From 935070c6b436d6991487d1d9da02b461e24d4d78 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 26 Dec 2024 21:55:11 +0100 Subject: [PATCH] feat: fixed stabbing attack trigger --- src/enemy.cpp | 7 +++++-- src/enemy.hpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/enemy.cpp b/src/enemy.cpp index c671364..71552fe 100644 --- a/src/enemy.cpp +++ b/src/enemy.cpp @@ -86,9 +86,12 @@ Enemy::ActionFn Enemy::fire() { Enemy::ActionFn Enemy::wait_end_of_shot() { this->set_current_state_name("Shoot (wait)"); 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::wait_line_of_sight; + return this->is_in_stab_range() + ? (ActionFn)&Enemy::stab + : (this->shots_fired < this->SHOTS_BEFORE_MOVE + ? (ActionFn)&Enemy::fire + : (ActionFn)&Enemy::wait_line_of_sight); return (ActionFn)&Enemy::wait_end_of_shot; } diff --git a/src/enemy.hpp b/src/enemy.hpp index 6ef0a41..2ecf974 100644 --- a/src/enemy.hpp +++ b/src/enemy.hpp @@ -45,7 +45,7 @@ private: float const AIM_SPEED{8.f}; float const TURN_SPEED{10.f}; float const AIM_OFFSET{-0.18f}; - float const STAB_RANGE{2.f}; + float const STAB_RANGE{3.5f}; float const MOVING_NAV_PRIORITY{.5f}; float const STATIONARY_NAV_PRIORITY{1.f};