From 8770569e1fc2f748f95938adb63f9ef9037c3c19 Mon Sep 17 00:00:00 2001 From: jeefo Date: Sat, 23 Aug 2025 16:50:32 +0300 Subject: [PATCH] fix: weapon firing with pistols after last commit --- inc/yapb.h | 1 + src/botlib.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/inc/yapb.h b/inc/yapb.h index d08d0b2..7c5cf45 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -737,6 +737,7 @@ public: public: void logic (); /// the things that can be executed while skipping frames + void upkeep (); void spawned (); void takeBlind (int alpha); void takeDamage (edict_t *inflictor, int damage, int armor, int bits); diff --git a/src/botlib.cpp b/src/botlib.cpp index 15fea23..3a9f837 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -3010,13 +3010,7 @@ void Bot::frame () { if (m_thinkTimer.time < game.time ()) { m_thinkTimer.time = game.time () + m_thinkTimer.interval; - if (m_aimFlags & AimFlags::Enemy) { - focusEnemy (); - } - doFireWeapons (); - updateLookAngles (); - - pev->flags |= FL_CLIENT | FL_FAKECLIENT; // restore fake client bit, just in case + upkeep (); if (m_fullThinkTimer.time < game.time ()) { m_fullThinkTimer.time = game.time () + m_fullThinkTimer.interval; @@ -3090,6 +3084,7 @@ void Bot::update () { if (m_lastDamageTimestamp < game.time () && !cr::fzero (m_lastDamageTimestamp)) { m_lastDamageTimestamp = 0.0f; } + pev->flags |= FL_CLIENT | FL_FAKECLIENT; // restore fake client bit, just in case // is bot movement enabled m_botMovement = false; @@ -3391,8 +3386,6 @@ void Bot::logic () { executeTasks (); // execute current task setAimDirection (); // choose aim direction - updateLookAngles (); // and turn to chosen aim direction - doFireWeapons (); // do weapon firing // check for reloading if (m_reloadCheckTime <= game.time ()) { @@ -3475,6 +3468,14 @@ void Bot::logic () { m_lastDamageType = -1; // reset damage } +void Bot::upkeep () { + if (m_aimFlags & AimFlags::Enemy) { + focusEnemy (); + } + doFireWeapons (); + updateLookAngles (); +} + void Bot::spawned () { if (game.is (GameFlags::CSDM | GameFlags::ZombieMod)) { newRound ();