]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Loopify bot weapon reloading
authorMario <mario@smbclan.net>
Wed, 23 Dec 2015 23:58:08 +0000 (09:58 +1000)
committerMario <mario@smbclan.net>
Wed, 23 Dec 2015 23:58:08 +0000 (09:58 +1000)
qcsrc/server/bot/havocbot/havocbot.qc

index 9f91db1f86329e780d460b65e8802a420e424a97..088ac899cc83440464af2022e3d6b1b664fe2374 100644 (file)
@@ -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;
+                       ));
                }
        }
 }