]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_instagib.qc
Replace all direct assignments to self with setself(e)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_instagib.qc
index 161dba90deb0c68d22f65ee5e65b96d4cf87de33..30810c82e4c7f84f6ec99de7df65f07b6afc8036 100644 (file)
@@ -5,50 +5,10 @@
 #include "../cl_client.qh"
 #include "../../common/buffs.qh"
 
-#include "../../common/items/item.qh"
-
-#define WITH(it) this.m_##it;
-#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-
-float instagib_respawntime_ammo = 45;
-float instagib_respawntimejitter_ammo = 0;
-GETTER(float, instagib_respawntime_ammo)
-GETTER(float, instagib_respawntimejitter_ammo)
-
-REGISTER_ITEM(VaporizerCells, Pickup, APPLY(UNWORDS
-    ,APPLY(CONFIGURE
-    ,   model               =   "models/items/a_cells.md3"
-    ,   sound               =   "misc/itempickup.wav"
-    ,   name                =   "Vaporizer Ammo"
-    )
-    ,IF(SV, CONFIGURE
-    ,   botvalue            =   100
-    ,   itemid              =   IT_CELLS
-    ,   respawntime         =         GET(instagib_respawntime_ammo)
-    ,   respawntimejitter   =   GET(instagib_respawntimejitter_ammo)
-    )
-))
-
-REGISTER_ITEM(ExtraLife, Pickup, APPLY(UNWORDS
-    ,APPLY(CONFIGURE
-    ,   model               =   "models/items/g_h100.md3"
-    ,   sound               =   "misc/megahealth.wav"
-    ,   name                =   "Extralife"
-    )
-    ,IF(SV, CONFIGURE
-    ,   botvalue            =   BOT_PICKUP_RATING_HIGH
-    ,   itemflags           =   FL_POWERUP
-    ,   itemid              =   IT_NAILS
-    ,   respawntime         =         GET(g_pickup_respawntime_powerup)
-    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup)
-    )
-))
-
-#undef WITH
-#undef CONFIGURE
+#include "../../common/items/all.qc"
 
 void spawnfunc_item_minst_cells (void)
