From c824818ec705acdb1ff251030cf6843ae2d0bea8 Mon Sep 17 00:00:00 2001 From: Putnam Date: Wed, 9 Sep 2020 20:49:26 -0700 Subject: [PATCH] Makes antag injection less probabilistic. --- code/game/gamemodes/dynamic/dynamic.dm | 10 +++--- .../gamemodes/dynamic/dynamic_storytellers.dm | 34 ++++++------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/code/game/gamemodes/dynamic/dynamic.dm b/code/game/gamemodes/dynamic/dynamic.dm index eac7347479..fbc433a8a0 100644 --- a/code/game/gamemodes/dynamic/dynamic.dm +++ b/code/game/gamemodes/dynamic/dynamic.dm @@ -173,7 +173,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null) dat += "[DR.ruletype] - [DR.name]
" else dat += "none.
" - dat += "
Injection Timers: ([storyteller.get_injection_chance(TRUE)]% chance)
" + dat += "
Injection Timers:
" dat += "Latejoin: [(latejoin_injection_cooldown-world.time)>60*10 ? "[round((latejoin_injection_cooldown-world.time)/60/10,0.1)] minutes" : "[(latejoin_injection_cooldown-world.time)/10] seconds"] \[Now!\]
" dat += "Midround: [(midround_injection_cooldown-world.time)>60*10 ? "[round((midround_injection_cooldown-world.time)/60/10,0.1)] minutes" : "[(midround_injection_cooldown-world.time)/10] seconds"] \[Now!\]
" usr << browse(dat.Join(), "window=gamemode_panel;size=500x500") @@ -513,7 +513,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null) drafted_rules -= starting_rule starting_rule.trim_candidates() - starting_rule.scale_up(extra_rulesets_amount, threat_level) + starting_rule.scale_up(extra_rulesets_amount, threat_level-added_threat) if (starting_rule.pre_execute()) log_threat("[starting_rule.ruletype] - [starting_rule.name] [starting_rule.cost + starting_rule.scaled_times * starting_rule.scaling_cost] threat", verbose = TRUE) if(starting_rule.flags & HIGHLANDER_RULESET) @@ -675,13 +675,12 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null) log_game("DYNAMIC: Checking for midround injection.") update_playercounts() - if (prob(storyteller.get_injection_chance())) + if (storyteller.should_inject_antag()) SSblackbox.record_feedback("tally","dynamic",1,"Attempted midround injections") var/list/drafted_rules = storyteller.midround_draft() if (drafted_rules.len > 0) SSblackbox.record_feedback("tally","dynamic",1,"Successful midround injections") picking_midround_latejoin_rule(drafted_rules) - // get_injection_chance can do things on fail /// Updates current_players. /datum/game_mode/dynamic/proc/update_playercounts() @@ -757,12 +756,11 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null) picking_midround_latejoin_rule(list(forced_latejoin_rule), forced = TRUE) forced_latejoin_rule = null - else if (latejoin_injection_cooldown < world.time && prob(storyteller.get_injection_chance())) + else if (storyteller.should_inject_antag()) SSblackbox.record_feedback("tally","dynamic",1,"Attempted latejoin injections") var/list/drafted_rules = storyteller.latejoin_draft(newPlayer) if (drafted_rules.len > 0 && picking_midround_latejoin_rule(drafted_rules)) SSblackbox.record_feedback("tally","dynamic",1,"Successful latejoin injections") - latejoin_injection_cooldown = storyteller.get_latejoin_cooldown() + world.time /// Increase the threat level. /datum/game_mode/dynamic/proc/create_threat(gain) diff --git a/code/game/gamemodes/dynamic/dynamic_storytellers.dm b/code/game/gamemodes/dynamic/dynamic_storytellers.dm index ed6cb0ba88..04e295356a 100644 --- a/code/game/gamemodes/dynamic/dynamic_storytellers.dm +++ b/code/game/gamemodes/dynamic/dynamic_storytellers.dm @@ -96,17 +96,11 @@ Property weights are added to the config weight of the ruleset. They are: var/midround_injection_cooldown_middle = 0.5*(GLOB.dynamic_midround_delay_max + GLOB.dynamic_midround_delay_min) return round(clamp(EXP_DISTRIBUTION(midround_injection_cooldown_middle), GLOB.dynamic_midround_delay_min, GLOB.dynamic_midround_delay_max)) -/datum/dynamic_storyteller/proc/get_latejoin_cooldown() - var/latejoin_injection_cooldown_middle = 0.5*(GLOB.dynamic_latejoin_delay_max + GLOB.dynamic_latejoin_delay_min) - return round(clamp(EXP_DISTRIBUTION(latejoin_injection_cooldown_middle), GLOB.dynamic_latejoin_delay_min, GLOB.dynamic_latejoin_delay_max)) - -/datum/dynamic_storyteller/proc/get_injection_chance(dry_run = FALSE) +/datum/dynamic_storyteller/proc/should_inject_antag(dry_run = FALSE) if(mode.forced_injection) mode.forced_injection = !dry_run - return 100 - var/threat_perc = mode.threat/mode.threat_level - - return clamp(round(100*(1-(threat_perc*threat_perc))**2,1),0,100) + return TRUE + return mode.threat < mode.threat_level /datum/dynamic_storyteller/proc/roundstart_draft() var/list/drafted_rules = list() @@ -210,9 +204,6 @@ Property weights are added to the config weight of the ruleset. They are: /datum/dynamic_storyteller/chaotic/get_midround_cooldown() return ..() / 4 -/datum/dynamic_storyteller/chaotic/get_latejoin_cooldown() - return ..() / 4 - /datum/dynamic_storyteller/team name = "Teamwork" config_tag = "teamwork" @@ -224,8 +215,8 @@ Property weights are added to the config weight of the ruleset. They are: flags = WAROPS_ALWAYS_ALLOWED | USE_PREV_ROUND_WEIGHTS property_weights = list("valid" = 3, "trust" = 5) -/datum/dynamic_storyteller/team/get_injection_chance(dry_run = FALSE) - return (mode.current_players[CURRENT_LIVING_ANTAGS].len ? 0 : ..()) +/datum/dynamic_storyteller/team/should_inject_antag(dry_run = FALSE) + return (mode.current_players[CURRENT_LIVING_ANTAGS].len ? FALSE : ..()) /datum/dynamic_storyteller/conversion name = "Conversion" @@ -250,11 +241,8 @@ Property weights are added to the config weight of the ruleset. They are: /datum/dynamic_storyteller/random/get_midround_cooldown() return rand(GLOB.dynamic_midround_delay_min/2, GLOB.dynamic_midround_delay_max*2) -/datum/dynamic_storyteller/random/get_latejoin_cooldown() - return rand(GLOB.dynamic_latejoin_delay_min/2, GLOB.dynamic_latejoin_delay_max*2) - -/datum/dynamic_storyteller/random/get_injection_chance() - return 50 // i would do rand(0,100) but it's actually the same thing when you do the math +/datum/dynamic_storyteller/random/should_inject_antag() + return prob(50) /datum/dynamic_storyteller/random/roundstart_draft() var/list/drafted_rules = list() @@ -318,7 +306,7 @@ Property weights are added to the config weight of the ruleset. They are: curve_width = 2 dead_player_weight = 2 flags = USE_PREV_ROUND_WEIGHTS - property_weights = list("trust" = -3) + property_weights = list("trust" = -2) /datum/dynamic_storyteller/liteextended name = "Calm" @@ -326,7 +314,7 @@ Property weights are added to the config weight of the ruleset. They are: desc = "Low-chaos round. Few antags. No conversion." curve_centre = -3 curve_width = 0.5 - flags = NO_ASSASSIN | FORCE_IF_WON + flags = NO_ASSASSIN weight = 1 dead_player_weight = 5 property_weights = list("extended" = 2, "chaos" = -1, "valid" = -1, "conversion" = -10) @@ -344,5 +332,5 @@ Property weights are added to the config weight of the ruleset. They are: /datum/dynamic_storyteller/no_antag/roundstart_draft() return list() -/datum/dynamic_storyteller/no_antag/get_injection_chance(dry_run) - return 0 +/datum/dynamic_storyteller/no_antag/should_inject_antag(dry_run) + return FALSE