diff --git a/include/yapb.h b/include/yapb.h index e09d8e0..232ff75 100644 --- a/include/yapb.h +++ b/include/yapb.h @@ -582,6 +582,7 @@ private: float m_headedTime; float m_prevTime; // time previously checked movement speed + float m_heavyTimestamp; // is it time to execute heavy-weight functions float m_prevSpeed; // speed some frames before float m_timeDoorOpen; // time to next door open check float m_lastChatTime; // time bot last chatted @@ -758,6 +759,7 @@ private: bool isReachableNode (int index); bool updateLiftHandling (); bool updateLiftStates (); + bool canRunHeavyWeight (); void instantChatter (int type); void update (); diff --git a/source/basecode.cpp b/source/basecode.cpp index 71dbc25..ad3c968 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -1834,7 +1834,6 @@ void Bot::setConditions () { // check if there are items needing to be used/collected if (m_itemCheckTime < game.time () || !game.isNullEntity (m_pickupItem)) { - updatePickups (); m_itemCheckTime = game.time () + 0.5f; } @@ -4735,7 +4734,9 @@ void Bot::logic () { } // do all sensing, calculate/filter all actions here - setConditions (); + if (canRunHeavyWeight ()) { + setConditions (); + } // some stuff required by by chatter engine if (yb_radio_mode.int_ () == 2) { @@ -5504,6 +5505,17 @@ uint8 Bot::computeMsec () { return static_cast ((game.time () - m_lastCommandTime) * 1000.0f); } +bool Bot::canRunHeavyWeight () { + constexpr auto interval = 1.0f / 10.0f; + + if (m_heavyTimestamp + interval < game.time ()) { + m_heavyTimestamp = game.time (); + + return true; + } + return false; +} + void Bot::runMovement () { // the purpose of this function is to compute, according to the specified computation // method, the msec value which will be passed as an argument of pfnRunPlayerMove. This diff --git a/source/combat.cpp b/source/combat.cpp index 579b7be..f16bcb6 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -96,6 +96,7 @@ bool Bot::checkBodyParts (edict_t *target) { return false; } + TraceResult result; auto eyes = getEyesPos (); diff --git a/source/manager.cpp b/source/manager.cpp index ae96991..0a8e912 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -854,6 +854,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member) { m_lastCommandTime = game.time () - 0.1f; m_frameInterval = game.time (); + m_heavyTimestamp = game.time (); m_slowFrameTimestamp = 0.0f; // stuff from jk_botti