From: Mario Date: Wed, 14 Oct 2015 11:02:39 +0000 (+1000) Subject: One small hook for a plumber, one giant mutator file for Xonokind X-Git-Tag: xonotic-v0.8.2~1801^2~41 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7a21308e015b71524f9cc676e0b327b74b694f66;p=xonotic%2Fxonotic-data.pk3dir.git One small hook for a plumber, one giant mutator file for Xonokind --- diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 7958d66f6..f06e1ec8a 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -883,15 +883,31 @@ float ball_customize() return true; } -MUTATOR_HOOKFUNCTION(nexball_BallDrop) +void nb_DropBall(entity player) +{ + if(player.ballcarried && g_nexball) + DropBall(player.ballcarried, player.origin, player.velocity); +} + +MUTATOR_HOOKFUNCTION(nb, ClientDisconnect) {SELFPARAM(); - if(self.ballcarried && g_nexball) - DropBall(self.ballcarried, self.origin, self.velocity); + nb_DropBall(self); + return false; +} - return 0; +MUTATOR_HOOKFUNCTION(nb, PlayerDies) +{SELFPARAM(); + nb_DropBall(self); + return false; +} + +MUTATOR_HOOKFUNCTION(nb, MakePlayerObserver) +{SELFPARAM(); + nb_DropBall(self); + return false; } -MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink) +MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) {SELFPARAM(); makevectors(self.v_angle); if(nexball_mode & NBM_BASKETBALL) @@ -956,7 +972,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink) return false; } -MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn) +MUTATOR_HOOKFUNCTION(nb, PlayerSpawn) {SELFPARAM(); self.weaponentity.weapons = '0 0 0'; @@ -971,7 +987,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn) .float stat_sv_airspeedlimit_nonqw; .float stat_sv_maxspeed; -MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics) +MUTATOR_HOOKFUNCTION(nb, PlayerPhysics) {SELFPARAM(); if(self.ballcarried) { @@ -981,7 +997,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics) return false; } -MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing) +MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon) {SELFPARAM(); if(self.weapon == WEP_NEXBALL.m_id) return true; @@ -989,7 +1005,7 @@ MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing) return false; } -MUTATOR_HOOKFUNCTION(nexball_FilterItem) +MUTATOR_HOOKFUNCTION(nb, FilterItem) {SELFPARAM(); if(self.classname == "droppedweapon") if(self.weapon == WEP_NEXBALL.m_id) @@ -998,16 +1014,11 @@ MUTATOR_HOOKFUNCTION(nexball_FilterItem) return false; } -MUTATOR_DEFINITION(gamemode_nexball) +REGISTER_MUTATOR(nb, g_nexball) { - MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY); - MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY); + ActivateTeamplay(); + SetLimits(autocvar_g_nexball_goallimit, autocvar_g_nexball_goalleadlimit, -1, -1); + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qh b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qh index 7d19c50e7..58bf6ec4d 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qh +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qh @@ -4,8 +4,6 @@ #include "weapon.qc" #ifdef SVQC -MUTATOR_DECLARATION(gamemode_nexball); - //EF_BRIGHTFIELD|EF_BRIGHTLIGHT|EF_DIMLIGHT|EF_BLUE|EF_RED|EF_FLAME const float BALL_EFFECTMASK = 1229; const vector BALL_MINS = '-16 -16 -16'; // The model is 24*24*24 diff --git a/qcsrc/server/mutators/gamemode_assault.qc b/qcsrc/server/mutators/gamemode_assault.qc index 85d975fbc..1ae2a6269 100644 --- a/qcsrc/server/mutators/gamemode_assault.qc +++ b/qcsrc/server/mutators/gamemode_assault.qc @@ -530,7 +530,7 @@ void havocbot_ast_reset_role(entity bot) } // mutator hooks -MUTATOR_HOOKFUNCTION(assault_PlayerSpawn) +MUTATOR_HOOKFUNCTION(assault, PlayerSpawn) {SELFPARAM(); if(self.team == assault_attacker_team) Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_ASSAULT_ATTACKING); @@ -540,7 +540,7 @@ MUTATOR_HOOKFUNCTION(assault_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(assault_TurretSpawn) +MUTATOR_HOOKFUNCTION(assault, TurretSpawn) {SELFPARAM(); if(!self.team || self.team == MAX_SHOT_DISTANCE) self.team = 5; // this gets reversed when match starts? @@ -548,20 +548,20 @@ MUTATOR_HOOKFUNCTION(assault_TurretSpawn) return false; } -MUTATOR_HOOKFUNCTION(assault_VehicleSpawn) +MUTATOR_HOOKFUNCTION(assault, VehicleSpawn) {SELFPARAM(); self.nextthink = time + 0.5; return false; } -MUTATOR_HOOKFUNCTION(assault_BotRoles) +MUTATOR_HOOKFUNCTION(assault, HavocBot_ChooseRole) {SELFPARAM(); havocbot_ast_reset_role(self); return true; } -MUTATOR_HOOKFUNCTION(assault_PlayHitsound) +MUTATOR_HOOKFUNCTION(assault, PlayHitsound) { return (frag_victim.classname == "func_assault_destructible"); } @@ -575,13 +575,10 @@ void assault_ScoreRules() ScoreRules_basics_end(); } -MUTATOR_DEFINITION(gamemode_assault) +REGISTER_MUTATOR(assault, g_assault) { - MUTATOR_HOOK(PlayerSpawn, assault_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(TurretSpawn, assault_TurretSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(VehicleSpawn, assault_VehicleSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, assault_BotRoles, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayHitsound, assault_PlayHitsound, CBC_ORDER_ANY); + ActivateTeamplay(); + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index 42aa4a29e..fe28a25bb 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -161,7 +161,7 @@ float ca_isEliminated(entity e) return false; } -MUTATOR_HOOKFUNCTION(ca_PlayerSpawn) +MUTATOR_HOOKFUNCTION(ca, PlayerSpawn) {SELFPARAM(); self.caplayer = 1; if(!warmup_stage) @@ -169,7 +169,7 @@ MUTATOR_HOOKFUNCTION(ca_PlayerSpawn) return 1; } -MUTATOR_HOOKFUNCTION(ca_PutClientInServer) +MUTATOR_HOOKFUNCTION(ca, PutClientInServer) {SELFPARAM(); if(!allowed_to_spawn) if(IS_PLAYER(self)) // this is true even when player is trying to join @@ -186,7 +186,7 @@ MUTATOR_HOOKFUNCTION(ca_PutClientInServer) return 1; } -MUTATOR_HOOKFUNCTION(ca_reset_map_players) +MUTATOR_HOOKFUNCTION(ca, reset_map_players) {SELFPARAM(); entity e; FOR_EACH_CLIENT(e) @@ -208,7 +208,7 @@ MUTATOR_HOOKFUNCTION(ca_reset_map_players) return 1; } -MUTATOR_HOOKFUNCTION(ca_ClientConnect) +MUTATOR_HOOKFUNCTION(ca, ClientConnect) {SELFPARAM(); self.classname = "observer"; return 1; @@ -220,7 +220,7 @@ MUTATOR_HOOKFUNCTION(ca_reset_map_global) return 1; } -MUTATOR_HOOKFUNCTION(ca_GetTeamCount) +MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE) { ret_float = ca_teams; return 0; @@ -253,7 +253,7 @@ void ca_LastPlayerForTeam_Notify() } } -MUTATOR_HOOKFUNCTION(ca_PlayerDies) +MUTATOR_HOOKFUNCTION(ca, PlayerDies) {SELFPARAM(); ca_LastPlayerForTeam_Notify(); if(!allowed_to_spawn) @@ -263,19 +263,19 @@ MUTATOR_HOOKFUNCTION(ca_PlayerDies) return 1; } -MUTATOR_HOOKFUNCTION(ca_ClientDisconnect) +MUTATOR_HOOKFUNCTION(ca, ClientDisconnect) {SELFPARAM(); if(self.caplayer == 1) ca_LastPlayerForTeam_Notify(); return 1; } -MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear) +MUTATOR_HOOKFUNCTION(ca, ForbidPlayerScore_Clear) { return 1; } -MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver) +MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver) {SELFPARAM(); if(self.caplayer == 1) ca_LastPlayerForTeam_Notify(); @@ -288,18 +288,18 @@ MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver) return 1; } -MUTATOR_HOOKFUNCTION(ca_ForbidThrowCurrentWeapon) +MUTATOR_HOOKFUNCTION(ca, ForbidThrowCurrentWeapon) { return 1; } -MUTATOR_HOOKFUNCTION(ca_GiveFragsForKill) +MUTATOR_HOOKFUNCTION(ca, GiveFragsForKill, CBC_ORDER_FIRST) { frag_score = 0; // score will be given to the winner team when the round ends return 1; } -MUTATOR_HOOKFUNCTION(ca_SetStartItems) +MUTATOR_HOOKFUNCTION(ca, SetStartItems) { start_items &= ~IT_UNLIMITED_AMMO; start_health = warmup_start_health = cvar("g_lms_start_health"); @@ -314,7 +314,7 @@ MUTATOR_HOOKFUNCTION(ca_SetStartItems) return 0; } -MUTATOR_HOOKFUNCTION(ca_PlayerDamage) +MUTATOR_HOOKFUNCTION(ca, PlayerDamage_Calculate) { if(IS_PLAYER(frag_target)) if(frag_target.deadflag == DEAD_NO) @@ -326,7 +326,7 @@ MUTATOR_HOOKFUNCTION(ca_PlayerDamage) return false; } -MUTATOR_HOOKFUNCTION(ca_FilterItem) +MUTATOR_HOOKFUNCTION(ca, FilterItem) {SELFPARAM(); if(autocvar_g_powerups <= 0) if(self.flags & FL_POWERUP) @@ -338,7 +338,7 @@ MUTATOR_HOOKFUNCTION(ca_FilterItem) return false; } -MUTATOR_HOOKFUNCTION(ca_PlayerDamage_SplitHealthArmor) +MUTATOR_HOOKFUNCTION(ca, PlayerDamage_SplitHealthArmor) { float excess = max(0, frag_damage - damage_take - damage_save); @@ -348,13 +348,13 @@ MUTATOR_HOOKFUNCTION(ca_PlayerDamage_SplitHealthArmor) return false; } -MUTATOR_HOOKFUNCTION(ca_PlayerRegen) +MUTATOR_HOOKFUNCTION(ca, PlayerRegen) { // no regeneration in CA return true; } -MUTATOR_HOOKFUNCTION(ca_CountFrags) +MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining) { // announce remaining frags return true; @@ -382,26 +382,13 @@ void ca_Initialize() EliminatedPlayers_Init(ca_isEliminated); } -MUTATOR_DEFINITION(gamemode_ca) +REGISTER_MUTATOR(ca, g_ca) { - MUTATOR_HOOK(PlayerSpawn, ca_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PutClientInServer, ca_PutClientInServer, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, ca_MakePlayerObserver, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientConnect, ca_ClientConnect, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_global, ca_reset_map_global, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_players, ca_reset_map_players, CBC_ORDER_ANY); - MUTATOR_HOOK(GetTeamCount, ca_GetTeamCount, CBC_ORDER_EXCLUSIVE); - MUTATOR_HOOK(PlayerDies, ca_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, ca_ClientDisconnect, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidPlayerScore_Clear, ca_ForbidPlayerScore_Clear, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidThrowCurrentWeapon, ca_ForbidThrowCurrentWeapon, CBC_ORDER_ANY); - MUTATOR_HOOK(GiveFragsForKill, ca_GiveFragsForKill, CBC_ORDER_FIRST); - MUTATOR_HOOK(SetStartItems, ca_SetStartItems, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, ca_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(FilterItem, ca_FilterItem, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, ca_PlayerDamage_SplitHealthArmor, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerRegen, ca_PlayerRegen, CBC_ORDER_ANY); - MUTATOR_HOOK(Scores_CountFragsRemaining, ca_CountFrags, CBC_ORDER_ANY); + ActivateTeamplay(); + SetLimits(autocvar_g_ca_point_limit, autocvar_g_ca_point_leadlimit, -1, -1); + + if(autocvar_g_ca_team_spawns) + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index 0c68bbfd0..ecbbc6ed8 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -1889,7 +1889,7 @@ void havocbot_role_ctf_setrole(entity bot, int role) // Hook Functions // ============== -MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink) +MUTATOR_HOOKFUNCTION(ctf, PlayerPreThink) {SELFPARAM(); entity flag; int t = 0, t2 = 0, t3 = 0; @@ -1941,7 +1941,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink) return false; } -MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values that are applied to players in g_damage.qc +MUTATOR_HOOKFUNCTION(ctf, PlayerDamage_Calculate) // for changing damage and force values that are applied to players in g_damage.qc { if(frag_attacker.flagcarried) // if the attacker is a flagcarrier { @@ -1969,7 +1969,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values t return false; } -MUTATOR_HOOKFUNCTION(ctf_PlayerDies) +MUTATOR_HOOKFUNCTION(ctf, PlayerDies) { if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker)) && (frag_target.flagcarried)) { @@ -1987,30 +1987,38 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerDies) return false; } -MUTATOR_HOOKFUNCTION(ctf_GiveFragsForKill) +MUTATOR_HOOKFUNCTION(ctf, GiveFragsForKill) { frag_score = 0; return (autocvar_g_ctf_ignore_frags); // no frags counted in ctf if this is true } -MUTATOR_HOOKFUNCTION(ctf_RemovePlayer) -{SELFPARAM(); - entity flag; // temporary entity for the search method - - if(self.flagcarried) - { ctf_Handle_Throw(self, world, DROP_NORMAL); } +void ctf_RemovePlayer(entity player) +{ + if(player.flagcarried) + { ctf_Handle_Throw(player, world, DROP_NORMAL); } - for(flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) + for(entity flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) { - if(flag.pass_sender == self) { flag.pass_sender = world; } - if(flag.pass_target == self) { flag.pass_target = world; } - if(flag.ctf_dropper == self) { flag.ctf_dropper = world; } + if(flag.pass_sender == player) { flag.pass_sender = world; } + if(flag.pass_target == player) { flag.pass_target = world; } + if(flag.ctf_dropper == player) { flag.ctf_dropper = world; } } +} + +MUTATOR_HOOKFUNCTION(ctf, MakePlayerObserver) +{SELFPARAM(); + ctf_RemovePlayer(self); + return false; +} +MUTATOR_HOOKFUNCTION(ctf, ClientDisconnect) +{SELFPARAM(); + ctf_RemovePlayer(self); return false; } -MUTATOR_HOOKFUNCTION(ctf_PortalTeleport) +MUTATOR_HOOKFUNCTION(ctf, PortalTeleport) {SELFPARAM(); if(self.flagcarried) if(!autocvar_g_ctf_portalteleport) @@ -2019,7 +2027,7 @@ MUTATOR_HOOKFUNCTION(ctf_PortalTeleport) return false; } -MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) +MUTATOR_HOOKFUNCTION(ctf, PlayerUseKey) {SELFPARAM(); if(MUTATOR_RETURNVALUE || gameover) { return false; } @@ -2112,7 +2120,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) return false; } -MUTATOR_HOOKFUNCTION(ctf_HelpMePing) +MUTATOR_HOOKFUNCTION(ctf, HelpMePing) {SELFPARAM(); if(self.wps_flagcarrier) // update the flagcarrier waypointsprite with "NEEDING HELP" notification { @@ -2128,7 +2136,7 @@ MUTATOR_HOOKFUNCTION(ctf_HelpMePing) return true; } -MUTATOR_HOOKFUNCTION(ctf_VehicleEnter) +MUTATOR_HOOKFUNCTION(ctf, VehicleEnter) { if(vh_player.flagcarried) { @@ -2151,7 +2159,7 @@ MUTATOR_HOOKFUNCTION(ctf_VehicleEnter) return false; } -MUTATOR_HOOKFUNCTION(ctf_VehicleExit) +MUTATOR_HOOKFUNCTION(ctf, VehicleExit) { if(vh_player.flagcarried) { @@ -2166,7 +2174,7 @@ MUTATOR_HOOKFUNCTION(ctf_VehicleExit) return false; } -MUTATOR_HOOKFUNCTION(ctf_AbortSpeedrun) +MUTATOR_HOOKFUNCTION(ctf, AbortSpeedrun) {SELFPARAM(); if(self.flagcarried) { @@ -2178,7 +2186,7 @@ MUTATOR_HOOKFUNCTION(ctf_AbortSpeedrun) return false; } -MUTATOR_HOOKFUNCTION(ctf_MatchEnd) +MUTATOR_HOOKFUNCTION(ctf, MatchEnd) { entity flag; // temporary entity for the search method @@ -2212,20 +2220,20 @@ MUTATOR_HOOKFUNCTION(ctf_MatchEnd) return false; } -MUTATOR_HOOKFUNCTION(ctf_BotRoles) +MUTATOR_HOOKFUNCTION(ctf, HavocBot_ChooseRole) {SELFPARAM(); havocbot_ctf_reset_role(self); return true; } -MUTATOR_HOOKFUNCTION(ctf_GetTeamCount) +MUTATOR_HOOKFUNCTION(ctf, GetTeamCount) { //ret_float = ctf_teams; ret_string = "ctf_team"; return true; } -MUTATOR_HOOKFUNCTION(ctf_SpectateCopy) +MUTATOR_HOOKFUNCTION(ctf, SpectateCopy) {SELFPARAM(); self.ctf_flagstatus = other.ctf_flagstatus; return false; @@ -2427,24 +2435,11 @@ void ctf_Initialize() } -MUTATOR_DEFINITION(gamemode_ctf) +REGISTER_MUTATOR(ctf, g_ctf) { - MUTATOR_HOOK(MakePlayerObserver, ctf_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, ctf_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, ctf_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(MatchEnd, ctf_MatchEnd, CBC_ORDER_ANY); - MUTATOR_HOOK(PortalTeleport, ctf_PortalTeleport, CBC_ORDER_ANY); - MUTATOR_HOOK(GiveFragsForKill, ctf_GiveFragsForKill, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, ctf_PlayerPreThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, ctf_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerUseKey, ctf_PlayerUseKey, CBC_ORDER_ANY); - MUTATOR_HOOK(HelpMePing, ctf_HelpMePing, CBC_ORDER_ANY); - MUTATOR_HOOK(VehicleEnter, ctf_VehicleEnter, CBC_ORDER_ANY); - MUTATOR_HOOK(VehicleExit, ctf_VehicleExit, CBC_ORDER_ANY); - MUTATOR_HOOK(AbortSpeedrun, ctf_AbortSpeedrun, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, ctf_BotRoles, CBC_ORDER_ANY); - MUTATOR_HOOK(GetTeamCount, ctf_GetTeamCount, CBC_ORDER_ANY); - MUTATOR_HOOK(SpectateCopy, ctf_SpectateCopy, CBC_ORDER_ANY); + ActivateTeamplay(); + SetLimits(autocvar_capturelimit_override, -1, autocvar_captureleadlimit_override, -1); + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_cts.qc b/qcsrc/server/mutators/gamemode_cts.qc index 06e2ca3fa..bdaee8c31 100644 --- a/qcsrc/server/mutators/gamemode_cts.qc +++ b/qcsrc/server/mutators/gamemode_cts.qc @@ -55,7 +55,7 @@ void cts_EventLog(string mode, entity actor) // use an alias for easy changing a GameLogEcho(strcat(":cts:", mode, ":", ((actor != world) ? (strcat(":", ftos(actor.playerid))) : ""))); } -MUTATOR_HOOKFUNCTION(cts_PlayerPhysics) +MUTATOR_HOOKFUNCTION(cts, PlayerPhysics) {SELFPARAM(); // force kbd movement for fairness float wishspeed; @@ -106,7 +106,7 @@ MUTATOR_HOOKFUNCTION(cts_PlayerPhysics) return false; } -MUTATOR_HOOKFUNCTION(cts_ResetMap) +MUTATOR_HOOKFUNCTION(cts, reset_map_global) { float s; @@ -140,7 +140,7 @@ MUTATOR_HOOKFUNCTION(cts_ResetMap) return false; } -MUTATOR_HOOKFUNCTION(cts_PlayerPreThink) +MUTATOR_HOOKFUNCTION(cts, PlayerPreThink) {SELFPARAM(); if(IS_SPEC(self) || IS_OBSERVER(self)) if(g_race_qualifying) @@ -150,7 +150,7 @@ MUTATOR_HOOKFUNCTION(cts_PlayerPreThink) return false; } -MUTATOR_HOOKFUNCTION(cts_ClientConnect) +MUTATOR_HOOKFUNCTION(cts, ClientConnect) {SELFPARAM(); race_PreparePlayer(); self.race_checkpoint = -1; @@ -177,7 +177,7 @@ MUTATOR_HOOKFUNCTION(cts_ClientConnect) return false; } -MUTATOR_HOOKFUNCTION(cts_MakePlayerObserver) +MUTATOR_HOOKFUNCTION(cts, MakePlayerObserver) {SELFPARAM(); if(PlayerScore_Add(self, SP_RACE_FASTEST, 0)) self.frags = FRAGS_LMS_LOSER; @@ -190,7 +190,7 @@ MUTATOR_HOOKFUNCTION(cts_MakePlayerObserver) return false; } -MUTATOR_HOOKFUNCTION(cts_PlayerSpawn) +MUTATOR_HOOKFUNCTION(cts, PlayerSpawn) {SELFPARAM(); if(spawn_spot.target == "") // Emergency: this wasn't a real spawnpoint. Can this ever happen? @@ -205,7 +205,7 @@ MUTATOR_HOOKFUNCTION(cts_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(cts_PutClientInServer) +MUTATOR_HOOKFUNCTION(cts, PutClientInServer) {SELFPARAM(); if(IS_PLAYER(self)) if(!gameover) @@ -220,20 +220,20 @@ MUTATOR_HOOKFUNCTION(cts_PutClientInServer) return false; } -MUTATOR_HOOKFUNCTION(cts_PlayerDies) +MUTATOR_HOOKFUNCTION(cts, PlayerDies) {SELFPARAM(); self.respawn_flags |= RESPAWN_FORCE; race_AbandonRaceCheck(self); return false; } -MUTATOR_HOOKFUNCTION(cts_BotRoles) +MUTATOR_HOOKFUNCTION(cts, HavocBot_ChooseRole) {SELFPARAM(); self.havocbot_role = havocbot_role_cts; return true; } -MUTATOR_HOOKFUNCTION(cts_PlayerPostThink) +MUTATOR_HOOKFUNCTION(cts, GetPressedKeys) {SELFPARAM(); if(self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1) { @@ -250,13 +250,13 @@ MUTATOR_HOOKFUNCTION(cts_PlayerPostThink) return false; } -MUTATOR_HOOKFUNCTION(cts_ForbidThrowing) +MUTATOR_HOOKFUNCTION(cts, ForbidThrowCurrentWeapon) { // no weapon dropping in CTS return true; } -MUTATOR_HOOKFUNCTION(cts_FilterItem) +MUTATOR_HOOKFUNCTION(cts, FilterItem) {SELFPARAM(); if(self.classname == "droppedweapon") return true; @@ -264,7 +264,7 @@ MUTATOR_HOOKFUNCTION(cts_FilterItem) return false; } -MUTATOR_HOOKFUNCTION(cts_PlayerDamage) +MUTATOR_HOOKFUNCTION(cts, PlayerDamage_Calculate) { if(frag_target == frag_attacker || frag_deathtype == DEATH_FALL.m_id) if(!autocvar_g_cts_selfdamage) @@ -273,12 +273,12 @@ MUTATOR_HOOKFUNCTION(cts_PlayerDamage) return false; } -MUTATOR_HOOKFUNCTION(cts_ForbidClearPlayerScore) +MUTATOR_HOOKFUNCTION(cts, ForbidPlayerScore_Clear) { return true; // in CTS, you don't lose score by observing } -MUTATOR_HOOKFUNCTION(cts_SetMods) +MUTATOR_HOOKFUNCTION(cts, SetModname) { g_cloaked = 1; // always enable cloak in CTS @@ -290,23 +290,11 @@ void cts_Initialize() cts_ScoreRules(); } -MUTATOR_DEFINITION(gamemode_cts) +REGISTER_MUTATOR(cts, g_cts) { - MUTATOR_HOOK(PlayerPhysics, cts_PlayerPhysics, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_global, cts_ResetMap, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, cts_PlayerPreThink, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientConnect, cts_ClientConnect, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, cts_MakePlayerObserver, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, cts_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PutClientInServer, cts_PutClientInServer, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, cts_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, cts_BotRoles, CBC_ORDER_ANY); - MUTATOR_HOOK(GetPressedKeys, cts_PlayerPostThink, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidThrowCurrentWeapon, cts_ForbidThrowing, CBC_ORDER_ANY); - MUTATOR_HOOK(FilterItem, cts_FilterItem, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, cts_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidPlayerScore_Clear, cts_ForbidClearPlayerScore, CBC_ORDER_ANY); - MUTATOR_HOOK(SetModname, cts_SetMods, CBC_ORDER_ANY); + g_race_qualifying = 1; + independent_players = 1; + SetLimits(0, 0, 0, -1); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_deathmatch.qc b/qcsrc/server/mutators/gamemode_deathmatch.qc index c3c8b0df5..773c08d21 100644 --- a/qcsrc/server/mutators/gamemode_deathmatch.qc +++ b/qcsrc/server/mutators/gamemode_deathmatch.qc @@ -1,15 +1,13 @@ #include "gamemode.qh" -MUTATOR_HOOKFUNCTION(dm_CountFrags) +MUTATOR_HOOKFUNCTION(dm, Scores_CountFragsRemaining) { // announce remaining frags return true; } -MUTATOR_DEFINITION(gamemode_deathmatch) +REGISTER_MUTATOR(dm, g_dm) { - MUTATOR_HOOK(Scores_CountFragsRemaining, dm_CountFrags, CBC_ORDER_ANY); - MUTATOR_ONADD { if(time > 1) // game loads at time 1 diff --git a/qcsrc/server/mutators/gamemode_domination.qc b/qcsrc/server/mutators/gamemode_domination.qc index 9e309f6e4..732022019 100644 --- a/qcsrc/server/mutators/gamemode_domination.qc +++ b/qcsrc/server/mutators/gamemode_domination.qc @@ -402,13 +402,13 @@ void havocbot_role_dom() } } -MUTATOR_HOOKFUNCTION(dom_GetTeamCount) +MUTATOR_HOOKFUNCTION(dom, GetTeamCount) { ret_float = domination_teams; return 0; } -MUTATOR_HOOKFUNCTION(dom_ResetMap) +MUTATOR_HOOKFUNCTION(dom, reset_map_players) {SELFPARAM(); total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0; entity e; @@ -423,7 +423,7 @@ MUTATOR_HOOKFUNCTION(dom_ResetMap) return 1; } -MUTATOR_HOOKFUNCTION(dom_PlayerSpawn) +MUTATOR_HOOKFUNCTION(dom, PlayerSpawn) {SELFPARAM(); if(domination_roundbased) if(!round_handler_IsRoundStarted()) @@ -433,13 +433,13 @@ MUTATOR_HOOKFUNCTION(dom_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(dom_ClientConnect) +MUTATOR_HOOKFUNCTION(dom, ClientConnect) {SELFPARAM(); set_dom_state(self); return false; } -MUTATOR_HOOKFUNCTION(dom_BotRoles) +MUTATOR_HOOKFUNCTION(dom, HavocBot_ChooseRole) {SELFPARAM(); self.havocbot_role = havocbot_role_dom; return true; @@ -628,13 +628,15 @@ void dom_Initialize() } -MUTATOR_DEFINITION(gamemode_domination) +REGISTER_MUTATOR(dom, g_domination) { - MUTATOR_HOOK(GetTeamCount, dom_GetTeamCount, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_players, dom_ResetMap, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, dom_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientConnect, dom_ClientConnect, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, dom_BotRoles, CBC_ORDER_ANY); + int fraglimit_override = autocvar_g_domination_point_limit; + if(autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) + fraglimit_override = autocvar_g_domination_roundbased_point_limit; + + ActivateTeamplay(); + SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, -1, -1); + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index 6eb2128f3..bcddf704d 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -317,17 +317,28 @@ void havocbot_role_ft_freeing() // Hook Functions // ============== -MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer) +void ft_RemovePlayer() {SELFPARAM(); self.health = 0; // neccessary to update correctly alive stats if(!self.frozen) freezetag_LastPlayerForTeam_Notify(); freezetag_Unfreeze(world); freezetag_count_alive_players(); +} + +MUTATOR_HOOKFUNCTION(ft, ClientDisconnect) +{SELFPARAM(); + ft_RemovePlayer(); + return 1; +} + +MUTATOR_HOOKFUNCTION(ft, MakePlayerObserver) +{SELFPARAM(); + ft_RemovePlayer(); return 1; } -MUTATOR_HOOKFUNCTION(freezetag_PlayerDies) +MUTATOR_HOOKFUNCTION(ft, PlayerDies) {SELFPARAM(); if(round_handler_IsActive()) if(round_handler_CountdownRunning()) @@ -381,7 +392,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies) return 1; } -MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn) +MUTATOR_HOOKFUNCTION(ft, PlayerSpawn) {SELFPARAM(); if(self.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players return 1; // do nothing, round is starting right now @@ -404,7 +415,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn) return 1; } -MUTATOR_HOOKFUNCTION(freezetag_reset_map_players) +MUTATOR_HOOKFUNCTION(ft, reset_map_players) {SELFPARAM(); entity e; FOR_EACH_PLAYER(e) @@ -419,13 +430,13 @@ MUTATOR_HOOKFUNCTION(freezetag_reset_map_players) return 1; } -MUTATOR_HOOKFUNCTION(freezetag_GiveFragsForKill) +MUTATOR_HOOKFUNCTION(ft, GiveFragsForKill, CBC_ORDER_FIRST) { frag_score = 0; // no frags counted in Freeze Tag return 1; } -MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink) +MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) {SELFPARAM(); float n; @@ -525,7 +536,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink) return 1; } -MUTATOR_HOOKFUNCTION(freezetag_SetStartItems) +MUTATOR_HOOKFUNCTION(ft, SetStartItems) { start_items &= ~IT_UNLIMITED_AMMO; //start_health = warmup_start_health = cvar("g_lms_start_health"); @@ -540,7 +551,7 @@ MUTATOR_HOOKFUNCTION(freezetag_SetStartItems) return 0; } -MUTATOR_HOOKFUNCTION(freezetag_BotRoles) +MUTATOR_HOOKFUNCTION(ft, HavocBot_ChooseRole) {SELFPARAM(); if (!self.deadflag) { @@ -553,7 +564,7 @@ MUTATOR_HOOKFUNCTION(freezetag_BotRoles) return true; } -MUTATOR_HOOKFUNCTION(freezetag_GetTeamCount) +MUTATOR_HOOKFUNCTION(ft, GetTeamCount, CBC_ORDER_EXCLUSIVE) { ret_float = freezetag_teams; return false; @@ -578,18 +589,13 @@ void freezetag_Initialize() EliminatedPlayers_Init(freezetag_isEliminated); } -MUTATOR_DEFINITION(gamemode_freezetag) +REGISTER_MUTATOR(ft, g_freezetag) { - MUTATOR_HOOK(MakePlayerObserver, freezetag_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, freezetag_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, freezetag_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, freezetag_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_players, freezetag_reset_map_players, CBC_ORDER_ANY); - MUTATOR_HOOK(GiveFragsForKill, freezetag_GiveFragsForKill, CBC_ORDER_FIRST); - MUTATOR_HOOK(PlayerPreThink, freezetag_PlayerPreThink, CBC_ORDER_FIRST); - MUTATOR_HOOK(SetStartItems, freezetag_SetStartItems, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, freezetag_BotRoles, CBC_ORDER_ANY); - MUTATOR_HOOK(GetTeamCount, freezetag_GetTeamCount, CBC_ORDER_EXCLUSIVE); + ActivateTeamplay(); + SetLimits(autocvar_g_freezetag_point_limit, autocvar_g_freezetag_point_leadlimit, -1, -1); + + if(autocvar_g_freezetag_team_spawns) + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_invasion.qc b/qcsrc/server/mutators/gamemode_invasion.qc index 0929d93a5..afad193f5 100644 --- a/qcsrc/server/mutators/gamemode_invasion.qc +++ b/qcsrc/server/mutators/gamemode_invasion.qc @@ -263,7 +263,7 @@ void Invasion_RoundStart() } } -MUTATOR_HOOKFUNCTION(invasion_MonsterDies) +MUTATOR_HOOKFUNCTION(inv, MonsterDies) {SELFPARAM(); if(!(self.spawnflags & MONSTERFLAG_RESPAWNED)) { @@ -285,7 +285,7 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterDies) return false; } -MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn) +MUTATOR_HOOKFUNCTION(inv, MonsterSpawn) {SELFPARAM(); if(!(self.spawnflags & MONSTERFLAG_SPAWNED)) return true; @@ -306,7 +306,7 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn) return false; } -MUTATOR_HOOKFUNCTION(invasion_OnEntityPreSpawn) +MUTATOR_HOOKFUNCTION(inv, OnEntityPreSpawn) {SELFPARAM(); if(startsWith(self.classname, "monster_")) if(!(self.spawnflags & MONSTERFLAG_SPAWNED)) @@ -315,7 +315,7 @@ MUTATOR_HOOKFUNCTION(invasion_OnEntityPreSpawn) return false; } -MUTATOR_HOOKFUNCTION(invasion_StartFrame) +MUTATOR_HOOKFUNCTION(inv, SV_StartFrame) { monsters_total = inv_maxspawned; // TODO: make sure numspawned never exceeds maxspawned monsters_killed = inv_numkilled; @@ -323,19 +323,19 @@ MUTATOR_HOOKFUNCTION(invasion_StartFrame) return false; } -MUTATOR_HOOKFUNCTION(invasion_PlayerRegen) +MUTATOR_HOOKFUNCTION(inv, PlayerRegen) { // no regeneration in invasion return true; } -MUTATOR_HOOKFUNCTION(invasion_PlayerSpawn) +MUTATOR_HOOKFUNCTION(inv, PlayerSpawn) {SELFPARAM(); self.bot_attack = false; return false; } -MUTATOR_HOOKFUNCTION(invasion_PlayerDamage) +MUTATOR_HOOKFUNCTION(inv, PlayerDamage_Calculate) { if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target) && frag_attacker != frag_target) { @@ -346,7 +346,7 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerDamage) return false; } -MUTATOR_HOOKFUNCTION(invasion_PlayerCommand) +MUTATOR_HOOKFUNCTION(inv, SV_ParseClientCommand) {SELFPARAM(); if(MUTATOR_RETURNVALUE) // command was already handled? return false; @@ -367,7 +367,7 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerCommand) return false; } -MUTATOR_HOOKFUNCTION(invasion_BotShouldAttack) +MUTATOR_HOOKFUNCTION(inv, BotShouldAttack) { if(!IS_MONSTER(checkentity)) return true; @@ -375,28 +375,27 @@ MUTATOR_HOOKFUNCTION(invasion_BotShouldAttack) return false; } -MUTATOR_HOOKFUNCTION(invasion_SetStartItems) +MUTATOR_HOOKFUNCTION(inv, SetStartItems) { start_health = 200; start_armorvalue = 200; - return false; } -MUTATOR_HOOKFUNCTION(invasion_AccuracyTargetValid) +MUTATOR_HOOKFUNCTION(inv, AccuracyTargetValid) { if(IS_MONSTER(frag_target)) return MUT_ACCADD_INVALID; return MUT_ACCADD_INDIFFERENT; } -MUTATOR_HOOKFUNCTION(invasion_AllowMobSpawning) +MUTATOR_HOOKFUNCTION(inv, AllowMobSpawning) { // monster spawning disabled during an invasion return true; } -MUTATOR_HOOKFUNCTION(invasion_GetTeamCount) +MUTATOR_HOOKFUNCTION(inv, GetTeamCount, CBC_ORDER_EXCLUSIVE) { ret_float = invasion_teams; return false; @@ -453,21 +452,15 @@ void invasion_Initialize() InitializeEntity(world, invasion_DelayedInit, INITPRIO_GAMETYPE); } -MUTATOR_DEFINITION(gamemode_invasion) +REGISTER_MUTATOR(inv, g_invasion) { - MUTATOR_HOOK(MonsterDies, invasion_MonsterDies, CBC_ORDER_ANY); - MUTATOR_HOOK(MonsterSpawn, invasion_MonsterSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(OnEntityPreSpawn, invasion_OnEntityPreSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(SV_StartFrame, invasion_StartFrame, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerRegen, invasion_PlayerRegen, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, invasion_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, invasion_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(SV_ParseClientCommand, invasion_PlayerCommand, CBC_ORDER_ANY); - MUTATOR_HOOK(BotShouldAttack, invasion_BotShouldAttack, CBC_ORDER_ANY); - MUTATOR_HOOK(SetStartItems, invasion_SetStartItems, CBC_ORDER_ANY); - MUTATOR_HOOK(AccuracyTargetValid, invasion_AccuracyTargetValid, CBC_ORDER_ANY); - MUTATOR_HOOK(AllowMobSpawning, invasion_AllowMobSpawning, CBC_ORDER_ANY); - MUTATOR_HOOK(GetTeamCount, invasion_GetTeamCount, CBC_ORDER_ANY); + SetLimits(autocvar_g_invasion_point_limit, -1, -1, -1); + if(autocvar_g_invasion_teams >= 2) + { + ActivateTeamplay(); + if(autocvar_g_invasion_team_spawns) + have_team_spawns = -1; // request team spawns + } MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_keepaway.qc b/qcsrc/server/mutators/gamemode_keepaway.qc index b4951c6e7..991285c92 100644 --- a/qcsrc/server/mutators/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/gamemode_keepaway.qc @@ -255,7 +255,7 @@ void havocbot_role_ka_collector() // Hook Functions // ============== -MUTATOR_HOOKFUNCTION(ka_Scoring) +MUTATOR_HOOKFUNCTION(ka, PlayerDies) {SELFPARAM(); if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker))) { @@ -276,13 +276,13 @@ MUTATOR_HOOKFUNCTION(ka_Scoring) return 0; } -MUTATOR_HOOKFUNCTION(ka_GiveFragsForKill) +MUTATOR_HOOKFUNCTION(ka, GiveFragsForKill) { frag_score = 0; // no frags counted in keepaway return 1; // you deceptive little bugger ;3 This needs to be true in order for this function to even count. } -MUTATOR_HOOKFUNCTION(ka_PlayerPreThink) +MUTATOR_HOOKFUNCTION(ka, PlayerPreThink) {SELFPARAM(); // clear the item used for the ball in keepaway self.items &= ~IT_KEY1; @@ -294,7 +294,7 @@ MUTATOR_HOOKFUNCTION(ka_PlayerPreThink) return 0; } -MUTATOR_HOOKFUNCTION(ka_PlayerUseKey) +MUTATOR_HOOKFUNCTION(ka, PlayerUseKey) {SELFPARAM(); if(MUTATOR_RETURNVALUE == 0) if(self.ballcarried) @@ -305,7 +305,7 @@ MUTATOR_HOOKFUNCTION(ka_PlayerUseKey) return 0; } -MUTATOR_HOOKFUNCTION(ka_PlayerDamage) // for changing damage and force values that are applied to players in g_damage.qc +MUTATOR_HOOKFUNCTION(ka, PlayerDamage_Calculate) // for changing damage and force values that are applied to players in g_damage.qc { if(frag_attacker.ballcarried) // if the attacker is a ballcarrier { @@ -336,13 +336,19 @@ MUTATOR_HOOKFUNCTION(ka_PlayerDamage) // for changing damage and force values th return 0; } -MUTATOR_HOOKFUNCTION(ka_RemovePlayer) +MUTATOR_HOOKFUNCTION(ka, ClientDisconnect) {SELFPARAM(); if(self.ballcarried) { ka_DropEvent(self); } // a player with the ball has left the match, drop it return 0; } -MUTATOR_HOOKFUNCTION(ka_PlayerPowerups) +MUTATOR_HOOKFUNCTION(ka, MakePlayerObserver) +{SELFPARAM(); + if(self.ballcarried) { ka_DropEvent(self); } // a player with the ball has left the match, drop it + return 0; +} + +MUTATOR_HOOKFUNCTION(ka, PlayerPowerups) {SELFPARAM(); // In the future this hook is supposed to allow me to do some extra stuff with waypointsprites and invisibility powerup // So bare with me until I can fix a certain bug with ka_ballcarrier_waypointsprite_visible_for_player() @@ -358,7 +364,7 @@ MUTATOR_HOOKFUNCTION(ka_PlayerPowerups) .float stat_sv_airspeedlimit_nonqw; .float stat_sv_maxspeed; -MUTATOR_HOOKFUNCTION(ka_PlayerPhysics) +MUTATOR_HOOKFUNCTION(ka, PlayerPhysics) {SELFPARAM(); if(self.ballcarried) { @@ -368,7 +374,7 @@ MUTATOR_HOOKFUNCTION(ka_PlayerPhysics) return false; } -MUTATOR_HOOKFUNCTION(ka_BotShouldAttack) +MUTATOR_HOOKFUNCTION(ka, BotShouldAttack) {SELFPARAM(); // if neither player has ball then don't attack unless the ball is on the ground if(!checkentity.ballcarried && !self.ballcarried && ka_ball.owner) @@ -376,7 +382,7 @@ MUTATOR_HOOKFUNCTION(ka_BotShouldAttack) return false; } -MUTATOR_HOOKFUNCTION(ka_BotRoles) +MUTATOR_HOOKFUNCTION(ka, HavocBot_ChooseRole) {SELFPARAM(); if (self.ballcarried) self.havocbot_role = havocbot_role_ka_carrier; @@ -435,20 +441,8 @@ void ka_Initialize() // run at the start of a match, initiates game mode } -MUTATOR_DEFINITION(gamemode_keepaway) +REGISTER_MUTATOR(ka, g_keepaway) { - MUTATOR_HOOK(MakePlayerObserver, ka_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, ka_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, ka_Scoring, CBC_ORDER_ANY); - MUTATOR_HOOK(GiveFragsForKill, ka_GiveFragsForKill, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, ka_PlayerPreThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDamage_Calculate, ka_PlayerDamage, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPowerups, ka_PlayerPowerups, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerUseKey, ka_PlayerUseKey, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPhysics, ka_PlayerPhysics, CBC_ORDER_ANY); - MUTATOR_HOOK(BotShouldAttack, ka_BotShouldAttack, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, ka_BotRoles, CBC_ORDER_ANY); - MUTATOR_ONADD { if(time > 1) // game loads at time 1 diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qc b/qcsrc/server/mutators/gamemode_keyhunt.qc index 68097755e..a27ebee02 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/gamemode_keyhunt.qc @@ -1039,13 +1039,19 @@ void kh_finalize() // register this as a mutator -MUTATOR_HOOKFUNCTION(kh_Key_DropAll) +MUTATOR_HOOKFUNCTION(kh, ClientDisconnect) {SELFPARAM(); kh_Key_DropAll(self, true); return 0; } -MUTATOR_HOOKFUNCTION(kh_PlayerDies) +MUTATOR_HOOKFUNCTION(kh, MakePlayerObserver) +{SELFPARAM(); + kh_Key_DropAll(self, true); + return 0; +} + +MUTATOR_HOOKFUNCTION(kh, PlayerDies) {SELFPARAM(); if(self == other) kh_Key_DropAll(self, true); @@ -1056,31 +1062,31 @@ MUTATOR_HOOKFUNCTION(kh_PlayerDies) return 0; } -MUTATOR_HOOKFUNCTION(kh_GiveFragsForKill) +MUTATOR_HOOKFUNCTION(kh, GiveFragsForKill, CBC_ORDER_FIRST) { frag_score = kh_HandleFrags(frag_attacker, frag_target, frag_score); return 0; } -MUTATOR_HOOKFUNCTION(kh_finalize) +MUTATOR_HOOKFUNCTION(kh, MatchEnd) { kh_finalize(); return 0; } -MUTATOR_HOOKFUNCTION(kh_GetTeamCount) +MUTATOR_HOOKFUNCTION(kh, GetTeamCount, CBC_ORDER_EXCLUSIVE) { ret_float = kh_teams; return 0; } -MUTATOR_HOOKFUNCTION(kh_SpectateCopy) +MUTATOR_HOOKFUNCTION(kh, SpectateCopy) {SELFPARAM(); self.kh_state = other.kh_state; return 0; } -MUTATOR_HOOKFUNCTION(kh_PlayerUseKey) +MUTATOR_HOOKFUNCTION(kh, PlayerUseKey) {SELFPARAM(); if(MUTATOR_RETURNVALUE == 0) { @@ -1095,16 +1101,12 @@ MUTATOR_HOOKFUNCTION(kh_PlayerUseKey) return 0; } -MUTATOR_DEFINITION(gamemode_keyhunt) +REGISTER_MUTATOR(kh, g_keyhunt) { - MUTATOR_HOOK(MakePlayerObserver, kh_Key_DropAll, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, kh_Key_DropAll, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, kh_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(GiveFragsForKill, kh_GiveFragsForKill, CBC_ORDER_FIRST); - MUTATOR_HOOK(MatchEnd, kh_finalize, CBC_ORDER_ANY); - MUTATOR_HOOK(GetTeamCount, kh_GetTeamCount, CBC_ORDER_EXCLUSIVE); - MUTATOR_HOOK(SpectateCopy, kh_SpectateCopy, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerUseKey, kh_PlayerUseKey, CBC_ORDER_ANY); + ActivateTeamplay(); + SetLimits(autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_point_leadlimit, -1, -1); + if(autocvar_g_keyhunt_team_spawns) + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index b3cf0db6a..84105f012 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -25,7 +25,7 @@ float LMS_NewPlayerLives() } // mutator hooks -MUTATOR_HOOKFUNCTION(lms_ResetMap) +MUTATOR_HOOKFUNCTION(lms, reset_map_global) { lms_lowest_lives = 999; lms_next_place = player_count; @@ -33,7 +33,7 @@ MUTATOR_HOOKFUNCTION(lms_ResetMap) return false; } -MUTATOR_HOOKFUNCTION(lms_ResetPlayers) +MUTATOR_HOOKFUNCTION(lms, reset_map_players) {SELFPARAM(); entity e; if(restart_mapalreadyrestarted || (time < game_starttime)) @@ -46,7 +46,7 @@ MUTATOR_HOOKFUNCTION(lms_ResetPlayers) return false; } -MUTATOR_HOOKFUNCTION(lms_PlayerPreSpawn) +MUTATOR_HOOKFUNCTION(lms, PutClientInServer) {SELFPARAM(); // player is dead and becomes observer // FIXME fix LMS scoring for new system @@ -59,31 +59,41 @@ MUTATOR_HOOKFUNCTION(lms_PlayerPreSpawn) return false; } -MUTATOR_HOOKFUNCTION(lms_PlayerDies) +MUTATOR_HOOKFUNCTION(lms, PlayerDies) {SELFPARAM(); self.respawn_flags |= RESPAWN_FORCE; return false; } -MUTATOR_HOOKFUNCTION(lms_RemovePlayer) -{SELFPARAM(); +void lms_RemovePlayer(entity player) +{ // Only if the player cannot play at all - if(PlayerScore_Add(self, SP_LMS_RANK, 0) == 666) - self.frags = FRAGS_SPECTATOR; + if(PlayerScore_Add(player, SP_LMS_RANK, 0) == 666) + player.frags = FRAGS_SPECTATOR; else - self.frags = FRAGS_LMS_LOSER; + player.frags = FRAGS_LMS_LOSER; - if(self.killcount != -666) - if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0 && self.lms_spectate_warning != 2) - Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_NOLIVES, self.netname); + if(player.killcount != -666) + if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0 && player.lms_spectate_warning != 2) + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_NOLIVES, player.netname); else - Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_FORFEIT, self.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_FORFEIT, player.netname); +} +MUTATOR_HOOKFUNCTION(lms, ClientDisconnect) +{SELFPARAM(); + lms_RemovePlayer(self); + return false; +} + +MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver) +{SELFPARAM(); + lms_RemovePlayer(self); return false; } -MUTATOR_HOOKFUNCTION(lms_ClientConnect) +MUTATOR_HOOKFUNCTION(lms, ClientConnect) {SELFPARAM(); self.classname = "player"; campaign_bots_may_start = 1; @@ -97,7 +107,7 @@ MUTATOR_HOOKFUNCTION(lms_ClientConnect) return false; } -MUTATOR_HOOKFUNCTION(lms_PlayerThink) +MUTATOR_HOOKFUNCTION(lms, PlayerPreThink) {SELFPARAM(); if(self.deadflag == DEAD_DYING) self.deadflag = DEAD_RESPAWNING; @@ -105,20 +115,20 @@ MUTATOR_HOOKFUNCTION(lms_PlayerThink) return false; } -MUTATOR_HOOKFUNCTION(lms_PlayerRegen) +MUTATOR_HOOKFUNCTION(lms, PlayerRegen) { if(autocvar_g_lms_regenerate) return false; return true; } -MUTATOR_HOOKFUNCTION(lms_ForbidThrowing) +MUTATOR_HOOKFUNCTION(lms, ForbidThrowCurrentWeapon) { // forbode! return true; } -MUTATOR_HOOKFUNCTION(lms_GiveFragsForKill) +MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill) { // remove a life float tl; @@ -139,7 +149,7 @@ MUTATOR_HOOKFUNCTION(lms_GiveFragsForKill) return true; } -MUTATOR_HOOKFUNCTION(lms_SetStartItems) +MUTATOR_HOOKFUNCTION(lms, SetStartItems) { start_items &= ~IT_UNLIMITED_AMMO; start_health = warmup_start_health = cvar("g_lms_start_health"); @@ -154,13 +164,13 @@ MUTATOR_HOOKFUNCTION(lms_SetStartItems) return false; } -MUTATOR_HOOKFUNCTION(lms_KeepScore) +MUTATOR_HOOKFUNCTION(lms, ForbidPlayerScore_Clear) { // don't clear player score return true; } -MUTATOR_HOOKFUNCTION(lms_FilterItem) +MUTATOR_HOOKFUNCTION(lms, FilterItem) {SELFPARAM(); if(autocvar_g_lms_extra_lives) if(self.itemdef == ITEM_HealthMega) @@ -172,7 +182,7 @@ MUTATOR_HOOKFUNCTION(lms_FilterItem) return true; } -MUTATOR_HOOKFUNCTION(lms_ItemTouch) +MUTATOR_HOOKFUNCTION(lms, ItemTouch) {SELFPARAM(); // give extra lives for mega health if (self.items & ITEM_HealthMega.m_itemid) @@ -201,22 +211,9 @@ void lms_Initialize() lms_ScoreRules(); } -MUTATOR_DEFINITION(gamemode_lms) +REGISTER_MUTATOR(lms, g_lms) { - MUTATOR_HOOK(reset_map_global, lms_ResetMap, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_players, lms_ResetPlayers, CBC_ORDER_ANY); - MUTATOR_HOOK(PutClientInServer, lms_PlayerPreSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, lms_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, lms_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientConnect, lms_ClientConnect, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, lms_PlayerThink, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerRegen, lms_PlayerRegen, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidThrowCurrentWeapon, lms_ForbidThrowing, CBC_ORDER_ANY); - MUTATOR_HOOK(GiveFragsForKill, lms_GiveFragsForKill, CBC_ORDER_ANY); - MUTATOR_HOOK(SetStartItems, lms_SetStartItems, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidPlayerScore_Clear, lms_KeepScore, CBC_ORDER_ANY); - MUTATOR_HOOK(FilterItem, lms_FilterItem, CBC_ORDER_ANY); - MUTATOR_HOOK(ItemTouch, lms_ItemTouch, CBC_ORDER_ANY); + SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, -1, -1); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 8b2e223c0..eb0a2e990 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -1664,7 +1664,7 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe // Hook Functions // ============== -MUTATOR_HOOKFUNCTION(ons_ResetMap) +MUTATOR_HOOKFUNCTION(ons, reset_map_global) {SELFPARAM(); entity e; FOR_EACH_PLAYER(e) @@ -1676,13 +1676,19 @@ MUTATOR_HOOKFUNCTION(ons_ResetMap) return false; } -MUTATOR_HOOKFUNCTION(ons_RemovePlayer) +MUTATOR_HOOKFUNCTION(ons, ClientDisconnect) {SELFPARAM(); self.ons_deathloc = '0 0 0'; return false; } -MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) +MUTATOR_HOOKFUNCTION(ons, MakePlayerObserver) +{SELFPARAM(); + self.ons_deathloc = '0 0 0'; + return false; +} + +MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) {SELFPARAM(); if(!round_handler_IsRoundStarted()) { @@ -1808,7 +1814,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(ons_PlayerDies) +MUTATOR_HOOKFUNCTION(ons, PlayerDies) {SELFPARAM(); frag_target.ons_deathloc = frag_target.origin; entity l; @@ -1828,7 +1834,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerDies) return false; } -MUTATOR_HOOKFUNCTION(ons_MonsterThink) +MUTATOR_HOOKFUNCTION(ons, MonsterMove) {SELFPARAM(); entity e = find(world, targetname, self.target); if (e != world) @@ -1858,7 +1864,7 @@ void ons_MonsterSpawn_Delayed() remove(self); } -MUTATOR_HOOKFUNCTION(ons_MonsterSpawn) +MUTATOR_HOOKFUNCTION(ons, MonsterSpawn) {SELFPARAM(); entity e = spawn(); e.owner = self; @@ -1889,7 +1895,7 @@ void ons_TurretSpawn_Delayed() remove(self); } -MUTATOR_HOOKFUNCTION(ons_TurretSpawn) +MUTATOR_HOOKFUNCTION(ons, TurretSpawn) {SELFPARAM(); entity e = spawn(); e.owner = self; @@ -1898,13 +1904,13 @@ MUTATOR_HOOKFUNCTION(ons_TurretSpawn) return false; } -MUTATOR_HOOKFUNCTION(ons_BotRoles) +MUTATOR_HOOKFUNCTION(ons, HavocBot_ChooseRole) {SELFPARAM(); havocbot_ons_reset_role(self); return true; } -MUTATOR_HOOKFUNCTION(ons_GetTeamCount) +MUTATOR_HOOKFUNCTION(ons, GetTeamCount) { // onslaught is special entity tmp_entity; @@ -1922,13 +1928,13 @@ MUTATOR_HOOKFUNCTION(ons_GetTeamCount) return true; } -MUTATOR_HOOKFUNCTION(ons_SpectateCopy) +MUTATOR_HOOKFUNCTION(ons, SpectateCopy) {SELFPARAM(); self.ons_roundlost = other.ons_roundlost; // make spectators see it too return false; } -MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand) +MUTATOR_HOOKFUNCTION(ons, SV_ParseClientCommand) {SELFPARAM(); if(MUTATOR_RETURNVALUE) // command was already handled? return false; @@ -1992,7 +1998,7 @@ MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand) return 0; } -MUTATOR_HOOKFUNCTION(ons_PlayerUseKey) +MUTATOR_HOOKFUNCTION(ons, PlayerUseKey) {SELFPARAM(); if(MUTATOR_RETURNVALUE || gameover) { return false; } @@ -2009,7 +2015,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerUseKey) return false; } -MUTATOR_HOOKFUNCTION(ons_PlayHitsound) +MUTATOR_HOOKFUNCTION(ons, PlayHitsound) { return (frag_victim.classname == "onslaught_generator" && !frag_victim.isshielded) || (frag_victim.classname == "onslaught_controlpoint_icon" && !frag_victim.owner.isshielded); @@ -2105,22 +2111,11 @@ void ons_Initialize() InitializeEntity(world, ons_DelayedInit, INITPRIO_GAMETYPE); } -MUTATOR_DEFINITION(gamemode_onslaught) +REGISTER_MUTATOR(ons, g_onslaught) { - MUTATOR_HOOK(reset_map_global, ons_ResetMap, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, ons_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientDisconnect, ons_RemovePlayer, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, ons_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, ons_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(MonsterMove, ons_MonsterThink, CBC_ORDER_ANY); - MUTATOR_HOOK(MonsterSpawn, ons_MonsterSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(TurretSpawn, ons_TurretSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, ons_BotRoles, CBC_ORDER_ANY); - MUTATOR_HOOK(GetTeamCount, ons_GetTeamCount, CBC_ORDER_ANY); - MUTATOR_HOOK(SpectateCopy, ons_SpectateCopy, CBC_ORDER_ANY); - MUTATOR_HOOK(SV_ParseClientCommand, ons_SV_ParseClientCommand, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerUseKey, ons_PlayerUseKey, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayHitsound, ons_PlayHitsound, CBC_ORDER_ANY); + ActivateTeamplay(); + SetLimits(autocvar_g_onslaught_point_limit, -1, -1, -1); + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_race.qc b/qcsrc/server/mutators/gamemode_race.qc index 271456986..fa2e24f45 100644 --- a/qcsrc/server/mutators/gamemode_race.qc +++ b/qcsrc/server/mutators/gamemode_race.qc @@ -62,7 +62,7 @@ void race_EventLog(string mode, entity actor) // use an alias for easy changing GameLogEcho(strcat(":race:", mode, ":", ((actor != world) ? (strcat(":", ftos(actor.playerid))) : ""))); } -MUTATOR_HOOKFUNCTION(race_PlayerPhysics) +MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) {SELFPARAM(); // force kbd movement for fairness float wishspeed; @@ -113,7 +113,7 @@ MUTATOR_HOOKFUNCTION(race_PlayerPhysics) return false; } -MUTATOR_HOOKFUNCTION(race_ResetMap) +MUTATOR_HOOKFUNCTION(rc, reset_map_global) { float s; @@ -147,7 +147,7 @@ MUTATOR_HOOKFUNCTION(race_ResetMap) return false; } -MUTATOR_HOOKFUNCTION(race_PlayerPreThink) +MUTATOR_HOOKFUNCTION(rc, PlayerPreThink) {SELFPARAM(); if(IS_SPEC(self) || IS_OBSERVER(self)) if(g_race_qualifying) @@ -157,7 +157,7 @@ MUTATOR_HOOKFUNCTION(race_PlayerPreThink) return false; } -MUTATOR_HOOKFUNCTION(race_ClientConnect) +MUTATOR_HOOKFUNCTION(rc, ClientConnect) {SELFPARAM(); race_PreparePlayer(); self.race_checkpoint = -1; @@ -184,7 +184,7 @@ MUTATOR_HOOKFUNCTION(race_ClientConnect) return false; } -MUTATOR_HOOKFUNCTION(race_MakePlayerObserver) +MUTATOR_HOOKFUNCTION(rc, MakePlayerObserver) {SELFPARAM(); if(g_race_qualifying) if(PlayerScore_Add(self, SP_RACE_FASTEST, 0)) @@ -198,7 +198,7 @@ MUTATOR_HOOKFUNCTION(race_MakePlayerObserver) return false; } -MUTATOR_HOOKFUNCTION(race_PlayerSpawn) +MUTATOR_HOOKFUNCTION(rc, PlayerSpawn) {SELFPARAM(); if(spawn_spot.target == "") // Emergency: this wasn't a real spawnpoint. Can this ever happen? @@ -213,7 +213,7 @@ MUTATOR_HOOKFUNCTION(race_PlayerSpawn) return false; } -MUTATOR_HOOKFUNCTION(race_PutClientInServer) +MUTATOR_HOOKFUNCTION(rc, PutClientInServer) {SELFPARAM(); if(IS_PLAYER(self)) if(!gameover) @@ -228,20 +228,20 @@ MUTATOR_HOOKFUNCTION(race_PutClientInServer) return false; } -MUTATOR_HOOKFUNCTION(race_PlayerDies) +MUTATOR_HOOKFUNCTION(rc, PlayerDies) {SELFPARAM(); self.respawn_flags |= RESPAWN_FORCE; race_AbandonRaceCheck(self); return false; } -MUTATOR_HOOKFUNCTION(race_BotRoles) +MUTATOR_HOOKFUNCTION(rc, HavocBot_ChooseRole) {SELFPARAM(); self.havocbot_role = havocbot_role_race; return true; } -MUTATOR_HOOKFUNCTION(race_PlayerPostThink) +MUTATOR_HOOKFUNCTION(rc, GetPressedKeys) {SELFPARAM(); if(self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1) { @@ -258,7 +258,7 @@ MUTATOR_HOOKFUNCTION(race_PlayerPostThink) return false; } -MUTATOR_HOOKFUNCTION(race_ForbidClearPlayerScore) +MUTATOR_HOOKFUNCTION(rc, ForbidPlayerScore_Clear) { if(g_race_qualifying) return true; // in qualifying, you don't lose score by observing @@ -266,13 +266,13 @@ MUTATOR_HOOKFUNCTION(race_ForbidClearPlayerScore) return false; } -MUTATOR_HOOKFUNCTION(race_GetTeamCount) +MUTATOR_HOOKFUNCTION(rc, GetTeamCount, CBC_ORDER_EXCLUSIVE) { ret_float = race_teams; return false; } -MUTATOR_HOOKFUNCTION(race_CountFrags) +MUTATOR_HOOKFUNCTION(rc, Scores_CountFragsRemaining) { // announce remaining frags if not in qualifying mode if(!g_race_qualifying) @@ -288,21 +288,53 @@ void race_Initialize() warmup_stage = 0; } -MUTATOR_DEFINITION(gamemode_race) +void rc_SetLimits() { - MUTATOR_HOOK(PlayerPhysics, race_PlayerPhysics, CBC_ORDER_ANY); - MUTATOR_HOOK(reset_map_global, race_ResetMap, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerPreThink, race_PlayerPreThink, CBC_ORDER_ANY); - MUTATOR_HOOK(ClientConnect, race_ClientConnect, CBC_ORDER_ANY); - MUTATOR_HOOK(MakePlayerObserver, race_MakePlayerObserver, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerSpawn, race_PlayerSpawn, CBC_ORDER_ANY); - MUTATOR_HOOK(PutClientInServer, race_PutClientInServer, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerDies, race_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRole, race_BotRoles, CBC_ORDER_ANY); - MUTATOR_HOOK(GetPressedKeys, race_PlayerPostThink, CBC_ORDER_ANY); - MUTATOR_HOOK(ForbidPlayerScore_Clear, race_ForbidClearPlayerScore, CBC_ORDER_ANY); - MUTATOR_HOOK(GetTeamCount, race_GetTeamCount, CBC_ORDER_ANY); - MUTATOR_HOOK(Scores_CountFragsRemaining, race_CountFrags, CBC_ORDER_ANY); + int fraglimit_override, leadlimit_override; + float timelimit_override, qualifying_override; + + if(autocvar_g_race_teams) + { + ActivateTeamplay(); + race_teams = bound(2, autocvar_g_race_teams, 4); + have_team_spawns = -1; // request team spawns + } + else + race_teams = 0; + + qualifying_override = autocvar_g_race_qualifying_timelimit_override; + fraglimit_override = autocvar_g_race_laps_limit; + leadlimit_override = 0; // currently not supported by race + timelimit_override = -1; // use default if we don't set it below + + // we need to find out the correct value for g_race_qualifying + float want_qualifying = ((qualifying_override >= 0) ? qualifying_override : autocvar_g_race_qualifying_timelimit) > 0; + + if(autocvar_g_campaign) + { + g_race_qualifying = 1; + independent_players = 1; + } + else if(!autocvar_g_campaign && want_qualifying) + { + g_race_qualifying = 2; + independent_players = 1; + race_fraglimit = (race_fraglimit >= 0) ? fraglimit_override : autocvar_fraglimit; + race_leadlimit = (race_leadlimit >= 0) ? leadlimit_override : autocvar_leadlimit; + race_timelimit = (race_timelimit >= 0) ? timelimit_override : autocvar_timelimit; + fraglimit_override = 0; + leadlimit_override = 0; + timelimit_override = autocvar_g_race_qualifying_timelimit; + } + else + g_race_qualifying = 0; + + SetLimits(fraglimit_override, leadlimit_override, timelimit_override, qualifying_override); +} + +REGISTER_MUTATOR(rc, g_race) +{ + rc_SetLimits(); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_tdm.qc b/qcsrc/server/mutators/gamemode_tdm.qc index 2ff647db0..acb875c55 100644 --- a/qcsrc/server/mutators/gamemode_tdm.qc +++ b/qcsrc/server/mutators/gamemode_tdm.qc @@ -43,22 +43,24 @@ void tdm_DelayedInit() } } -MUTATOR_HOOKFUNCTION(tdm_GetTeamCount) +MUTATOR_HOOKFUNCTION(tdm, GetTeamCount, CBC_ORDER_EXCLUSIVE) { ret_string = "tdm_team"; return true; } -MUTATOR_HOOKFUNCTION(tdm_CountFrags) +MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining) { // announce remaining frags return true; } -MUTATOR_DEFINITION(gamemode_tdm) +REGISTER_MUTATOR(tdm, g_tdm) { - MUTATOR_HOOK(GetTeamCount, tdm_GetTeamCount, CBC_ORDER_ANY); - MUTATOR_HOOK(Scores_CountFragsRemaining, tdm_CountFrags, CBC_ORDER_ANY); + ActivateTeamplay(); + SetLimits(autocvar_g_tdm_point_limit, autocvar_g_tdm_point_leadlimit, -1, -1); + if(autocvar_g_tdm_team_spawns) + have_team_spawns = -1; // request team spawns MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index b65cbd2e7..8556be077 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -1,21 +1,6 @@ #ifndef MUTATORS_H #define MUTATORS_H -MUTATOR_DECLARATION(gamemode_assault); -MUTATOR_DECLARATION(gamemode_ca); -MUTATOR_DECLARATION(gamemode_keyhunt); -MUTATOR_DECLARATION(gamemode_freezetag); -MUTATOR_DECLARATION(gamemode_keepaway); -MUTATOR_DECLARATION(gamemode_ctf); -MUTATOR_DECLARATION(gamemode_onslaught); -MUTATOR_DECLARATION(gamemode_domination); -MUTATOR_DECLARATION(gamemode_lms); -MUTATOR_DECLARATION(gamemode_invasion); -MUTATOR_DECLARATION(gamemode_cts); -MUTATOR_DECLARATION(gamemode_race); -MUTATOR_DECLARATION(gamemode_tdm); -MUTATOR_DECLARATION(gamemode_deathmatch); - MUTATOR_DECLARATION(mutator_dodging); MUTATOR_DECLARATION(mutator_invincibleprojectiles); MUTATOR_DECLARATION(mutator_new_toys); diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 5a9d2ee3b..73ab0cefe 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -44,12 +44,25 @@ void ActivateTeamplay() cvar_set("teamplay", "2"); // DP needs this for sending proper getstatus replies. } -void InitGameplayMode() +void SetLimits(int fraglimit_override, int leadlimit_override, float timelimit_override, float qualifying_override) { - float fraglimit_override, timelimit_override, leadlimit_override, qualifying_override; - - qualifying_override = -1; + // enforce the server's universal frag/time limits + // set to -1 to not change value + if(!autocvar_g_campaign) + { + if(fraglimit_override >= 0) + cvar_set("fraglimit", ftos(fraglimit_override)); + if(timelimit_override >= 0) + cvar_set("timelimit", ftos(timelimit_override)); + if(leadlimit_override >= 0) + cvar_set("leadlimit", ftos(leadlimit_override)); + if(qualifying_override >= 0) + cvar_set("g_race_qualifying_timelimit", ftos(qualifying_override)); + } +} +void InitGameplayMode() +{ VoteReset(); // find out good world mins/maxs bounds, either the static bounds found by looking for solid, or the mapinfo specified bounds @@ -77,192 +90,12 @@ void InitGameplayMode() MapInfo_ClearTemps(); // set both here, gamemode can override it later - timelimit_override = autocvar_timelimit_override; - fraglimit_override = autocvar_fraglimit_override; - leadlimit_override = autocvar_leadlimit_override; + SetLimits(autocvar_fraglimit_override, autocvar_leadlimit_override, autocvar_timelimit_override, -1); gamemode_name = MapInfo_Type_ToText(MapInfo_LoadedGametype); - if(g_dm) - { - MUTATOR_ADD(gamemode_deathmatch); - } - - if(g_tdm) - { - ActivateTeamplay(); - fraglimit_override = autocvar_g_tdm_point_limit; - leadlimit_override = autocvar_g_tdm_point_leadlimit; - if(autocvar_g_tdm_team_spawns) - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_tdm); - } - - if(g_domination) - { - ActivateTeamplay(); - fraglimit_override = autocvar_g_domination_point_limit; - leadlimit_override = autocvar_g_domination_point_leadlimit; - if(autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) - fraglimit_override = autocvar_g_domination_roundbased_point_limit; - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_domination); - } - - if(g_ctf) - { - ActivateTeamplay(); - fraglimit_override = autocvar_capturelimit_override; - leadlimit_override = autocvar_captureleadlimit_override; - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_ctf); - } - - if(g_lms) - { - fraglimit_override = autocvar_g_lms_lives_override; - leadlimit_override = 0; // not supported by LMS - if(fraglimit_override == 0) - fraglimit_override = -1; - MUTATOR_ADD(gamemode_lms); - } - - if(g_ca) - { - ActivateTeamplay(); - fraglimit_override = autocvar_g_ca_point_limit; - leadlimit_override = autocvar_g_ca_point_leadlimit; - if(autocvar_g_ca_team_spawns) - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_ca); - } - - if(g_keyhunt) - { - ActivateTeamplay(); - fraglimit_override = autocvar_g_keyhunt_point_limit; - leadlimit_override = autocvar_g_keyhunt_point_leadlimit; - if(autocvar_g_keyhunt_team_spawns) - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_keyhunt); - } - - if(g_freezetag) - { - ActivateTeamplay(); - fraglimit_override = autocvar_g_freezetag_point_limit; - leadlimit_override = autocvar_g_freezetag_point_leadlimit; - if(autocvar_g_freezetag_team_spawns) - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_freezetag); - } - - if(g_assault) - { - ActivateTeamplay(); - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_assault); - } - - if(g_onslaught) - { - ActivateTeamplay(); - fraglimit_override = autocvar_g_onslaught_point_limit; - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_onslaught); - } - - if(g_race) - { - if(autocvar_g_race_teams) - { - ActivateTeamplay(); - race_teams = bound(2, autocvar_g_race_teams, 4); - have_team_spawns = -1; // request team spawns - } - else - race_teams = 0; - qualifying_override = autocvar_g_race_qualifying_timelimit_override; - fraglimit_override = autocvar_g_race_laps_limit; - leadlimit_override = 0; // currently not supported by race - - // we need to find out the correct value for g_race_qualifying - float want_qualifying = ((qualifying_override >= 0) ? qualifying_override : autocvar_g_race_qualifying_timelimit) > 0; - - if(autocvar_g_campaign) - { - g_race_qualifying = 1; - independent_players = 1; - } - else if(!autocvar_g_campaign && want_qualifying) - { - g_race_qualifying = 2; - independent_players = 1; - race_fraglimit = (race_fraglimit >= 0) ? fraglimit_override : autocvar_fraglimit; - race_leadlimit = (race_leadlimit >= 0) ? leadlimit_override : autocvar_leadlimit; - race_timelimit = (race_timelimit >= 0) ? timelimit_override : autocvar_timelimit; - fraglimit_override = 0; - leadlimit_override = 0; - timelimit_override = autocvar_g_race_qualifying_timelimit; - } - else - { - g_race_qualifying = 0; - } - - MUTATOR_ADD(gamemode_race); - } - - if(g_cts) - { - g_race_qualifying = 1; - fraglimit_override = 0; - leadlimit_override = 0; - independent_players = 1; - MUTATOR_ADD(gamemode_cts); - } - - if(g_nexball) - { - fraglimit_override = autocvar_g_nexball_goallimit; - leadlimit_override = autocvar_g_nexball_goalleadlimit; - ActivateTeamplay(); - have_team_spawns = -1; // request team spawns - MUTATOR_ADD(gamemode_nexball); - } - - if(g_keepaway) - { - MUTATOR_ADD(gamemode_keepaway); - } - - if(g_invasion) - { - fraglimit_override = autocvar_g_invasion_point_limit; - if(autocvar_g_invasion_teams >= 2) - { - ActivateTeamplay(); - if(autocvar_g_invasion_team_spawns) - have_team_spawns = -1; // request team spawns - } - MUTATOR_ADD(gamemode_invasion); - } - cache_mutatormsg = strzone(""); cache_lastmutatormsg = strzone(""); - // enforce the server's universal frag/time limits - if(!autocvar_g_campaign) - { - if(fraglimit_override >= 0) - cvar_set("fraglimit", ftos(fraglimit_override)); - if(timelimit_override >= 0) - cvar_set("timelimit", ftos(timelimit_override)); - if(leadlimit_override >= 0) - cvar_set("leadlimit", ftos(leadlimit_override)); - if(qualifying_override >= 0) - cvar_set("g_race_qualifying_timelimit", ftos(qualifying_override)); - } - InitializeEntity(world, default_delayedinit, INITPRIO_GAMETYPE_FALLBACK); }