Skip to content

Commit

Permalink
More dynamic rework: help I wasn't done (#11642)
Browse files Browse the repository at this point in the history
* Starting a replacement of how threat works.

* no, we do it this way

* Added threat levels to jobs

* Added threat to... a lot.

* Updated for traitor classes.

* Fixed errors, except for one.

It's consistently giving me "maximum number of internal arrays exceeded (65535)". I have no idea what could be causing this.

* Added type annotation to GetJob.

* This one I should change though

* wow how'd that happen

* spammable means low threat

* Made story threat have initial threat level on average

* Made somet rulesets force if they won the vote

* )

* Gave EVERY job threat, added a config for it.

* Rebalanced some numbers

* Update code/game/gamemodes/dynamic/dynamic_storytellers.dm

Co-Authored-By: Ghom <[email protected]>

* Removes mush threat

* Makes devil threat scale with form

* reviewing reviewer's review of reviewer

* Gutlunches can be friendly spawned, so no

* Also made forced-friendly mobs not count

* null checks better

* Made antag threats in config, too

* various fixes

* Another couple dynamic fixes

* Made an admin message chunk all one line.

Co-authored-by: Ghom <[email protected]>
  • Loading branch information
Putnam3145 and Ghommie authored Mar 28, 2020
1 parent 44f1b77 commit 8a620b0
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 21 deletions.
6 changes: 3 additions & 3 deletions code/__HELPERS/roundend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@
parts += "[FOURSPACES]<i>Nobody died this shift!</i>"
if(istype(SSticker.mode, /datum/game_mode/dynamic))
var/datum/game_mode/dynamic/mode = SSticker.mode
parts += "[FOURSPACES]Threat level: [mode.threat_level]"
parts += "[FOURSPACES]Threat left: [mode.threat]"
parts += "[FOURSPACES]Final threat level: [mode.threat_level]"
parts += "[FOURSPACES]Final threat: [mode.threat]"
parts += "[FOURSPACES]Executed rules:"
for(var/datum/dynamic_ruleset/rule in mode.executed_rules)
parts += "[FOURSPACES][FOURSPACES][rule.ruletype] - <b>[rule.name]</b>: -[rule.cost + rule.scaled_times * rule.scaling_cost] threat"
Expand All @@ -331,7 +331,7 @@
for(var/entry in mode.threat_tallies)
parts += "[FOURSPACES][FOURSPACES][entry] added [mode.threat_tallies[entry]]"
SSblackbox.record_feedback("tally","dynamic_threat",mode.threat_level,"Final threat level")
SSblackbox.record_feedback("tally","dynamic_threat",mode.threat,"Threat left")
SSblackbox.record_feedback("tally","dynamic_threat",mode.threat,"Final Threat")
return parts.Join("<br>")

/client/proc/roundend_report_file()
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/configuration/entries/game_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM

/datum/config_entry/keyed_list/antag_threat
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM

/datum/config_entry/number/monkeycap
config_entry_value = 64
min_val = 0
Expand Down
11 changes: 6 additions & 5 deletions code/game/gamemodes/dynamic/dynamic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ GLOBAL_VAR_INIT(dynamic_storyteller_type, /datum/dynamic_storyteller/classic)
/datum/game_mode/dynamic/admin_panel()
var/list/dat = list("<html><head><title>Game Mode Panel</title></head><body><h1><B>Game Mode Panel</B></h1>")
dat += "Dynamic Mode <a href='?_src_=vars;[HrefToken()];Vars=[REF(src)]'>\[VV\]</A><a href='?src=\ref[src];[HrefToken()]'>\[Refresh\]</A><BR>"
dat += "Threat Level: <b>[threat_level]</b><br/>"
dat += "Target threat: <b>[threat_level]</b><br/>"

dat += "Threat to Spend: <b>[threat]</b> <a href='?src=\ref[src];[HrefToken()];adjustthreat=1'>\[Adjust\]</A> <a href='?src=\ref[src];[HrefToken()];threatlog=1'>\[View Log\]</a><br/>"
dat += "Current threat: <b>[threat]</b> <a href='?src=\ref[src];[HrefToken()];adjustthreat=1'>\[Adjust\]</A> <a href='?src=\ref[src];[HrefToken()];threatlog=1'>\[View Log\]</a><br/>"
dat += "<br/>"
dat += "Storyteller: <b>[storyteller.name]</b><br/>"
dat += "Parameters: centre = [GLOB.dynamic_curve_centre] ; width = [GLOB.dynamic_curve_width].<br/>"
Expand Down Expand Up @@ -339,9 +339,10 @@ GLOBAL_VAR_INIT(dynamic_storyteller_type, /datum/dynamic_storyteller/classic)
storyteller = new GLOB.dynamic_storyteller_type // this is where all the initialization happens
storyteller.on_start()
SSblackbox.record_feedback("text","dynamic_storyteller",1,storyteller.name)
message_admins("Dynamic mode parameters for the round:")
message_admins("Centre is [GLOB.dynamic_curve_centre], Width is [GLOB.dynamic_curve_width], Forced extended is [GLOB.dynamic_forced_extended ? "Enabled" : "Disabled"], No stacking is [GLOB.dynamic_no_stacking ? "Enabled" : "Disabled"].")
message_admins("Stacking limit is [GLOB.dynamic_stacking_limit], Classic secret is [GLOB.dynamic_classic_secret ? "Enabled" : "Disabled"], High population limit is [GLOB.dynamic_high_pop_limit].")
message_admins("Dynamic mode parameters for the round:\n\
Storyteller is [storyteller.name].\n\
Centre is [GLOB.dynamic_curve_centre], Width is [GLOB.dynamic_curve_width], Forced extended is [GLOB.dynamic_forced_extended ? "Enabled" : "Disabled"], No stacking is [GLOB.dynamic_no_stacking ? "Enabled" : "Disabled"].\n\
Stacking limit is [GLOB.dynamic_stacking_limit], Classic secret is [GLOB.dynamic_classic_secret ? "Enabled" : "Disabled"], High population limit is [GLOB.dynamic_high_pop_limit].")
log_game("DYNAMIC: Dynamic mode parameters for the round:")
log_game("DYNAMIC: Centre is [GLOB.dynamic_curve_centre], Width is [GLOB.dynamic_curve_width], Forced extended is [GLOB.dynamic_forced_extended ? "Enabled" : "Disabled"], No stacking is [GLOB.dynamic_no_stacking ? "Enabled" : "Disabled"].")
log_game("DYNAMIC: Stacking limit is [GLOB.dynamic_stacking_limit], Classic secret is [GLOB.dynamic_classic_secret ? "Enabled" : "Disabled"], High population limit is [GLOB.dynamic_high_pop_limit].")
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
if (M.mind && M.mind.assigned_role && (M.mind.assigned_role in enemy_roles) && (!(M in candidates) || (M.mind.assigned_role in restricted_roles)))
job_check++ // Checking for "enemies" (such as sec officers). To be counters, they must either not be candidates to that rule, or have a job that restricts them from it

