17 double relax_distance,
float flee_wt){
21 _flee_position = target_object.
get_pos(_ai_char->_window_render);
22 _flee_distance = panic_distance;
23 _flee_weight = flee_wt;
24 _flee_relax_distance = relax_distance;
27 _flee_activate_done =
false;
30 Flee::Flee(
AICharacter *ai_ch, LVecBase3 pos,
double panic_distance,
31 double relax_distance,
float flee_wt){
36 _flee_distance = panic_distance;
37 _flee_weight = flee_wt;
38 _flee_relax_distance = relax_distance;
41 _flee_activate_done =
false;
56 LVecBase3 desired_force;
58 dirn = _ai_char->_ai_char_np.
get_pos(_ai_char->_window_render) - _flee_present_pos;
59 distance = dirn.length();
60 desired_force = _flee_direction * _ai_char->_movt_force;
62 if(distance > (_flee_distance + _flee_relax_distance)) {
63 if((_ai_char->_steering->_behaviors_flags | _ai_char->_steering->_flee) == _ai_char->_steering->_flee) {
64 _ai_char->_steering->_steering_force = LVecBase3(0.0, 0.0, 0.0);
67 _ai_char->_steering->
turn_off(
"flee");
68 _ai_char->_steering->
turn_on(
"flee_activate");
69 return(LVecBase3(0.0, 0.0, 0.0));
72 return(desired_force);
85 _flee_activate_done =
false;
87 dirn = (_ai_char->_ai_char_np.
get_pos(_ai_char->_window_render) - _flee_position);
88 distance = dirn.length();
90 if(distance < _flee_distance) {
91 _flee_direction = _ai_char->_ai_char_np.
get_pos(_ai_char->_window_render) - _flee_position;
92 _flee_direction.normalize();
93 _flee_present_pos = _ai_char->_ai_char_np.
get_pos(_ai_char->_window_render);
94 _ai_char->_steering->
turn_off(
"flee_activate");
95 _ai_char->_steering->
turn_on(
"flee");
96 _flee_activate_done =
true;
void turn_on(std::string ai_type)
This function turns on any aiBehavior which is passed as a string.
void turn_off(std::string ai_type)
This function turns off any aiBehavior which is passed as a string.
LVecBase3 do_flee()
This function performs the flee and returns a flee force which is used in the calculate_prioritized f...
LPoint3 get_pos() const
Retrieves the translation component of the transform.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void flee_activate()
This function checks for whether the target is within the panic distance.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...