]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/instagib/instagib.qc
Merge branch 'master' into terencehill/translate_colors_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / instagib / instagib.qc
index cc6f405e66faadc8702dfd6eb72736a609ab1c54..ec11970fed3519536b2076f8d9cee51e3a286df7 100644 (file)
@@ -3,15 +3,22 @@
 
 #include "items.qc"
 
+#ifdef SVQC
+float autocvar_g_instagib_invis_alpha;
+#endif
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
 
-#include "../../../../server/cl_client.qh"
-#include "../../../buffs/all.qh"
+int autocvar_g_instagib_ammo_drop;
+int autocvar_g_instagib_extralives;
+float autocvar_g_instagib_speed_highspeed;
 
-#include "../../../items/all.qc"
+#include <server/cl_client.qh>
+
+#include <common/items/all.qc>
 
 REGISTER_MUTATOR(mutator_instagib, cvar("g_instagib") && !g_nexball);
 
@@ -19,25 +26,24 @@ spawnfunc(item_minst_cells)
 {
        if (!g_instagib) { remove(self); return; }
        if (!self.ammo_cells) self.ammo_cells = autocvar_g_instagib_ammo_drop;
-       StartItemA(ITEM_VaporizerCells);
+       StartItem(this, ITEM_VaporizerCells);
 }
 
 void instagib_invisibility()
 {SELFPARAM();
        self.strength_finished = autocvar_g_balance_powerup_strength_time;
-       StartItemA(ITEM_Invisibility);
+       StartItem(this, ITEM_Invisibility);
 }
 
 void instagib_extralife()
 {SELFPARAM();
-       self.max_health = 1;
-       StartItemA(ITEM_ExtraLife);
+       StartItem(this, ITEM_ExtraLife);
 }
 
 void instagib_speed()
 {SELFPARAM();
        self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
-       StartItemA(ITEM_Speed);
+       StartItem(this, ITEM_Speed);
 }
 
 .float instagib_nextthink;
@@ -46,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()
@@ -56,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);
@@ -73,59 +79,59 @@ void instagib_ammocheck()
                self.instagib_needammo = true;
                if (self.health <= 5)
                {
-                       Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
                }
                else if (self.health <= 10)
                {
-                       Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
                }
                else if (self.health <= 20)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
                }
                else if (self.health <= 30)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
                }
                else if (self.health <= 40)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
                }
                else if (self.health <= 50)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
                }
                else if (self.health <= 60)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
                }
                else if (self.health <= 70)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
                }
                else if (self.health <= 80)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
                }
                else if (self.health <= 90)
                {
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
                }
                else
                {
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
-                       Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
+                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
                }
        }
        self.instagib_nextthink = time + 1;
@@ -133,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;
 }
 
@@ -195,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;
@@ -218,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;
@@ -269,11 +272,11 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
 
        if(IS_PLAYER(frag_target))
        {
-               if(frag_deathtype == DEATH_FALL)
+               if(frag_deathtype == DEATH_FALL.m_id)
                        frag_damage = 0; // never count fall damage
 
                if(!autocvar_g_instagib_damagedbycontents)
-               switch(frag_deathtype)
+               switch(DEATH_ENT(frag_deathtype))
                {
                        case DEATH_DROWN:
                        case DEATH_SLIME:
@@ -283,24 +286,31 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
                }
 
                if(IS_PLAYER(frag_attacker))
-               if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
+               if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
                {
+                       if(!autocvar_g_instagib_friendlypush && SAME_TEAM(frag_target, frag_attacker))
+                               frag_force = '0 0 0';
+
                        if(frag_target.armorvalue)
                        {
                                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);
                        }
                }
 
-               if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER.m_id))
+               if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
                {
                        if(frag_deathtype & HITTYPE_SECONDARY)
                        {
-                               if(!autocvar_g_instagib_blaster_keepdamage)
-                                       frag_damage = frag_mirrordamage = 0;
+                               if(!autocvar_g_instagib_blaster_keepdamage || frag_attacker == frag_target)
+                               {
+                                       frag_damage = 0;
+                                       if(!autocvar_g_instagib_mirrordamage)
+                                               frag_mirrordamage = 0; // never do mirror damage on enemies
+                               }
 
                                if(frag_target != frag_attacker)
                                {
@@ -312,6 +322,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
                }
        }
 
+       if(!autocvar_g_instagib_mirrordamage) // only apply the taking lives hack if we don't want to support real damage mirroring
        if(IS_PLAYER(frag_attacker))
        if(frag_mirrordamage > 0)
        {
@@ -325,7 +336,8 @@ 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)
+       if(IS_PLAYER(frag_target))
                yoda = 1;
 
        return false;
@@ -367,7 +379,8 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem)
                e.noalign = self.noalign;
         e.cnt = self.cnt;
         e.team = self.team;
-               WITH(entity, self, e, spawnfunc_item_minst_cells(e));
+        e.spawnfunc_checked = true;
+               WITHSELF(e, spawnfunc_item_minst_cells(e));
                return true;
        }
 
@@ -398,10 +411,10 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, CustomizeWaypoint)
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDies)
 {
-       if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
+       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)
@@ -423,7 +436,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);
@@ -472,7 +485,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, BuildMutatorsPrettyString)
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, SetModname)
 {
-       modname = "instagib";
+       modname = "InstaGib";
        return true;
 }