var/threat = round(mode.threat_level/10)
var/threat = CLAMP(round(mode.threat_level/10),1,10)
if (job_check < required_enemies[threat])
SSblackbox.record_feedback("tally","dynamic",1,"Times rulesets rejected due to not enough enemy roles")
return FALSE
Expand Down Expand Up @@ -216,7 +216,7 @@
var/player_count = mode.current_players[CURRENT_LIVING_PLAYERS].len
var/antag_count = mode.current_players[CURRENT_LIVING_ANTAGS].len
var/max_traitors = round(player_count / 10) + 1
if ((antag_count < max_traitors) && prob(mode.threat_level))//adding traitors if the antag population is getting low
if ((antag_count < max_traitors) && prob(min(100,mode.threat_level)))//adding traitors if the antag population is getting low
return ..()
else
return FALSE
Expand Down
12 changes: 7 additions & 5 deletions code/game/gamemodes/dynamic/dynamic_storytellers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ Property weights are:
if(H.stat != DEAD && is_station_level(T.z) && !("Station" in H.faction))
threat += H.threat()
for (var/mob/M in mode.current_players[CURRENT_LIVING_PLAYERS])
if (M.stat != DEAD && M.mind && M.mind.assigned_role)
if(length(M.mind.antag_datums))
threat += SSjob.GetJob(M.mind.assigned_role).GetThreat()
else
threat -= SSjob.GetJob(M.mind.assigned_role).GetThreat()
if (M?.mind?.assigned_role && M.stat != DEAD)
var/datum/job/J = SSjob.GetJob(M.mind.assigned_role)
if(J)
if(length(M.mind.antag_datums))
threat += J.GetThreat()
else
threat -= J.GetThreat()
threat += (mode.current_players[CURRENT_DEAD_PLAYERS].len)*dead_player_weight
return round(threat,0.1)

Expand Down
3 changes: 3 additions & 0 deletions code/modules/antagonists/_common/antag_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ GLOBAL_LIST_EMPTY(antagonists)

/// Gets our threat level. Defaults to threat var, override for custom stuff like different traitor goals having different threats.
/datum/antagonist/proc/threat()
. = CONFIG_GET(keyed_list/antag_threat)[lowertext(name)]
if(. == null)
return threat
return threat

//This one is created by admin tools for custom objectives
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/bloodsucker/datum_bloodsucker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
owner.current.blood_volume = max(owner.current.blood_volume,BLOOD_VOLUME_SAFE)

/datum/antagonist/bloodsucker/threat()
return threat+3*vamplevel
return ..()+3*vamplevel


/datum/antagonist/bloodsucker/proc/SelectFirstName()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/bloodsucker/datum_hunter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
threat = -3
/datum/antagonist/vamphunter/threat()
return bad_dude ? -threat : threat
return bad_dude ? -(..()) : ..()
/datum/antagonist/vamphunter/on_gain()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/devil/devil.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ GLOBAL_LIST_INIT(devil_suffix, list(" the Red", " the Soulless", " the Master",
var/ascendable = FALSE

/datum/antagonist/devil/threat()
return threat + form * 10
return ..() + form * 10

/datum/antagonist/devil/can_be_owned(datum/mind/new_owner)
. = ..()
Expand Down
3 changes: 2 additions & 1 deletion code/modules/antagonists/ninja/ninja.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
job_rank = ROLE_NINJA
show_name_in_check_antagonists = TRUE
antag_moodlet = /datum/mood_event/focused
threat = 8
var/helping_station = FALSE
var/give_objectives = TRUE
var/give_equipment = TRUE

/datum/antagonist/ninja/threat()
return helping_station ? -8 : 8
return helping_station ? -(..()) : ..()

/datum/antagonist/ninja/apply_innate_effects(mob/living/mob_override)
var/mob/living/M = mob_override || owner.current
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/traitor/datum_traitor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,4 @@
return SSticker.mode.name == "traitor"

/datum/antagonist/traitor/threat()
return threat+traitor_kind.threat
return (..())+traitor_kind.threat
6 changes: 5 additions & 1 deletion config/job_threats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
## List of job titles followed by dynamic threat value, all prefixed with JOB_THREAT. See code/modules/jobs/job_types for titles
## e.g.
## JOB_THREAT Captain 5
## JOB_THREAT Assistant 0.2
## JOB_THREAT Assistant 0.2

## Custom antag threat values, see above
## e.g.
## ANTAG_THREAT Traitor 5

0 comments on commit 8a620b0

Please sign in to comment.