From 4ad442e8cc56c3d43c7d5a10eb776ebc6bef40fa Mon Sep 17 00:00:00 2001 From: drjaska Date: Sat, 29 Jan 2022 08:26:30 +0200 Subject: [PATCH] set mayhem_fraglimit to respect fraglimit_override and set menu to use fraglimit_override + some cleanup --- .../gamemodes/gamemode/mayhem/mayhem.qh | 2 +- .../gamemodes/gamemode/mayhem/sv_mayhem.qc | 18 +++++++++------- .../gamemodes/gamemode/tmayhem/sv_tmayhem.qc | 21 +++++++++++-------- .../gamemodes/gamemode/tmayhem/tmayhem.qh | 2 +- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh b/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh index e853d3553..19de29f03 100644 --- a/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh +++ b/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh @@ -26,7 +26,7 @@ CLASS(mayhem, Gametype) METHOD(mayhem, m_configuremenu, void(Gametype this, entity menu, void(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip) returns)) { TC(Gametype, this); - returns(menu, _("Frag limit:"), 5, 100, 5, "g_mayhem_fraglimit", string_null, _("How many frags worth of score is needed before the match will end")); + returns(menu, _("Frag limit:"), 5, 100, 5, "fraglimit_override", string_null, _("How many frags worth of score is needed before the match will end")); } ATTRIB(mayhem, m_legacydefaults, string, "30 20 0"); ENDCLASS(mayhem) diff --git a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc index 7a8ae68e3..035718794 100644 --- a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc @@ -3,7 +3,6 @@ float autocvar_g_mayhem_fraglimit; float autocvar_g_mayhem_visual_score_limit; -float mayhempointmultiplier; bool autocvar_g_mayhem_regenerate; string autocvar_g_mayhem_weaponarena; @@ -35,10 +34,10 @@ void mayhem_DelayedInit(entity this) void mayhem_Initialize() { - if(autocvar_g_mayhem_visual_score_limit > 0 && autocvar_g_mayhem_fraglimit > 0) - mayhempointmultiplier = autocvar_g_mayhem_visual_score_limit / autocvar_g_mayhem_fraglimit; - - GameRules_limit_score(autocvar_g_mayhem_visual_score_limit); + if (autocvar_fraglimit_override != 0) + GameRules_limit_score(autocvar_g_mayhem_visual_score_limit); + else + GameRules_limit_score(9999); InitializeEntity(NULL, mayhem_DelayedInit, INITPRIO_GAMETYPE); } @@ -52,7 +51,7 @@ MUTATOR_HOOKFUNCTION(mayhem, Scores_CountFragsRemaining) MUTATOR_HOOKFUNCTION(mayhem, SetStartItems) { start_items &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS); - if(!cvar("g_use_ammunition") || autocvar_g_mayhem_unlimited_ammo) + if (!cvar("g_use_ammunition") || autocvar_g_mayhem_unlimited_ammo) start_items |= IT_UNLIMITED_AMMO; start_health = warmup_start_health = autocvar_g_mayhem_start_health; @@ -68,7 +67,7 @@ MUTATOR_HOOKFUNCTION(mayhem, SetStartItems) //this hook also enables rotting, as players spawn with more hp and armor than what default rot limits are set to this is a bad idea as of now MUTATOR_HOOKFUNCTION(mayhem, PlayerRegen) { - if(autocvar_g_mayhem_regenerate) + if (autocvar_g_mayhem_regenerate) return false; return true; } @@ -130,7 +129,10 @@ MUTATOR_HOOKFUNCTION(mayhem, Damage_Calculate) M_ARGV(4, float) = frag_damage; } -void FFAMayhemCalculatePlayerScore(entity scorer){ +void FFAMayhemCalculatePlayerScore(entity scorer) +{ + if (autocvar_fraglimit_override > 0) autocvar_g_mayhem_fraglimit = autocvar_fraglimit_override; + switch (autocvar_g_mayhem_scoringmethod) { default: diff --git a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc index 4c9e7f85d..22914adc1 100644 --- a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc @@ -4,7 +4,6 @@ float autocvar_g_tmayhem_fraglimit; float autocvar_g_tmayhem_visual_score_limit; float autocvar_g_tmayhem_score_leadlimit; bool autocvar_g_tmayhem_team_spawns; -float tmayhempointmultiplier; // TODO? rename to teammayhem? requires checking alias and other string lengths int autocvar_g_tmayhem_teams; @@ -47,7 +46,7 @@ void tmayhem_SpawnTeam (string teamname, int teamcolor) void tmayhem_DelayedInit(entity this) { // if no teams are found, spawn defaults - if(find(NULL, classname, "tmayhem_team") == NULL) + if (find(NULL, classname, "tmayhem_team") == NULL) { LOG_TRACE("No \"tmayhem_team\" entities found on this map, creating them anyway."); @@ -68,14 +67,15 @@ void tmayhem_DelayedInit(entity this) void tmayhem_Initialize() { - if(autocvar_g_tmayhem_visual_score_limit != 0 && autocvar_g_tmayhem_fraglimit != 0) - tmayhempointmultiplier = autocvar_g_tmayhem_visual_score_limit / autocvar_g_tmayhem_fraglimit; - GameRules_teams(true); GameRules_spawning_teams(autocvar_g_tmayhem_team_spawns); - GameRules_limit_score(autocvar_g_tmayhem_visual_score_limit); GameRules_limit_lead(autocvar_g_tmayhem_score_leadlimit); + if (autocvar_fraglimit_override != 0) + GameRules_limit_score(autocvar_g_tmayhem_visual_score_limit); + else + GameRules_limit_score(9999); + InitializeEntity(NULL, tmayhem_DelayedInit, INITPRIO_GAMETYPE); } // code up to here is just to support maps that don't have team entities @@ -94,7 +94,7 @@ MUTATOR_HOOKFUNCTION(tmayhem, Scores_CountFragsRemaining) MUTATOR_HOOKFUNCTION(tmayhem, SetStartItems) { start_items &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS); - if(!cvar("g_use_ammunition") || autocvar_g_tmayhem_unlimited_ammo) + if (!cvar("g_use_ammunition") || autocvar_g_tmayhem_unlimited_ammo) start_items |= IT_UNLIMITED_AMMO; start_health = warmup_start_health = autocvar_g_tmayhem_start_health; @@ -110,7 +110,7 @@ MUTATOR_HOOKFUNCTION(tmayhem, SetStartItems) //this hook also enables rotting, as players spawn with more hp and armor than what default rot limits are set to this is a bad idea as of now until PlayerRegen is changed MUTATOR_HOOKFUNCTION(tmayhem, PlayerRegen) { - if(autocvar_g_tmayhem_regenerate) + if (autocvar_g_tmayhem_regenerate) return false; return true; } @@ -178,7 +178,10 @@ MUTATOR_HOOKFUNCTION(tmayhem, Damage_Calculate) M_ARGV(5, float) = frag_mirrordamage; } -void TeamMayhemCalculatePlayerScore(entity scorer){ +void TeamMayhemCalculatePlayerScore(entity scorer) +{ + if (autocvar_fraglimit_override > 0) autocvar_g_tmayhem_fraglimit = autocvar_fraglimit_override; + switch (autocvar_g_tmayhem_scoringmethod) { default: diff --git a/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh b/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh index 0e18d05d2..dd4fa6e37 100644 --- a/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh +++ b/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh @@ -43,7 +43,7 @@ CLASS(tmayhem, Gametype) METHOD(tmayhem, m_configuremenu, void(Gametype this, entity menu, void(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip) returns)) { TC(Gametype, this); - returns(menu, _("Frag limit:"), 5, 100, 5, "g_tmayhem_fraglimit", "g_tmayhem_teams_override", _("How many frags worth of score is needed before the match will end")); + returns(menu, _("Frag limit:"), 5, 100, 5, "fraglimit_override", "g_tmayhem_teams_override", _("How many frags worth of score is needed before the match will end")); } ATTRIB(tmayhem, m_legacydefaults, string, "50 20 2 0"); ENDCLASS(tmayhem) -- 2.39.2