]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_instagib.qc
Replace `MAP(IDENTITY)` with `UNWORDS`
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_instagib.qc
index 141172e2fb6f1d680dc8bb36c7a3c698f7c87cb5..161dba90deb0c68d22f65ee5e65b96d4cf87de33 100644 (file)
@@ -1,20 +1,65 @@
+#include "../_all.qh"
+
+#include "mutator.qh"
+
+#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
+
 void spawnfunc_item_minst_cells (void)
 {
        if (!g_instagib) { remove(self); return; }
        if (!self.ammo_cells)
                self.ammo_cells = autocvar_g_instagib_ammo_drop;
 
-       StartItem ("models/items/a_cells.md3",
-                          "misc/itempickup.wav", 45, 0,
-                          "Vaporizer Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
+       StartItemA (ITEM_VaporizerCells);
 }
 
 void instagib_health_mega()
 {
        self.max_health = 1;
-       StartItem ("models/items/g_h100.md3",
-                          "misc/megahealth.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
-                          "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+       StartItemA (ITEM_ExtraLife);
 }
 
 .float instagib_nextthink;
@@ -246,6 +291,18 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
 
                if(IS_PLAYER(frag_attacker))
                if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
+               {
+                       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
+                               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))
                {
                        if(frag_deathtype & HITTYPE_SECONDARY)
                        {
@@ -257,14 +314,6 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
                                        frag_force = '0 0 0';
                                }
                        }
-                       else 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
-                               Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
-                       }
                }
        }
 
@@ -281,7 +330,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
                frag_mirrordamage = 0;
        }
 
-       if(frag_target.items & IT_STRENGTH)
+       if((frag_target.buffs & BUFF_INVISIBLE) || (frag_target.items & IT_STRENGTH))
                yoda = 1;
 
        return false;