From cb01fd2a2b31c3cdc905e665480252a24a7e4284 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Dec 2015 09:58:08 +1000 Subject: [PATCH] Loopify bot weapon reloading --- qcsrc/server/bot/havocbot/havocbot.qc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index 9f91db1f8..088ac899c 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -171,12 +171,10 @@ void havocbot_ai() if(skill >= 5) // bots can only look for unloaded weapons past this skill if(self.clip_load >= 0) // only if we're not reloading a weapon already { - for (int i = WEP_FIRST; i <= WEP_LAST; ++i) - { - entity e = Weapons_from(i); - if ((self.weapons & (e.m_wepset)) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < e.reloading_ammo)) - PS(self).m_switchweapon = Weapons_from(i); - } + FOREACH(Weapons, it != WEP_Null, LAMBDA( + if((self.weapons & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[it.m_id] < it.reloading_ammo)) + PS(self).m_switchweapon = it.m_id; + )); } } } -- 2.39.2