]> 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 bd61023a1ed3f1605f39c0c055e4551502294589..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,
-                          "MinstaNex 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;
@@ -23,77 +68,77 @@ void instagib_stop_countdown(entity e)
 {
        if (!e.instagib_needammo)
                return;
-       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_MINSTA_FINDAMMO);
-       e.instagib_needammo = FALSE;
+       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_INSTAGIB_FINDAMMO);
+       e.instagib_needammo = false;
 }
 void instagib_ammocheck()
 {
-       if (!IS_PLAYER(self))
-               return; // not a player
-       if (time < self.instagib_nextthink)
+       if(time < self.instagib_nextthink)
                return;
+       if(!IS_PLAYER(self))
+               return; // not a player
 
-       if (self.deadflag || gameover)
+       if(self.deadflag || gameover)
                instagib_stop_countdown(self);
-       else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO))
+       else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
                instagib_stop_countdown(self);
        else
        {
-               self.instagib_needammo = TRUE;
-               if (self.health == 5)
+               self.instagib_needammo = true;
+               if (self.health <= 5)
                {
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
                }
-               else if (self.health == 10)
+               else if (self.health <= 10)
                {
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
                }
-               else if (self.health == 20)
+               else if (self.health <= 20)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
                }
-               else if (self.health == 30)
+               else if (self.health <= 30)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
                }
-               else if (self.health == 40)
+               else if (self.health <= 40)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
                }
-               else if (self.health == 50)
+               else if (self.health <= 50)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
                }
-               else if (self.health == 60)
+               else if (self.health <= 60)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
                }
-               else if (self.health == 70)
+               else if (self.health <= 70)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
                }
-               else if (self.health == 80)
+               else if (self.health <= 80)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
                }
-               else if (self.health == 90)
+               else if (self.health <= 90)
                {
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MINSTA_FINDAMMO);
+                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
                }
-               else if (self.health == 100)
+               else
                {
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_MINSTA_FINDAMMO);
+                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                }
        }
@@ -106,14 +151,14 @@ MUTATOR_HOOKFUNCTION(instagib_MatchEnd)
        FOR_EACH_PLAYER(head)
                instagib_stop_countdown(head);
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
 {
        other.monster_loot = spawnfunc_item_minst_cells;
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
@@ -121,40 +166,40 @@ MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
        // always refill ammo
        if(self.monsterid == MON_MAGE)
                self.skin = 1;
-       
-       return FALSE;
+
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
 {
        if(checkentity.items & IT_STRENGTH)
-               return TRUE;
+               return true;
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
 {
        instagib_stop_countdown(self);
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
 {
        self.effects |= EF_FULLBRIGHT;
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerPreThink)
 {
        instagib_ammocheck();
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
 {
        // no regeneration in instagib
-       return TRUE;
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
@@ -203,7 +248,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
                }
        }
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
@@ -211,7 +256,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
        if(self.items & IT_INVINCIBLE)
                self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_SplitHealthArmor)
@@ -219,14 +264,14 @@ MUTATOR_HOOKFUNCTION(instagib_SplitHealthArmor)
        damage_save = 0;
        damage_take = frag_damage;
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_ForbidThrowing)
 {
        // weapon dropping on death handled by FilterItem
 
-       return TRUE;
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
@@ -245,28 +290,29 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
                }
 
                if(IS_PLAYER(frag_attacker))
-               if(DEATH_ISWEAPON(frag_deathtype, WEP_MINSTANEX))
-               if(frag_target.armorvalue)
+               if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
                {
-                       frag_target.armorvalue -= 1;
-                       Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_MINSTA_LIVES_REMAINING, frag_target.armorvalue);
-                       frag_damage = 0;
-                       frag_target.damage_dealt += 1;
-                       frag_attacker.damage_dealt += 1; // TODO change this to a future specific hitsound for armor hit
+                       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))
-               if (DEATH_ISWEAPON(frag_deathtype, WEP_LASER))
+               if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
                {
-                       frag_damage = 0;
-                       frag_mirrordamage = 0;
-                       if (frag_target != frag_attacker)
+                       if(frag_deathtype & HITTYPE_SECONDARY)
                        {
-                               if (frag_target.health >= 1)
-                                       Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_MINSTA_SECONDARY);
-                               frag_force = '0 0 0';
-                               // keep mirrorfrag_force
-                               //frag_attacker = frag_target;
+                               frag_damage = frag_mirrordamage = 0;
+
+                               if(frag_target != frag_attacker)
+                               {
+                                       if(frag_target.health > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
+                                       frag_force = '0 0 0';
+                               }
                        }
                }
        }
