]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Mutators: port to new syntax
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 14 Oct 2015 11:07:19 +0000 (22:07 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 14 Oct 2015 11:13:27 +0000 (22:13 +1100)
27 files changed:
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/mutator_bloodloss.qc
qcsrc/server/mutators/mutator_breakablehook.qc
qcsrc/server/mutators/mutator_buffs.qc
qcsrc/server/mutators/mutator_campcheck.qc
qcsrc/server/mutators/mutator_dodging.qc
qcsrc/server/mutators/mutator_invincibleproj.qc
qcsrc/server/mutators/mutator_melee_only.qc
qcsrc/server/mutators/mutator_midair.qc
qcsrc/server/mutators/mutator_multijump.qc
qcsrc/server/mutators/mutator_nades.qc
qcsrc/server/mutators/mutator_new_toys.qc
qcsrc/server/mutators/mutator_nix.qc
qcsrc/server/mutators/mutator_overkill.qc
qcsrc/server/mutators/mutator_physical_items.qc
qcsrc/server/mutators/mutator_pinata.qc
qcsrc/server/mutators/mutator_random_gravity.qc
qcsrc/server/mutators/mutator_rocketflying.qc
qcsrc/server/mutators/mutator_spawn_near_teammate.qc
qcsrc/server/mutators/mutator_superspec.qc
qcsrc/server/mutators/mutator_touchexplode.qc
qcsrc/server/mutators/mutator_vampire.qc
qcsrc/server/mutators/mutators.qc [deleted file]
qcsrc/server/mutators/mutators.qh [deleted file]
qcsrc/server/mutators/mutators_include.qh
qcsrc/server/mutators/sandbox.qc
qcsrc/server/progs.inc

index ca8c41e9bfc02de784a3de5db23bb483c79ce841..043f5b9593f1f13e2aaeb2e9c17221cd02ee3f4f 100644 (file)
@@ -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;
 
index 1e54218840ca09679af39d9108c80c27ff9b8d6c..5db1f98a0eb9c84e953ab2409655958f64914f5b 100644 (file)
@@ -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(bloodlossPlayerJump)
 {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(bloodlossBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":bloodloss");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(bloodloss_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(bloodlossBuildMutatorsPrettyString)
 {
        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;
-}
index 3f75e3f9946f42cf9418c6f1bc8c6190ab4ad56a..257937efe5fd2d86aa5bb5277d30ffd590a398c4 100644 (file)
@@ -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")
        {
index 7c24ea14f205bfc76ccee0e2213ec4fd2b5a2a21..42c7294770038aa2a02f7fa8d41fc01ea1d28097 100644 (file)
@@ -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(buffsPlayerDamage_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(buffsPlayerDamage_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(buffsPlayerPhysics)
 {SELFPARAM();
        if(self.buffs & BUFF_SPEED.m_itemid)
        {
@@ -554,7 +568,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_PlayerJump)
+MUTATOR_HOOKFUNCTION(buffsPlayerJump)
 {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(buffsMonsterMove)
 {SELFPARAM();
        if(time < self.buff_disability_time)
        {
@@ -573,7 +587,7 @@ MUTATOR_HOOKFUNCTION(buffs_MonsterMove)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_PlayerDies)
+MUTATOR_HOOKFUNCTION(buffsPlayerDies)
 {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(buffsCustomizeWaypoint)
 {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(buffsSpectateCopy)
 {SELFPARAM();
        self.buffs = other.buffs;
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_VehicleEnter)
+MUTATOR_HOOKFUNCTION(buffsVehicleEnter)
 {
        vh_vehicle.buffs = vh_player.buffs;
        vh_player.buffs = 0;
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_VehicleExit)
+MUTATOR_HOOKFUNCTION(buffsVehicleExit)
 {
        vh_player.buffs = vh_vehicle.buffs;
        vh_vehicle.buffs = 0;
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_PlayerRegen)
+MUTATOR_HOOKFUNCTION(buffsPlayerRegen)
 {SELFPARAM();
        if(self.buffs & BUFF_MEDIC.m_itemid)
        {
@@ -925,19 +939,19 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerRegen)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_GetCvars)
+MUTATOR_HOOKFUNCTION(buffsGetCvars)
 {
        GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_buffs_autoreplace, "cl_buffs_autoreplace");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_BuildMutatorsString)
+MUTATOR_HOOKFUNCTION(buffsBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":Buffs");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(buffs_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(buffsBuildMutatorsPrettyString)
 {
        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;
-}
index 4acc7540502ef433d30e830c6c2ee3ce529ca0d1..04598edc21a674ad62104354ce1704f17b3ba71b 100644 (file)
@@ -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(campcheckPlayerDies)
 {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(campcheckPlayerSpawn)
 {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(campcheckBuildMutatorsString)
 {
        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;
-}
index e9dd6fd73ca75e0da2cc44c7a5d1fdeee588f338..e41456ad56de4620d05a4046d53dfb9ab01a4da5 100644 (file)
 .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(dodgingGetCvars)
 {
        GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_dodging_timeout, "cl_dodging_timeout");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics)
+MUTATOR_HOOKFUNCTION(dodgingPlayerPhysics)
 {
        // print("dodging_PlayerPhysics\n");
        PM_dodging();
@@ -291,38 +304,11 @@ MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys)
+MUTATOR_HOOKFUNCTION(dodgingGetPressedKeys)
 {
        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
index 2855a074f765a07d16f842d357b39332046c3278..3f76bf727cf0c6157b6018f4f45daeaab0ffb29a 100644 (file)
@@ -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(invincibleprojectilesBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":InvincibleProjectiles");
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(invincibleprojectiles_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(invincibleprojectilesBuildMutatorsPrettyString)
 {
        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;
-}
index 019eeb8017af87f196e5c100a9fdb0f0f50e44c2..f85260d864cdde32da3db99f7b2534644bcea610 100644 (file)
@@ -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;
-}
index 33ae58f4dd0fefb485d01b03f6bd9208c93af2c8..4dfb7d5fbe03342e1e730a6fe8834d3c3ce056d1 100644 (file)
@@ -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(midairPlayerPowerups)
 {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(midairPlayerSpawn)
 {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(midairBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":midair");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(midair_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(midairBuildMutatorsPrettyString)
 {
        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;
-}
index de6296d820dbb9996891ee4541b8f29ab3b57feb..d36f281a1f06d626d8422e4223b431a30e9d10a4 100644 (file)
@@ -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(multijumpPlayerJump)
 {
        return PM_multijump_checkjump();
 }
 
-MUTATOR_HOOKFUNCTION(multijump_GetCvars)
+MUTATOR_HOOKFUNCTION(multijumpGetCvars)
 {
        GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_multijump, "cl_multijump");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsString)
+MUTATOR_HOOKFUNCTION(multijumpBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":multijump");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(multijumpBuildMutatorsPrettyString)
 {
        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
index bf55e6704d284707847d0c67fd2ff84f609fd72e..fc1f1d1e7b705890313ce607aeb343c989ebb4a3 100644 (file)
 #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(nadesVehicleEnter)
 {
        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(nadesPlayerPreThink)
 {SELFPARAM();
        if (!IS_PLAYER(self)) { return false; }
 
@@ -1052,7 +1067,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(nades_PlayerSpawn)
+MUTATOR_HOOKFUNCTION(nadesPlayerSpawn)
 {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(nadesMonsterDies)
 {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(nadesGetCvars)
 {
        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(nadesBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":Nades");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(nades_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(nadesBuildMutatorsPrettyString)
 {
        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;
-}
index 93b64ebcc69258094d5b29dfe02b848f33362b4a..d7fc5257e9af15c4972bcb8414acfb39626d0f1a 100644 (file)
@@ -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(ntSetModname)
 {
        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(ntSetStartItems)
 {
        // 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(ntSetWeaponreplace)
 {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(ntFilterItem)
 {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;
-}
index 2a26d9326be9a15742479ad9337ce3b04cd409f5..96e8ca97b1eab89b45f36ff1f5487e69cb501517 100644 (file)
@@ -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(nixBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":NIX");
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(nix_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(nixBuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", NIX");
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(nix_FilterItem)
+MUTATOR_HOOKFUNCTION(nixFilterItem)
 {SELFPARAM();
        switch (self.items)
        {
@@ -204,14 +237,14 @@ MUTATOR_HOOKFUNCTION(nix_FilterItem)
        return 1; // delete all other items
 }
 
-MUTATOR_HOOKFUNCTION(nix_OnEntityPreSpawn)
+MUTATOR_HOOKFUNCTION(nixOnEntityPreSpawn)
 {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(nixPlayerPreThink)
 {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(nixPlayerSpawn)
 {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;
-}
index 5d1a9cd06dac86590ea3c94940ca29ae5210c5a9..79607a1aa6370531e0f0b750fe08e59c1c9d5481 100644 (file)
@@ -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(okPlayerDamage_SplitHealthArmor)
 {SELFPARAM();
        if(damage_take)
                self.ok_pauseregen_finished = max(self.ok_pauseregen_finished, time + 2);
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(ok_PlayerDies)
+MUTATOR_HOOKFUNCTION(okPlayerDies)
 {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(okPlayerRegen)
 {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(okForbidThrowCurrentWeapon)
 {
        return true;
 }
 
-MUTATOR_HOOKFUNCTION(ok_PlayerPreThink)
+MUTATOR_HOOKFUNCTION(okPlayerPreThink)
 {SELFPARAM();
        if(intermission_running || gameover)
                return false;
@@ -188,7 +207,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerPreThink)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(ok_PlayerSpawn)
+MUTATOR_HOOKFUNCTION(okPlayerSpawn)
 {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(okOnEntityPreSpawn)
 {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(okSpectateCopy)
 {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(okBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":OK");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(ok_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(okBuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", Overkill");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(ok_SetModname)
+MUTATOR_HOOKFUNCTION(okSetModname)
 {
        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;
-}
index d1272319ee2959d690dfd1dd0472904bf629b80c..4bcf495f70e49f2fb64b8bc6c9a64fb325a7e4c0 100644 (file)
@@ -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;
-}
index 4c450a85cd392136f4305ec838dabfb0d860a7e5..a531d6becc6a1ae292a180a82ac98c553e39b90c 100644 (file)
@@ -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(pinataBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":Pinata");
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(pinata_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(pinataBuildMutatorsPrettyString)
 {
        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;
-}
index ff85f29059d01c892d1f7ae7c2fe3a0211ffd02e..1a927648d54dc4d5795ce6cc228ec5b3c12a91d1 100644 (file)
@@ -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;
-}
index c403e9f9ca47d1335d39de0ee05f67cc9204357d..44ceeaa9ef73a58ef37076b667ffb836f17a36da 100644 (file)
@@ -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(rocketflyingBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":RocketFlying");
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(rocketflying_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(rocketflyingBuildMutatorsPrettyString)
 {
        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;
-}
index c996f1a12c0146112a1f51eb04aa094da34def6b..3bc1f7b3d9f85d753efb3808461be3d924d809d8 100644 (file)
@@ -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;
-}
index e0b5ad35dc63387a86d2c57ff993808d8be90910..f5b3d36fbcd2865d4c22de0aaf36fd3e2e2b4716 100644 (file)
@@ -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(superspecItemTouch)
 {SELFPARAM();
        entity _item = self;
 
@@ -151,7 +152,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch)
        return MUT_ITEMTOUCH_CONTINUE;
 }
 
-MUTATOR_HOOKFUNCTION(superspec_SV_ParseClientCommand)
+MUTATOR_HOOKFUNCTION(superspecSV_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(superspecBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":SS");
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(superspec_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(superspecBuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", Super Spectators");
        return 0;
@@ -441,7 +442,7 @@ void superspec_hello()
        remove(self);
 }
 
-MUTATOR_HOOKFUNCTION(superspec_ClientConnect)
+MUTATOR_HOOKFUNCTION(superspecClientConnect)
 {SELFPARAM();
        if(!IS_REAL_CLIENT(self))
                return false;
@@ -489,7 +490,7 @@ MUTATOR_HOOKFUNCTION(superspec_ClientConnect)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(superspec_PlayerDies)
+MUTATOR_HOOKFUNCTION(superspecPlayerDies)
 {SELFPARAM();
        entity e;
        FOR_EACH_SPEC(e)
@@ -508,22 +509,8 @@ MUTATOR_HOOKFUNCTION(superspec_PlayerDies)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(superspec_ClientDisconnect)
+MUTATOR_HOOKFUNCTION(superspecClientDisconnect)
 {
        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;
-}
index e0dd4cd67e8dc434036ca04cf51b579aa53a59bf..ba90bedbbd81fc7251ccd3fd7f67b6c12d5ba38d 100644 (file)
@@ -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;
-}
index b5cad57aefbd37e854ebf37fdbeb5fe79b96a83e..d06b0eed5ea2fe6318c60dfbc88d4f0159631c4e 100644 (file)
@@ -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(vampireBuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":Vampire");
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(vampire_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(vampireBuildMutatorsPrettyString)
 {
        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 (file)
index 93fc4cf..0000000
+++ /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 (file)
index 8556be0..0000000
+++ /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
index e7144bcd3ef5194fa26793d39d422f98b5536cb3..fa91a83f35cd658afe3fe5f75d51bbc91789aa5e 100644 (file)
@@ -2,7 +2,6 @@
 #define MUTATORS_INCLUDE_H
 
 #include "../../common/mutators/base.qh"
-#include "mutators.qh"
 
 #include "gamemode_assault.qh"
 #include "gamemode_ca.qh"
index 7a52f0c6961d9531b7f25cbc0ffbddd9e21b3f62..c6119951056b8582447204d3b48ab75f6f5099b1 100644 (file)
@@ -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(sandboxSetModname)
 {
        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;
-}
-
index ece94bdbefb6ca0d67a5b29309cbbe976b0108cf..37946e38cb62fd893ce240b1f1ed4db436c04ef5 100644 (file)
@@ -44,7 +44,6 @@
 #include "command/all.qc"
 
 #include "mutators/mutators_include.qc"
-#include "mutators/mutators.qc"
 
 #include "pathlib/_all.inc"