]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_nix.qc
Use SELFPARAM() in every function that uses self
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_nix.qc
index 26209daa11820df61c918b7f41a059725bf2b143..8cf0118d4e428465befc4f810012246f5b700b15 100644 (file)
@@ -1,6 +1,10 @@
-float g_nix_with_laser;
+#include "../_all.qh"
+
+#include "mutator.qh"
+
+float g_nix_with_blaster;
 // WEAPONTODO
-float nix_weapon;
+int nix_weapon;
 float nix_nextchange;
 float nix_nextweapon;
 .float nix_lastchange_id;
@@ -12,22 +16,22 @@ float NIX_CanChooseWeapon(float wpn)
        entity e;
        e = get_weaponinfo(wpn);
        if(!e.weapon) // skip dummies
-               return FALSE;
+               return false;
        if(g_weaponarena)
        {
                if(!(g_weaponarena_weapons & WepSet_FromWeapon(wpn)))
-                       return FALSE;
+                       return false;
        }
        else
        {
-               if(wpn == WEP_BLASTER && g_nix_with_laser) // WEAPONTODO: rename to g_nix_with_blaster
-                       return FALSE;
+               if(wpn == WEP_BLASTER.m_id && g_nix_with_blaster) // WEAPONTODO: rename to g_nix_with_blaster
+                       return false;
                if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
-                       return FALSE;
+                       return false;
                if (!(e.spawnflags & WEP_FLAG_NORMAL))
-                       return FALSE;
+                       return false;
        }
-       return TRUE;
+       return true;
 }
 void NIX_ChooseNextWeapon()
 {
@@ -40,7 +44,7 @@ void NIX_ChooseNextWeapon()
 }
 
 void NIX_GiveCurrentWeapon()
-{
+{SELFPARAM();
        float dt;
 
        if(!nix_nextweapon)
@@ -65,7 +69,7 @@ void NIX_GiveCurrentWeapon()
        if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round!
        {
                self.ammo_shells = self.ammo_nails = self.ammo_rockets = self.ammo_cells = self.ammo_plasma = self.ammo_fuel = 0;
-               
+
                if(self.items & IT_UNLIMITED_WEAPON_AMMO)
                {
                        switch(e.ammo_field)
@@ -137,13 +141,13 @@ void NIX_GiveCurrentWeapon()
        }
 
        self.weapons = '0 0 0';
-       if(g_nix_with_laser)
-               self.weapons &= ~WEPSET_BLASTER;
+       if(g_nix_with_blaster)
+               self.weapons |= WEPSET_BLASTER;
        self.weapons |= WepSet_FromWeapon(nix_weapon);
 
        if(self.switchweapon != nix_weapon)
-               if(!client_hasweapon(self, self.switchweapon, TRUE, FALSE))
-                       if(client_hasweapon(self, nix_weapon, TRUE, FALSE))
+               if(!client_hasweapon(self, self.switchweapon, true, false))
+                       if(client_hasweapon(self, nix_weapon, true, false))
                                W_SwitchWeapon(nix_weapon);
 }
 
@@ -173,19 +177,22 @@ MUTATOR_HOOKFUNCTION(nix_BuildMutatorsPrettyString)
 }
 
 MUTATOR_HOOKFUNCTION(nix_FilterItem)
-{
+{SELFPARAM();
        switch (self.items)
        {
-               case IT_HEALTH:
-               case IT_5HP:
-               case IT_25HP:
-               case IT_ARMOR:
-               case IT_ARMOR_SHARD:
+               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 0;
                        break;
-               case IT_STRENGTH:
-               case IT_INVINCIBLE:
+               case ITEM_Strength.m_itemid:
+               case ITEM_Shield.m_itemid:
                        if (autocvar_g_nix_with_powerups)
                                return 0;
                        break;
@@ -195,14 +202,14 @@ MUTATOR_HOOKFUNCTION(nix_FilterItem)
 }
 
 MUTATOR_HOOKFUNCTION(nix_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo)
                return 1;
        return 0;
 }
 
 MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
-{
+{SELFPARAM();
        if(!intermission_running)
        if(self.deadflag == DEAD_NO)
        if(IS_PLAYER(self))
@@ -211,7 +218,7 @@ MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(nix_PlayerSpawn)
-{
+{SELFPARAM();
        self.nix_lastchange_id = -1;
        NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning
        self.items |= IT_UNLIMITED_SUPERWEAPONS;
@@ -225,7 +232,7 @@ MUTATOR_HOOKFUNCTION(nix_SetModname)
 }
 
 MUTATOR_DEFINITION(mutator_nix)
-{
+{SELFPARAM();
        entity e;
 
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, nix_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
@@ -239,7 +246,7 @@ MUTATOR_DEFINITION(mutator_nix)
 
        MUTATOR_ONADD
        {
-               g_nix_with_laser = autocvar_g_nix_with_laser;
+               g_nix_with_blaster = autocvar_g_nix_with_blaster;
 
                nix_nextchange = 0;
                nix_nextweapon = 0;
@@ -265,7 +272,7 @@ MUTATOR_DEFINITION(mutator_nix)
                        e.ammo_rockets = start_ammo_rockets;
                        e.ammo_fuel = start_ammo_fuel;
                        e.weapons = start_weapons;
-                       if(!client_hasweapon(e, e.weapon, TRUE, FALSE))
+                       if(!client_hasweapon(e, e.weapon, true, false))
                                e.switchweapon = w_getbestweapon(self);
                }
        }