@@ -278,43 +324,48 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
                if(frag_attacker.armorvalue > 0)
                {
                        frag_attacker.armorvalue -= 1;
-                       Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_MINSTA_LIVES_REMAINING, frag_attacker.armorvalue);
+                       Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_attacker.armorvalue);
                        frag_attacker.damage_dealt += 1;
                }
                frag_mirrordamage = 0;
        }
 
-       if(frag_target.items & IT_STRENGTH)
+       if((frag_target.buffs & BUFF_INVISIBLE) || (frag_target.items & IT_STRENGTH))
                yoda = 1;
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
 {
-       start_ammo_cells = cvar("g_instagib_ammo_start");
+       start_health       = warmup_start_health       = 100;
+       start_armorvalue   = warmup_start_armorvalue   = 0;
+
+       start_ammo_shells  = warmup_start_ammo_shells  = 0;
+       start_ammo_nails   = warmup_start_ammo_nails   = 0;
+       start_ammo_cells   = warmup_start_ammo_cells   = cvar("g_instagib_ammo_start");
+       start_ammo_plasma  = warmup_start_ammo_plasma  = 0;
+       start_ammo_rockets = warmup_start_ammo_rockets = 0;
+       start_ammo_fuel    = warmup_start_ammo_fuel    = 0;
 
-       start_health = 100;
-       start_armorvalue = 0;
-       start_weapons = WEPSET_MINSTANEX;
-       warmup_start_weapons = WEPSET_MINSTANEX;
+       start_weapons = warmup_start_weapons = WEPSET_VAPORIZER;
        start_items |= IT_UNLIMITED_SUPERWEAPONS;
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
 {
        if(self.classname == "item_cells")
-               return TRUE; // no normal cells?
+               return true; // no normal cells?
 
-       if(self.weapon == WEP_MINSTANEX && self.classname == "droppedweapon")
+       if(self.weapon == WEP_VAPORIZER && self.classname == "droppedweapon")
        {
                self.ammo_cells = autocvar_g_instagib_ammo_drop;
-               return FALSE;
+               return false;
        }
 
-       if(self.weapon == WEP_ROCKET_LAUNCHER || self.weapon == WEP_NEX)
+       if(self.weapon == WEP_DEVASTATOR || self.weapon == WEP_VORTEX)
        {
                entity e = spawn();
                setorigin(e, self.origin);
@@ -323,19 +374,19 @@ MUTATOR_HOOKFUNCTION(instagib_FilterItem)
                self = e;
                spawnfunc_item_minst_cells();
                self = oldself;
-               return TRUE;
+               return true;
        }
 
        if(self.flags & FL_POWERUP)
-               return FALSE;
+               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(self.ammo_cells && !self.weapon)
-               return FALSE;
+               return false;
 
-       return TRUE;
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
@@ -346,9 +397,9 @@ MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
        // but only apply this to real players, not to spectators
        if((self.owner.flags & FL_CLIENT) && (self.owner.items & IT_STRENGTH) && (e == other))
        if(DIFF_TEAM(self.owner, e))
-               return TRUE;
+               return true;
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_ItemCountdown)
@@ -359,7 +410,7 @@ MUTATOR_HOOKFUNCTION(instagib_ItemCountdown)
                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;
        }
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
@@ -393,9 +444,9 @@ MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
 
 MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
 {
-       if (!autocvar_g_powerups) { return FALSE; }
+       if (!autocvar_g_powerups) { return false; }
        if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
-               return FALSE;
+               return false;
 
        entity e = spawn();
 
@@ -411,25 +462,25 @@ MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
        e.noalign = self.noalign;
        setorigin(e, self.origin);
 
-       return TRUE;
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":instagib");
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", instagib");
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_SetModname)
 {
        modname = "instagib";
-       return TRUE;
+       return true;
 }
 
 MUTATOR_DEFINITION(mutator_instagib)
@@ -457,5 +508,5 @@ MUTATOR_DEFINITION(mutator_instagib)
        MUTATOR_HOOK(BuildMutatorsPrettyString, instagib_BuildMutatorsPrettyString, CBC_ORDER_ANY);
        MUTATOR_HOOK(SetModname, instagib_SetModname, CBC_ORDER_ANY);
 
-       return FALSE;
+       return false;
 }