From e40afcae5d84952e2b1470486b4a20d8a57acc3c Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 25 Dec 2024 18:25:26 +0100 Subject: [PATCH] feat: removed transitions to chase state --- src/enemy.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/enemy.cpp b/src/enemy.cpp index 9e7c83c..c671364 100644 --- a/src/enemy.cpp +++ b/src/enemy.cpp @@ -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}); 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; } @@ -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})}; 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()) - 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; } @@ -139,7 +139,9 @@ Enemy::ActionFn Enemy::stop_running() { this->set_current_state_name("Chase (stop)"); this->agent->set_target_position(this->get_global_position()); 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) {