From: Lyberta Date: Wed, 6 Jun 2018 00:38:40 +0000 (+0300) Subject: Added MUTATOR_IS_ENABLED macro. X-Git-Tag: xonotic-v0.8.5~2108^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=524d2e52f82e986764687989ec0075719a4c4cee;p=xonotic%2Fxonotic-data.pk3dir.git Added MUTATOR_IS_ENABLED macro. --- diff --git a/qcsrc/common/mutators/base.qh b/qcsrc/common/mutators/base.qh index 565e39998..163960ba5 100644 --- a/qcsrc/common/mutators/base.qh +++ b/qcsrc/common/mutators/base.qh @@ -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) diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 4a54d8117..5afb96507 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc index 4a18cc930..b88d96d70 100644 --- a/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 616a05da3..f93b69235 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -17,22 +17,6 @@ float autocvar_g_instagib_speed_highspeed; #include -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; diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qh b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qh index 9020b9312..56f4ac7da 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qh +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qh @@ -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; + } +} diff --git a/qcsrc/common/mutators/mutator/melee_only/sv_melee_only.qc b/qcsrc/common/mutators/mutator/melee_only/sv_melee_only.qc index 2f8b45a99..a56efaf83 100644 --- a/qcsrc/common/mutators/mutator/melee_only/sv_melee_only.qc +++ b/qcsrc/common/mutators/mutator/melee_only/sv_melee_only.qc @@ -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) { diff --git a/qcsrc/common/mutators/mutator/new_toys/sv_new_toys.qc b/qcsrc/common/mutators/mutator/new_toys/sv_new_toys.qc index 3ac652d78..1c38588ac 100644 --- a/qcsrc/common/mutators/mutator/new_toys/sv_new_toys.qc +++ b/qcsrc/common/mutators/mutator/new_toys/sv_new_toys.qc @@ -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 { diff --git a/qcsrc/common/mutators/mutator/nix/sv_nix.qc b/qcsrc/common/mutators/mutator/nix/sv_nix.qc index e88ff9b55..fec01e447 100644 --- a/qcsrc/common/mutators/mutator/nix/sv_nix.qc +++ b/qcsrc/common/mutators/mutator/nix/sv_nix.qc @@ -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 { diff --git a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc index 33deb64fc..f4432a9cb 100644 --- a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc @@ -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); diff --git a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh index 72324e6db..4949edb1e 100644 --- a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh +++ b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh @@ -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; + } +} diff --git a/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc b/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc index c5bf2262e..d270cd7c3 100644 --- a/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc +++ b/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc @@ -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) { diff --git a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc index 6afcd72e9..2829e3ae2 100644 --- a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc +++ b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc @@ -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); diff --git a/qcsrc/common/mutators/mutator/vampire/sv_vampire.qc b/qcsrc/common/mutators/mutator/vampire/sv_vampire.qc index b599805a4..b446c9270 100644 --- a/qcsrc/common/mutators/mutator/vampire/sv_vampire.qc +++ b/qcsrc/common/mutators/mutator/vampire/sv_vampire.qc @@ -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) { diff --git a/qcsrc/common/turrets/turret/plasma.qc b/qcsrc/common/turrets/turret/plasma.qc index c4e50a7e7..89ddfbd4f 100644 --- a/qcsrc/common/turrets/turret/plasma.qc +++ b/qcsrc/common/turrets/turret/plasma.qc @@ -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, diff --git a/qcsrc/common/turrets/turret/plasma_dual.qc b/qcsrc/common/turrets/turret/plasma_dual.qc index 8d20da5b6..9fa10eeff 100644 --- a/qcsrc/common/turrets/turret/plasma_dual.qc +++ b/qcsrc/common/turrets/turret/plasma_dual.qc @@ -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); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 270a4d1af..991cba4a3 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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) { diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index f87bce9e8..9d5033afc 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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)