From: Mario Date: Sat, 29 Aug 2015 06:23:14 +0000 (+1000) Subject: Add a mutator file for deathmatch and add a hook for counting the remaining frags... X-Git-Tag: xonotic-v0.8.2~2000 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3fffd587c93c7705c6d67c87e57a755851de4d63;p=xonotic%2Fxonotic-data.pk3dir.git Add a mutator file for deathmatch and add a hook for counting the remaining frags (also removing it from score based modes, where counting remaining frags is silly) --- diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 2ad5af5ac..05c508c4c 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1857,7 +1857,7 @@ float WinningCondition_Scores(float limit, float leadlimit) if(WinningConditionHelper_zeroisworst) leadlimit = 0; // not supported in this mode - if(g_dm || g_tdm || g_ca || g_freezetag || (g_race && !g_race_qualifying) || g_nexball) + if(MUTATOR_CALLHOOK(Scores_CountFragsRemaining)) // these modes always score in increments of 1, thus this makes sense { if(leaderfrags != WinningConditionHelper_topscore) diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 3db532022..33fa9ee3f 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -583,4 +583,7 @@ MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit); /**/ o(string, ret_string) \ /**/ MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel); + +/** Return error to play frag remaining announcements */ +MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS); #endif diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index 9ad532e90..544b8766b 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -353,6 +353,12 @@ MUTATOR_HOOKFUNCTION(ca_PlayerRegen) return true; } +MUTATOR_HOOKFUNCTION(ca_CountFrags) +{ + // announce remaining frags + return true; +} + void ca_Initialize() { allowed_to_spawn = true; @@ -394,6 +400,7 @@ MUTATOR_DEFINITION(gamemode_ca) 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); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_deathmatch.qc b/qcsrc/server/mutators/gamemode_deathmatch.qc new file mode 100644 index 000000000..06afc516b --- /dev/null +++ b/qcsrc/server/mutators/gamemode_deathmatch.qc @@ -0,0 +1,31 @@ +MUTATOR_HOOKFUNCTION(dm_CountFrags) +{ + // announce remaining frags + return true; +} + +MUTATOR_DEFINITION(gamemode_deathmatch) +{ + MUTATOR_HOOK(Scores_CountFragsRemaining, dm_CountFrags, CBC_ORDER_ANY); + + MUTATOR_ONADD + { + if(time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back dm_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + print("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index fd3a9deb4..e1336c5c1 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -555,7 +555,7 @@ MUTATOR_HOOKFUNCTION(freezetag_BotRoles) MUTATOR_HOOKFUNCTION(freezetag_GetTeamCount) { ret_float = freezetag_teams; - return 0; + return false; } void freezetag_Initialize() diff --git a/qcsrc/server/mutators/gamemode_nexball.qc b/qcsrc/server/mutators/gamemode_nexball.qc index 456d0df1f..2875f316e 100644 --- a/qcsrc/server/mutators/gamemode_nexball.qc +++ b/qcsrc/server/mutators/gamemode_nexball.qc @@ -778,7 +778,6 @@ void W_Nexball_Attack2(void) if(!(balls & BALL_BASKET)) return; W_SetupShot(self, false, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0); -// Send_Effect("grenadelauncher_muzzleflash", w_shotorg, w_shotdir * 1000, 1); missile = spawn(); missile.owner = self; diff --git a/qcsrc/server/mutators/gamemode_race.qc b/qcsrc/server/mutators/gamemode_race.qc index 3cefc8669..be6515475 100644 --- a/qcsrc/server/mutators/gamemode_race.qc +++ b/qcsrc/server/mutators/gamemode_race.qc @@ -273,6 +273,15 @@ MUTATOR_HOOKFUNCTION(race_GetTeamCount) return false; } +MUTATOR_HOOKFUNCTION(race_CountFrags) +{ + // announce remaining frags if not in qualifying mode + if(!g_race_qualifying) + return true; + + return false; +} + void race_Initialize() { race_ScoreRules(); @@ -294,6 +303,7 @@ MUTATOR_DEFINITION(gamemode_race) 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); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_tdm.qc b/qcsrc/server/mutators/gamemode_tdm.qc index afff8bdb2..d977ece6f 100644 --- a/qcsrc/server/mutators/gamemode_tdm.qc +++ b/qcsrc/server/mutators/gamemode_tdm.qc @@ -55,9 +55,16 @@ MUTATOR_HOOKFUNCTION(tdm_GetTeamCount) return true; } +MUTATOR_HOOKFUNCTION(tdm_CountFrags) +{ + // announce remaining frags + return true; +} + MUTATOR_DEFINITION(gamemode_tdm) { MUTATOR_HOOK(GetTeamCount, tdm_GetTeamCount, CBC_ORDER_ANY); + MUTATOR_HOOK(Scores_CountFragsRemaining, tdm_CountFrags, CBC_ORDER_ANY); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index 6d889e24e..e1355a447 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -15,6 +15,7 @@ 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); diff --git a/qcsrc/server/mutators/mutators_include.qc b/qcsrc/server/mutators/mutators_include.qc index aaedcba8b..d403cb12f 100644 --- a/qcsrc/server/mutators/mutators_include.qc +++ b/qcsrc/server/mutators/mutators_include.qc @@ -89,6 +89,7 @@ #include "gamemode_race.qc" #include "gamemode_cts.qc" #include "gamemode_tdm.qc" +#include "gamemode_deathmatch.qc" #include "mutator_invincibleproj.qc" #include "mutator_new_toys.qc" diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index f75df5e38..26bcb246d 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -84,6 +84,7 @@ void InitGameplayMode() if(g_dm) { + MUTATOR_ADD(gamemode_deathmatch); } if(g_tdm)