From 6f0075e60655ee21dd6585b1def1fefd0a719b60 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 17 Dec 2020 22:44:35 -0800 Subject: [PATCH] Made minor roundstarts actually work. --- code/game/gamemodes/dynamic/dynamic.dm | 2 +- .../dynamic/dynamic_rulesets_minor.dm | 43 +++++++++++++++++++ .../gamemodes/dynamic/dynamic_storytellers.dm | 1 - 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/code/game/gamemodes/dynamic/dynamic.dm b/code/game/gamemodes/dynamic/dynamic.dm index 78821a881e..f57dda877c 100644 --- a/code/game/gamemodes/dynamic/dynamic.dm +++ b/code/game/gamemodes/dynamic/dynamic.dm @@ -415,7 +415,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null) /datum/game_mode/dynamic/post_setup(report) update_playercounts() if(minor_ruleset_start) - addtimer(CALLBACK(src, /datum/game_mode/dynamic/.proc/minor_roundstart),rand(1 MINUTES,5 MINUTES)) + addtimer(CALLBACK(src, /datum/game_mode/dynamic/.proc/minor_roundstart),rand(1 MINUTES,3 MINUTES)) else for(var/datum/dynamic_ruleset/roundstart/rule in executed_rules) addtimer(CALLBACK(src, /datum/game_mode/dynamic/.proc/execute_roundstart_rule, rule), rule.delay) diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets_minor.dm b/code/game/gamemodes/dynamic/dynamic_rulesets_minor.dm index 618befbaa7..74a61bd3ff 100644 --- a/code/game/gamemodes/dynamic/dynamic_rulesets_minor.dm +++ b/code/game/gamemodes/dynamic/dynamic_rulesets_minor.dm @@ -1,3 +1,46 @@ +/datum/dynamic_ruleset/minor/proc/trim_list(list/L = list()) + var/list/trimmed_list = L.Copy() + for(var/mob/M in trimmed_list) + if (!ishuman(M)) + trimmed_list.Remove(M) + continue + if (HAS_TRAIT(M, TRAIT_NO_MIDROUND_ANTAG)) + trimmed_list.Remove(M) + continue + if (!M.client) // Are they connected? + trimmed_list.Remove(M) + continue + if(!mode.check_age(M.client, minimum_required_age)) + trimmed_list.Remove(M) + continue + if(antag_flag_override) + if(!(antag_flag_override in M.client.prefs.be_special) || jobban_isbanned(M.ckey, antag_flag_override)) + trimmed_list.Remove(M) + continue + else + if(!(antag_flag in M.client.prefs.be_special) || jobban_isbanned(M.ckey, antag_flag)) + trimmed_list.Remove(M) + continue + if (M.mind) + if ((M.mind.assigned_role in GLOB.exp_specialmap[EXP_TYPE_SPECIAL])) // Are they playing a ghost role? + trimmed_list.Remove(M) + continue + if (M.mind.assigned_role in restricted_roles) // Does their job allow it? + trimmed_list.Remove(M) + continue + if ((exclusive_roles.len > 0) && !(M.mind.assigned_role in exclusive_roles)) // Is the rule exclusive to their job? + trimmed_list.Remove(M) + continue + return trimmed_list + +/datum/dynamic_ruleset/minor/trim_candidates() + // + // All you need to know is that here, the candidates list contains 4 lists itself, indexed with the following defines: + // Candidates = list(CURRENT_LIVING_PLAYERS, CURRENT_LIVING_ANTAGS, CURRENT_DEAD_PLAYERS, CURRENT_OBSERVERS) + // So for example you can get the list of all current dead players with var/list/dead_players = candidates[CURRENT_DEAD_PLAYERS] + // Make sure to properly typecheck the mobs in those lists, as the dead_players list could contain ghosts, or dead players still in their bodies. + // We're still gonna trim the obvious (mobs without clients, jobbanned players, etc) + candidates = trim_list(mode.current_players[CURRENT_LIVING_PLAYERS]) ////////////////////////////////////////////// // // diff --git a/code/game/gamemodes/dynamic/dynamic_storytellers.dm b/code/game/gamemodes/dynamic/dynamic_storytellers.dm index 84407ecce8..1ebbfdacc3 100644 --- a/code/game/gamemodes/dynamic/dynamic_storytellers.dm +++ b/code/game/gamemodes/dynamic/dynamic_storytellers.dm @@ -128,7 +128,6 @@ Property weights are added to the config weight of the ruleset. They are: var/list/drafted_rules = list() for (var/datum/dynamic_ruleset/minor/rule in mode.minor_rules) if (rule.acceptable(mode.current_players[CURRENT_LIVING_PLAYERS].len, mode.threat_level)) - rule.candidates = mode.candidates.Copy() rule.trim_candidates() if (rule.ready() && rule.candidates.len > 0) var/property_weight = 0