From: Mario Date: Thu, 24 Dec 2015 00:02:33 +0000 (+1000) Subject: Loopify more bot weapon stuff X-Git-Tag: xonotic-v0.8.2~1439 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fa2a7c0af1a94d0425d8a12cc617ea4bece7877f;p=xonotic%2Fxonotic-data.pk3dir.git Loopify more bot weapon stuff --- diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index e166f8b58..09cfe4f1f 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -990,14 +990,11 @@ float havocbot_chooseweapon_checkreload(int new_weapon) // if this weapon is scheduled for reloading, don't switch to it during combat if (self.weapon_load[new_weapon] < 0) { - float i, other_weapon_available = false; - for(i = WEP_FIRST; i <= WEP_LAST; ++i) - { - Weapon w = Weapons_from(i); - // if we are out of ammo for all other weapons, it's an emergency to switch to anything else - if (w.wr_checkammo1(w) + w.wr_checkammo2(w)) + bool other_weapon_available = false; + FOREACH(Weapons, it != WEP_Null, LAMBDA( + if(it.wr_checkammo1(it) + it.wr_checkammo2(it)) other_weapon_available = true; - } + )); if(other_weapon_available) return true; } @@ -1021,14 +1018,13 @@ void havocbot_chooseweapon() { // If no weapon was chosen get the first available weapon if(PS(self).m_weapon==WEP_Null) - for(i = WEP_FIRST; i <= WEP_LAST; ++i) if(i != WEP_BLASTER.m_id) - { - if(client_hasweapon(self, Weapons_from(i), true, false)) + FOREACH(Weapons, it != WEP_Null, LAMBDA( + if(client_hasweapon(self, it, true, false)) { - PS(self).m_switchweapon = Weapons_from(i); + PS(self).m_switchweapon = it; return; } - } + )); return; }