]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/instagib/instagib.qc
Cleanse the physics hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / instagib / instagib.qc
index fa8ce973477430f05415cc5e750a2293fa810232..ef1856d688dd3f17487017e9ac171d1bee8e5513 100644 (file)
@@ -145,32 +145,39 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, MatchEnd)
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterDropItem)
 {
-       other.monster_loot = spawnfunc_item_minst_cells;
+       entity item = M_ARGV(1, entity);
+
+       item.monster_loot = spawnfunc_item_minst_cells;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterSpawn)
-{SELFPARAM();
+{
+       entity mon = M_ARGV(0, entity);
+
        // always refill ammo
-       if(self.monsterid == MON_MAGE.monsterid)
-               self.skin = 1;
+       if(mon.monsterid == MON_MAGE.monsterid)
+               mon.skin = 1;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, BotShouldAttack)
 {
-       if (checkentity.items & ITEM_Invisibility.m_itemid)
+       entity targ = M_ARGV(1, entity);
+
+       if (targ.items & ITEM_Invisibility.m_itemid)
                return true;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, MakePlayerObserver)
-{SELFPARAM();
-       instagib_stop_countdown(self);
-       return false;
+{
+       entity player = M_ARGV(0, entity);
+
+       instagib_stop_countdown(player);
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerSpawn)
@@ -193,70 +200,69 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerRegen)
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
-{SELFPARAM();
-       if (!(self.effects & EF_FULLBRIGHT))
-               self.effects |= EF_FULLBRIGHT;
+{
+       entity player = M_ARGV(0, entity);
 
-       if (self.items & ITEM_Invisibility.m_itemid)
+       if (!(player.effects & EF_FULLBRIGHT))
+               player.effects |= EF_FULLBRIGHT;
+
+       if (player.items & ITEM_Invisibility.m_itemid)
        {
-               play_countdown(self.strength_finished, SND_POWEROFF);
-               if (time > self.strength_finished)
+               play_countdown(player.strength_finished, SND_POWEROFF);
+               if (time > player.strength_finished)
                {
-                       self.alpha = default_player_alpha;
-                       self.exteriorweaponentity.alpha = default_weapon_alpha;
-                       self.items &= ~ITEM_Invisibility.m_itemid;
-                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
+                       player.alpha = default_player_alpha;
+                       player.exteriorweaponentity.alpha = default_weapon_alpha;
+                       player.items &= ~ITEM_Invisibility.m_itemid;
+                       Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
                }
        }
        else
        {
-               if (time < self.strength_finished)
+               if (time < player.strength_finished)
                {
-                       self.alpha = autocvar_g_instagib_invis_alpha;
-                       self.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
-                       self.items |= ITEM_Invisibility.m_itemid;
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, self.netname);
-                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
+                       player.alpha = autocvar_g_instagib_invis_alpha;
+                       player.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
+                       player.items |= ITEM_Invisibility.m_itemid;
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, player.netname);
+                       Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
                }
        }
 
-       if (self.items & ITEM_Speed.m_itemid)
+       if (player.items & ITEM_Speed.m_itemid)
        {
-               play_countdown(self.invincible_finished, SND_POWEROFF);
-               if (time > self.invincible_finished)
+               play_countdown(player.invincible_finished, SND_POWEROFF);
+               if (time > player.invincible_finished)
                {
-                       self.items &= ~ITEM_Speed.m_itemid;
-                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
+                       player.items &= ~ITEM_Speed.m_itemid;
+                       Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_POWERDOWN_SPEED);
                }
        }
        else
        {
-               if (time < self.invincible_finished)
+               if (time < player.invincible_finished)
                {
-                       self.items |= ITEM_Speed.m_itemid;
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, self.netname);
-                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
+                       player.items |= ITEM_Speed.m_itemid;
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, player.netname);
+                       Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_POWERUP_SPEED);
                }
        }
