]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/instagib/instagib.qc
Always disable self damage from the blaster in instagib
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / instagib / instagib.qc
index 2a46dd699e1b5426c9735b7a0b3a0ec58424556f..f8f2e5a7dfb41ec821f611b8f8573a784e97d01c 100644 (file)
@@ -16,10 +16,9 @@ int autocvar_g_instagib_ammo_drop;
 int autocvar_g_instagib_extralives;
 float autocvar_g_instagib_speed_highspeed;
 
-#include "../../../../server/cl_client.qh"
-#include "../../../buffs/all.qh"
+#include <server/cl_client.qh>
 
-#include "../../../items/all.qc"
+#include <common/items/all.qc>
 
 REGISTER_MUTATOR(mutator_instagib, cvar("g_instagib") && !g_nexball);
 
@@ -38,7 +37,6 @@ void instagib_invisibility()
 
 void instagib_extralife()
 {SELFPARAM();
-       self.max_health = 1;
        StartItem(this, ITEM_ExtraLife);
 }
 
@@ -54,7 +52,7 @@ void instagib_stop_countdown(entity e)
 {
        if (!e.instagib_needammo)
                return;
-       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_INSTAGIB_FINDAMMO);
+       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_INSTAGIB_FINDAMMO);
        e.instagib_needammo = false;
 }
 void instagib_ammocheck()
@@ -64,7 +62,7 @@ void instagib_ammocheck()
        if(!IS_PLAYER(self))
                return; // not a player
 
-       if(self.deadflag || gameover)
+       if(IS_DEAD(self) || gameover)
                instagib_stop_countdown(self);
        else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
                instagib_stop_countdown(self);
@@ -141,10 +139,7 @@ void instagib_ammocheck()
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, MatchEnd)
 {
-       entity head;
-       FOR_EACH_PLAYER(head)
-               instagib_stop_countdown(head);
-
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(instagib_stop_countdown(it)));
        return false;
 }
 
@@ -203,7 +198,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
 
        if (self.items & ITEM_Invisibility.m_itemid)
        {
-               play_countdown(self.strength_finished, SND(POWEROFF));
+               play_countdown(self.strength_finished, SND_POWEROFF);
                if (time > self.strength_finished)
                {
                        self.alpha = default_player_alpha;
@@ -226,7 +221,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
 
        if (self.items & ITEM_Speed.m_itemid)
        {
-               play_countdown(self.invincible_finished, SND(POWEROFF));
+               play_countdown(self.invincible_finished, SND_POWEROFF);
                if (time > self.invincible_finished)
                {
                        self.items &= ~ITEM_Speed.m_itemid;
@@ -298,7 +293,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
                                frag_target.armorvalue -= 1;
                                frag_damage = 0;
                                frag_target.damage_dealt += 1;
-                               frag_attacker.damage_dealt += 1; // TODO: change this to a specific hitsound for armor hit
+                               frag_attacker.damage_dealt += 1;
                                Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
                        }
                }
@@ -307,7 +302,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
                {
                        if(frag_deathtype & HITTYPE_SECONDARY)
                        {
-                               if(!autocvar_g_instagib_blaster_keepdamage)
+                               if(!autocvar_g_instagib_blaster_keepdamage || frag_attacker == frag_target)
                                        frag_damage = frag_mirrordamage = 0;
 
                                if(frag_target != frag_attacker)
@@ -333,7 +328,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
                frag_mirrordamage = 0;
        }
 
-       if((frag_target.buffs & BUFF_INVISIBLE.m_itemid) || (frag_target.items & ITEM_Invisibility.m_itemid))
+       if(frag_target.alpha && frag_target.alpha < 1)
                yoda = 1;
 
        return false;
@@ -376,7 +371,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem)
         e.cnt = self.cnt;
         e.team = self.team;
         e.spawnfunc_checked = true;
-               WITH(entity, self, e, spawnfunc_item_minst_cells(e));
+               WITHSELF(e, spawnfunc_item_minst_cells(e));
                return true;
        }
 
@@ -410,7 +405,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDies)
        if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
                frag_damage = 1000; // always gib if it was a vaporizer death
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch)
@@ -432,7 +427,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch)
                return MUT_ITEMTOUCH_CONTINUE;
        }
 
-       if(self.max_health)
+       if(self.itemdef == ITEM_ExtraLife)
        {
                other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
                Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);