Merge remote-tracking branch 'upstream/master' into familyport

This commit is contained in:
keronshb
2021-10-28 14:41:46 -04:00
387 changed files with 1908 additions and 1658 deletions
+51 -19
View File
@@ -1,13 +1,16 @@
#define RULESET_STOP_PROCESSING 1
#define FAKE_REPORT_CHANCE 8
#define FAKE_REPORT_CHANCE 20
#define REPORT_NEG_DIVERGENCE -15
#define REPORT_POS_DIVERGENCE 15
#define EXTENDED_CURVE_CENTER -7
// Are HIGH_IMPACT_RULESETs allowed to stack?
GLOBAL_VAR_INIT(dynamic_no_stacking, TRUE)
// If enabled does not accept or execute any rulesets.
GLOBAL_VAR_INIT(dynamic_forced_extended, FALSE)
// Antags still allowed, but no roundstart antags + midrounds are low impact
GLOBAL_VAR_INIT(dynamic_extended, FALSE)
// How high threat is required for HIGH_IMPACT_RULESETs stacking.
// This is independent of dynamic_no_stacking.
GLOBAL_VAR_INIT(dynamic_stacking_limit, 90)
@@ -163,6 +166,7 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
dat += "Split parameters: centre = [roundstart_split_curve_centre] ; width = [roundstart_split_curve_width].<br/>"
dat += "<i>On average, <b>[peaceful_percentage]</b>% of the rounds are more peaceful.</i><br/>"
dat += "Forced extended: <a href='?src=\ref[src];[HrefToken()];forced_extended=1'><b>[GLOB.dynamic_forced_extended ? "On" : "Off"]</b></a><br/>"
dat += "Dynamic extended: <a href='?src=\ref[src];[HrefToken()];extended=1'><b>[GLOB.dynamic_extended ? "On" : "Off"]</b></a><br/>"
dat += "No stacking (only one round-ender): <a href='?src=\ref[src];[HrefToken()];no_stacking=1'><b>[GLOB.dynamic_no_stacking ? "On" : "Off"]</b></a><br/>"
dat += "Stacking limit: [GLOB.dynamic_stacking_limit] <a href='?src=\ref[src];[HrefToken()];stacking_limit=1'>\[Adjust\]</A>"
dat += "<br/>"
@@ -192,10 +196,12 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
return
if (href_list["forced_extended"])
GLOB.dynamic_forced_extended = !GLOB.dynamic_forced_extended
else if (href_list["extended"])
GLOB.dynamic_extended = !GLOB.dynamic_extended
else if (href_list["no_stacking"])
GLOB.dynamic_no_stacking = !GLOB.dynamic_no_stacking
else if (href_list["adjustthreat"])
var/threatadd = input("Specify how much threat to add (negative to subtract). This can inflate the threat level.", "Adjust Threat", 0) as null|num
var/threatadd = tgui_input_num(usr, "Specify how much threat to add (negative to subtract). This can inflate the threat level.", "Adjust Threat", 0)
if(!threatadd)
return
if(threatadd > 0)
@@ -215,9 +221,9 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
else if (href_list["threatlog"])
show_threatlog(usr)
else if (href_list["stacking_limit"])
GLOB.dynamic_stacking_limit = input(usr,"Change the threat limit at which round-endings rulesets will start to stack.", "Change stacking limit", null) as num
GLOB.dynamic_stacking_limit = tgui_input_num(usr,"Change the threat limit at which round-endings rulesets will start to stack.", "Change stacking limit", null)
else if(href_list["force_latejoin_rule"])
var/added_rule = input(usr,"What ruleset do you want to force upon the next latejoiner? This will bypass threat level and population restrictions.", "Rigging Latejoin", null) as null|anything in sortNames(init_rulesets(/datum/dynamic_ruleset/latejoin))
var/added_rule = tgui_input_list(usr,"What ruleset do you want to force upon the next latejoiner? This will bypass threat level and population restrictions.", "Rigging Latejoin", sortNames(init_rulesets(/datum/dynamic_ruleset/latejoin)))
if (!added_rule)
return
forced_latejoin_rule = added_rule
@@ -228,7 +234,7 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
log_admin("[key_name(usr)] cleared the forced latejoin ruleset.")
message_admins("[key_name(usr)] cleared the forced latejoin ruleset.")
else if(href_list["force_midround_rule"])
var/added_rule = input(usr,"What ruleset do you want to force right now? This will bypass threat level and population restrictions.", "Execute Ruleset", null) as null|anything in sortNames(init_rulesets(/datum/dynamic_ruleset/midround))
var/added_rule = tgui_input_list(usr,"What ruleset do you want to force right now? This will bypass threat level and population restrictions.", "Execute Ruleset", sortNames(init_rulesets(/datum/dynamic_ruleset/midround)))
if (!added_rule)
return
log_admin("[key_name(usr)] executed the [added_rule] ruleset.")
@@ -309,9 +315,10 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
/// Generates the threat level using lorentz distribution and assigns peaceful_percentage.
/datum/game_mode/dynamic/proc/generate_threat()
if(GLOB.dynamic_extended)
threat_curve_centre = EXTENDED_CURVE_CENTER
var/relative_threat = LORENTZ_DISTRIBUTION(threat_curve_centre, threat_curve_width)
threat_level = round(lorentz_to_amount(relative_threat), 0.1)
peaceful_percentage = round(LORENTZ_CUMULATIVE_DISTRIBUTION(relative_threat, threat_curve_centre, threat_curve_width), 0.01)*100
SSblackbox.record_feedback("tally","dynamic_threat",threat_level,"Initial threat level")
@@ -321,14 +328,18 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
/// Generates the midround and roundstart budgets
/datum/game_mode/dynamic/proc/generate_budgets()
var/relative_round_start_budget_scale = LORENTZ_DISTRIBUTION(roundstart_split_curve_centre, roundstart_split_curve_width)
round_start_budget = round((lorentz_to_amount(relative_round_start_budget_scale) / 100) * threat_level, 0.1)
initial_round_start_budget = round_start_budget
mid_round_budget = threat_level - round_start_budget
if(GLOB.dynamic_extended)
mid_round_budget = threat_level
round_start_budget = 0
else
var/relative_round_start_budget_scale = LORENTZ_DISTRIBUTION(roundstart_split_curve_centre, roundstart_split_curve_width)
round_start_budget = round((lorentz_to_amount(relative_round_start_budget_scale) / 100) * threat_level, 0.1)
initial_round_start_budget = round_start_budget
mid_round_budget = threat_level - round_start_budget
/datum/game_mode/dynamic/proc/setup_parameters()
log_game("DYNAMIC: Dynamic mode parameters for the round:")
log_game("DYNAMIC: Centre is [threat_curve_centre], Width is [threat_curve_width], Forced extended is [GLOB.dynamic_forced_extended ? "Enabled" : "Disabled"], No stacking is [GLOB.dynamic_no_stacking ? "Enabled" : "Disabled"].")
log_game("DYNAMIC: Centre is [threat_curve_centre], Width is [threat_curve_width], Extended is [GLOB.dynamic_extended ? "Enabled" : "Disabled"], No stacking is [GLOB.dynamic_no_stacking ? "Enabled" : "Disabled"].")
log_game("DYNAMIC: Stacking limit is [GLOB.dynamic_stacking_limit].")
if(GLOB.dynamic_forced_threat_level >= 0)
threat_level = round(GLOB.dynamic_forced_threat_level, 0.1)
@@ -346,9 +357,15 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
shown_threat = clamp(threat_level + rand(REPORT_NEG_DIVERGENCE, REPORT_POS_DIVERGENCE), 0, 100)
/datum/game_mode/dynamic/proc/set_cooldowns()
var/coeff = GLOB.dynamic_extended ? 2 : 1
latejoin_delay_min *= coeff
latejoin_delay_max *= coeff
var/latejoin_injection_cooldown_middle = 0.5*(latejoin_delay_max + latejoin_delay_min)
latejoin_injection_cooldown = round(clamp(EXP_DISTRIBUTION(latejoin_injection_cooldown_middle), latejoin_delay_min, latejoin_delay_max)) + world.time
midround_delay_min *= coeff
midround_delay_max *= coeff
var/midround_injection_cooldown_middle = 0.5*(midround_delay_max + midround_delay_min)
midround_injection_cooldown = round(clamp(EXP_DISTRIBUTION(midround_injection_cooldown_middle), midround_delay_min, midround_delay_max)) + world.time
@@ -456,6 +473,9 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
if (GLOB.dynamic_forced_extended)
log_game("DYNAMIC: Starting a round of forced extended.")
return TRUE
if (GLOB.dynamic_extended)
log_game("DYNAMIC: Starting a round of dynamic extended.")
return TRUE
var/list/drafted_rules = list()
for (var/datum/dynamic_ruleset/roundstart/rule in roundstart_rules)
if (!rule.weight)
@@ -563,9 +583,10 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
return FALSE
// Check if the ruleset is high impact and if a high impact ruleset has been executed
else if(new_rule.flags & HIGH_IMPACT_RULESET)
if(threat_level < GLOB.dynamic_stacking_limit && GLOB.dynamic_no_stacking)
if(high_impact_ruleset_executed)
return FALSE
if(GLOB.dynamic_extended)
return FALSE
if(high_impact_ruleset_executed && threat_level < GLOB.dynamic_stacking_limit && GLOB.dynamic_no_stacking)
return FALSE
var/population = current_players[CURRENT_LIVING_PLAYERS].len
if((new_rule.acceptable(population, threat_level) && new_rule.cost <= mid_round_budget) || forced)
@@ -598,8 +619,8 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
/datum/game_mode/dynamic/proc/midround_rule_draft()
set waitfor = FALSE
if (midround_injection_cooldown < world.time)
/*if (GLOB.dynamic_forced_extended)
return*/
if (GLOB.dynamic_forced_extended)
return
// Somehow it managed to trigger midround multiple times so this was moved here.
// There is no way this should be able to trigger an injection twice now.
@@ -620,6 +641,11 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
for (var/datum/dynamic_ruleset/midround/rule in midround_rules)
if (!rule.weight)
continue
if(rule.flags & HIGH_IMPACT_RULESET)
if (high_impact_ruleset_executed && threat_level < GLOB.dynamic_stacking_limit && GLOB.dynamic_no_stacking)
continue
if(GLOB.dynamic_extended)
continue
if (rule.acceptable(current_players[CURRENT_LIVING_PLAYERS].len, threat_level) && mid_round_budget >= rule.cost)
rule.trim_candidates()
if (rule.ready())
@@ -642,11 +668,17 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
forced_injection = dry_run
return 100
var/chance = 0
var/max_pop_per_antag = max(5,15 - round(threat_level/10) - round(current_players[CURRENT_LIVING_PLAYERS].len/5))
var/effective_living_players = current_players[CURRENT_LIVING_PLAYERS].len
if(GLOB.dynamic_extended)
effective_living_players = min(effective_living_players, length(SSjob.get_living_sec())*2 + length(SSjob.get_living_heads()))
var/max_pop_per_antag = max(5,15 - round(threat_level/10) - round(effective_living_players/5))
if (!current_players[CURRENT_LIVING_ANTAGS].len)
chance += 50 // No antags at all? let's boost those odds!
if(GLOB.dynamic_extended)
chance += min(50,effective_living_players*5)
else
chance += 50 // No antags at all? let's boost those odds!
else
var/current_pop_per_antag = current_players[CURRENT_LIVING_PLAYERS].len / current_players[CURRENT_LIVING_ANTAGS].len
var/current_pop_per_antag = effective_living_players / current_players[CURRENT_LIVING_ANTAGS].len
if (current_pop_per_antag > max_pop_per_antag)
chance += min(50, 25+10*(current_pop_per_antag-max_pop_per_antag))
else
@@ -72,9 +72,9 @@
set name = "Run Dynamic Simulations"
set category = "Debug"
var/simulations = input(usr, "Enter number of simulations") as num
var/roundstart_players = input(usr, "Enter number of round start players") as num
var/forced_threat_level = input(usr, "Enter forced threat level, if you want one") as num | null
var/simulations = tgui_input_num(usr, "Enter number of simulations")
var/roundstart_players = tgui_input_num(usr, "Enter number of round start players")
var/forced_threat_level = tgui_input_num(usr, "Enter forced threat level, if you want one")
SSticker.mode = new /datum/game_mode/dynamic
message_admins("Running dynamic simulations...")
+7 -12
View File
@@ -40,16 +40,11 @@ GLOBAL_LIST_EMPTY(objectives)
//Shared by few objective types
/datum/objective/proc/admin_simple_target_pick(mob/admin)
var/list/possible_targets = list("Free objective")
var/def_value
for(var/datum/mind/possible_target in SSticker.minds)
if ((possible_target != src) && ishuman(possible_target.current))
possible_targets += possible_target.current
if(target && target.current)
def_value = target.current
var/mob/new_target = input(admin,"Select target:", "Objective target", def_value) as null|anything in possible_targets
var/mob/new_target = tgui_input_list(admin,"Select target:", "Objective target", possible_targets)
if (!new_target)
return
@@ -606,12 +601,12 @@ GLOBAL_LIST_EMPTY(possible_items)
/datum/objective/steal/admin_edit(mob/admin)
var/list/possible_items_all = GLOB.possible_items+"custom"
var/new_target = input(admin,"Select target:", "Objective target", steal_target) as null|anything in possible_items_all
var/new_target = tgui_input_list(admin,"Select target:", "Objective target", possible_items_all)
if (!new_target)
return
if (new_target == "custom") //Can set custom items.
var/custom_path = input(admin,"Search for target item type:","Type") as null|text
var/custom_path = tgui_input_text(admin,"Search for target item type:","Type")
if (!custom_path)
return
var/obj/item/custom_target = pick_closest_path(custom_path, make_types_fancy(subtypesof(/obj/item)))
@@ -728,7 +723,7 @@ GLOBAL_LIST_EMPTY(possible_items_special)
return checking.researched_nodes.len >= target_amount
/datum/objective/download/admin_edit(mob/admin)
var/count = input(admin,"How many nodes ?","Nodes",target_amount) as num|null
var/count = tgui_input_num(admin,"How many nodes ?","Nodes",target_amount)
if(count)
target_amount = count
update_explanation_text()
@@ -774,7 +769,7 @@ GLOBAL_LIST_EMPTY(possible_items_special)
return captured_amount >= target_amount
/datum/objective/capture/admin_edit(mob/admin)
var/count = input(admin,"How many mobs to capture ?","capture",target_amount) as num|null
var/count = tgui_input_num(admin,"How many mobs to capture ?","capture",target_amount)
if(count)
target_amount = count
update_explanation_text()
@@ -806,7 +801,7 @@ GLOBAL_LIST_EMPTY(possible_items_special)
explanation_text = "Extract [target_amount] compatible genome\s."
/datum/objective/absorb/admin_edit(mob/admin)
var/count = input(admin,"How many people to absorb?","absorb",target_amount) as num|null
var/count = tgui_input_num(admin,"How many people to absorb?","absorb",target_amount)
if(count)
target_amount = count
update_explanation_text()
@@ -896,7 +891,7 @@ GLOBAL_LIST_EMPTY(possible_items_special)
/datum/objective/destroy/admin_edit(mob/admin)
var/list/possible_targets = active_ais(1)
if(possible_targets.len)
var/mob/new_target = input(admin,"Select target:", "Objective target") as null|anything in possible_targets
var/mob/new_target = tgui_input_list(admin,"Select target:", "Objective target", possible_targets)
target = new_target.mind
else
to_chat(admin, "No active AIs with minds")