]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/nix/sv_nix.qc
Merge branch 'master' into Mario/wepent_experimental
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nix / sv_nix.qc
index 8067f791a7e44a5a00f890aff4fc60e0184ac18e..a06f5364d4473bf673cfcfa29aff140c8f3442de 100644 (file)
@@ -63,9 +63,14 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
                        it.ammo_rockets = start_ammo_rockets;
                        it.ammo_fuel = start_ammo_fuel;
                        it.weapons = start_weapons;
-                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-                       if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
-                               it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity);
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                       {
+                               .entity weaponentity = weaponentities[slot];
+                               if(it.(weaponentity).m_weapon == WEP_Null && slot != 0)
+                                       continue;
+                               if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
+                                       it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity);
+                       }
                });
        }
 
@@ -97,7 +102,7 @@ void NIX_ChooseNextWeapon()
        RandomSelection_Init();
        FOREACH(Weapons, it != WEP_Null, LAMBDA(
                if(NIX_CanChooseWeapon(it.m_id))
-                       RandomSelection_Add(NULL, it.m_id, string_null, 1, (it.m_id != nix_weapon));
+                       RandomSelection_AddFloat(it.m_id, 1, (it.m_id != nix_weapon));
        ));
        nix_nextweapon = RandomSelection_chosen_float;
 }
@@ -215,14 +220,20 @@ void NIX_GiveCurrentWeapon(entity this)
                this.weapons |= WEPSET(BLASTER);
        this.weapons |= e.m_wepset;
 
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
     Weapon w = Weapons_from(nix_weapon);
-       if(this.(weaponentity).m_switchweapon != w)
+    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+    {
+       .entity weaponentity = weaponentities[slot];
+       if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
+               continue;
+
+               if(this.(weaponentity).m_switchweapon != w)
                if(!client_hasweapon(this, this.(weaponentity).m_switchweapon, weaponentity, true, false))
                {
                        if(client_hasweapon(this, w, weaponentity, true, false))
                                W_SwitchWeapon(this, w, weaponentity);
                }
+       }
 }
 
 MUTATOR_HOOKFUNCTION(nix, ForbidThrowCurrentWeapon)
@@ -244,24 +255,13 @@ MUTATOR_HOOKFUNCTION(nix, FilterItem)
 {
        entity item = M_ARGV(0, entity);
 
-       switch (item.items)
+       if(item.itemdef.instanceOfHealth || item.itemdef.instanceOfArmor)
+       {
+               return !autocvar_g_nix_with_healtharmor;
+       }
+       else if(item.itemdef.instanceOfPowerup)
        {
-               case ITEM_HealthSmall.m_itemid:
-               case ITEM_HealthMedium.m_itemid:
-               case ITEM_HealthLarge.m_itemid:
-               case ITEM_HealthMega.m_itemid:
-               case ITEM_ArmorSmall.m_itemid:
-               case ITEM_ArmorMedium.m_itemid:
-               case ITEM_ArmorLarge.m_itemid:
-               case ITEM_ArmorMega.m_itemid:
-                       if (autocvar_g_nix_with_healtharmor)
-                               return false;
-                       break;
-               case ITEM_Strength.m_itemid:
-               case ITEM_Shield.m_itemid:
-                       if (autocvar_g_nix_with_powerups)
-                               return false;
-                       break;
+               return !autocvar_g_nix_with_powerups;
        }
 
        return true; // delete all other items