]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Loopify more bot weapon stuff
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:02:33 +0000 (10:02 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:02:33 +0000 (10:02 +1000)
qcsrc/server/bot/havocbot/havocbot.qc

index e166f8b58ed13e37910ea091c7246a6d5a122098..09cfe4f1f932217e4c1fa63e944b7d90790a1073 100644 (file)
@@ -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;
        }