-       return false;
 }
 
 .float stat_sv_maxspeed;
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPhysics)
-{SELFPARAM();
-       if(self.items & ITEM_Speed.m_itemid)
-               self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
+{
+       entity player = M_ARGV(0, entity);
 
-       return false;
+       if(player.items & ITEM_Speed.m_itemid)
+               player.stat_sv_maxspeed = player.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_SplitHealthArmor)
 {
-       damage_save = 0;
-       damage_take = frag_damage;
-
-       return false;
+       M_ARGV(4, float) = M_ARGV(7, float); // take = damage
+       M_ARGV(5, float) = 0; // save
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, ForbidThrowCurrentWeapon)
@@ -374,48 +380,53 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem)
-{SELFPARAM();
-       if(self.classname == "item_cells")
+{
+       entity item = M_ARGV(0, entity);
+
+       if(item.classname == "item_cells")
                return true; // no normal cells?
 
-       if(self.weapon == WEP_VAPORIZER.m_id && self.classname == "droppedweapon")
+       if(item.weapon == WEP_VAPORIZER.m_id && item.classname == "droppedweapon")
        {
-               self.ammo_cells = autocvar_g_instagib_ammo_drop;
+               item.ammo_cells = autocvar_g_instagib_ammo_drop;
                return false;
        }
 
-       if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id)
+       if(item.weapon == WEP_DEVASTATOR.m_id || item.weapon == WEP_VORTEX.m_id)
        {
                entity e = spawn();
-               setorigin(e, self.origin);
-               e.noalign = self.noalign;
-        e.cnt = self.cnt;
-        e.team = self.team;
+               setorigin(e, item.origin);
+               e.noalign = item.noalign;
+        e.cnt = item.cnt;
+        e.team = item.team;
         e.spawnfunc_checked = true;
                WITHSELF(e, spawnfunc_item_minst_cells(e));
                return true;
        }
 
-       if(self.flags & FL_POWERUP)
+       if(item.flags & FL_POWERUP)
                return false;
 
-       if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells")
-               self.ammo_cells = autocvar_g_instagib_ammo_drop;
+       if(item.ammo_cells > autocvar_g_instagib_ammo_drop && item.classname != "item_minst_cells")
+               item.ammo_cells = autocvar_g_instagib_ammo_drop;
 
-       if(self.ammo_cells && !self.weapon)
+       if(item.ammo_cells && !item.weapon)
                return false;
 
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, CustomizeWaypoint)
-{SELFPARAM();
-       entity e = WaypointSprite_getviewentity(other);
+{
+       entity wp = M_ARGV(0, entity);
+       entity player = M_ARGV(1, entity);
+
+       entity e = WaypointSprite_getviewentity(player);
 
        // 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 & ITEM_Invisibility.m_itemid) && (e == other))
-       if(DIFF_TEAM(self.owner, e))
+       if((wp.owner.flags & FL_CLIENT) && (wp.owner.items & ITEM_Invisibility.m_itemid) && (e == player))
+       if(DIFF_TEAM(wp.owner, e))
                return true;
 
        return false;
@@ -423,6 +434,9 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, CustomizeWaypoint)
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDies)
 {
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+
        if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
                frag_damage = 1000; // always gib if it was a vaporizer death
 
@@ -430,28 +444,31 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch)
-{SELFPARAM();
-       if(self.ammo_cells)
+{
+       entity item = M_ARGV(0, entity);
+       entity toucher = M_ARGV(1, entity);
+
+       if(item.ammo_cells)
        {
                // play some cool sounds ;)
-               if (IS_CLIENT(other))
+               if (IS_CLIENT(toucher))
                {
-                       if(other.health <= 5)
-                               Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_LASTSECOND);
-                       else if(other.health < 50)
-                               Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_NARROWLY);
+                       if(toucher.health <= 5)
+                               Send_Notification(NOTIF_ONE, toucher, MSG_ANNCE, ANNCE_INSTAGIB_LASTSECOND);
+                       else if(toucher.health < 50)
+                               Send_Notification(NOTIF_ONE, toucher, MSG_ANNCE, ANNCE_INSTAGIB_NARROWLY);
                }
 
-               if(other.health < 100)
-                       other.health = 100;
+               if(toucher.health < 100)
+                       toucher.health = 100;
 
                return MUT_ITEMTOUCH_CONTINUE;
        }
 
-       if(self.itemdef == ITEM_ExtraLife)
+       if(item.itemdef == ITEM_ExtraLife)
        {
-               other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
-               Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
+               toucher.armorvalue = bound(toucher.armorvalue, 999, toucher.armorvalue + autocvar_g_instagib_extralives);
+               Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES);
                return MUT_ITEMTOUCH_PICKUP;
        }
 
@@ -459,10 +476,11 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch)
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, OnEntityPreSpawn)
-{SELFPARAM();
+{
        if (!autocvar_g_powerups) { return false; }
+       entity ent = M_ARGV(0, entity);
        // Can't use .itemdef here
-       if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
+       if (!(ent.classname == "item_strength" || ent.classname == "item_invincible" || ent.classname == "item_health_mega"))
                return false;
 
        entity e = spawn();
@@ -476,28 +494,26 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, OnEntityPreSpawn)
                setthink(e, instagib_speed);
 
        e.nextthink = time + 0.1;
-       e.spawnflags = self.spawnflags;
-       e.noalign = self.noalign;
-       setorigin(e, self.origin);
+       e.spawnflags = ent.spawnflags;
+       e.noalign = ent.noalign;
+       setorigin(e, ent.origin);
 
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, BuildMutatorsString)
 {
-       ret_string = strcat(ret_string, ":instagib");
-       return false;
+       M_ARGV(0, string) = strcat(M_ARGV(0, string), ":instagib");
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, BuildMutatorsPrettyString)
 {
-       ret_string = strcat(ret_string, ", instagib");
-       return false;
+       M_ARGV(0, string) = strcat(M_ARGV(0, string), ", instagib");
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, SetModname)
 {
-       modname = "InstaGib";
+       M_ARGV(0, string) = "InstaGib";
        return true;
 }