19 double relax_distance,
float evade_wt) {
22 _evade_target = target_object;
23 _evade_distance = panic_distance;
24 _evade_relax_distance = relax_distance;
25 _evade_weight = evade_wt;
28 _evade_activate_done =
false;
46 assert(_evade_target &&
"evade target not assigned");
48 _evade_direction = _ai_char->_ai_char_np.
get_pos(_ai_char->_window_render) - _evade_target.
get_pos(_ai_char->_window_render);
49 double distance = _evade_direction.
length();
52 LVecBase3 desired_force = _evade_direction * _ai_char->_movt_force;
54 if(distance > (_evade_distance + _evade_relax_distance)) {
55 if((_ai_char->_steering->_behaviors_flags | _ai_char->_steering->_evade) == _ai_char->_steering->_evade) {
56 _ai_char->_steering->_steering_force =
LVecBase3(0.0, 0.0, 0.0);
58 _ai_char->_steering->
turn_off(
"evade");
59 _ai_char->_steering->
turn_on(
"evade_activate");
65 return(desired_force);
79 _evade_direction = (_ai_char->_ai_char_np.
get_pos(_ai_char->_window_render) - _evade_target.
get_pos(_ai_char->_window_render));
80 double distance = _evade_direction.
length();
81 _evade_activate_done =
false;
83 if(distance < _evade_distance) {
84 _ai_char->_steering->
turn_off(
"evade_activate");
85 _ai_char->_steering->
turn_on(
"evade");
86 _evade_activate_done =
true;
This is the base class for all three-component vectors and points.
LVecBase3 do_evade()
This function performs the evade and returns an evade force which is used in the calculate_prioritize...
void turn_off(string ai_type)
This function turns off any aiBehavior which is passed as a string.
LPoint3 get_pos() const
Retrieves the translation component of the transform.
void turn_on(string ai_type)
This function turns on any aiBehavior which is passed as a string.
float length() const
Returns the length of the vector, by the Pythagorean theorem.
void evade_activate()
This function checks for whether the target is within the panic distance.
bool normalize()
Normalizes the vector in place.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...