diff --git a/src/botlib.cpp b/src/botlib.cpp index 19e4651..0875015 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -122,10 +122,6 @@ bool Bot::seesEntity (const Vector &dest, bool fromBody) { void Bot::avoidGrenades () { // checks if bot 'sees' a grenade, and avoid it - if (!bots.hasActiveGrenades ()) { - return; - } - // check if old pointers to grenade is invalid if (game.isNullEntity (m_avoidGrenade)) { m_avoidGrenade = nullptr; @@ -135,6 +131,10 @@ void Bot::avoidGrenades () { m_avoidGrenade = nullptr; m_needAvoidGrenade = 0; } + + if (!bots.hasActiveGrenades ()) { + return; + } auto &activeGrenades = bots.getActiveGrenades (); // find all grenades on the map @@ -158,11 +158,7 @@ void Bot::avoidGrenades () { m_preventFlashing = game.time () + rg.get (1.0f, 2.0f); } } - else if (strcmp (model, "hegrenade.mdl") == 0) { - if (!game.isNullEntity (m_avoidGrenade)) { - continue; - } - + else if (game.isNullEntity (m_avoidGrenade) && strcmp (model, "hegrenade.mdl") == 0) { if (game.getTeam (pent->v.owner) == m_team || pent->v.owner == ent ()) { continue; }