Files
Bubberstation/code/modules/research/server.dm
MrMelbert 4c277dc572 Dynamic Rework (#91290)
## About The Pull Request

Implements https://hackmd.io/@tgstation/SkeUS7lSp , rewriting Dynamic
from the ground-up

- Dynamic configuration is now vastly streamlined, making it far far far
easier to understand and edit

- Threat is gone entirely; round chaos is now determined by dynamic
tiers
   - There's 5 dynamic tiers, 0 to 4.
      - 0 is a pure greenshift.
- Tiers are just picked via weight - "16% chance of getting a high chaos
round".
- Tiers have min pop ranges. "Tier 4 (high chaos) requires 25 pop to be
selected".
- Tier determines how much of every ruleset is picked. "Tier 4 (High
Chaos) will pick 3-4 roundstart[1], 1-2 light, 1-2 heavy, and 2-3
latejoins".
- The number of rulesets picked depends on how many people are in the
server - this is also configurable[2]. As an example, a tier that
demands "1-3" rulesets will not spawn 3 rulesets if population <= 40 and
will not spawn 2 rulesets if population <= 25.
- Tiers also determine time before light, heavy, and latejoin rulesets
are picked, as well as the cooldown range between spawns. More chaotic
tiers may send midrounds sooner or wait less time between sending them.

- On the ruleset side of things, "requirements", "scaling", and
"enemies" is gone.
- You can configure a ruleset's min pop and weight flat, or per tier.
- For example a ruleset like Obsession is weighted higher for tiers 1-2
and lower for tiers 3-4.
- Rather than scaling up, roundstart rulesets can just be selected
multiple times.
- Rulesets also have `min_antag_cap` and `max_antag_cap`.
`min_antag_cap` determines how many candidates are needed for it to run,
and `max_antag_cap` determines how many candidates are selected.

- Rulesets attempt to run every 2.5 minutes. [3]

- Light rulesets will ALWAYS be picked before heavy rulesets. [4]

- Light injection chance is no longer 100%, heavy injection chance
formula has been simplified.
- Chance simply scales based on number of dead players / total number
off players, with a flag 50% chance if no antags exist. [5]

[1] This does not guarantee you will actually GET 3-4 roundstart
rulesets. If a roundstart ruleset is picked, and it ends up being unable
to execute (such as "not enough candidates", that slot is effectively a
wash.) This might be revisited.

[2] Currently, this is a hard limit - below X pop, you WILL get a
quarter or a half of the rulesets. This might be revisited to just be
weighted - you are just MORE LIKELY to get a quarter or a half.

[3] Little worried about accidentally frontloading everything so we'll
see about this

[4] This may be revisited but in most contexts it seems sensible. 

[5] This may also be revisited, I'm not 100% sure what the best / most
simple way to tackle midround chances is.

Other implementation details

- The process of making rulesets has been streamlined as well. Many
rulesets only amount to a definition and `assign_role`.

- Dynamic.json -> Dynamic.toml

- Dynamic event hijacked was ripped out entirely.
- Most midround antag random events are now dynamic rulesets. Fugitives,
Morphs, Slaughter Demons, etc.
      - The 1 weight slaughter demon event is gone. RIP in peace. 
- There is now a hidden midround event that simply adds +1 latejoin, +1
light, or +1 heavy ruleset.

- `mind.special_role` is dead. Minds have a lazylist of special roles
now but it's essentially only used for traitor panel.

- Revs refactored almost entirely. Revs can now exist without a dynamic
ruleset.

- Cult refactored a tiny bit. 

- Antag datums cleaned up.

- Pre round setup is less centralized on Dynamic.

- Admins have a whole panel for interfacing with dynamic. It's pretty
slapdash I'm sure someone could make a nicer looking one.


