]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added MUTATOR_IS_ENABLED macro.
authorLyberta <lyberta@lyberta.net>
Wed, 6 Jun 2018 00:38:40 +0000 (03:38 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 6 Jun 2018 00:38:40 +0000 (03:38 +0300)
17 files changed:
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc
qcsrc/common/mutators/mutator/instagib/sv_instagib.qc
qcsrc/common/mutators/mutator/instagib/sv_instagib.qh
qcsrc/common/mutators/mutator/melee_only/sv_melee_only.qc
qcsrc/common/mutators/mutator/new_toys/sv_new_toys.qc
qcsrc/common/mutators/mutator/nix/sv_nix.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qh
qcsrc/common/mutators/mutator/pinata/sv_pinata.qc
qcsrc/common/mutators/mutator/random_items/sv_random_items.qc
qcsrc/common/mutators/mutator/vampire/sv_vampire.qc
qcsrc/common/turrets/turret/plasma.qc
qcsrc/common/turrets/turret/plasma_dual.qc
qcsrc/server/client.qc
qcsrc/server/g_damage.qc

index 565e39998d7d4186d20ef3937f60ceddc9d53830..163960ba5f5d9ee2d4841b277d28bbe2b316f464 100644 (file)
@@ -171,6 +171,8 @@ void Mutator_Remove(Mutator mut);
 bool mutator_log = false;
 .bool m_added;
 
+#define MUTATOR_IS_ENABLED(this) MUTATOR_##this.mutatorcheck()
+
 #ifdef GAMEQC
 /** server mutators activate corresponding client mutators for all clients */
 REGISTER_NET_LINKED(Mutator)
index 4a54d8117d24ba4ae80bf772e792d1ec1286464f..5afb965076965b484fb01b44b8184fa1e89cad98 100644 (file)
@@ -926,7 +926,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                BUFF_ONADD(BUFF_INVISIBLE)
                {
-                       if(time < player.strength_finished && autocvar_g_instagib)
+                       if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
                                player.buff_invisible_prev_alpha = default_player_alpha; // we don't want to save the powerup's alpha, as player may lose the powerup while holding the buff
                        else
                                player.buff_invisible_prev_alpha = player.alpha;
@@ -935,7 +935,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                BUFF_ONREM(BUFF_INVISIBLE)
                {
-                       if(time < player.strength_finished && autocvar_g_instagib)
+                       if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
                                player.alpha = autocvar_g_instagib_invis_alpha;
                        else
                                player.alpha = player.buff_invisible_prev_alpha;
index 4a18cc930879ad34e28ef7551c7af1e381bf8d46..b88d96d700307fbf05480fb88befac6a4824b6bd 100644 (file)
@@ -4,7 +4,7 @@ AUTOCVAR(sv_damagetext, int, 2, "<= 0: disabled, >= 1: visible to spectators, >=
 
 REGISTER_MUTATOR(damagetext, true);
 
-#define SV_DAMAGETEXT_DISABLED()        (autocvar_sv_damagetext <= 0 || autocvar_g_instagib)
+#define SV_DAMAGETEXT_DISABLED()        (autocvar_sv_damagetext <= 0 || MUTATOR_IS_ENABLED(mutator_instagib))
 #define SV_DAMAGETEXT_SPECTATORS_ONLY() (autocvar_sv_damagetext >= 1)
 #define SV_DAMAGETEXT_PLAYERS()         (autocvar_sv_damagetext >= 2)
 #define SV_DAMAGETEXT_ALL()             (autocvar_sv_damagetext >= 3)
index 616a05da3c93e9c77294028f469ae9a1c649a9ce..f93b69235df1213ce71b19aa5e446c8c0383dda7 100644 (file)
@@ -17,22 +17,6 @@ float autocvar_g_instagib_speed_highspeed;
 
 #include <common/items/_mod.qh>
 
-REGISTER_MUTATOR(mutator_instagib, autocvar_g_instagib && !g_nexball)
-{
-       MUTATOR_ONADD
-       {
-               ITEM_VaporizerCells.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_Invisibility.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_Speed.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-       }
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               ITEM_VaporizerCells.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_Invisibility.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_Speed.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-       }
-}
-
 void instagib_invisibility(entity this)
 {
        this.strength_finished = autocvar_g_instagib_invisibility_time;
index 9020b93124777851f80a80eb1e2dc4b0edab75fa..56f4ac7daaaace7d5d831d281107ed0632d75eaf 100644 (file)
@@ -7,3 +7,19 @@ float autocvar_g_instagib_invis_alpha;
 void instagib_invisibility(entity this);
 void instagib_extralife(entity this);
 void instagib_speed(entity this);
+
+REGISTER_MUTATOR(mutator_instagib, autocvar_g_instagib && !g_nexball)
+{
+       MUTATOR_ONADD
+       {
+               ITEM_VaporizerCells.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_Invisibility.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_Speed.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+       }
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               ITEM_VaporizerCells.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_Invisibility.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_Speed.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+       }
+}
index 2f8b45a99b46f09450ab44c93867b236b4ef4639..a56efaf83cffbf086b2cbca93f5798cfce6b7d20 100644 (file)
@@ -1,7 +1,9 @@
 #include "sv_melee_only.qh"
 
+#include "../overkill/sv_overkill.qh"
+
 string autocvar_g_melee_only;
-REGISTER_MUTATOR(melee_only, expr_evaluate(autocvar_g_melee_only) && !autocvar_g_instagib && !cvar("g_overkill") && !g_nexball);
+REGISTER_MUTATOR(melee_only, expr_evaluate(autocvar_g_melee_only) && !MUTATOR_IS_ENABLED(mutator_instagib) && !MUTATOR_IS_ENABLED(ok) && !g_nexball);
 
 MUTATOR_HOOKFUNCTION(melee_only, SetStartItems, CBC_ORDER_LAST)
 {
index 3ac652d7807df5d1ee4797dad9f16134b25dd756..1c38588ace59e62fe7ff24c47d4c7bf90d3f8c2b 100644 (file)
@@ -74,7 +74,7 @@ roflsound "New toys, new toys!" sound.
 
 bool nt_IsNewToy(int w);
 
-REGISTER_MUTATOR(nt, expr_evaluate(cvar_string("g_new_toys")) && !autocvar_g_instagib && !cvar("g_overkill"))
+REGISTER_MUTATOR(nt, expr_evaluate(cvar_string("g_new_toys")) && !MUTATOR_IS_ENABLED(mutator_instagib) && !MUTATOR_IS_ENABLED(ok))
 {
        MUTATOR_ONADD
        {
index e88ff9b552984feb7a083932173d64939709ab52..fec01e4472d77e8a4185c735a304b9876ccf346a 100644 (file)
@@ -36,7 +36,7 @@ float nix_nextweapon;
 
 bool NIX_CanChooseWeapon(int wpn);
 
-REGISTER_MUTATOR(nix, expr_evaluate(cvar_string("g_nix")) && !autocvar_g_instagib && !cvar("g_overkill"))
+REGISTER_MUTATOR(nix, expr_evaluate(cvar_string("g_nix")) && !MUTATOR_IS_ENABLED(mutator_instagib) && !MUTATOR_IS_ENABLED(ok))
 {
        MUTATOR_ONADD
        {
index 33deb64fcb2484569de8105870fbdc97a9a3e7a4..f4432a9cbb830973f25fea4a1e6dffc4e6203f77 100644 (file)
@@ -1,70 +1,11 @@
 #include "sv_overkill.qh"
 
-#include "okshotgun.qh"
-#include "okhmg.qh"
-#include "okrpc.qh"
-
-string autocvar_g_overkill;
-
 bool autocvar_g_overkill_powerups_replace;
 
 bool autocvar_g_overkill_itemwaypoints = true;
 
 .Weapon ok_lastwep[MAX_WEAPONSLOTS];
 
-REGISTER_MUTATOR(ok, expr_evaluate(autocvar_g_overkill) && !autocvar_g_instagib && !g_nexball && cvar_string("g_mod_balance") == "Overkill")
-{
-       MUTATOR_ONADD
-       {
-               precache_all_playermodels("models/ok_player/*.dpm");
-
-               if (autocvar_g_overkill_filter_healthmega)
-               {
-                       ITEM_HealthMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-               if (autocvar_g_overkill_filter_armormedium)
-               {
-                       ITEM_ArmorMedium.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-               if (autocvar_g_overkill_filter_armorbig)
-               {
-                       ITEM_ArmorBig.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-               if (autocvar_g_overkill_filter_armormega)
-               {
-                       ITEM_ArmorMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-
-               WEP_OVERKILL_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-               WEP_OVERKILL_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-
-               WEP_OVERKILL_SHOTGUN.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-               WEP_OVERKILL_MACHINEGUN.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-               WEP_OVERKILL_NEX.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-
-               //WEP_SHOTGUN.mdl = "ok_shotgun";
-               //WEP_MACHINEGUN.mdl = "ok_mg";
-               //WEP_VORTEX.mdl = "ok_sniper";
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               ITEM_HealthMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_ArmorMedium.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_ArmorBig.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_ArmorMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-
-               WEP_OVERKILL_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-               WEP_OVERKILL_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-
-               WEP_OVERKILL_SHOTGUN.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-               WEP_OVERKILL_MACHINEGUN.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-               WEP_OVERKILL_NEX.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-       }
-}
-
-void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float);
-
 MUTATOR_HOOKFUNCTION(ok, Damage_Calculate, CBC_ORDER_LAST)
 {
        entity frag_attacker = M_ARGV(1, entity);
index 72324e6dbb01b375b00010231235a03d7a35e649..4949edb1e82fdac49e7edf57b69efb092ceef229 100644 (file)
@@ -1,8 +1,61 @@
 #pragma once
 
+#include "okshotgun.qh"
+#include "okmachinegun.qh"
+#include "okhmg.qh"
+#include "okrpc.qh"
+
+string autocvar_g_overkill;
 bool autocvar_g_overkill_filter_healthmega;
 bool autocvar_g_overkill_filter_armormedium;
 bool autocvar_g_overkill_filter_armorbig;
 bool autocvar_g_overkill_filter_armormega;
 
 .float ok_item;
+
+REGISTER_MUTATOR(ok, expr_evaluate(autocvar_g_overkill) && !MUTATOR_IS_ENABLED(mutator_instagib) && !g_nexball && cvar_string("g_mod_balance") == "Overkill")
+{
+       MUTATOR_ONADD
+       {
+               precache_all_playermodels("models/ok_player/*.dpm");
+
+               if (autocvar_g_overkill_filter_healthmega)
+               {
+                       ITEM_HealthMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+               if (autocvar_g_overkill_filter_armormedium)
+               {
+                       ITEM_ArmorMedium.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+               if (autocvar_g_overkill_filter_armorbig)
+               {
+                       ITEM_ArmorBig.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+               if (autocvar_g_overkill_filter_armormega)
+               {
+                       ITEM_ArmorMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+
+               WEP_OVERKILL_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+               WEP_OVERKILL_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+
+               WEP_OVERKILL_SHOTGUN.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+               WEP_OVERKILL_MACHINEGUN.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+               WEP_OVERKILL_NEX.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               ITEM_HealthMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_ArmorMedium.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_ArmorBig.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_ArmorMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+
+               WEP_OVERKILL_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+               WEP_OVERKILL_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+
+               WEP_OVERKILL_SHOTGUN.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+               WEP_OVERKILL_MACHINEGUN.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+               WEP_OVERKILL_NEX.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+       }
+}
index c5bf2262eb35e37523c3ac83caa559d4ef1e8d6d..d270cd7c3e7e1f70dd58feb615b80372e15a78bb 100644 (file)
@@ -1,7 +1,7 @@
 #include "sv_pinata.qh"
 
 string autocvar_g_pinata;
-REGISTER_MUTATOR(pinata, expr_evaluate(autocvar_g_pinata) && !autocvar_g_instagib && !cvar("g_overkill"));
+REGISTER_MUTATOR(pinata, expr_evaluate(autocvar_g_pinata) && !MUTATOR_IS_ENABLED(mutator_instagib) && !MUTATOR_IS_ENABLED(ok));
 
 MUTATOR_HOOKFUNCTION(pinata, PlayerDies)
 {
index 6afcd72e9cc2f8e3e2a558d7b5eff2e129aa50ab..2829e3ae2b8a70534134eefaeb6738f47123df4a 100644 (file)
@@ -55,11 +55,11 @@ string RandomItems_GetRandomItemClassNameWithProperty(string prefix,
 
 string RandomItems_GetRandomItemClassName(string prefix)
 {
-       if (autocvar_g_instagib)
+       if (MUTATOR_IS_ENABLED(mutator_instagib))
        {
                return RandomItems_GetRandomInstagibItemClassName(prefix);
        }
-       if (expr_evaluate(autocvar_g_overkill))
+       if (MUTATOR_IS_ENABLED(ok))
        {
                return RandomItems_GetRandomOverkillItemClassName(prefix);
        }
@@ -328,7 +328,7 @@ entity RandomItems_ReplaceMapItem(entity item)
        }
        random_items_is_spawning = true;
        entity new_item;
-       if (!expr_evaluate(autocvar_g_overkill))
+       if (!MUTATOR_IS_ENABLED(ok))
        {
                new_item = Item_Create(strzone(new_classname), item.origin,
                        Item_ShouldKeepPosition(item));
@@ -374,7 +374,7 @@ void RandomItems_SpawnLootItem(vector position)
        spread.z = autocvar_g_random_loot_spread / 2;
        spread += randomvec() * autocvar_g_random_loot_spread;
        random_items_is_spawning = true;
-       if (!expr_evaluate(autocvar_g_overkill))
+       if (!MUTATOR_IS_ENABLED(ok))
        {
                Item_CreateLoot(class_name, position, spread,
                        autocvar_g_random_loot_time);
index b599805a45774f6d971087191a259ebffef342c1..b446c927052e0fc824a07708f03a9633f4c4fdad 100644 (file)
@@ -1,7 +1,7 @@
 #include "sv_vampire.qh"
 
 string autocvar_g_vampire;
-REGISTER_MUTATOR(vampire, expr_evaluate(autocvar_g_vampire) && !autocvar_g_instagib);
+REGISTER_MUTATOR(vampire, expr_evaluate(autocvar_g_vampire) && !MUTATOR_IS_ENABLED(mutator_instagib));
 
 MUTATOR_HOOKFUNCTION(vampire, PlayerDamage_SplitHealthArmor)
 {
index c4e50a7e71f058be20cd74201a619a5878e20777..89ddfbd4f1ca6a28df7f9d45339b016d01923144 100644 (file)
@@ -6,7 +6,7 @@ spawnfunc(turret_plasma) { if (!turret_initialize(this, TUR_PLASMA)) delete(this
 
 METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it))
 {
-    if(autocvar_g_instagib)
+    if(MUTATOR_IS_ENABLED(mutator_instagib))
     {
         .entity weaponentity = weaponentities[0]; // TODO: unhardcode
         FireRailgunBullet (it, weaponentity, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * max_shot_distance, 10000000000,
index 8d20da5b6eed40b3c9f66eddffbe3b0c780b228a..9fa10eefff01e8a2c7cf0a9cbd305014f7be13e4 100644 (file)
@@ -6,7 +6,7 @@ spawnfunc(turret_plasma_dual) { if (!turret_initialize(this, TUR_PLASMA_DUAL)) d
 
 METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur, entity it))
 {
-    if (autocvar_g_instagib) {
+    if (MUTATOR_IS_ENABLED(mutator_instagib)) {
         .entity weaponentity = weaponentities[0]; // TODO: unhardcode
         FireRailgunBullet (it, weaponentity, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * max_shot_distance, 10000000000,
                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
index 270a4d1af3c4940da7a1102c5286e5bca81b80d7..991cba4a39c656413aa1ba426bed430bc59c65d2 100644 (file)
@@ -49,6 +49,7 @@
 #include "../common/items/_mod.qh"
 
 #include "../common/mutators/mutator/waypoints/all.qh"
+#include "../common/mutators/mutator/instagib/sv_instagib.qh"
 
 #include "../common/triggers/subs.qh"
 #include "../common/triggers/triggers.qh"
@@ -1503,7 +1504,7 @@ void player_powerups(entity this)
        Fire_ApplyDamage(this);
        Fire_ApplyEffect(this);
 
-       if (!autocvar_g_instagib)
+       if (!MUTATOR_IS_ENABLED(mutator_instagib))
        {
                if (this.items & ITEM_Strength.m_itemid)
                {
index f87bce9e85d56976a6d7b2b9405e24d2bf008c19..9d5033afcafe04e4d8f56d2cfa7a9c1d25d9147a 100644 (file)
@@ -779,7 +779,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                        }
                }
 
-               if(!autocvar_g_instagib)
+               if(!MUTATOR_IS_ENABLED(mutator_instagib))
                {
                        // apply strength multiplier
                        if (attacker.items & ITEM_Strength.m_itemid)