]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix another hardcoded slot 0 case
authorMario <mario@smbclan.net>
Wed, 5 Oct 2016 10:59:45 +0000 (20:59 +1000)
committerMario <mario@smbclan.net>
Wed, 5 Oct 2016 10:59:45 +0000 (20:59 +1000)
qcsrc/server/bot/default/scripting.qc

index 6b3ab1e4b05d2de7a41bbdbbc54244356c4f7318..66dc91b2592eedb79cb180abec127c7e8f6968a6 100644 (file)
@@ -568,11 +568,22 @@ float bot_cmd_select_weapon(entity this)
        if(id < WEP_FIRST || id > WEP_LAST)
                return CMD_STATUS_ERROR;
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       bool success = false;
 
-       if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
-               this.(weaponentity).m_switchweapon = Weapons_from(id);
-       else
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
+                       continue;
+
+               if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
+               {
+                       success = true;
+                       this.(weaponentity).m_switchweapon = Weapons_from(id);
+               }
+       }
+
+       if(!success)
                return CMD_STATUS_ERROR;
 
        return CMD_STATUS_FINISHED;