![image](https://github.com/user-attachments/assets/e99ca607-20b0-4d30-ab4a-f602babe7ac7)


![image](https://github.com/user-attachments/assets/470c3c20-c354-4ee6-b63b-a8f36dda4b5c)

- Maybe some other things.

## Why It's Good For The Game

See readme for more info.

Will you see a massive change in how rounds play out? My hunch says
rounds will spawn less rulesets on average, but it's ultimately to how
it's configured

## Changelog

🆑 Melbert
refactor: Dynamic rewritten entirely, report any strange rounds
config: Dynamic config reworked, it's now a TOML file
refactor: Refactored antag roles somewhat, report any oddities
refactor: Refactored Revolution entirely, report any oddities
del: Deleted most midround events that spawn antags - they use dynamic
rulesets now
add: Dynamic rulesets can now be false alarms
add: Adds a random event that gives dynamic the ability to run another
ruleset later
admin: Adds a panel for messing around with dynamic
admin: Adds a panel for chance for every dynamic ruleset to be selected
admin: You can spawn revs without using dynamic now
fix: Nuke team leaders get their fun title back
/🆑
2025-06-25 17:36:10 -07:00

270 lines
10 KiB
Plaintext

/// Default master server machine state. Use a special screwdriver to get to the next state.
#define HDD_PANEL_CLOSED 0
/// Front master server HDD panel has been removed. Use a special crowbar to get to the next state.
#define HDD_PANEL_OPEN 1
/// Master server HDD has been pried loose and is held in by only cables. Use a special set of wirecutters to finish stealing the objective.
#define HDD_PRIED 2
/// Master server HDD has been cut loose.
#define HDD_CUT_LOOSE 3
/// The ninja has blown the HDD up.
#define HDD_OVERLOADED 4
#define SERVER_NOMINAL_TEXT "Nominal"
/obj/machinery/rnd/server
name = "\improper R&D Server"
desc = "A computer system running a deep neural network that processes arbitrary information to produce data useable in the development of new technologies. In layman's terms, it makes research points."
icon = 'icons/obj/machines/research.dmi'
icon_state = "RD-server-on"
base_icon_state = "RD-server"
circuit = /obj/item/circuitboard/machine/rdserver
req_access = list(ACCESS_RD)
/// if TRUE, we are currently operational and giving out research points.
var/working = TRUE
/// if TRUE, someone manually disabled us via console.
var/research_disabled = FALSE
/obj/machinery/rnd/server/Initialize(mapload)
. = ..()
//servers handle techwebs differently as we are expected to be there to connect
//every other machinery on-station.
if(!stored_research)
if(CONFIG_GET(flag/no_default_techweb_link))
stored_research = new /datum/techweb
else
var/datum/techweb/science_web = locate(/datum/techweb/science) in SSresearch.techwebs
connect_techweb(science_web)
stored_research.techweb_servers |= src
name += " [num2hex(rand(1,65535), -1)]" //gives us a random four-digit hex number as part of the name. Y'know, for fluff.
/obj/machinery/rnd/server/Destroy()
if(stored_research)
stored_research.techweb_servers -= src
if(CONFIG_GET(flag/no_default_techweb_link))
QDEL_NULL(stored_research)
return ..()
/obj/machinery/rnd/server/update_icon_state()
if(machine_stat & NOPOWER)
icon_state = "[base_icon_state]-off"
else
// "working" will cover EMP'd, disabled, or just broken
icon_state = "[base_icon_state]-[working ? "on" : "halt"]"
return ..()
/obj/machinery/rnd/server/power_change()
refresh_working()
return ..()
/obj/machinery/rnd/server/on_set_machine_stat()
refresh_working()
return ..()
/// Checks if we should be working or not, and updates accordingly.
/obj/machinery/rnd/server/proc/refresh_working()
if(machine_stat & (NOPOWER|EMPED) || research_disabled)
working = FALSE
else
working = TRUE
update_current_power_usage()
update_appearance(UPDATE_ICON_STATE)
/obj/machinery/rnd/server/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
set_machine_stat(machine_stat | EMPED)
addtimer(CALLBACK(src, PROC_REF(fix_emp)), 60 SECONDS)
refresh_working()
/// Callback to un-emp the server afetr some time.
/obj/machinery/rnd/server/proc/fix_emp()
set_machine_stat(machine_stat & ~EMPED)
refresh_working()
/// Toggles whether or not researched_disabled is, yknow, disabled
/obj/machinery/rnd/server/proc/toggle_disable(mob/user)
research_disabled = !research_disabled
user.log_message("[research_disabled ? "shut off" : "turned on"] [src]", LOG_GAME)
refresh_working()
/// Gets status text based on this server's status for the computer.
/obj/machinery/rnd/server/proc/get_status_text()
if(machine_stat & EMPED)
return "O&F@I*$ - R3*&O$T R@U!R%D"
else if(machine_stat & NOPOWER)
return "Offline - Server Unpowered"
else if(research_disabled)
return "Offline - Server Control Disabled"
else if(!working)
// If, for some reason, working is FALSE even though we're not emp'd or powerless,
// We need something to update our working state - such as rebooting the server
return "Offline - Reboot Required"
return SERVER_NOMINAL_TEXT
/obj/machinery/rnd/server/multitool_act(mob/living/user, obj/item/multitool/tool)
if(!stored_research)
return
tool.set_buffer(stored_research)
balloon_alert(user, "saved to multitool buffer")
return TRUE
/// Master R&D server. As long as this still exists and still holds the HDD for the theft objective, research points generate at normal speed. Destroy it or an antag steals the HDD? Half research speed.
/obj/machinery/rnd/server/master
max_integrity = 1800 //takes roughly ~15s longer to break then full deconstruction.
circuit = null
var/obj/item/computer_disk/hdd_theft/source_code_hdd
var/deconstruction_state = HDD_PANEL_CLOSED
var/front_panel_screws = 4
var/hdd_wires = 6
/obj/machinery/rnd/server/master/Initialize(mapload)
. = ..()
name = "\improper Master " + name
desc += "\nIt looks incredibly resistant to damage!"
source_code_hdd = new(src)
add_overlay("RD-server-objective-stripes")
/obj/machinery/rnd/server/master/Destroy()
QDEL_NULL(source_code_hdd)
return ..()
/obj/machinery/rnd/server/master/get_status_text()
. = ..()
// Give us a special message if we're nominal, but our hard drive is gone
if(. == SERVER_NOMINAL_TEXT && !source_code_hdd)
return "<font color=orange>Nominal - Hard Drive Missing</font>"
/obj/machinery/rnd/server/master/examine(mob/user)
. = ..()
switch(deconstruction_state)
if(HDD_PANEL_CLOSED)
. += "The front panel is closed. You can see some recesses which may have <b>screws</b>."
if(HDD_PANEL_OPEN)
. += "The front panel is dangling open. The hdd is in a secure housing. Looks like you'll have to <b>pry</b> it loose."
if(HDD_PRIED)
. += "The front panel is dangling open. The hdd has been pried from its housing. It is still connected by <b>wires</b>."
if(HDD_CUT_LOOSE)
. += "The front panel is dangling open. All you can see inside are cut wires and mangled metal."
if(HDD_OVERLOADED)
. += "The front panel is dangling open. The hdd inside is destroyed and the wires are all burned."
/obj/machinery/rnd/server/master/tool_act(mob/living/user, obj/item/tool, list/modifiers)
if(!tool.tool_behaviour)
return ..()
// Only antags are given the training and knowledge to disassemble this thing.
if(!user.is_antag())
if(user.combat_mode)
return ITEM_INTERACT_SKIP_TO_ATTACK
balloon_alert(user, "you can't find an obvious maintenance hatch!")
return ITEM_INTERACT_BLOCKING
return ..()
/obj/machinery/rnd/server/master/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers)
if(istype(attacking_item, /obj/item/computer_disk/hdd_theft))
switch(deconstruction_state)
if(HDD_PANEL_CLOSED)
balloon_alert(user, "you can't find a place to insert it!")
return TRUE
if(HDD_PANEL_OPEN)
balloon_alert(user, "you weren't trained to install this!")
return TRUE
if(HDD_PRIED)
balloon_alert(user, "the hdd housing is completely broken, it won't fit!")
return TRUE
if(HDD_CUT_LOOSE)
balloon_alert(user, "the hdd housing is completely broken and all the wires are cut!")
return TRUE
if(HDD_OVERLOADED)
balloon_alert(user, "the inside is scorched and all the wires are burned!")
return TRUE
return ..()
/obj/machinery/rnd/server/master/screwdriver_act(mob/living/user, obj/item/tool)
if(deconstruction_state != HDD_PANEL_CLOSED || user.combat_mode)
return FALSE
to_chat(user, span_notice("You can see [front_panel_screws] screw\s. You start unscrewing [front_panel_screws == 1 ? "it" : "them"]..."))
while(tool.use_tool(src, user, 7.5 SECONDS, volume=100))
front_panel_screws--
if(front_panel_screws <= 0)
deconstruction_state = HDD_PANEL_OPEN
to_chat(user, span_notice("You remove the last screw from [src]'s front panel."))
add_overlay("RD-server-hdd-panel-open")
return TRUE
to_chat(user, span_notice("The screw breaks as you remove it. Only [front_panel_screws] left..."))
return TRUE
/obj/machinery/rnd/server/master/crowbar_act(mob/living/user, obj/item/tool)
if(deconstruction_state != HDD_PANEL_OPEN || user.combat_mode)
return FALSE
to_chat(user, span_notice("You can see [source_code_hdd] in a secure housing behind the front panel. You begin to pry it loose..."))
if(tool.use_tool(src, user, 15 SECONDS, volume=100))
to_chat(user, span_notice("You destroy the housing, prying [source_code_hdd] free."))
deconstruction_state = HDD_PRIED
return TRUE
/obj/machinery/rnd/server/master/wirecutter_act(mob/living/user, obj/item/tool)
if(deconstruction_state != HDD_PRIED || user.combat_mode)
return FALSE
to_chat(user, span_notice("There are [hdd_wires] wire\s connected to [source_code_hdd]. You start cutting [hdd_wires == 1 ? "it" : "them"]..."))
while(tool.use_tool(src, user, 7.5 SECONDS, volume=100))
hdd_wires--
if(hdd_wires <= 0)
deconstruction_state = HDD_CUT_LOOSE
to_chat(user, span_notice("You cut the final wire and remove [source_code_hdd]."))
try_put_in_hand(source_code_hdd, user)
source_code_hdd = null
stored_research.income_modifier *= 0.5
return TRUE
to_chat(user, span_notice("You delicately cut the wire. [hdd_wires] wire\s left..."))
return TRUE
/obj/machinery/rnd/server/master/on_deconstruction(disassembled)
// If the machine contains a source code HDD, destroying it will negatively impact research speed. Safest to log this.
if(source_code_hdd)
// Destroyed with a hard drive inside = harm income
stored_research.income_modifier *= 0.5
// If there's a usr, this was likely a direct deconstruction of some sort. Extra logging info!
if(usr)
var/mob/user = usr
message_admins("[ADMIN_LOOKUPFLW(user)] deconstructed [ADMIN_JMP(src)].")
user.log_message("deconstructed [src].", LOG_GAME)
return ..()
message_admins("[ADMIN_JMP(src)] has been deconstructed by an unknown user.")
log_game("[src] has been deconstructed by an unknown user.")
return ..()
/// Destroys the source_code_hdd if present and sets the machine state to overloaded, adding the panel open overlay if necessary.
/obj/machinery/rnd/server/master/proc/overload_source_code_hdd()
if(source_code_hdd)
QDEL_NULL(source_code_hdd)
// Overloaded = harm income
stored_research.income_modifier *= 0.5
if(deconstruction_state == HDD_PANEL_CLOSED)
add_overlay("RD-server-hdd-panel-open")
front_panel_screws = 0
hdd_wires = 0
deconstruction_state = HDD_OVERLOADED
#undef HDD_CUT_LOOSE
#undef HDD_OVERLOADED
#undef HDD_PANEL_CLOSED
#undef HDD_PANEL_OPEN
#undef HDD_PRIED
#undef SERVER_NOMINAL_TEXT