From 39d9a37ad3d73b83ce0e9f9d1947c0de09f263e7 Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 14 Oct 2015 22:07:19 +1100 Subject: [PATCH] Mutators: port to new syntax --- qcsrc/server/miscfunctions.qh | 4 - qcsrc/server/mutators/mutator_bloodloss.qc | 20 +-- .../server/mutators/mutator_breakablehook.qc | 4 +- qcsrc/server/mutators/mutator_buffs.qc | 116 ++++++---------- qcsrc/server/mutators/mutator_campcheck.qc | 23 +--- qcsrc/server/mutators/mutator_dodging.qc | 78 +++++------ .../server/mutators/mutator_invincibleproj.qc | 17 +-- qcsrc/server/mutators/mutator_melee_only.qc | 23 +--- qcsrc/server/mutators/mutator_midair.qc | 23 +--- qcsrc/server/mutators/mutator_multijump.qc | 34 ++--- qcsrc/server/mutators/mutator_nades.qc | 78 +++++------ qcsrc/server/mutators/mutator_new_toys.qc | 77 +++++------ qcsrc/server/mutators/mutator_nix.qc | 126 ++++++++---------- qcsrc/server/mutators/mutator_overkill.qc | 79 +++++------ .../server/mutators/mutator_physical_items.qc | 56 ++++---- qcsrc/server/mutators/mutator_pinata.qc | 19 +-- .../server/mutators/mutator_random_gravity.qc | 30 ++--- qcsrc/server/mutators/mutator_rocketflying.qc | 17 +-- .../mutators/mutator_spawn_near_teammate.qc | 20 +-- qcsrc/server/mutators/mutator_superspec.qc | 31 ++--- qcsrc/server/mutators/mutator_touchexplode.qc | 18 +-- qcsrc/server/mutators/mutator_vampire.qc | 18 +-- qcsrc/server/mutators/mutators.qc | 36 ----- qcsrc/server/mutators/mutators.qh | 27 ---- qcsrc/server/mutators/mutators_include.qh | 1 - qcsrc/server/mutators/sandbox.qc | 60 ++++----- qcsrc/server/progs.inc | 1 - 27 files changed, 383 insertions(+), 653 deletions(-) delete mode 100644 qcsrc/server/mutators/mutators.qc delete mode 100644 qcsrc/server/mutators/mutators.qh diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index ca8c41e9b..043f5b959 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -302,12 +302,8 @@ float sv_autotaunt; float sv_taunt; string GetGametype(); // g_world.qc -void mutators_add(); // mutators.qc void readlevelcvars(void) { - // load mutators - mutators_add(); - if(cvar("sv_allow_fullbright")) serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT; diff --git a/qcsrc/server/mutators/mutator_bloodloss.qc b/qcsrc/server/mutators/mutator_bloodloss.qc index 1e5421884..5db1f98a0 100644 --- a/qcsrc/server/mutators/mutator_bloodloss.qc +++ b/qcsrc/server/mutators/mutator_bloodloss.qc @@ -1,9 +1,11 @@ #include "mutator.qh" +REGISTER_MUTATOR(bloodloss, cvar("g_bloodloss")); + .float bloodloss_timer; -MUTATOR_HOOKFUNCTION(bloodloss_PlayerThink) +MUTATOR_HOOKFUNCTION(bloodloss, PlayerPreThink) {SELFPARAM(); if(IS_PLAYER(self)) if(self.health <= autocvar_g_bloodloss && self.deadflag == DEAD_NO) @@ -23,7 +25,7 @@ MUTATOR_HOOKFUNCTION(bloodloss_PlayerThink) return false; } -MUTATOR_HOOKFUNCTION(bloodloss_PlayerJump) +MUTATOR_HOOKFUNCTION(bloodloss, PlayerJump) {SELFPARAM(); if(self.health <= autocvar_g_bloodloss) return true; @@ -31,24 +33,14 @@ MUTATOR_HOOKFUNCTION(bloodloss_PlayerJump) return false; } -MUTATOR_HOOKFUNCTION(bloodloss_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(bloodloss, BuildMutatorsString) { ret_string = strcat(ret_string, ":bloodloss"); return false; } -MUTATOR_HOOKFUNCTION(bloodloss_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(bloodloss, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Blood loss"); return false; } - -MUTATOR_DEFINITION(mutator_bloodloss) -{ - MUTATOR_HOOK(PlayerPreThink, bloodloss_PlayerThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerJump, bloodloss_PlayerJump, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, bloodloss_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, bloodloss_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - return false; -} diff --git a/qcsrc/server/mutators/mutator_breakablehook.qc b/qcsrc/server/mutators/mutator_breakablehook.qc index 3f75e3f99..257937efe 100644 --- a/qcsrc/server/mutators/mutator_breakablehook.qc +++ b/qcsrc/server/mutators/mutator_breakablehook.qc @@ -1,12 +1,12 @@ #include "../../common/deathtypes/all.qh" #include "../g_hook.qh" -REGISTER_MUTATOR(bh, cvar("g_breakablehook")); +REGISTER_MUTATOR(breakablehook, cvar("g_breakablehook")); bool autocvar_g_breakablehook; // allow toggling mid match? bool autocvar_g_breakablehook_owner; -MUTATOR_HOOKFUNCTION(bh, PlayerDamage_Calculate) +MUTATOR_HOOKFUNCTION(breakablehook, PlayerDamage_Calculate) { if(frag_target.classname == "grapplinghook") { diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc index 7c24ea14f..42c729477 100644 --- a/qcsrc/server/mutators/mutator_buffs.qc +++ b/qcsrc/server/mutators/mutator_buffs.qc @@ -6,6 +6,20 @@ #include "../../common/gamemodes/all.qh" #include "../../common/buffs/all.qh" +.float buff_time; +void buffs_DelayedInit(); + +REGISTER_MUTATOR(buffs, cvar("g_buffs")) +{ + MUTATOR_ONADD + { + addstat(STAT_BUFFS, AS_INT, buffs); + addstat(STAT_BUFF_TIME, AS_FLOAT, buff_time); + + InitializeEntity(world, buffs_DelayedInit, INITPRIO_FINDTARGET); + } +} + entity buff_FirstFromFlags(int _buffs) { if (flags) @@ -413,7 +427,7 @@ float buff_Inferno_CalculateTime(float x, float offset_x, float offset_y, float } // mutator hooks -MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_SplitHealthArmor) +MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_SplitHealthArmor) { if(frag_deathtype == DEATH_BUFF.m_id) { return false; } @@ -427,7 +441,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_SplitHealthArmor) return false; } -MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) +MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate) { if(frag_deathtype == DEATH_BUFF.m_id) { return false; } @@ -518,7 +532,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) return false; } -MUTATOR_HOOKFUNCTION(buffs_PlayerSpawn) +MUTATOR_HOOKFUNCTION(buffs,PlayerSpawn) {SELFPARAM(); self.buffs = 0; // reset timers here to prevent them continuing after re-spawn @@ -531,7 +545,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerSpawn) .float stat_sv_airspeedlimit_nonqw; .float stat_sv_jumpvelocity; -MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics) +MUTATOR_HOOKFUNCTION(buffs, PlayerPhysics) {SELFPARAM(); if(self.buffs & BUFF_SPEED.m_itemid) { @@ -554,7 +568,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics) return false; } -MUTATOR_HOOKFUNCTION(buffs_PlayerJump) +MUTATOR_HOOKFUNCTION(buffs, PlayerJump) {SELFPARAM(); if(self.buffs & BUFF_JUMP.m_itemid) player_jumpheight = autocvar_g_buffs_jump_height; @@ -562,7 +576,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerJump) return false; } -MUTATOR_HOOKFUNCTION(buffs_MonsterMove) +MUTATOR_HOOKFUNCTION(buffs, MonsterMove) {SELFPARAM(); if(time < self.buff_disability_time) { @@ -573,7 +587,7 @@ MUTATOR_HOOKFUNCTION(buffs_MonsterMove) return false; } -MUTATOR_HOOKFUNCTION(buffs_PlayerDies) +MUTATOR_HOOKFUNCTION(buffs, PlayerDies) {SELFPARAM(); if(self.buffs) { @@ -590,7 +604,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDies) return false; } -MUTATOR_HOOKFUNCTION(buffs_PlayerUseKey) +MUTATOR_HOOKFUNCTION(buffs, PlayerUseKey, CBC_ORDER_FIRST) {SELFPARAM(); if(MUTATOR_RETURNVALUE || gameover) { return false; } if(self.buffs) @@ -606,7 +620,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerUseKey) return false; } -MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey) +MUTATOR_HOOKFUNCTION(buffs, ForbidThrowCurrentWeapon) {SELFPARAM(); if(MUTATOR_RETURNVALUE || gameover) { return false; } @@ -676,22 +690,24 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey) return false; } -MUTATOR_HOOKFUNCTION(buffs_RemovePlayer) -{SELFPARAM(); - if(self.buff_model) +bool buffs_RemovePlayer(entity player) +{ + if(player.buff_model) { - remove(self.buff_model); - self.buff_model = world; + remove(player.buff_model); + player.buff_model = world; } // also reset timers here to prevent them continuing after spectating - self.buff_disability_time = 0; - self.buff_disability_effect_time = 0; + player.buff_disability_time = 0; + player.buff_disability_effect_time = 0; return false; } +MUTATOR_HOOKFUNCTION(buffs, MakePlayerObserver) { return buffs_RemovePlayer(self); } +MUTATOR_HOOKFUNCTION(buffs, ClientDisconnect) { return buffs_RemovePlayer(self); } -MUTATOR_HOOKFUNCTION(buffs_CustomizeWaypoint) +MUTATOR_HOOKFUNCTION(buffs, CustomizeWaypoint) {SELFPARAM(); entity e = WaypointSprite_getviewentity(other); @@ -704,7 +720,7 @@ MUTATOR_HOOKFUNCTION(buffs_CustomizeWaypoint) return false; } -MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn) +MUTATOR_HOOKFUNCTION(buffs, OnEntityPreSpawn, CBC_ORDER_LAST) {SELFPARAM(); if(autocvar_g_buffs_replace_powerups) switch(self.classname) @@ -720,7 +736,7 @@ MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn) return false; } -MUTATOR_HOOKFUNCTION(buffs_WeaponRate) +MUTATOR_HOOKFUNCTION(buffs, WeaponRateFactor) {SELFPARAM(); if(self.buffs & BUFF_SPEED.m_itemid) weapon_rate *= autocvar_g_buffs_speed_rate; @@ -731,7 +747,7 @@ MUTATOR_HOOKFUNCTION(buffs_WeaponRate) return false; } -MUTATOR_HOOKFUNCTION(buffs_WeaponSpeed) +MUTATOR_HOOKFUNCTION(buffs, WeaponSpeedFactor) {SELFPARAM(); if(self.buffs & BUFF_SPEED.m_itemid) ret_float *= autocvar_g_buffs_speed_weaponspeed; @@ -742,9 +758,7 @@ MUTATOR_HOOKFUNCTION(buffs_WeaponSpeed) return false; } -.float buff_time; - -MUTATOR_HOOKFUNCTION(buffs_PlayerThink) +MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) {SELFPARAM(); if(gameover || self.deadflag != DEAD_NO) { return false; } @@ -890,27 +904,27 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink) return false; } -MUTATOR_HOOKFUNCTION(buffs_SpectateCopy) +MUTATOR_HOOKFUNCTION(buffs, SpectateCopy) {SELFPARAM(); self.buffs = other.buffs; return false; } -MUTATOR_HOOKFUNCTION(buffs_VehicleEnter) +MUTATOR_HOOKFUNCTION(buffs, VehicleEnter) { vh_vehicle.buffs = vh_player.buffs; vh_player.buffs = 0; return false; } -MUTATOR_HOOKFUNCTION(buffs_VehicleExit) +MUTATOR_HOOKFUNCTION(buffs, VehicleExit) { vh_player.buffs = vh_vehicle.buffs; vh_vehicle.buffs = 0; return false; } -MUTATOR_HOOKFUNCTION(buffs_PlayerRegen) +MUTATOR_HOOKFUNCTION(buffs, PlayerRegen) {SELFPARAM(); if(self.buffs & BUFF_MEDIC.m_itemid) { @@ -925,19 +939,19 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerRegen) return false; } -MUTATOR_HOOKFUNCTION(buffs_GetCvars) +MUTATOR_HOOKFUNCTION(buffs, GetCvars) { GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_buffs_autoreplace, "cl_buffs_autoreplace"); return false; } -MUTATOR_HOOKFUNCTION(buffs_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsString) { ret_string = strcat(ret_string, ":Buffs"); return false; } -MUTATOR_HOOKFUNCTION(buffs_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Buffs"); return false; @@ -958,45 +972,3 @@ void buffs_DelayedInit() } } } - -void buffs_Initialize() -{ - addstat(STAT_BUFFS, AS_INT, buffs); - addstat(STAT_BUFF_TIME, AS_FLOAT, buff_time); - - InitializeEntity(world, buffs_DelayedInit, INITPRIO_FINDTARGET); -} - -MUTATOR_DEFINITION(mutator_buffs) -{ - MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, buffs_PlayerDamage_SplitHealthArmor, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, buffs_PlayerDamage_Calculate, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, buffs_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPhysics, buffs_PlayerPhysics, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerJump, buffs_PlayerJump, CBC_ORDER_ANY); - MUTATOR_HOOK(MonsterMove, buffs_MonsterMove, CBC_ORDER_ANY); - MUTATOR_HOOK(SpectateCopy, buffs_SpectateCopy, CBC_ORDER_ANY); - MUTATOR_HOOK(VehicleEnter, buffs_VehicleEnter, CBC_ORDER_ANY); - MUTATOR_HOOK(VehicleExit, buffs_VehicleExit, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerRegen, buffs_PlayerRegen, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, buffs_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerUseKey, buffs_PlayerUseKey, CBC_ORDER_FIRST); - MUTATOR_HOOK(ForbidThrowCurrentWeapon, buffs_PlayerThrowKey, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, buffs_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, buffs_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(OnEntityPreSpawn, buffs_OnEntityPreSpawn, CBC_ORDER_LAST); - MUTATOR_HOOK(CustomizeWaypoint, buffs_CustomizeWaypoint, CBC_ORDER_ANY); - MUTATOR_HOOK(WeaponRateFactor, buffs_WeaponRate, CBC_ORDER_ANY); - MUTATOR_HOOK(WeaponSpeedFactor, buffs_WeaponSpeed, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, buffs_PlayerThink, CBC_ORDER_ANY); - MUTATOR_HOOK(GetCvars, buffs_GetCvars, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, buffs_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, buffs_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - MUTATOR_ONADD - { - buffs_Initialize(); - } - - return false; -} diff --git a/qcsrc/server/mutators/mutator_campcheck.qc b/qcsrc/server/mutators/mutator_campcheck.qc index 4acc75405..04598edc2 100644 --- a/qcsrc/server/mutators/mutator_campcheck.qc +++ b/qcsrc/server/mutators/mutator_campcheck.qc @@ -3,17 +3,19 @@ #include "../campaign.qh" +REGISTER_MUTATOR(campcheck, cvar("g_campcheck")); + .float campcheck_nextcheck; .float campcheck_traveled_distance; -MUTATOR_HOOKFUNCTION(campcheck_PlayerDies) +MUTATOR_HOOKFUNCTION(campcheck, PlayerDies) {SELFPARAM(); Kill_Notification(NOTIF_ONE, self, MSG_CENTER_CPID, CPID_CAMPCHECK); return false; } -MUTATOR_HOOKFUNCTION(campcheck_PlayerDamage) +MUTATOR_HOOKFUNCTION(campcheck, PlayerDamage_Calculate) { if(IS_PLAYER(frag_target)) if(IS_PLAYER(frag_attacker)) @@ -26,7 +28,7 @@ MUTATOR_HOOKFUNCTION(campcheck_PlayerDamage) return false; } -MUTATOR_HOOKFUNCTION(campcheck_PlayerThink) +MUTATOR_HOOKFUNCTION(campcheck, PlayerPreThink) {SELFPARAM(); if(!gameover) if(!warmup_stage) // don't consider it camping during warmup? @@ -72,7 +74,7 @@ MUTATOR_HOOKFUNCTION(campcheck_PlayerThink) return false; } -MUTATOR_HOOKFUNCTION(campcheck_PlayerSpawn) +MUTATOR_HOOKFUNCTION(campcheck, PlayerSpawn) {SELFPARAM(); self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2; self.campcheck_traveled_distance = 0; @@ -80,19 +82,8 @@ MUTATOR_HOOKFUNCTION(campcheck_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(campcheck_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(campcheck, BuildMutatorsString) { ret_string = strcat(ret_string, ":CampCheck"); return false; } - -MUTATOR_DEFINITION(mutator_campcheck) -{ - MUTATOR_HOOK(PlayerDies, campcheck_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, campcheck_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, campcheck_PlayerThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, campcheck_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, campcheck_BuildMutatorsString, CBC_ORDER_ANY); - - return false; -} diff --git a/qcsrc/server/mutators/mutator_dodging.qc b/qcsrc/server/mutators/mutator_dodging.qc index e9dd6fd73..e41456ad5 100644 --- a/qcsrc/server/mutators/mutator_dodging.qc +++ b/qcsrc/server/mutators/mutator_dodging.qc @@ -50,6 +50,35 @@ .float stat_dodging_up_speed; .float stat_dodging_wall; +REGISTER_MUTATOR(dodging, cvar("g_dodging")) +{ + // this just turns on the cvar. + MUTATOR_ONADD + { + g_dodging = cvar("g_dodging"); + addstat(STAT_DODGING, AS_INT, stat_dodging); + addstat(STAT_DODGING_DELAY, AS_FLOAT, stat_dodging_delay); + addstat(STAT_DODGING_TIMEOUT, AS_FLOAT, cvar_cl_dodging_timeout); // we stat this, so it is updated on the client when updated on server (otherwise, chaos) + addstat(STAT_DODGING_FROZEN_NO_DOUBLETAP, AS_INT, stat_dodging_frozen_nodoubletap); + addstat(STAT_DODGING_HORIZ_SPEED_FROZEN, AS_FLOAT, stat_dodging_horiz_speed_frozen); + addstat(STAT_DODGING_FROZEN, AS_INT, stat_dodging_frozen); + addstat(STAT_DODGING_HORIZ_SPEED, AS_FLOAT, stat_dodging_horiz_speed); + addstat(STAT_DODGING_HEIGHT_THRESHOLD, AS_FLOAT, stat_dodging_height_threshold); + addstat(STAT_DODGING_DISTANCE_THRESHOLD, AS_FLOAT, stat_dodging_distance_threshold); + addstat(STAT_DODGING_RAMP_TIME, AS_FLOAT, stat_dodging_ramp_time); + addstat(STAT_DODGING_UP_SPEED, AS_FLOAT, stat_dodging_up_speed); + addstat(STAT_DODGING_WALL, AS_FLOAT, stat_dodging_wall); + } + + // this just turns off the cvar. + MUTATOR_ONROLLBACK_OR_REMOVE + { + g_dodging = 0; + } + + return false; +} + #endif // set to 1 to indicate dodging has started.. reset by physics hook after dodge has been done.. @@ -96,22 +125,6 @@ void dodging_UpdateStats() self.stat_dodging_wall = PHYS_DODGING_WALL; } -void dodging_Initialize() -{ - addstat(STAT_DODGING, AS_INT, stat_dodging); - addstat(STAT_DODGING_DELAY, AS_FLOAT, stat_dodging_delay); - addstat(STAT_DODGING_TIMEOUT, AS_FLOAT, cvar_cl_dodging_timeout); // we stat this, so it is updated on the client when updated on server (otherwise, chaos) - addstat(STAT_DODGING_FROZEN_NO_DOUBLETAP, AS_INT, stat_dodging_frozen_nodoubletap); - addstat(STAT_DODGING_HORIZ_SPEED_FROZEN, AS_FLOAT, stat_dodging_horiz_speed_frozen); - addstat(STAT_DODGING_FROZEN, AS_INT, stat_dodging_frozen); - addstat(STAT_DODGING_HORIZ_SPEED, AS_FLOAT, stat_dodging_horiz_speed); - addstat(STAT_DODGING_HEIGHT_THRESHOLD, AS_FLOAT, stat_dodging_height_threshold); - addstat(STAT_DODGING_DISTANCE_THRESHOLD, AS_FLOAT, stat_dodging_distance_threshold); - addstat(STAT_DODGING_RAMP_TIME, AS_FLOAT, stat_dodging_ramp_time); - addstat(STAT_DODGING_UP_SPEED, AS_FLOAT, stat_dodging_up_speed); - addstat(STAT_DODGING_WALL, AS_FLOAT, stat_dodging_wall); -} - #endif // returns 1 if the player is close to a wall @@ -277,13 +290,13 @@ void PM_dodging() #ifdef SVQC -MUTATOR_HOOKFUNCTION(dodging_GetCvars) +MUTATOR_HOOKFUNCTION(dodging, GetCvars) { GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_dodging_timeout, "cl_dodging_timeout"); return false; } -MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) +MUTATOR_HOOKFUNCTION(dodging, PlayerPhysics) { // print("dodging_PlayerPhysics\n"); PM_dodging(); @@ -291,38 +304,11 @@ MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) return false; } -MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) +MUTATOR_HOOKFUNCTION(dodging, GetPressedKeys) { PM_dodging_checkpressedkeys(); return false; } -MUTATOR_DEFINITION(mutator_dodging) -{ - // we need to be called before GetPressedKey does its thing so we can - // detect state changes and therefore dodging actions.. - MUTATOR_HOOK(GetPressedKeys, dodging_GetPressedKeys, CBC_ORDER_ANY); - - // in the physics hook we actually implement the dodge.. - MUTATOR_HOOK(PlayerPhysics, dodging_PlayerPhysics, CBC_ORDER_ANY); - - // get timeout information from the client, so the client can configure it.. - MUTATOR_HOOK(GetCvars, dodging_GetCvars, CBC_ORDER_ANY); - - // this just turns on the cvar. - MUTATOR_ONADD - { - g_dodging = cvar("g_dodging"); - dodging_Initialize(); - } - - // this just turns off the cvar. - MUTATOR_ONROLLBACK_OR_REMOVE - { - g_dodging = 0; - } - - return false; -} #endif diff --git a/qcsrc/server/mutators/mutator_invincibleproj.qc b/qcsrc/server/mutators/mutator_invincibleproj.qc index 2855a074f..3f76bf727 100644 --- a/qcsrc/server/mutators/mutator_invincibleproj.qc +++ b/qcsrc/server/mutators/mutator_invincibleproj.qc @@ -1,7 +1,9 @@ #include "mutator.qh" -MUTATOR_HOOKFUNCTION(invincibleprojectiles_EditProjectile) +REGISTER_MUTATOR(invincibleprojectiles, cvar("g_invincible_projectiles")); + +MUTATOR_HOOKFUNCTION(invincibleprojectiles, EditProjectile) { if(other.health) { @@ -11,23 +13,14 @@ MUTATOR_HOOKFUNCTION(invincibleprojectiles_EditProjectile) return 0; } -MUTATOR_HOOKFUNCTION(invincibleprojectiles_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(invincibleprojectiles, BuildMutatorsString) { ret_string = strcat(ret_string, ":InvincibleProjectiles"); return 0; } -MUTATOR_HOOKFUNCTION(invincibleprojectiles_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(invincibleprojectiles, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Invincible Projectiles"); return 0; } - -MUTATOR_DEFINITION(mutator_invincibleprojectiles) -{ - MUTATOR_HOOK(EditProjectile, invincibleprojectiles_EditProjectile, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, invincibleprojectiles_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, invincibleprojectiles_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - return 0; -} diff --git a/qcsrc/server/mutators/mutator_melee_only.qc b/qcsrc/server/mutators/mutator_melee_only.qc index 019eeb801..f85260d86 100644 --- a/qcsrc/server/mutators/mutator_melee_only.qc +++ b/qcsrc/server/mutators/mutator_melee_only.qc @@ -1,7 +1,9 @@ #include "mutator.qh" -MUTATOR_HOOKFUNCTION(melee_SetStartItems) +REGISTER_MUTATOR(melee_only, cvar("g_melee_only") && !cvar("g_instagib") && !g_nexball); + +MUTATOR_HOOKFUNCTION(melee_only, SetStartItems) { start_ammo_shells = warmup_start_ammo_shells = 0; start_weapons = warmup_start_weapons = WEPSET(SHOTGUN); @@ -9,12 +11,12 @@ MUTATOR_HOOKFUNCTION(melee_SetStartItems) return false; } -MUTATOR_HOOKFUNCTION(melee_ForbidThrowing) +MUTATOR_HOOKFUNCTION(melee_only, ForbidThrowCurrentWeapon) { return true; } -MUTATOR_HOOKFUNCTION(melee_FilterItem) +MUTATOR_HOOKFUNCTION(melee_only, FilterItem) {SELFPARAM(); switch (self.items) { @@ -26,25 +28,14 @@ MUTATOR_HOOKFUNCTION(melee_FilterItem) return true; } -MUTATOR_HOOKFUNCTION(melee_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(melee_only, BuildMutatorsString) { ret_string = strcat(ret_string, ":MeleeOnly"); return false; } -MUTATOR_HOOKFUNCTION(melee_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(melee_only, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Melee Only Arena"); return false; } - -MUTATOR_DEFINITION(mutator_melee_only) -{ - MUTATOR_HOOK(SetStartItems, melee_SetStartItems, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidThrowCurrentWeapon, melee_ForbidThrowing, CBC_ORDER_ANY); - MUTATOR_HOOK(FilterItem, melee_FilterItem, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, melee_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, melee_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - return false; -} diff --git a/qcsrc/server/mutators/mutator_midair.qc b/qcsrc/server/mutators/mutator_midair.qc index 33ae58f4d..4dfb7d5fb 100644 --- a/qcsrc/server/mutators/mutator_midair.qc +++ b/qcsrc/server/mutators/mutator_midair.qc @@ -1,9 +1,11 @@ #include "mutator.qh" +REGISTER_MUTATOR(midair, cvar("g_midair")); + .float midair_shieldtime; -MUTATOR_HOOKFUNCTION(midair_PlayerDamage) +MUTATOR_HOOKFUNCTION(midair, PlayerDamage_Calculate) {SELFPARAM(); if(IS_PLAYER(frag_attacker)) if(IS_PLAYER(frag_target)) @@ -13,7 +15,7 @@ MUTATOR_HOOKFUNCTION(midair_PlayerDamage) return false; } -MUTATOR_HOOKFUNCTION(midair_PlayerPowerups) +MUTATOR_HOOKFUNCTION(midair, PlayerPowerups) {SELFPARAM(); if(time >= game_starttime) if(self.flags & FL_ONGROUND) @@ -25,7 +27,7 @@ MUTATOR_HOOKFUNCTION(midair_PlayerPowerups) return false; } -MUTATOR_HOOKFUNCTION(midair_PlayerSpawn) +MUTATOR_HOOKFUNCTION(midair, PlayerSpawn) {SELFPARAM(); if(IS_BOT_CLIENT(self)) self.bot_moveskill = 0; // disable bunnyhopping @@ -33,25 +35,14 @@ MUTATOR_HOOKFUNCTION(midair_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(midair_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(midair, BuildMutatorsString) { ret_string = strcat(ret_string, ":midair"); return false; } -MUTATOR_HOOKFUNCTION(midair_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(midair, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Midair"); return false; } - -MUTATOR_DEFINITION(mutator_midair) -{ - MUTATOR_HOOK(PlayerDamage_Calculate, midair_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPowerups, midair_PlayerPowerups, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, midair_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, midair_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, midair_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - return false; -} diff --git a/qcsrc/server/mutators/mutator_multijump.qc b/qcsrc/server/mutators/mutator_multijump.qc index de6296d82..d36f281a1 100644 --- a/qcsrc/server/mutators/mutator_multijump.qc +++ b/qcsrc/server/mutators/mutator_multijump.qc @@ -138,7 +138,16 @@ bool PM_multijump_checkjump() } #ifdef SVQC -MUTATOR_HOOKFUNCTION(multijump_PlayerPhysics) +REGISTER_MUTATOR(multijump, cvar("g_multijump")) +{ + MUTATOR_ONADD + { + multijump_AddStats(); + } + return false; +} + +MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics) { multijump_UpdateStats(); PM_multijump(); @@ -146,42 +155,27 @@ MUTATOR_HOOKFUNCTION(multijump_PlayerPhysics) return false; } -MUTATOR_HOOKFUNCTION(multijump_PlayerJump) +MUTATOR_HOOKFUNCTION(multijump, PlayerJump) { return PM_multijump_checkjump(); } -MUTATOR_HOOKFUNCTION(multijump_GetCvars) +MUTATOR_HOOKFUNCTION(multijump, GetCvars) { GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_multijump, "cl_multijump"); return false; } -MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(multijump, BuildMutatorsString) { ret_string = strcat(ret_string, ":multijump"); return false; } -MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(multijump, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Multi jump"); return false; } -MUTATOR_DEFINITION(mutator_multijump) -{ - MUTATOR_HOOK(PlayerPhysics, multijump_PlayerPhysics, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerJump, multijump_PlayerJump, CBC_ORDER_ANY); - MUTATOR_HOOK(GetCvars, multijump_GetCvars, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, multijump_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, multijump_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - MUTATOR_ONADD - { - multijump_AddStats(); - } - - return false; -} #endif diff --git a/qcsrc/server/mutators/mutator_nades.qc b/qcsrc/server/mutators/mutator_nades.qc index bf55e6704..fc1f1d1e7 100644 --- a/qcsrc/server/mutators/mutator_nades.qc +++ b/qcsrc/server/mutators/mutator_nades.qc @@ -10,6 +10,21 @@ #include "../../common/monsters/sv_monsters.qh" #include "../g_subs.qh" +REGISTER_MUTATOR(nades, cvar("g_nades")) +{ + MUTATOR_ONADD + { + addstat(STAT_NADE_TIMER, AS_FLOAT, nade_timer); + addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades); + addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type); + addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score); + addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb); + addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha); + } + + return false; +} + .float nade_time_primed; .entity nade_spawnloc; @@ -906,7 +921,7 @@ void nades_Clear(entity player) player.nade_timer = 0; } -MUTATOR_HOOKFUNCTION(nades_VehicleEnter) +MUTATOR_HOOKFUNCTION(nades, VehicleEnter) { if(vh_player.nade) toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05)); @@ -951,7 +966,7 @@ CLASS(NadeOffhand, OffhandWeapon) ENDCLASS(NadeOffhand) NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); } -MUTATOR_HOOKFUNCTION(nades_CheckThrow) +MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST) { if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) { nades_CheckThrow(); @@ -960,7 +975,7 @@ MUTATOR_HOOKFUNCTION(nades_CheckThrow) return false; } -MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) +MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) {SELFPARAM(); if (!IS_PLAYER(self)) { return false; } @@ -1052,7 +1067,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) return false; } -MUTATOR_HOOKFUNCTION(nades_PlayerSpawn) +MUTATOR_HOOKFUNCTION(nades, PlayerSpawn) {SELFPARAM(); if(autocvar_g_nades_spawn) self.nade_refire = time + autocvar_g_spawnshieldtime; @@ -1081,7 +1096,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(nades_PlayerDies) +MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST) { if(frag_target.nade) if(!frag_target.frozen || !autocvar_g_freezetag_revive_nade) @@ -1115,7 +1130,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerDies) return false; } -MUTATOR_HOOKFUNCTION(nades_PlayerDamage) +MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate) { if(frag_target.frozen) if(autocvar_g_freezetag_revive_nade) @@ -1135,7 +1150,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerDamage) return false; } -MUTATOR_HOOKFUNCTION(nades_MonsterDies) +MUTATOR_HOOKFUNCTION(nades, MonsterDies) {SELFPARAM(); if(IS_PLAYER(frag_attacker)) if(DIFF_TEAM(frag_attacker, self)) @@ -1145,14 +1160,18 @@ MUTATOR_HOOKFUNCTION(nades_MonsterDies) return false; } -MUTATOR_HOOKFUNCTION(nades_RemovePlayer) +bool nades_RemovePlayer() {SELFPARAM(); nades_Clear(self); nades_RemoveBonus(self); return false; } -MUTATOR_HOOKFUNCTION(nades_SpectateCopy) +MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { nades_RemovePlayer(); } +MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { nades_RemovePlayer(); } +MUTATOR_HOOKFUNCTION(nades, reset_map_global) { nades_RemovePlayer(); } + +MUTATOR_HOOKFUNCTION(nades, SpectateCopy) {SELFPARAM(); self.nade_timer = other.nade_timer; self.nade_type = other.nade_type; @@ -1164,7 +1183,7 @@ MUTATOR_HOOKFUNCTION(nades_SpectateCopy) return false; } -MUTATOR_HOOKFUNCTION(nades_GetCvars) +MUTATOR_HOOKFUNCTION(nades, GetCvars) { GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type"); GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type"); @@ -1172,49 +1191,14 @@ MUTATOR_HOOKFUNCTION(nades_GetCvars) return false; } -MUTATOR_HOOKFUNCTION(nades_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString) { ret_string = strcat(ret_string, ":Nades"); return false; } -MUTATOR_HOOKFUNCTION(nades_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Nades"); return false; } - -void nades_Initialize() -{ - addstat(STAT_NADE_TIMER, AS_FLOAT, nade_timer); - addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades); - addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type); - addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score); - addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb); - addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha); -} - -MUTATOR_DEFINITION(mutator_nades) -{ - MUTATOR_HOOK(ForbidThrowCurrentWeapon, nades_CheckThrow, CBC_ORDER_LAST); - MUTATOR_HOOK(VehicleEnter, nades_VehicleEnter, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, nades_PlayerPreThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, nades_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, nades_PlayerDies, CBC_ORDER_LAST); - MUTATOR_HOOK(PlayerDamage_Calculate, nades_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(MonsterDies, nades_MonsterDies, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, nades_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, nades_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(SpectateCopy, nades_SpectateCopy, CBC_ORDER_ANY); - MUTATOR_HOOK(GetCvars, nades_GetCvars, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_global, nades_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, nades_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, nades_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - MUTATOR_ONADD - { - nades_Initialize(); - } - - return false; -} diff --git a/qcsrc/server/mutators/mutator_new_toys.qc b/qcsrc/server/mutators/mutator_new_toys.qc index 93b64ebcc..d7fc5257e 100644 --- a/qcsrc/server/mutators/mutator_new_toys.qc +++ b/qcsrc/server/mutators/mutator_new_toys.qc @@ -69,6 +69,37 @@ roflsound "New toys, new toys!" sound. */ +bool nt_IsNewToy(int w); + +REGISTER_MUTATOR(nt, cvar("g_new_toys") && !cvar("g_instagib") && !cvar("g_overkill")) +{ + MUTATOR_ONADD + { + if(time > 1) // game loads at time 1 + error("This cannot be added at runtime\n"); + + // mark the guns as ok to use by e.g. impulse 99 + for(int i = WEP_FIRST; i <= WEP_LAST; ++i) + if(nt_IsNewToy(i)) + get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED; + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + for(int i = WEP_FIRST; i <= WEP_LAST; ++i) + if(nt_IsNewToy(i)) + get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED; + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This cannot be removed at runtime\n"); + return -1; + } + + return 0; +} + .string new_toys; float autocvar_g_new_toys_autoreplace; @@ -77,13 +108,13 @@ const float NT_AUTOREPLACE_NEVER = 0; const float NT_AUTOREPLACE_ALWAYS = 1; const float NT_AUTOREPLACE_RANDOM = 2; -MUTATOR_HOOKFUNCTION(nt_SetModname) +MUTATOR_HOOKFUNCTION(nt, SetModname) { modname = "NewToys"; return 0; } -float nt_IsNewToy(float w) +bool nt_IsNewToy(int w) { switch(w) { @@ -123,7 +154,7 @@ string nt_GetReplacement(string w, float m) return s; } -MUTATOR_HOOKFUNCTION(nt_SetStartItems) +MUTATOR_HOOKFUNCTION(nt, SetStartItems) { // rearrange start_weapon_default // apply those bits that are set by start_weapon_defaultmask @@ -167,7 +198,7 @@ MUTATOR_HOOKFUNCTION(nt_SetStartItems) return 0; } -MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace) +MUTATOR_HOOKFUNCTION(nt, SetWeaponreplace) {SELFPARAM(); // otherwise, we do replace if(self.new_toys) @@ -187,7 +218,7 @@ MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace) return 0; } -MUTATOR_HOOKFUNCTION(nt_FilterItem) +MUTATOR_HOOKFUNCTION(nt, FilterItem) {SELFPARAM(); if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound) { self.item_pickupsound = string_null; @@ -195,39 +226,3 @@ MUTATOR_HOOKFUNCTION(nt_FilterItem) } return 0; } - -MUTATOR_DEFINITION(mutator_new_toys) -{ - MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY); - MUTATOR_HOOK(SetStartItems, nt_SetStartItems, CBC_ORDER_ANY); - MUTATOR_HOOK(SetWeaponreplace, nt_SetWeaponreplace, CBC_ORDER_LAST); - MUTATOR_HOOK(FilterItem, nt_FilterItem, CBC_ORDER_ANY); - - MUTATOR_ONADD - { - if(time > 1) // game loads at time 1 - error("This cannot be added at runtime\n"); - - // mark the guns as ok to use by e.g. impulse 99 - float i; - for(i = WEP_FIRST; i <= WEP_LAST; ++i) - if(nt_IsNewToy(i)) - get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED; - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - float i; - for(i = WEP_FIRST; i <= WEP_LAST; ++i) - if(nt_IsNewToy(i)) - get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED; - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This cannot be removed at runtime\n"); - return -1; - } - - return 0; -} diff --git a/qcsrc/server/mutators/mutator_nix.qc b/qcsrc/server/mutators/mutator_nix.qc index 2a26d9326..96e8ca97b 100644 --- a/qcsrc/server/mutators/mutator_nix.qc +++ b/qcsrc/server/mutators/mutator_nix.qc @@ -10,10 +10,53 @@ float nix_nextweapon; .float nix_lastinfotime; .float nix_nextincr; -float NIX_CanChooseWeapon(float wpn) +bool NIX_CanChooseWeapon(int wpn); + +REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill")) +{ + MUTATOR_ONADD + { + g_nix_with_blaster = autocvar_g_nix_with_blaster; + + nix_nextchange = 0; + nix_nextweapon = 0; + + for (int i = WEP_FIRST; i <= WEP_LAST; ++i) + if (NIX_CanChooseWeapon(i)) { + Weapon w = get_weaponinfo(i); + w.wr_init(w); + } + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // nothing to roll back + } + + MUTATOR_ONREMOVE + { + // as the PlayerSpawn hook will no longer run, NIX is turned off by this! + entity e; + FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO) + { + e.ammo_cells = start_ammo_cells; + e.ammo_plasma = start_ammo_plasma; + e.ammo_shells = start_ammo_shells; + e.ammo_nails = start_ammo_nails; + e.ammo_rockets = start_ammo_rockets; + e.ammo_fuel = start_ammo_fuel; + e.weapons = start_weapons; + if(!client_hasweapon(e, e.weapon, true, false)) + e.switchweapon = w_getbestweapon(self); + } + } + + return 0; +} + +bool NIX_CanChooseWeapon(int wpn) { - entity e; - e = get_weaponinfo(wpn); + entity e = get_weaponinfo(wpn); if(!e.weapon) // skip dummies return false; if(g_weaponarena) @@ -23,7 +66,7 @@ float NIX_CanChooseWeapon(float wpn) } else { - if(wpn == WEP_BLASTER.m_id && g_nix_with_blaster) // WEAPONTODO: rename to g_nix_with_blaster + if(wpn == WEP_BLASTER.m_id && g_nix_with_blaster) return false; if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED) return false; @@ -152,34 +195,24 @@ void NIX_GiveCurrentWeapon() W_SwitchWeapon(nix_weapon); } -void NIX_precache() -{ - float i; - for (i = WEP_FIRST; i <= WEP_LAST; ++i) - if (NIX_CanChooseWeapon(i)) { - Weapon w = get_weaponinfo(i); - w.wr_init(w); - } -} - -MUTATOR_HOOKFUNCTION(nix_ForbidThrowCurrentWeapon) +MUTATOR_HOOKFUNCTION(nix, ForbidThrowCurrentWeapon) { return 1; // no throwing in NIX } -MUTATOR_HOOKFUNCTION(nix_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(nix, BuildMutatorsString) { ret_string = strcat(ret_string, ":NIX"); return 0; } -MUTATOR_HOOKFUNCTION(nix_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(nix, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", NIX"); return 0; } -MUTATOR_HOOKFUNCTION(nix_FilterItem) +MUTATOR_HOOKFUNCTION(nix, FilterItem) {SELFPARAM(); switch (self.items) { @@ -204,14 +237,14 @@ MUTATOR_HOOKFUNCTION(nix_FilterItem) return 1; // delete all other items } -MUTATOR_HOOKFUNCTION(nix_OnEntityPreSpawn) +MUTATOR_HOOKFUNCTION(nix, OnEntityPreSpawn) {SELFPARAM(); if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo) return 1; return 0; } -MUTATOR_HOOKFUNCTION(nix_PlayerPreThink) +MUTATOR_HOOKFUNCTION(nix, PlayerPreThink) {SELFPARAM(); if(!intermission_running) if(self.deadflag == DEAD_NO) @@ -220,7 +253,7 @@ MUTATOR_HOOKFUNCTION(nix_PlayerPreThink) return 0; } -MUTATOR_HOOKFUNCTION(nix_PlayerSpawn) +MUTATOR_HOOKFUNCTION(nix, PlayerSpawn) {SELFPARAM(); self.nix_lastchange_id = -1; NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning @@ -228,57 +261,8 @@ MUTATOR_HOOKFUNCTION(nix_PlayerSpawn) return 0; } -MUTATOR_HOOKFUNCTION(nix_SetModname) +MUTATOR_HOOKFUNCTION(nix, SetModname, CBC_ORDER_LAST) { modname = "NIX"; return 0; } - -MUTATOR_DEFINITION(mutator_nix) -{SELFPARAM(); - entity e; - - MUTATOR_HOOK(ForbidThrowCurrentWeapon, nix_ForbidThrowCurrentWeapon, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, nix_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, nix_BuildMutatorsPrettyString, CBC_ORDER_ANY); - MUTATOR_HOOK(FilterItem, nix_FilterItem, CBC_ORDER_ANY); - MUTATOR_HOOK(OnEntityPreSpawn, nix_OnEntityPreSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, nix_PlayerPreThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, nix_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(SetModname, nix_SetModname, CBC_ORDER_LAST); - - MUTATOR_ONADD - { - g_nix_with_blaster = autocvar_g_nix_with_blaster; - - nix_nextchange = 0; - nix_nextweapon = 0; - - NIX_precache(); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // nothing to roll back - } - - MUTATOR_ONREMOVE - { - // as the PlayerSpawn hook will no longer run, NIX is turned off by this! - - FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO) - { - e.ammo_cells = start_ammo_cells; - e.ammo_plasma = start_ammo_plasma; - e.ammo_shells = start_ammo_shells; - e.ammo_nails = start_ammo_nails; - e.ammo_rockets = start_ammo_rockets; - e.ammo_fuel = start_ammo_fuel; - e.weapons = start_weapons; - if(!client_hasweapon(e, e.weapon, true, false)) - e.switchweapon = w_getbestweapon(self); - } - } - - return 0; -} diff --git a/qcsrc/server/mutators/mutator_overkill.qc b/qcsrc/server/mutators/mutator_overkill.qc index 5d1a9cd06..79607a1aa 100644 --- a/qcsrc/server/mutators/mutator_overkill.qc +++ b/qcsrc/server/mutators/mutator_overkill.qc @@ -2,6 +2,24 @@ #include "mutator.qh" +void ok_Initialize(); + +REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill") +{ + MUTATOR_ONADD + { + ok_Initialize(); + } + + MUTATOR_ONREMOVE + { + WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED; + WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED; + } + + return false; +} + void W_Blaster_Attack(entity, float, float, float, float, float, float, float, float, float, float); spawnfunc(weapon_hmg); spawnfunc(weapon_rpc); @@ -42,7 +60,7 @@ float ok_CheckWeaponCharge(entity ent, int wep) return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname))); } -MUTATOR_HOOKFUNCTION(ok_PlayerDamage_Calculate) +MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST) { if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target)) if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER)) @@ -62,14 +80,14 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDamage_Calculate) return false; } -MUTATOR_HOOKFUNCTION(ok_PlayerDamage_SplitHealthArmor) +MUTATOR_HOOKFUNCTION(ok, PlayerDamage_SplitHealthArmor) {SELFPARAM(); if(damage_take) self.ok_pauseregen_finished = max(self.ok_pauseregen_finished, time + 2); return false; } -MUTATOR_HOOKFUNCTION(ok_PlayerDies) +MUTATOR_HOOKFUNCTION(ok, PlayerDies) {SELFPARAM(); entity targ = ((frag_attacker) ? frag_attacker : frag_target); @@ -97,8 +115,9 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDies) return false; } +MUTATOR_HOOKFUNCTION(ok, MonsterDropItem) { ok_PlayerDies(); } -MUTATOR_HOOKFUNCTION(ok_PlayerRegen) +MUTATOR_HOOKFUNCTION(ok, PlayerRegen) {SELFPARAM(); // overkill's values are different, so use custom regen if(!self.frozen) @@ -117,12 +136,12 @@ MUTATOR_HOOKFUNCTION(ok_PlayerRegen) return true; // return true anyway, as frozen uses no regen } -MUTATOR_HOOKFUNCTION(ok_ForbidThrowCurrentWeapon) +MUTATOR_HOOKFUNCTION(ok, ForbidThrowCurrentWeapon) { return true; } -MUTATOR_HOOKFUNCTION(ok_PlayerPreThink) +MUTATOR_HOOKFUNCTION(ok, PlayerPreThink) {SELFPARAM(); if(intermission_running || gameover) return false; @@ -188,7 +207,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerPreThink) return false; } -MUTATOR_HOOKFUNCTION(ok_PlayerSpawn) +MUTATOR_HOOKFUNCTION(ok, PlayerSpawn) {SELFPARAM(); if(autocvar_g_overkill_ammo_charge) { @@ -209,7 +228,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerSpawn) void _spawnfunc_weapon_hmg() { SELFPARAM(); spawnfunc_weapon_hmg(this); } void _spawnfunc_weapon_rpc() { SELFPARAM(); spawnfunc_weapon_rpc(this); } -MUTATOR_HOOKFUNCTION(ok_OnEntityPreSpawn) +MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn) {SELFPARAM(); if(autocvar_g_powerups) if(autocvar_g_overkill_powerups_replace) @@ -252,7 +271,7 @@ MUTATOR_HOOKFUNCTION(ok_OnEntityPreSpawn) return false; } -MUTATOR_HOOKFUNCTION(ok_ItemRemove) +MUTATOR_HOOKFUNCTION(ok, FilterItem) {SELFPARAM(); if(self.ok_item) return false; @@ -266,7 +285,7 @@ MUTATOR_HOOKFUNCTION(ok_ItemRemove) return true; } -MUTATOR_HOOKFUNCTION(ok_SpectateCopy) +MUTATOR_HOOKFUNCTION(ok, SpectateCopy) {SELFPARAM(); self.ammo_charge[self.weapon] = other.ammo_charge[other.weapon]; self.ok_use_ammocharge = other.ok_use_ammocharge; @@ -274,7 +293,7 @@ MUTATOR_HOOKFUNCTION(ok_SpectateCopy) return false; } -MUTATOR_HOOKFUNCTION(ok_StartItems) +MUTATOR_HOOKFUNCTION(ok, SetStartItems) { WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN)); @@ -287,19 +306,19 @@ MUTATOR_HOOKFUNCTION(ok_StartItems) return false; } -MUTATOR_HOOKFUNCTION(ok_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString) { ret_string = strcat(ret_string, ":OK"); return false; } -MUTATOR_HOOKFUNCTION(ok_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(ok, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Overkill"); return false; } -MUTATOR_HOOKFUNCTION(ok_SetModname) +MUTATOR_HOOKFUNCTION(ok, SetModname) { modname = "Overkill"; return true; @@ -330,35 +349,3 @@ void ok_Initialize() WEP_MACHINEGUN.mdl = "ok_mg"; WEP_VORTEX.mdl = "ok_sniper"; } - -MUTATOR_DEFINITION(mutator_overkill) -{ - MUTATOR_HOOK(ForbidThrowCurrentWeapon, ok_ForbidThrowCurrentWeapon, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, ok_PlayerPreThink, CBC_ORDER_LAST); - MUTATOR_HOOK(PlayerSpawn, ok_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, ok_PlayerDamage_Calculate, CBC_ORDER_LAST); - MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, ok_PlayerDamage_SplitHealthArmor, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, ok_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerRegen, ok_PlayerRegen, CBC_ORDER_ANY); - MUTATOR_HOOK(OnEntityPreSpawn, ok_OnEntityPreSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(FilterItem, ok_ItemRemove, CBC_ORDER_ANY); - MUTATOR_HOOK(MonsterDropItem, ok_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(SpectateCopy, ok_SpectateCopy, CBC_ORDER_ANY); - MUTATOR_HOOK(SetStartItems, ok_StartItems, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, ok_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, ok_BuildMutatorsPrettyString, CBC_ORDER_ANY); - MUTATOR_HOOK(SetModname, ok_SetModname, CBC_ORDER_ANY); - - MUTATOR_ONADD - { - ok_Initialize(); - } - - MUTATOR_ONREMOVE - { - WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED; - WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED; - } - - return false; -} diff --git a/qcsrc/server/mutators/mutator_physical_items.qc b/qcsrc/server/mutators/mutator_physical_items.qc index d1272319e..4bcf495f7 100644 --- a/qcsrc/server/mutators/mutator_physical_items.qc +++ b/qcsrc/server/mutators/mutator_physical_items.qc @@ -1,6 +1,32 @@ #include "mutator.qh" +REGISTER_MUTATOR(physical_items, cvar("g_physical_items")) +{ + // check if we have a physics engine + MUTATOR_ONADD + { + if (!(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE"))) + { + LOG_TRACE("Warning: Physical items are enabled but no physics engine can be used. Reverting to old items.\n"); + return -1; + } + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // nothing to roll back + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This cannot be removed at runtime\n"); + return -1; + } + + return 0; +} + .vector spawn_origin, spawn_angles; void physical_item_think() @@ -60,7 +86,7 @@ void physical_item_damage(entity inflictor, entity attacker, float damage, int d } } -MUTATOR_HOOKFUNCTION(item_spawning) +MUTATOR_HOOKFUNCTION(physical_items, Item_Spawn) {SELFPARAM(); if(self.owner == world && autocvar_g_physical_items <= 1) return false; @@ -112,31 +138,3 @@ MUTATOR_HOOKFUNCTION(item_spawning) return false; } - -MUTATOR_DEFINITION(mutator_physical_items) -{ - MUTATOR_HOOK(Item_Spawn, item_spawning, CBC_ORDER_ANY); - - // check if we have a physics engine - MUTATOR_ONADD - { - if (!(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE"))) - { - LOG_TRACE("Warning: Physical items are enabled but no physics engine can be used. Reverting to old items.\n"); - return -1; - } - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // nothing to roll back - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This cannot be removed at runtime\n"); - return -1; - } - - return 0; -} diff --git a/qcsrc/server/mutators/mutator_pinata.qc b/qcsrc/server/mutators/mutator_pinata.qc index 4c450a85c..a531d6bec 100644 --- a/qcsrc/server/mutators/mutator_pinata.qc +++ b/qcsrc/server/mutators/mutator_pinata.qc @@ -1,10 +1,11 @@ #include "mutator.qh" -MUTATOR_HOOKFUNCTION(pinata_PlayerDies) +REGISTER_MUTATOR(pinata, cvar("g_pinata") && !cvar("g_instagib") && !cvar("g_overkill")); + +MUTATOR_HOOKFUNCTION(pinata, PlayerDies) {SELFPARAM(); - float j; - for(j = WEP_FIRST; j <= WEP_LAST; ++j) + for(int j = WEP_FIRST; j <= WEP_LAST; ++j) if(self.weapons & WepSet_FromWeapon(j)) if(self.switchweapon != j) if(W_IsWeaponThrowable(j)) @@ -13,23 +14,15 @@ MUTATOR_HOOKFUNCTION(pinata_PlayerDies) return true; } -MUTATOR_HOOKFUNCTION(pinata_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(pinata, BuildMutatorsString) { ret_string = strcat(ret_string, ":Pinata"); return false; } -MUTATOR_HOOKFUNCTION(pinata_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(pinata, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Piñata"); return false; } -MUTATOR_DEFINITION(mutator_pinata) -{ - MUTATOR_HOOK(PlayerDies, pinata_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, pinata_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, pinata_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - return false; -} diff --git a/qcsrc/server/mutators/mutator_random_gravity.qc b/qcsrc/server/mutators/mutator_random_gravity.qc index ff85f2905..1a927648d 100644 --- a/qcsrc/server/mutators/mutator_random_gravity.qc +++ b/qcsrc/server/mutators/mutator_random_gravity.qc @@ -6,9 +6,19 @@ // Mutator by Mario // Inspired by Player 2 +REGISTER_MUTATOR(random_gravity, cvar("g_random_gravity")) +{ + MUTATOR_ONADD + { + cvar_settemp("sv_gravity", cvar_string("sv_gravity")); // settemp current gravity so it's restored on match end + } + + return false; +} + float gravity_delay; -MUTATOR_HOOKFUNCTION(gravity_StartFrame) +MUTATOR_HOOKFUNCTION(random_gravity, SV_StartFrame) { if(gameover || !cvar("g_random_gravity")) return false; if(time < gravity_delay) return false; @@ -27,28 +37,14 @@ MUTATOR_HOOKFUNCTION(gravity_StartFrame) return false; } -MUTATOR_HOOKFUNCTION(gravity_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(random_gravity, BuildMutatorsString) { ret_string = strcat(ret_string, ":RandomGravity"); return 0; } -MUTATOR_HOOKFUNCTION(gravity_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(random_gravity, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Random gravity"); return 0; } - -MUTATOR_DEFINITION(mutator_random_gravity) -{ - MUTATOR_HOOK(SV_StartFrame, gravity_StartFrame, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, gravity_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, gravity_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - MUTATOR_ONADD - { - cvar_settemp("sv_gravity", cvar_string("sv_gravity")); // settemp current gravity so it's restored on match end - } - - return false; -} diff --git a/qcsrc/server/mutators/mutator_rocketflying.qc b/qcsrc/server/mutators/mutator_rocketflying.qc index c403e9f9c..44ceeaa9e 100644 --- a/qcsrc/server/mutators/mutator_rocketflying.qc +++ b/qcsrc/server/mutators/mutator_rocketflying.qc @@ -1,7 +1,9 @@ #include "mutator.qh" -MUTATOR_HOOKFUNCTION(rocketflying_EditProjectile) +REGISTER_MUTATOR(rocketflying, cvar("g_rocket_flying")); + +MUTATOR_HOOKFUNCTION(rocketflying, EditProjectile) { if(other.classname == "rocket" || other.classname == "mine") { @@ -11,23 +13,14 @@ MUTATOR_HOOKFUNCTION(rocketflying_EditProjectile) return 0; } -MUTATOR_HOOKFUNCTION(rocketflying_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(rocketflying, BuildMutatorsString) { ret_string = strcat(ret_string, ":RocketFlying"); return 0; } -MUTATOR_HOOKFUNCTION(rocketflying_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(rocketflying, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Rocket Flying"); return 0; } - -MUTATOR_DEFINITION(mutator_rocketflying) -{ - MUTATOR_HOOK(EditProjectile, rocketflying_EditProjectile, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, rocketflying_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, rocketflying_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - return 0; -} diff --git a/qcsrc/server/mutators/mutator_spawn_near_teammate.qc b/qcsrc/server/mutators/mutator_spawn_near_teammate.qc index c996f1a12..3bc1f7b3d 100644 --- a/qcsrc/server/mutators/mutator_spawn_near_teammate.qc +++ b/qcsrc/server/mutators/mutator_spawn_near_teammate.qc @@ -1,6 +1,8 @@ #include "mutator.qh" +REGISTER_MUTATOR(spawn_near_teammate, cvar("g_spawn_near_teammate") && teamplay); + .entity msnt_lookat; .float msnt_timer; @@ -8,7 +10,7 @@ .float cvar_cl_spawn_near_teammate; -MUTATOR_HOOKFUNCTION(msnt_Spawn_Score) +MUTATOR_HOOKFUNCTION(spawn_near_teammate, Spawn_Score) {SELFPARAM(); if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate)) return 0; @@ -44,7 +46,7 @@ MUTATOR_HOOKFUNCTION(msnt_Spawn_Score) return 0; } -MUTATOR_HOOKFUNCTION(msnt_PlayerSpawn) +MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) {SELFPARAM(); // Note: when entering this, fixangle is already set. if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate)) @@ -153,24 +155,14 @@ MUTATOR_HOOKFUNCTION(msnt_PlayerSpawn) return 0; } -MUTATOR_HOOKFUNCTION(msnt_PlayerDies) +MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerDies) {SELFPARAM(); self.msnt_deathloc = self.origin; return 0; } -MUTATOR_HOOKFUNCTION(msnt_GetCvars) +MUTATOR_HOOKFUNCTION(spawn_near_teammate, GetCvars) { GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_spawn_near_teammate, "cl_spawn_near_teammate"); return false; } - -MUTATOR_DEFINITION(mutator_spawn_near_teammate) -{ - MUTATOR_HOOK(Spawn_Score, msnt_Spawn_Score, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, msnt_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, msnt_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(GetCvars, msnt_GetCvars, CBC_ORDER_ANY); - - return 0; -} diff --git a/qcsrc/server/mutators/mutator_superspec.qc b/qcsrc/server/mutators/mutator_superspec.qc index e0b5ad35d..f5b3d36fb 100644 --- a/qcsrc/server/mutators/mutator_superspec.qc +++ b/qcsrc/server/mutators/mutator_superspec.qc @@ -1,6 +1,7 @@ - #include "mutator.qh" +REGISTER_MUTATOR(superspec, cvar("g_superspectate")); + #define _SSMAGIX "SUPERSPEC_OPTIONSFILE_V1" #define _ISLOCAL ((edict_num(1) == self) ? true : false) @@ -97,7 +98,7 @@ float superspec_filteritem(entity _for, entity _item) return false; } -MUTATOR_HOOKFUNCTION(superspec_ItemTouch) +MUTATOR_HOOKFUNCTION(superspec, ItemTouch) {SELFPARAM(); entity _item = self; @@ -151,7 +152,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch) return MUT_ITEMTOUCH_CONTINUE; } -MUTATOR_HOOKFUNCTION(superspec_SV_ParseClientCommand) +MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand) {SELFPARAM(); #define OPTIONINFO(flag,var,test,text,long,short) \ var = strcat(var, ((flag & test) ? "^2[ON] ^7" : "^1[OFF] ^7")); \ @@ -421,13 +422,13 @@ MUTATOR_HOOKFUNCTION(superspec_SV_ParseClientCommand) #undef OPTIONINFO } -MUTATOR_HOOKFUNCTION(superspec_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(superspec, BuildMutatorsString) { ret_string = strcat(ret_string, ":SS"); return 0; } -MUTATOR_HOOKFUNCTION(superspec_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(superspec, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Super Spectators"); return 0; @@ -441,7 +442,7 @@ void superspec_hello() remove(self); } -MUTATOR_HOOKFUNCTION(superspec_ClientConnect) +MUTATOR_HOOKFUNCTION(superspec, ClientConnect) {SELFPARAM(); if(!IS_REAL_CLIENT(self)) return false; @@ -489,7 +490,7 @@ MUTATOR_HOOKFUNCTION(superspec_ClientConnect) return false; } -MUTATOR_HOOKFUNCTION(superspec_PlayerDies) +MUTATOR_HOOKFUNCTION(superspec, PlayerDies) {SELFPARAM(); entity e; FOR_EACH_SPEC(e) @@ -508,22 +509,8 @@ MUTATOR_HOOKFUNCTION(superspec_PlayerDies) return false; } -MUTATOR_HOOKFUNCTION(superspec_ClientDisconnect) +MUTATOR_HOOKFUNCTION(superspec, ClientDisconnect) { superspec_save_client_conf(); return false; } - -MUTATOR_DEFINITION(mutator_superspec) -{ - - MUTATOR_HOOK(BuildMutatorsString, superspec_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, superspec_BuildMutatorsPrettyString, CBC_ORDER_ANY); - MUTATOR_HOOK(SV_ParseClientCommand, superspec_SV_ParseClientCommand, CBC_ORDER_ANY); - MUTATOR_HOOK(ItemTouch, superspec_ItemTouch, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientConnect, superspec_ClientConnect, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, superspec_ClientDisconnect, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, superspec_PlayerDies, CBC_ORDER_ANY); - - return 0; -} diff --git a/qcsrc/server/mutators/mutator_touchexplode.qc b/qcsrc/server/mutators/mutator_touchexplode.qc index e0dd4cd67..ba90bedbb 100644 --- a/qcsrc/server/mutators/mutator_touchexplode.qc +++ b/qcsrc/server/mutators/mutator_touchexplode.qc @@ -1,25 +1,24 @@ - #include "mutator.qh" +REGISTER_MUTATOR(touchexplode, cvar("g_touchexplode")); + .float touchexplode_time; void PlayerTouchExplode(entity p1, entity p2) {SELFPARAM(); - vector org; - org = (p1.origin + p2.origin) * 0.5; + vector org = (p1.origin + p2.origin) * 0.5; org.z += (p1.mins.z + p2.mins.z) * 0.5; sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM); Send_Effect(EFFECT_EXPLOSION_SMALL, org, '0 0 0', 1); - entity e; - e = spawn(); + entity e = spawn(); setorigin(e, org); RadiusDamage(e, world, autocvar_g_touchexplode_damage, autocvar_g_touchexplode_edgedamage, autocvar_g_touchexplode_radius, world, world, autocvar_g_touchexplode_force, DEATH_TOUCHEXPLODE.m_id, world); remove(e); } -MUTATOR_HOOKFUNCTION(touchexplode_PlayerThink) +MUTATOR_HOOKFUNCTION(touchexplode, PlayerPreThink) {SELFPARAM(); if(time > self.touchexplode_time) if(!gameover) @@ -42,10 +41,3 @@ MUTATOR_HOOKFUNCTION(touchexplode_PlayerThink) return false; } - -MUTATOR_DEFINITION(mutator_touchexplode) -{ - MUTATOR_HOOK(PlayerPreThink, touchexplode_PlayerThink, CBC_ORDER_ANY); - - return false; -} diff --git a/qcsrc/server/mutators/mutator_vampire.qc b/qcsrc/server/mutators/mutator_vampire.qc index b5cad57ae..d06b0eed5 100644 --- a/qcsrc/server/mutators/mutator_vampire.qc +++ b/qcsrc/server/mutators/mutator_vampire.qc @@ -1,7 +1,8 @@ - #include "mutator.qh" -MUTATOR_HOOKFUNCTION(vampire_PlayerDamage) +REGISTER_MUTATOR(vampire, cvar("g_vampire") && !cvar("g_instagib")); + +MUTATOR_HOOKFUNCTION(vampire, PlayerDamage_SplitHealthArmor) { if(time >= frag_target.spawnshieldtime) if(frag_target != frag_attacker) @@ -14,23 +15,14 @@ MUTATOR_HOOKFUNCTION(vampire_PlayerDamage) return false; } -MUTATOR_HOOKFUNCTION(vampire_BuildMutatorsString) +MUTATOR_HOOKFUNCTION(vampire, BuildMutatorsString) { ret_string = strcat(ret_string, ":Vampire"); return 0; } -MUTATOR_HOOKFUNCTION(vampire_BuildMutatorsPrettyString) +MUTATOR_HOOKFUNCTION(vampire, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Vampire"); return 0; } - -MUTATOR_DEFINITION(mutator_vampire) -{ - MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, vampire_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsString, vampire_BuildMutatorsString, CBC_ORDER_ANY); - MUTATOR_HOOK(BuildMutatorsPrettyString, vampire_BuildMutatorsPrettyString, CBC_ORDER_ANY); - - return 0; -} diff --git a/qcsrc/server/mutators/mutators.qc b/qcsrc/server/mutators/mutators.qc deleted file mode 100644 index 93fc4cf70..000000000 --- a/qcsrc/server/mutators/mutators.qc +++ /dev/null @@ -1,36 +0,0 @@ -#if defined(CSQC) -#elif defined(MENUQC) -#elif defined(SVQC) - #include "mutators_include.qh" - #include "../../common/mapinfo.qh" -#endif - -void mutators_add() -{ - #define CHECK_MUTATOR_ADD(mut_cvar,mut_name,dependence) \ - { if(cvar(mut_cvar) && dependence) { MUTATOR_ADD(mut_name); } } - - CHECK_MUTATOR_ADD("g_dodging", mutator_dodging, 1); - CHECK_MUTATOR_ADD("g_spawn_near_teammate", mutator_spawn_near_teammate, teamplay); - CHECK_MUTATOR_ADD("g_physical_items", mutator_physical_items, 1); - CHECK_MUTATOR_ADD("g_touchexplode", mutator_touchexplode, 1); - CHECK_MUTATOR_ADD("g_invincible_projectiles", mutator_invincibleprojectiles, 1); - CHECK_MUTATOR_ADD("g_new_toys", mutator_new_toys, !cvar("g_instagib") && !cvar("g_overkill")); - CHECK_MUTATOR_ADD("g_nix", mutator_nix, !cvar("g_instagib") && !cvar("g_overkill")); - CHECK_MUTATOR_ADD("g_rocket_flying", mutator_rocketflying, 1); - CHECK_MUTATOR_ADD("g_vampire", mutator_vampire, !cvar("g_instagib")); - CHECK_MUTATOR_ADD("g_superspectate", mutator_superspec, 1); - CHECK_MUTATOR_ADD("g_pinata", mutator_pinata, !cvar("g_instagib") && !cvar("g_overkill")); - CHECK_MUTATOR_ADD("g_midair", mutator_midair, 1); - CHECK_MUTATOR_ADD("g_bloodloss", mutator_bloodloss, 1); - CHECK_MUTATOR_ADD("g_random_gravity", mutator_random_gravity, 1); - CHECK_MUTATOR_ADD("g_multijump", mutator_multijump, 1); - CHECK_MUTATOR_ADD("g_melee_only", mutator_melee_only, !cvar("g_instagib") && !g_nexball); - CHECK_MUTATOR_ADD("g_nades", mutator_nades, 1); - CHECK_MUTATOR_ADD("g_sandbox", sandbox, 1); - CHECK_MUTATOR_ADD("g_campcheck", mutator_campcheck, 1); - CHECK_MUTATOR_ADD("g_overkill", mutator_overkill, !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill"); - CHECK_MUTATOR_ADD("g_buffs", mutator_buffs, 1); - - #undef CHECK_MUTATOR_ADD -} diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh deleted file mode 100644 index 8556be077..000000000 --- a/qcsrc/server/mutators/mutators.qh +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MUTATORS_H -#define MUTATORS_H - -MUTATOR_DECLARATION(mutator_dodging); -MUTATOR_DECLARATION(mutator_invincibleprojectiles); -MUTATOR_DECLARATION(mutator_new_toys); -MUTATOR_DECLARATION(mutator_nix); -MUTATOR_DECLARATION(mutator_rocketflying); -MUTATOR_DECLARATION(mutator_spawn_near_teammate); -MUTATOR_DECLARATION(mutator_physical_items); -MUTATOR_DECLARATION(mutator_vampire); -MUTATOR_DECLARATION(mutator_superspec); -MUTATOR_DECLARATION(mutator_touchexplode); -MUTATOR_DECLARATION(mutator_pinata); -MUTATOR_DECLARATION(mutator_midair); -MUTATOR_DECLARATION(mutator_bloodloss); -MUTATOR_DECLARATION(mutator_random_gravity); -MUTATOR_DECLARATION(mutator_multijump); -MUTATOR_DECLARATION(mutator_melee_only); -MUTATOR_DECLARATION(mutator_nades); -MUTATOR_DECLARATION(mutator_campcheck); -MUTATOR_DECLARATION(mutator_buffs); - -MUTATOR_DECLARATION(sandbox); -MUTATOR_DECLARATION(mutator_overkill); - -#endif diff --git a/qcsrc/server/mutators/mutators_include.qh b/qcsrc/server/mutators/mutators_include.qh index e7144bcd3..fa91a83f3 100644 --- a/qcsrc/server/mutators/mutators_include.qh +++ b/qcsrc/server/mutators/mutators_include.qh @@ -2,7 +2,6 @@ #define MUTATORS_INCLUDE_H #include "../../common/mutators/base.qh" -#include "mutators.qh" #include "gamemode_assault.qh" #include "gamemode_ca.qh" diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 7a52f0c69..c61199510 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -1,6 +1,30 @@ - #include "mutator.qh" +float autosave_time; +void sandbox_Database_Load(); + +REGISTER_MUTATOR(sandbox, cvar("g_sandbox")) +{ + MUTATOR_ONADD + { + autosave_time = time + autocvar_g_sandbox_storage_autosave; // don't save the first server frame + if(autocvar_g_sandbox_storage_autoload) + sandbox_Database_Load(); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // nothing to roll back + } + + MUTATOR_ONREMOVE + { + // nothing to remove + } + + return false; +} + const float MAX_STORAGE_ATTACHMENTS = 16; float object_count; .float object_flood; @@ -418,7 +442,7 @@ void sandbox_Database_Load() fclose(file_get); } -MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) +MUTATOR_HOOKFUNCTION(sandbox, SV_ParseClientCommand) {SELFPARAM(); if(MUTATOR_RETURNVALUE) // command was already handled? return false; @@ -790,8 +814,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) return false; } -float autosave_time; -MUTATOR_HOOKFUNCTION(sandbox_StartFrame) +MUTATOR_HOOKFUNCTION(sandbox, SV_StartFrame) { if(!autocvar_g_sandbox_storage_autosave) return false; @@ -804,35 +827,8 @@ MUTATOR_HOOKFUNCTION(sandbox_StartFrame) return true; } -MUTATOR_HOOKFUNCTION(sandbox_SetModname) +MUTATOR_HOOKFUNCTION(sandbox, SetModname) { modname = "Sandbox"; return true; } - -MUTATOR_DEFINITION(sandbox) -{ - MUTATOR_HOOK(SV_ParseClientCommand, sandbox_PlayerCommand, CBC_ORDER_ANY); - MUTATOR_HOOK(SV_StartFrame, sandbox_StartFrame, CBC_ORDER_ANY); - MUTATOR_HOOK(SetModname, sandbox_SetModname, CBC_ORDER_ANY); - - MUTATOR_ONADD - { - autosave_time = time + autocvar_g_sandbox_storage_autosave; // don't save the first server frame - if(autocvar_g_sandbox_storage_autoload) - sandbox_Database_Load(); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // nothing to roll back - } - - MUTATOR_ONREMOVE - { - // nothing to remove - } - - return false; -} - diff --git a/qcsrc/server/progs.inc b/qcsrc/server/progs.inc index ece94bdbe..37946e38c 100644 --- a/qcsrc/server/progs.inc +++ b/qcsrc/server/progs.inc @@ -44,7 +44,6 @@ #include "command/all.qc" #include "mutators/mutators_include.qc" -#include "mutators/mutators.qc" #include "pathlib/_all.inc" -- 2.39.2