feat: removed transitions to chase state

main
Sara 2024-12-25 18:25:26 +01:00
parent c7ae756776
commit e40afcae5d
1 changed files with 5 additions and 3 deletions

View File

@ -88,7 +88,7 @@ Enemy::ActionFn Enemy::wait_end_of_shot() {
this->target_rotation = gd::Vector3{0.f, 0.f, 1.f}.signed_angle_to(this->last_known_player_position - this->aim_offset_position(), {0.f, 1.f, 0.f}); this->target_rotation = gd::Vector3{0.f, 0.f, 1.f}.signed_angle_to(this->last_known_player_position - this->aim_offset_position(), {0.f, 1.f, 0.f});
if(this->at_target_angle && !this->anim_tree->get_current_state().begins_with("Fire") && !this->anim_tree->get_fire_weapon()) if(this->at_target_angle && !this->anim_tree->get_current_state().begins_with("Fire") && !this->anim_tree->get_fire_weapon())
return this->shots_fired < this->SHOTS_BEFORE_MOVE ? (ActionFn)&Enemy::fire : (ActionFn)&Enemy::chase_enter; return this->shots_fired < this->SHOTS_BEFORE_MOVE ? (ActionFn)&Enemy::fire : (ActionFn)&Enemy::wait_line_of_sight;
return (ActionFn)&Enemy::wait_end_of_shot; return (ActionFn)&Enemy::wait_end_of_shot;
} }
@ -108,7 +108,7 @@ Enemy::ActionFn Enemy::wait_end_of_stab() {
float const target_diff{this->get_global_basis().get_column(2).signed_angle_to(this->last_known_player_position - this->aim_offset_position(), {0.f, 1.f, 0.f})}; float const target_diff{this->get_global_basis().get_column(2).signed_angle_to(this->last_known_player_position - this->aim_offset_position(), {0.f, 1.f, 0.f})};
this->target_rotation = this->get_global_rotation().y + target_diff; this->target_rotation = this->get_global_rotation().y + target_diff;
if(this->at_target_angle && !this->anim_tree->get_current_state().begins_with("Stab") && !this->anim_tree->get_fire_weapon()) if(this->at_target_angle && !this->anim_tree->get_current_state().begins_with("Stab") && !this->anim_tree->get_fire_weapon())
return this->is_in_stab_range() ? (ActionFn)&Enemy::chase_enter : (ActionFn)&Enemy::stab; return this->is_in_stab_range() ? (ActionFn)&Enemy::stab : (ActionFn)&Enemy::wait_line_of_sight;
return (ActionFn)&Enemy::wait_end_of_stab; return (ActionFn)&Enemy::wait_end_of_stab;
} }
@ -139,7 +139,9 @@ Enemy::ActionFn Enemy::stop_running() {
this->set_current_state_name("Chase (stop)"); this->set_current_state_name("Chase (stop)");
this->agent->set_target_position(this->get_global_position()); this->agent->set_target_position(this->get_global_position());
this->agent->set_avoidance_priority(this->STATIONARY_NAV_PRIORITY); this->agent->set_avoidance_priority(this->STATIONARY_NAV_PRIORITY);
return this->anim_tree->get_current_state().begins_with("Run") ? (ActionFn)&Enemy::stop_running : (ActionFn)&Enemy::wait_line_of_sight; return this->anim_tree->get_current_state().begins_with("Run") && this->get_global_rotation().y == this->target_rotation
? (ActionFn)&Enemy::stop_running
: (ActionFn)&Enemy::wait_line_of_sight;
} }
void Enemy::_physics_process(double delta) { void Enemy::_physics_process(double delta) {