Merge pull request #13785 from Putnam3145/fix-grab-bag

Makes grab bag ONLY make station antags; triples alien dynamic threat.
This commit is contained in:
silicons
2020-12-20 15:42:04 -07:00
committed by GitHub
12 changed files with 119 additions and 38 deletions
+8 -2
View File
@@ -64,6 +64,8 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null)
var/threat_average_weight = 0
/// Last time a threat average sample was taken. Used for weighting the rolling average.
var/last_threat_sample_time = 0
/// Maximum threat recorded so far, for cross-round chaos adjustment.
var/max_threat = 0
/// Things that cause a rolling threat adjustment to be displayed at roundend.
var/list/threat_tallies = list()
/// Running information about the threat. Can store text or datum entries.
@@ -145,6 +147,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null)
third_rule_req = list(101, 101, 101, 101, 101, 100, 90, 80, 70, 60)
high_pop_second_rule_req = CONFIG_GET(number/dynamic_second_rule_high_pop_requirement)
high_pop_third_rule_req = CONFIG_GET(number/dynamic_third_rule_high_pop_requirement)
added_threat = CONFIG_GET(number/dynamic_threat_baseline)
GLOB.dynamic_high_pop_limit = CONFIG_GET(number/dynamic_high_pop_limit)
GLOB.dynamic_latejoin_delay_min = CONFIG_GET(number/dynamic_latejoin_delay_min)*600
GLOB.dynamic_latejoin_delay_max = CONFIG_GET(number/dynamic_latejoin_delay_max)*600
@@ -415,7 +418,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)
@@ -439,7 +442,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null)
potential_minor_rulesets -= rule
update_playercounts()
iterations++
message_admins("Minor antag roundstart rolls completed, with [num_rulesets_executed] antags or antag teams made.")
message_admins("Minor antag roundstart rolls completed, with [iterations] rolls done and [num_rulesets_executed] antags or antag teams made.")
log_game("DYNAMIC: Minor antag roundstart made [num_rulesets_executed] antags or antag teams.")
@@ -612,6 +615,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null)
latejoin_rules = remove_from_list(latejoin_rules, rule.type)
else if(rule.ruletype == "Midround")
midround_rules = remove_from_list(midround_rules, rule.type)
message_admins("DYNAMIC: Picked [rule]; executing soon...")
addtimer(CALLBACK(src, /datum/game_mode/dynamic/.proc/execute_midround_latejoin_rule, rule), rule.delay)
return TRUE
@@ -663,6 +667,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null)
/datum/game_mode/dynamic/proc/execute_midround_latejoin_rule(sent_rule)
var/datum/dynamic_ruleset/rule = sent_rule
if (rule.execute())
message_admins("DYNAMIC: Injected a [rule.ruletype == "latejoin" ? "latejoin" : "midround"] ruleset [rule.name].")
log_game("DYNAMIC: Injected a [rule.ruletype == "latejoin" ? "latejoin" : "midround"] ruleset [rule.name].")
log_threat("[rule.ruletype] [rule.name] added [rule.cost]", verbose = TRUE)
if(rule.flags & HIGHLANDER_RULESET)
@@ -741,6 +746,7 @@ GLOBAL_VAR_INIT(dynamic_forced_storyteller, null)
if(!M.voluntary_ghosted)
current_players[CURRENT_DEAD_PLAYERS].Add(M) // Players who actually died (and admins who ghosted, would be nice to avoid counting them somehow)
threat = storyteller.calculate_threat() + added_threat
max_threat = max(max_threat,threat)
if(threat_average_weight)
var/cur_sample_weight = world.time - last_threat_sample_time
threat_average = ((threat_average * threat_average_weight) + (threat * cur_sample_weight)) / (threat_average_weight + cur_sample_weight)
@@ -48,6 +48,9 @@
if (!M.client) // Are they connected?
trimmed_list.Remove(M)
continue
if(M.client.prefs && M.client.prefs.toggles & MIDROUND_ANTAG)
trimmed_list.Remove(M)
continue
if(!mode.check_age(M.client, minimum_required_age))
trimmed_list.Remove(M)
continue
@@ -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])
//////////////////////////////////////////////
// //
@@ -8,7 +8,6 @@
/datum/dynamic_ruleset/roundstart/traitor
name = "Traitors"
config_tag = "traitor"
persistent = TRUE
antag_flag = ROLE_TRAITOR
antag_datum = /datum/antagonist/traitor/
minimum_required_age = 0
@@ -34,15 +33,6 @@
M.mind.restricted_roles = restricted_roles
return TRUE
/datum/dynamic_ruleset/roundstart/traitor/rule_process()
if (autotraitor_cooldown > 0)
autotraitor_cooldown--
else
autotraitor_cooldown = 450 // 15 minutes
message_admins("Checking if we can turn someone into a traitor.")
log_game("DYNAMIC: Checking if we can turn someone into a traitor.")
mode.picking_specific_rule(/datum/dynamic_ruleset/midround/autotraitor)
//////////////////////////////////////////
// //
// BLOOD BROTHERS //
@@ -15,10 +15,13 @@
*/
var/flags = 0
var/dead_player_weight = 1 // How much dead players matter for threat calculation
var/weight = 3 // Weights for randomly picking storyteller. Multiplied by score after voting.
var/weight = 0 // Weights for randomly picking storyteller. Multiplied by score after voting.
var/min_chaos = -1000 // Won't show up if recent rounds have been below this chaotic on average
var/max_chaos = 1000 // Won't show up if recent rounds have been above this chaotic on average
var/event_frequency_lower = 6 MINUTES // How rare events will be, at least.
var/event_frequency_upper = 20 MINUTES // How rare events will be, at most.
var/min_players = -1 // How many players are required for this one to start.
var/soft_antag_ratio_cap = 4 // how many players-per-antag there should be
var/datum/game_mode/dynamic/mode = null // Cached as soon as it's made, by dynamic.
/**
@@ -101,8 +104,10 @@ Property weights are added to the config weight of the ruleset. They are:
/datum/dynamic_storyteller/proc/should_inject_antag(dry_run = FALSE)
if(mode.forced_injection)
mode.forced_injection = !dry_run
mode.forced_injection = dry_run
return TRUE
if(mode.current_players[CURRENT_LIVING_PLAYERS].len < (mode.current_players[CURRENT_LIVING_ANTAGS].len * soft_antag_ratio_cap))
return FALSE
return mode.threat < mode.threat_level
/datum/dynamic_storyteller/proc/roundstart_draft()
@@ -126,11 +131,10 @@ Property weights are added to the config weight of the ruleset. They are:
/datum/dynamic_storyteller/proc/minor_rule_draft()
var/list/drafted_rules = list()
for (var/datum/dynamic_ruleset/minor/rule in mode.minor_rules)
for (var/datum/dynamic_ruleset/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)
if (rule.ready())
var/property_weight = 0
for(var/property in property_weights)
if(property in rule.property_weights) // just treat it as 0 if it's not in there
@@ -213,6 +217,8 @@ Property weights are added to the config weight of the ruleset. They are:
weight = 1
event_frequency_lower = 2 MINUTES
event_frequency_upper = 10 MINUTES
max_chaos = 50
soft_antag_ratio_cap = 1
flags = WAROPS_ALWAYS_ALLOWED | FORCE_IF_WON
min_players = 30
var/refund_cooldown = 0
@@ -235,12 +241,13 @@ Property weights are added to the config weight of the ruleset. They are:
desc = "Modes where the crew must band together. Nukies, xenos, blob. Only one antag threat at once."
curve_centre = 2
curve_width = 1.5
weight = 2
weight = 4
max_chaos = 75
min_players = 20
flags = WAROPS_ALWAYS_ALLOWED | USE_PREV_ROUND_WEIGHTS
property_weights = list("valid" = 3, "trust" = 5)
/datum/dynamic_storyteller/chaotic/minor_start_chance()
/datum/dynamic_storyteller/team/minor_start_chance()
return 0
/datum/dynamic_storyteller/team/should_inject_antag(dry_run = FALSE)
@@ -256,13 +263,15 @@ Property weights are added to the config weight of the ruleset. They are:
flags = WAROPS_ALWAYS_ALLOWED
property_weights = list("valid" = 1, "conversion" = 20)
/datum/dynamic_storyteller/chaotic/minor_start_chance()
/datum/dynamic_storyteller/conversion/minor_start_chance()
return 0
/datum/dynamic_storyteller/random
name = "Random"
config_tag = "random"
weight = 1
max_chaos = 60
soft_antag_ratio_cap = 1
desc = "No weighting at all; every ruleset has the same chance of happening. Cooldowns vary wildly. As random as it gets."
/datum/dynamic_storyteller/random/on_start()
@@ -275,7 +284,7 @@ Property weights are added to the config weight of the ruleset. They are:
/datum/dynamic_storyteller/random/should_inject_antag()
return prob(50)
/datum/dynamic_storyteller/chaotic/minor_start_chance()
/datum/dynamic_storyteller/random/minor_start_chance()
return 20
/datum/dynamic_storyteller/random/roundstart_draft()
@@ -331,7 +340,7 @@ Property weights are added to the config weight of the ruleset. They are:
name = "Story"
config_tag = "story"
desc = "Antags with options for loadouts and gimmicks. Traitor, wizard, nukies."
weight = 2
weight = 4
curve_width = 2
flags = USE_PREV_ROUND_WEIGHTS
property_weights = list("story_potential" = 2)
@@ -339,6 +348,7 @@ Property weights are added to the config weight of the ruleset. They are:
/datum/dynamic_storyteller/classic
name = "Classic"
config_tag = "classic"
weight = 8
desc = "No special antagonist weights. Good variety, but not like random. Uses your chaos preference to weight."
flags = USE_PREF_WEIGHTS | USE_PREV_ROUND_WEIGHTS
@@ -346,7 +356,7 @@ Property weights are added to the config weight of the ruleset. They are:
name = "Intrigue"
config_tag = "intrigue"
desc = "Antags that instill distrust in the crew. Traitors, bloodsuckers."
weight = 2
weight = 4
curve_width = 2
dead_player_weight = 2
flags = USE_PREV_ROUND_WEIGHTS
@@ -358,8 +368,8 @@ Property weights are added to the config weight of the ruleset. They are:
/datum/dynamic_storyteller/grabbag
name = "Grab Bag"
config_tag = "grabbag"
desc = "Crew antags (e.g. traitor, changeling, bloodsucker, heretic) only, all mixed together."
weight = 2
desc = "Crew antags (e.g. traitor, changeling, bloodsucker, heretic) only at round start, all mixed together."
weight = 4
flags = USE_PREF_WEIGHTS | USE_PREV_ROUND_WEIGHTS
/datum/dynamic_storyteller/grabbag/minor_start_chance()
@@ -372,12 +382,14 @@ Property weights are added to the config weight of the ruleset. They are:
curve_centre = -3
curve_width = 0.5
flags = NO_ASSASSIN
weight = 1
min_chaos = 30
weight = 3
dead_player_weight = 5
soft_antag_ratio_cap = 8
property_weights = list("extended" = 2, "chaos" = -1, "valid" = -1, "conversion" = -10)
/datum/dynamic_storyteller/liteextended/minor_start_chance()
return 100
return 90
/datum/dynamic_storyteller/no_antag
name = "Extended"
@@ -385,6 +397,7 @@ Property weights are added to the config weight of the ruleset. They are:
desc = "No standard antags."
curve_centre = -5
curve_width = 0.5
min_chaos = 40
flags = NO_ASSASSIN | FORCE_IF_WON
weight = 1
property_weights = list("extended" = 2)