-{
+{SELFPARAM();
        if (!g_instagib) { remove(self); return; }
        if (!self.ammo_cells)
                self.ammo_cells = autocvar_g_instagib_ammo_drop;
@@ -57,7 +17,7 @@ void spawnfunc_item_minst_cells (void)
 }
 
 void instagib_health_mega()
-{
+{SELFPARAM();
        self.max_health = 1;
        StartItemA (ITEM_ExtraLife);
 }
@@ -72,7 +32,7 @@ void instagib_stop_countdown(entity e)
        e.instagib_needammo = false;
 }
 void instagib_ammocheck()
-{
+{SELFPARAM();
        if(time < self.instagib_nextthink)
                return;
        if(!IS_PLAYER(self))
@@ -82,6 +42,14 @@ void instagib_ammocheck()
                instagib_stop_countdown(self);
        else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
                instagib_stop_countdown(self);
+       else if(autocvar_g_rm && autocvar_g_rm_laser)
+       {
+               if(!self.instagib_needammo)
+               {
+                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
+                       self.instagib_needammo = true;
+               }
+       }
        else
        {
                self.instagib_needammo = true;
@@ -162,9 +130,9 @@ MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
-{
+{SELFPARAM();
        // always refill ammo
-       if(self.monsterid == MON_MAGE)
+       if(self.monsterid == MON_MAGE.monsterid)
                self.skin = 1;
 
        return false;
@@ -172,20 +140,20 @@ MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
 
 MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
 {
-       if(checkentity.items & IT_STRENGTH)
+       if(checkentity.items & ITEM_Strength.m_itemid)
                return true;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
-{
+{SELFPARAM();
        instagib_stop_countdown(self);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
-{
+{SELFPARAM();
        self.effects |= EF_FULLBRIGHT;
        return false;
 }
@@ -203,18 +171,18 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
-{
+{SELFPARAM();
        if (!(self.effects & EF_FULLBRIGHT))
                self.effects |= EF_FULLBRIGHT;
 
-       if (self.items & IT_STRENGTH)
+       if (self.items & ITEM_Strength.m_itemid)
        {
                play_countdown(self.strength_finished, "misc/poweroff.wav");
                if (time > self.strength_finished)
                {
                        self.alpha = default_player_alpha;
                        self.exteriorweaponentity.alpha = default_weapon_alpha;
-                       self.items &= ~IT_STRENGTH;
+                       self.items &= ~ITEM_Strength.m_itemid;
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
                }
        }
@@ -224,18 +192,18 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
                {
                        self.alpha = autocvar_g_instagib_invis_alpha;
                        self.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
-                       self.items |= IT_STRENGTH;
+                       self.items |= ITEM_Strength.m_itemid;
                        Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, self.netname);
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
                }
        }
 
-       if (self.items & IT_INVINCIBLE)
+       if (self.items & ITEM_Shield.m_itemid)
        {
                play_countdown(self.invincible_finished, "misc/poweroff.wav");
                if (time > self.invincible_finished)
                {
-                       self.items &= ~IT_INVINCIBLE;
+                       self.items &= ~ITEM_Shield.m_itemid;
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
                }
        }
@@ -243,7 +211,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
        {
                if (time < self.invincible_finished)
                {
-                       self.items |= IT_INVINCIBLE;
+                       self.items |= ITEM_Shield.m_itemid;
                        Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, self.netname);
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
                }
@@ -252,8 +220,8 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
-{
-       if(self.items & IT_INVINCIBLE)
+{SELFPARAM();
+       if(self.items & ITEM_Shield.m_itemid)
                self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
 
        return false;
@@ -290,7 +258,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
                }
 
                if(IS_PLAYER(frag_attacker))
-               if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
+               if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
                {
                        if(frag_target.armorvalue)
                        {
@@ -302,7 +270,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
                        }
                }
 
-               if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
+               if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER.m_id))
                {
                        if(frag_deathtype & HITTYPE_SECONDARY)
                        {
@@ -330,7 +298,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
                frag_mirrordamage = 0;
        }
 
-       if((frag_target.buffs & BUFF_INVISIBLE) || (frag_target.items & IT_STRENGTH))
+       if((frag_target.buffs & BUFF_INVISIBLE.m_itemid) || (frag_target.items & ITEM_Strength.m_itemid))
                yoda = 1;
 
        return false;
@@ -355,25 +323,22 @@ MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
-{
+{SELFPARAM();
        if(self.classname == "item_cells")
                return true; // no normal cells?
 
-       if(self.weapon == WEP_VAPORIZER && self.classname == "droppedweapon")
+       if(self.weapon == WEP_VAPORIZER.m_id && self.classname == "droppedweapon")
        {
                self.ammo_cells = autocvar_g_instagib_ammo_drop;
                return false;
        }
 
-       if(self.weapon == WEP_DEVASTATOR || self.weapon == WEP_VORTEX)
+       if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id)
        {
                entity e = spawn();
                setorigin(e, self.origin);
-               entity oldself;
-               oldself = self;
-               self = e;
-               spawnfunc_item_minst_cells();
-               self = oldself;
+               SELFCALL(e, spawnfunc_item_minst_cells());
+               SELFCALL_DONE();
                return true;
        }
 
@@ -390,12 +355,12 @@ MUTATOR_HOOKFUNCTION(instagib_FilterItem)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
-{
+{SELFPARAM();
        entity e = WaypointSprite_getviewentity(other);
 
        // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
        // but only apply this to real players, not to spectators
-       if((self.owner.flags & FL_CLIENT) && (self.owner.items & IT_STRENGTH) && (e == other))
+       if((self.owner.flags & FL_CLIENT) && (self.owner.items & ITEM_Strength.m_itemid) && (e == other))
        if(DIFF_TEAM(self.owner, e))
                return true;
 
@@ -403,18 +368,18 @@ MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_ItemCountdown)
-{
-       switch(self.items)
+{SELFPARAM();
+       switch (self.items)
        {
-               case IT_STRENGTH:   item_name = "item-invis"; item_color = '0 0 1'; break;
-               case IT_NAILS:      item_name = "item-extralife"; item_color = '1 0 0'; break;
-               case IT_INVINCIBLE: item_name = "item-speed"; item_color = '1 0 1'; break;
+               case ITEM_Strength.m_itemid:  item_name = "item-invis";     item_color = '0 0 1'; break;
+               case ITEM_ExtraLife.m_itemid: item_name = "item-extralife"; item_color = '1 0 0'; break;
+               case ITEM_Shield.m_itemid:    item_name = "item-speed";     item_color = '1 0 1'; break;
        }
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
-{
+{SELFPARAM();
        if(self.ammo_cells)
        {
                // play some cool sounds ;)
@@ -443,9 +408,9 @@ MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if (!autocvar_g_powerups) { return false; }
-       if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
+       if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.itemdef == ITEM_HealthMega))
                return false;
 
        entity e = spawn();