From e0bdfc3f5ffd98ce0a6b0e6b6a7e060700204540 Mon Sep 17 00:00:00 2001
From: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Date: Wed, 25 Jun 2025 19:36:10 -0500
Subject: [PATCH] Dynamic Rework (#91290)
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.


- Maybe some other things.
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
:cl: 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
/:cl:
(cherry picked from commit 4c277dc5727c6bd8344a5b508400370863de5deb)
---
code/__DEFINES/antagonists.dm | 9 +-
.../signals/signals_mob/signals_mob_main.dm | 2 +-
.../dcs/signals/signals_subsystem.dm | 3 +
code/__DEFINES/dynamic.dm | 46 -
code/__DEFINES/jobs.dm | 4 +
code/__DEFINES/role_preferences.dm | 90 +-
code/__HELPERS/events.dm | 2 -
code/__HELPERS/game.dm | 10 +-
code/__HELPERS/logging/dynamic.dm | 5 -
code/__HELPERS/logging/manifest.dm | 5 +-
code/__HELPERS/roundend.dm | 12 +-
code/controllers/subsystem/blackbox.dm | 4 +-
.../subsystem/dynamic/__dynamic_defines.dm | 55 +
.../subsystem/dynamic/_dynamic_ruleset.dm | 372 ++++
.../subsystem/dynamic/_dynamic_tier.dm | 316 ++++
code/controllers/subsystem/dynamic/dynamic.dm | 1665 +++++++----------
.../subsystem/dynamic/dynamic_admin.dm | 254 +++
.../subsystem/dynamic/dynamic_hijacking.dm | 25 -
.../subsystem/dynamic/dynamic_logging.dm | 101 -
.../dynamic/dynamic_midround_rolling.dm | 108 --
.../dynamic/dynamic_ruleset_latejoin.dm | 128 ++
.../dynamic/dynamic_ruleset_midround.dm | 1150 ++++++++++++
.../dynamic/dynamic_ruleset_roundstart.dm | 433 +++++
.../subsystem/dynamic/dynamic_rulesets.dm | 310 ---
.../dynamic/dynamic_rulesets_latejoin.dm | 263 ---
.../dynamic/dynamic_rulesets_midround.dm | 1009 ----------
.../dynamic/dynamic_rulesets_roundstart.dm | 747 --------
.../subsystem/dynamic/dynamic_testing.dm | 111 ++
.../dynamic/dynamic_unfavorable_situation.dm | 74 -
code/controllers/subsystem/dynamic/readme.md | 202 --
.../subsystem/dynamic/ruleset_picking.dm | 159 --
code/controllers/subsystem/job.dm | 31 +-
code/controllers/subsystem/polling.dm | 5 +-
code/controllers/subsystem/ticker.dm | 124 +-
code/datums/ai_laws/ai_laws.dm | 4 +-
code/datums/communications.dm | 74 +
code/datums/mind/_mind.dm | 18 +-
code/datums/mind/antag.dm | 54 +-
code/datums/mind/initialization.dm | 1 -
.../proximity_monitor/fields/heretic_arena.dm | 2 +-
code/datums/station_traits/_station_trait.dm | 9 -
code/datums/station_traits/job_traits.dm | 20 -
code/datums/station_traits/negative_traits.dm | 1 -
code/datums/station_traits/neutral_traits.dm | 17 +-
code/game/gamemodes/objective.dm | 14 +-
.../game/machinery/computer/communications.dm | 58 +-
code/game/machinery/wishgranter.dm | 2 +-
.../anomalies/anomalies_pyroclastic.dm | 1 -
.../objects/effects/poster_motivational.dm | 4 +-
.../game/objects/items/devices/aicard_evil.dm | 2 +-
code/game/objects/items/religion.dm | 2 +-
code/game/objects/items/robot/robot_parts.dm | 2 +-
.../game/objects/items/storage/uplink_kits.dm | 8 +-
code/modules/admin/admin.dm | 148 +-
code/modules/admin/antag_panel.dm | 22 +-
code/modules/admin/check_antagonists.dm | 4 +-
code/modules/admin/player_panel.dm | 2 +-
code/modules/admin/topic.dm | 121 +-
code/modules/admin/verbs/admingame.dm | 33 +-
code/modules/admin/verbs/adminhelp.dm | 4 +-
.../antagonists/_common/antag_datum.dm | 43 +-
.../antagonists/_common/antag_helpers.dm | 3 +-
.../antagonists/_common/antag_spawner.dm | 10 +-
code/modules/antagonists/abductor/abductor.dm | 4 +-
.../antagonists/ashwalker/ashwalker.dm | 5 +-
.../battlecruiser/battlecruiser.dm | 4 +-
code/modules/antagonists/blob/blob_antag.dm | 4 +-
.../antagonists/brainwashing/brainwashing.dm | 4 +-
code/modules/antagonists/brother/brother.dm | 7 +-
.../antagonists/changeling/changeling.dm | 4 +-
.../changeling/fallen_changeling.dm | 3 +-
code/modules/antagonists/clown_ops/clownop.dm | 11 +-
.../antagonists/cult/datums/cultist.dm | 2 +-
code/modules/antagonists/cult/runes.dm | 3 +-
code/modules/antagonists/ert/ert.dm | 3 +-
.../antagonists/evil_clone/evil_clone.dm | 4 +-
code/modules/antagonists/fugitive/fugitive.dm | 15 +-
.../antagonists/fugitive/hunters/hunter.dm | 3 +-
.../antagonists/greentext/greentext.dm | 2 +-
.../antagonists/heretic/heretic_antag.dm | 2 +-
.../antagonists/heretic/heretic_monsters.dm | 2 +-
.../heretic/soultrapped_heretic.dm | 2 +-
.../antagonists/highlander/highlander.dm | 3 +-
.../antagonists/hypnotized/hypnotized.dm | 4 +-
code/modules/antagonists/malf_ai/malf_ai.dm | 4 +-
.../antagonists/nightmare/nightmare.dm | 2 +-
.../antagonists/nukeop/datums/operative.dm | 70 +-
.../nukeop/datums/operative_leader.dm | 36 +-
.../nukeop/datums/operative_lone.dm | 19 +-
.../nukeop/datums/operative_team.dm | 61 +-
code/modules/antagonists/obsessed/obsessed.dm | 9 +-
.../paradox_clone/paradox_clone.dm | 15 +-
code/modules/antagonists/pirate/pirate.dm | 2 +-
.../antagonists/pirate/pirate_event.dm | 119 --
.../antagonists/pyro_slime/pyro_slime.dm | 1 +
.../revolution/enemy_of_the_state.dm | 2 +-
.../antagonists/revolution/revolution.dm | 209 +--
.../revolution/revolution_handler.dm | 159 ++
.../sentient_creature/sentient_creature.dm | 2 +-
.../modules/antagonists/shade/shade_minion.dm | 2 +-
.../antagonists/space_dragon/space_dragon.dm | 4 +-
.../antagonists/space_ninja/space_ninja.dm | 11 +-
code/modules/antagonists/spy/spy.dm | 2 +-
.../antagonists/survivalist/survivalist.dm | 1 -
.../syndicate_monkey/syndicate_monkey.dm | 2 +-
.../traitor/components/demoraliser.dm | 2 +-
.../traitor/contractor/contract_teammate.dm | 2 +-
.../antagonists/traitor/datum_traitor.dm | 10 +-
.../antagonists/valentines/valentine.dm | 4 +-
.../antagonists/voidwalker/voidwalker.dm | 2 +-
.../antagonists/wishgranter/wishgranter.dm | 1 -
.../equipment/spellbook_entries/summons.dm | 23 +-
.../wizard/equipment/wizard_spellbook.dm | 2 +-
.../wizard/grand_ritual/finales/armageddon.dm | 6 +-
.../finales/grand_ritual_finale.dm | 2 +-
.../antagonists/wizard/slaughter_antag.dm | 2 +-
code/modules/antagonists/wizard/wizard.dm | 7 +-
code/modules/antagonists/xeno/xeno.dm | 5 +-
.../modules/bitrunning/antagonists/_parent.dm | 2 +-
.../bitrunning/antagonists/ghost_role.dm | 2 +-
code/modules/bitrunning/event.dm | 1 -
code/modules/bitrunning/server/threats.dm | 1 -
.../client/preferences/middleware/antags.dm | 102 +-
code/modules/client/preferences_savefile.dm | 2 +-
code/modules/client/verbs/who.dm | 2 +-
code/modules/clothing/outfits/event.dm | 1 -
code/modules/events/_event.dm | 6 -
code/modules/events/creep_awakening.dm | 30 -
code/modules/events/dynamic_tweak.dm | 35 +
code/modules/events/false_alarm.dm | 77 +-
code/modules/events/ghost_role/abductor.dm | 43 -
.../events/ghost_role/alien_infestation.dm | 82 -
code/modules/events/ghost_role/blob.dm | 44 -
.../events/ghost_role/changeling_event.dm | 29 -
.../events/ghost_role/fugitive_event.dm | 192 --
code/modules/events/ghost_role/morph_event.dm | 35 -
code/modules/events/ghost_role/nightmare.dm | 38 -
code/modules/events/ghost_role/operative.dm | 4 +-
.../events/ghost_role/revenant_event.dm | 61 -
.../events/ghost_role/slaughter_event.dm | 36 -
.../modules/events/ghost_role/space_dragon.dm | 35 -
code/modules/events/ghost_role/space_ninja.dm | 65 -
code/modules/events/holiday/vday.dm | 2 -
code/modules/events/spider_infestation.dm | 36 -
code/modules/events/wizard/imposter.dm | 1 -
code/modules/jobs/job_exp.dm | 2 +-
code/modules/jobs/job_types/_job.dm | 4 +
code/modules/jobs/job_types/ai.dm | 3 +
.../job_types/antagonists/clown_operative.dm | 2 -
.../antagonists/nuclear_operative.dm | 21 +-
code/modules/jobs/job_types/captain.dm | 2 +-
code/modules/jobs/job_types/cyborg.dm | 3 +
code/modules/jobs/job_types/detective.dm | 2 +-
.../jobs/job_types/head_of_security.dm | 2 +-
code/modules/jobs/job_types/prisoner.dm | 2 +-
.../jobs/job_types/security_officer.dm | 2 +-
.../station_trait/bridge_assistant.dm | 2 +-
.../job_types/station_trait/cargo_gorilla.dm | 4 +-
.../jobs/job_types/station_trait/human_ai.dm | 2 +-
.../station_trait/veteran_advisor.dm | 2 +-
code/modules/jobs/job_types/warden.dm | 2 +-
code/modules/lost_crew/recovered_crew.dm | 4 +-
.../modules/meteors/meteor_mode_controller.dm | 31 +
code/modules/meteors/meteor_spawning.dm | 8 +-
.../mining_loot/megafauna/the_thing.dm | 6 +-
.../modules/mob/dead/new_player/new_player.dm | 29 +-
.../mob/living/basic/drone/interaction.dm | 4 +-
.../living/basic/space_fauna/demon/demon.dm | 1 -
.../basic/space_fauna/revenant/_revenant.dm | 1 -
code/modules/mob/living/carbon/human/human.dm | 1 -
code/modules/mob/living/living.dm | 7 +-
code/modules/mob/living/silicon/ai/ai.dm | 8 +-
.../modules/mob/living/silicon/robot/robot.dm | 5 +-
code/modules/mob/mob_helpers.dm | 77 +-
code/modules/mob/mob_lists.dm | 11 +-
.../modular_computers/computers/item/pda.dm | 2 +-
.../programs/messenger/messenger_program.dm | 2 +-
code/modules/projectiles/projectile/magic.dm | 16 +-
code/modules/research/server.dm | 2 +-
code/modules/shuttle/shuttle_events/humans.dm | 2 +-
.../unit_tests/dynamic_ruleset_sanity.dm | 35 +-
...hot_antag_icons_clownoperativemidround.png | Bin 0 -> 2004 bytes
...creenshot_antag_icons_nuclearoperative.png | Bin 0 -> 1895 bytes
code/modules/unit_tests/traitor.dm | 2 +-
config/dynamic.json | 155 --
config/dynamic.toml | 612 ++++++
tgstation.dme | 36 +-
.../packages/tgui/interfaces/DynamicAdmin.tsx | 739 ++++++++
.../tgui/interfaces/DynamicTester.tsx | 145 ++
189 files changed, 6052 insertions(+), 6318 deletions(-)
delete mode 100644 code/__DEFINES/dynamic.dm
create mode 100644 code/controllers/subsystem/dynamic/__dynamic_defines.dm
create mode 100644 code/controllers/subsystem/dynamic/_dynamic_ruleset.dm
create mode 100644 code/controllers/subsystem/dynamic/_dynamic_tier.dm
create mode 100644 code/controllers/subsystem/dynamic/dynamic_admin.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_hijacking.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_logging.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_midround_rolling.dm
create mode 100644 code/controllers/subsystem/dynamic/dynamic_ruleset_latejoin.dm
create mode 100644 code/controllers/subsystem/dynamic/dynamic_ruleset_midround.dm
create mode 100644 code/controllers/subsystem/dynamic/dynamic_ruleset_roundstart.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_rulesets.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_rulesets_latejoin.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_rulesets_midround.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_rulesets_roundstart.dm
create mode 100644 code/controllers/subsystem/dynamic/dynamic_testing.dm
delete mode 100644 code/controllers/subsystem/dynamic/dynamic_unfavorable_situation.dm
delete mode 100644 code/controllers/subsystem/dynamic/readme.md
delete mode 100644 code/controllers/subsystem/dynamic/ruleset_picking.dm
delete mode 100644 code/modules/antagonists/pirate/pirate_event.dm
create mode 100644 code/modules/antagonists/revolution/revolution_handler.dm
delete mode 100644 code/modules/events/creep_awakening.dm
create mode 100644 code/modules/events/dynamic_tweak.dm
delete mode 100644 code/modules/events/ghost_role/abductor.dm
delete mode 100644 code/modules/events/ghost_role/alien_infestation.dm
delete mode 100644 code/modules/events/ghost_role/blob.dm
delete mode 100644 code/modules/events/ghost_role/changeling_event.dm
delete mode 100644 code/modules/events/ghost_role/fugitive_event.dm
delete mode 100644 code/modules/events/ghost_role/morph_event.dm
delete mode 100644 code/modules/events/ghost_role/nightmare.dm
delete mode 100644 code/modules/events/ghost_role/revenant_event.dm
delete mode 100644 code/modules/events/ghost_role/slaughter_event.dm
delete mode 100644 code/modules/events/ghost_role/space_dragon.dm
delete mode 100644 code/modules/events/ghost_role/space_ninja.dm
delete mode 100644 code/modules/events/spider_infestation.dm
delete mode 100644 code/modules/jobs/job_types/antagonists/clown_operative.dm
create mode 100644 code/modules/meteors/meteor_mode_controller.dm
create mode 100644 code/modules/unit_tests/screenshots/screenshot_antag_icons_clownoperativemidround.png
create mode 100644 code/modules/unit_tests/screenshots/screenshot_antag_icons_nuclearoperative.png
delete mode 100644 config/dynamic.json
create mode 100644 config/dynamic.toml
create mode 100644 tgui/packages/tgui/interfaces/DynamicAdmin.tsx
create mode 100644 tgui/packages/tgui/interfaces/DynamicTester.tsx
diff --git a/code/__DEFINES/antagonists.dm b/code/__DEFINES/antagonists.dm
index eedd2f2329f..011f48f7b73 100644
--- a/code/__DEFINES/antagonists.dm
+++ b/code/__DEFINES/antagonists.dm
@@ -278,6 +278,8 @@ GLOBAL_LIST_INIT(ai_employers, list(
/// Checks if the given mob is a wizard
#define IS_WIZARD(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/wizard))
+/// Checks if the given mob is a wizard apprentice
+#define IS_WIZARD_APPRENTICE(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/wizard/apprentice))
/// Checks if the given mob is a revolutionary. Will return TRUE for rev heads as well.
#define IS_REVOLUTIONARY(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/rev))
@@ -397,8 +399,11 @@ GLOBAL_LIST_INIT(human_invader_antagonists, list(
#define ANTAG_GROUP_CREW "Deviant Crew"
-// This flag disables certain checks that presume antagonist datums mean 'baddie'.
-#define FLAG_FAKE_ANTAG (1 << 0)
+/// Used to denote an antag datum that either isn't necessarily "evil" (like Valentines)
+/// or isn't necessarily a "real" antag (like Ashwalkers)
+#define ANTAG_FAKE (1 << 0)
+/// Antag is not added to the global list of antags
+#define ANTAG_SKIP_GLOBAL_LIST (1 << 1)
#define HUNTER_PACK_COPS "Spacepol Fugitive Hunters"
#define HUNTER_PACK_RUSSIAN "Russian Fugitive Hunters"
diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm
index 53fa1021a0f..222ceaa158c 100644
--- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm
+++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm
@@ -77,7 +77,7 @@
/// From /mob/proc/ghostize() Called when a mob successfully ghosts
#define COMSIG_MOB_GHOSTIZED "mob_ghostized"
/// can_roll_midround(datum/antagonist/antag_type) from certain midround rulesets, (mob/living/source, datum/mind/mind, datum/antagonist/antagonist)
-#define COMSIG_MOB_MIND_BEFORE_MIDROUND_ROLL "mob_mind_transferred_out_of"
+#define COMSIG_MOB_MIND_BEFORE_MIDROUND_ROLL "mob_mind_before_midround_roll"
#define CANCEL_ROLL (1<<1)
///signal sent when a mob has their holy role set. Sent to the mob having their role changed.
diff --git a/code/__DEFINES/dcs/signals/signals_subsystem.dm b/code/__DEFINES/dcs/signals/signals_subsystem.dm
index 749ba9f6381..2260a480a79 100644
--- a/code/__DEFINES/dcs/signals/signals_subsystem.dm
+++ b/code/__DEFINES/dcs/signals/signals_subsystem.dm
@@ -26,3 +26,6 @@
///Sent after awards are saved in the database (/datum/controller/subsystem/achievements/save_achievements_to_db)
#define COMSIG_ACHIEVEMENTS_SAVED_TO_DB "achievements_saved_to_db"
+
+/// Send after config is loaded but before picking roundstart rulesets
+#define COMSIG_DYNAMIC_PRE_ROUNDSTART "dynamic_pre_roundstart"
diff --git a/code/__DEFINES/dynamic.dm b/code/__DEFINES/dynamic.dm
deleted file mode 100644
index 0162ef755e3..00000000000
--- a/code/__DEFINES/dynamic.dm
+++ /dev/null
@@ -1,46 +0,0 @@
-/// This is the only ruleset that should be picked this round, used by admins and should not be on rulesets in code.
-#define ONLY_RULESET (1 << 0)
-
-/// Only one ruleset with this flag will be picked.
-#define HIGH_IMPACT_RULESET (1 << 1)
-
-/// This ruleset can only be picked once. Anything that does not have a scaling_cost MUST have this.
-#define LONE_RULESET (1 << 2)
-
-/// This is a "heavy" midround ruleset, and should be run later into the round
-#define MIDROUND_RULESET_STYLE_HEAVY "Heavy"
-
-/// This is a "light" midround ruleset, and should be run early into the round
-#define MIDROUND_RULESET_STYLE_LIGHT "Light"
-
-/// No round event was hijacked this cycle
-#define HIJACKED_NOTHING "HIJACKED_NOTHING"
-
-/// This cycle, a round event was hijacked when the last midround event was too recent.
-#define HIJACKED_TOO_RECENT "HIJACKED_TOO_RECENT"
-
-/// Kill this ruleset from continuing to process
-#define RULESET_STOP_PROCESSING 1
-
-/// Requirements when something needs a lot of threat to run, but still possible at low-pop
-#define REQUIREMENTS_VERY_HIGH_THREAT_NEEDED list(90,90,90,80,60,50,40,40,40,40)
-
-/// Max number of teams we can have for the abductor ruleset
-#define ABDUCTOR_MAX_TEAMS 4
-
-// Ruletype defines
-#define ROUNDSTART_RULESET "Roundstart"
-#define LATEJOIN_RULESET "Latejoin"
-#define MIDROUND_RULESET "Midround"
-
-#define RULESET_NOT_FORCED "not forced"
-/// Ruleset should run regardless of population and threat available
-#define RULESET_FORCE_ENABLED "force enabled"
-/// Ruleset should not run regardless of population and threat available
-#define RULESET_FORCE_DISABLED "force disabled"
-
-// Flavor ruletypes, used by station traits
-/// Rulesets selected by dynamic at default
-#define RULESET_CATEGORY_DEFAULT (1 << 0)
-/// Rulesets not including crew antagonists, non-witting referring to antags like obsessed which aren't really enemies of the station
-#define RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS (1 << 1)
diff --git a/code/__DEFINES/jobs.dm b/code/__DEFINES/jobs.dm
index d71da7a326b..5c466a6ca12 100644
--- a/code/__DEFINES/jobs.dm
+++ b/code/__DEFINES/jobs.dm
@@ -279,6 +279,10 @@ DEFINE_BITFIELD(departments_bitflags, list(
#define JOB_LATEJOIN_ONLY (1<<11)
/// This job is a head of staff.
#define JOB_HEAD_OF_STAFF (1<<12)
+/// This job will NEVER be selected as an antag role
+#define JOB_ANTAG_BLACKLISTED (1<<13)
+/// This job will never be selected as an antag role IF config `protect_roles_from_antagonist` is set
+#define JOB_ANTAG_PROTECTED (1<<14)
DEFINE_BITFIELD(job_flags, list(
"JOB_ANNOUNCE_ARRIVAL" = JOB_ANNOUNCE_ARRIVAL,
diff --git a/code/__DEFINES/role_preferences.dm b/code/__DEFINES/role_preferences.dm
index da975f90ea5..a560083458a 100644
--- a/code/__DEFINES/role_preferences.dm
+++ b/code/__DEFINES/role_preferences.dm
@@ -35,6 +35,7 @@
#define ROLE_NINJA "Space Ninja"
#define ROLE_OBSESSED "Obsessed"
#define ROLE_OPERATIVE_MIDROUND "Operative (Midround)"
+#define ROLE_CLOWN_OPERATIVE_MIDROUND "Clown Operative (Midround)"
#define ROLE_PARADOX_CLONE "Paradox Clone"
#define ROLE_REV_HEAD "Head Revolutionary"
#define ROLE_SLEEPER_AGENT "Syndicate Sleeper Agent"
@@ -77,13 +78,13 @@
#define ROLE_REVENANT "Revenant"
#define ROLE_SENTIENCE "Sentience Potion Spawn"
#define ROLE_SOULTRAPPED_HERETIC "Soultrapped Heretic"
+/// This flag specifically is used as a generic catch-all antag ban
#define ROLE_SYNDICATE "Syndicate"
#define ROLE_EXPERIMENTAL_CLONER "Experimental Cloner"
#define ROLE_CLOWN_OPERATIVE "Clown Operative"
#define ROLE_FREE_GOLEM "Free Golem"
#define ROLE_MORPH "Morph"
-#define ROLE_NUCLEAR_OPERATIVE "Nuclear Operative"
#define ROLE_POSITRONIC_BRAIN "Positronic Brain"
#define ROLE_SANTA "Santa"
#define ROLE_SERVANT_GOLEM "Servant Golem"
@@ -132,93 +133,6 @@
#define ROLE_CYBER_POLICE "Cyber Police"
#define ROLE_CYBER_TAC "Cyber Tac"
#define ROLE_NETGUARDIAN "NetGuardian Prime"
-//SKYRAT EDIT START - Skyrat roles
-#define ROLE_BLACK_MARKET_DEALER "Black Market Dealer"
-#define ROLE_DS2 "DS2 Syndicate"
-#define ROLE_FREIGHTER_CREW "Freighter Crew"
-#define ROLE_GHOST_CAFE "Ghost Cafe Visitor"
-#define ROLE_PORT_TARKON "Port Tarkon Survivor"
-//SKYRAT EDIT END
-
-//BUBBER EDIT START
-#define ROLE_DAUNTLESS "Dauntless Syndicate"
-#define ROLE_PERSISTENCE "Persistence Syndicate"
-
-#define ROLE_BLOODSUCKER "Bloodsucker"
-#define ROLE_VAMPIRICACCIDENT "Bloodsucker (Midround)"
-#define ROLE_BLOODSUCKERBREAKOUT "Bloodsucker (Latejoin)"
-#define ROLE_MONSTERHUNTER "Monster Hunter"
-#define ROLE_VASSAL "Ghoul"
-
-#define ROLE_CHANGELING_ZOMBIE "Changeling Zombie"
-//BUBBER EDIT END
-
-/// This defines the antagonists you can operate with in the settings.
-/// Keys are the antagonist, values are the number of days since the player's
-/// first connection in order to play.
-GLOBAL_LIST_INIT(special_roles, list(
- // Roundstart
- ROLE_BROTHER = 0,
- ROLE_CHANGELING = 0,
- ROLE_CLOWN_OPERATIVE = 14,
- ROLE_CULTIST = 14,
- ROLE_HERETIC = 0,
- ROLE_MALF = 0,
- ROLE_OPERATIVE = 14,
- ROLE_REV_HEAD = 14,
- ROLE_TRAITOR = 0,
- ROLE_WIZARD = 14,
- ROLE_SPY = 0,
- // SKYRAT EDIT ADDITION
- ROLE_ASSAULT_OPERATIVE = 14,
- // SKYRAT EDIT END
-
- // Midround
- ROLE_ABDUCTOR = 0,
- ROLE_ALIEN = 0,
- ROLE_BLOB = 0,
- ROLE_BLOB_INFECTION = 0,
- ROLE_CHANGELING_MIDROUND = 0,
- ROLE_FUGITIVE = 0,
- ROLE_LONE_OPERATIVE = 14,
- ROLE_MALF_MIDROUND = 0,
- ROLE_NIGHTMARE = 0,
- ROLE_NINJA = 0,
- ROLE_OBSESSED = 0,
- ROLE_OPERATIVE_MIDROUND = 14,
- ROLE_PARADOX_CLONE = 0,
- ROLE_REVENANT = 0,
- ROLE_SLEEPER_AGENT = 0,
- ROLE_SPACE_DRAGON = 0,
- ROLE_SPIDER = 0,
- ROLE_WIZARD_MIDROUND = 14,
- //SKYRAT EDIT START
- ROLE_LONE_INFILTRATOR = 0,
- ROLE_BORER = 0,
- ROLE_MUTANT = 0,
- //SKYRAT EDIT END
- ROLE_VOIDWALKER = 0,
-
- // Latejoin
- ROLE_HERETIC_SMUGGLER = 0,
- ROLE_PROVOCATEUR = 14,
- ROLE_SYNDICATE_INFILTRATOR = 0,
- ROLE_STOWAWAY_CHANGELING = 0,
-
- // I'm not too sure why these are here, but they're not moving.
- ROLE_GLITCH = 0,
- ROLE_PAI = 0,
- ROLE_SENTIENCE = 0,
- ROLE_RECOVERED_CREW = 0,
-
- //BUBBER EDIT START
- ROLE_BLOODSUCKER = 14,
- ROLE_VAMPIRICACCIDENT = 14,
- ROLE_BLOODSUCKERBREAKOUT = 14,
- ROLE_MONSTERHUNTER = 14,
- ROLE_CHANGELING_ZOMBIE = 0
- //BUBBER EDIT END
-))
//Job defines for what happens when you fail to qualify for any job during job selection
#define BEOVERFLOW 1
diff --git a/code/__HELPERS/events.dm b/code/__HELPERS/events.dm
index 9b5f939de15..58d91c8caa8 100644
--- a/code/__HELPERS/events.dm
+++ b/code/__HELPERS/events.dm
@@ -23,7 +23,6 @@
possible_spawns += spawn_turf
if(!length(possible_spawns))
- message_admins("No valid generic_maintenance_landmark landmarks found, aborting...")
return null
return pick(possible_spawns)
@@ -44,7 +43,6 @@
possible_spawns += get_turf(spawn_location)
if(!length(possible_spawns))
- message_admins("No valid carpspawn landmarks found, aborting...")
return null
return pick(possible_spawns)
diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm
index 8ae96a3aeb1..afe155b50d2 100644
--- a/code/__HELPERS/game.dm
+++ b/code/__HELPERS/game.dm
@@ -150,8 +150,8 @@
return
///Get active players who are playing in the round
-/proc/get_active_player_count(alive_check = FALSE, afk_check = FALSE, human_check = FALSE)
- var/active_players = 0
+/proc/get_active_player_list(alive_check = FALSE, afk_check = FALSE, human_check = FALSE)
+ var/list/active_players = list()
for(var/mob/player_mob as anything in GLOB.player_list)
if(!player_mob?.client)
continue
@@ -167,9 +167,13 @@
var/mob/dead/observer/ghost_player = player_mob
if(ghost_player.started_as_observer) // Exclude people who started as observers
continue
- active_players++
+ active_players += player_mob
return active_players
+///Counts active players who are playing in the round
+/proc/get_active_player_count(alive_check = FALSE, afk_check = FALSE, human_check = FALSE)
+ return length(get_active_player_list(alive_check, afk_check, human_check))
+
///Uses stripped down and bastardized code from respawn character
/proc/make_body(mob/dead/observer/ghost_player)
if(!ghost_player || !ghost_player.key)
diff --git a/code/__HELPERS/logging/dynamic.dm b/code/__HELPERS/logging/dynamic.dm
index 488aeaec3be..70e3d873163 100644
--- a/code/__HELPERS/logging/dynamic.dm
+++ b/code/__HELPERS/logging/dynamic.dm
@@ -1,8 +1,3 @@
-/// Log to dynamic and message admins
-/datum/controller/subsystem/dynamic/proc/log_dynamic_and_announce(text)
- message_admins("DYNAMIC: [text]")
- log_dynamic("[text]")
-
/// Logging for dynamic procs
/proc/log_dynamic(text, list/data)
logger.Log(LOG_CATEGORY_DYNAMIC, text, data)
diff --git a/code/__HELPERS/logging/manifest.dm b/code/__HELPERS/logging/manifest.dm
index 5c18b5e4b18..70ebd8ace0a 100644
--- a/code/__HELPERS/logging/manifest.dm
+++ b/code/__HELPERS/logging/manifest.dm
@@ -1,9 +1,10 @@
/// Logging for player manifest (ckey, name, job, special role, roundstart/latejoin)
/proc/log_manifest(ckey, datum/mind/mind, mob/body, latejoin = FALSE)
- var/message = "[ckey] \\ [body.real_name] \\ [mind.assigned_role.title] \\ [mind.special_role || "NONE"] \\ [latejoin ? "LATEJOIN" : "ROUNDSTART"]"
+ var/roles = english_list(mind.get_special_roles(), nothing_text = "NONE")
+ var/message = "[ckey] \\ [body.real_name] \\ [mind.assigned_role.title] \\ [roles] \\ [latejoin ? "LATEJOIN" : "ROUNDSTART"]"
logger.Log(LOG_CATEGORY_MANIFEST, message, list(
"mind" = mind, "body" = body, "latejoin" = latejoin
))
// Roundstart happens with SSblackbox.ReportRoundstartManifest
if(latejoin)
- SSblackbox.ReportManifest(ckey, body.real_name, mind.assigned_role.title, mind.special_role, latejoin)
+ SSblackbox.ReportManifest(ckey, body.real_name, mind.assigned_role.title, roles, latejoin)
diff --git a/code/__HELPERS/roundend.dm b/code/__HELPERS/roundend.dm
index c0de1b973a6..c8e9ffb88e6 100644
--- a/code/__HELPERS/roundend.dm
+++ b/code/__HELPERS/roundend.dm
@@ -371,15 +371,9 @@ GLOBAL_LIST_INIT(achievements_unlocked, list())
else
parts += "[FOURSPACES]Nobody died this shift!"
- parts += "[FOURSPACES]Threat level: [SSdynamic.threat_level]"
- parts += "[FOURSPACES]Threat left: [SSdynamic.mid_round_budget]"
- if(SSdynamic.roundend_threat_log.len)
- parts += "[FOURSPACES]Threat edits:"
- for(var/entry as anything in SSdynamic.roundend_threat_log)
- parts += "[FOURSPACES][FOURSPACES][entry] "
- parts += "[FOURSPACES]Executed rules:"
- for(var/datum/dynamic_ruleset/rule in SSdynamic.executed_rules)
- parts += "[FOURSPACES][FOURSPACES][rule.ruletype] - [rule.name]: -[rule.cost + rule.scaled_times * rule.scaling_cost] threat"
+ parts += "[FOURSPACES]Round: [SSdynamic.current_tier.name]"
+ for(var/datum/dynamic_ruleset/rule as anything in SSdynamic.executed_rulesets - SSdynamic.unreported_rulesets)
+ parts += "[FOURSPACES][FOURSPACES]- [rule.name] ([rule.config_tag])"
return parts.Join(" ")
diff --git a/code/controllers/subsystem/blackbox.dm b/code/controllers/subsystem/blackbox.dm
index 9d761f5322d..b4e67fe7f91 100644
--- a/code/controllers/subsystem/blackbox.dm
+++ b/code/controllers/subsystem/blackbox.dm
@@ -351,7 +351,7 @@ Versioning
"name" = L.real_name,
"key" = L.ckey,
"job" = L.mind.assigned_role.title,
- "special" = L.mind.special_role,
+ "special" = jointext(L.mind.get_special_roles(), " | "),
"pod" = get_area_name(L, TRUE),
"laname" = L.lastattacker,
"lakey" = L.lastattackerckey,
@@ -440,7 +440,7 @@ Versioning
"ckey" = mob_ckey,
"character_name" = new_character.real_name,
"job" = new_character.mind?.assigned_role?.title,
- "special" = new_character.mind?.special_role,
+ "special" = english_list(new_character.mind?.get_special_roles(), nothing_text = "NONE"),
"latejoin" = 0,
))
SSdbcore.MassInsert(format_table_name("manifest"), query_rows, special_columns = special_columns)
diff --git a/code/controllers/subsystem/dynamic/__dynamic_defines.dm b/code/controllers/subsystem/dynamic/__dynamic_defines.dm
new file mode 100644
index 00000000000..b22e7ff0798
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/__dynamic_defines.dm
@@ -0,0 +1,55 @@
+// Config values, don't change these randomly
+/// Configuring "roundstart" type rulesets
+#define ROUNDSTART "roundstart"
+/// Configuring "light midround" type rulesets
+#define LIGHT_MIDROUND "light_midround"
+/// Configuring "heavy midround" type rulesets
+#define HEAVY_MIDROUND "heavy_midround"
+/// Configuring "latejoin" type rulesets
+#define LATEJOIN "latejoin"
+
+/// Lower end for how many of a ruleset type can be selected
+#define LOW_END "low"
+/// Upper end for how many of a ruleset type can be selected
+#define HIGH_END "high"
+/// Population threshold for ruleset types - below this, only a quarter of the low to high end is used
+#define HALF_RANGE_POP_THRESHOLD "half_range_pop_threshold"
+/// Population threshold for ruleset types - below this, only a half of the low to high end is used
+#define FULL_RANGE_POP_THRESHOLD "full_range_pop_threshold"
+/// Round time threshold for which a ruleset type will be selected
+#define TIME_THRESHOLD "time_threshold"
+/// Lower end for cooldown duration for a ruleset type
+#define EXECUTION_COOLDOWN_LOW "execution_cooldown_low"
+/// Upper end for cooldown duration for a ruleset type
+#define EXECUTION_COOLDOWN_HIGH "execution_cooldown_high"
+
+// Tiers, don't change these randomly
+/// Tier 0, no antags at all
+#define DYNAMIC_TIER_GREEN 0
+/// Tier 1, low amount of antags
+#define DYNAMIC_TIER_LOW 1
+/// Tier 2, medium amount of antags
+#define DYNAMIC_TIER_LOWMEDIUM 2
+/// Tier 3, high amount of antags
+#define DYNAMIC_TIER_MEDIUMHIGH 3
+/// Tier 4, maximum amount of antags
+#define DYNAMIC_TIER_HIGH 4
+
+// Ruleset flags
+/// Ruleset denotes that it involves an outside force spawning in to attack the station
+#define RULESET_INVADER (1<<0)
+/// Multiple high impact rulesets cannot be selected unless we're at the highest tier
+#define RULESET_HIGH_IMPACT (1<<1)
+/// Ruleset can be configured by admins (implements /proc/configure_ruleset)
+/// Only implemented for midrounds currently
+#define RULESET_ADMIN_CONFIGURABLE (1<<2)
+
+/// Href for cancelling midround rulesets before execution
+#define MIDROUND_CANCEL_HREF(...) "(CANCEL)"
+/// Href for rerolling midround rulesets before execution
+#define MIDROUND_REROLL_HREF(rulesets) "[length(rulesets) \
+ ? "(SOMETHING ELSE)" \
+ : "([span_tooltip("There are no more rulesets to pick from!", "NOTHING ELSE")])"\
+]"
+
+#define RULESET_CONFIG_CANCEL "Cancel"
diff --git a/code/controllers/subsystem/dynamic/_dynamic_ruleset.dm b/code/controllers/subsystem/dynamic/_dynamic_ruleset.dm
new file mode 100644
index 00000000000..2ca15349339
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/_dynamic_ruleset.dm
@@ -0,0 +1,372 @@
+/**
+ * ## Dynamic ruleset datum
+ *
+ * These datums (which are not singletons) are used by dynamic to create antagonists
+ */
+/datum/dynamic_ruleset
+ /// Human-readable name of the ruleset.
+ var/name
+ /// Tag the ruleset uses for configuring.
+ /// Don't change this unless you know what you're doing.
+ var/config_tag
+
+ /// What flag to check for jobbans? Optional, if unset, uses pref_flag
+ var/jobban_flag
+ /// What flag to check for prefs? Required if the antag has an associated preference
+ var/pref_flag
+ /// Flags for this ruleset
+ var/ruleset_flags = NONE
+ /// Points to what antag datum this ruleset will use for generating a preview icon in the prefs menu
+ var/preview_antag_datum
+ /// List of all minds selected for this ruleset
+ VAR_FINAL/list/datum/mind/selected_minds = list()
+
+ /**
+ * The chance the ruleset is picked when selecting from the pool of rulesets.
+ *
+ * This can either be
+ * - A list of weight corresponding to dynamic tiers.
+ * If a tier is not specified, it will use the next highest tier.
+ * Or
+ * - A single weight for all tiers.
+ */
+ var/list/weight = 0
+ /**
+ * The min population for which this ruleset is available.
+ *
+ * This can either be
+ * - A list of min populations corresponding to dynamic tiers.
+ * If a tier is not specified, it will use the next highest tier.
+ * Or
+ * - A single min population for all tiers.
+ */
+ var/list/min_pop = 0
+ /// List of roles that are blacklisted from this ruleset
+ /// For roundstart rulesets, it will prevent players from being selected for this ruleset if they have one of these roles
+ /// For latejoin or midround rulesets, it will prevent players from being assigned to this ruleset if they have one of these roles
+ var/list/blacklisted_roles = list()
+ /**
+ * How many candidates are needed for this ruleset to be selected?
+ * Ie. "We won't even bother attempting to run this ruleset unless at least x players want to be it"
+ *
+ * This can either be
+ * - A number
+ * Or
+ * - A list in the form of list("denominator" = x, "offset" = y)
+ * which will divide the population size by x and add y to it to calculate the number of candidates
+ */
+ var/min_antag_cap = 1
+ /**
+ * How many candidates will be this ruleset try to select?
+ * Ie. "We have 10 cadidates, but we only want x of them to be antags"
+ *
+ * This can either be
+ * - A number
+ * Or
+ * - A list in the form of list("denominator" = x, "offset" = y)
+ * which will divide the population size by x and add y to it to calculate the number of candidates
+ *
+ * If null, defaults to min_antag_cap
+ */
+ var/max_antag_cap
+ /// If set to TRUE, dynamic will be able to draft this ruleset again later on
+ var/repeatable = FALSE
+ /// Every time this ruleset is selected, the weight will be decreased by this amount
+ var/repeatable_weight_decrease = 2
+ /// Players whose account is less than this many days old will be filtered out of the candidate list
+ var/minimum_required_age = 0
+ /// Templates necessary for this ruleset to be executed
+ VAR_PROTECTED/list/ruleset_lazy_templates
+
+/datum/dynamic_ruleset/New(list/dynamic_config)
+ for(var/new_var in dynamic_config?[config_tag])
+ set_config_value(new_var, dynamic_config[config_tag][new_var])
+
+/datum/dynamic_ruleset/Destroy()
+ selected_minds = null
+ return ..()
+
+/// Used for parsing config entries to validate them
+/datum/dynamic_ruleset/proc/set_config_value(new_var, new_val)
+ if(!(new_var in vars))
+ log_dynamic("Erroneous config edit rejected: [new_var]")
+ return FALSE
+ var/static/list/locked_config_values = list(
+ NAMEOF_STATIC(src, config_tag),
+ NAMEOF_STATIC(src, jobban_flag),
+ NAMEOF_STATIC(src, pref_flag),
+ NAMEOF_STATIC(src, preview_antag_datum),
+ NAMEOF_STATIC(src, ruleset_flags),
+ NAMEOF_STATIC(src, ruleset_lazy_templates),
+ NAMEOF_STATIC(src, selected_minds),
+ NAMEOF_STATIC(src, vars),
+ )
+
+ if(new_var in locked_config_values)
+ log_dynamic("Bad config edit rejected: [new_var]")
+ return FALSE
+ if(islist(new_val) && (new_var == NAMEOF(src, weight) || new_var == NAMEOF(src, min_pop)))
+ new_val = load_tier_list(new_val)
+
+ vars[new_var] = new_val
+ return TRUE
+
+/datum/dynamic_ruleset/vv_edit_var(var_name, var_value)
+ if(var_name == NAMEOF(src, config_tag))
+ return FALSE
+ return ..()
+
+/// Used to create tier lists for weights and min_pop values
+/datum/dynamic_ruleset/proc/load_tier_list(list/incoming_list)
+ PRIVATE_PROC(TRUE)
+
+ var/list/tier_list = new /list(4)
+ // loads a list of list("2" = 1, "3" = 3) into a list(null, 1, 3, null)
+ for(var/tier in incoming_list)
+ tier_list[text2num(tier)] = incoming_list[tier]
+
+ // turn list(null, 1, 3, null) into list(1, 1, 3, null)
+ for(var/i in 1 to length(tier_list))
+ var/val = tier_list[i]
+ if(isnum(val))
+ break
+ for(var/j in i to length(tier_list))
+ var/other_val = tier_list[j]
+ if(!isnum(other_val))
+ continue
+ tier_list[i] = other_val
+ break
+
+ // turn list(1, 1, 3, null) into list(1, 1, 3, 3)
+ for(var/i in length(tier_list) to 1 step -1)
+ var/val = tier_list[i]
+ if(isnum(val))
+ break
+ for(var/j in i to 1 step -1)
+ var/other_val = tier_list[j]
+ if(!isnum(other_val))
+ continue
+ tier_list[i] = other_val
+ break
+
+ // we can assert that tier[1] and tier[4] are not null, but we cannot say the same for tier[2] and tier[3]
+ // this can be happen due to the following setup: list(1, null, null, 4)
+ // (which is an invalid config, and should be fixed by the operator)
+ if(isnull(tier_list[2]))
+ tier_list[2] = tier_list[1]
+ if(isnull(tier_list[3]))
+ tier_list[3] = tier_list[4]
+
+ return tier_list
+
+/**
+ * Any additional checks to see if this ruleset can be selected
+ */
+/datum/dynamic_ruleset/proc/can_be_selected()
+ return TRUE
+
+/**
+ * Calculates the weight of this ruleset for the given tier.
+ *
+ * * population_size - How many players are alive
+ * * tier - The dynamic tier to calculate the weight for
+ */
+/datum/dynamic_ruleset/proc/get_weight(population_size = 0, tier = DYNAMIC_TIER_LOW)
+ SHOULD_NOT_OVERRIDE(TRUE)
+
+ if(type in SSdynamic.admin_disabled_rulesets)
+ return 0
+ if(!can_be_selected())
+ return 0
+ var/final_minpop = islist(min_pop) ? min_pop[tier] : min_pop
+ if(final_minpop > population_size)
+ return 0
+
+ var/final_weight = islist(weight) ? weight[tier] : weight
+ for(var/datum/dynamic_ruleset/other_ruleset as anything in SSdynamic.executed_rulesets)
+ if(other_ruleset == src)
+ continue
+ if(tier != DYNAMIC_TIER_HIGH && (ruleset_flags & RULESET_HIGH_IMPACT) && (other_ruleset.ruleset_flags & RULESET_HIGH_IMPACT))
+ return 0
+ if(!istype(other_ruleset, type))
+ continue
+ if(!repeatable)
+ return 0
+ final_weight -= repeatable_weight_decrease
+
+ return max(final_weight, 0)
+
+/// Returns what the antag cap with the given population is.
+/datum/dynamic_ruleset/proc/get_antag_cap(population_size, antag_cap)
+ SHOULD_NOT_OVERRIDE(TRUE)
+ if (isnum(antag_cap))
+ return antag_cap
+
+ return ceil(population_size / antag_cap["denominator"]) + antag_cap["offset"]
+
+/**
+ * Prepares the ruleset for execution, primarily used for selecting the players who will be assigned to this ruleset
+ *
+ * * antag_candidates - List of players who are candidates for this ruleset
+ * This list is mutated by this proc!
+ *
+ * Returns TRUE if execution is ready, FALSE if it should be canceled
+ */
+/datum/dynamic_ruleset/proc/prepare_execution(population_size = 0, list/mob/antag_candidates = list())
+ SHOULD_NOT_OVERRIDE(TRUE)
+
+ // !! THIS SLEEPS !!
+ load_templates()
+
+ // This is (mostly) redundant, buuuut the (potential) sleep above makes it iffy, so let's just be safe
+ if(!can_be_selected())
+ return FALSE
+
+ var/max_candidates = get_antag_cap(population_size, max_antag_cap || min_antag_cap)
+ var/min_candidates = get_antag_cap(population_size, min_antag_cap)
+
+ var/list/selected_candidates = select_candidates(antag_candidates, max_candidates)
+ if(length(selected_candidates) < min_candidates)
+ return FALSE
+
+ for(var/mob/candidate as anything in selected_candidates)
+ var/datum/mind/candidate_mind = get_candidate_mind(candidate)
+ prepare_for_role(candidate_mind)
+ LAZYADDASSOC(SSjob.prevented_occupations, candidate_mind, get_blacklisted_roles()) // this is what makes sure you can't roll traitor as a sec-off
+ selected_minds += candidate_mind
+ antag_candidates -= candidate
+
+ return TRUE
+
+/// Gets the mind of a candidate, can be overridden to return a different mind if necessary
+/datum/dynamic_ruleset/proc/get_candidate_mind(mob/dead/candidate)
+ return candidate.mind
+
+/// Returns a list of roles that cannot be selected for this ruleset
+/datum/dynamic_ruleset/proc/get_blacklisted_roles()
+ return get_config_blacklisted_roles() | get_always_blacklisted_roles()
+
+/// Returns all the jobs the config says this ruleset cannot select
+/datum/dynamic_ruleset/proc/get_config_blacklisted_roles()
+ SHOULD_NOT_OVERRIDE(TRUE)
+ var/list/blacklist = blacklisted_roles.Copy()
+ for(var/datum/job/job as anything in SSjob.all_occupations)
+ var/protected = (job.job_flags & JOB_ANTAG_PROTECTED)
+ var/blacklisted = (job.job_flags & JOB_ANTAG_BLACKLISTED)
+ if((CONFIG_GET(flag/protect_roles_from_antagonist) && protected) || blacklisted)
+ blacklist |= job.title
+ if(CONFIG_GET(flag/protect_assistant_from_antagonist))
+ blacklisted_roles |= JOB_ASSISTANT
+ return blacklist
+
+/// Returns a list of roles that are always blacklisted from this ruleset, for mechanical reasons (an AI can't be a changeling)
+/datum/dynamic_ruleset/proc/get_always_blacklisted_roles()
+ return list(
+ JOB_AI,
+ JOB_CYBORG,
+ )
+
+/// Takes in a list of players and returns a list of players who are valid candidates for this ruleset
+/// Don't touch this proc if you need to trim candidates further - override is_valid_candidate() instead
+/datum/dynamic_ruleset/proc/trim_candidates(list/mob/antag_candidates)
+ SHOULD_NOT_OVERRIDE(TRUE)
+
+ var/list/valid_candidates = list()
+ for(var/mob/candidate as anything in antag_candidates)
+ var/client/candidate_client = GET_CLIENT(candidate)
+ if(isnull(candidate_client))
+ continue
+ if(candidate_client.get_remaining_days(minimum_required_age) > 0)
+ continue
+ if(pref_flag && !(pref_flag in candidate_client.prefs.be_special))
+ continue
+ if(is_banned_from(candidate.ckey, list(ROLE_SYNDICATE, jobban_flag || pref_flag)))
+ continue
+ if(!is_valid_candidate(candidate, candidate_client))
+ continue
+ valid_candidates += candidate
+ return valid_candidates
+
+/// Returns a list of players picked for this ruleset
+/datum/dynamic_ruleset/proc/select_candidates(list/mob/antag_candidates, num_candidates = 0)
+ SHOULD_NOT_OVERRIDE(TRUE)
+ PRIVATE_PROC(TRUE)
+
+ if(num_candidates <= 0)
+ return list()
+
+ // technically not pure
+ var/list/resulting_candidates = shuffle(trim_candidates(antag_candidates)) || list()
+ if(length(resulting_candidates) <= num_candidates)
+ return resulting_candidates
+
+ resulting_candidates.Cut(num_candidates + 1)
+ return resulting_candidates
+
+/// Handles loading map templates that this ruleset requires
+/datum/dynamic_ruleset/proc/load_templates()
+ SHOULD_NOT_OVERRIDE(TRUE)
+ PRIVATE_PROC(TRUE)
+
+ for(var/template in ruleset_lazy_templates)
+ SSmapping.lazy_load_template(template)
+
+/**
+ * Any additional checks to see if this player is a valid candidate for this ruleset
+ */
+/datum/dynamic_ruleset/proc/is_valid_candidate(mob/candidate, client/candidate_client)
+ SHOULD_CALL_PARENT(TRUE)
+ return TRUE
+
+/**
+ * Handles any special logic that needs to be done for a player before they are assigned to this ruleset
+ * This is ran before the player is in their job position, and before they even have a player character
+ *
+ * Override this proc to do things like set forced jobs, DON'T assign roles or give out equipments here!
+ */
+/datum/dynamic_ruleset/proc/prepare_for_role(datum/mind/candidate)
+ PROTECTED_PROC(TRUE)
+ return
+
+/**
+ * Executes the ruleset, assigning the selected players to their roles.
+ * No backing out now, at this point it's guaranteed to run.
+ *
+ * Prefer to override assign_role() instead of this proc
+ */
+/datum/dynamic_ruleset/proc/execute()
+ var/list/execute_args = create_execute_args()
+ for(var/datum/mind/mind as anything in selected_minds)
+ assign_role(arglist(list(mind) + execute_args))
+
+/// Allows you to supply extra arguments to assign_role() if needed
+/datum/dynamic_ruleset/proc/create_execute_args()
+ return list()
+
+/**
+ * Used by the ruleset to actually assign the role to the player
+ * This is ran after they have a player character spawned, and after they're in their job (with all their job equipment)
+ *
+ * Override this proc to give out antag datums or special items or whatever
+ */
+/datum/dynamic_ruleset/proc/assign_role(datum/mind/candidate)
+ PROTECTED_PROC(TRUE)
+ stack_trace("Ruleset [src] does not implement assign_role()")
+ return
+
+/**
+ * Handles setting SSticker news report / mode result for more impactful rulsets
+ *
+ * Return TRUE if any result was set
+ */
+/datum/dynamic_ruleset/proc/round_result()
+ return FALSE
+
+/**
+ * Allows admins to configure rulesets before prepare_execution() is called.
+ *
+ * Only called if RULESET_ADMIN_CONFIGURABLE is set in ruleset_flags.
+ * Also only called by midrounds currently.
+ */
+/datum/dynamic_ruleset/proc/configure_ruleset(mob/admin)
+ stack_trace("Ruleset [type] sets flag RULESET_ADMIN_CONFIGURABLE but does not implement configure_ruleset!")
diff --git a/code/controllers/subsystem/dynamic/_dynamic_tier.dm b/code/controllers/subsystem/dynamic/_dynamic_tier.dm
new file mode 100644
index 00000000000..3d1fe57f17e
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/_dynamic_tier.dm
@@ -0,0 +1,316 @@
+/**
+ * ## Dynamic tier datum
+ *
+ * These datums are essentially used to configure the dynamic system
+ * They serve as a very simple way to see at a glance what dynamic is doing and what it is going to do
+ *
+ * For example, a tier will say "we will spawn 1-2 roundstart antags"
+ */
+/datum/dynamic_tier
+ /// Tier number - A number which determines the severity of the tier - the higher the number, the more antags
+ var/tier = -1
+ /// The human readable name of the tier
+ var/name
+ /// Tag the tier uses for configuring.
+ /// Don't change this unless you know what you're doing.
+ var/config_tag
+ /// The chance this tier will be selected from all tiers
+ /// Keep all tiers added up to 100 weight, keeps things readable
+ var/weight = 0
+ /// This tier will not be selected if the population is below this number
+ var/min_pop = 0
+
+ /// String which is sent to the players reporting which tier is active
+ var/advisory_report
+
+ /**
+ * How Dynamic will select rulesets based on the tier
+ *
+ * Every tier configures each of the ruleset types - ie, roundstart, light midround, heavy midround, latejoin
+ *
+ * Every type can be configured with the following:
+ * - LOW_END: The lower for how many of this ruleset type can be selected
+ * - HIGH_END: The upper for how many of this ruleset type can be selected
+ * - HALF_RANGE_POP_THRESHOLD: Below this population range, the high end is quartered
+ * - FULL_RANGE_POP_THRESHOLD: Below this population range, the high end is halved
+ *
+ * Non-roundstart ruleset types also have:
+ * - TIME_THRESHOLD: World time must pass this threshold before dynamic starts running this ruleset type
+ * - EXECUTION_COOLDOWN_LOW: The lower end for how long to wait before running this ruleset type again
+ * - EXECUTION_COOLDOWN_HIGH: The upper end for how long to wait before running this ruleset type again
+ */
+ var/list/ruleset_type_settings = list(
+ ROUNDSTART = list(
+ LOW_END = 0,
+ HIGH_END = 0,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 50,
+ TIME_THRESHOLD = 0 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 0 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 0 MINUTES,
+ ),
+ LIGHT_MIDROUND = list(
+ LOW_END = 0,
+ HIGH_END = 0,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 30 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ HEAVY_MIDROUND = list(
+ LOW_END = 0,
+ HIGH_END = 0,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 60 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ LATEJOIN = list(
+ LOW_END = 0,
+ HIGH_END = 0,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 0 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ )
+
+/datum/dynamic_tier/New(list/dynamic_config)
+ for(var/new_var in dynamic_config?[config_tag])
+ if(!(new_var in vars))
+ continue
+ set_config_value(new_var, dynamic_config[config_tag][new_var])
+
+/// Used for parsing config entries to validate them
+/datum/dynamic_tier/proc/set_config_value(new_var, new_val)
+ switch(new_var)
+ if(NAMEOF(src, tier), NAMEOF(src, config_tag), NAMEOF(src, vars))
+ return FALSE
+ if(NAMEOF(src, ruleset_type_settings))
+ for(var/category in new_val)
+ for(var/rule in new_val[category])
+ if(rule == LOW_END || rule == HIGH_END)
+ ruleset_type_settings[category][rule] = max(0, new_val[category][rule])
+ else if(rule == TIME_THRESHOLD || rule == EXECUTION_COOLDOWN_LOW || rule == EXECUTION_COOLDOWN_HIGH)
+ ruleset_type_settings[category][rule] = new_val[category][rule] * 1 MINUTES
+ else
+ ruleset_type_settings[category][rule] = new_val[category][rule]
+ return TRUE
+
+ vars[new_var] = new_val
+ return TRUE
+
+/datum/dynamic_tier/vv_edit_var(var_name, var_value)
+ switch(var_name)
+ if(NAMEOF(src, tier))
+ return FALSE
+
+ return ..()
+
+/datum/dynamic_tier/greenshift
+ tier = DYNAMIC_TIER_GREEN
+ config_tag = "Greenshift"
+ name = "Greenshift"
+ weight = 2
+
+ advisory_report = "Advisory Level: Green Star \
+ Your sector's advisory level is Green Star. \
+ Surveillance information shows no credible threats to Nanotrasen assets within the Spinward Sector at this time. \
+ As always, the Department advises maintaining vigilance against potential threats, regardless of a lack of known threats."
+
+/datum/dynamic_tier/low
+ tier = DYNAMIC_TIER_LOW
+ config_tag = "Low Chaos"
+ name = "Low Chaos"
+ weight = 8
+
+ advisory_report = "Advisory Level: Yellow Star \
+ Your sector's advisory level is Yellow Star. \
+ Surveillance shows a credible risk of enemy attack against our assets in the Spinward Sector. \
+ We advise a heightened level of security alongside maintaining vigilance against potential threats."
+
+ ruleset_type_settings = list(
+ ROUNDSTART = list(
+ LOW_END = 1,
+ HIGH_END = 1,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ ),
+ LIGHT_MIDROUND = list(
+ LOW_END = 0,
+ HIGH_END = 2,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 30 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ HEAVY_MIDROUND = list(
+ LOW_END = 0,
+ HIGH_END = 1,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 60 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ LATEJOIN = list(
+ LOW_END = 0,
+ HIGH_END = 1,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 5 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ )
+
+/datum/dynamic_tier/lowmedium
+ tier = DYNAMIC_TIER_LOWMEDIUM
+ config_tag = "Low-Medium Chaos"
+ name = "Low-Medium Chaos"
+ weight = 46
+
+ advisory_report = "Advisory Level: Red Star \
+ Your sector's advisory level is Red Star. \
+ The Department of Intelligence has decrypted Cybersun communications suggesting a high likelihood of attacks \
+ on Nanotrasen assets within the Spinward Sector. \
+ Stations in the region are advised to remain highly vigilant for signs of enemy activity and to be on high alert."
+
+ ruleset_type_settings = list(
+ ROUNDSTART = list(
+ LOW_END = 1,
+ HIGH_END = 2,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ ),
+ LIGHT_MIDROUND = list(
+ LOW_END = 0,
+ HIGH_END = 2,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 30 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ HEAVY_MIDROUND = list(
+ LOW_END = 0,
+ HIGH_END = 1,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 60 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ LATEJOIN = list(
+ LOW_END = 1,
+ HIGH_END = 2,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 5 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ )
+
+/datum/dynamic_tier/mediumhigh
+ tier = DYNAMIC_TIER_MEDIUMHIGH
+ config_tag = "Medium-High Chaos"
+ name = "Medium-High Chaos"
+ weight = 36
+
+ advisory_report = "Advisory Level: Black Orbit \
+ Your sector's advisory level is Black Orbit. \
+ Your sector's local communications network is currently undergoing a blackout, \
+ and we are therefore unable to accurately judge enemy movements within the region. \
+ However, information passed to us by GDI suggests a high amount of enemy activity in the sector, \
+ indicative of an impending attack. Remain on high alert and vigilant against any other potential threats."
+
+ ruleset_type_settings = list(
+ ROUNDSTART = list(
+ LOW_END = 2,
+ HIGH_END = 3,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ ),
+ LIGHT_MIDROUND = list(
+ LOW_END = 1,
+ HIGH_END = 2,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 30 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ HEAVY_MIDROUND = list(
+ LOW_END = 1,
+ HIGH_END = 2,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 60 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ LATEJOIN = list(
+ LOW_END = 1,
+ HIGH_END = 3,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 5 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ )
+
+/datum/dynamic_tier/high
+ tier = DYNAMIC_TIER_HIGH
+ config_tag = "High Chaos"
+ name = "High Chaos"
+ weight = 10
+
+ min_pop = 25
+
+ advisory_report = "Advisory Level: Midnight Sun \
+ Your sector's advisory level is Midnight Sun. \
+ Credible information passed to us by GDI suggests that the Syndicate \
+ is preparing to mount a major concerted offensive on Nanotrasen assets in the Spinward Sector to cripple our foothold there. \
+ All stations should remain on high alert and prepared to defend themselves."
+
+ ruleset_type_settings = list(
+ ROUNDSTART = list(
+ LOW_END = 3,
+ HIGH_END = 4,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ ),
+ LIGHT_MIDROUND = list(
+ LOW_END = 1,
+ HIGH_END = 2,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 20 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ HEAVY_MIDROUND = list(
+ LOW_END = 2,
+ HIGH_END = 4,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 30 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ LATEJOIN = list(
+ LOW_END = 2,
+ HIGH_END = 3,
+ HALF_RANGE_POP_THRESHOLD = 25,
+ FULL_RANGE_POP_THRESHOLD = 40,
+ TIME_THRESHOLD = 5 MINUTES,
+ EXECUTION_COOLDOWN_LOW = 10 MINUTES,
+ EXECUTION_COOLDOWN_HIGH = 20 MINUTES,
+ ),
+ )
diff --git a/code/controllers/subsystem/dynamic/dynamic.dm b/code/controllers/subsystem/dynamic/dynamic.dm
index 65ffc205b56..6fd7fd28972 100644
--- a/code/controllers/subsystem/dynamic/dynamic.dm
+++ b/code/controllers/subsystem/dynamic/dynamic.dm
@@ -1,306 +1,591 @@
-// 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)
-// How high threat is required for HIGH_IMPACT_RULESETs stacking.
-// This is independent of dynamic_no_stacking.
-GLOBAL_VAR_INIT(dynamic_stacking_limit, 90)
-// List of forced roundstart rulesets.
-GLOBAL_LIST_EMPTY(dynamic_forced_roundstart_ruleset)
-// Forced threat level, setting this to zero or higher forces the roundstart threat to the value.
-GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
-/// Modify the threat level for station traits before dynamic can be Initialized. List(instance = threat_reduction)
-GLOBAL_LIST_EMPTY(dynamic_station_traits)
-/// Rulesets which have been forcibly enabled or disabled
-GLOBAL_LIST_EMPTY(dynamic_forced_rulesets)
-/// Bitflags used during init by Dynamic to determine which rulesets we're allowed to use, used by station traits for gamemode-esque experiences
-GLOBAL_VAR_INIT(dynamic_ruleset_categories, RULESET_CATEGORY_DEFAULT)
-
SUBSYSTEM_DEF(dynamic)
name = "Dynamic"
flags = SS_NO_INIT
- wait = 1 SECONDS
+ wait = 5 MINUTES
- // Threat logging vars
- /// The "threat cap", threat shouldn't normally go above this and is used in ruleset calculations
- var/threat_level = 0
+ // These vars just exist for admins interfacing with dynamic
+ /// Cooldown between "we're going to spawn a midround" and "we're actually spawning a midround", to give admins a chance to cancel
+ COOLDOWN_DECLARE(midround_admin_cancel_period)
+ /// Set to TRUE by hrefs if admins cancel a midround
+ var/tmp/midround_admin_cancel = FALSE
+ /// Set to TRUE by hrefs if admins reroll a midround
+ var/tmp/midround_admin_reroll = FALSE
+ /// Set to TRUE by admin panels if they want to max out the chance of a light ruleset spawning
+ var/tmp/admin_forcing_next_light = FALSE
+ /// Set to TRUE by admin panels if they want to max out the chance of a heavy ruleset spawning
+ var/tmp/admin_forcing_next_heavy = FALSE
+ /// Set to TRUE by admin panels if they want to max out the chance of a latejoin ruleset spawning
+ var/tmp/admin_forcing_next_latejoin = FALSE
+ /// List of ruleset typepaths that admins have explicitly disabled
+ var/tmp/list/admin_disabled_rulesets = list()
- /// Set at the beginning of the round. Spent by the mode to "purchase" rules. Everything else goes in the postround budget.
- var/round_start_budget = 0
+ // Dynamic vars
+ /// Reference to a dynamic tier datum, the tier picked for this round
+ var/datum/dynamic_tier/current_tier
+ /// The config for dynamic loaded from the toml file
+ var/list/dynamic_config = list()
+ /// Tracks how many of each ruleset category is yet to be spawned
+ var/list/rulesets_to_spawn = list(
+ ROUNDSTART = -1,
+ LIGHT_MIDROUND = -1,
+ HEAVY_MIDROUND = -1,
+ LATEJOIN = -1,
+ )
+ /// Tracks the number of rulesets to spawn at game start (for admin reference)
+ var/list/base_rulesets_to_spawn = list(
+ ROUNDSTART = 0,
+ LIGHT_MIDROUND = 0,
+ HEAVY_MIDROUND = 0,
+ LATEJOIN = 0,
+ )
+ /// Cooldown for when we are allowed to spawn light rulesets
+ COOLDOWN_DECLARE(light_ruleset_start)
+ /// Cooldown for when we are allowed to spawn heavy rulesets
+ COOLDOWN_DECLARE(heavy_ruleset_start)
+ /// Cooldown for when we are allowed to spawn latejoin rulesets
+ COOLDOWN_DECLARE(latejoin_ruleset_start)
+ /// Tracks how many time we fail to spawn a latejoin (to up the odds next time)
+ var/failed_latejoins = 0
+ /// Cooldown between midround ruleset executions
+ COOLDOWN_DECLARE(midround_cooldown)
+ /// Cooldown between latejoin ruleset executions
+ COOLDOWN_DECLARE(latejoin_cooldown)
+ /// List of rulesets that have been executed this round
+ var/list/datum/dynamic_ruleset/executed_rulesets = list()
+ /// List of rulesets that have been set up to run, but not yet executed
+ var/list/datum/dynamic_ruleset/queued_rulesets = list()
+ /// Rulesets in this list will be excluded from the roundend report
+ var/list/datum/dynamic_ruleset/unreported_rulesets = list()
+ /// Whether random events that spawn antagonists or modify dynamic are enabled
+ var/antag_events_enabled = TRUE
- /// Set at the beginning of the round. Spent by midrounds and latejoins.
- var/mid_round_budget = 0
-
- /// The initial round start budget for logging purposes, set once at the beginning of the round.
- var/initial_round_start_budget = 0
-
- /// Running information about the threat. Can store text or datum entries.
- var/list/threat_log = list()
- /// Threat log shown on the roundend report. Should only list player-made edits.
- var/list/roundend_threat_log = list()
- /// List of latejoin rules used for selecting the rules.
- var/list/latejoin_rules
- /// List of midround rules used for selecting the rules.
- var/list/midround_rules
- /** # Pop range per requirement.
- * If the value is five the range is:
- * 0-4, 5-9, 10-14, 15-19, 20-24, 25-29, 30-34, 35-39, 40-54, 45+
- * If it is six the range is:
- * 0-5, 6-11, 12-17, 18-23, 24-29, 30-35, 36-41, 42-47, 48-53, 54+
- * If it is seven the range is:
- * 0-6, 7-13, 14-20, 21-27, 28-34, 35-41, 42-48, 49-55, 56-62, 63+
- */
- var/pop_per_requirement = 6
- /// Number of players who were ready on roundstart.
- var/roundstart_pop_ready = 0
- /// List of candidates used on roundstart rulesets.
- var/list/candidates = list()
- /// Rules that are processed, rule_process is called on the rules in this list.
- var/list/current_rules = list()
- /// List of executed rulesets.
- var/list/executed_rules = list()
- /// If TRUE, the next player to latejoin will guarantee roll for a random latejoin antag
- /// (this does not guarantee they get said antag roll, depending on preferences and circumstances)
- var/late_forced_injection = FALSE
- /// If TRUE, a midround ruleset will be rolled
- var/mid_forced_injection = FALSE
- /// Forced ruleset to be executed for the next latejoin.
- var/datum/dynamic_ruleset/latejoin/forced_latejoin_rule = null
- /// How many percent of the rounds are more peaceful.
- var/peaceful_percentage = 50
- /// If a high impact ruleset was executed. Only one will run at a time in most circumstances.
- var/high_impact_ruleset_executed = FALSE
- /// If a only ruleset has been executed.
- var/only_ruleset_executed = FALSE
- /// Dynamic configuration, loaded on pre_setup
- var/list/configuration = null
-
- /// When world.time is over this number the mode tries to inject a latejoin ruleset.
- var/latejoin_injection_cooldown = 0
-
- /// The minimum time the recurring latejoin ruleset timer is allowed to be.
- var/latejoin_delay_min = (5 MINUTES)
-
- /// The maximum time the recurring latejoin ruleset timer is allowed to be.
- var/latejoin_delay_max = (25 MINUTES)
-
- /// The low bound for the midround roll time splits.
- /// This number influences where to place midround rolls, making this smaller
- /// will make midround rolls more frequent, and vice versa.
- /// A midround will never be able to roll before this.
- var/midround_lower_bound = 10 MINUTES
-
- /// The upper bound for the midround roll time splits.
- /// This number influences where to place midround rolls, making this larger
- /// will make midround rolls less frequent, and vice versa.
- /// A midround will never be able to roll farther than this.
- var/midround_upper_bound = 100 MINUTES
-
- /// The distance between the chosen midround roll point (which is deterministic),
- /// and when it can actually roll.
- /// Basically, if this is set to 5 minutes, and a midround roll point is decided to be at 20 minutes,
- /// then it can roll anywhere between 15 and 25 minutes.
- var/midround_roll_distance = 3 MINUTES
-
- /// The amount of threat per midround roll.
- /// Basically, if this is set to 5, then for every 5 threat, one midround roll will be added.
- /// The equation this is used in rounds up, meaning that if this is set to 5, and you have 6
- /// threat, then you will get 2 midround rolls.
- var/threat_per_midround_roll = 7
-
- /// A number between -5 and +5.
- /// A negative value will give a more peaceful round and
- /// a positive value will give a round with higher threat.
- var/threat_curve_centre = 0
-
- /// A number between 0.5 and 4.
- /// Higher value will favour extreme rounds and
- /// lower value rounds closer to the average.
- var/threat_curve_width = 1.8
-
- /// A number between -5 and +5.
- /// Equivalent to threat_curve_centre, but for the budget split.
- /// A negative value will weigh towards midround rulesets, and a positive
- /// value will weight towards roundstart ones.
- var/roundstart_split_curve_centre = 1
-
- /// A number between 0.5 and 4.
- /// Equivalent to threat_curve_width, but for the budget split.
- /// Higher value will favour more variance in splits and
- /// lower value rounds closer to the average.
- var/roundstart_split_curve_width = 1.8
-
- /// The minimum amount of time for antag random events to be hijacked.
- var/random_event_hijack_minimum = 10 MINUTES
-
- /// The maximum amount of time for antag random events to be hijacked.
- var/random_event_hijack_maximum = 18 MINUTES
-
- /// What is the lower bound of when the roundstart announcement is sent out?
- var/waittime_l = 600
-
- /// What is the higher bound of when the roundstart announcement is sent out?
- var/waittime_h = 1800
-
- /// A number between 0 and 100. The maximum amount of threat allowed to generate.
- var/max_threat_level = 100
-
- /// The extra chance multiplier that a heavy impact midround ruleset will run next time.
- /// For example, if this is set to 50, then the next heavy roll will be about 50% more likely to happen.
- var/hijacked_random_event_injection_chance_modifier = 50
-
- /// Any midround before this point is guaranteed to be light
- var/midround_light_upper_bound = 25 MINUTES
-
- /// Any midround after this point is guaranteed to be heavy
- var/midround_heavy_lower_bound = 55 MINUTES
-
- /// If there are less than this many players readied, threat level will be lowered.
- /// This number should be kept fairly low, as there are other measures that population
- /// impacts Dynamic, such as the requirements variable on rulesets.
- var/low_pop_player_threshold = 20
-
- /// The maximum threat that can roll with *zero* players.
- /// As the number of players approaches `low_pop_player_threshold`, the maximum
- /// threat level will increase.
- /// For example, if `low_pop_maximum_threat` is 50, `low_pop_player_threshold` is 20,
- /// and the number of readied players is 10, then the highest threat that can roll is
- /// lerp(50, 100, 10 / 20), AKA 75.
- var/low_pop_maximum_threat = 40
-
- /// The chance for latejoins to roll when ready
- var/latejoin_roll_chance = 50
-
- // == EVERYTHING BELOW THIS POINT SHOULD NOT BE CONFIGURED ==
-
- /// A list of recorded "snapshots" of the round, stored in the dynamic.json log
- var/list/datum/dynamic_snapshot/snapshots
-
- /// The time when the last midround injection was attempted, whether or not it was successful
- var/last_midround_injection_attempt = 0
-
- /// Whether or not a random event has been hijacked this midround cycle
- var/random_event_hijacked = HIJACKED_NOTHING
-
- /// The timer ID for the cancellable midround rule injection
- var/midround_injection_timer_id
-
- /// The last drafted midround rulesets (without the current one included).
- /// Used for choosing different midround injections.
- var/list/current_midround_rulesets
-
- VAR_PRIVATE/next_midround_injection
-
-/datum/controller/subsystem/dynamic/proc/admin_panel()
- var/list/dat = list()
- dat += "Dynamic Mode VVRefresh "
- dat += "Threat Level: [threat_level] "
- dat += "Budgets (Roundstart/Midrounds): [initial_round_start_budget]/[threat_level - initial_round_start_budget] "
-
- dat += "Midround budget to spend: [mid_round_budget]AdjustView Log "
- dat += " "
- dat += "Parameters: centre = [threat_curve_centre] ; width = [threat_curve_width]. "
- dat += "Split parameters: centre = [roundstart_split_curve_centre] ; width = [roundstart_split_curve_width]. "
- dat += "On average, [clamp(peaceful_percentage, 1, 99)]% of the rounds are more peaceful. "
- dat += "Forced extended: [GLOB.dynamic_forced_extended ? "On" : "Off"] "
- dat += "No stacking (only one round-ender): [GLOB.dynamic_no_stacking ? "On" : "Off"] "
- dat += "Stacking limit: [GLOB.dynamic_stacking_limit] Adjust"
- dat += " "
- dat += "Force Next Latejoin Ruleset "
- if (forced_latejoin_rule)
- dat += {"-> [forced_latejoin_rule.name] <- "}
- dat += "Execute Midround Ruleset "
- dat += " "
- dat += "Executed rulesets: "
- if (executed_rules.len > 0)
- dat += " "
- for (var/datum/dynamic_ruleset/DR in executed_rules)
- dat += "[DR.ruletype] - [DR.name] "
- else
- dat += "none. "
- dat += " Injection Timers: ([get_heavy_midround_injection_chance(dry_run = TRUE)]% heavy midround chance) "
- dat += "Latejoin: [DisplayTimeText(latejoin_injection_cooldown-world.time)] Now! "
-
- var/next_injection = next_midround_injection()
- if (next_injection == INFINITY)
- dat += "All midrounds have been exhausted."
- else
- dat += "Midround: [DisplayTimeText(next_injection - world.time)] Now! "
-
- var/datum/browser/browser = new(usr, "gamemode_panel", "Game Mode Panel", 500, 500)
- browser.set_content(dat.Join())
- browser.open()
-
-/datum/controller/subsystem/dynamic/Topic(href, href_list)
- if (..()) // Sanity, maybe ?
+/datum/controller/subsystem/dynamic/fire(resumed)
+ if(!COOLDOWN_FINISHED(src, midround_cooldown) || EMERGENCY_PAST_POINT_OF_NO_RETURN)
return
- if(!check_rights(R_ADMIN))
- message_admins("[usr.key] has attempted to override the game mode panel!")
- log_admin("[key_name(usr)] tried to use the game mode panel without authorization.")
- return
- if (href_list["forced_extended"])
- GLOB.dynamic_forced_extended = !GLOB.dynamic_forced_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
- if(!threatadd)
+
+ if(COOLDOWN_FINISHED(src, light_ruleset_start))
+ if(try_spawn_midround(LIGHT_MIDROUND))
return
- if(threatadd > 0)
- create_threat(threatadd, threat_log, "[gameTimestamp()]: increased by [key_name(usr)]")
- else
- spend_midround_budget(-threatadd, threat_log, "[gameTimestamp()]: decreased by [key_name(usr)]")
- else if (href_list["injectlate"])
- latejoin_injection_cooldown = 0
- late_forced_injection = TRUE
- message_admins("[key_name(usr)] forced a latejoin injection.")
- else if (href_list["injectmid"])
- mid_forced_injection = TRUE
- message_admins("[key_name(usr)] forced a midround injection.")
- try_midround_roll()
- 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
- 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 sort_names(init_rulesets(/datum/dynamic_ruleset/latejoin))
- if (!added_rule)
+
+ if(COOLDOWN_FINISHED(src, heavy_ruleset_start))
+ if(try_spawn_midround(HEAVY_MIDROUND))
return
- forced_latejoin_rule = added_rule
- log_admin("[key_name(usr)] set [added_rule] to proc on the next latejoin.")
- message_admins("[key_name(usr)] set [added_rule] to proc on the next valid latejoin.")
- else if(href_list["clear_forced_latejoin"])
- forced_latejoin_rule = null
- 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 sort_names(init_rulesets(/datum/dynamic_ruleset/midround))
- if (!added_rule)
- return
- log_admin("[key_name(usr)] executed the [added_rule] ruleset.")
- message_admins("[key_name(usr)] executed the [added_rule] ruleset.")
- picking_specific_rule(added_rule, TRUE)
- else if(href_list["cancelmidround"])
- admin_cancel_midround(usr, href_list["cancelmidround"])
- return
- else if (href_list["differentmidround"])
- admin_different_midround(usr, href_list["differentmidround"])
+
+/datum/controller/subsystem/dynamic/proc/get_config()
+ if(!length(dynamic_config))
+ load_config()
+ return dynamic_config
+
+/**
+ * Selects which rulesets are to run at roundstart, and sets them up
+ *
+ * Note: This proc can sleep (due to lazyloading of templates)!
+ */
+/datum/controller/subsystem/dynamic/proc/select_roundstart_antagonists()
+ load_config()
+ SEND_SIGNAL(src, COMSIG_DYNAMIC_PRE_ROUNDSTART, dynamic_config)
+ // we start by doing a dry run of the job selection process to detect antag rollers
+ SSjob.divide_occupations(pure = TRUE, allow_all = TRUE)
+
+ var/list/antag_candidates = list()
+ // anyone who was readied up and NOT unassigned is a potential candidate (even those who have no antag preferences)
+ for(var/mob/dead/new_player/player as anything in GLOB.new_player_list - SSjob.unassigned)
+ if(player.ready == PLAYER_READY_TO_PLAY && player.mind)
+ antag_candidates += player
+
+ // anyone unassigned are potential antag rollers, so we need to warn them
+ for(var/mob/dead/new_player/player as anything in SSjob.unassigned)
+ var/list/job_data = list()
+ var/job_prefs = player.client?.prefs.job_preferences
+ for(var/job in job_prefs)
+ var/priority = job_prefs[job]
+ job_data += "[job]: [SSjob.job_priority_level_to_string(priority)]"
+ to_chat(player, span_danger("You were unable to qualify for any roundstart antagonist role this round \
+ because your job preferences presented a high chance of all of your selected jobs being unavailable, \
+ along with 'return to lobby if job is unavailable' enabled. \
+ Increase the number of roles set to medium or low priority to reduce the chances of this happening."))
+ log_admin("[player.ckey] failed to qualify for any roundstart antagonist role \
+ because their job preferences presented a high chance of all of their selected jobs being unavailable, \
+ along with 'return to lobby if job is unavailable' enabled and has [player.client.prefs.be_special.len] antag preferences enabled. \
+ They will be unable to qualify for any roundstart antagonist role. These are their job preferences - [job_data.Join(" | ")]")
+
+ var/num_real_players = length(antag_candidates)
+ // now select a tier (if admins didn't)
+ // this also calculates the number of rulesets to spawn
+ if(!current_tier)
+ pick_tier(num_real_players)
+ // put rulesets in the queue (if admins didn't)
+ // this will even handle the case in which the tier wants 0 roundstart rulesets
+ if(!length(queued_rulesets))
+ queued_rulesets += pick_roundstart_rulesets(antag_candidates)
+ // we got what we needed, reset so we can do real job selection later
+ // reset only happens AFTER roundstart selection so we can verify stuff like "can we get 3 heads of staff for revs?"
+ SSjob.reset_occupations()
+ // finally, run through the queue and prepare rulesets for execution
+ // (actual execution, ie assigning antags, will happen after job assignment)
+ for(var/datum/dynamic_ruleset/roundstart/ruleset in queued_rulesets)
+ // NOTE: !! THIS CAN SLEEP !!
+ if(!ruleset.prepare_execution( num_real_players, antag_candidates ))
+ log_dynamic("Roundstart: Selected ruleset [ruleset.config_tag], but preparation failed!")
+ queued_rulesets -= ruleset
+ qdel(ruleset)
+ continue
+
+ // Just logs who was selected at roundstart
+ for(var/datum/mind/selected as anything in ruleset.selected_minds)
+ log_dynamic("Roundstart: [key_name(selected)] has been selected for [ruleset.config_tag].")
+
+ rulesets_to_spawn[ROUNDSTART] -= 1
+ // and start ticking
+ COOLDOWN_START(src, light_ruleset_start, current_tier.ruleset_type_settings[LIGHT_MIDROUND][TIME_THRESHOLD])
+ COOLDOWN_START(src, heavy_ruleset_start, current_tier.ruleset_type_settings[HEAVY_MIDROUND][TIME_THRESHOLD])
+ COOLDOWN_START(src, latejoin_ruleset_start, current_tier.ruleset_type_settings[LATEJOIN][TIME_THRESHOLD])
+
+ return TRUE
+
+/datum/controller/subsystem/dynamic/proc/load_config()
+ PRIVATE_PROC(TRUE)
+
+ if(!CONFIG_GET(flag/dynamic_config_enabled))
return
- admin_panel() // Refreshes the window
+ var/config_file = "[global.config.directory]/dynamic.toml"
+ var/list/result = rustg_raw_read_toml_file(config_file)
+ if(!result["success"])
+ log_dynamic("Failed to load config file! ([config_file] - [result["content"]])")
+ return
+
+ dynamic_config = json_decode(result["content"])
+
+/// Sets the tier to the typepath passed in
+/datum/controller/subsystem/dynamic/proc/set_tier(picked_tier, population = length(GLOB.player_list))
+ current_tier = new picked_tier(dynamic_config)
+
+ for(var/category in current_tier.ruleset_type_settings)
+ var/list/range = current_tier.ruleset_type_settings[category] || list()
+ var/low_end = range[LOW_END] || 0
+ var/high_end = range[HIGH_END] || 0
+
+ if(population <= (range[HALF_RANGE_POP_THRESHOLD] || 0))
+ high_end = max(low_end, ceil(high_end * 0.25))
+ else if(population <= (range[FULL_RANGE_POP_THRESHOLD] || 0))
+ high_end = max(low_end, ceil(high_end * 0.5))
+
+ rulesets_to_spawn[category] = rand(low_end, high_end)
+ base_rulesets_to_spawn[category] = rulesets_to_spawn[category]
+
+/// Picks what tier we are going to use for this round and sets up all the corresponding variables and ranges
+/datum/controller/subsystem/dynamic/proc/pick_tier(roundstart_population = 0)
+ PRIVATE_PROC(TRUE)
+
+ var/list/tier_weighted = list()
+ for(var/datum/dynamic_tier/tier_datum as anything in subtypesof(/datum/dynamic_tier))
+ var/min_players_config = dynamic_config[tier_datum::config_tag]?[NAMEOF(tier_datum, min_pop)]
+ var/min_players = isnull(min_players_config) ? tier_datum::min_pop : min_players_config
+ if(roundstart_population < min_players)
+ continue
+
+ var/tier_config_weight = dynamic_config[tier_datum::config_tag]?[NAMEOF(tier_datum, weight)]
+ var/tier_weight = isnull(tier_config_weight) ? tier_datum::weight : tier_config_weight
+ if(tier_weight <= 0)
+ continue
+
+ tier_weighted[tier_datum] = tier_weight
+
+ set_tier(pick_weight(tier_weighted), roundstart_population)
+
+ var/roundstart_spawn = rulesets_to_spawn[ROUNDSTART]
+ var/light_midround_spawn = rulesets_to_spawn[LIGHT_MIDROUND]
+ var/heavy_midround_spawn = rulesets_to_spawn[HEAVY_MIDROUND]
+ var/latejoin_spawn = rulesets_to_spawn[LATEJOIN]
+
+ log_dynamic("Selected tier: [current_tier.tier]")
+ log_dynamic("- Roundstart population: [roundstart_population]")
+ log_dynamic("- Roundstart ruleset count: [roundstart_spawn]")
+ log_dynamic("- Light midround ruleset count: [light_midround_spawn]")
+ log_dynamic("- Heavy midround ruleset count: [heavy_midround_spawn]")
+ log_dynamic("- Latejoin ruleset count: [latejoin_spawn]")
+ SSblackbox.record_feedback(
+ "associative",
+ "dynamic_tier",
+ 1,
+ list(
+ "server_name" = CONFIG_GET(string/serversqlname),
+ "tier" = current_tier.tier,
+ "player_count" = roundstart_population,
+ "roundstart_ruleset_count" = roundstart_spawn,
+ "light_midround_ruleset_count" = light_midround_spawn,
+ "heavy_midround_ruleset_count" = heavy_midround_spawn,
+ "latejoin_ruleset_count" = latejoin_spawn,
+ ),
+ )
+
+/// Gets a weighted list of roundstart rulesets
+/datum/controller/subsystem/dynamic/proc/get_roundstart_rulesets(list/antag_candidates)
+ PRIVATE_PROC(TRUE)
+
+ var/list/datum/dynamic_ruleset/roundstart/rulesets = list()
+ for(var/ruleset_type in subtypesof(/datum/dynamic_ruleset/roundstart))
+ var/datum/dynamic_ruleset/roundstart/ruleset = new ruleset_type(dynamic_config)
+ rulesets[ruleset] = ruleset.get_weight(length(antag_candidates), current_tier.tier)
+
+ return rulesets
+
+/// Picks as many roundstart rulesets as we are allowed to spawn, returns them
+/datum/controller/subsystem/dynamic/proc/pick_roundstart_rulesets(list/antag_candidates)
+ PRIVATE_PROC(TRUE)
+
+ if(rulesets_to_spawn[ROUNDSTART] <= 0)
+ return list()
+
+ var/list/rulesets_weighted = get_roundstart_rulesets(antag_candidates)
+ var/total_weight = 0
+ for(var/ruleset in rulesets_weighted)
+ total_weight += rulesets_weighted[ruleset]
+ if(total_weight <= 0)
+ log_dynamic("Roundstart: No rulesets to pick from!")
+ return list()
+
+ var/list/picked_rulesets = list()
+ while(rulesets_to_spawn[ROUNDSTART] > 0)
+ if(!length(rulesets_weighted) || total_weight <= 0)
+ log_dynamic("Roundstart: No more rulesets to pick from with [rulesets_to_spawn[ROUNDSTART]] left!")
+ break
+ rulesets_to_spawn[ROUNDSTART] -= 1
+ var/datum/dynamic_ruleset/roundstart/picked_ruleset = pick_weight(rulesets_weighted)
+ log_dynamic("Roundstart: Ruleset [picked_ruleset.config_tag] (Chance: [round(rulesets_weighted[picked_ruleset] / total_weight * 100, 0.01)]%)")
+ if(picked_ruleset.solo)
+ log_dynamic("Roundstart: Ruleset is a solo ruleset. Cancelling other picks.")
+ QDEL_LIST(picked_rulesets)
+ rulesets_weighted -= picked_ruleset
+ picked_rulesets += picked_ruleset
+ break
+ if(!picked_ruleset.repeatable)
+ rulesets_weighted -= picked_ruleset
+ picked_rulesets += picked_ruleset
+ continue
+
+ rulesets_weighted[picked_ruleset] -= picked_ruleset.repeatable_weight_decrease
+ total_weight -= picked_ruleset.repeatable_weight_decrease
+ // Rulesets are not singletons. We need to to make a new one
+ picked_rulesets += new picked_ruleset.type(dynamic_config)
+
+ // clean up unused rulesets
+ QDEL_LIST(rulesets_weighted)
+ return picked_rulesets
+
+/datum/controller/subsystem/dynamic/proc/get_advisory_report()
+ var/shown_tier = current_tier.tier
+ if(prob(10))
+ shown_tier = pick(list(DYNAMIC_TIER_LOW, DYNAMIC_TIER_LOWMEDIUM, DYNAMIC_TIER_MEDIUMHIGH, DYNAMIC_TIER_HIGH) - current_tier.tier)
+
+ else if(prob(15))
+ shown_tier = clamp(current_tier.tier + pick(-1, 1), DYNAMIC_TIER_LOW, DYNAMIC_TIER_HIGH)
+
+ for(var/datum/dynamic_tier/tier_datum as anything in subtypesof(/datum/dynamic_tier))
+ if(tier_datum::tier == shown_tier)
+ return tier_datum::advisory_report
+
+ return null
+
+/**
+ * Invoked by SSdynamic to try to spawn a random midround ruleset
+ * Respects ranges and thresholds
+ *
+ * Prioritizes light midround rulesets first, then heavy midround rulesets
+ *
+ * Returns TRUE if a ruleset was spawned, FALSE otherwise
+ */
+/datum/controller/subsystem/dynamic/proc/try_spawn_midround(range)
+ if(rulesets_to_spawn[range] <= 0)
+ return FALSE
+ var/midround_chance = get_midround_chance(range)
+ if(!prob(midround_chance))
+ log_dynamic("Midround ([range]): Ruleset chance failed ([midround_chance]% chance)")
+ return FALSE
+
+ midround_admin_cancel = FALSE
+ midround_admin_reroll = FALSE
+ COOLDOWN_RESET(src, midround_admin_cancel_period)
+
+ var/player_count = get_active_player_count(afk_check = TRUE)
+ var/list/rulesets_weighted = get_midround_rulesets(player_count, range)
+ var/datum/dynamic_ruleset/midround/picked_ruleset = pick_weight(rulesets_weighted)
+ if(isnull(picked_ruleset))
+ log_dynamic("Midround ([range]): No rulesets to pick from!")
+ return FALSE
+ message_admins("Midround ([range]): Executing [picked_ruleset.config_tag] \
+ [MIDROUND_CANCEL_HREF()] [MIDROUND_REROLL_HREF(rulesets_weighted)]")
+ // if we have admins online, we have a waiting period before execution to allow them to cancel or reroll
+ if(length(GLOB.admins))
+ COOLDOWN_START(src, midround_admin_cancel_period, 15 SECONDS)
+ while(!COOLDOWN_FINISHED(src, midround_admin_cancel_period))
+ if(midround_admin_cancel)
+ QDEL_LIST(rulesets_weighted)
+ COOLDOWN_START(src, midround_cooldown, get_ruleset_cooldown(range))
+ return FALSE
+ if(midround_admin_reroll && length(rulesets_weighted) >= 2)
+ midround_admin_reroll = FALSE
+ COOLDOWN_START(src, midround_admin_cancel_period, 15 SECONDS)
+ rulesets_weighted -= picked_ruleset
+ qdel(picked_ruleset)
+ picked_ruleset = pick_weight(rulesets_weighted)
+ if(isnull(picked_ruleset))
+ log_dynamic("Midround ([range]): No rulesets to pick from!")
+ message_admins("Rerolling Midround ([range]): Failed to pick a new ruleset, cancelling instead!")
+ midround_admin_cancel = TRUE
+ continue
+ message_admins("Rerolling Midround ([range]): Executing [picked_ruleset.config_tag] - \
+ [length(rulesets_weighted) - 1] remaining rulesets in pool. [MIDROUND_CANCEL_HREF()] [MIDROUND_REROLL_HREF(rulesets_weighted)]")
+ stoplag()
+
+ // NOTE: !! THIS CAN SLEEP !!
+ if(!picked_ruleset.prepare_execution(player_count, picked_ruleset.collect_candidates()))
+ log_dynamic("Midround ([range]): Selected ruleset [picked_ruleset.config_tag], but preparation failed!")
+ QDEL_LIST(rulesets_weighted)
+ return FALSE
+ // Run the thing
+ executed_rulesets += picked_ruleset
+ rulesets_weighted -= picked_ruleset
+ picked_ruleset.execute()
+ // Post execute logging
+ for(var/datum/mind/selected as anything in picked_ruleset.selected_minds)
+ message_admins("Midround ([range]): [ADMIN_LOOKUPFLW(selected.current)] has been selected for [picked_ruleset.config_tag].")
+ log_dynamic("Midround ([range]): [key_name(selected.current)] has been selected for [picked_ruleset.config_tag].")
+ notify_ghosts("[selected.name] has been picked for [picked_ruleset.config_tag]!", source = selected.current)
+ // Clean up unused rulesets
+ QDEL_LIST(rulesets_weighted)
+ rulesets_to_spawn[range] -= 1
+ if(range == LIGHT_MIDROUND)
+ admin_forcing_next_light = FALSE
+ if(range == HEAVY_MIDROUND)
+ admin_forcing_next_heavy = FALSE
+ COOLDOWN_START(src, midround_cooldown, get_ruleset_cooldown(range))
+ return TRUE
+
+/// Gets a weighted list of midround rulesets
+/datum/controller/subsystem/dynamic/proc/get_midround_rulesets(player_count, midround_type)
+ PRIVATE_PROC(TRUE)
+
+ var/list/datum/dynamic_ruleset/midround/rulesets = list()
+ for(var/datum/dynamic_ruleset/midround/ruleset_type as anything in subtypesof(/datum/dynamic_ruleset/midround))
+ if(initial(ruleset_type.midround_type) != midround_type)
+ continue
+ var/datum/dynamic_ruleset/midround/ruleset = new ruleset_type(dynamic_config)
+ rulesets[ruleset] = ruleset.get_weight(player_count, current_tier.tier)
+
+ return rulesets
+
+/**
+ * Attempt to run a midround ruleset of the given type
+ *
+ * * midround_type - The type of midround ruleset to force
+ * * forced_max_cap - Rather than using the ruleset's max antag cap, use this value
+ * As an example, this allows you to only spawn 1 traitor rather than the ruleset's default of 3
+ * Can't be set to 0 (why are you forcing a ruleset that spawns 0 antags?)
+ * * alert_admins_on_fail - If TRUE, alert admins if the ruleset fails to prepare/execute
+ * * mob/admin - The admin who is forcing the ruleset, used for configuring the ruleset if possible
+ */
+/datum/controller/subsystem/dynamic/proc/force_run_midround(midround_typepath, forced_max_cap, alert_admins_on_fail = FALSE, mob/admin)
+ if(!ispath(midround_typepath, /datum/dynamic_ruleset/midround))
+ CRASH("force_run_midround() was called with an invalid midround type: [midround_typepath]")
+
+ var/datum/dynamic_ruleset/midround/running = new midround_typepath(dynamic_config)
+ if(isnum(forced_max_cap) && forced_max_cap > 0)
+ running.min_antag_cap = min(forced_max_cap, running.min_antag_cap)
+ running.max_antag_cap = forced_max_cap
+
+ if(admin && (running.ruleset_flags & RULESET_ADMIN_CONFIGURABLE))
+ if(running.configure_ruleset(admin) == RULESET_CONFIG_CANCEL)
+ qdel(running)
+ return FALSE
+
+ // NOTE: !! THIS CAN SLEEP !!
+ if(!running.prepare_execution(get_active_player_count(afk_check = TRUE), running.collect_candidates()))
+ if(alert_admins_on_fail)
+ message_admins("Midround (forced): Forced ruleset [running.config_tag], but preparation failed!")
+ log_dynamic("Midround (forced): Forced ruleset [running.config_tag], but preparation failed!")
+ qdel(running)
+ return FALSE
+
+ executed_rulesets += running
+ running.execute()
+ // Post execute logging
+ for(var/datum/mind/selected as anything in running.selected_minds)
+ message_admins("Midround (forced): [ADMIN_LOOKUPFLW(selected.current)] has been selected for [running.config_tag].")
+ log_dynamic("Midround (forced): [key_name(selected.current)] has been selected for [running.config_tag].")
+ notify_ghosts("[selected.name] has been picked for [running.config_tag]!", source = selected.current)
+ return TRUE
+
+/**
+ * Called when someone latejoins
+ * (This could be a signal in the future)
+ */
+/datum/controller/subsystem/dynamic/proc/on_latejoin(mob/living/carbon/human/latejoiner)
+ // First check queued rulesets - queued rulesets by pass cooldowns and probability checks,
+ // because they're generally forced by events or admins (and thus have higher priority)
+ for(var/datum/dynamic_ruleset/latejoin/queued in queued_rulesets)
+ // NOTE: !! THIS CAN SLEEP !!
+ if(!queued.prepare_execution(get_active_player_count(afk_check = TRUE), list(latejoiner)))
+ message_admins("Latejoin (forced): Queued ruleset [queued.config_tag] failed to prepare! It remains queued for next latejoin. (REMOVE FROM QUEUE)")
+ log_dynamic("Latejoin (forced): Queued ruleset [queued.config_tag] failed to prepare! It remains queued for next latejoin.")
+ continue
+ message_admins("Latejoin (forced): [ADMIN_LOOKUPFLW(latejoiner)] has been selected for [queued.config_tag].")
+ log_dynamic("Latejoin (forced): [key_name(latejoiner)] has been selected for [queued.config_tag].")
+ queued_rulesets -= queued
+ executed_rulesets += queued
+ queued.execute()
+ return
+
+ if(COOLDOWN_FINISHED(src, latejoin_ruleset_start) && COOLDOWN_FINISHED(src, latejoin_cooldown))
+ if(try_spawn_latejoin(latejoiner))
+ return
+
+/**
+ * Invoked by SSdynamic to try to spawn a latejoin ruleset
+ * Respects ranges and thresholds
+ *
+ * Returns TRUE if a ruleset was spawned, FALSE otherwise
+ */
+/datum/controller/subsystem/dynamic/proc/try_spawn_latejoin(mob/living/carbon/human/latejoiner)
+
+ if(rulesets_to_spawn[LATEJOIN] <= 0)
+ return FALSE
+ var/latejoin_chance = get_latejoin_chance()
+ if(!prob(latejoin_chance))
+ log_dynamic("Latejoin: Ruleset chance failed ([latejoin_chance]% chance)")
+ return FALSE
+
+ var/player_count = get_active_player_count(afk_check = TRUE)
+ var/list/rulesets_weighted = get_latejoin_rulesets(player_count)
+ // Note, we make no effort to actually pick a valid ruleset here
+ // We pick a ruleset, and they player might not even have that antag selected. And that's fine
+ var/datum/dynamic_ruleset/latejoin/picked_ruleset = pick_weight(rulesets_weighted)
+ if(isnull(picked_ruleset))
+ log_dynamic("Latejoin: No rulesets to pick from!")
+ return FALSE
+ // NOTE: !! THIS CAN SLEEP !!
+ if(!picked_ruleset.prepare_execution(player_count, list(latejoiner)))
+ log_dynamic("Latejoin: Selected ruleset [picked_ruleset.name] for [key_name(latejoiner)], but preparation failed! Latejoin chance has increased.")
+ QDEL_LIST(rulesets_weighted)
+ failed_latejoins++
+ return FALSE
+ // Run the thing
+ executed_rulesets += picked_ruleset
+ rulesets_weighted -= picked_ruleset
+ picked_ruleset.execute()
+ // Post execute logging
+ if(!(latejoiner.mind in picked_ruleset.selected_minds))
+ stack_trace("Dynamic: Latejoin [picked_ruleset.type] executed, but the latejoiner was not in its selected minds list!")
+ message_admins("Latejoin: [ADMIN_LOOKUPFLW(latejoiner)] has been selected for [picked_ruleset.config_tag].")
+ log_dynamic("Latejoin: [key_name(latejoiner)] has been selected for [picked_ruleset.config_tag].")
+ // Clean up unused rulesets
+ QDEL_LIST(rulesets_weighted)
+ rulesets_to_spawn[LATEJOIN] -= 1
+ failed_latejoins = 0
+ admin_forcing_next_latejoin = FALSE
+ COOLDOWN_START(src, latejoin_cooldown, get_ruleset_cooldown(LATEJOIN))
+ return TRUE
+
+/// Gets a weighted list of latejoin rulesets
+/datum/controller/subsystem/dynamic/proc/get_latejoin_rulesets(player_count)
+ PRIVATE_PROC(TRUE)
+
+ var/list/datum/dynamic_ruleset/latejoin/rulesets = list()
+ for(var/ruleset_type in subtypesof(/datum/dynamic_ruleset/latejoin))
+ var/datum/dynamic_ruleset/latejoin/ruleset = new ruleset_type(dynamic_config)
+ rulesets[ruleset] = ruleset.get_weight(player_count, current_tier.tier)
+
+ return rulesets
+
+/**
+ * Queues a ruleset to run on roundstart or next latejoin which fulfills all requirements
+ *
+ * For example, if you queue a latejoin revolutionary, it'll only run when population gets large enough and there are enough heads of staff
+ * For all latejoins until then, it will simply do nothing
+ *
+ * * latejoin_type - The type of latejoin ruleset to force
+ */
+/datum/controller/subsystem/dynamic/proc/queue_ruleset(ruleset_typepath)
+ if(!ispath(ruleset_typepath, /datum/dynamic_ruleset/latejoin) && !ispath(ruleset_typepath, /datum/dynamic_ruleset/roundstart))
+ CRASH("queue_ruleset() was called with an invalid type: [ruleset_typepath]")
+
+ queued_rulesets += new ruleset_typepath(dynamic_config)
+
+/**
+ * Get the cooldown between attempts to spawn a ruleset of the given type
+ */
+/datum/controller/subsystem/dynamic/proc/get_ruleset_cooldown(range)
+ if(range == ROUNDSTART)
+ stack_trace("Attempting to get cooldown for roundstart rulesets - this is redundant and is likely an error")
+ return 0
+
+ var/low = current_tier.ruleset_type_settings[range][EXECUTION_COOLDOWN_LOW] || 0
+ var/high = current_tier.ruleset_type_settings[range][EXECUTION_COOLDOWN_HIGH] || 0
+ return rand(low, high)
+
+/**
+ * Gets the chance of a midround ruleset being selected
+ */
+/datum/controller/subsystem/dynamic/proc/get_midround_chance(range)
+ if(admin_forcing_next_light && range == LIGHT_MIDROUND)
+ return 100
+ if(admin_forcing_next_heavy && range == HEAVY_MIDROUND)
+ return 100
+
+ var/chance = 0
+ var/num_antags = length(GLOB.current_living_antags)
+ var/num_dead = length(GLOB.dead_player_list)
+ var/num_alive = get_active_player_count(afk_check = TRUE)
+ if(num_dead + num_alive <= 0)
+ return 0
+
+ chance += 100 - (200 * (num_dead / (num_alive + num_dead)))
+ if(num_antags < 0)
+ chance += 50
+
+ return chance
+
+/**
+ * Gets the chance of a latejoin ruleset being selected
+ */
+/datum/controller/subsystem/dynamic/proc/get_latejoin_chance()
+ if(admin_forcing_next_latejoin)
+ return 100
+
+ var/chance = 0
+ var/num_antags = length(GLOB.current_living_antags)
+ var/num_dead = length(GLOB.dead_player_list)
+ var/num_alive = get_active_player_count(afk_check = TRUE)
+ if(num_dead + num_alive <= 0)
+ return 0
+
+ chance += 100 - (200 * (num_dead / (num_alive + num_dead)))
+ if(num_antags < 0)
+ chance += 50
+ chance += (failed_latejoins * 15)
+ // Reduced chance before lights start
+ if(!COOLDOWN_FINISHED(src, light_ruleset_start))
+ chance *= 0.2
+
+ return chance
-// Set result and news report here
/datum/controller/subsystem/dynamic/proc/set_round_result()
// If it got to this part, just pick one high impact ruleset if it exists
- for(var/datum/dynamic_ruleset/rule in executed_rules)
- if(rule.flags & HIGH_IMPACT_RULESET)
- rule.round_result()
- // One was set, so we're done here
- if(SSticker.news_report)
- return
+ for(var/datum/dynamic_ruleset/rule as anything in executed_rulesets)
+ if(rule.round_result())
+ return
SSticker.mode_result = "undefined"
+ switch(GLOB.revolution_handler?.result)
+ if(STATION_VICTORY)
+ SSticker.mode_result = "loss - rev heads killed"
+ SSticker.news_report = REVS_LOSE
+ if(REVOLUTION_VICTORY)
+ SSticker.mode_result = "win - heads killed"
+ SSticker.news_report = REVS_WIN
+
// Something nuked the station - it wasn't nuke ops (they set their own via their rulset)
if(GLOB.station_was_nuked)
SSticker.news_report = STATION_NUKED
@@ -312,717 +597,121 @@ SUBSYSTEM_DEF(dynamic)
if(EMERGENCY_ESCAPED_OR_ENDGAMED && !SSticker.news_report)
SSticker.news_report = SSshuttle.emergency?.is_hijacked() ? SHUTTLE_HIJACK : STATION_EVACUATED
-/datum/controller/subsystem/dynamic/proc/send_intercept()
- /*if(GLOB.communications_controller.block_command_report) //If we don't want the report to be printed just yet, we put it off until it's ready
- addtimer(CALLBACK(src, PROC_REF(send_intercept)), 10 SECONDS)
+/// Helper to clear all queued rulesets and stop any other rulesets from naturally spawning
+/datum/controller/subsystem/dynamic/proc/force_extended()
+ for(var/category in rulesets_to_spawn)
+ rulesets_to_spawn[category] = 0
+ QDEL_LIST(queued_rulesets)
+
+/datum/controller/subsystem/dynamic/Topic(href, list/href_list)
+ . = ..()
+ if(href_list["admin_dequeue"])
+ if(!check_rights(R_ADMIN))
+ return
+ var/datum/dynamic_ruleset/to_remove = locate(href_list["admin_dequeue"]) in queued_rulesets
+ if(!istype(to_remove))
+ return
+ queued_rulesets -= to_remove
+ qdel(to_remove)
+ message_admins(span_adminnotice("[key_name_admin(usr)] [to_remove.config_tag] from the latejoin queue."))
+ log_admin("[key_name(usr)] removed [to_remove.config_tag] from the latejoin queue.")
return
- . = "Nanotrasen Department of Intelligence Threat Advisory, Spinward Sector, TCD [time2text(world.realtime, "DDD, MMM DD", NO_TIMEZONE)], [CURRENT_STATION_YEAR]:
" + footnote_pile
-
-#ifndef MAP_TEST
- print_command_report(., "[command_name()] Status Summary", announce=FALSE)
- if(greenshift)
- priority_announce("Thanks to the tireless efforts of our security and intelligence divisions, there are currently no credible threats to [station_name()]. All station construction projects have been authorized. Have a secure shift!", "Security Report", SSstation.announcer.get_rand_report_sound(), color_override = "green")
- else
- if(SSsecurity_level.get_current_level_as_number() < SEC_LEVEL_BLUE)
- SSsecurity_level.set_level(SEC_LEVEL_BLUE, announce = FALSE)
- priority_announce("[SSsecurity_level.current_security_level.elevating_to_announcement]\n\nA summary has been copied and printed to all communications consoles.", "Security level elevated.", ANNOUNCER_INTERCEPT, color_override = SSsecurity_level.current_security_level.announcement_color)
-#endif*/ // BUBBER EDIT END
-
- return .
-
-/// Generate the advisory level depending on the shown threat level.
-/datum/controller/subsystem/dynamic/proc/generate_advisory_level()
- var/advisory_string = ""
- switch(round(threat_level))
- if(0 to 65)
- advisory_string += "Advisory Level: Yellow Star "
- advisory_string += "Your sector's advisory level is Yellow Star. Surveillance shows a credible risk of enemy attack against our assets in the Spinward Sector. We advise a heightened level of security alongside maintaining vigilance against potential threats."
- if(66 to 79)
- advisory_string += "Advisory Level: Red Star "
- advisory_string += "Your sector's advisory level is Red Star. The Department of Intelligence has decrypted Cybersun communications suggesting a high likelihood of attacks on Nanotrasen assets within the Spinward Sector. Stations in the region are advised to remain highly vigilant for signs of enemy activity and to be on high alert."
- if(80 to 99)
- advisory_string += "Advisory Level: Black Orbit "
- advisory_string += "Your sector's advisory level is Black Orbit. Your sector's local communications network is currently undergoing a blackout, and we are therefore unable to accurately judge enemy movements within the region. However, information passed to us by GDI suggests a high amount of enemy activity in the sector, indicative of an impending attack. Remain on high alert and vigilant against any other potential threats."
- if(100)
- advisory_string += "Advisory Level: Midnight Sun "
- advisory_string += "Your sector's advisory level is Midnight Sun. Credible information passed to us by GDI suggests that the Syndicate is preparing to mount a major concerted offensive on Nanotrasen assets in the Spinward Sector to cripple our foothold there. All stations should remain on high alert and prepared to defend themselves."
-
- return advisory_string
-
-/datum/controller/subsystem/dynamic/proc/show_threatlog(mob/admin)
- if(!SSticker.HasRoundStarted())
- tgui_alert(usr, "The round hasn't started yet!")
- return
-
- if(!check_rights(R_ADMIN))
- return
-
- var/list/out = list("Threat Log Starting Threat: [threat_level] ")
-
- for(var/entry in threat_log)
- if(istext(entry))
- out += "[entry] "
-
- out += "Remaining threat/threat_level: [mid_round_budget]/[threat_level]"
-
- usr << browse(HTML_SKELETON_TITLE("Threat Log", out.Join()), "window=threatlog;size=700x500")
-
-/// Generates the threat level using lorentz distribution and assigns peaceful_percentage.
-/datum/controller/subsystem/dynamic/proc/generate_threat()
- // At lower pop levels we run a Liner Interpolation against the max threat based proportionally on the number
- // of players ready. This creates a balanced lorentz curve within a smaller range than 0 to max_threat_level.
- var/calculated_max_threat = (SSticker.totalPlayersReady < low_pop_player_threshold) ? LERP(low_pop_maximum_threat, max_threat_level, SSticker.totalPlayersReady / low_pop_player_threshold) : max_threat_level
- log_dynamic("Calculated maximum threat level based on player count of [SSticker.totalPlayersReady]: [calculated_max_threat]")
-
- threat_level = lorentz_to_amount(threat_curve_centre, threat_curve_width, calculated_max_threat)
-
- for(var/datum/station_trait/station_trait in GLOB.dynamic_station_traits)
- threat_level = max(threat_level - GLOB.dynamic_station_traits[station_trait], 0)
- log_dynamic("Threat reduced by [GLOB.dynamic_station_traits[station_trait]]. Source: [type].")
-
- peaceful_percentage = (threat_level/max_threat_level)*100
-
-/// Generates the midround and roundstart budgets
-/datum/controller/subsystem/dynamic/proc/generate_budgets()
- round_start_budget = lorentz_to_amount(roundstart_split_curve_centre, roundstart_split_curve_width, threat_level, 0.1)
- initial_round_start_budget = round_start_budget
- mid_round_budget = threat_level - round_start_budget
-
-/datum/controller/subsystem/dynamic/proc/setup_parameters()
- log_dynamic("Dynamic mode parameters for the round:")
- log_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_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)
- else
- generate_threat()
- generate_budgets()
- set_cooldowns()
- log_dynamic("Dynamic Mode initialized with a Threat Level of... [threat_level]! ([round_start_budget] round start budget)")
- SSblackbox.record_feedback(
- "associative",
- "dynamic_threat",
- 1,
- list(
- "server_name" = CONFIG_GET(string/serversqlname),
- "forced_threat_level" = GLOB.dynamic_forced_threat_level,
- "threat_level" = threat_level,
- "max_threat" = (SSticker.totalPlayersReady < low_pop_player_threshold) ? LERP(low_pop_maximum_threat, max_threat_level, SSticker.totalPlayersReady / low_pop_player_threshold) : max_threat_level,
- "player_count" = SSticker.totalPlayersReady,
- "round_start_budget" = round_start_budget,
- "parameters" = list(
- "threat_curve_centre" = threat_curve_centre,
- "threat_curve_width" = threat_curve_width,
- "forced_extended" = GLOB.dynamic_forced_extended,
- "no_stacking" = GLOB.dynamic_no_stacking,
- "stacking_limit" = GLOB.dynamic_stacking_limit,
- ),
- ),
- )
- return TRUE
-
-
-/datum/controller/subsystem/dynamic/proc/set_cooldowns()
- 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
-
-// Called BEFORE everyone is equipped with their job
-/datum/controller/subsystem/dynamic/proc/pre_setup()
- if(CONFIG_GET(flag/dynamic_config_enabled))
- var/json_file = file("[global.config.directory]/dynamic.json")
- if(fexists(json_file))
- configuration = json_decode(file2text(json_file))
- if(configuration["Dynamic"])
- for(var/variable in configuration["Dynamic"])
- if(!(variable in vars))
- stack_trace("Invalid dynamic configuration variable [variable] in game mode variable changes.")
- continue
- vars[variable] = configuration["Dynamic"][variable]
-
- configure_station_trait_costs()
- setup_parameters()
- setup_hijacking()
- setup_rulesets()
-
- //We do this here instead of with the midround rulesets and such because these rules can hang refs
- //To new_player and such, and we want the datums to just free when the roundstart work is done
- var/list/roundstart_rules = init_rulesets(/datum/dynamic_ruleset/roundstart)
-
- SSjob.divide_occupations(pure = TRUE, allow_all = TRUE)
- for(var/i in GLOB.new_player_list)
- var/mob/dead/new_player/player = i
- if(player.ready == PLAYER_READY_TO_PLAY && player.mind && player.check_preferences())
- if(is_unassigned_job(player.mind.assigned_role))
- var/list/job_data = list()
- var/job_prefs = player.client.prefs.job_preferences
- for(var/job in job_prefs)
- var/priority = job_prefs[job]
- job_data += "[job]: [SSjob.job_priority_level_to_string(priority)]"
- to_chat(player, span_danger("You were unable to qualify for any roundstart antagonist role this round because your job preferences presented a high chance of all of your selected jobs being unavailable, along with 'return to lobby if job is unavailable' enabled. Increase the number of roles set to medium or low priority to reduce the chances of this happening."))
- log_admin("[player.ckey] failed to qualify for any roundstart antagonist role because their job preferences presented a high chance of all of their selected jobs being unavailable, along with 'return to lobby if job is unavailable' enabled and has [player.client.prefs.be_special.len] antag preferences enabled. They will be unable to qualify for any roundstart antagonist role. These are their job preferences - [job_data.Join(" | ")]")
+ data += "\[\"[ruleset.config_tag]\"\]\n"
+ if(islist(ruleset.weight))
+ for(var/i in 1 to length(ruleset.weight))
+ data += "weight.[i] = [ruleset.weight[i]]\n"
+ else
+ data += "weight = [ruleset.weight || 0]\n"
+ if(islist(ruleset.min_pop))
+ for(var/i in 1 to length(ruleset.min_pop))
+ data += "min_pop.[i] = [ruleset.min_pop[i]]\n"
+ else
+ data += "min_pop = [ruleset.min_pop || 0]\n"
+ if(length(ruleset.blacklisted_roles))
+ data += "blacklisted_roles = \[\n"
+ for(var/i in ruleset.blacklisted_roles)
+ data += "\t\"[i]\",\n"
+ data += "\]\n"
+ else
+ data += "blacklisted_roles = \[\]\n"
+ if(!istype(ruleset, /datum/dynamic_ruleset/latejoin) && !istype(ruleset, /datum/dynamic_ruleset/midround/from_living))
+ if(islist(ruleset.min_antag_cap))
+ for(var/ruleset_min_antag_cap in ruleset.min_antag_cap)
+ data += "min_antag_cap.[ruleset_min_antag_cap] = [ruleset.min_antag_cap[ruleset_min_antag_cap]]\n"
else
- roundstart_pop_ready++
- candidates.Add(player)
- SSjob.reset_occupations()
- log_dynamic("Listing [roundstart_rules.len] round start rulesets, and [candidates.len] players ready.")
- if (candidates.len <= 0)
- log_dynamic("[candidates.len] candidates.")
- return TRUE
+ data += "min_antag_cap = [ruleset.min_antag_cap || 0]\n"
+ if(islist(ruleset.max_antag_cap))
+ for(var/ruleset_max_antag_cap in ruleset.max_antag_cap)
+ data += "max_antag_cap.[ruleset_max_antag_cap] = [ruleset.max_antag_cap[ruleset_max_antag_cap]]\n"
+ else if(!isnull(ruleset.max_antag_cap))
+ data += "max_antag_cap = [ruleset.max_antag_cap]\n"
+ else
+ data += "# max_antag_cap = min_antag_cap\n"
+ data += "repeatable_weight_decrease = [ruleset.repeatable_weight_decrease]\n"
+ data += "repeatable = [ruleset.repeatable]\n"
+ data += "minimum_required_age = [ruleset.minimum_required_age]\n"
+ data += "\n"
+ qdel(ruleset)
- if(GLOB.dynamic_forced_roundstart_ruleset.len > 0)
- rigged_roundstart()
- else
- roundstart(roundstart_rules)
-
- log_dynamic("[round_start_budget] round start budget was left, donating it to midrounds.")
- threat_log += "[gameTimestamp()]: [round_start_budget] round start budget was left, donating it to midrounds."
- mid_round_budget += round_start_budget
-
- var/starting_rulesets = ""
- for (var/datum/dynamic_ruleset/roundstart/DR in executed_rules)
- starting_rulesets += "[DR.name], "
- log_dynamic("Picked the following roundstart rules: [starting_rulesets]")
- candidates.Cut()
+ var/filepath = "[global.config.directory]/dynamic.toml"
+ fdel(file(filepath))
+ text2file(data, filepath)
return TRUE
-
-// Called AFTER everyone is equipped with their job
-/datum/controller/subsystem/dynamic/proc/post_setup(report)
- for(var/datum/dynamic_ruleset/roundstart/rule in executed_rules)
- rule.candidates.Cut() // The rule should not use candidates at this point as they all are null.
- addtimer(CALLBACK(src, PROC_REF(execute_roundstart_rule), rule), rule.delay)
-
- if (!CONFIG_GET(flag/no_intercept_report))
- addtimer(CALLBACK(src, PROC_REF(send_intercept)), rand(waittime_l, waittime_h))
- //SKYRAT EDIT START - DIVERGENCY/GOALS REPORT
-// else // BUBBER EDIT REMOVAL
-// addtimer(CALLBACK(src, PROC_REF(send_trait_report)), rand(waittime_l, waittime_h)) // BUBBER EDIT REMOVAL
- //SKYRAT EDIT END
- addtimer(CALLBACK(src, PROC_REF(display_roundstart_logout_report)), ROUNDSTART_LOGOUT_REPORT_TIME)
-
- if(CONFIG_GET(flag/reopen_roundstart_suicide_roles))
- var/delay = CONFIG_GET(number/reopen_roundstart_suicide_roles_delay)
- if(delay)
- delay *= (1 SECONDS)
- else
- delay = (4 MINUTES) //default to 4 minutes if the delay isn't defined.
- addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(reopen_roundstart_suicide_roles)), delay)
-
- if(SSdbcore.Connect())
- var/list/to_set = list()
- var/arguments = list()
- if(GLOB.revdata.originmastercommit)
- to_set += "commit_hash = :commit_hash"
- arguments["commit_hash"] = GLOB.revdata.originmastercommit
- if(to_set.len)
- arguments["round_id"] = GLOB.round_id
- var/datum/db_query/query_round_game_mode = SSdbcore.NewQuery(
- "UPDATE [format_table_name("round")] SET [to_set.Join(", ")] WHERE id = :round_id",
- arguments
- )
- query_round_game_mode.Execute()
- qdel(query_round_game_mode)
- return TRUE
-
-/datum/controller/subsystem/dynamic/proc/display_roundstart_logout_report()
- var/list/msg = list("[span_boldnotice("Roundstart logout report")]\n\n")
- for(var/i in GLOB.mob_living_list)
- var/mob/living/L = i
- var/mob/living/carbon/C = L
- if (istype(C) && !C.last_mind)
- continue // never had a client
-
- if(L.ckey && !GLOB.directory[L.ckey])
- msg += "[L.name] ([L.key]), the [L.job] (Disconnected)\n"
-
-
- if(L.ckey && L.client)
- var/failed = FALSE
- if(L.client.inactivity >= ROUNDSTART_LOGOUT_AFK_THRESHOLD) //Connected, but inactive (alt+tabbed or something)
- msg += "[L.name] ([L.key]), the [L.job] (Connected, Inactive)\n"
- failed = TRUE //AFK client
- if(!failed && L.stat)
- if(HAS_TRAIT(L, TRAIT_SUICIDED)) //Suicider
- msg += "[L.name] ([L.key]), the [L.job] ([span_bolddanger("Suicide")])\n"
- failed = TRUE //Disconnected client
- if(!failed && (L.stat == UNCONSCIOUS || L.stat == HARD_CRIT))
- msg += "[L.name] ([L.key]), the [L.job] (Dying)\n"
- failed = TRUE //Unconscious
- if(!failed && L.stat == DEAD)
- msg += "[L.name] ([L.key]), the [L.job] (Dead)\n"
- failed = TRUE //Dead
-
- continue //Happy connected client
- for(var/mob/dead/observer/D in GLOB.dead_mob_list)
- if(D.mind && D.mind.current == L)
- if(L.stat == DEAD)
- if(HAS_TRAIT(L, TRAIT_SUICIDED)) //Suicider
- msg += "[L.name] ([ckey(D.mind.key)]), the [L.job] ([span_bolddanger("Suicide")])\n"
- continue //Disconnected client
- else
- msg += "[L.name] ([ckey(D.mind.key)]), the [L.job] (Dead)\n"
- continue //Dead mob, ghost abandoned
- else
- if(D.can_reenter_corpse)
- continue //Adminghost, or cult/wizard ghost
- else
- msg += "[L.name] ([ckey(D.mind.key)]), the [L.job] ([span_bolddanger("Ghosted")])\n"
- continue //Ghosted while alive
-
- var/concatenated_message = msg.Join()
- log_admin(concatenated_message)
- to_chat(GLOB.admins, concatenated_message)
-
-/// Initializes the internal ruleset variables
-/datum/controller/subsystem/dynamic/proc/setup_rulesets()
- midround_rules = init_rulesets(/datum/dynamic_ruleset/midround)
- latejoin_rules = init_rulesets(/datum/dynamic_ruleset/latejoin)
-
-/// Returns a list of the provided rulesets.
-/// Configures their variables to match config.
-/datum/controller/subsystem/dynamic/proc/init_rulesets(ruleset_subtype)
- var/list/rulesets = list()
-
- for (var/datum/dynamic_ruleset/ruleset_type as anything in subtypesof(ruleset_subtype))
- if (initial(ruleset_type.name) == "")
- continue
-
- if (initial(ruleset_type.weight) == 0)
- continue
-
- var/ruleset = new ruleset_type
- configure_ruleset(ruleset)
- rulesets += ruleset
-
- return rulesets
-
-/// A simple roundstart proc used when dynamic_forced_roundstart_ruleset has rules in it.
-/datum/controller/subsystem/dynamic/proc/rigged_roundstart()
- message_admins("[GLOB.dynamic_forced_roundstart_ruleset.len] rulesets being forced. Will now attempt to draft players for them.")
- log_dynamic("[GLOB.dynamic_forced_roundstart_ruleset.len] rulesets being forced. Will now attempt to draft players for them.")
- for (var/datum/dynamic_ruleset/roundstart/rule in GLOB.dynamic_forced_roundstart_ruleset)
- configure_ruleset(rule)
- message_admins("Drafting players for forced ruleset [rule.name].")
- log_dynamic("Drafting players for forced ruleset [rule.name].")
- rule.acceptable(roundstart_pop_ready, threat_level) // Assigns some vars in the modes, running it here for consistency
- rule.candidates = candidates.Copy()
- rule.trim_candidates()
- rule.load_templates()
- if (rule.ready(roundstart_pop_ready, TRUE))
- var/cost = rule.cost
- var/scaled_times = 0
- if (rule.scaling_cost)
- scaled_times = round(max(round_start_budget - cost, 0) / rule.scaling_cost)
- cost += rule.scaling_cost * scaled_times
-
- spend_roundstart_budget(picking_roundstart_rule(rule, scaled_times, forced = TRUE))
-
-/datum/controller/subsystem/dynamic/proc/roundstart(list/roundstart_rules)
- if (GLOB.dynamic_forced_extended)
- log_dynamic("Starting a round of forced extended.")
- return TRUE
- var/list/drafted_rules = list()
- for (var/datum/dynamic_ruleset/roundstart/rule in roundstart_rules)
- if (!rule.weight)
- continue
- if (rule.acceptable(roundstart_pop_ready, threat_level) && round_start_budget >= rule.cost) // If we got the population and threat required
- rule.candidates = candidates.Copy()
- rule.trim_candidates()
- rule.load_templates()
- if (rule.ready(roundstart_pop_ready) && rule.candidates.len > 0)
- drafted_rules[rule] = rule.weight
-
- var/list/rulesets_picked = list()
-
- // Kept in case a ruleset can't be initialized for whatever reason, we want to be able to only spend what we can use.
- var/round_start_budget_left = round_start_budget
-
- while (round_start_budget_left > 0)
- var/datum/dynamic_ruleset/roundstart/ruleset = pick_weight(drafted_rules)
- if (isnull(ruleset))
- log_dynamic("No more rules can be applied, stopping with [round_start_budget] left.")
- break
-
- var/cost = (ruleset in rulesets_picked) ? ruleset.scaling_cost : ruleset.cost
- if (cost == 0)
- stack_trace("[ruleset] cost 0, this is going to result in an infinite loop.")
- drafted_rules[ruleset] = null
- continue
-
- if (cost > round_start_budget_left)
- drafted_rules[ruleset] = null
- continue
-
- if (check_blocking(ruleset.blocking_rules, rulesets_picked))
- drafted_rules[ruleset] = null
- continue
-
- round_start_budget_left -= cost
-
- rulesets_picked[ruleset] += 1
-
- if (ruleset.flags & HIGH_IMPACT_RULESET)
- for (var/_other_ruleset in drafted_rules)
- var/datum/dynamic_ruleset/other_ruleset = _other_ruleset
- if (other_ruleset.flags & HIGH_IMPACT_RULESET)
- drafted_rules[other_ruleset] = null
-
- if (ruleset.flags & LONE_RULESET)
- drafted_rules[ruleset] = null
-
- for (var/ruleset in rulesets_picked)
- spend_roundstart_budget(picking_roundstart_rule(ruleset, rulesets_picked[ruleset] - 1))
-
- update_log()
-
-/// Initializes the round start ruleset provided to it. Returns how much threat to spend.
-/datum/controller/subsystem/dynamic/proc/picking_roundstart_rule(datum/dynamic_ruleset/roundstart/ruleset, scaled_times = 0, forced = FALSE)
- log_dynamic("Picked a ruleset: [ruleset.name], scaled [scaled_times] times")
-
- ruleset.trim_candidates()
- var/added_threat = ruleset.scale_up(roundstart_pop_ready, scaled_times)
-
- if(ruleset.pre_execute(roundstart_pop_ready))
- threat_log += "[gameTimestamp()]: Roundstart [ruleset.name] spent [ruleset.cost + added_threat]. [ruleset.scaling_cost ? "Scaled up [ruleset.scaled_times]/[scaled_times] times." : ""]"
- if(ruleset.flags & ONLY_RULESET)
- only_ruleset_executed = TRUE
- if(ruleset.flags & HIGH_IMPACT_RULESET)
- high_impact_ruleset_executed = TRUE
- executed_rules += ruleset
- return ruleset.cost + added_threat
- else
- stack_trace("The starting rule \"[ruleset.name]\" failed to pre_execute.")
- return 0
-
-/// Mainly here to facilitate delayed rulesets. All roundstart rulesets are executed with a timered callback to this proc.
-/datum/controller/subsystem/dynamic/proc/execute_roundstart_rule(sent_rule)
- var/datum/dynamic_ruleset/rule = sent_rule
- if(rule.execute())
- if(rule.persistent)
- current_rules += rule
- new_snapshot(rule)
- rule.forget_startup()
- return TRUE
- rule.clean_up() // Refund threat, delete teams and so on.
- rule.forget_startup()
- executed_rules -= rule
- stack_trace("The starting rule \"[rule.name]\" failed to execute.")
- return FALSE
-
-/// An experimental proc to allow admins to call rules on the fly or have rules call other rules.
-/datum/controller/subsystem/dynamic/proc/picking_specific_rule(ruletype, forced = FALSE, ignore_cost = FALSE)
- var/datum/dynamic_ruleset/midround/new_rule
- if(ispath(ruletype))
- new_rule = new ruletype() // You should only use it to call midround rules though.
- configure_ruleset(new_rule) // This makes sure the rule is set up properly.
- else if(istype(ruletype, /datum/dynamic_ruleset))
- new_rule = ruletype
- else
- return FALSE
-
- if(!new_rule)
- return FALSE
-
- if(!forced)
- if(only_ruleset_executed)
- return FALSE
- // Check if a blocking ruleset has been executed.
- else if(check_blocking(new_rule.blocking_rules, executed_rules))
- 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
-
- var/population = GLOB.alive_player_list.len
- if((new_rule.acceptable(population, threat_level) && (ignore_cost || new_rule.cost <= mid_round_budget)) || forced)
- new_rule.trim_candidates()
- new_rule.load_templates()
- if (new_rule.ready(forced))
- if (!ignore_cost)
- spend_midround_budget(new_rule.cost, threat_log, "[gameTimestamp()]: Forced rule [new_rule.name]")
- new_rule.pre_execute(population)
- if (new_rule.execute()) // This should never fail since ready() returned 1
- if(new_rule.flags & HIGH_IMPACT_RULESET)
- high_impact_ruleset_executed = TRUE
- else if(new_rule.flags & ONLY_RULESET)
- only_ruleset_executed = TRUE
- log_dynamic("Making a call to a specific ruleset...[new_rule.name]!")
- executed_rules += new_rule
- if (new_rule.persistent)
- current_rules += new_rule
- new_rule.forget_startup()
- return TRUE
- else if (forced)
- log_dynamic("The ruleset [new_rule.name] couldn't be executed due to lack of elligible players.")
- new_rule.forget_startup()
- return FALSE
-
-/datum/controller/subsystem/dynamic/fire()
- for (var/datum/dynamic_ruleset/rule in current_rules)
- if(rule.rule_process() == RULESET_STOP_PROCESSING) // If rule_process() returns 1 (RULESET_STOP_PROCESSING), stop processing.
- current_rules -= rule
-
- try_midround_roll()
-
-/// Removes type from the list
-/datum/controller/subsystem/dynamic/proc/remove_from_list(list/type_list, type)
- for(var/I in type_list)
- if(istype(I, type))
- type_list -= I
- return type_list
-
-/// Checks if a type in blocking_list is in rule_list.
-/datum/controller/subsystem/dynamic/proc/check_blocking(list/blocking_list, list/rule_list)
- if(blocking_list.len > 0)
- for(var/blocking in blocking_list)
- for(var/_executed in rule_list)
- var/datum/executed = _executed
- if(blocking == executed.type)
- log_dynamic("FAIL: check_blocking - [blocking] conflicts with [executed.type]")
- return TRUE
- return FALSE
-
-/// Handles late-join antag assignments
-/datum/controller/subsystem/dynamic/proc/make_antag_chance(mob/living/carbon/human/newPlayer)
- if (GLOB.dynamic_forced_extended)
- return
- if(EMERGENCY_ESCAPED_OR_ENDGAMED) // No more rules after the shuttle has left
- return
-
- if (forced_latejoin_rule)
- log_dynamic("Forcing specific [forced_latejoin_rule.ruletype] ruleset [forced_latejoin_rule].")
- if(!handle_executing_latejoin(forced_latejoin_rule, newPlayer, forced = TRUE))
- message_admins("The forced latejoin ruleset [forced_latejoin_rule.name] couldn't be executed \
- as the most recent latejoin did not fulfill the ruleset's requirements.")
- forced_latejoin_rule = null
- return
-
- if(!late_forced_injection)
- if(latejoin_injection_cooldown >= world.time)
- return
- if(!prob(latejoin_roll_chance))
- return
-
- var/was_forced = late_forced_injection
- late_forced_injection = FALSE
- var/list/possible_latejoin_rules = list()
- for (var/datum/dynamic_ruleset/latejoin/rule in latejoin_rules)
- if(!rule.weight)
- continue
- if(mid_round_budget < rule.cost)
- continue
- if(!rule.acceptable(GLOB.alive_player_list.len, threat_level))
- continue
- possible_latejoin_rules[rule] = rule.get_weight()
-
- if(!length(possible_latejoin_rules))
- log_dynamic("FAIL: [newPlayer] was selected to roll for a latejoin ruleset, but there were no valid rulesets.")
- return
-
- log_dynamic("[newPlayer] was selected to roll for a latejoin ruleset from the following list: [english_list(possible_latejoin_rules)].")
- // You get one shot at becoming a latejoin antag, if it fails the next guy will try.
- var/datum/dynamic_ruleset/latejoin/picked_rule = pick_ruleset(possible_latejoin_rules, max_allowed_attempts = 1)
- if(isnull(picked_rule))
- log_dynamic("FAIL: No valid rulset was selected for [newPlayer]'s latejoin[was_forced ? "" : ", the next player will be checked instead"].")
- return
- if(was_forced)
- log_dynamic("Forcing random [picked_rule.ruletype] ruleset [picked_rule].")
- handle_executing_latejoin(picked_rule, newPlayer, forced = was_forced)
-
-/**
- * This proc handles the execution of a latejoin ruleset, including removing it from latejoin rulesets if not repeatable,
- * upping the injection cooldown, and starting a timer to execute the ruleset on delay.
- */
-/datum/controller/subsystem/dynamic/proc/handle_executing_latejoin(datum/dynamic_ruleset/ruleset, mob/living/carbon/human/only_candidate, forced = FALSE)
- ruleset.candidates = list(only_candidate)
- ruleset.trim_candidates()
- ruleset.load_templates()
- if (!ruleset.ready(forced))
- log_dynamic("FAIL: [only_candidate] was selected to latejoin with the [ruleset] ruleset, \
- but the ruleset failed to execute[length(ruleset.candidates) ? "":" as they were not a valid candiate"].")
- return FALSE
- if (!ruleset.repeatable)
- latejoin_rules = remove_from_list(latejoin_rules, ruleset.type)
- addtimer(CALLBACK(src, PROC_REF(execute_midround_latejoin_rule), ruleset), ruleset.delay)
-
- if(!forced)
- 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
- log_dynamic("A latejoin rulset triggered successfully, the next latejoin injection will happen at [latejoin_injection_cooldown] round time.")
-
- return TRUE
-
-/// Apply configurations to rule.
-/datum/controller/subsystem/dynamic/proc/configure_ruleset(datum/dynamic_ruleset/ruleset)
- var/rule_conf = LAZYACCESSASSOC(configuration, ruleset.ruletype, ruleset.name)
- for(var/variable in rule_conf)
- if(!(variable in ruleset.vars))
- stack_trace("Invalid dynamic configuration variable [variable] in [ruleset.ruletype] [ruleset.name].")
- continue
- ruleset.vars[variable] = rule_conf[variable]
- ruleset.restricted_roles |= SSstation.antag_restricted_roles
- if(length(ruleset.protected_roles)) //if we care to protect any role, we should protect station trait roles too
- ruleset.protected_roles |= SSstation.antag_protected_roles
- if(CONFIG_GET(flag/protect_roles_from_antagonist))
- ruleset.restricted_roles |= ruleset.protected_roles
- if(CONFIG_GET(flag/protect_assistant_from_antagonist))
- ruleset.restricted_roles |= JOB_ASSISTANT
- // SKYRAT EDIT ADDITION
- for(var/datum/job/iterating_job as anything in subtypesof(/datum/job))
- if(!initial(iterating_job.antagonist_restricted))
- continue
- if(initial(iterating_job.restricted_antagonists))
- var/list/restricted_antagonists = initial(iterating_job.restricted_antagonists)
- if(!(ruleset.antag_flag in restricted_antagonists))
- continue
- ruleset.restricted_roles |= initial(iterating_job.title)
- else
- ruleset.restricted_roles |= initial(iterating_job.title)
- // SKYRAT EDIT END
- if(!(ruleset.ruleset_category & GLOB.dynamic_ruleset_categories))
- ruleset.requirements = list(101,101,101,101,101,101,101,101,101,101)
-
-/// Get station traits and call for their config
-/datum/controller/subsystem/dynamic/proc/configure_station_trait_costs()
- if(!CONFIG_GET(flag/dynamic_config_enabled))
- return
- for(var/datum/station_trait/station_trait as anything in GLOB.dynamic_station_traits)
- configure_station_trait(station_trait)
-
-/// Apply configuration for station trait costs
-/datum/controller/subsystem/dynamic/proc/configure_station_trait(datum/station_trait/station_trait)
- var/list/station_trait_config = LAZYACCESSASSOC(configuration, "Station", station_trait.dynamic_threat_id)
- var/cost = station_trait_config["cost"]
-
- if(isnull(cost)) //0 is valid so check for null specifically
- return
-
- if(cost != GLOB.dynamic_station_traits[station_trait])
- log_dynamic("Config set [station_trait.dynamic_threat_id] cost from [station_trait.threat_reduction] to [cost]")
-
- GLOB.dynamic_station_traits[station_trait] = cost
-
-/// Refund threat, but no more than threat_level.
-/datum/controller/subsystem/dynamic/proc/refund_threat(regain)
- mid_round_budget = min(threat_level, mid_round_budget + regain)
-
-/// Generate threat and increase the threat_level if it goes beyond, capped at 100
-/datum/controller/subsystem/dynamic/proc/create_threat(gain, list/threat_log, reason)
- mid_round_budget = min(100, mid_round_budget + gain)
- if(mid_round_budget > threat_level)
- threat_level = mid_round_budget
- for(var/list/logs in threat_log)
- log_threat(gain, logs, reason)
-
-/datum/controller/subsystem/dynamic/proc/log_threat(threat_change, list/threat_log, reason)
- var/gain_or_loss = "+"
- if(threat_change < 0)
- gain_or_loss = "-"
- threat_log += "Threat [gain_or_loss][abs(threat_change)] - [reason]."
-
-/// Expend round start threat, can't fall under 0.
-/datum/controller/subsystem/dynamic/proc/spend_roundstart_budget(cost, list/threat_log, reason)
- round_start_budget = max(round_start_budget - cost,0)
- if (!isnull(threat_log))
- log_threat(-cost, threat_log, reason)
-
-/// Expend midround threat, can't fall under 0.
-/datum/controller/subsystem/dynamic/proc/spend_midround_budget(cost, list/threat_log, reason)
- mid_round_budget = max(mid_round_budget - cost,0)
- if (!isnull(threat_log))
- log_threat(-cost, threat_log, reason)
-
-#define MAXIMUM_DYN_DISTANCE 5
-
-/**
- * Returns the comulative distribution of threat centre and width, and a random location of -5 to 5
- * plus or minus the otherwise unattainable lower and upper percentiles. All multiplied by the maximum
- * threat and then rounded to the nearest interval.
- * rand() calls without arguments returns a value between 0 and 1, allowing for smaller intervals.
- */
-/datum/controller/subsystem/dynamic/proc/lorentz_to_amount(centre = 0, scale = 1.8, max_threat = 100, interval = 1)
- var/location = RANDOM_DECIMAL(-MAXIMUM_DYN_DISTANCE, MAXIMUM_DYN_DISTANCE) * rand()
- var/lorentz_result = LORENTZ_CUMULATIVE_DISTRIBUTION(centre, location, scale)
- var/std_threat = lorentz_result * max_threat
- ///Without these, the amount won't come close to hitting 0% or 100% of the max threat.
- var/lower_deviation = max(std_threat * (location-centre)/MAXIMUM_DYN_DISTANCE, 0)
- var/upper_deviation = max((max_threat - std_threat) * (centre-location)/MAXIMUM_DYN_DISTANCE, 0)
- return clamp(round(std_threat + upper_deviation - lower_deviation, interval), 0, 100)
-
-/proc/reopen_roundstart_suicide_roles()
- var/include_command = CONFIG_GET(flag/reopen_roundstart_suicide_roles_command_positions)
- var/list/reopened_jobs = list()
-
- for(var/mob/living/quitter in GLOB.suicided_mob_list)
- var/datum/job/job = SSjob.get_job(quitter.job)
- if(!job || !(job.job_flags & JOB_REOPEN_ON_ROUNDSTART_LOSS))
- continue
- if(!include_command && job.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND)
- continue
- job.current_positions = max(job.current_positions - 1, 0)
- reopened_jobs += quitter.job
-
- if(CONFIG_GET(flag/reopen_roundstart_suicide_roles_command_report))
- if(reopened_jobs.len)
- var/reopened_job_report_positions
- for(var/dead_dudes_job in reopened_jobs)
- reopened_job_report_positions = "[reopened_job_report_positions ? "[reopened_job_report_positions]\n":""][dead_dudes_job]"
-
- var/suicide_command_report = {"
- [command_name()] Human Resources Board
- Notice of Personnel Change
- To personnel management staff aboard [station_name()]:
- Our medical staff have detected a series of anomalies in the vital sensors
- of some of the staff aboard your station.
- Further investigation into the situation on our end resulted in us discovering
- a series of rather... unforturnate decisions that were made on the part of said staff.
- As such, we have taken the liberty to automatically reopen employment opportunities for the positions of the crew members
- who have decided not to partake in our research. We will be forwarding their cases to our employment review board
- to determine their eligibility for continued service with the company (and of course the
- continued storage of cloning records within the central medical backup server.)
- The following positions have been reopened on our behalf:
- [reopened_job_report_positions]
- "}
-
- print_command_report(suicide_command_report, "Central Command Personnel Update")
-
-
-#undef MAXIMUM_DYN_DISTANCE
+#endif
diff --git a/code/controllers/subsystem/dynamic/dynamic_admin.dm b/code/controllers/subsystem/dynamic/dynamic_admin.dm
new file mode 100644
index 00000000000..7c8cb3ecabd
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/dynamic_admin.dm
@@ -0,0 +1,254 @@
+ADMIN_VERB(dynamic_panel, R_ADMIN, "Dynamic Panel", "Mess with dynamic.", ADMIN_CATEGORY_GAME)
+ dynamic_panel(user.mob)
+
+/proc/dynamic_panel(mob/user)
+ if(!check_rights(R_ADMIN))
+ return
+ var/datum/dynamic_panel/tgui = new()
+ tgui.ui_interact(user)
+
+ log_admin("[key_name(user)] opened the Dynamic Panel.")
+ if(!isobserver(user))
+ message_admins("[key_name_admin(user)] opened the Dynamic Panel.")
+ BLACKBOX_LOG_ADMIN_VERB("Dynamic Panel")
+
+/datum/dynamic_panel
+
+/datum/dynamic_panel/ui_state(mob/user)
+ return ADMIN_STATE(R_ADMIN)
+
+/datum/dynamic_panel/ui_close()
+ qdel(src)
+
+/datum/dynamic_panel/ui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ ui = new(user, src, "DynamicAdmin")
+ ui.open()
+
+/datum/dynamic_panel/ui_data(mob/user)
+ var/list/data = list()
+
+ if(SSdynamic.current_tier)
+ data["current_tier"] = list(
+ "number" = SSdynamic.current_tier.tier,
+ "name" = SSdynamic.current_tier.name,
+ )
+
+ data["ruleset_count"] = list()
+ for(var/category in SSdynamic.rulesets_to_spawn)
+ data["ruleset_count"][category] = max(SSdynamic.rulesets_to_spawn[category], 0)
+
+ data["full_config"] = SSdynamic.get_config()
+ data["config_even_enabled"] = CONFIG_GET(flag/dynamic_config_enabled) && length(data["full_config"])
+
+ data["queued_rulesets"] = list()
+ for(var/i in 1 to length(SSdynamic.queued_rulesets))
+ data["queued_rulesets"] += list(ruleset_to_data(SSdynamic.queued_rulesets[i]) + list("index" = i))
+
+ data["active_rulesets"] = list()
+ for(var/i in 1 to length(SSdynamic.executed_rulesets))
+ data["active_rulesets"] += list(ruleset_to_data(SSdynamic.executed_rulesets[i]) + list("index" = i))
+
+ data["all_rulesets"] = list()
+ for(var/ruleset_type in subtypesof(/datum/dynamic_ruleset/roundstart))
+ data["all_rulesets"][ROUNDSTART] += list(ruleset_to_data(ruleset_type))
+ for(var/ruleset_type in subtypesof(/datum/dynamic_ruleset/midround))
+ var/datum/dynamic_ruleset/midround/midround = ruleset_type
+ switch(initial(midround.midround_type))
+ if(HEAVY_MIDROUND)
+ data["all_rulesets"][HEAVY_MIDROUND] += list(ruleset_to_data(ruleset_type))
+ if(LIGHT_MIDROUND)
+ data["all_rulesets"][LIGHT_MIDROUND] += list(ruleset_to_data(ruleset_type))
+ for(var/ruleset_type in subtypesof(/datum/dynamic_ruleset/latejoin))
+ data["all_rulesets"][LATEJOIN] += list(ruleset_to_data(ruleset_type))
+
+ data["time_until_lights"] = COOLDOWN_TIMELEFT(SSdynamic, light_ruleset_start)
+ data["time_until_heavies"] = COOLDOWN_TIMELEFT(SSdynamic, heavy_ruleset_start)
+ data["time_until_latejoins"] = COOLDOWN_TIMELEFT(SSdynamic, latejoin_ruleset_start)
+
+ data["time_until_next_midround"] = COOLDOWN_TIMELEFT(SSdynamic, midround_cooldown)
+ data["time_until_next_latejoin"] = COOLDOWN_TIMELEFT(SSdynamic, latejoin_cooldown)
+ data["failed_latejoins"] = SSdynamic.failed_latejoins
+
+ data["light_midround_chance"] = SSdynamic.get_midround_chance(LIGHT_MIDROUND)
+ data["heavy_midround_chance"] = SSdynamic.get_midround_chance(HEAVY_MIDROUND)
+ data["latejoin_chance"] = SSdynamic.get_latejoin_chance()
+
+ data["roundstarted"] = SSticker.HasRoundStarted()
+
+ data["light_chance_maxxed"] = SSdynamic.admin_forcing_next_light
+ data["heavy_chance_maxxed"] = SSdynamic.admin_forcing_next_heavy
+ data["latejoin_chance_maxxed"] = SSdynamic.admin_forcing_next_latejoin
+
+ data["next_dynamic_tick"] = SSdynamic.next_fire ? SSdynamic.next_fire - world.time : SSticker.GetTimeLeft()
+
+ data["antag_events_enabled"] = SSdynamic.antag_events_enabled
+
+ return data
+
+/// Pass a ruleset typepath or a ruleset instance
+/datum/dynamic_panel/proc/ruleset_to_data(datum/dynamic_ruleset/ruleset)
+ var/list/data = list()
+ var/ruleset_path = isdatum(ruleset) ? ruleset.type : ruleset
+ data["name"] = initial(ruleset.name)
+ data["id"] = initial(ruleset.config_tag)
+ data["typepath"] = ruleset_path
+ data["selected_players"] = list()
+ data["admin_disabled"] = (ruleset_path in SSdynamic.admin_disabled_rulesets)
+ if(isdatum(ruleset))
+ for(var/datum/mind/player as anything in ruleset.selected_minds)
+ data["selected_players"] += list(list(
+ "key" = player.key,
+ ))
+ data["hidden"] = (ruleset in SSdynamic.unreported_rulesets)
+ return data
+
+/datum/dynamic_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
+ . = ..()
+ if(.)
+ return
+ switch(action)
+ if("remove_queued_ruleset")
+ var/index = params["ruleset_index"]
+ if(length(SSdynamic.queued_rulesets) < index)
+ return
+ var/datum/dynamic_ruleset/ruleset = SSdynamic.queued_rulesets[index]
+ if(!ruleset)
+ return
+ SSdynamic.queued_rulesets -= ruleset
+ message_admins("[key_name_admin(ui.user)] removed [ruleset.config_tag] from the dynamic ruleset queue.")
+ log_admin("[key_name_admin(ui.user)] removed [ruleset.config_tag] from the dynamic ruleset queue.")
+ qdel(ruleset)
+ return TRUE
+ if("add_queued_ruleset")
+ var/datum/dynamic_ruleset/ruleset_path = text2path(params["ruleset_type"])
+ if(!ruleset_path)
+ return
+ SSdynamic.queue_ruleset(ruleset_path)
+ message_admins("[key_name_admin(ui.user)] added [initial(ruleset_path.config_tag)] to the dynamic ruleset queue.")
+ log_admin("[key_name_admin(ui.user)] added [initial(ruleset_path.config_tag)] to the dynamic ruleset queue.")
+ return TRUE
+ if("dynamic_vv")
+ ui.user?.client?.debug_variables(SSdynamic)
+ return TRUE
+ if("add_ruleset_category_count")
+ var/category = params["ruleset_category"]
+ if(!category)
+ return
+ SSdynamic.rulesets_to_spawn[category] += 1
+ message_admins("[key_name_admin(ui.user)] added 1 to the [category] ruleset category.")
+ log_admin("[key_name_admin(ui.user)] added 1 to the [category] ruleset category.")
+ return TRUE
+ if("set_ruleset_category_count")
+ var/category = params["ruleset_category"]
+ var/count = params["ruleset_count"]
+ if(!category || !isnum(count))
+ return
+ SSdynamic.rulesets_to_spawn[category] = count
+ message_admins("[key_name_admin(ui.user)] set the [category] ruleset category to [count].")
+ log_admin("[key_name_admin(ui.user)] set the [category] ruleset category to [count].")
+ return TRUE
+ if("execute_ruleset")
+ var/datum/dynamic_ruleset/ruleset_path = text2path(params["ruleset_type"])
+ if(!ruleset_path)
+ return
+ message_admins("[key_name_admin(ui.user)] executed the ruleset [initial(ruleset_path.config_tag)].")
+ log_admin("[key_name_admin(ui.user)] executed the ruleset [initial(ruleset_path.config_tag)].")
+ ASYNC
+ SSdynamic.force_run_midround(ruleset_path, alert_admins_on_fail = TRUE, admin = ui.user)
+ return TRUE
+ if("disable_ruleset")
+ var/ruleset_path = text2path(params["ruleset_type"])
+ if(!ruleset_path)
+ return
+ if(ruleset_path in SSdynamic.admin_disabled_rulesets)
+ SSdynamic.admin_disabled_rulesets -= ruleset_path
+ message_admins("[key_name_admin(ui.user)] enabled [ruleset_path] to be selected.")
+ log_admin("[key_name_admin(ui.user)] enabled [ruleset_path] to be selected.")
+ else
+ SSdynamic.admin_disabled_rulesets += ruleset_path
+ message_admins("[key_name_admin(ui.user)] disabled [ruleset_path] from being selected.")
+ log_admin("[key_name_admin(ui.user)] disabled [ruleset_path] from being selected.")
+ return TRUE
+ if("disable_all")
+ SSdynamic.admin_disabled_rulesets |= subtypesof(/datum/dynamic_ruleset)
+ message_admins("[key_name_admin(ui.user)] disabled all rulesets from being selected.")
+ log_admin("[key_name_admin(ui.user)] disabled all rulesets from being selected.")
+ if("enable_all")
+ SSdynamic.admin_disabled_rulesets.Cut()
+ message_admins("[key_name_admin(ui.user)] re-enabled all rulesets.")
+ log_admin("[key_name_admin(ui.user)] re_enabled all rulesets.")
+ if("set_tier")
+ if(SSdynamic.current_tier && SSticker.HasRoundStarted())
+ return TRUE
+ var/list/tiers = list()
+ for(var/datum/dynamic_tier/tier as anything in subtypesof(/datum/dynamic_tier))
+ tiers[initial(tier.name)] = tier
+ var/datum/dynamic_tier/picked = tgui_input_list(ui.user, "Pick a dynamic tier before the game starts", "Pick tier", tiers, ui_state = ADMIN_STATE(R_ADMIN))
+ if(picked && !SSticker.HasRoundStarted())
+ SSdynamic.set_tier(tiers[picked])
+ message_admins("[key_name_admin(ui.user)] set the dynamic tier to [initial(picked.tier)].")
+ log_admin("[key_name_admin(ui.user)] set the dynamic tier to [initial(picked.tier)].")
+ return TRUE
+ if("max_light_chance")
+ SSdynamic.admin_forcing_next_light = !SSdynamic.admin_forcing_next_light
+ message_admins("[key_name_admin(ui.user)] [SSdynamic.admin_forcing_next_light ? "forced" : "reset"] the next light ruleset chance.")
+ log_admin("[key_name_admin(ui.user)] [SSdynamic.admin_forcing_next_light ? "forced" : "reset"] the next light ruleset chance.")
+ return TRUE
+ if("max_heavy_chance")
+ SSdynamic.admin_forcing_next_heavy = !SSdynamic.admin_forcing_next_heavy
+ message_admins("[key_name_admin(ui.user)] [SSdynamic.admin_forcing_next_heavy ? "forced" : "reset"] the next heavy ruleset chance.")
+ log_admin("[key_name_admin(ui.user)] [SSdynamic.admin_forcing_next_heavy ? "forced" : "reset"] the next heavy ruleset chance.")
+ return TRUE
+ if("max_latejoin_chance")
+ SSdynamic.admin_forcing_next_latejoin = !SSdynamic.admin_forcing_next_latejoin
+ message_admins("[key_name_admin(ui.user)] [SSdynamic.admin_forcing_next_latejoin ? "forced" : "reset"] the next latejoin ruleset chance.")
+ log_admin("[key_name_admin(ui.user)] [SSdynamic.admin_forcing_next_latejoin ? "forced" : "reset"] the next latejoin ruleset chance.")
+ return TRUE
+ if("light_start_now")
+ COOLDOWN_RESET(SSdynamic, light_ruleset_start)
+ message_admins("[key_name_admin(ui.user)] reset the light ruleset start cooldown.")
+ log_admin("[key_name_admin(ui.user)] reset the light ruleset start cooldown.")
+ return TRUE
+ if("heavy_start_now")
+ COOLDOWN_RESET(SSdynamic, heavy_ruleset_start)
+ message_admins("[key_name_admin(ui.user)] reset the heavy ruleset start cooldown.")
+ log_admin("[key_name_admin(ui.user)] reset the heavy ruleset start cooldown.")
+ return TRUE
+ if("latejoin_start_now")
+ COOLDOWN_RESET(SSdynamic, latejoin_ruleset_start)
+ message_admins("[key_name_admin(ui.user)] reset the latejoin ruleset start cooldown.")
+ log_admin("[key_name_admin(ui.user)] reset the latejoin ruleset start cooldown.")
+ return TRUE
+ if("reset_midround_cooldown")
+ COOLDOWN_RESET(SSdynamic, midround_cooldown)
+ message_admins("[key_name_admin(ui.user)] reset the midround cooldown.")
+ log_admin("[key_name_admin(ui.user)] reset the midround cooldown.")
+ return TRUE
+ if("reset_latejoin_cooldown")
+ COOLDOWN_RESET(SSdynamic, latejoin_cooldown)
+ message_admins("[key_name_admin(ui.user)] reset the latejoin cooldown.")
+ log_admin("[key_name_admin(ui.user)] reset the latejoin cooldown.")
+ return TRUE
+ if("hide_ruleset")
+ var/index = params["ruleset_index"]
+ if(length(SSdynamic.executed_rulesets) < index)
+ return
+ var/datum/dynamic_ruleset/ruleset = SSdynamic.executed_rulesets[index]
+ if(!ruleset)
+ return
+ if(ruleset in SSdynamic.unreported_rulesets)
+ SSdynamic.unreported_rulesets -= ruleset
+ message_admins("[key_name_admin(ui.user)] hid [ruleset] from the roundend report.")
+ log_admin("[key_name_admin(ui.user)] hid [ruleset] from the roundend report.")
+ else
+ SSdynamic.unreported_rulesets += ruleset
+ message_admins("[key_name_admin(ui.user)] unhid [ruleset] from the roundend report.")
+ log_admin("[key_name_admin(ui.user)] unhid [ruleset] from the roundend report.")
+ return TRUE
+ if("toggle_antag_events")
+ SSdynamic.antag_events_enabled = !SSdynamic.antag_events_enabled
+ message_admins("[key_name_admin(ui.user)] [SSdynamic.antag_events_enabled ? "enabled" : "disabled"] antag events.")
+ log_admin("[key_name_admin(ui.user)] [SSdynamic.antag_events_enabled ? "enabled" : "disabled"] antag events.")
+ return TRUE
diff --git a/code/controllers/subsystem/dynamic/dynamic_hijacking.dm b/code/controllers/subsystem/dynamic/dynamic_hijacking.dm
deleted file mode 100644
index 7577cbcd84f..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_hijacking.dm
+++ /dev/null
@@ -1,25 +0,0 @@
-/datum/controller/subsystem/dynamic/proc/setup_hijacking()
- RegisterSignal(SSdcs, COMSIG_GLOB_PRE_RANDOM_EVENT, PROC_REF(on_pre_random_event))
-
-/datum/controller/subsystem/dynamic/proc/on_pre_random_event(datum/source, datum/round_event_control/round_event_control)
- SIGNAL_HANDLER
- if (!round_event_control.dynamic_should_hijack)
- return
-
- if (random_event_hijacked != HIJACKED_NOTHING)
- log_dynamic_and_announce("Random event [round_event_control.name] tried to roll, but Dynamic vetoed it (random event has already ran).")
- SSevents.spawnEvent()
- SSevents.reschedule()
- return CANCEL_PRE_RANDOM_EVENT
-
- var/time_range = rand(random_event_hijack_minimum, random_event_hijack_maximum)
-
- if (world.time - last_midround_injection_attempt < time_range)
- random_event_hijacked = HIJACKED_TOO_RECENT
- log_dynamic_and_announce("Random event [round_event_control.name] tried to roll, but the last midround injection \
- was too recent. Heavy injection chance has been raised to [get_heavy_midround_injection_chance(dry_run = TRUE)]%.")
- return CANCEL_PRE_RANDOM_EVENT
-
- if (next_midround_injection() - world.time < time_range)
- log_dynamic_and_announce("Random event [round_event_control.name] tried to roll, but the next midround injection is too soon.")
- return CANCEL_PRE_RANDOM_EVENT
diff --git a/code/controllers/subsystem/dynamic/dynamic_logging.dm b/code/controllers/subsystem/dynamic/dynamic_logging.dm
deleted file mode 100644
index 1ff3b4d3119..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_logging.dm
+++ /dev/null
@@ -1,101 +0,0 @@
-/// A "snapshot" of dynamic at an important point in time.
-/// Exported to JSON in the dynamic.json log file.
-/datum/dynamic_snapshot
- /// The remaining midround threat
- var/remaining_threat
-
- /// The world.time when the snapshot was taken
- var/time
-
- /// The total number of players in the server
- var/total_players
-
- /// The number of alive players
- var/alive_players
-
- /// The number of dead players
- var/dead_players
-
- /// The number of observers
- var/observers
-
- /// The number of alive antags
- var/alive_antags
-
- /// The rulesets chosen this snapshot
- var/datum/dynamic_snapshot_ruleset/ruleset_chosen
-
- /// The cached serialization of this snapshot
- var/serialization
-
-/// A ruleset chosen during a snapshot
-/datum/dynamic_snapshot_ruleset
- /// The name of the ruleset chosen
- var/name
-
- /// If it is a round start ruleset, how much it was scaled by
- var/scaled
-
- /// The number of assigned antags
- var/assigned
-
-/datum/dynamic_snapshot_ruleset/New(datum/dynamic_ruleset/ruleset)
- name = ruleset.name
- assigned = ruleset.assigned.len
-
- if (istype(ruleset, /datum/dynamic_ruleset/roundstart))
- scaled = ruleset.scaled_times
-
-/// Convert the snapshot to an associative list
-/datum/dynamic_snapshot/proc/to_list()
- if (!isnull(serialization))
- return serialization
-
- serialization = list(
- "remaining_threat" = remaining_threat,
- "time" = time,
- "total_players" = total_players,
- "alive_players" = alive_players,
- "dead_players" = dead_players,
- "observers" = observers,
- "alive_antags" = alive_antags,
- "ruleset_chosen" = list(
- "name" = ruleset_chosen.name,
- "scaled" = ruleset_chosen.scaled,
- "assigned" = ruleset_chosen.assigned,
- ),
- )
-
- return serialization
-
-/// Updates the log for the current snapshots.
-/datum/controller/subsystem/dynamic/proc/update_log()
- var/list/serialized = list()
- serialized["threat_level"] = threat_level
- serialized["round_start_budget"] = initial_round_start_budget
- serialized["mid_round_budget"] = threat_level - initial_round_start_budget
-
- var/list/serialized_snapshots = list()
- for (var/datum/dynamic_snapshot/snapshot as anything in snapshots)
- serialized_snapshots += list(snapshot.to_list())
- serialized["snapshots"] = serialized_snapshots
-
- rustg_file_write(json_encode(serialized), "[GLOB.log_directory]/dynamic.json")
- rustg_file_write(json_encode(serialized), "[GLOB.public_log_directory]/dynamic.json") // BUBBER EDIT
-
-/// Creates a new snapshot with the given rulesets chosen, and writes to the JSON output.
-/datum/controller/subsystem/dynamic/proc/new_snapshot(datum/dynamic_ruleset/ruleset_chosen)
- var/datum/dynamic_snapshot/new_snapshot = new
-
- new_snapshot.remaining_threat = mid_round_budget
- new_snapshot.time = world.time
- new_snapshot.alive_players = GLOB.alive_player_list.len
- new_snapshot.dead_players = GLOB.dead_player_list.len
- new_snapshot.observers = GLOB.current_observers_list.len
- new_snapshot.total_players = new_snapshot.alive_players + new_snapshot.dead_players + new_snapshot.observers
- new_snapshot.alive_antags = GLOB.current_living_antags.len
- new_snapshot.ruleset_chosen = new /datum/dynamic_snapshot_ruleset(ruleset_chosen)
-
- LAZYADD(snapshots, new_snapshot)
-
- update_log()
diff --git a/code/controllers/subsystem/dynamic/dynamic_midround_rolling.dm b/code/controllers/subsystem/dynamic/dynamic_midround_rolling.dm
deleted file mode 100644
index c44bf3d591c..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_midround_rolling.dm
+++ /dev/null
@@ -1,108 +0,0 @@
-/// Returns the world.time of the next midround injection.
-/// Will return a cached result from `next_midround_injection`, the variable.
-/// If that variable is null, will generate a new one.
-/datum/controller/subsystem/dynamic/proc/next_midround_injection()
- if (!isnull(next_midround_injection))
- return next_midround_injection
-
- // Admins can futz around with the midround threat, and we want to be able to react to that
- var/midround_threat = threat_level - round_start_budget
-
- var/rolls = CEILING(midround_threat / threat_per_midround_roll, 1)
- var/distance = ((1 / (rolls + 1)) * midround_upper_bound) + midround_lower_bound
-
- if (last_midround_injection_attempt == 0)
- last_midround_injection_attempt = SSticker.round_start_time
-
- return last_midround_injection_attempt + distance
-
-/datum/controller/subsystem/dynamic/proc/try_midround_roll()
- if (!mid_forced_injection && next_midround_injection() > world.time)
- return
-
- if (GLOB.dynamic_forced_extended)
- return
-
- if (EMERGENCY_PAST_POINT_OF_NO_RETURN)
- return
-
- var/spawn_heavy = prob(get_heavy_midround_injection_chance())
-
- last_midround_injection_attempt = world.time
- next_midround_injection = null
- mid_forced_injection = FALSE
-
- log_dynamic_and_announce("A midround ruleset is rolling, and will be [spawn_heavy ? "HEAVY" : "LIGHT"].")
-
- random_event_hijacked = HIJACKED_NOTHING
-
- var/list/drafted_heavies = list()
- var/list/drafted_lights = list()
-
- for (var/datum/dynamic_ruleset/midround/ruleset in midround_rules)
- if (ruleset.weight == 0)
- log_dynamic("FAIL: [ruleset] has a weight of 0")
- continue
-
- if (!ruleset.acceptable(GLOB.alive_player_list.len, threat_level))
- var/ruleset_forced = GLOB.dynamic_forced_rulesets[type] || RULESET_NOT_FORCED
- if (ruleset_forced == RULESET_NOT_FORCED)
- log_dynamic("FAIL: [ruleset] is not acceptable with the current parameters. Alive players: [GLOB.alive_player_list.len], threat level: [threat_level]")
- else
- log_dynamic("FAIL: [ruleset] was disabled.")
- continue
-
- if (mid_round_budget < ruleset.cost)
- log_dynamic("FAIL: [ruleset] is too expensive, and cannot be bought. Midround budget: [mid_round_budget], ruleset cost: [ruleset.cost]")
- continue
-
- if (ruleset.minimum_round_time > world.time - SSticker.round_start_time)
- log_dynamic("FAIL: [ruleset] is trying to run too early. Minimum round time: [ruleset.minimum_round_time], current round time: [world.time - SSticker.round_start_time]")
- continue
-
- // If admins have disabled dynamic from picking from the ghost pool
- if(istype(ruleset, /datum/dynamic_ruleset/midround/from_ghosts) && !(GLOB.ghost_role_flags & GHOSTROLE_MIDROUND_EVENT))
- log_dynamic("FAIL: [ruleset] is a from_ghosts ruleset, but ghost roles are disabled")
- continue
-
- ruleset.trim_candidates()
- ruleset.load_templates()
- if (!ruleset.ready())
- log_dynamic("FAIL: [ruleset] is not ready()")
- continue
-
- var/ruleset_is_heavy = (ruleset.midround_ruleset_style == MIDROUND_RULESET_STYLE_HEAVY)
- if (ruleset_is_heavy)
- drafted_heavies[ruleset] = ruleset.get_weight()
- else
- drafted_lights[ruleset] = ruleset.get_weight()
-
- var/heavy_light_log_count = "[drafted_heavies.len] heavies / [drafted_lights.len] lights"
-
- log_dynamic("Rolling [spawn_heavy ? "HEAVY" : "LIGHT"]... [heavy_light_log_count]")
-
- if (spawn_heavy && drafted_heavies.len > 0 && pick_midround_rule(drafted_heavies, "heavy rulesets"))
- return
- else if (drafted_lights.len > 0 && pick_midround_rule(drafted_lights, "light rulesets"))
- if (spawn_heavy)
- log_dynamic_and_announce("A heavy ruleset was intended to roll, but there weren't any available. [heavy_light_log_count]")
- else
- log_dynamic_and_announce("No midround rulesets could be drafted. ([heavy_light_log_count])")
-
-/// Gets the chance for a heavy ruleset midround injection, the dry_run argument is only used for forced injection.
-/datum/controller/subsystem/dynamic/proc/get_heavy_midround_injection_chance(dry_run)
- var/chance_modifier = 1
- var/next_midround_roll = next_midround_injection() - SSticker.round_start_time
-
- if (random_event_hijacked != HIJACKED_NOTHING)
- chance_modifier += (hijacked_random_event_injection_chance_modifier / 100)
-
- if (GLOB.current_living_antags.len == 0)
- chance_modifier += 0.5
-
- if (GLOB.dead_player_list.len > GLOB.alive_player_list.len)
- chance_modifier -= 0.3
-
- var/heavy_coefficient = CLAMP01((next_midround_roll - midround_light_upper_bound) / (midround_heavy_lower_bound - midround_light_upper_bound))
-
- return 100 * (heavy_coefficient * max(1, chance_modifier))
diff --git a/code/controllers/subsystem/dynamic/dynamic_ruleset_latejoin.dm b/code/controllers/subsystem/dynamic/dynamic_ruleset_latejoin.dm
new file mode 100644
index 00000000000..d780e2fa344
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/dynamic_ruleset_latejoin.dm
@@ -0,0 +1,128 @@
+/datum/dynamic_ruleset/latejoin
+ min_antag_cap = 1
+ max_antag_cap = 1
+ repeatable = TRUE
+
+/datum/dynamic_ruleset/latejoin/set_config_value(nvar, nval)
+ if(nvar == NAMEOF(src, min_antag_cap) || nvar == NAMEOF(src, max_antag_cap))
+ return FALSE
+ return ..()
+
+/datum/dynamic_ruleset/latejoin/vv_edit_var(var_name, var_value)
+ if(var_name == NAMEOF(src, min_antag_cap) || var_name == NAMEOF(src, max_antag_cap))
+ return FALSE
+ return ..()
+
+/datum/dynamic_ruleset/latejoin/is_valid_candidate(mob/candidate, client/candidate_client)
+ if(isnull(candidate.mind))
+ return FALSE
+ if(candidate.mind.assigned_role.title in get_blacklisted_roles())
+ return FALSE
+ return ..()
+
+/datum/dynamic_ruleset/latejoin/traitor
+ name = "Traitor"
+ config_tag = "Latejoin Traitor"
+ preview_antag_datum = /datum/antagonist/traitor
+ pref_flag = ROLE_SYNDICATE_INFILTRATOR
+ jobban_flag = ROLE_TRAITOR
+ weight = 10
+ min_pop = 3
+ blacklisted_roles = list(
+ JOB_HEAD_OF_PERSONNEL,
+ )
+
+/datum/dynamic_ruleset/latejoin/traitor/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/traitor)
+
+/datum/dynamic_ruleset/latejoin/heretic
+ name = "Heretic"
+ config_tag = "Latejoin Heretic"
+ preview_antag_datum = /datum/antagonist/heretic
+ pref_flag = ROLE_HERETIC_SMUGGLER
+ jobban_flag = ROLE_HERETIC
+ weight = 3
+ min_pop = 30 // Ensures good spread of sacrifice targets
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_HERETIC_SACRIFICE)
+ blacklisted_roles = list(
+ JOB_HEAD_OF_PERSONNEL,
+ )
+
+/datum/dynamic_ruleset/latejoin/heretic/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/heretic)
+
+/datum/dynamic_ruleset/latejoin/changeling
+ name = "Changeling"
+ config_tag = "Latejoin Changeling"
+ preview_antag_datum = /datum/antagonist/changeling
+ pref_flag = ROLE_STOWAWAY_CHANGELING
+ jobban_flag = ROLE_CHANGELING
+ weight = 3
+ min_pop = 15
+ blacklisted_roles = list(
+ JOB_HEAD_OF_PERSONNEL,
+ )
+
+/datum/dynamic_ruleset/latejoin/changeling/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/changeling)
+
+/datum/dynamic_ruleset/latejoin/revolution
+ name = "Revolution"
+ config_tag = "Latejoin Revolution"
+ preview_antag_datum = /datum/antagonist/rev/head
+ pref_flag = ROLE_PROVOCATEUR
+ jobban_flag = ROLE_REV_HEAD
+ ruleset_flags = RULESET_HIGH_IMPACT
+ weight = 1
+ min_pop = 30
+ repeatable = FALSE
+ /// How many heads of staff are required to be on the station for this to be selected
+ var/heads_necessary = 3
+
+/datum/dynamic_ruleset/latejoin/revolution/can_be_selected()
+ if(GLOB.revolution_handler)
+ return FALSE
+ var/head_check = 0
+ for(var/mob/player as anything in get_active_player_list(alive_check = TRUE, afk_check = TRUE))
+ if (player.mind.assigned_role.job_flags & JOB_HEAD_OF_STAFF)
+ head_check++
+ return head_check >= heads_necessary
+
+/datum/dynamic_ruleset/latejoin/revolution/get_always_blacklisted_roles()
+ . = ..()
+ for(var/datum/job/job as anything in SSjob.all_occupations)
+ if(job.job_flags & JOB_HEAD_OF_STAFF)
+ . |= job.title
+
+/datum/dynamic_ruleset/latejoin/revolution/assign_role(datum/mind/candidate)
+ LAZYADD(candidate.special_roles, "Dormant Head Revolutionary")
+ addtimer(CALLBACK(src, PROC_REF(reveal_head), candidate), 1 MINUTES, TIMER_DELETE_ME)
+
+/datum/dynamic_ruleset/latejoin/revolution/proc/reveal_head(datum/mind/candidate)
+ LAZYREMOVE(candidate.special_roles, "Dormant Head Revolutionary")
+
+ var/head_check = 0
+ for(var/mob/player as anything in get_active_player_list(alive_check = TRUE, afk_check = TRUE))
+ if(player.mind?.assigned_role.job_flags & JOB_HEAD_OF_STAFF)
+ head_check++
+
+ if(head_check < heads_necessary - 1) // little bit of leeway
+ SSdynamic.unreported_rulesets += src
+ name += " (Canceled)"
+ log_dynamic("[config_tag]: Not enough heads of staff were present to start a revolution.")
+ return
+
+ if(!can_be_headrev(candidate))
+ SSdynamic.unreported_rulesets += src
+ name += " (Canceled)"
+ log_dynamic("[config_tag]: [key_name(candidate)] was ineligible after the timer expired. Ruleset canceled.")
+ message_admins("[config_tag]: [key_name(candidate)] was ineligible after the timer expired. Ruleset canceled.")
+ return
+
+ GLOB.revolution_handler ||= new()
+ var/datum/antagonist/rev/head/new_head = new()
+ new_head.give_flash = TRUE
+ new_head.give_hud = TRUE
+ new_head.remove_clumsy = TRUE
+ candidate.add_antag_datum(new_head, GLOB.revolution_handler.revs)
+ GLOB.revolution_handler.start_revolution()
diff --git a/code/controllers/subsystem/dynamic/dynamic_ruleset_midround.dm b/code/controllers/subsystem/dynamic/dynamic_ruleset_midround.dm
new file mode 100644
index 00000000000..40e46d4cf0e
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/dynamic_ruleset_midround.dm
@@ -0,0 +1,1150 @@
+/datum/dynamic_ruleset/midround
+ repeatable = TRUE
+ repeatable_weight_decrease = 2
+ /// LIGHT_MIDROUND or HEAVY_MIDROUND - determines which pool it enters
+ var/midround_type
+ /// If the false alarm event can pick this ruleset to trigger, well, a false alarm
+ var/false_alarm_able = FALSE
+
+/**
+ * Collect candidates handles getting the broad pool of players we want to pick from
+ *
+ * You can sleep in this - say, if you wanted to poll players.
+ */
+/datum/dynamic_ruleset/midround/proc/collect_candidates()
+ return list()
+
+/**
+ * Called when the ruleset is selected for false alarm
+ */
+/datum/dynamic_ruleset/midround/proc/false_alarm()
+ return
+
+/datum/dynamic_ruleset/midround/spiders
+ name = "Spiders"
+ config_tag = "Spiders"
+ midround_type = HEAVY_MIDROUND
+ false_alarm_able = TRUE
+ ruleset_flags = RULESET_INVADER
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 0,
+ DYNAMIC_TIER_MEDIUMHIGH = 1,
+ DYNAMIC_TIER_HIGH = 2,
+ )
+ min_pop = 30
+ min_antag_cap = 0
+ /// Determines how many eggs to create - can take a formula like antag_cap
+ var/egg_count = 2
+
+/datum/dynamic_ruleset/midround/spiders/can_be_selected()
+ return ..() && (GLOB.ghost_role_flags & GHOSTROLE_MIDROUND_EVENT) && !isnull(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = TRUE))
+
+/datum/dynamic_ruleset/midround/spiders/execute()
+ var/num_egg = get_antag_cap(length(GLOB.alive_player_list), egg_count)
+ while(num_egg > 0)
+ var/turf/spawn_loc = find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = TRUE)
+ if(isnull(spawn_loc))
+ break
+ var/obj/effect/mob_spawn/ghost_role/spider/midwife/new_eggs = new(spawn_loc)
+ new_eggs.amount_grown = 98
+ num_egg--
+
+ addtimer(CALLBACK(src, PROC_REF(announce_spiders)), rand(375, 600) SECONDS)
+
+/datum/dynamic_ruleset/midround/spiders/proc/announce_spiders()
+ priority_announce("Unidentified lifesigns detected coming aboard [station_name()]. Secure any exterior access, including ducting and ventilation.", "Lifesign Alert", ANNOUNCER_ALIENS)
+
+/datum/dynamic_ruleset/midround/spiders/false_alarm()
+ announce_spiders()
+
+/datum/dynamic_ruleset/midround/pirates
+ name = "Pirates"
+ config_tag = "Light Pirates"
+ midround_type = LIGHT_MIDROUND
+ jobban_flag = ROLE_TRAITOR
+ ruleset_flags = RULESET_INVADER|RULESET_ADMIN_CONFIGURABLE
+ weight = 3
+ min_pop = 15
+ min_antag_cap = 0 // ship will spawn if there are no ghosts around
+
+ /// Pool to pick pirates from
+ var/list/datum/pirate_gang/pirate_pool
+
+/datum/dynamic_ruleset/midround/pirates/New(list/dynamic_config)
+ . = ..()
+ pirate_pool = default_pirate_pool()
+
+/datum/dynamic_ruleset/midround/pirates/can_be_selected()
+ return ..() && !SSmapping.is_planetary() && (GLOB.ghost_role_flags & GHOSTROLE_MIDROUND_EVENT) && length(default_pirate_pool()) > 0
+
+// An abornmal ruleset that selects no players, but just spawns a pirate ship
+/datum/dynamic_ruleset/midround/pirates/execute()
+ send_pirate_threat(pirate_pool)
+
+/// Returns what pool of pirates to drawn from
+/// Returned list is mutated by the ruleset
+/datum/dynamic_ruleset/midround/pirates/proc/default_pirate_pool()
+ return GLOB.light_pirate_gangs
+
+/datum/dynamic_ruleset/midround/pirates/heavy
+ name = "Pirates"
+ config_tag = "Heavy Pirates"
+ midround_type = HEAVY_MIDROUND
+ jobban_flag = ROLE_TRAITOR
+ ruleset_flags = RULESET_INVADER
+ weight = 3
+ min_pop = 25
+ min_antag_cap = 0 // ship will spawn if there are no ghosts around
+
+/datum/dynamic_ruleset/midround/pirates/heavy/default_pirate_pool()
+ return GLOB.heavy_pirate_gangs
+
+#define RANDOM_PIRATE_POOL "Random"
+
+/datum/dynamic_ruleset/midround/pirates/configure_ruleset(mob/admin)
+ var/list/admin_pool = list("[RULESET_CONFIG_CANCEL]" = TRUE, "[RANDOM_PIRATE_POOL]" = TRUE)
+ for(var/datum/pirate_gang/gang as anything in default_pirate_pool())
+ admin_pool[gang.name] = gang
+ var/picked = tgui_input_list(admin, "Select a pirate gang", "Pirate Gang Selection", admin_pool)
+ if(!picked || picked == RULESET_CONFIG_CANCEL)
+ return RULESET_CONFIG_CANCEL
+ if(picked == RANDOM_PIRATE_POOL)
+ return null
+
+ pirate_pool = list(admin_pool[picked])
+ return null
+
+#undef RANDOM_PIRATE_POOL
+
+#define NO_ANSWER 0
+#define POSITIVE_ANSWER 1
+#define NEGATIVE_ANSWER 2
+
+/datum/dynamic_ruleset/midround/pirates/proc/send_pirate_threat(list/pirate_selection)
+ var/datum/pirate_gang/chosen_gang = pick_n_take(pirate_selection)
+ ///If there was nothing to pull from our requested list, stop here.
+ if(!chosen_gang)
+ message_admins("Error attempting to run the space pirate event, as the given pirate gangs list was empty.")
+ return
+ //set payoff
+ var/payoff = 0
+ var/datum/bank_account/account = SSeconomy.get_dep_account(ACCOUNT_CAR)
+ if(account)
+ payoff = max(PAYOFF_MIN, FLOOR(account.account_balance * 0.80, 1000))
+ var/datum/comm_message/threat = chosen_gang.generate_message(payoff)
+ //send message
+ priority_announce("Incoming subspace communication. Secure channel opened at all communication consoles.", "Incoming Message", SSstation.announcer.get_rand_report_sound())
+ threat.answer_callback = CALLBACK(src, PROC_REF(pirates_answered), threat, chosen_gang, payoff, world.time)
+ addtimer(CALLBACK(src, PROC_REF(spawn_pirates), threat, chosen_gang), RESPONSE_MAX_TIME)
+ GLOB.communications_controller.send_message(threat, unique = TRUE)
+
+/datum/dynamic_ruleset/midround/pirates/proc/pirates_answered(datum/comm_message/threat, datum/pirate_gang/chosen_gang, payoff, initial_send_time)
+ if(world.time > initial_send_time + RESPONSE_MAX_TIME)
+ priority_announce(chosen_gang.response_too_late, sender_override = chosen_gang.ship_name, color_override = chosen_gang.announcement_color)
+ return
+ if(!threat?.answered)
+ return
+ if(threat.answered == NEGATIVE_ANSWER)
+ priority_announce(chosen_gang.response_rejected, sender_override = chosen_gang.ship_name, color_override = chosen_gang.announcement_color)
+ return
+
+ var/datum/bank_account/plundered_account = SSeconomy.get_dep_account(ACCOUNT_CAR)
+ if(plundered_account)
+ if(plundered_account.adjust_money(-payoff))
+ chosen_gang.paid_off = TRUE
+ priority_announce(chosen_gang.response_received, sender_override = chosen_gang.ship_name, color_override = chosen_gang.announcement_color)
+ else
+ priority_announce(chosen_gang.response_not_enough, sender_override = chosen_gang.ship_name, color_override = chosen_gang.announcement_color)
+
+/datum/dynamic_ruleset/midround/pirates/proc/spawn_pirates(datum/comm_message/threat, datum/pirate_gang/chosen_gang)
+ if(chosen_gang.paid_off)
+ return
+
+ var/list/candidates = SSpolling.poll_ghost_candidates("Do you wish to be considered for a [span_notice("pirate crew of [chosen_gang.name]?")]", check_jobban = ROLE_TRAITOR, alert_pic = /obj/item/claymore/cutlass, role_name_text = "pirate crew")
+ shuffle_inplace(candidates)
+
+ var/template_key = "pirate_[chosen_gang.ship_template_id]"
+ var/datum/map_template/shuttle/pirate/ship = SSmapping.shuttle_templates[template_key]
+ var/x = rand(TRANSITIONEDGE,world.maxx - TRANSITIONEDGE - ship.width)
+ var/y = rand(TRANSITIONEDGE,world.maxy - TRANSITIONEDGE - ship.height)
+ var/z = SSmapping.empty_space.z_value
+ var/turf/T = locate(x,y,z)
+ if(!T)
+ CRASH("Pirate event found no turf to load in")
+
+ if(!ship.load(T))
+ CRASH("Loading pirate ship failed!")
+
+ for(var/turf/area_turf as anything in ship.get_affected_turfs(T))
+ for(var/obj/effect/mob_spawn/ghost_role/human/pirate/spawner in area_turf)
+ if(candidates.len > 0)
+ var/mob/our_candidate = candidates[1]
+ var/mob/spawned_mob = spawner.create_from_ghost(our_candidate)
+ candidates -= our_candidate
+ notify_ghosts(
+ "The [chosen_gang.ship_name] has an object of interest: [spawned_mob]!",
+ source = spawned_mob,
+ header = "Pirates!",
+ )
+ else
+ notify_ghosts(
+ "The [chosen_gang.ship_name] has an object of interest: [spawner]!",
+ source = spawner,
+ header = "Pirate Spawn Here!",
+ )
+
+ priority_announce(chosen_gang.arrival_announcement, sender_override = chosen_gang.ship_name)
+
+#undef NO_ANSWER
+#undef POSITIVE_ANSWER
+#undef NEGATIVE_ANSWER
+/**
+ * ### Ghost rulesets
+ *
+ * Rulesets which select an observer/ghost player to play as a new character
+ *
+ * Implementation notes:
+ * - prepare_role will handle making the body for the mob for you. Avoid touching it if not necessary.
+ * - create_ruleset_body is what makes the new /mob for the candidate. It handles putting the player in the body for you.
+ * You can override it entirely for to spawn a different mob type.
+ * You can also override it to spawn nothing, if you're doing special handling in assign_role, but you'll have to handle moving the player yourself.
+ * - assign_role is what gives the player their antag datum.
+ */
+/datum/dynamic_ruleset/midround/from_ghosts
+ ///Path of an item to show up in ghost polls for applicants to sign up.
+ var/signup_atom_appearance = /obj/structure/sign/poster/contraband/syndicate_recruitment
+ /// Text shown in the candidate poll. Optional, if unset uses pref_flag. (Though required if pref_flag is unset)
+ var/candidate_role
+
+/datum/dynamic_ruleset/midround/from_ghosts/can_be_selected()
+ SHOULD_CALL_PARENT(TRUE)
+ return ..() && (GLOB.ghost_role_flags & GHOSTROLE_MIDROUND_EVENT)
+
+/datum/dynamic_ruleset/midround/from_ghosts/get_candidate_mind(mob/dead/candidate)
+ // Ghost roles will always get a fresh mind
+ return new /datum/mind(candidate.key)
+
+/datum/dynamic_ruleset/midround/from_ghosts/prepare_for_role(datum/mind/candidate)
+ var/mob/living/body = create_ruleset_body()
+ if(isnull(body))
+ return
+ candidate.transfer_to(body, force_key_move = TRUE) // yoinks the candidate's client
+ if(ishuman(body))
+ var/mob/living/carbon/human/human_body = body
+ body.client?.prefs.safe_transfer_prefs_to(body)
+ human_body.dna.remove_all_mutations()
+ human_body.dna.update_dna_identity()
+
+/**
+ * Handles making the body for the candidate
+ *
+ * Handling loc is not necessary here - you can do it in assign_role
+ *
+ * Returning null will skip body creation entirely, though you will be expected to do it yourself in assign_role
+ */
+/datum/dynamic_ruleset/midround/from_ghosts/proc/create_ruleset_body()
+ return new /mob/living/carbon/human
+
+/datum/dynamic_ruleset/midround/from_ghosts/collect_candidates()
+ var/readable_poll_role = candidate_role || pref_flag
+ if(isnull(readable_poll_role))
+ stack_trace("[config_tag]: No candidate role or pref_flag set, give it a human readable candidate roll at the bare minimum.")
+ readable_poll_role = "Some Midround Antagonist Without A Role Set (Yell At Coders)"
+
+ return SSpolling.poll_candidates(
+ group = trim_candidates(GLOB.dead_player_list | GLOB.current_observers_list),
+ question = "Looking for volunteers to become [span_notice(readable_poll_role)] for [span_danger(name)]",
+ // check_jobban = list(ROLE_SYNDICATE, jobban_flag || pref_flag), // Not necessary, handled in trim_candidates()
+ // role = pref_flag, // Not necessary, handled in trim_candidates()
+ poll_time = 30 SECONDS,
+ alert_pic = signup_atom_appearance,
+ role_name_text = readable_poll_role,
+ )
+
+/datum/dynamic_ruleset/midround/from_ghosts/wizard
+ name = "Wizard"
+ config_tag = "Midround Wizard"
+ preview_antag_datum = /datum/antagonist/wizard
+ midround_type = HEAVY_MIDROUND
+ candidate_role = "Wizard"
+ pref_flag = ROLE_WIZARD_MIDROUND
+ jobban_flag = ROLE_WIZARD
+ ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 0,
+ DYNAMIC_TIER_MEDIUMHIGH = 1,
+ DYNAMIC_TIER_HIGH = 2,
+ )
+ min_pop = 30
+ max_antag_cap = 1
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_WIZARDDEN)
+ signup_atom_appearance = /obj/item/clothing/head/wizard
+
+/datum/dynamic_ruleset/midround/from_ghosts/wizard/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/wizard) // moves to lair for us
+
+/datum/dynamic_ruleset/midround/from_ghosts/nukies
+ name = "Nuclear Operatives"
+ config_tag = "Midround Nukeops"
+ preview_antag_datum = /datum/antagonist/nukeop
+ midround_type = HEAVY_MIDROUND
+ candidate_role = "Operative"
+ pref_flag = ROLE_OPERATIVE_MIDROUND
+ jobban_flag = ROLE_OPERATIVE
+ ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ min_antag_cap = list("denominator" = 18, "offset" = 1)
+ repeatable = FALSE
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_NUKIEBASE)
+ signup_atom_appearance = /obj/machinery/nuclearbomb/syndicate
+
+/datum/dynamic_ruleset/midround/from_ghosts/nukies/create_execute_args()
+ return list(
+ new /datum/team/nuclear(),
+ get_most_experienced(selected_minds, pref_flag),
+ )
+
+/datum/dynamic_ruleset/midround/from_ghosts/nukies/assign_role(datum/mind/candidate, datum/team/nuclear/nuke_team, datum/mind/most_experienced)
+ if(most_experienced == candidate)
+ candidate.add_antag_datum(/datum/antagonist/nukeop/leader, nuke_team) // moves to nuke base for us
+ else
+ candidate.add_antag_datum(/datum/antagonist/nukeop, nuke_team) // moves to nuke base for us
+
+/datum/dynamic_ruleset/midround/from_ghosts/nukies/round_result()
+ var/datum/antagonist/nukeop/nukie = selected_minds[1].has_antag_datum(/datum/antagonist/nukeop)
+ var/datum/team/nuclear/nuke_team = nukie.get_team()
+ var/result = nuke_team.get_result()
+ switch(result)
+ if(NUKE_RESULT_FLUKE)
+ SSticker.mode_result = "loss - syndicate nuked - disk secured"
+ SSticker.news_report = NUKE_SYNDICATE_BASE
+ if(NUKE_RESULT_NUKE_WIN)
+ SSticker.mode_result = "win - syndicate nuke"
+ SSticker.news_report = STATION_DESTROYED_NUKE
+ if(NUKE_RESULT_NOSURVIVORS)
+ SSticker.mode_result = "halfwin - syndicate nuke - did not evacuate in time"
+ SSticker.news_report = STATION_DESTROYED_NUKE
+ if(NUKE_RESULT_WRONG_STATION)
+ SSticker.mode_result = "halfwin - blew wrong station"
+ SSticker.news_report = NUKE_MISS
+ if(NUKE_RESULT_WRONG_STATION_DEAD)
+ SSticker.mode_result = "halfwin - blew wrong station - did not evacuate in time"
+ SSticker.news_report = NUKE_MISS
+ if(NUKE_RESULT_CREW_WIN_SYNDIES_DEAD)
+ SSticker.mode_result = "loss - evacuation - disk secured - syndi team dead"
+ SSticker.news_report = OPERATIVES_KILLED
+ if(NUKE_RESULT_CREW_WIN)
+ SSticker.mode_result = "loss - evacuation - disk secured"
+ SSticker.news_report = OPERATIVES_KILLED
+ if(NUKE_RESULT_DISK_LOST)
+ SSticker.mode_result = "halfwin - evacuation - disk not secured"
+ SSticker.news_report = OPERATIVE_SKIRMISH
+ if(NUKE_RESULT_DISK_STOLEN)
+ SSticker.mode_result = "halfwin - detonation averted"
+ SSticker.news_report = OPERATIVE_SKIRMISH
+ else
+ SSticker.mode_result = "halfwin - interrupted"
+ SSticker.news_report = OPERATIVE_SKIRMISH
+
+/datum/dynamic_ruleset/midround/from_ghosts/nukies/clown
+ name = "Clown Operatives"
+ config_tag = "Midround Clownops"
+ preview_antag_datum = /datum/antagonist/nukeop/clownop
+ candidate_role = "Operative"
+ pref_flag = ROLE_CLOWN_OPERATIVE_MIDROUND
+ jobban_flag = ROLE_CLOWN_OPERATIVE
+ weight = 0
+ signup_atom_appearance = /obj/machinery/nuclearbomb/syndicate/bananium
+
+/datum/dynamic_ruleset/midround/from_ghosts/nukies/clown/assign_role(datum/mind/candidate, datum/team/nuclear/nuke_team, datum/mind/most_experienced)
+ if(most_experienced == candidate)
+ candidate.add_antag_datum(/datum/antagonist/nukeop/leader/clownop, nuke_team) // moves to nuke base for us
+ else
+ candidate.add_antag_datum(/datum/antagonist/nukeop/clownop, nuke_team) // moves to nuke base for us
+
+/datum/dynamic_ruleset/midround/from_ghosts/blob
+ name = "Blob"
+ config_tag = "Blob"
+ preview_antag_datum = /datum/antagonist/blob
+ midround_type = HEAVY_MIDROUND
+ false_alarm_able = TRUE
+ pref_flag = ROLE_BLOB
+ ruleset_flags = RULESET_INVADER
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ max_antag_cap = 1
+ repeatable_weight_decrease = 3
+ signup_atom_appearance = /obj/structure/blob/normal
+ /// How many points does the blob spawn with
+ var/starting_points = OVERMIND_STARTING_POINTS
+
+/datum/dynamic_ruleset/midround/from_ghosts/blob/create_ruleset_body()
+ return new /mob/eye/blob(get_blobspawn(), starting_points)
+
+/datum/dynamic_ruleset/midround/from_ghosts/blob/assign_role(datum/mind/candidate)
+ return // everything is handled by blob new()
+
+/datum/dynamic_ruleset/midround/from_ghosts/blob/proc/get_blobspawn()
+ if(!length(GLOB.blobstart))
+ var/obj/effect/landmark/observer_start/default = locate() in GLOB.landmarks_list
+ return get_turf(default)
+
+ return pick(GLOB.blobstart)
+
+/datum/dynamic_ruleset/midround/from_ghosts/blob/false_alarm()
+ priority_announce("Confirmed outbreak of level 5 biohazard aboard [station_name()]. All personnel must contain the outbreak.", "Biohazard Alert", ANNOUNCER_OUTBREAK5)
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph
+ name = "Alien Infestation"
+ config_tag = "Xenomorph"
+ preview_antag_datum = /datum/antagonist/xeno
+ midround_type = HEAVY_MIDROUND
+ false_alarm_able = TRUE
+ pref_flag = ROLE_ALIEN
+ ruleset_flags = RULESET_INVADER
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 5,
+ DYNAMIC_TIER_HIGH = 5,
+ )
+ min_pop = 30
+ max_antag_cap = 1
+ min_antag_cap = 1
+ repeatable_weight_decrease = 3
+ signup_atom_appearance = /mob/living/basic/alien
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/New(list/dynamic_config)
+ . = ..()
+ max_antag_cap += prob(50) // 50% chance to get a second xeno, free!
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/can_be_selected()
+ return ..() && length(find_vents()) > 0
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/execute()
+ . = ..()
+ addtimer(CALLBACK(src, PROC_REF(announce_xenos)), rand(375, 600) SECONDS)
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/proc/announce_xenos()
+ priority_announce("Unidentified lifesigns detected coming aboard [station_name()]. Secure any exterior access, including ducting and ventilation.", "Lifesign Alert", ANNOUNCER_ALIENS)
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/false_alarm()
+ announce_xenos()
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/create_ruleset_body()
+ return new /mob/living/carbon/alien/larva
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/create_execute_args()
+ return list(find_vents())
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/assign_role(datum/mind/candidate, list/vent_list)
+ // xeno login gives antag datums
+ var/obj/vent = length(vent_list) >= 2 ? pick_n_take(vent_list) : vent_list[1]
+ candidate.current.move_into_vent(vent)
+
+/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/proc/find_vents()
+ var/list/vents = list()
+ var/list/vent_pumps = SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/atmospherics/components/unary/vent_pump)
+ for(var/obj/machinery/atmospherics/components/unary/vent_pump/temp_vent as anything in vent_pumps)
+ if(QDELETED(temp_vent))
+ continue
+ if(!is_station_level(temp_vent.loc.z) || temp_vent.welded)
+ continue
+ var/datum/pipeline/temp_vent_parent = temp_vent.parents[1]
+ if(!temp_vent_parent)
+ continue
+ // Stops Aliens getting stuck in small networks.
+ // See: Security, Virology
+ if(length(temp_vent_parent.other_atmos_machines) <= 20)
+ continue
+ vents += temp_vent
+ return vents
+
+/datum/dynamic_ruleset/midround/from_ghosts/nightmare
+ name = "Nightmare"
+ config_tag = "Nightmare"
+ preview_antag_datum = /datum/antagonist/nightmare
+ midround_type = LIGHT_MIDROUND
+ pref_flag = ROLE_NIGHTMARE
+ ruleset_flags = RULESET_INVADER
+ weight = 5
+ min_pop = 15
+ max_antag_cap = 1
+ signup_atom_appearance = /obj/item/light_eater
+
+/datum/dynamic_ruleset/midround/from_ghosts/nightmare/can_be_selected()
+ return ..() && !isnull(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = TRUE))
+
+/datum/dynamic_ruleset/midround/from_ghosts/nightmare/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/nightmare)
+ candidate.current.set_species(/datum/species/shadow/nightmare)
+ candidate.current.forceMove(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = TRUE))
+ playsound(candidate.current, 'sound/effects/magic/ethereal_exit.ogg', 50, TRUE, -1)
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_dragon
+ name = "Space Dragon"
+ config_tag = "Space Dragon"
+ preview_antag_datum = /datum/antagonist/space_dragon
+ midround_type = HEAVY_MIDROUND
+ false_alarm_able = TRUE
+ pref_flag = ROLE_SPACE_DRAGON
+ ruleset_flags = RULESET_INVADER
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 3,
+ DYNAMIC_TIER_MEDIUMHIGH = 5,
+ DYNAMIC_TIER_HIGH = 5,
+ )
+ min_pop = 30
+ max_antag_cap = 1
+ repeatable_weight_decrease = 3
+ signup_atom_appearance = /mob/living/basic/space_dragon
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/can_be_selected()
+ return ..() && !isnull(find_space_spawn())
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/create_ruleset_body()
+ return new /mob/living/basic/space_dragon
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/space_dragon)
+ candidate.current.forceMove(find_space_spawn())
+ playsound(candidate.current, 'sound/effects/magic/ethereal_exit.ogg', 50, TRUE, -1)
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/execute()
+ . = ..()
+ addtimer(CALLBACK(src, PROC_REF(announce_space_dragon)), rand(5, 10) SECONDS)
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/proc/announce_space_dragon()
+ priority_announce("A large organic energy flux has been recorded near of [station_name()], please stand-by.", "Lifesign Alert")
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/false_alarm()
+ announce_space_dragon()
+
+/datum/dynamic_ruleset/midround/from_ghosts/abductors
+ name = "Abductors"
+ config_tag = "Abductors"
+ preview_antag_datum = /datum/antagonist/abductor
+ midround_type = LIGHT_MIDROUND
+ pref_flag = ROLE_ABDUCTOR
+ ruleset_flags = RULESET_INVADER
+ weight = 5
+ min_pop = 20
+ min_antag_cap = 2
+ repeatable_weight_decrease = 3
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_ABDUCTOR_SHIPS)
+ signup_atom_appearance = /obj/item/melee/baton/abductor
+
+/datum/dynamic_ruleset/midround/from_ghosts/abductors/can_be_selected()
+ if(!..())
+ return FALSE
+ var/num_abductors = 0
+ for(var/datum/team/abductor_team/team in GLOB.antagonist_teams)
+ num_abductors++
+ return num_abductors < 4
+
+/datum/dynamic_ruleset/midround/from_ghosts/abductors/create_execute_args()
+ return list(new /datum/team/abductor_team())
+
+/datum/dynamic_ruleset/midround/from_ghosts/abductors/assign_role(datum/mind/candidate, datum/team/abductor_team/team)
+ if(candidate == selected_minds[1])
+ candidate.add_antag_datum(/datum/antagonist/abductor/scientist, team) // sets species and moves to spawn point
+ else
+ candidate.add_antag_datum(/datum/antagonist/abductor/agent, team) // sets species and moves to spawn point
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_ninja
+ name = "Space Ninja"
+ config_tag = "Space Ninja"
+ preview_antag_datum = /datum/antagonist/ninja
+ midround_type = HEAVY_MIDROUND
+ pref_flag = ROLE_NINJA
+ ruleset_flags = RULESET_INVADER
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 0,
+ DYNAMIC_TIER_MEDIUMHIGH = 1,
+ DYNAMIC_TIER_HIGH = 2,
+ )
+ min_pop = 30
+ max_antag_cap = 1
+ repeatable = FALSE
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_NINJA_HOLDING_FACILITY)
+ signup_atom_appearance = /obj/item/energy_katana
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_ninja/can_be_selected()
+ return ..() && !isnull(find_space_spawn())
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_ninja/assign_role(datum/mind/candidate)
+ var/mob/living/carbon/human/new_ninja = candidate.current
+ new_ninja.forceMove(find_space_spawn()) // ninja antag datum needs the mob to be in place first
+ randomize_human_normie(new_ninja)
+ var/new_name = "[pick(GLOB.ninja_titles)] [pick(GLOB.ninja_names)]"
+ new_ninja.name = new_name
+ new_ninja.real_name = new_name
+ new_ninja.dna.update_dna_identity() // ninja antag datum needs dna to be set first
+ candidate.add_antag_datum(/datum/antagonist/ninja)
+
+/datum/dynamic_ruleset/midround/from_ghosts/revenant
+ name = "Revenant"
+ config_tag = "Revenant"
+ preview_antag_datum = /datum/antagonist/revenant
+ midround_type = LIGHT_MIDROUND
+ pref_flag = ROLE_REVENANT
+ ruleset_flags = RULESET_INVADER
+ weight = 5
+ min_pop = 10
+ max_antag_cap = 1
+ repeatable = FALSE
+ signup_atom_appearance = /mob/living/basic/revenant
+ /// There must be this many dead mobs on the station for a revenant to spawn (of all mob types, not just humans)
+ /// Remember there's usually 2-3 that spawn in the Morgue roundstart, so adjust this accordingly
+ var/required_station_corpses = 10
+
+/datum/dynamic_ruleset/midround/from_ghosts/revenant/can_be_selected()
+ if(!..())
+ return FALSE
+ var/num_station_corpses = 0
+ for(var/mob/deceased as anything in GLOB.dead_mob_list)
+ var/turf/deceased_turf = get_turf(deceased)
+ if(is_station_level(deceased_turf?.z))
+ num_station_corpses++
+
+ return num_station_corpses > required_station_corpses
+
+/datum/dynamic_ruleset/midround/from_ghosts/revenant/create_ruleset_body()
+ return new /mob/living/basic/revenant(pick(get_revenant_spawns()))
+
+/datum/dynamic_ruleset/midround/from_ghosts/revenant/assign_role(datum/mind/candidate)
+ return // revenant new() handles everything
+
+/datum/dynamic_ruleset/midround/from_ghosts/revenant/proc/get_revenant_spawns()
+ var/list/spawn_locs = list()
+ for(var/mob/deceased in GLOB.dead_mob_list)
+ var/turf/deceased_turf = get_turf(deceased)
+ if(is_station_level(deceased_turf?.z))
+ spawn_locs += deceased_turf
+ if(!length(spawn_locs) || length(spawn_locs) < 12) // get a comfortably large pool of spawnpoints
+ for(var/obj/structure/bodycontainer/corpse_container in GLOB.bodycontainers)
+ var/turf/container_turf = get_turf(corpse_container)
+ if(is_station_level(container_turf?.z))
+ spawn_locs += container_turf
+ if(!length(spawn_locs) || length(spawn_locs) < 4) // get a comfortably large pool of spawnpoints
+ for(var/obj/effect/landmark/carpspawn/carpspawn in GLOB.landmarks_list)
+ spawn_locs += carpspawn.loc
+
+ return spawn_locs
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_changeling
+ name = "Space Changeling"
+ config_tag = "Midround Changeling"
+ preview_antag_datum = /datum/antagonist/changeling/space
+ midround_type = LIGHT_MIDROUND
+ candidate_role = "Changeling"
+ pref_flag = ROLE_CHANGELING_MIDROUND
+ jobban_flag = ROLE_CHANGELING
+ ruleset_flags = RULESET_INVADER
+ weight = 5
+ min_pop = 15
+ max_antag_cap = 1
+ signup_atom_appearance = /obj/effect/meteor/meaty/changeling
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_changeling/create_ruleset_body()
+ return // handled by generate_changeling_meteor() entirely
+
+/datum/dynamic_ruleset/midround/from_ghosts/space_changeling/assign_role(datum/mind/candidate)
+ generate_changeling_meteor(candidate)
+
+/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone
+ name = "Paradox Clone"
+ config_tag = "Paradox Clone"
+ preview_antag_datum = /datum/antagonist/paradox_clone
+ midround_type = LIGHT_MIDROUND
+ pref_flag = ROLE_PARADOX_CLONE
+ ruleset_flags = RULESET_INVADER
+ weight = 5
+ min_pop = 10
+ max_antag_cap = 1
+ signup_atom_appearance = /obj/effect/bluespace_stream
+
+/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/can_be_selected()
+ return ..() && !isnull(find_clone()) && !isnull(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE))
+
+/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/create_ruleset_body()
+ return // handled by assign_role() entirely
+
+/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/assign_role(datum/mind/candidate)
+ var/mob/living/carbon/human/good_version = find_clone()
+ var/mob/living/carbon/human/bad_version = good_version.make_full_human_copy(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE))
+ candidate.transfer_to(bad_version, force_key_move = TRUE)
+
+ var/datum/antagonist/paradox_clone/antag = candidate.add_antag_datum(/datum/antagonist/paradox_clone)
+ antag.original_ref = WEAKREF(good_version.mind)
+ antag.setup_clone()
+
+ playsound(bad_version, 'sound/items/weapons/zapbang.ogg', 30, TRUE)
+ bad_version.put_in_hands(new /obj/item/storage/toolbox/mechanical()) //so they dont get stuck in maints
+
+/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/proc/find_clone()
+ var/list/possible_targets = list()
+
+ for(var/mob/living/carbon/human/player in GLOB.player_list)
+ if(!player.client || !player.mind || player.stat != CONSCIOUS)
+ continue
+ if(!(player.mind.assigned_role.job_flags & JOB_CREW_MEMBER))
+ continue
+ possible_targets += player
+
+ if(length(possible_targets))
+ return pick(possible_targets)
+ return null
+
+/datum/dynamic_ruleset/midround/from_ghosts/voidwalker
+ name = "Voidwalker"
+ config_tag = "Voidwalker"
+ preview_antag_datum = /datum/antagonist/voidwalker
+ midround_type = LIGHT_MIDROUND
+ pref_flag = ROLE_VOIDWALKER
+ ruleset_flags = RULESET_INVADER
+ weight = 5
+ min_pop = 30 // Ensures there's a lot of people near windows
+ max_antag_cap = 1
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_VOIDWALKER_VOID)
+ signup_atom_appearance = /obj/item/clothing/head/helmet/skull/cosmic
+
+/datum/dynamic_ruleset/midround/from_ghosts/voidwalker/can_be_selected()
+ return ..() && !SSmapping.is_planetary() && !isnull(find_space_spawn())
+
+/datum/dynamic_ruleset/midround/from_ghosts/voidwalker/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/voidwalker)
+ candidate.current.set_species(/datum/species/voidwalker)
+ candidate.current.forceMove(find_space_spawn())
+ playsound(candidate.current, 'sound/effects/magic/ethereal_exit.ogg', 50, TRUE, -1)
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives
+ name = "Fugitive"
+ config_tag = "Fugitives"
+ preview_antag_datum = /datum/antagonist/fugitive
+ midround_type = LIGHT_MIDROUND
+ pref_flag = ROLE_FUGITIVE
+ ruleset_flags = RULESET_INVADER|RULESET_ADMIN_CONFIGURABLE
+ weight = 3
+ min_pop = 20
+ max_antag_cap = 4
+ min_antag_cap = 3
+ repeatable = FALSE
+ signup_atom_appearance = /obj/item/card/id/advanced/prisoner
+ /// What backstory is the fugitive(s)?
+ VAR_FINAL/fugitive_backstory
+ /// What backstory is the hunter(s)?
+ VAR_FINAL/hunter_backstory
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/can_be_selected()
+ return ..() && !SSmapping.is_planetary() && !isnull(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE))
+
+// If less than a certain number of candidates accept the poll, it varies how many antags are spawned
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/collect_candidates()
+ . = ..()
+ if(length(.) <= 1 || prob(30 - (length(.) * 2)))
+ min_antag_cap = 1
+ max_antag_cap = 1
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/create_execute_args()
+ return list(
+ new /datum/team/fugitive(),
+ find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE),
+ )
+
+#define RANDOM_BACKSTORY "Random"
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/configure_ruleset(mob/admin)
+ var/list/fugitive_backstories = list(
+ FUGITIVE_BACKSTORY_CULTIST,
+ FUGITIVE_BACKSTORY_INVISIBLE,
+ FUGITIVE_BACKSTORY_PRISONER,
+ FUGITIVE_BACKSTORY_SYNTH,
+ FUGITIVE_BACKSTORY_WALDO,
+ RANDOM_BACKSTORY,
+ RULESET_CONFIG_CANCEL,
+ )
+ var/list/hunter_backstories = list(
+ HUNTER_PACK_BOUNTY,
+ HUNTER_PACK_COPS,
+ HUNTER_PACK_MI13,
+ HUNTER_PACK_PSYKER,
+ HUNTER_PACK_RUSSIAN,
+ RANDOM_BACKSTORY,
+ RULESET_CONFIG_CANCEL,
+ )
+
+ var/picked_fugitive_backstory = tgui_input_list(admin, "Select a fugitive backstory", "Fugitive Backstory", fugitive_backstories)
+ if(!picked_fugitive_backstory || picked_fugitive_backstory == RULESET_CONFIG_CANCEL)
+ return RULESET_CONFIG_CANCEL
+ if(picked_fugitive_backstory != RANDOM_BACKSTORY)
+ fugitive_backstory = picked_fugitive_backstory
+
+ var/picked_hunter_backstory = tgui_input_list(admin, "Select a hunter backstory", "Hunter Backstory", hunter_backstories)
+ if(!picked_hunter_backstory || picked_hunter_backstory == RULESET_CONFIG_CANCEL)
+ return RULESET_CONFIG_CANCEL
+ if(picked_hunter_backstory != RANDOM_BACKSTORY)
+ hunter_backstory = picked_hunter_backstory
+
+ return null
+
+#undef RANDOM_BACKSTORY
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/execute()
+ if(length(selected_minds) == 1)
+ fugitive_backstory ||= pick(
+ FUGITIVE_BACKSTORY_INVISIBLE,
+ FUGITIVE_BACKSTORY_WALDO,
+ )
+ else
+ fugitive_backstory ||= pick(
+ FUGITIVE_BACKSTORY_CULTIST,
+ FUGITIVE_BACKSTORY_PRISONER,
+ FUGITIVE_BACKSTORY_SYNTH,
+ )
+
+ hunter_backstory ||= pick(
+ HUNTER_PACK_COPS,
+ HUNTER_PACK_RUSSIAN,
+ HUNTER_PACK_BOUNTY,
+ HUNTER_PACK_PSYKER,
+ HUNTER_PACK_MI13,
+ )
+ . = ..()
+ addtimer(CALLBACK(src, PROC_REF(check_spawn_hunters), hunter_backstory, 10 MINUTES), 1 MINUTES)
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/assign_role(datum/mind/candidate, datum/team/fugitive/team, turf/team_spawn)
+ candidate.current.forceMove(team_spawn)
+ equip_fugitive(candidate.current, team)
+ if(length(selected_minds) > 1 && candidate == selected_minds[1])
+ equip_fugitive_leader(candidate.current)
+ playsound(candidate.current, 'sound/items/weapons/emitter.ogg', 50, TRUE)
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/proc/equip_fugitive(mob/living/carbon/human/fugitive, datum/team/fugitive/team)
+ fugitive.set_species(/datum/species/human)
+ randomize_human_normie(fugitive)
+
+ var/datum/antagonist/fugitive/antag = new()
+ antag.backstory = fugitive_backstory
+ fugitive.mind.add_antag_datum(antag, team)
+ // Should really datumize this at some point
+ switch(fugitive_backstory)
+ if(FUGITIVE_BACKSTORY_PRISONER)
+ fugitive.equipOutfit(/datum/outfit/prisoner)
+ if(FUGITIVE_BACKSTORY_CULTIST)
+ fugitive.equipOutfit(/datum/outfit/yalp_cultist)
+ if(FUGITIVE_BACKSTORY_WALDO)
+ fugitive.equipOutfit(/datum/outfit/waldo)
+ if(FUGITIVE_BACKSTORY_SYNTH)
+ fugitive.equipOutfit(/datum/outfit/synthetic)
+ if(FUGITIVE_BACKSTORY_INVISIBLE)
+ fugitive.equipOutfit(/datum/outfit/invisible_man)
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/proc/equip_fugitive_leader(mob/living/carbon/human/fugitive)
+ var/turf/leader_turf = get_turf(fugitive)
+ var/obj/item/storage/toolbox/mechanical/toolbox = new(leader_turf)
+ fugitive.put_in_hands(toolbox)
+
+ switch(fugitive_backstory)
+ if(FUGITIVE_BACKSTORY_SYNTH)
+ new /obj/item/choice_beacon/augments(leader_turf)
+ new /obj/item/autosurgeon(leader_turf)
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/proc/check_spawn_hunters(remaining_time)
+ //if the emergency shuttle has been called, spawn hunters now to give them a chance
+ if(remaining_time == 0 || !EMERGENCY_IDLE_OR_RECALLED)
+ spawn_hunters()
+ return
+ addtimer(CALLBACK(src, PROC_REF(check_spawn_hunters), remaining_time - 1 MINUTES), 1 MINUTES)
+
+/datum/dynamic_ruleset/midround/from_ghosts/fugitives/proc/spawn_hunters()
+ var/list/candidates = SSpolling.poll_ghost_candidates("Do you wish to be considered for a group of [span_notice(hunter_backstory)]?", check_jobban = list(ROLE_FUGITIVE_HUNTER, ROLE_SYNDICATE), alert_pic = /obj/machinery/sleeper, role_name_text = hunter_backstory)
+ shuffle_inplace(candidates)
+
+ var/datum/map_template/shuttle/hunter/ship
+ switch(hunter_backstory)
+ if(HUNTER_PACK_COPS)
+ ship = new /datum/map_template/shuttle/hunter/space_cop
+ if(HUNTER_PACK_RUSSIAN)
+ ship = new /datum/map_template/shuttle/hunter/russian
+ if(HUNTER_PACK_BOUNTY)
+ ship = new /datum/map_template/shuttle/hunter/bounty
+ if(HUNTER_PACK_PSYKER)
+ ship = new /datum/map_template/shuttle/hunter/psyker
+ if(HUNTER_PACK_MI13)
+ ship = new/datum/map_template/shuttle/hunter/mi13_foodtruck
+
+ var/x = rand(TRANSITIONEDGE, world.maxx - TRANSITIONEDGE - ship.width)
+ var/y = rand(TRANSITIONEDGE, world.maxy - TRANSITIONEDGE - ship.height)
+ var/z = SSmapping.empty_space.z_value
+ var/turf/placement_turf = locate(x, y ,z)
+ if(!placement_turf)
+ CRASH("Fugitive Hunters (Created from fugitive event) found no turf to load in")
+ if(!ship.load(placement_turf))
+ CRASH("Loading [hunter_backstory] ship failed!")
+
+ for(var/turf/shuttle_turf in ship.get_affected_turfs(placement_turf))
+ for(var/obj/effect/mob_spawn/ghost_role/human/fugitive/spawner in shuttle_turf)
+ if(length(candidates))
+ var/mob/our_candidate = candidates[1]
+ var/mob/spawned_mob = spawner.create_from_ghost(our_candidate)
+ candidates -= our_candidate
+ notify_ghosts(
+ "[spawner.prompt_name] has awoken: [spawned_mob]!",
+ source = spawned_mob,
+ header = "Come look!",
+ )
+ else
+ notify_ghosts(
+ "[spawner.prompt_name] spawner has been created!",
+ source = spawner,
+ header = "Spawn Here!",
+ )
+
+ var/list/announcement_text_list = list()
+ var/announcement_title = ""
+ switch(hunter_backstory)
+ if(HUNTER_PACK_COPS)
+ announcement_text_list += "Attention Crew of [station_name()], this is the Police. A wanted criminal has been reported taking refuge on your station."
+ announcement_text_list += "We have a warrant from the SSC authorities to take them into custody. Officers have been dispatched to your location."
+ announcement_text_list += "We demand your cooperation in bringing this criminal to justice."
+ announcement_title += "Spacepol Command"
+ if(HUNTER_PACK_RUSSIAN)
+ announcement_text_list += "Zdraviya zhelaju, [station_name()] crew. We are coming to your station."
+ announcement_text_list += "There is a criminal aboard. We will arrest them and return them to the gulag. That's good, yes?"
+ announcement_title += "Russian Freighter"
+ if(HUNTER_PACK_BOUNTY)
+ announcement_text_list += "[station_name()]. One of our bounty marks has ended up on your station. We will be arriving to collect shortly."
+ announcement_text_list += "Let's make this quick. If you don't want trouble, stay the hell out of our way."
+ announcement_title += "Unregistered Signal"
+ if(HUNTER_PACK_PSYKER)
+ announcement_text_list += "HEY, CAN YOU HEAR US? We're coming to your station. There's a bad guy down there, really bad guy. We need to arrest them."
+ announcement_text_list += "We're also offering fortune telling services out of the front door if you have paying customers."
+ announcement_title += "Fortune-Telling Entertainment Shuttle"
+ if(HUNTER_PACK_MI13)
+ announcement_text_list += "Illegal intrusion detected in the crew monitoring network. Central Command has been informed."
+ announcement_text_list += "Please report any suspicious individuals or behaviour to your local security team."
+ announcement_title += "Nanotrasen Intrusion Countermeasures Electronics"
+
+ if(!length(announcement_text_list))
+ announcement_text_list += "Unidentified ship detected near the station."
+ stack_trace("Fugitive hunter announcement was unable to generate an announcement text based on backstory: [hunter_backstory]")
+
+ if(!length(announcement_title))
+ announcement_title += "Unknown Signal"
+ stack_trace("Fugitive hunter announcement was unable to generate an announcement title based on backstory: [hunter_backstory]")
+
+ priority_announce(jointext(announcement_text_list, " "), announcement_title)
+
+/datum/dynamic_ruleset/midround/from_ghosts/morph
+ name = "Morph"
+ config_tag = "Morph"
+ // preview_antag_datum = /datum/antagonist/morph // Doesn't actually have its own pref
+ midround_type = LIGHT_MIDROUND
+ candidate_role = "Morphling"
+ jobban_flag = ROLE_ALIEN
+ ruleset_flags = RULESET_INVADER
+ weight = 0
+ max_antag_cap = 1
+ signup_atom_appearance = /mob/living/basic/morph
+
+/datum/dynamic_ruleset/midround/from_ghosts/morph/can_be_selected()
+ return ..() && !isnull(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE))
+
+/datum/dynamic_ruleset/midround/from_ghosts/morph/create_ruleset_body()
+ return new /mob/living/basic/morph(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE))
+
+/datum/dynamic_ruleset/midround/from_ghosts/morph/assign_role(datum/mind/candidate)
+ candidate.set_assigned_role(SSjob.get_job_type(/datum/job/morph))
+ candidate.add_antag_datum(/datum/antagonist/morph)
+
+/datum/dynamic_ruleset/midround/from_ghosts/slaughter_demon
+ name = "Slaughter Demon"
+ config_tag = "Slaughter Demon"
+ candidate_role = "Slaughter Demon"
+ // preview_antag_datum = /datum/antagonist/slaughter // Doesn't actually have its own pref
+ midround_type = HEAVY_MIDROUND
+ jobban_flag = ROLE_ALIEN
+ ruleset_flags = RULESET_INVADER
+ weight = 0
+ min_pop = 20
+ max_antag_cap = 1
+ signup_atom_appearance = /mob/living/basic/demon/slaughter
+
+/datum/dynamic_ruleset/midround/from_ghosts/slaughter_demon/can_be_selected()
+ return ..() && !isnull(find_space_spawn())
+
+/datum/dynamic_ruleset/midround/from_ghosts/slaughter_demon/create_ruleset_body()
+ var/turf/spawnloc = find_space_spawn()
+ . = new /mob/living/basic/demon/slaughter(spawnloc)
+ new /obj/effect/dummy/phased_mob/blood(spawnloc, .)
+
+/datum/dynamic_ruleset/midround/from_ghosts/slaughter_demon/assign_role(datum/mind/candidate)
+ return // handled by new() entirely
+
+/datum/dynamic_ruleset/midround/from_living
+ min_antag_cap = 1
+ max_antag_cap = 1
+ repeatable = TRUE
+
+/datum/dynamic_ruleset/midround/from_living/set_config_value(nvar, nval)
+ if(nvar == NAMEOF(src, min_antag_cap) || nvar == NAMEOF(src, max_antag_cap))
+ return FALSE
+ return ..()
+
+/datum/dynamic_ruleset/midround/from_living/vv_edit_var(var_name, var_value)
+ if(var_name == NAMEOF(src, min_antag_cap) || var_name == NAMEOF(src, max_antag_cap))
+ return FALSE
+ return ..()
+
+/datum/dynamic_ruleset/midround/from_living/collect_candidates()
+ return GLOB.alive_player_list
+
+/datum/dynamic_ruleset/midround/from_living/is_valid_candidate(mob/candidate, client/candidate_client)
+ if(candidate.stat == DEAD || isnull(candidate.mind))
+ return FALSE
+ // only pick members of the crew
+ if(!job_check(candidate))
+ return FALSE
+ if(!antag_check(candidate))
+ return FALSE
+ // checks for stuff like bitrunner avatars and ghost mafia
+ if(HAS_TRAIT(candidate, TRAIT_MIND_TEMPORARILY_GONE) || HAS_TRAIT(candidate, TRAIT_TEMPORARY_BODY))
+ return FALSE
+ if(SEND_SIGNAL(candidate, COMSIG_MOB_MIND_BEFORE_MIDROUND_ROLL, src, pref_flag) & CANCEL_ROLL)
+ return FALSE
+ return ..()
+
+/// Checks if the candidate is a valid job for this ruleset - by default you probably only want crew members. (Return FALSE to mark the candidate invalid)
+/datum/dynamic_ruleset/midround/from_living/proc/job_check(mob/candidate)
+ if(!(candidate.mind.assigned_role.job_flags & JOB_CREW_MEMBER))
+ return FALSE
+ if(candidate.mind.assigned_role.title in get_blacklisted_roles())
+ return FALSE
+ return TRUE
+
+/// Checks if the candidate is an antag - most of the time you don't want to double dip. (Return FALSE to mark the candidate invalid)
+/datum/dynamic_ruleset/midround/from_living/proc/antag_check(mob/candidate)
+ return !candidate.is_antag()
+
+/datum/dynamic_ruleset/midround/from_living/traitor
+ name = "Traitor"
+ config_tag = "Midround Traitor"
+ preview_antag_datum = /datum/antagonist/traitor
+ midround_type = LIGHT_MIDROUND
+ false_alarm_able = TRUE
+ pref_flag = ROLE_SLEEPER_AGENT
+ jobban_flag = ROLE_TRAITOR
+ weight = 10
+ min_pop = 3
+ blacklisted_roles = list(
+ JOB_HEAD_OF_PERSONNEL,
+ )
+
+/datum/dynamic_ruleset/midround/from_living/traitor/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/traitor)
+
+/datum/dynamic_ruleset/midround/from_living/traitor/false_alarm()
+ priority_announce(
+ "Attention crew, it appears that someone on your station has hijacked your telecommunications and broadcasted an unknown signal.",
+ "[command_name()] High-Priority Update",
+ )
+
+/datum/dynamic_ruleset/midround/from_living/malf_ai
+ name = "Malfunctioning AI"
+ config_tag = "Midround Malfunctioning AI"
+ preview_antag_datum = /datum/antagonist/malf_ai
+ midround_type = HEAVY_MIDROUND
+ pref_flag = ROLE_MALF_MIDROUND
+ jobban_flag = ROLE_MALF
+ ruleset_flags = RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ repeatable = FALSE
+
+/datum/dynamic_ruleset/midround/from_living/malf_ai/get_always_blacklisted_roles()
+ return list()
+
+/datum/dynamic_ruleset/midround/from_living/malf_ai/job_check(mob/candidate)
+ return istype(candidate.mind.assigned_role, /datum/job/ai)
+
+/datum/dynamic_ruleset/midround/from_living/malf_ai/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/malf_ai)
+
+/datum/dynamic_ruleset/midround/from_living/malf_ai/can_be_selected()
+ return ..() && !HAS_TRAIT(SSstation, STATION_TRAIT_HUMAN_AI)
+
+/datum/dynamic_ruleset/midround/from_living/blob
+ name = "Blob Infection"
+ config_tag = "Blob Infection"
+ preview_antag_datum = /datum/antagonist/blob/infection
+ midround_type = HEAVY_MIDROUND
+ pref_flag = ROLE_BLOB_INFECTION
+ jobban_flag = ROLE_BLOB
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ repeatable_weight_decrease = 3
+
+/datum/dynamic_ruleset/midround/from_living/blob/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/blob/infection)
+ notify_ghosts(
+ "[candidate.current.real_name] has become a blob host!",
+ source = candidate.current,
+ header = "So Bulbous...",
+ )
+
+/datum/dynamic_ruleset/midround/from_living/obsesed
+ name = "Obsession"
+ config_tag = "Midround Obsessed"
+ preview_antag_datum = /datum/antagonist/obsessed
+ midround_type = LIGHT_MIDROUND
+ pref_flag = ROLE_OBSESSED
+ blacklisted_roles = list()
+ weight = list(
+ DYNAMIC_TIER_LOW = 5,
+ DYNAMIC_TIER_LOWMEDIUM = 5,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 1,
+ )
+ min_pop = 5
+
+/datum/dynamic_ruleset/midround/from_living/obsesed/is_valid_candidate(mob/candidate, client/candidate_client)
+ return ..() && !!candidate.get_organ_by_type(/obj/item/organ/brain)
+
+/datum/dynamic_ruleset/midround/from_living/obsesed/antag_check(mob/candidate)
+ // Obsessed is a special case, it can select other antag players
+ return !candidate.mind.has_antag_datum(/datum/antagonist/obsessed)
+
+/datum/dynamic_ruleset/midround/from_living/obsesed/assign_role(datum/mind/candidate)
+ var/obj/item/organ/brain/brain = candidate.current.get_organ_by_type(__IMPLIED_TYPE__)
+ brain.brain_gain_trauma(/datum/brain_trauma/special/obsessed)
+ notify_ghosts(
+ "[candidate.current.real_name] has developed an obsession with someone!",
+ source = candidate.current,
+ header = "Love Can Bloom",
+ )
diff --git a/code/controllers/subsystem/dynamic/dynamic_ruleset_roundstart.dm b/code/controllers/subsystem/dynamic/dynamic_ruleset_roundstart.dm
new file mode 100644
index 00000000000..1bdfe947615
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/dynamic_ruleset_roundstart.dm
@@ -0,0 +1,433 @@
+/datum/dynamic_ruleset/roundstart
+ // We can pick multiple of a roundstart ruleset to "scale up" (spawn more of the same type of antag)
+ // Set this to FALSE if you DON'T want this ruleset to "scale up"
+ repeatable = TRUE
+ /// If TRUE, the ruleset will be the only one selected for roundstart
+ var/solo = FALSE
+
+/datum/dynamic_ruleset/roundstart/is_valid_candidate(mob/candidate, client/candidate_client)
+ if(isnull(candidate.mind))
+ return FALSE
+ // Checks that any other roundstart ruleset hasn't already picked this guy
+ for(var/datum/dynamic_ruleset/roundstart/ruleset as anything in SSdynamic.queued_rulesets)
+ if(candidate.mind in ruleset.selected_minds)
+ return FALSE
+ return ..()
+
+/// Helpful proc - to use if your ruleset forces a job - which ensures a candidate can play the passed job typepath
+/datum/dynamic_ruleset/roundstart/proc/ruleset_forced_job_check(mob/candidate, client/candidate_client, datum/job/job_typepath)
+ // Malf AI can only go to people who want to be AI
+ if(!candidate_client.prefs.job_preferences[job_typepath::title])
+ return FALSE
+ // And only to people who can actually be AI this round
+ if(SSjob.check_job_eligibility(candidate, SSjob.get_job_type(job_typepath), "[name] Candidacy") != JOB_AVAILABLE)
+ return FALSE
+ // (Something else forced us to play a job that isn't AI)
+ var/forced_job = LAZYACCESS(SSjob.forced_occupations, candidate)
+ if(forced_job && forced_job != job_typepath)
+ return FALSE
+ // (Something else forced us NOT to play AI)
+ if(job_typepath::title in LAZYACCESS(SSjob.prevented_occupations, candidate))
+ return FALSE
+ return TRUE
+
+/datum/dynamic_ruleset/roundstart/traitor
+ name = "Traitors"
+ config_tag = "Roundstart Traitor"
+ preview_antag_datum = /datum/antagonist/traitor
+ pref_flag = ROLE_TRAITOR
+ weight = 10
+ min_pop = 3
+ max_antag_cap = list("denominator" = 38)
+
+/datum/dynamic_ruleset/roundstart/traitor/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/traitor)
+
+/datum/dynamic_ruleset/roundstart/malf_ai
+ name = "Malfunctioning AI"
+ config_tag = "Roundstart Malfunctioning AI"
+ pref_flag = ROLE_MALF
+ preview_antag_datum = /datum/antagonist/malf_ai
+ ruleset_flags = RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ max_antag_cap = 1
+ repeatable = FALSE
+
+/datum/dynamic_ruleset/roundstart/malf_ai/get_always_blacklisted_roles()
+ return list()
+
+/datum/dynamic_ruleset/roundstart/malf_ai/is_valid_candidate(mob/candidate, client/candidate_client)
+ return ..() && ruleset_forced_job_check(candidate, candidate_client, /datum/job/ai)
+
+/datum/dynamic_ruleset/roundstart/malf_ai/prepare_for_role(datum/mind/candidate)
+ LAZYSET(SSjob.forced_occupations, candidate, /datum/job/ai)
+
+/datum/dynamic_ruleset/roundstart/malf_ai/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/malf_ai)
+
+/datum/dynamic_ruleset/roundstart/malf_ai/can_be_selected()
+ return ..() && !HAS_TRAIT(SSstation, STATION_TRAIT_HUMAN_AI)
+
+/datum/dynamic_ruleset/roundstart/blood_brother
+ name = "Blood Brothers"
+ config_tag = "Roundstart Blood Brothers"
+ preview_antag_datum = /datum/antagonist/brother
+ pref_flag = ROLE_BROTHER
+ weight = 5
+ max_antag_cap = list("denominator" = 29)
+ min_pop = 10
+
+/datum/dynamic_ruleset/roundstart/blood_brother/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/brother)
+
+/datum/dynamic_ruleset/roundstart/changeling
+ name = "Changelings"
+ config_tag = "Roundstart Changeling"
+ preview_antag_datum = /datum/antagonist/changeling
+ pref_flag = ROLE_CHANGELING
+ weight = 3
+ min_pop = 15
+ max_antag_cap = list("denominator" = 29)
+
+/datum/dynamic_ruleset/roundstart/changeling/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/changeling)
+
+/datum/dynamic_ruleset/roundstart/heretic
+ name = "Heretics"
+ config_tag = "Roundstart Heretics"
+ preview_antag_datum = /datum/antagonist/heretic
+ pref_flag = ROLE_HERETIC
+ weight = 3
+ max_antag_cap = list("denominator" = 24)
+ min_pop = 30 // Ensures good spread of sacrifice targets
+
+/datum/dynamic_ruleset/roundstart/heretic/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/heretic)
+
+/datum/dynamic_ruleset/roundstart/wizard
+ name = "Wizard"
+ config_tag = "Roundstart Wizard"
+ preview_antag_datum = /datum/antagonist/wizard
+ pref_flag = ROLE_WIZARD
+ ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 0,
+ DYNAMIC_TIER_MEDIUMHIGH = 1,
+ DYNAMIC_TIER_HIGH = 2,
+ )
+ max_antag_cap = 1
+ min_pop = 30
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_WIZARDDEN)
+ repeatable = FALSE
+
+/datum/dynamic_ruleset/roundstart/wizard/prepare_for_role(datum/mind/candidate)
+ LAZYSET(SSjob.forced_occupations, candidate, /datum/job/space_wizard)
+
+/datum/dynamic_ruleset/roundstart/wizard/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/wizard) // moves to lair for us
+
+/datum/dynamic_ruleset/roundstart/wizard/round_result()
+ for(var/datum/mind/wiz as anything in selected_minds)
+ if(considered_alive(wiz) && !considered_exiled(wiz))
+ return FALSE
+
+ SSticker.news_report = WIZARD_KILLED
+ return TRUE
+
+/datum/dynamic_ruleset/roundstart/blood_cult
+ name = "Blood Cult"
+ config_tag = "Roundstart Blood Cult"
+ preview_antag_datum = /datum/antagonist/cult
+ pref_flag = ROLE_CULTIST
+ ruleset_flags = RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ blacklisted_roles = list(
+ JOB_HEAD_OF_PERSONNEL,
+ )
+ min_antag_cap = list("denominator" = 20, "offset" = 1)
+ repeatable = FALSE
+ /// Ratio of cultists getting on the shuttle to be considered a minor win
+ var/ratio_to_be_considered_escaped = 0.5
+
+/datum/dynamic_ruleset/roundstart/blood_cult/get_always_blacklisted_roles()
+ return ..() | JOB_CHAPLAIN
+
+/datum/dynamic_ruleset/roundstart/blood_cult/create_execute_args()
+ return list(
+ new /datum/team/cult(),
+ get_most_experienced(selected_minds, pref_flag),
+ )
+
+/datum/dynamic_ruleset/roundstart/blood_cult/execute()
+ . = ..()
+ // future todo, find a cleaner way to get this from execute args
+ var/datum/team/cult/main_cult = locate() in GLOB.antagonist_teams
+ main_cult.setup_objectives()
+
+/datum/dynamic_ruleset/roundstart/blood_cult/assign_role(datum/mind/candidate, datum/team/cult/cult, datum/mind/most_experienced)
+ var/datum/antagonist/cult/cultist = new()
+ cultist.give_equipment = TRUE
+ candidate.add_antag_datum(cultist, cult)
+ if(most_experienced == candidate)
+ cultist.make_cult_leader()
+
+/datum/dynamic_ruleset/roundstart/blood_cult/round_result()
+ var/datum/team/cult/main_cult = locate() in GLOB.antagonist_teams
+ if(main_cult.check_cult_victory())
+ SSticker.mode_result = "win - cult win"
+ SSticker.news_report = CULT_SUMMON
+ return TRUE
+
+ var/num_cultists = main_cult.size_at_maximum || 100
+ var/ratio_to_be_considered_escaped = 0.5
+ var/escaped_cultists = 0
+ for(var/datum/mind/escapee as anything in main_cult.members)
+ if(considered_escaped(escapee))
+ escaped_cultists++
+
+ SSticker.mode_result = "loss - staff stopped the cult"
+ SSticker.news_report = (escaped_cultists / num_cultists) >= ratio_to_be_considered_escaped ? CULT_ESCAPE : CULT_FAILURE
+ return TRUE
+
+/datum/dynamic_ruleset/roundstart/nukies
+ name = "Nuclear Operatives"
+ config_tag = "Roundstart Nukeops"
+ preview_antag_datum = /datum/antagonist/nukeop
+ pref_flag = ROLE_OPERATIVE
+ ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ min_antag_cap = list("denominator" = 18, "offset" = 1)
+ ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_NUKIEBASE)
+ repeatable = FALSE
+
+/datum/dynamic_ruleset/roundstart/nukies/prepare_for_role(datum/mind/candidate)
+ LAZYSET(SSjob.forced_occupations, candidate, /datum/job/nuclear_operative)
+
+/datum/dynamic_ruleset/roundstart/nukies/create_execute_args()
+ return list(
+ new /datum/team/nuclear(),
+ get_most_experienced(selected_minds, pref_flag),
+ )
+
+/datum/dynamic_ruleset/roundstart/nukies/assign_role(datum/mind/candidate, datum/team/nuke_team, datum/mind/most_experienced)
+ if(most_experienced == candidate)
+ candidate.add_antag_datum(/datum/antagonist/nukeop/leader, nuke_team)
+ else
+ candidate.add_antag_datum(/datum/antagonist/nukeop, nuke_team)
+
+/datum/dynamic_ruleset/roundstart/nukies/round_result()
+ var/datum/antagonist/nukeop/nukie = selected_minds[1].has_antag_datum(/datum/antagonist/nukeop)
+ var/datum/team/nuclear/nuke_team = nukie.get_team()
+ var/result = nuke_team.get_result()
+ switch(result)
+ if(NUKE_RESULT_FLUKE)
+ SSticker.mode_result = "loss - syndicate nuked - disk secured"
+ SSticker.news_report = NUKE_SYNDICATE_BASE
+ if(NUKE_RESULT_NUKE_WIN)
+ SSticker.mode_result = "win - syndicate nuke"
+ SSticker.news_report = STATION_DESTROYED_NUKE
+ if(NUKE_RESULT_NOSURVIVORS)
+ SSticker.mode_result = "halfwin - syndicate nuke - did not evacuate in time"
+ SSticker.news_report = STATION_DESTROYED_NUKE
+ if(NUKE_RESULT_WRONG_STATION)
+ SSticker.mode_result = "halfwin - blew wrong station"
+ SSticker.news_report = NUKE_MISS
+ if(NUKE_RESULT_WRONG_STATION_DEAD)
+ SSticker.mode_result = "halfwin - blew wrong station - did not evacuate in time"
+ SSticker.news_report = NUKE_MISS
+ if(NUKE_RESULT_CREW_WIN_SYNDIES_DEAD)
+ SSticker.mode_result = "loss - evacuation - disk secured - syndi team dead"
+ SSticker.news_report = OPERATIVES_KILLED
+ if(NUKE_RESULT_CREW_WIN)
+ SSticker.mode_result = "loss - evacuation - disk secured"
+ SSticker.news_report = OPERATIVES_KILLED
+ if(NUKE_RESULT_DISK_LOST)
+ SSticker.mode_result = "halfwin - evacuation - disk not secured"
+ SSticker.news_report = OPERATIVE_SKIRMISH
+ if(NUKE_RESULT_DISK_STOLEN)
+ SSticker.mode_result = "halfwin - detonation averted"
+ SSticker.news_report = OPERATIVE_SKIRMISH
+ else
+ SSticker.mode_result = "halfwin - interrupted"
+ SSticker.news_report = OPERATIVE_SKIRMISH
+
+/datum/dynamic_ruleset/roundstart/nukies/clown
+ name = "Clown Operatives"
+ config_tag = "Roundstart Clownops"
+ preview_antag_datum = /datum/antagonist/nukeop/clownop
+ pref_flag = ROLE_CLOWN_OPERATIVE
+ weight = 0
+
+/datum/dynamic_ruleset/roundstart/nukies/clown/prepare_for_role(datum/mind/candidate)
+ LAZYSET(SSjob.forced_occupations, candidate, /datum/job/nuclear_operative/clown_operative)
+
+/datum/dynamic_ruleset/roundstart/nukies/clown/assign_role(datum/mind/candidate, datum/team/nuke_team, datum/mind/most_experienced)
+ if(most_experienced == candidate)
+ candidate.add_antag_datum(/datum/antagonist/nukeop/leader/clownop)
+ else
+ candidate.add_antag_datum(/datum/antagonist/nukeop/clownop)
+
+/datum/dynamic_ruleset/roundstart/revolution
+ name = "Revolution"
+ config_tag = "Roundstart Revolution"
+ preview_antag_datum = /datum/antagonist/rev/head
+ pref_flag = ROLE_REV_HEAD
+ ruleset_flags = RULESET_HIGH_IMPACT
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 30
+ min_antag_cap = 1
+ max_antag_cap = 3
+ repeatable = FALSE
+ /// If we have fewer heads of staff than this 7 minutes into the round, we'll cancel the revolution
+ var/heads_necessary = 2
+
+/datum/dynamic_ruleset/roundstart/revolution/get_always_blacklisted_roles()
+ . = ..()
+ for(var/datum/job/job as anything in SSjob.all_occupations)
+ if(job.job_flags & JOB_HEAD_OF_STAFF)
+ . |= job.title
+
+/datum/dynamic_ruleset/roundstart/revolution/assign_role(datum/mind/candidate)
+ LAZYADD(candidate.special_roles, "Dormant Head Revolutionary")
+ addtimer(CALLBACK(src, PROC_REF(reveal_head), candidate), 7 MINUTES, TIMER_DELETE_ME)
+
+/// Reveals the headrev after a set amount of time
+/datum/dynamic_ruleset/roundstart/revolution/proc/reveal_head(datum/mind/candidate)
+ LAZYREMOVE(candidate.special_roles, "Dormant Head Revolutionary")
+
+ var/head_check = 0
+ for(var/mob/player as anything in get_active_player_list(alive_check = TRUE, afk_check = TRUE))
+ if(player.mind?.assigned_role.job_flags & JOB_HEAD_OF_STAFF)
+ head_check++
+
+ if(head_check < heads_necessary)
+ log_dynamic("[config_tag]: Not enough heads of staff were present to start a revolution.")
+ addtimer(CALLBACK(src, PROC_REF(revs_execution_failed)), 1 MINUTES, TIMER_UNIQUE|TIMER_DELETE_ME)
+ return
+
+ if(!can_be_headrev(candidate))
+ log_dynamic("[config_tag]: [key_name(candidate)] was not eligible to be a headrev after the timer expired - finding a replacement.")
+ find_another_headrev()
+ return
+
+ GLOB.revolution_handler ||= new()
+ var/datum/antagonist/rev/head/new_head = new()
+ new_head.give_flash = TRUE
+ new_head.give_hud = TRUE
+ new_head.remove_clumsy = TRUE
+ candidate.add_antag_datum(new_head, GLOB.revolution_handler.revs)
+ GLOB.revolution_handler.start_revolution()
+
+/datum/dynamic_ruleset/roundstart/revolution/proc/find_another_headrev()
+ for(var/mob/living/carbon/human/upstanding_citizen in GLOB.player_list)
+ if(!can_be_headrev(upstanding_citizen.mind))
+ continue
+ reveal_head(upstanding_citizen.mind)
+ log_dynamic("[config_tag]: [key_name(upstanding_citizen)] was selected as a replacement headrev.")
+ return
+
+ log_dynamic("[config_tag]: Failed to find a replacement headrev.")
+ addtimer(CALLBACK(src, PROC_REF(revs_execution_failed)), 1 MINUTES, TIMER_UNIQUE|TIMER_DELETE_ME)
+
+/datum/dynamic_ruleset/roundstart/revolution/proc/revs_execution_failed()
+ if(GLOB.revolution_handler)
+ return
+ // Execution is effectively cancelled by this point, but it's not like we can go back and refund it
+ SSdynamic.unreported_rulesets += src
+ name += " (Canceled)"
+ log_dynamic("[config_tag]: All headrevs were ineligible after the timer expired, and no replacements could be found. Ruleset canceled.")
+ message_admins("[config_tag]: All headrevs were ineligible after the timer expired, and no replacements could be found. Ruleset canceled.")
+
+/datum/dynamic_ruleset/roundstart/spies
+ name = "Spies"
+ config_tag = "Roundstart Spies"
+ preview_antag_datum = /datum/antagonist/spy
+ pref_flag = ROLE_SPY
+ weight = list(
+ DYNAMIC_TIER_LOW = 0,
+ DYNAMIC_TIER_LOWMEDIUM = 1,
+ DYNAMIC_TIER_MEDIUMHIGH = 3,
+ DYNAMIC_TIER_HIGH = 3,
+ )
+ min_pop = 10
+ min_antag_cap = list("denominator" = 20, "offset" = 1)
+
+/datum/dynamic_ruleset/roundstart/spies/assign_role(datum/mind/candidate)
+ candidate.add_antag_datum(/datum/antagonist/spy)
+
+/datum/dynamic_ruleset/roundstart/extended
+ name = "Extended"
+ config_tag = "Extended"
+ weight = 0
+ min_antag_cap = 0
+ repeatable = FALSE
+ solo = TRUE
+
+/datum/dynamic_ruleset/roundstart/extended/execute()
+ // No midrounds no latejoins
+ for(var/category in SSdynamic.rulesets_to_spawn)
+ SSdynamic.rulesets_to_spawn[category] = 0
+
+/datum/dynamic_ruleset/roundstart/meteor
+ name = "Meteor"
+ config_tag = "Meteor"
+ weight = 0
+ min_antag_cap = 0
+ repeatable = FALSE
+
+/datum/dynamic_ruleset/roundstart/meteor/execute()
+ GLOB.meteor_mode ||= new()
+ GLOB.meteor_mode.start_meteor()
+
+/datum/dynamic_ruleset/roundstart/nations
+ name = "Nations"
+ config_tag = "Nations"
+ weight = 0
+ min_antag_cap = 0
+ repeatable = FALSE
+ solo = TRUE
+
+/datum/dynamic_ruleset/roundstart/nations/execute()
+ // No midrounds no latejoins
+ for(var/category in SSdynamic.rulesets_to_spawn)
+ SSdynamic.rulesets_to_spawn[category] = 0
+
+ //notably assistant is not in this list to prevent the round turning into BARBARISM instantly, and silicon is in this list for UN
+ var/list/department_types = list(
+ /datum/job_department/silicon, //united nations
+ /datum/job_department/cargo,
+ /datum/job_department/engineering,
+ /datum/job_department/medical,
+ /datum/job_department/science,
+ /datum/job_department/security,
+ /datum/job_department/service,
+ )
+
+ for(var/department_type in department_types)
+ create_separatist_nation(department_type, announcement = FALSE, dangerous = FALSE, message_admins = FALSE)
+
+ GLOB.round_default_lawset = /datum/ai_laws/united_nations
diff --git a/code/controllers/subsystem/dynamic/dynamic_rulesets.dm b/code/controllers/subsystem/dynamic/dynamic_rulesets.dm
deleted file mode 100644
index 1eca2aeaff3..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_rulesets.dm
+++ /dev/null
@@ -1,310 +0,0 @@
-/datum/dynamic_ruleset
- /// For admin logging and round end screen.
- // If you want to change this variable name, the force latejoin/midround rulesets
- // to not use sort_names.
- var/name = ""
- /// For admin logging and round end screen, do not change this unless making a new rule type.
- var/ruletype = ""
- /// If set to TRUE, the rule won't be discarded after being executed, and dynamic will call rule_process() every time it ticks.
- var/persistent = FALSE
- /// If set to TRUE, dynamic will be able to draft this ruleset again later on. (doesn't apply for roundstart rules)
- var/repeatable = FALSE
- /// If set higher than 0 decreases weight by itself causing the ruleset to appear less often the more it is repeated.
- var/repeatable_weight_decrease = 2
- /// List of players that are being drafted for this rule
- var/list/mob/candidates = list()
- /// List of players that were selected for this rule. This can be minds, or mobs.
- var/list/assigned = list()
- /// Preferences flag such as ROLE_WIZARD that need to be turned on for players to be antag.
- var/antag_flag = null
- /// The antagonist datum that is assigned to the mobs mind on ruleset execution.
- var/datum/antagonist/antag_datum = null
- /// The required minimum account age for this ruleset.
- var/minimum_required_age = 7
- /// If set, and config flag protect_roles_from_antagonist is false, then the rule will not pick players from these roles.
- var/list/protected_roles = list()
- /// If set, rule will deny candidates from those roles always.
- var/list/restricted_roles = list()
- /// If set, rule will only accept candidates from those roles. If on a roundstart ruleset, requires the player to have the correct antag pref enabled and any of the possible roles enabled.
- var/list/exclusive_roles = list()
- /// If set, there needs to be a certain amount of players doing those roles (among the players who won't be drafted) for the rule to be drafted IMPORTANT: DOES NOT WORK ON ROUNDSTART RULESETS.
- var/list/enemy_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- /// If enemy_roles was set, this is the amount of enemy job workers needed per threat_level range (0-10,10-20,etc) IMPORTANT: DOES NOT WORK ON ROUNDSTART RULESETS.
- var/required_enemies = list(1,1,0,0,0,0,0,0,0,0)
- /// The rule needs this many candidates (post-trimming) to be executed (example: Cult needs 4 players at round start)
- var/required_candidates = 0
- /// 0 -> 9, probability for this rule to be picked against other rules. If zero this will effectively disable the rule.
- var/weight = 5
- /// Threat cost for this rule, this is decreased from the threat level when the rule is executed.
- var/cost = 0
- /// Cost per level the rule scales up.
- var/scaling_cost = 0
- /// How many times a rule has scaled up upon getting picked.
- var/scaled_times = 0
- /// Used for the roundend report
- var/total_cost = 0
- /// A flag that determines how the ruleset is handled. Check __DEFINES/dynamic.dm for an explanation of the accepted values.
- var/flags = NONE
- /// Pop range per requirement. If zero defaults to dynamic's pop_per_requirement.
- var/pop_per_requirement = 0
- /// Requirements are the threat level requirements per pop range.
- /// With the default values, The rule will never get drafted below 10 threat level (aka: "peaceful extended"), and it requires a higher threat level at lower pops.
- var/list/requirements = list(40,30,20,10,10,10,10,10,10,10)
- /// If a role is to be considered another for the purpose of banning.
- var/antag_flag_override = null
- /// If set, will check this preference instead of antag_flag.
- var/antag_preference = null
- /// If a ruleset type which is in this list has been executed, then the ruleset will not be executed.
- var/list/blocking_rules = list()
- /// The minimum amount of players required for the rule to be considered.
- var/minimum_players = 0
- /// The maximum amount of players required for the rule to be considered.
- /// Anything below zero or exactly zero is ignored.
- var/maximum_players = 0
- /// Calculated during acceptable(), used in scaling and team sizes.
- var/indice_pop = 0
- /// Base probability used in scaling. The higher it is, the more likely to scale. Kept as a var to allow for config editing._SendSignal(sigtype, list/arguments)
- var/base_prob = 60
- /// Delay for when execute will get called from the time of post_setup (roundstart) or process (midround/latejoin).
- /// Make sure your ruleset works with execute being called during the game when using this, and that the clean_up proc reverts it properly in case of faliure.
- var/delay = 0
-
- /// Judges the amount of antagonists to apply, for both solo and teams.
- /// Note that some antagonists (such as traitors, lings, heretics, etc) will add more based on how many times they've been scaled.
- /// Written as a linear equation--ceil(x/denominator) + offset, or as a fixed constant.
- /// If written as a linear equation, will be in the form of `list("denominator" = denominator, "offset" = offset).
- var/antag_cap = 0
-
- /// A list, or null, of templates that the ruleset depends on to function correctly
- var/list/ruleset_lazy_templates
- /// In what categories is this ruleset allowed to run? Used by station traits
- var/ruleset_category = RULESET_CATEGORY_DEFAULT
-
-/datum/dynamic_ruleset/New()
- // Rulesets can be instantiated more than once, such as when an admin clicks
- // "Execute Midround Ruleset". Thus, it would be wrong to perform any
- // side effects here. Dynamic rulesets should be stateless anyway.
- SHOULD_NOT_OVERRIDE(TRUE)
-
- ..()
-
-/datum/dynamic_ruleset/roundstart // One or more of those drafted at roundstart
- ruletype = ROUNDSTART_RULESET
-
-// Can be drafted when a player joins the server
-/datum/dynamic_ruleset/latejoin
- ruletype = LATEJOIN_RULESET
-
-/// By default, a rule is acceptable if it satisfies the threat level/population requirements.
-/// If your rule has extra checks, such as counting security officers, do that in ready() instead
-/datum/dynamic_ruleset/proc/acceptable(population = 0, threat_level = 0)
- var/ruleset_forced = GLOB.dynamic_forced_rulesets[type] || RULESET_NOT_FORCED
- if (ruleset_forced != RULESET_NOT_FORCED)
- if (ruleset_forced == RULESET_FORCE_ENABLED)
- return TRUE
- else
- log_dynamic("FAIL: [src] was disabled in admin panel.")
- return FALSE
-
- if(!is_valid_population(population))
- var/range = maximum_players > 0 ? "([minimum_players] - [maximum_players])" : "(minimum: [minimum_players])"
- log_dynamic("FAIL: [src] failed acceptable: min/max players out of range [range] vs population ([population])")
- return FALSE
-
- if (!is_valid_threat(population, threat_level))
- log_dynamic("FAIL: [src] failed acceptable: threat_level ([threat_level]) < requirement ([requirements[indice_pop]])")
- return FALSE
-
- return TRUE
-
-/// Returns true if we have enough players to run
-/datum/dynamic_ruleset/proc/is_valid_population(population)
- if(minimum_players > population)
- return FALSE
- if(maximum_players > 0 && population > maximum_players)
- return FALSE
- return TRUE
-
-/// Sets the current threat indices and returns true if we're inside of them
-/datum/dynamic_ruleset/proc/is_valid_threat(population, threat_level)
- pop_per_requirement = pop_per_requirement > 0 ? pop_per_requirement : SSdynamic.pop_per_requirement
- indice_pop = min(requirements.len,round(population/pop_per_requirement)+1)
- return threat_level >= requirements[indice_pop]
-
-/// When picking rulesets, if dynamic picks the same one multiple times, it will "scale up".
-/// However, doing this blindly would result in lowpop rounds (think under 10 people) where over 80% of the crew is antags!
-/// This function is here to ensure the antag ratio is kept under control while scaling up.
-/// Returns how much threat to actually spend in the end.
-/datum/dynamic_ruleset/proc/scale_up(population, max_scale)
- SHOULD_NOT_OVERRIDE(TRUE)
- if (!scaling_cost)
- return 0
-
- var/antag_fraction = 0
- for(var/datum/dynamic_ruleset/ruleset as anything in (SSdynamic.executed_rules + list(src))) // we care about the antags we *will* assign, too
- antag_fraction += ruleset.get_antag_cap_scaling_included(population) / SSdynamic.roundstart_pop_ready
-
- for(var/i in 1 to max_scale)
- if(antag_fraction < 0.25)
- scaled_times += 1
- antag_fraction += get_scaling_antag_cap(population) / SSdynamic.roundstart_pop_ready // we added new antags, gotta update the %
-
- return scaled_times * scaling_cost
-
-/// Returns how many more antags to add while scaling with a given population.
-/// By default rulesets scale linearly, but you can override this to make them scale differently.
-/datum/dynamic_ruleset/proc/get_scaling_antag_cap(population)
- return get_antag_cap(population)
-
-/// Returns what the antag cap with the given population is.
-/datum/dynamic_ruleset/proc/get_antag_cap(population)
- SHOULD_NOT_OVERRIDE(TRUE)
- if (isnum(antag_cap))
- return antag_cap
-
- return CEILING(population / antag_cap["denominator"], 1) + (antag_cap["offset"] || 0)
-
-/// Gets the 'final' antag cap for this ruleset, which is the base cap plus the scaled cap.
-/datum/dynamic_ruleset/proc/get_antag_cap_scaling_included(population)
- SHOULD_NOT_OVERRIDE(TRUE)
- var/base_cap = get_antag_cap(population)
- var/modded_cap = scaled_times * get_scaling_antag_cap(population)
- return base_cap + modded_cap
-
-/// This is called if persistent variable is true everytime SSTicker ticks.
-/datum/dynamic_ruleset/proc/rule_process()
- return
-
-/// Called on pre_setup for roundstart rulesets.
-/// Do everything you need to do before job is assigned here.
-/// IMPORTANT: ASSIGN special_role HERE
-/datum/dynamic_ruleset/proc/pre_execute()
- return TRUE
-
-/// Called on post_setup on roundstart and when the rule executes on midround and latejoin.
-/// Give your candidates or assignees equipment and antag datum here.
-/datum/dynamic_ruleset/proc/execute()
- for(var/datum/mind/M in assigned)
- M.add_antag_datum(antag_datum)
- GLOB.pre_setup_antags -= M
- return TRUE
-
-/// Rulesets can be reused, so when we're done setting one up we want to wipe its memory of the people it was selecting over
-/// This isn't Destroy we aren't deleting it here, rulesets free when nothing holds a ref. This is just to prevent hung refs.
-/datum/dynamic_ruleset/proc/forget_startup()
- SHOULD_CALL_PARENT(TRUE)
- candidates = list()
- assigned = list()
- antag_datum = null
-
-/// Here you can perform any additional checks you want. (such as checking the map etc)
-/// Remember that on roundstart no one knows what their job is at this point.
-/// IMPORTANT: If ready() returns TRUE, that means pre_execute() or execute() should never fail!
-/datum/dynamic_ruleset/proc/ready(forced = 0)
- return check_candidates()
-
-/// This should always be called before ready is, to ensure that the ruleset can locate map/template based landmarks as needed
-/datum/dynamic_ruleset/proc/load_templates()
- for(var/template in ruleset_lazy_templates)
- SSmapping.lazy_load_template(template)
-
-/// Runs from gamemode process() if ruleset fails to start, like delayed rulesets not getting valid candidates.
-/// This one only handles refunding the threat, override in ruleset to clean up the rest.
-/datum/dynamic_ruleset/proc/clean_up()
- SSdynamic.refund_threat(cost + (scaled_times * scaling_cost))
- SSdynamic.threat_log += "[gameTimestamp()]: [ruletype] [name] refunded [cost + (scaled_times * scaling_cost)]. Failed to execute."
-
-/// Gets weight of the ruleset
-/// Note that this decreases weight if repeatable is TRUE and repeatable_weight_decrease is higher than 0
-/// Note: If you don't want repeatable rulesets to decrease their weight use the weight variable directly
-/datum/dynamic_ruleset/proc/get_weight()
- if(repeatable && weight > 1 && repeatable_weight_decrease > 0)
- for(var/datum/dynamic_ruleset/DR in SSdynamic.executed_rules)
- if(istype(DR, type))
- weight = max(weight-repeatable_weight_decrease,1)
- return weight
-
-/// Checks if there are enough candidates to run, and logs otherwise
-/datum/dynamic_ruleset/proc/check_candidates()
- if (required_candidates <= candidates.len)
- return TRUE
-
- log_dynamic("FAIL: [src] does not have enough candidates ([required_candidates] needed, [candidates.len] found)")
- return FALSE
-
-/// Here you can remove candidates that do not meet your requirements.
-/// This means if their job is not correct or they have disconnected you can remove them from candidates here.
-/// Usually this does not need to be changed unless you need some specific requirements from your candidates.
-/datum/dynamic_ruleset/proc/trim_candidates()
- return
-
-/// Set mode_result and news report here.
-/// Only called if ruleset is flagged as HIGH_IMPACT_RULESET
-/datum/dynamic_ruleset/proc/round_result()
-
-//////////////////////////////////////////////
-// //
-// ROUNDSTART RULESETS //
-// //
-//////////////////////////////////////////////
-
-/// Checks if candidates are connected and if they are banned or don't want to be the antagonist.
-/datum/dynamic_ruleset/roundstart/trim_candidates()
- for(var/mob/dead/new_player/candidate_player in candidates)
- var/client/candidate_client = GET_CLIENT(candidate_player)
- if (!candidate_client || !candidate_player.mind) // Are they connected?
- candidates.Remove(candidate_player)
- continue
-
- //SKYRAT EDIT ADDITION
- if(!candidate_client.prefs?.read_preference(/datum/preference/toggle/be_antag))
- candidates.Remove(candidate_player)
- continue
-
- if(is_banned_from(candidate_client.ckey, BAN_ANTAGONIST))
- candidates.Remove(candidate_player)
- continue
- //SKYRAT EDIT END
-
- if(candidate_client.get_remaining_days(minimum_required_age) > 0)
- candidates.Remove(candidate_player)
- continue
-
- if(candidate_player.mind.special_role) // We really don't want to give antag to an antag.
- candidates.Remove(candidate_player)
- continue
-
- if (!((antag_preference || antag_flag) in candidate_client.prefs.be_special))
- candidates.Remove(candidate_player)
- continue
-
- if (is_banned_from(candidate_player.ckey, list(antag_flag_override || antag_flag, ROLE_SYNDICATE)))
- candidates.Remove(candidate_player)
- continue
-
- // If this ruleset has exclusive_roles set, we want to only consider players who have those
- // job prefs enabled and are eligible to play that job. Otherwise, continue as before.
- if(length(exclusive_roles))
- var/exclusive_candidate = FALSE
- for(var/role in exclusive_roles)
- var/datum/job/job = SSjob.get_job(role)
-
- if((role in candidate_client.prefs.job_preferences) && SSjob.check_job_eligibility(candidate_player, job, "Dynamic Roundstart TC", add_job_to_log = TRUE) == JOB_AVAILABLE)
- exclusive_candidate = TRUE
- break
-
- // If they didn't have any of the required job prefs enabled or were banned from all enabled prefs,
- // they're not eligible for this antag type.
- if(!exclusive_candidate)
- candidates.Remove(candidate_player)
-
-/// Do your checks if the ruleset is ready to be executed here.
-/// Should ignore certain checks if forced is TRUE
-/datum/dynamic_ruleset/roundstart/ready(population, forced = FALSE)
- return ..()
diff --git a/code/controllers/subsystem/dynamic/dynamic_rulesets_latejoin.dm b/code/controllers/subsystem/dynamic/dynamic_rulesets_latejoin.dm
deleted file mode 100644
index a5f1ded382a..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_rulesets_latejoin.dm
+++ /dev/null
@@ -1,263 +0,0 @@
-//////////////////////////////////////////////
-// //
-// LATEJOIN RULESETS //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/latejoin/trim_candidates()
- for(var/mob/P in candidates)
- if(!P.client || !P.mind || is_unassigned_job(P.mind.assigned_role)) // Are they connected?
- candidates.Remove(P)
- else if (P.client.get_remaining_days(minimum_required_age) > 0)
- candidates.Remove(P)
- else if(P.mind.assigned_role.title in restricted_roles) // Does their job allow for it?
- candidates.Remove(P)
- else if((exclusive_roles.len > 0) && !(P.mind.assigned_role.title in exclusive_roles)) // Is the rule exclusive to their job?
- candidates.Remove(P)
- else if (!((antag_preference || antag_flag) in P.client.prefs.be_special) || is_banned_from(P.ckey, list(antag_flag_override || antag_flag, ROLE_SYNDICATE)))
- candidates.Remove(P)
- // SKYRAT EDIT ADDITION - PROTECTED JOBS
- else if(P.client?.prefs && !P.client.prefs.read_preference(/datum/preference/toggle/be_antag))
- candidates.Remove(P)
- continue
- else if(is_banned_from(P.client?.ckey, BAN_ANTAGONIST))
- candidates.Remove(P)
- continue
- // SKYRAT EDIT END
-
-/datum/dynamic_ruleset/latejoin/ready(forced = 0)
- if (forced)
- return ..()
-
- var/job_check = 0
- if (enemy_roles.len > 0)
- for (var/mob/M in GLOB.alive_player_list)
- if (M.stat == DEAD)
- continue // Dead players cannot count as opponents
- if (M.mind && (M.mind.assigned_role.title in enemy_roles) && (!(M in candidates) || (M.mind.assigned_role.title 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(SSdynamic.threat_level/10)
- var/ruleset_forced = (GLOB.dynamic_forced_rulesets[type] || RULESET_NOT_FORCED) == RULESET_FORCE_ENABLED
- if (!ruleset_forced && job_check < required_enemies[threat])
- log_dynamic("FAIL: [src] is not ready, because there are not enough enemies: [required_enemies[threat]] needed, [job_check] found")
- return FALSE
-
- return ..()
-
-/datum/dynamic_ruleset/latejoin/execute()
- var/mob/M = pick(candidates)
- assigned += M.mind
- M.mind.special_role = antag_flag
- M.mind.add_antag_datum(antag_datum)
- return TRUE
-
-//////////////////////////////////////////////
-// //
-// SYNDICATE TRAITORS //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/latejoin/infiltrator
- name = "Syndicate Infiltrator"
- antag_datum = /datum/antagonist/traitor
- antag_flag = ROLE_SYNDICATE_INFILTRATOR
- antag_flag_override = ROLE_TRAITOR
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL,
- JOB_HEAD_OF_SECURITY,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- required_candidates = 1
- weight = 11
- cost = 5
- requirements = list(5,5,5,5,5,5,5,5,5,5)
- repeatable = TRUE
-
-//////////////////////////////////////////////
-// //
-// REVOLUTIONARY PROVOCATEUR //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/latejoin/provocateur
- name = "Provocateur"
- persistent = TRUE
- antag_datum = /datum/antagonist/rev/head
- antag_flag = ROLE_PROVOCATEUR
- antag_flag_override = ROLE_REV_HEAD
- restricted_roles = list(
- JOB_AI,
- JOB_CAPTAIN,
- JOB_CHIEF_ENGINEER,
- JOB_CHIEF_MEDICAL_OFFICER,
- JOB_CYBORG,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_QUARTERMASTER,
- JOB_RESEARCH_DIRECTOR,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- enemy_roles = list(
- JOB_AI,
- JOB_CYBORG,
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 1
- delay = 1 MINUTES // Prevents rule start while head is offstation.
- cost = 10
- requirements = list(101,101,70,40,30,20,20,20,20,20)
- flags = HIGH_IMPACT_RULESET
- blocking_rules = list(/datum/dynamic_ruleset/roundstart/revs)
- var/required_heads_of_staff = 3
- var/finished = FALSE
- var/datum/team/revolution/revolution
-
-/datum/dynamic_ruleset/latejoin/provocateur/ready(forced=FALSE)
- if (forced)
- required_heads_of_staff = 1
- if(!..())
- return FALSE
- var/head_check = 0
- for(var/mob/player in GLOB.alive_player_list)
- if (player.mind.assigned_role.job_flags & JOB_HEAD_OF_STAFF)
- head_check++
- return (head_check >= required_heads_of_staff)
-
-/datum/dynamic_ruleset/latejoin/provocateur/execute()
- var/mob/M = pick(candidates) // This should contain a single player, but in case.
- if(check_eligible(M.mind)) // Didnt die/run off z-level/get implanted since leaving shuttle.
- assigned += M.mind
- M.mind.special_role = antag_flag
- revolution = new()
- var/datum/antagonist/rev/head/new_head = new()
- new_head.give_flash = TRUE
- new_head.give_hud = TRUE
- new_head.remove_clumsy = TRUE
- new_head = M.mind.add_antag_datum(new_head, revolution)
- revolution.update_objectives()
- revolution.update_rev_heads()
- SSshuttle.registerHostileEnvironment(revolution)
- return TRUE
- else
- log_dynamic("[ruletype] [name] discarded [M.name] from head revolutionary due to ineligibility.")
- log_dynamic("[ruletype] [name] failed to get any eligible headrevs. Refunding [cost] threat.")
- return FALSE
-
-/datum/dynamic_ruleset/latejoin/provocateur/rule_process()
- var/winner = revolution.process_victory()
- if (isnull(winner))
- return
-
- finished = winner
-
- if(winner == REVOLUTION_VICTORY)
- GLOB.revolutionary_win = TRUE
-
- return RULESET_STOP_PROCESSING
-
-/// Checks for revhead loss conditions and other antag datums.
-/datum/dynamic_ruleset/latejoin/provocateur/proc/check_eligible(datum/mind/M)
- var/turf/T = get_turf(M.current)
- if(!considered_afk(M) && considered_alive(M) && is_station_level(T.z) && !M.antag_datums?.len && !HAS_MIND_TRAIT(M.current, TRAIT_UNCONVERTABLE))
- return TRUE
- return FALSE
-
-/datum/dynamic_ruleset/latejoin/provocateur/round_result()
- revolution.round_result(finished)
-
-//////////////////////////////////////////////
-// //
-// HERETIC SMUGGLER //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/latejoin/heretic_smuggler
- name = "Heretic Smuggler"
- antag_datum = /datum/antagonist/heretic
- antag_flag = ROLE_HERETIC_SMUGGLER
- antag_flag_override = ROLE_HERETIC
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- JOB_CHAPLAIN, // BUBBER EDIT - Chaplains can't heretic
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- required_candidates = 1
- weight = 4
- cost = 12
- requirements = list(101,101,50,10,10,10,10,10,10,10)
- repeatable = TRUE
-
-/datum/dynamic_ruleset/latejoin/heretic_smuggler/execute()
- var/mob/picked_mob = pick(candidates)
- assigned += picked_mob.mind
- picked_mob.mind.special_role = antag_flag
- var/datum/antagonist/heretic/new_heretic = picked_mob.mind.add_antag_datum(antag_datum)
-
- // Heretics passively gain influence over time.
- // As a consequence, latejoin heretics start out at a massive
- // disadvantage if the round's been going on for a while.
- // Let's give them some influence points when they arrive.
- new_heretic.knowledge_points += round((world.time - SSticker.round_start_time) / new_heretic.passive_gain_timer)
- // BUT let's not give smugglers a million points on arrival.
- // Limit it to four missed passive gain cycles (4 points).
- new_heretic.knowledge_points = min(new_heretic.knowledge_points, 5)
-
- return TRUE
-
-/// Ruleset for latejoin changelings
-/datum/dynamic_ruleset/latejoin/stowaway_changeling
- name = "Stowaway Changeling"
- antag_datum = /datum/antagonist/changeling
- antag_flag = ROLE_STOWAWAY_CHANGELING
- antag_flag_override = ROLE_CHANGELING
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- required_candidates = 1
- weight = 2
- cost = 12
- requirements = list(101,101,60,50,40,20,20,10,10,10)
- repeatable = TRUE
-
-/datum/dynamic_ruleset/latejoin/stowaway_changeling/execute()
- var/mob/picked_mob = pick(candidates)
- assigned += picked_mob.mind
- picked_mob.mind.special_role = antag_flag
- picked_mob.mind.add_antag_datum(antag_datum)
- return TRUE
diff --git a/code/controllers/subsystem/dynamic/dynamic_rulesets_midround.dm b/code/controllers/subsystem/dynamic/dynamic_rulesets_midround.dm
deleted file mode 100644
index 0821fcbf2e5..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_rulesets_midround.dm
+++ /dev/null
@@ -1,1009 +0,0 @@
-/// Probability the AI going malf will be accompanied by an ion storm announcement and some ion laws.
-#define MALF_ION_PROB 33
-/// The probability to replace an existing law with an ion law instead of adding a new ion law.
-#define REPLACE_LAW_WITH_ION_PROB 10
-
-/// Midround Rulesets
-/datum/dynamic_ruleset/midround // Can be drafted once in a while during a round
- ruletype = MIDROUND_RULESET
- var/midround_ruleset_style
- /// If the ruleset should be restricted from ghost roles.
- var/restrict_ghost_roles = TRUE
- /// What mob type the ruleset is restricted to.
- var/required_type = /mob/living/carbon/human
- var/list/living_players = list()
- var/list/living_antags = list()
- var/list/dead_players = list()
- var/list/list_observers = list()
-
- /// The minimum round time before this ruleset will show up
- var/minimum_round_time = 0
- /// Abstract root value
- var/abstract_type = /datum/dynamic_ruleset/midround
-
-/datum/dynamic_ruleset/midround/forget_startup()
- living_players = list()
- living_antags = list()
- dead_players = list()
- list_observers = list()
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts
- weight = 0
- required_type = /mob/dead/observer
- abstract_type = /datum/dynamic_ruleset/midround/from_ghosts
- /// Whether the ruleset should call generate_ruleset_body or not.
- var/makeBody = TRUE
- /// The rule needs this many applicants to be properly executed.
- var/required_applicants = 1
- ///Path of an item to show up in ghost polls for applicants to sign up.
- var/signup_item_path = /obj/structure/sign/poster/contraband/syndicate_recruitment
-
-/datum/dynamic_ruleset/midround/from_ghosts/check_candidates()
- var/dead_count = dead_players.len + list_observers.len
- if (required_candidates <= dead_count)
- return TRUE
-
- log_dynamic("FAIL: [src], a from_ghosts ruleset, did not have enough dead candidates: [required_candidates] needed, [dead_count] found")
-
- return FALSE
-
-/datum/dynamic_ruleset/midround/trim_candidates()
- living_players = trim_list(GLOB.alive_player_list)
- living_antags = trim_list(GLOB.current_living_antags)
- dead_players = trim_list(GLOB.dead_player_list)
- list_observers = trim_list(GLOB.current_observers_list)
-
-/datum/dynamic_ruleset/midround/proc/trim_list(list/to_trim = list())
- var/list/trimmed_list = to_trim.Copy()
- for(var/mob/creature in trimmed_list)
- if (!istype(creature, required_type))
- trimmed_list.Remove(creature)
- continue
- if (isnull(creature.client)) // Are they connected?
- trimmed_list.Remove(creature)
- continue
- //SKYRAT EDIT ADDITION
- if(is_banned_from(creature.client.ckey, BAN_ANTAGONIST))
- trimmed_list.Remove(creature)
- continue
- if(!creature.client?.prefs?.read_preference(/datum/preference/toggle/be_antag))
- trimmed_list.Remove(creature)
- continue
- //SKYRAT EDIT END
- if(creature.client.get_remaining_days(minimum_required_age) > 0)
- trimmed_list.Remove(creature)
- continue
- if (!((antag_preference || antag_flag) in creature.client.prefs.be_special))
- trimmed_list.Remove(creature)
- continue
- if (is_banned_from(creature.ckey, list(antag_flag_override || antag_flag, ROLE_SYNDICATE)))
- trimmed_list.Remove(creature)
- continue
- if (isnull(creature.mind))
- continue
- if (restrict_ghost_roles && !(creature.mind.assigned_role.job_flags & JOB_CREW_MEMBER)) // Are they not playing a station role?
- trimmed_list.Remove(creature)
- continue
- if (creature.mind.assigned_role.title in restricted_roles) // Does their job allow it?
- trimmed_list.Remove(creature)
- continue
- if (length(exclusive_roles) && !(creature.mind.assigned_role.title in exclusive_roles)) // Is the rule exclusive to their job?
- trimmed_list.Remove(creature)
- continue
- if(HAS_TRAIT(creature, TRAIT_MIND_TEMPORARILY_GONE)) // are they out of body?
- trimmed_list.Remove(creature)
- continue
- if(HAS_TRAIT(creature, TRAIT_TEMPORARY_BODY)) // are they an avatar?
- trimmed_list.Remove(creature)
- continue
- return trimmed_list
-
-// You can then for example prompt dead players in execute() to join as strike teams or whatever
-// Or autotator someone
-
-// IMPORTANT, since /datum/dynamic_ruleset/midround may accept candidates from both living, dead, and even antag players
-// subtype your midround with /from_ghosts or /from_living to get candidate checking. Or check yourself by subtyping from neither
-/datum/dynamic_ruleset/midround/ready(forced = FALSE)
- if (forced)
- return TRUE
-
- var/job_check = 0
- if (enemy_roles.len > 0)
- for (var/mob/M in GLOB.alive_player_list)
- if (M.stat == DEAD || !M.client)
- continue // Dead/disconnected players cannot count as opponents
- if (M.mind && (M.mind.assigned_role.title in enemy_roles) && (!(M in candidates) || (M.mind.assigned_role.title 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(SSdynamic.threat_level/10)
- var/ruleset_forced = (GLOB.dynamic_forced_rulesets[type] || RULESET_NOT_FORCED) == RULESET_FORCE_ENABLED
- if (!ruleset_forced && job_check < required_enemies[threat])
- log_dynamic("FAIL: [src] is not ready, because there are not enough enemies: [required_enemies[threat]] needed, [job_check] found")
- return FALSE
-
- return TRUE
-
-/datum/dynamic_ruleset/midround/from_ghosts/execute()
- var/list/possible_candidates = list()
- possible_candidates.Add(dead_players)
- possible_candidates.Add(list_observers)
- send_applications(possible_candidates)
- if(assigned.len > 0)
- return TRUE
- else
- return FALSE
-
-/// This sends a poll to ghosts if they want to be a ghost spawn from a ruleset.
-/datum/dynamic_ruleset/midround/from_ghosts/proc/send_applications(list/possible_volunteers = list())
- if (possible_volunteers.len <= 0) // This shouldn't happen, as ready() should return FALSE if there is not a single valid candidate
- message_admins("Possible volunteers was 0. This shouldn't appear, because of ready(), unless you forced it!")
- return
-
- SSdynamic.log_dynamic_and_announce("Polling [possible_volunteers.len] players to apply for the [name] ruleset.")
- candidates = SSpolling.poll_ghost_candidates(
- question = "Looking for volunteers to become [span_notice(antag_flag)] for [span_danger(name)]",
- check_jobban = antag_flag_override,
- role = antag_flag || antag_flag_override,
- poll_time = 30 SECONDS,
- alert_pic = signup_item_path,
- role_name_text = antag_flag,
- )
-
- if(!candidates || candidates.len <= 0)
- SSdynamic.log_dynamic_and_announce("The ruleset [name] received no applications.")
- SSdynamic.executed_rules -= src
- attempt_replacement()
- return
-
- SSdynamic.log_dynamic_and_announce("[candidates.len] players volunteered for [name].")
- review_applications()
-
-/// Here is where you can check if your ghost applicants are valid for the ruleset.
-/// Called by send_applications().
-/datum/dynamic_ruleset/midround/from_ghosts/proc/review_applications()
- if(candidates.len < required_applicants)
- SSdynamic.executed_rules -= src
- return
- for (var/i = 1, i <= required_candidates, i++)
- if(candidates.len <= 0)
- break
- var/mob/applicant = pick(candidates)
- candidates -= applicant
- if(!isobserver(applicant))
- if(applicant.stat == DEAD) // Not an observer? If they're dead, make them one.
- applicant = applicant.ghostize(FALSE)
- else // Not dead? Disregard them, pick a new applicant
- i--
- continue
- if(!applicant)
- i--
- continue
- assigned += applicant
- finish_applications()
-
-/// Here the accepted applications get generated bodies and their setup is finished.
-/// Called by review_applications()
-/datum/dynamic_ruleset/midround/from_ghosts/proc/finish_applications()
- var/i = 0
- for(var/mob/applicant as anything in assigned)
- i++
- var/mob/new_character = applicant
- if(makeBody)
- new_character = generate_ruleset_body(applicant)
- SEND_GLOBAL_SIGNAL(COMSIG_RULESET_BODY_GENERATED_FROM_GHOSTS, applicant)
- finish_setup(new_character, i)
- notify_ghosts(
- "[applicant.name] has been picked for the ruleset [name]!",
- source = new_character,
- )
-
-/datum/dynamic_ruleset/midround/from_ghosts/proc/generate_ruleset_body(mob/applicant)
- var/mob/living/carbon/human/new_character = make_body(applicant)
- new_character.dna.remove_all_mutations()
- return new_character
-
-/datum/dynamic_ruleset/midround/from_ghosts/proc/finish_setup(mob/new_character, index)
- var/datum/antagonist/new_role = new antag_datum()
- setup_role(new_role)
- new_character.mind.add_antag_datum(new_role)
- new_character.mind.special_role = antag_flag
-
-/datum/dynamic_ruleset/midround/from_ghosts/proc/setup_role(datum/antagonist/new_role)
- return
-
-/// Fired when there are no valid candidates. Will spawn a sleeper agent or latejoin traitor.
-/datum/dynamic_ruleset/midround/from_ghosts/proc/attempt_replacement()
- var/datum/dynamic_ruleset/midround/from_living/autotraitor/sleeper_agent = new
-
- SSdynamic.configure_ruleset(sleeper_agent)
-
- if (!SSdynamic.picking_specific_rule(sleeper_agent))
- return
-
- SSdynamic.picking_specific_rule(/datum/dynamic_ruleset/latejoin/infiltrator)
-
-///subtype to handle checking players
-/datum/dynamic_ruleset/midround/from_living
- weight = 0
- abstract_type = /datum/dynamic_ruleset/midround/from_living
-
-/datum/dynamic_ruleset/midround/from_living/ready(forced)
- if(!check_candidates())
- return FALSE
- return ..()
-
-
-/// Midround Traitor Ruleset (From Living)
-/datum/dynamic_ruleset/midround/from_living/autotraitor
- name = "Syndicate Sleeper Agent"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- antag_datum = /datum/antagonist/traitor
- antag_flag = ROLE_SLEEPER_AGENT
- antag_flag_override = ROLE_TRAITOR
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- ROLE_POSITRONIC_BRAIN,
- )
- required_candidates = 1
- weight = 35
- cost = 3
- requirements = list(3,3,3,3,3,3,3,3,3,3)
- repeatable = TRUE
-
-/datum/dynamic_ruleset/midround/from_living/autotraitor/trim_candidates()
- ..()
- candidates = living_players
- for(var/mob/living/player in candidates)
- if(issilicon(player)) // Your assigned role doesn't change when you are turned into a silicon.
- candidates -= player
- else if(is_centcom_level(player.z))
- candidates -= player // We don't autotator people in CentCom
- else if(player.mind && (player.mind.special_role || !player.mind.can_roll_midround(antag_datum)))
- candidates -= player // We don't autotator people with roles already
-
-/datum/dynamic_ruleset/midround/from_living/autotraitor/execute()
- var/mob/M = pick(candidates)
- assigned += M
- candidates -= M
- var/datum/antagonist/traitor/newTraitor = new
- M.mind.add_antag_datum(newTraitor)
- message_admins("[ADMIN_LOOKUPFLW(M)] was selected by the [name] ruleset and has been made into a midround traitor.")
- log_dynamic("[key_name(M)] was selected by the [name] ruleset and has been made into a midround traitor.")
- return TRUE
-
-/// Midround Malf AI Ruleset (From Living)
-/datum/dynamic_ruleset/midround/malf
- name = "Malfunctioning AI"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_datum = /datum/antagonist/malf_ai
- antag_flag = ROLE_MALF_MIDROUND
- antag_flag_override = ROLE_MALF
- enemy_roles = list(
- JOB_CHEMIST,
- JOB_CHIEF_ENGINEER,
- JOB_HEAD_OF_SECURITY,
- JOB_RESEARCH_DIRECTOR,
- JOB_SCIENTIST,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- exclusive_roles = list(JOB_AI)
- required_enemies = list(4,4,4,4,4,4,2,2,2,0)
- required_candidates = 1
- minimum_players = 25
- weight = 2
- cost = 10
- required_type = /mob/living/silicon/ai
- blocking_rules = list(/datum/dynamic_ruleset/roundstart/malf_ai)
- // AIs are technically considered "Ghost roles" as far as candidate selection are concerned
- // So we need to allow it here. We filter of actual ghost role AIs (charlie) via trim_candidates ourselves
- restrict_ghost_roles = FALSE
-
-/datum/dynamic_ruleset/midround/malf/trim_candidates()
- ..()
- candidates = list()
- for(var/mob/living/silicon/ai/player in living_players)
- if(!is_station_level(player.z))
- continue
- if(isnull(player.mind))
- continue
- if(player.mind.special_role || !player.mind.can_roll_midround(antag_datum))
- continue
- candidates += player
-
-/datum/dynamic_ruleset/midround/malf/ready(forced)
- if(!check_candidates())
- log_dynamic("FAIL: No valid AI found for the Malfunctioning AI ruleset.")
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/malf/execute()
- var/mob/living/silicon/ai/new_malf_ai = pick_n_take(candidates)
- assigned += new_malf_ai.mind
- var/datum/antagonist/malf_ai/malf_antag_datum = new
- new_malf_ai.mind.special_role = antag_flag
- new_malf_ai.mind.add_antag_datum(malf_antag_datum)
- if(prob(MALF_ION_PROB))
- priority_announce("Ion storm detected near the station. Please check all AI-controlled equipment for errors.", "Anomaly Alert", ANNOUNCER_IONSTORM)
- if(prob(REPLACE_LAW_WITH_ION_PROB))
- new_malf_ai.replace_random_law(generate_ion_law(), list(LAW_INHERENT, LAW_SUPPLIED, LAW_ION), LAW_ION)
- else
- new_malf_ai.add_ion_law(generate_ion_law())
- return TRUE
-
-/// Midround Wizard Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/wizard
- name = "Wizard"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_datum = /datum/antagonist/wizard
- antag_flag = ROLE_WIZARD_MIDROUND
- antag_flag_override = ROLE_WIZARD
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 1
- cost = 10
- requirements = REQUIREMENTS_VERY_HIGH_THREAT_NEEDED
- flags = HIGH_IMPACT_RULESET
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_WIZARDDEN)
- signup_item_path = /obj/item/clothing/head/wizard
-
-/datum/dynamic_ruleset/midround/from_ghosts/wizard/ready(forced = FALSE)
- if(!check_candidates())
- return FALSE
- if(!length(GLOB.wizardstart))
- log_admin("Cannot accept Wizard ruleset. Couldn't find any wizard spawn points.")
- message_admins("Cannot accept Wizard ruleset. Couldn't find any wizard spawn points.")
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/wizard/finish_setup(mob/new_character, index)
- ..()
- new_character.forceMove(pick(GLOB.wizardstart))
-
-/// Midround Nuclear Operatives Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/nuclear
- name = "Nuclear Assault"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_flag = ROLE_OPERATIVE_MIDROUND
- antag_flag_override = ROLE_OPERATIVE
- antag_datum = /datum/antagonist/nukeop
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- enemy_roles = list(
- JOB_AI,
- JOB_CYBORG,
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- required_enemies = list(3,3,3,3,3,2,1,1,0,0)
- required_candidates = 5
- weight = 5
- cost = 7
- minimum_round_time = 70 MINUTES
- requirements = REQUIREMENTS_VERY_HIGH_THREAT_NEEDED
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_NUKIEBASE)
- flags = HIGH_IMPACT_RULESET
- signup_item_path = /obj/machinery/nuclearbomb
-
- var/list/operative_cap = list(2,2,3,3,4,5,5,5,5,5)
-
-/datum/dynamic_ruleset/midround/from_ghosts/nuclear/acceptable(population=0, threat_level=0)
- if (locate(/datum/dynamic_ruleset/roundstart/nuclear) in SSdynamic.executed_rules)
- return FALSE // Unavailable if nuke ops were already sent at roundstart
- indice_pop = min(operative_cap.len, round(living_players.len/5)+1)
- required_candidates = operative_cap[indice_pop]
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/nuclear/ready(forced = FALSE)
- if (!check_candidates())
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/nuclear/finish_applications()
- var/mob/leader = get_most_experienced(assigned, ROLE_NUCLEAR_OPERATIVE)
- if(leader)
- assigned.Remove(leader)
- assigned.Insert(1, leader)
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/nuclear/finish_setup(mob/new_character, index)
- new_character.mind.set_assigned_role(SSjob.get_job_type(/datum/job/nuclear_operative))
- new_character.mind.special_role = ROLE_NUCLEAR_OPERATIVE
- if(index == 1)
- var/datum/antagonist/nukeop/leader/leader_antag_datum = new()
- new_character.mind.add_antag_datum(leader_antag_datum)
- return
- return ..()
-
-/// Midround Blob Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/blob
- name = "Blob"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_datum = /datum/antagonist/blob
- antag_flag = ROLE_BLOB
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- minimum_round_time = 35 MINUTES
- weight = 3
- cost = 8
- minimum_players = 25
- repeatable = TRUE
- signup_item_path = /obj/structure/blob/normal
-
-/datum/dynamic_ruleset/midround/from_ghosts/blob/generate_ruleset_body(mob/applicant)
- var/body = applicant.become_overmind()
- return body
-
-/// Midround Blob Infection Ruleset (From Living)
-/datum/dynamic_ruleset/midround/from_living/blob_infection
- name = "Blob Infection"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_datum = /datum/antagonist/blob/infection
- antag_flag = ROLE_BLOB_INFECTION
- antag_flag_override = ROLE_BLOB
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- ROLE_POSITRONIC_BRAIN,
- )
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- minimum_round_time = 35 MINUTES
- weight = 3
- cost = 10
- minimum_players = 25
- repeatable = TRUE
-
-/datum/dynamic_ruleset/midround/from_living/blob_infection/trim_candidates()
- ..()
- candidates = living_players
- for(var/mob/living/player as anything in candidates)
- var/turf/player_turf = get_turf(player)
- if(!player_turf || !is_station_level(player_turf.z))
- candidates -= player
- continue
-
- if(player.mind && (player.mind.special_role || !player.mind.can_roll_midround(antag_datum)))
- candidates -= player
-
-/datum/dynamic_ruleset/midround/from_living/blob_infection/execute()
- if(!candidates || !candidates.len)
- return FALSE
- var/mob/living/carbon/human/blob_antag = pick_n_take(candidates)
- assigned += blob_antag.mind
- blob_antag.mind.special_role = antag_flag
- notify_ghosts(
- "[blob_antag] has become a blob host!",
- source = blob_antag,
- header = "So Bulbous...",
- )
- return ..()
-
-/// Midround Xenomorph Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/xenomorph
- name = "Alien Infestation"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_datum = /datum/antagonist/xeno
- antag_flag = ROLE_ALIEN
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- minimum_round_time = 40 MINUTES
- weight = 5
- cost = 10
- minimum_players = 25
- repeatable = TRUE
- signup_item_path = /mob/living/basic/alien
- var/list/vents = list()
-
-/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/forget_startup()
- vents = list()
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/execute()
- // 50% chance of being incremented by one
- required_candidates += prob(50)
- var/list/vent_pumps = SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/atmospherics/components/unary/vent_pump)
- for(var/obj/machinery/atmospherics/components/unary/vent_pump/temp_vent as anything in vent_pumps)
- if(QDELETED(temp_vent))
- continue
- if(is_station_level(temp_vent.loc.z) && !temp_vent.welded)
- var/datum/pipeline/temp_vent_parent = temp_vent.parents[1]
- if(!temp_vent_parent)
- continue // No parent vent
- // Stops Aliens getting stuck in small networks.
- // See: Security, Virology
- if(temp_vent_parent.other_atmos_machines.len > 20)
- vents += temp_vent
- if(!vents.len)
- return FALSE
- . = ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/xenomorph/generate_ruleset_body(mob/applicant)
- var/obj/vent = pick_n_take(vents)
- var/mob/living/carbon/alien/larva/new_xeno = new(vent.loc)
- new_xeno.PossessByPlayer(applicant.ckey)
- new_xeno.move_into_vent(vent)
- message_admins("[ADMIN_LOOKUPFLW(new_xeno)] has been made into an alien by the midround ruleset.")
- log_dynamic("[key_name(new_xeno)] was spawned as an alien by the midround ruleset.")
- return new_xeno
-
-/// Midround Nightmare Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/nightmare
- name = "Nightmare"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- antag_datum = /datum/antagonist/nightmare
- antag_flag = ROLE_NIGHTMARE
- antag_flag_override = ROLE_ALIEN
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 3
- cost = 5
- minimum_players = 15
- repeatable = TRUE
- signup_item_path = /obj/item/light_eater
-
-/datum/dynamic_ruleset/midround/from_ghosts/nightmare/acceptable(population = 0, threat_level = 0)
- var/turf/spawn_loc = find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = TRUE) //Checks if there's a single safe, dark tile on station.
- if(!spawn_loc)
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/nightmare/generate_ruleset_body(mob/applicant)
- var/datum/mind/player_mind = new /datum/mind(applicant.key)
- player_mind.active = TRUE
-
- var/mob/living/carbon/human/new_nightmare = new (find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = TRUE))
- player_mind.transfer_to(new_nightmare)
- player_mind.set_assigned_role(SSjob.get_job_type(/datum/job/nightmare))
- player_mind.special_role = ROLE_NIGHTMARE
- player_mind.add_antag_datum(/datum/antagonist/nightmare)
- new_nightmare.set_species(/datum/species/shadow/nightmare)
-
- playsound(new_nightmare, 'sound/effects/magic/ethereal_exit.ogg', 50, TRUE, -1)
- message_admins("[ADMIN_LOOKUPFLW(new_nightmare)] has been made into a Nightmare by the midround ruleset.")
- log_dynamic("[key_name(new_nightmare)] was spawned as a Nightmare by the midround ruleset.")
- return new_nightmare
-
-/// Midround Space Dragon Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/space_dragon
- name = "Space Dragon"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_datum = /datum/antagonist/space_dragon
- antag_flag = ROLE_SPACE_DRAGON
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 4
- cost = 7
- minimum_players = 25
- repeatable = TRUE
- signup_item_path = /mob/living/basic/space_dragon
- var/list/spawn_locs = list()
-
-/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/forget_startup()
- spawn_locs = list()
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/execute()
- for(var/obj/effect/landmark/carpspawn/C in GLOB.landmarks_list)
- spawn_locs += (C.loc)
- if(!spawn_locs.len)
- message_admins("No valid spawn locations found, aborting...")
- return MAP_ERROR
- . = ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/space_dragon/generate_ruleset_body(mob/applicant)
- var/datum/mind/player_mind = new /datum/mind(applicant.key)
- player_mind.active = TRUE
-
- var/mob/living/basic/space_dragon/S = new (pick(spawn_locs))
- player_mind.transfer_to(S)
- player_mind.add_antag_datum(/datum/antagonist/space_dragon)
-
- playsound(S, 'sound/effects/magic/ethereal_exit.ogg', 50, TRUE, -1)
- message_admins("[ADMIN_LOOKUPFLW(S)] has been made into a Space Dragon by the midround ruleset.")
- log_dynamic("[key_name(S)] was spawned as a Space Dragon by the midround ruleset.")
- priority_announce("A large organic energy flux has been recorded near of [station_name()], please stand-by.", "Lifesign Alert")
- return S
-
-/datum/dynamic_ruleset/midround/from_ghosts/abductors
- name = "Abductors"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- antag_datum = /datum/antagonist/abductor
- antag_flag = ROLE_ABDUCTOR
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 2
- required_applicants = 2
- weight = 4
- cost = 7
- minimum_players = 25
- repeatable = TRUE
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_ABDUCTOR_SHIPS)
-
- var/datum/team/abductor_team/new_team
-
-/datum/dynamic_ruleset/midround/from_ghosts/abductors/forget_startup()
- new_team = null
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/abductors/ready(forced = FALSE)
- if (required_candidates > (dead_players.len + list_observers.len))
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/abductors/finish_setup(mob/new_character, index)
- if (index == 1) // Our first guy is the scientist. We also initialize the team here as well since this should only happen once per pair of abductors.
- new_team = new
- if(new_team.team_number > ABDUCTOR_MAX_TEAMS)
- return MAP_ERROR
- var/datum/antagonist/abductor/scientist/new_role = new
- new_character.mind.add_antag_datum(new_role, new_team)
- else // Our second guy is the agent, team is already created, don't need to make another one.
- var/datum/antagonist/abductor/agent/new_role = new
- new_character.mind.add_antag_datum(new_role, new_team)
-
-/// Midround Space Ninja Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/space_ninja
- name = "Space Ninja"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_datum = /datum/antagonist/ninja
- antag_flag = ROLE_NINJA
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 4
- cost = 8
- minimum_players = 30
- repeatable = TRUE
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_NINJA_HOLDING_FACILITY) // I mean, no one uses the nets anymore but whateva
- signup_item_path = /obj/item/energy_katana
-
- var/list/spawn_locs = list()
-
-/datum/dynamic_ruleset/midround/from_ghosts/space_ninja/forget_startup()
- spawn_locs = list()
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/space_ninja/execute()
- for(var/obj/effect/landmark/carpspawn/carp_spawn in GLOB.landmarks_list)
- if(!isturf(carp_spawn.loc))
- stack_trace("Carp spawn found not on a turf: [carp_spawn.type] on [isnull(carp_spawn.loc) ? "null" : carp_spawn.loc.type]")
- continue
- spawn_locs += carp_spawn.loc
- if(!spawn_locs.len)
- message_admins("No valid spawn locations found, aborting...")
- return MAP_ERROR
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/space_ninja/generate_ruleset_body(mob/applicant)
- var/mob/living/carbon/human/ninja = create_space_ninja(pick(spawn_locs))
- ninja.PossessByPlayer(applicant.ckey)
- ninja.mind.add_antag_datum(/datum/antagonist/ninja)
-
- message_admins("[ADMIN_LOOKUPFLW(ninja)] has been made into a Space Ninja by the midround ruleset.")
- log_dynamic("[key_name(ninja)] was spawned as a Space Ninja by the midround ruleset.")
- return ninja
-
-/// Midround Spiders Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/spiders
- name = "Spiders"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- antag_flag = ROLE_SPIDER
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_type = /mob/dead/observer
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 0
- weight = 3
- cost = 8
- minimum_players = 27
- repeatable = TRUE
- var/spawncount = 2
-
-/datum/dynamic_ruleset/midround/spiders/execute()
- create_midwife_eggs(spawncount)
- return ..()
-
-/// Midround Revenant Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/revenant
- name = "Revenant"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- antag_datum = /datum/antagonist/revenant
- antag_flag = ROLE_REVENANT
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 4
- cost = 5
- minimum_players = 15
- repeatable = TRUE
- signup_item_path = /mob/living/basic/revenant
- var/dead_mobs_required = 20
- var/need_extra_spawns_value = 15
- var/list/spawn_locs = list()
-
-/datum/dynamic_ruleset/midround/from_ghosts/revenant/forget_startup()
- spawn_locs = list()
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/revenant/acceptable(population=0, threat_level=0)
- if(GLOB.dead_mob_list.len < dead_mobs_required)
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/revenant/execute()
- for(var/mob/living/corpse in GLOB.dead_mob_list) //look for any dead bodies
- var/turf/corpse_turf = get_turf(corpse)
- if(corpse_turf && is_station_level(corpse_turf.z))
- spawn_locs += corpse_turf
- if(!spawn_locs.len || spawn_locs.len < need_extra_spawns_value) //look for any morgue trays, crematoriums, ect if there weren't alot of dead bodies on the station to pick from
- for(var/obj/structure/bodycontainer/corpse_container in GLOB.bodycontainers)
- var/turf/container_turf = get_turf(corpse_container)
- if(container_turf && is_station_level(container_turf.z))
- spawn_locs += container_turf
- if(!spawn_locs.len) //If we can't find any valid spawnpoints, try the carp spawns
- for(var/obj/effect/landmark/carpspawn/carp_spawnpoint in GLOB.landmarks_list)
- if(isturf(carp_spawnpoint.loc))
- spawn_locs += carp_spawnpoint.loc
- if(!spawn_locs.len) //If we can't find THAT, then just give up and cry
- return FALSE
- . = ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/revenant/generate_ruleset_body(mob/applicant)
- var/mob/living/basic/revenant/revenant = new(pick(spawn_locs))
- revenant.PossessByPlayer(applicant.ckey)
- message_admins("[ADMIN_LOOKUPFLW(revenant)] has been made into a revenant by the midround ruleset.")
- log_game("[key_name(revenant)] was spawned as a revenant by the midround ruleset.")
- return revenant
-
-/// Midround Space Pirates Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/pirates
- name = "Space Pirates"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- antag_flag = "Space Pirates"
- required_type = /mob/dead/observer
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 0
- weight = 3
- cost = 8
- minimum_players = 20
- repeatable = TRUE
-
-/datum/dynamic_ruleset/midround/pirates/acceptable(population=0, threat_level=0)
- if (SSmapping.is_planetary() || GLOB.light_pirate_gangs.len == 0)
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/pirates/execute()
- send_pirate_threat(GLOB.light_pirate_gangs)
- return ..()
-
-/// Dangerous Space Pirates ruleset
-/datum/dynamic_ruleset/midround/dangerous_pirates
- name = "Dangerous Space Pirates"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_HEAVY
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- antag_flag = "Space Pirates"
- required_type = /mob/dead/observer
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 0
- weight = 3
- cost = 8
- minimum_players = 25
- repeatable = TRUE
-
-/datum/dynamic_ruleset/midround/dangerous_pirates/acceptable(population=0, threat_level=0)
- if (SSmapping.is_planetary() || GLOB.heavy_pirate_gangs.len == 0)
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/dangerous_pirates/execute()
- send_pirate_threat(GLOB.heavy_pirate_gangs)
- return ..()
-
-/// Midround Obsessed Ruleset (From Living)
-/datum/dynamic_ruleset/midround/from_living/obsessed
- name = "Obsessed"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- antag_datum = /datum/antagonist/obsessed
- antag_flag = ROLE_OBSESSED
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- ROLE_POSITRONIC_BRAIN,
- )
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 4
- cost = 3 // Doesn't have the same impact on rounds as revenants, dragons, sentient disease (10) or syndicate infiltrators (5).
- repeatable = TRUE
-
-/datum/dynamic_ruleset/midround/from_living/obsessed/trim_candidates()
- ..()
- candidates = living_players
- for(var/mob/living/carbon/human/candidate in candidates)
- if( \
- !candidate.get_organ_by_type(/obj/item/organ/brain) \
- || candidate.mind.has_antag_datum(/datum/antagonist/obsessed) \
- || candidate.stat == DEAD \
- || !(ROLE_OBSESSED in candidate.client?.prefs?.be_special) \
- || !candidate.mind.assigned_role \
- )
- candidates -= candidate
-
-/datum/dynamic_ruleset/midround/from_living/obsessed/execute()
- var/mob/living/carbon/human/obsessed = pick_n_take(candidates)
- obsessed.gain_trauma(/datum/brain_trauma/special/obsessed)
- message_admins("[ADMIN_LOOKUPFLW(obsessed)] has been made Obsessed by the midround ruleset.")
- log_game("[key_name(obsessed)] was made Obsessed by the midround ruleset.")
- notify_ghosts(
- "[obsessed.real_name] has developed an obsession with someone!",
- source = obsessed,
- header = "Love Can Bloom",
- )
- return TRUE
-
-/// Midround Space Changeling Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/changeling_midround
- name = "Space Changeling"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- antag_datum = /datum/antagonist/changeling/space
- antag_flag = ROLE_CHANGELING_MIDROUND
- antag_flag_override = ROLE_CHANGELING
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_type = /mob/dead/observer
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 3
- cost = 7
- minimum_players = 15
- repeatable = TRUE
- signup_item_path = /obj/effect/meteor/meaty/changeling
-
-/datum/dynamic_ruleset/midround/from_ghosts/changeling_midround/generate_ruleset_body(mob/applicant)
- var/body = generate_changeling_meteor(applicant)
- message_admins("[ADMIN_LOOKUPFLW(body)] has been made into a space changeling by the midround ruleset.")
- log_dynamic("[key_name(body)] was spawned as a space changeling by the midround ruleset.")
- return body
-
-/// Midround Paradox Clone Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone
- name = "Paradox Clone"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- antag_datum = /datum/antagonist/paradox_clone
- antag_flag = ROLE_PARADOX_CLONE
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- enemy_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- required_enemies = list(2, 2, 1, 1, 1, 1, 1, 0, 0, 0)
- required_candidates = 1
- weight = 4
- cost = 3
- repeatable = TRUE
- signup_item_path = /obj/effect/bluespace_stream
- var/list/possible_spawns = list() ///places the antag can spawn
-
-/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/forget_startup()
- possible_spawns = list()
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/execute()
- possible_spawns += find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE)
- if(!possible_spawns.len)
- return MAP_ERROR
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/generate_ruleset_body(mob/applicant)
- var/datum/mind/player_mind = new /datum/mind(applicant.key)
- player_mind.active = TRUE
-
- var/mob/living/carbon/human/clone_victim = find_original()
- var/mob/living/carbon/human/clone = clone_victim.make_full_human_copy(pick(possible_spawns))
- player_mind.transfer_to(clone)
-
- var/datum/antagonist/paradox_clone/new_datum = player_mind.add_antag_datum(/datum/antagonist/paradox_clone)
- new_datum.original_ref = WEAKREF(clone_victim.mind)
- new_datum.setup_clone()
-
- playsound(clone, 'sound/items/weapons/zapbang.ogg', 30, TRUE)
- new /obj/item/storage/toolbox/mechanical(clone.loc) //so they dont get stuck in maints
-
- message_admins("[ADMIN_LOOKUPFLW(clone)] has been made into a Paradox Clone by the midround ruleset.")
- clone.log_message("was spawned as a Paradox Clone of [key_name(clone)] by the midround ruleset.", LOG_GAME)
-
- return clone
-
-/**
- * Trims through GLOB.player_list and finds a target
- * Returns a single human victim, if none is possible then returns null.
- */
-/datum/dynamic_ruleset/midround/from_ghosts/paradox_clone/proc/find_original()
- var/list/possible_targets = list()
-
- for(var/mob/living/carbon/human/player in GLOB.player_list)
- if(!player.client || !player.mind || player.stat)
- continue
- if(!(player.mind.assigned_role.job_flags & JOB_CREW_MEMBER))
- continue
- possible_targets += player
-
- if(possible_targets.len)
- return pick(possible_targets)
- return FALSE
-
-#undef MALF_ION_PROB
-#undef REPLACE_LAW_WITH_ION_PROB
-
-/// Midround Voidwalker Ruleset (From Ghosts)
-/datum/dynamic_ruleset/midround/from_ghosts/voidwalker
- name = "Voidwalker"
- midround_ruleset_style = MIDROUND_RULESET_STYLE_LIGHT
- antag_datum = /datum/antagonist/voidwalker
- antag_flag = ROLE_VOIDWALKER
- antag_flag_override = ROLE_VOIDWALKER
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- required_enemies = list(2,2,1,1,1,1,1,0,0,0)
- required_candidates = 1
- weight = 2
- cost = 5
- minimum_players = 40
- repeatable = TRUE
- signup_item_path = /obj/item/clothing/head/helmet/skull/cosmic
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_VOIDWALKER_VOID)
- /// The space turf we find in acceptable(), cached for ease
- var/space_turf
-
-/datum/dynamic_ruleset/midround/from_ghosts/voidwalker/acceptable(population = 0, threat_level = 0)
- space_turf = find_space_spawn()
- // Space only antag and will die on planetary gravity.
- if(SSmapping.is_planetary() || !space_turf)
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/midround/from_ghosts/voidwalker/generate_ruleset_body(mob/applicant)
- var/datum/mind/player_mind = new /datum/mind(applicant.key)
- player_mind.active = TRUE
-
- var/mob/living/carbon/human/voidwalker = new (space_turf)
- player_mind.transfer_to(voidwalker)
- player_mind.set_assigned_role(SSjob.get_job_type(/datum/job/voidwalker))
- player_mind.special_role = antag_flag
- player_mind.add_antag_datum(antag_datum)
-
- playsound(voidwalker, 'sound/effects/magic/ethereal_exit.ogg', 50, TRUE, -1)
- message_admins("[ADMIN_LOOKUPFLW(voidwalker)] has been made into a Voidwalker by the midround ruleset.")
- log_dynamic("[key_name(voidwalker)] was spawned as a Voidwalker by the midround ruleset.")
- return voidwalker
diff --git a/code/controllers/subsystem/dynamic/dynamic_rulesets_roundstart.dm b/code/controllers/subsystem/dynamic/dynamic_rulesets_roundstart.dm
deleted file mode 100644
index 7880e1cb12b..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_rulesets_roundstart.dm
+++ /dev/null
@@ -1,747 +0,0 @@
-GLOBAL_VAR_INIT(revolutionary_win, FALSE)
-
-//////////////////////////////////////////////
-// //
-// SYNDICATE TRAITORS //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/traitor
- name = "Traitors"
- antag_flag = ROLE_TRAITOR
- antag_datum = /datum/antagonist/traitor
- minimum_required_age = 0
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- required_candidates = 1
- weight = 5
- cost = 8 // Avoid raising traitor threat above this, as it is the default low cost ruleset.
- scaling_cost = 9
- requirements = list(8,8,8,8,8,8,8,8,8,8)
- antag_cap = list("denominator" = 38)
- var/autotraitor_cooldown = (15 MINUTES)
-
-/datum/dynamic_ruleset/roundstart/traitor/pre_execute(population)
- . = ..()
- for (var/i in 1 to get_antag_cap_scaling_included(population))
- if(candidates.len <= 0)
- break
- var/mob/M = pick_n_take(candidates)
- assigned += M.mind
- M.mind.special_role = ROLE_TRAITOR
- M.mind.restricted_roles = restricted_roles
- GLOB.pre_setup_antags += M.mind
- return TRUE
-
-//////////////////////////////////////////////
-// //
-// MALFUNCTIONING AI //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/malf_ai
- name = "Malfunctioning AI"
- antag_flag = ROLE_MALF
- antag_datum = /datum/antagonist/malf_ai
- minimum_required_age = 14
- exclusive_roles = list(JOB_AI)
- required_candidates = 1
- weight = 3
- cost = 18
- requirements = list(101,101,101,80,60,50,30,20,10,10)
- antag_cap = 1
- flags = HIGH_IMPACT_RULESET
-
-/datum/dynamic_ruleset/roundstart/malf_ai/ready(forced)
- var/datum/job/ai_job = SSjob.get_job_type(/datum/job/ai)
-
- // If we're not forced, we're going to make sure we can actually have an AI in this shift,
- if(!forced && min(ai_job.total_positions - ai_job.current_positions, ai_job.spawn_positions) <= 0)
- log_dynamic("FAIL: [src] could not run, because there is nobody who wants to be an AI")
- return FALSE
-
- return ..()
-
-/datum/dynamic_ruleset/roundstart/malf_ai/pre_execute(population)
- . = ..()
-
- var/datum/job/ai_job = SSjob.get_job_type(/datum/job/ai)
- // Maybe a bit too pedantic, but there should never be more malf AIs than there are available positions, spawn positions or antag cap allocations.
- var/num_malf = min(get_antag_cap(population), min(ai_job.total_positions - ai_job.current_positions, ai_job.spawn_positions))
- for (var/i in 1 to num_malf)
- if(candidates.len <= 0)
- break
- var/mob/new_malf = pick_n_take(candidates)
- assigned += new_malf.mind
- new_malf.mind.special_role = ROLE_MALF
- GLOB.pre_setup_antags += new_malf.mind
- // We need an AI for the malf roundstart ruleset to execute. This means that players who get selected as malf AI get priority, because antag selection comes before role selection.
- LAZYADDASSOC(SSjob.dynamic_forced_occupations, new_malf, "AI")
- return TRUE
-
-//////////////////////////////////////////
-// //
-// BLOOD BROTHERS //
-// //
-//////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/traitorbro
- name = "Blood Brothers"
- antag_flag = ROLE_BROTHER
- antag_datum = /datum/antagonist/brother
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- weight = 5
- cost = 8
- scaling_cost = 15
- requirements = list(40,30,30,20,20,15,15,15,10,10)
- antag_cap = 1
-
-/datum/dynamic_ruleset/roundstart/traitorbro/pre_execute(population)
- . = ..()
-
- for (var/i in 1 to get_antag_cap_scaling_included(population))
- var/mob/candidate = pick_n_take(candidates)
- if (isnull(candidate))
- break
-
- assigned += candidate.mind
- candidate.mind.restricted_roles = restricted_roles
- candidate.mind.special_role = ROLE_BROTHER
- GLOB.pre_setup_antags += candidate.mind
-
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/traitorbro/execute()
- for (var/datum/mind/mind in assigned)
- new /datum/team/brother_team(mind)
- GLOB.pre_setup_antags -= mind
-
- return TRUE
-
-//////////////////////////////////////////////
-// //
-// CHANGELINGS //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/changeling
- name = "Changelings"
- antag_flag = ROLE_CHANGELING
- antag_datum = /datum/antagonist/changeling
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- required_candidates = 1
- weight = 3
- cost = 16
- scaling_cost = 10
- requirements = list(70,70,60,50,40,20,20,10,10,10)
- antag_cap = list("denominator" = 29)
-
-/datum/dynamic_ruleset/roundstart/changeling/pre_execute(population)
- . = ..()
- for (var/i in 1 to get_antag_cap_scaling_included(population))
- if(candidates.len <= 0)
- break
- var/mob/M = pick_n_take(candidates)
- assigned += M.mind
- M.mind.restricted_roles = restricted_roles
- M.mind.special_role = ROLE_CHANGELING
- GLOB.pre_setup_antags += M.mind
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/changeling/execute()
- for(var/datum/mind/changeling in assigned)
- var/datum/antagonist/changeling/new_antag = new antag_datum()
- changeling.add_antag_datum(new_antag)
- GLOB.pre_setup_antags -= changeling
- return TRUE
-
-//////////////////////////////////////////////
-// //
-// HERETICS //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/heretics
- name = "Heretics"
- antag_flag = ROLE_HERETIC
- antag_datum = /datum/antagonist/heretic
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- JOB_CHAPLAIN, // BUBBER EDIT - Chaplains can't heretic
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- required_candidates = 1
- weight = 3
- cost = 16
- scaling_cost = 9
- requirements = list(101,101,60,30,30,25,20,15,10,10)
- antag_cap = list("denominator" = 24)
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_HERETIC_SACRIFICE)
-
-
-/datum/dynamic_ruleset/roundstart/heretics/pre_execute(population)
- . = ..()
- var/num_ecult = get_antag_cap(population) * (scaled_times + 1)
-
- for (var/i = 1 to num_ecult)
- if(candidates.len <= 0)
- break
- var/mob/picked_candidate = pick_n_take(candidates)
- assigned += picked_candidate.mind
- picked_candidate.mind.restricted_roles = restricted_roles
- picked_candidate.mind.special_role = ROLE_HERETIC
- GLOB.pre_setup_antags += picked_candidate.mind
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/heretics/execute()
-
- for(var/c in assigned)
- var/datum/mind/cultie = c
- var/datum/antagonist/heretic/new_antag = new antag_datum()
- cultie.add_antag_datum(new_antag)
- GLOB.pre_setup_antags -= cultie
-
- return TRUE
-
-
-//////////////////////////////////////////////
-// //
-// WIZARDS //
-// //
-//////////////////////////////////////////////
-
-// Dynamic is a wonderful thing that adds wizards to every round and then adds even more wizards during the round.
-/datum/dynamic_ruleset/roundstart/wizard
- name = "Wizard"
- antag_flag = ROLE_WIZARD
- antag_datum = /datum/antagonist/wizard
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- flags = HIGH_IMPACT_RULESET
- minimum_required_age = 14
- restricted_roles = list(
- JOB_CAPTAIN,
- JOB_HEAD_OF_SECURITY,
- ) // Just to be sure that a wizard getting picked won't ever imply a Captain or HoS not getting drafted
- required_candidates = 1
- weight = 2
- cost = 20
- requirements = list(90,90,90,80,60,40,30,20,10,10)
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_WIZARDDEN)
-
-/datum/dynamic_ruleset/roundstart/wizard/ready(forced = FALSE)
- if(!check_candidates())
- return FALSE
- if(!length(GLOB.wizardstart))
- log_admin("Cannot accept Wizard ruleset. Couldn't find any wizard spawn points.")
- message_admins("Cannot accept Wizard ruleset. Couldn't find any wizard spawn points.")
- return FALSE
- return ..()
-
-/datum/dynamic_ruleset/roundstart/wizard/round_result()
- for(var/datum/antagonist/wizard/wiz in GLOB.antagonists)
- var/mob/living/real_wiz = wiz.owner?.current
- if(isnull(real_wiz))
- continue
-
- var/turf/wiz_location = get_turf(real_wiz)
- // If this wiz is alive AND not in an away level, then we know not all wizards are dead and can leave entirely
- if(considered_alive(wiz.owner) && wiz_location && !is_away_level(wiz_location.z))
- return
-
- SSticker.news_report = WIZARD_KILLED
-
-/datum/dynamic_ruleset/roundstart/wizard/pre_execute()
- . = ..()
- if(GLOB.wizardstart.len == 0)
- return FALSE
- var/mob/M = pick_n_take(candidates)
- if (M)
- assigned += M.mind
- M.mind.set_assigned_role(SSjob.get_job_type(/datum/job/space_wizard))
- M.mind.special_role = ROLE_WIZARD
-
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/wizard/execute()
- for(var/datum/mind/M in assigned)
- M.current.forceMove(pick(GLOB.wizardstart))
- M.add_antag_datum(new antag_datum())
- return TRUE
-
-//////////////////////////////////////////////
-// //
-// BLOOD CULT //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/bloodcult
- name = "Blood Cult"
- antag_flag = ROLE_CULTIST
- antag_datum = /datum/antagonist/cult
- minimum_required_age = 14
- restricted_roles = list(
- JOB_AI,
- JOB_CAPTAIN,
- JOB_CHAPLAIN,
- JOB_CYBORG,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- required_candidates = 2
- weight = 3
- cost = 20
- requirements = list(100,90,80,60,40,30,10,10,10,10)
- flags = HIGH_IMPACT_RULESET
- antag_cap = list("denominator" = 20, "offset" = 1)
- var/datum/team/cult/main_cult
-
-/datum/dynamic_ruleset/roundstart/bloodcult/ready(population, forced = FALSE)
- required_candidates = get_antag_cap(population)
- return ..()
-
-/datum/dynamic_ruleset/roundstart/bloodcult/pre_execute(population)
- . = ..()
- var/cultists = get_antag_cap(population)
- for(var/cultists_number = 1 to cultists)
- if(candidates.len <= 0)
- break
- var/mob/M = pick_n_take(candidates)
- assigned += M.mind
- M.mind.special_role = ROLE_CULTIST
- M.mind.restricted_roles = restricted_roles
- GLOB.pre_setup_antags += M.mind
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/bloodcult/execute()
- main_cult = new
- for(var/datum/mind/M in assigned)
- var/datum/antagonist/cult/new_cultist = new antag_datum()
- new_cultist.cult_team = main_cult
- new_cultist.give_equipment = TRUE
- M.add_antag_datum(new_cultist)
- GLOB.pre_setup_antags -= M
- main_cult.setup_objectives()
- var/datum/mind/most_experienced = get_most_experienced(assigned, antag_flag)
- if(!most_experienced)
- most_experienced = assigned[1]
- var/datum/antagonist/cult/leader = most_experienced.has_antag_datum(/datum/antagonist/cult)
- leader.make_cult_leader()
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/bloodcult/round_result()
- if(main_cult.check_cult_victory())
- SSticker.mode_result = "win - cult win"
- SSticker.news_report = CULT_SUMMON
- return
-
- SSticker.mode_result = "loss - staff stopped the cult"
-
- if(main_cult.size_at_maximum == 0)
- CRASH("Cult team existed with a size_at_maximum of 0 at round end!")
-
- // If more than a certain ratio of our cultists have escaped, give the "cult escape" resport.
- // Otherwise, give the "cult failure" report.
- var/ratio_to_be_considered_escaped = 0.5
- var/escaped_cultists = 0
- for(var/datum/mind/escapee as anything in main_cult.members)
- if(considered_escaped(escapee))
- escaped_cultists++
-
- SSticker.news_report = (escaped_cultists / main_cult.size_at_maximum) >= ratio_to_be_considered_escaped ? CULT_ESCAPE : CULT_FAILURE
-
-//////////////////////////////////////////////
-// //
-// NUCLEAR OPERATIVES //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/nuclear
- name = "Nuclear Emergency"
- antag_flag = ROLE_OPERATIVE
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- antag_datum = /datum/antagonist/nukeop
- var/datum/antagonist/antag_leader_datum = /datum/antagonist/nukeop/leader
- minimum_required_age = 14
- restricted_roles = list(
- JOB_CAPTAIN,
- JOB_HEAD_OF_SECURITY,
- ) // Just to be sure that a nukie getting picked won't ever imply a Captain or HoS not getting drafted
- required_candidates = 5
- weight = 3
- cost = 20
- requirements = list(90,90,90,80,60,40,30,20,10,10)
- flags = HIGH_IMPACT_RULESET
- antag_cap = list("denominator" = 18, "offset" = 1)
- ruleset_lazy_templates = list(LAZY_TEMPLATE_KEY_NUKIEBASE)
- var/required_role = ROLE_NUCLEAR_OPERATIVE
- var/datum/team/nuclear/nuke_team
- ///The job type to dress up our nuclear operative as.
- var/datum/job/job_type = /datum/job/nuclear_operative
-
-/datum/dynamic_ruleset/roundstart/nuclear/ready(population, forced = FALSE)
- required_candidates = get_antag_cap(population)
- return ..()
-
-/datum/dynamic_ruleset/roundstart/nuclear/pre_execute(population)
- . = ..()
- // If ready() did its job, candidates should have 5 or more members in it
- var/operatives = get_antag_cap(population)
- for(var/operatives_number = 1 to operatives)
- if(candidates.len <= 0)
- break
- var/mob/M = pick_n_take(candidates)
- assigned += M.mind
- M.mind.set_assigned_role(SSjob.get_job_type(job_type))
- M.mind.special_role = required_role
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/nuclear/execute()
- var/datum/mind/most_experienced = get_most_experienced(assigned, required_role)
- if(!most_experienced)
- most_experienced = assigned[1]
- var/datum/antagonist/nukeop/leader/leader = most_experienced.add_antag_datum(antag_leader_datum)
- nuke_team = leader.nuke_team
- for(var/datum/mind/assigned_player in assigned)
- if(assigned_player == most_experienced)
- continue
- var/datum/antagonist/nukeop/new_op = new antag_datum()
- assigned_player.add_antag_datum(new_op)
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/nuclear/round_result()
- var/result = nuke_team.get_result()
- switch(result)
- if(NUKE_RESULT_FLUKE)
- SSticker.mode_result = "loss - syndicate nuked - disk secured"
- SSticker.news_report = NUKE_SYNDICATE_BASE
- if(NUKE_RESULT_NUKE_WIN)
- SSticker.mode_result = "win - syndicate nuke"
- SSticker.news_report = STATION_DESTROYED_NUKE
- if(NUKE_RESULT_NOSURVIVORS)
- SSticker.mode_result = "halfwin - syndicate nuke - did not evacuate in time"
- SSticker.news_report = STATION_DESTROYED_NUKE
- if(NUKE_RESULT_WRONG_STATION)
- SSticker.mode_result = "halfwin - blew wrong station"
- SSticker.news_report = NUKE_MISS
- if(NUKE_RESULT_WRONG_STATION_DEAD)
- SSticker.mode_result = "halfwin - blew wrong station - did not evacuate in time"
- SSticker.news_report = NUKE_MISS
- if(NUKE_RESULT_CREW_WIN_SYNDIES_DEAD)
- SSticker.mode_result = "loss - evacuation - disk secured - syndi team dead"
- SSticker.news_report = OPERATIVES_KILLED
- if(NUKE_RESULT_CREW_WIN)
- SSticker.mode_result = "loss - evacuation - disk secured"
- SSticker.news_report = OPERATIVES_KILLED
- if(NUKE_RESULT_DISK_LOST)
- SSticker.mode_result = "halfwin - evacuation - disk not secured"
- SSticker.news_report = OPERATIVE_SKIRMISH
- if(NUKE_RESULT_DISK_STOLEN)
- SSticker.mode_result = "halfwin - detonation averted"
- SSticker.news_report = OPERATIVE_SKIRMISH
- else
- SSticker.mode_result = "halfwin - interrupted"
- SSticker.news_report = OPERATIVE_SKIRMISH
-
-//////////////////////////////////////////////
-// //
-// REVS //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/revs
- name = "Revolution"
- persistent = TRUE
- antag_flag = ROLE_REV_HEAD
- antag_flag_override = ROLE_REV_HEAD
- antag_datum = /datum/antagonist/rev/head
- minimum_required_age = 14
- restricted_roles = list(
- JOB_AI,
- JOB_CAPTAIN,
- JOB_CHIEF_ENGINEER,
- JOB_CHIEF_MEDICAL_OFFICER,
- JOB_CYBORG,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL,
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_QUARTERMASTER,
- JOB_RESEARCH_DIRECTOR,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- required_candidates = 3
- weight = 3
- delay = 7 MINUTES
- cost = 20
- requirements = list(101,101,70,40,30,20,10,10,10,10)
- antag_cap = 3
- flags = HIGH_IMPACT_RULESET
- blocking_rules = list(/datum/dynamic_ruleset/latejoin/provocateur)
- // I give up, just there should be enough heads with 35 players...
- minimum_players = 35
- var/datum/team/revolution/revolution
- var/finished = FALSE
-
-/datum/dynamic_ruleset/roundstart/revs/pre_execute(population)
- . = ..()
- var/max_candidates = get_antag_cap(population)
- for(var/i = 1 to max_candidates)
- if(candidates.len <= 0)
- break
- var/mob/M = pick_n_take(candidates)
- assigned += M.mind
- M.mind.restricted_roles = restricted_roles
- M.mind.special_role = antag_flag
- GLOB.pre_setup_antags += M.mind
- return TRUE
-
-/datum/dynamic_ruleset/roundstart/revs/execute()
- revolution = new()
- for(var/datum/mind/M in assigned)
- GLOB.pre_setup_antags -= M
- if(check_eligible(M))
- var/datum/antagonist/rev/head/new_head = new antag_datum()
- new_head.give_flash = TRUE
- new_head.give_hud = TRUE
- new_head.remove_clumsy = TRUE
- M.add_antag_datum(new_head,revolution)
- else
- assigned -= M
- log_dynamic("[ruletype] [name] discarded [M.name] from head revolutionary due to ineligibility.")
- if(revolution.members.len)
- revolution.update_objectives()
- revolution.update_rev_heads()
- SSshuttle.registerHostileEnvironment(revolution)
- return TRUE
- log_dynamic("[ruletype] [name] failed to get any eligible headrevs. Refunding [cost] threat.")
- return FALSE
-
-/datum/dynamic_ruleset/roundstart/revs/clean_up()
- qdel(revolution)
- ..()
-
-/datum/dynamic_ruleset/roundstart/revs/rule_process()
- var/winner = revolution.process_victory()
- if (isnull(winner))
- return
-
- finished = winner
-
- if(winner == REVOLUTION_VICTORY)
- GLOB.revolutionary_win = TRUE
-
- return RULESET_STOP_PROCESSING
-
-/// Checks for revhead loss conditions and other antag datums.
-/datum/dynamic_ruleset/roundstart/revs/proc/check_eligible(datum/mind/M)
- var/turf/T = get_turf(M.current)
- if(!considered_afk(M) && considered_alive(M) && is_station_level(T.z) && !M.antag_datums?.len && !HAS_MIND_TRAIT(M.current, TRAIT_UNCONVERTABLE))
- return TRUE
- return FALSE
-
-/datum/dynamic_ruleset/roundstart/revs/round_result()
- revolution.round_result(finished)
-
-// Admin only rulesets. The threat requirement is 101 so it is not possible to roll them.
-
-//////////////////////////////////////////////
-// //
-// EXTENDED //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/extended
- name = "Extended"
- antag_flag = null
- antag_datum = null
- restricted_roles = list()
- required_candidates = 0
- weight = 3
- cost = 0
- requirements = list(101,101,101,101,101,101,101,101,101,101)
- flags = LONE_RULESET
-
-/datum/dynamic_ruleset/roundstart/extended/pre_execute()
- . = ..()
- message_admins("Starting a round of extended.")
- log_game("Starting a round of extended.")
- SSdynamic.spend_roundstart_budget(SSdynamic.round_start_budget)
- SSdynamic.spend_midround_budget(SSdynamic.mid_round_budget)
- SSdynamic.threat_log += "[gameTimestamp()]: Extended ruleset set threat to 0."
- return TRUE
-
-//////////////////////////////////////////////
-// //
-// CLOWN OPS //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/nuclear/clown_ops
- name = "Clown Operatives"
- antag_datum = /datum/antagonist/nukeop/clownop
- antag_flag = ROLE_CLOWN_OPERATIVE
- antag_flag_override = ROLE_OPERATIVE
- ruleset_category = parent_type::ruleset_category | RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- antag_leader_datum = /datum/antagonist/nukeop/leader/clownop
- requirements = list(101,101,101,101,101,101,101,101,101,101)
- required_role = ROLE_CLOWN_OPERATIVE
- job_type = /datum/job/clown_operative
-
-/datum/dynamic_ruleset/roundstart/nuclear/clown_ops/pre_execute()
- . = ..()
- if(!.)
- return
-
- var/list/nukes = SSmachines.get_machines_by_type(/obj/machinery/nuclearbomb/syndicate)
- for(var/obj/machinery/nuclearbomb/syndicate/nuke as anything in nukes)
- new /obj/machinery/nuclearbomb/syndicate/bananium(nuke.loc)
- qdel(nuke)
-
-//////////////////////////////////////////////
-// //
-// METEOR //
-// //
-//////////////////////////////////////////////
-
-/datum/dynamic_ruleset/roundstart/meteor
- name = "Meteor"
- persistent = TRUE
- required_candidates = 0
- weight = 3
- cost = 0
- requirements = list(101,101,101,101,101,101,101,101,101,101)
- flags = LONE_RULESET
- var/meteordelay = 2000
- var/nometeors = FALSE
- var/rampupdelta = 5
-
-/datum/dynamic_ruleset/roundstart/meteor/rule_process()
- if(nometeors || meteordelay > world.time - SSticker.round_start_time)
- return
-
- var/list/wavetype = GLOB.meteors_normal
- var/meteorminutes = (world.time - SSticker.round_start_time - meteordelay) / 10 / 60
-
- if (prob(meteorminutes))
- wavetype = GLOB.meteors_threatening
-
- if (prob(meteorminutes/2))
- wavetype = GLOB.meteors_catastrophic
-
- var/ramp_up_final = clamp(round(meteorminutes/rampupdelta), 1, 10)
-
- spawn_meteors(ramp_up_final, wavetype)
-
-/// Ruleset for Nations
-/datum/dynamic_ruleset/roundstart/nations
- name = "Nations"
- required_candidates = 0
- weight = 0 //admin only (and for good reason)
- cost = 0
- flags = LONE_RULESET | ONLY_RULESET
-
-/datum/dynamic_ruleset/roundstart/nations/execute()
- . = ..()
- //notably assistant is not in this list to prevent the round turning into BARBARISM instantly, and silicon is in this list for UN
- var/list/department_types = list(
- /datum/job_department/silicon, //united nations
- /datum/job_department/cargo,
- /datum/job_department/engineering,
- /datum/job_department/medical,
- /datum/job_department/science,
- /datum/job_department/security,
- /datum/job_department/service,
- )
-
- for(var/department_type in department_types)
- create_separatist_nation(department_type, announcement = FALSE, dangerous = FALSE, message_admins = FALSE)
-
- GLOB.round_default_lawset = /datum/ai_laws/united_nations
-
-/datum/dynamic_ruleset/roundstart/spies
- name = "Spies"
- antag_flag = ROLE_SPY
- antag_datum = /datum/antagonist/spy
- minimum_required_age = 0
- protected_roles = list(
- JOB_CAPTAIN,
- JOB_DETECTIVE,
- JOB_HEAD_OF_PERSONNEL, // AA = bad
- JOB_HEAD_OF_SECURITY,
- JOB_PRISONER,
- JOB_SECURITY_OFFICER,
- JOB_WARDEN,
- )
- restricted_roles = list(
- JOB_AI,
- JOB_CYBORG,
- )
- required_candidates = 3 // lives or dies by there being a few spies
- weight = 5
- cost = 8
- scaling_cost = 4
- minimum_players = 10
- antag_cap = list("denominator" = 20, "offset" = 1)
- requirements = list(8, 8, 8, 8, 8, 8, 8, 8, 8, 8)
- /// What fraction is added to the antag cap for each additional scale
- var/fraction_per_scale = 0.2
-
-/datum/dynamic_ruleset/roundstart/spies/pre_execute(population)
- for(var/i in 1 to get_antag_cap_scaling_included(population))
- if(length(candidates) <= 0)
- break
- var/mob/picked_player = pick_n_take(candidates)
- assigned += picked_player.mind
- picked_player.mind.special_role = ROLE_SPY
- picked_player.mind.restricted_roles = restricted_roles
- GLOB.pre_setup_antags += picked_player.mind
- return TRUE
-
-// Scaling adds a fraction of the amount of additional spies rather than the full amount.
-/datum/dynamic_ruleset/roundstart/spies/get_scaling_antag_cap(population)
- return ceil(..() * fraction_per_scale)
diff --git a/code/controllers/subsystem/dynamic/dynamic_testing.dm b/code/controllers/subsystem/dynamic/dynamic_testing.dm
new file mode 100644
index 00000000000..5df1e3d2977
--- /dev/null
+++ b/code/controllers/subsystem/dynamic/dynamic_testing.dm
@@ -0,0 +1,111 @@
+
+/// Verb to open the create command report window and send command reports.
+ADMIN_VERB(dynamic_tester, R_DEBUG, "Dynamic Tester", "See dynamic probabilities.", ADMIN_CATEGORY_DEBUG)
+ BLACKBOX_LOG_ADMIN_VERB("Dynamic Tester")
+ var/datum/dynamic_tester/tgui = new()
+ tgui.ui_interact(user.mob)
+
+/datum/dynamic_tester
+ /// Instances of every roundstart ruleset
+ var/list/roundstart_rulesets = list()
+ /// Instances of every midround ruleset
+ var/list/midround_rulesets = list()
+
+ /// A formatted report of the weights of each roundstart ruleset, refreshed occasionally and sent to the UI.
+ var/list/roundstart_ruleset_report = list()
+ /// A formatted report of the weights of each midround ruleset, refreshed occasionally and sent to the UI.
+ var/list/midround_ruleset_report = list()
+
+ /// What is the tier we are testing?
+ var/tier = 1
+ /// How many players are we testing with?
+ var/num_players = 10
+
+/datum/dynamic_tester/New()
+ for(var/datum/dynamic_ruleset/rtype as anything in subtypesof(/datum/dynamic_ruleset/roundstart))
+ if(!initial(rtype.config_tag))
+ continue
+ var/datum/dynamic_ruleset/roundstart/created = new rtype(SSdynamic.get_config())
+ roundstart_rulesets += created
+ // snowflake so we can see headrev stats
+ if(istype(created, /datum/dynamic_ruleset/roundstart/revolution))
+ var/datum/dynamic_ruleset/roundstart/revolution/revs = created
+ revs.heads_necessary = 0
+
+ for(var/datum/dynamic_ruleset/rtype as anything in subtypesof(/datum/dynamic_ruleset/midround))
+ if(!initial(rtype.config_tag))
+ continue
+ var/datum/dynamic_ruleset/midround/created = new rtype(SSdynamic.get_config())
+ midround_rulesets += created
+
+ update_reports()
+
+/datum/dynamic_tester/ui_state(mob/user)
+ return ADMIN_STATE(R_DEBUG)
+
+/datum/dynamic_tester/ui_close()
+ qdel(src)
+
+/datum/dynamic_tester/ui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ ui = new(user, src, "DynamicTester")
+ ui.open()
+
+/datum/dynamic_tester/ui_static_data(mob/user)
+ var/list/data = list()
+
+ data["tier"] = tier
+ data["num_players"] = num_players
+ data["roundstart_ruleset_report"] = flatten_list(roundstart_ruleset_report)
+ data["midround_ruleset_report"] = flatten_list(midround_ruleset_report)
+
+ return data
+
+/datum/dynamic_tester/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
+ . = ..()
+ if(.)
+ return
+
+ switch(action)
+ if("set_num_players")
+ var/old_num = num_players
+ num_players = text2num(params["num_players"])
+ if(old_num != num_players)
+ update_reports()
+ return TRUE
+
+ if("set_tier")
+ var/old_tier = tier
+ tier = text2num(params["tier"])
+ if(old_tier != tier)
+ update_reports()
+ return TRUE
+
+/datum/dynamic_tester/proc/update_reports()
+ roundstart_ruleset_report.Cut()
+ for(var/datum/dynamic_ruleset/roundstart/ruleset as anything in roundstart_rulesets)
+ var/comment = ""
+ if(istype(ruleset, /datum/dynamic_ruleset/roundstart/revolution))
+ var/datum/dynamic_ruleset/roundstart/revolution/revs = ruleset
+ comment = " (Assuming [initial(revs.heads_necessary)] heads of staff)"
+
+ roundstart_ruleset_report[ruleset] = list(
+ "name" = ruleset.name,
+ "weight" = ruleset.get_weight(num_players, tier),
+ "max_candidates" = ruleset.get_antag_cap(num_players, ruleset.max_antag_cap || ruleset.min_antag_cap),
+ "min_candidates" = ruleset.get_antag_cap(num_players, ruleset.min_antag_cap),
+ "comment" = comment,
+ )
+
+ midround_ruleset_report.Cut()
+ for(var/datum/dynamic_ruleset/midround/ruleset as anything in midround_rulesets)
+ midround_ruleset_report[ruleset] = list(
+ "name" = ruleset.name,
+ "weight" = ruleset.get_weight(num_players, tier),
+ "max_candidates" = ruleset.get_antag_cap(num_players, ruleset.max_antag_cap || ruleset.min_antag_cap),
+ "min_candidates" = ruleset.get_antag_cap(num_players, ruleset.min_antag_cap),
+ "comment" = ruleset.midround_type,
+ )
+
+ update_static_data_for_all_viewers()
diff --git a/code/controllers/subsystem/dynamic/dynamic_unfavorable_situation.dm b/code/controllers/subsystem/dynamic/dynamic_unfavorable_situation.dm
deleted file mode 100644
index 994f2e3f5de..00000000000
--- a/code/controllers/subsystem/dynamic/dynamic_unfavorable_situation.dm
+++ /dev/null
@@ -1,74 +0,0 @@
-/// An easy interface to make...*waves hands* bad things happen.
-/// This is used for impactful events like traitors hacking and creating more threat, or a revolutions victory.
-/// It tries to spawn a heavy midround if possible, otherwise it will trigger a "bad" random event after a short period.
-/// Calling this function will not use up any threat.
-/datum/controller/subsystem/dynamic/proc/unfavorable_situation()
- SHOULD_NOT_SLEEP(TRUE)
-
- INVOKE_ASYNC(src, PROC_REF(_unfavorable_situation))
-
-/datum/controller/subsystem/dynamic/proc/_unfavorable_situation()
- var/static/list/unfavorable_random_events = list()
- if (!length(unfavorable_random_events))
- unfavorable_random_events = generate_unfavourable_events()
- var/list/possible_heavies = generate_unfavourable_heavy_rulesets()
- if (!length(possible_heavies))
- var/datum/round_event_control/round_event_control_type = pick(unfavorable_random_events)
- var/delay = rand(20 SECONDS, 1 MINUTES)
-
- log_dynamic_and_announce("An unfavorable situation was requested, but no heavy rulesets could be drafted. Spawning [initial(round_event_control_type.name)] in [DisplayTimeText(delay)] instead.")
- force_event_after(round_event_control_type, "an unfavorable situation", delay)
- else
- var/datum/dynamic_ruleset/midround/heavy_ruleset = pick_weight(possible_heavies)
- log_dynamic_and_announce("An unfavorable situation was requested, spawning [initial(heavy_ruleset.name)]")
- picking_specific_rule(heavy_ruleset, forced = TRUE, ignore_cost = TRUE)
-
-/// Return a valid heavy dynamic ruleset, or an empty list if there's no time to run any rulesets
-/datum/controller/subsystem/dynamic/proc/generate_unfavourable_heavy_rulesets()
- if (EMERGENCY_PAST_POINT_OF_NO_RETURN)
- return list()
-
- var/list/possible_heavies = list()
- for (var/datum/dynamic_ruleset/midround/ruleset as anything in midround_rules)
- if (ruleset.midround_ruleset_style != MIDROUND_RULESET_STYLE_HEAVY)
- continue
-
- if (ruleset.weight == 0)
- continue
-
- if (ruleset.cost > max_threat_level)
- continue
-
- if (!ruleset.acceptable(GLOB.alive_player_list.len, threat_level))
- continue
-
- if (ruleset.minimum_round_time > world.time - SSticker.round_start_time)
- continue
-
- if(istype(ruleset, /datum/dynamic_ruleset/midround/from_ghosts) && !(GLOB.ghost_role_flags & GHOSTROLE_MIDROUND_EVENT))
- continue
-
- ruleset.trim_candidates()
-
- ruleset.load_templates()
- if (!ruleset.ready())
- continue
-
- possible_heavies[ruleset] = ruleset.get_weight()
- return possible_heavies
-
-/// Filter the below list by which events can actually run on this map
-/datum/controller/subsystem/dynamic/proc/generate_unfavourable_events()
- var/static/list/unfavorable_random_events = list(
- /datum/round_event_control/earthquake,
- /datum/round_event_control/immovable_rod,
- /datum/round_event_control/meteor_wave,
- /datum/round_event_control/portal_storm_syndicate,
- )
- var/list/picked_events = list()
- for(var/type in unfavorable_random_events)
- var/datum/round_event_control/event = new type()
- if(!event.valid_for_map())
- continue
- picked_events += type
- return picked_events
diff --git a/code/controllers/subsystem/dynamic/readme.md b/code/controllers/subsystem/dynamic/readme.md
deleted file mode 100644
index d59ed6215a9..00000000000
--- a/code/controllers/subsystem/dynamic/readme.md
+++ /dev/null
@@ -1,202 +0,0 @@
-# Dynamic Mode
-
-## Roundstart
-
-Dynamic rolls threat based on a special sauce formula:
-
-> [dynamic_curve_width][/datum/controller/global_vars/var/dynamic_curve_width] \* tan((3.1416 \* (rand() - 0.5) \* 57.2957795)) + [dynamic_curve_centre][/datum/controller/global_vars/var/dynamic_curve_centre]
-
-This threat is split into two separate budgets--`round_start_budget` and `mid_round_budget`. For example, a round with 50 threat might be split into a 30 roundstart budget, and a 20 midround budget. The roundstart budget is used to apply antagonists applied on readied players when the roundstarts (`/datum/dynamic_ruleset/roundstart`). The midround budget is used for two types of rulesets:
-
-- `/datum/dynamic_ruleset/midround` - Rulesets that apply to either existing alive players, or to ghosts. Think Blob or Space Ninja, which poll ghosts asking if they want to play as these roles.
-- `/datum/dynamic_ruleset/latejoin` - Rulesets that apply to the next player that joins. Think Syndicate Infiltrator, which converts a player just joining an existing round into traitor.
-
-This split is done with a similar method, known as the ["lorentz distribution"](https://en.wikipedia.org/wiki/Cauchy_distribution), exists to create a bell curve that ensures that while most rounds will have a threat level around ~50, chaotic and tame rounds still exist for variety.
-
-The process of creating these numbers occurs in `/datum/controller/subsystem/dynamic/proc/generate_threat` (for creating the threat level) and `/datum/controller/subsystem/dynamic/proc/generate_budgets` (for splitting the threat level into budgets).
-
-## Deciding roundstart threats
-
-In `/datum/controller/subsystem/dynamic/proc/roundstart()` (called when no admin chooses the rulesets explicitly), Dynamic uses the available roundstart budget to pick threats. This is done through the following system:
-
-- All roundstart rulesets (remember, `/datum/dynamic_ruleset/roundstart`) are put into an associative list with their weight as the values (`drafted_rules`).
-- Until there is either no roundstart budget left, or until there is no ruleset we can choose from with the available threat, a `pickweight` is done based on the drafted_rules. If the same threat is picked twice, it will "scale up". The meaning of this depends on the ruleset itself, using the `scaled_times` variable; traitors for instance will create more the higher they scale.
- - If a ruleset is chosen with the `HIGH_IMPACT_RULESET` in its `flags`, then all other `HIGH_IMPACT_RULESET`s will be removed from `drafted_rules`. This is so that only one can ever be chosen.
- - If a ruleset has `LONE_RULESET` in its `flags`, then it will be removed from `drafted_rules`. This is to ensure it will only ever be picked once. An example of this in use is Wizard, to avoid creating multiple wizards.
-- After all roundstart threats are chosen, `/datum/dynamic_ruleset/proc/picking_roundstart_rule` is called for each, passing in the ruleset and the number of times it is scaled.
- - In this stage, `pre_execute` is called, which is the function that will determine what players get what antagonists. If this function returns FALSE for whatever reason (in the case of an error), then its threat is refunded.
-
-After this process is done, any leftover roundstart threat will be given to the existing midround budget (done in `/datum/controller/subsystem/dynamic/pre_setup()`).
-
-## Deciding midround threats
-
-### Frequency
-
-The frequency of midround threats is based on the midround threat of the round. The number of midround threats that will roll is `threat_level` / `threat_per_midround_roll` (configurable), rounded up. For example, if `threat_per_midround_roll` is set to 5, then for every 5 threat, one midround roll will be added. If you have 6 threat, with this configuration, you will get 2 midround rolls.
-
-These midround roll points are then equidistantly spaced across the round, starting from `midround_lower_bound` (configurable) to `midround_upper_bound` (configurable), with a +/- of `midround_roll_distance` (configurable).
-
-For example, if:
-
-1. `midround_lower_bound` is `10 MINUTES`
-2. `midround_upper_bound` is `100 MINUTES`
-3. `midround_roll_distance` is `3 MINUTES`
-4. You have 5 midround rolls for the round
-
-...then those 5 midround rolls will be placed equidistantly (meaning equally apart) across the first 10-100 minutes of the round. Every individual roll will then be adjusted to either be 3 minutes earlier, or 3 minutes later.
-
-### Threat variety
-
-Threats are split between **heavy** rulesets and **light** rulesets. A heavy ruleset includes major threats like space dragons or blobs, while light rulesets are ones that don't often cause shuttle calls when rolled, such as revenants or traitors (sleeper agents).
-
-When a midround roll occurs, the decision to choose between light or heavy depends on the current round time. If it is less than `midround_light_upper_bound` (configurable), then it is guaranteed to be a light ruleset. If it is more than `midround_heavy_lower_bound`, then it is guaranteed to be a heavy ruleset. If it is any point in between, it will interpolate the value between those. This means that the longer the round goes on, the more likely you are to get a heavy ruleset.
-
-If no heavy ruleset can run, such as not having enough threat, then a light ruleset is guaranteed to run.
-
-## Rule Processing
-
-Calls [rule_process][/datum/dynamic_ruleset/proc/rule_process] on every rule which is in the current_rules list.
-Every sixty seconds, update_playercounts()
-Midround injection time is checked against world.time to see if an injection should happen.
-If midround injection time is lower than world.time, it updates playercounts again, then tries to inject and generates a new cooldown regardless of whether a rule is picked.
-
-## Latejoin
-
-make_antag_chance(newPlayer) -> (For each latespawn rule...)
--> acceptable(living players, threat_level) -> trim_candidates() -> ready(forced=FALSE)
-**If true, add to drafted rules
-**NOTE that acceptable uses threat_level not threat!
-**NOTE Latejoin timer is ONLY reset if at least one rule was drafted.
-**NOTE the new_player.dm AttemptLateSpawn() calls OnPostSetup for all roles (unless assigned role is MODE)
-
-(After collecting all draftble rules...)
--> picking_latejoin_ruleset(drafted_rules) -> spend threat -> ruleset.execute()
-
-## Midround
-
-process() -> (For each midround rule...
--> acceptable(living players, threat_level) -> trim_candidates() -> ready(forced=FALSE)
-(After collecting all draftble rules...)
--> picking_midround_ruleset(drafted_rules) -> spend threat -> ruleset.execute()
-
-## Forced
-
-For latejoin, it simply sets forced_latejoin_rule
-make_antag_chance(newPlayer) -> trim_candidates() -> ready(forced=TRUE) \*\*NOTE no acceptable() call
-
-For midround, calls the below proc with forced = TRUE
-picking_specific_rule(ruletype,forced) -> forced OR acceptable(living_players, threat_level) -> trim_candidates() -> ready(forced) -> spend threat -> execute()
-**NOTE specific rule can be called by RS traitor->MR autotraitor w/ forced=FALSE
-**NOTE that due to short circuiting acceptable() need not be called if forced.
-
-## Ruleset
-
-acceptable(population,threat) just checks if enough threat_level for population indice.
-\*\*NOTE that we currently only send threat_level as the second arg, not threat.
-ready(forced) checks if enough candidates and calls the map's map_ruleset(dynamic_ruleset) at the parent level
-
-trim_candidates() varies significantly according to the ruleset type
-Roundstart: All candidates are new_player mobs. Check them for standard stuff: connected, desire role, not banned, etc.
-\*\*NOTE Roundstart deals with both candidates (trimmed list of valid players) and mode.candidates (everyone readied up). Don't confuse them!
-Latejoin: Only one candidate, the latejoiner. Standard checks.
-Midround: Instead of building a single list candidates, candidates contains four lists: living, dead, observing, and living antags. Standard checks in trim_list(list).
-
-Midround - Rulesets have additional types
-/from_ghosts: execute() -> send_applications() -> review_applications() -> finish_applications() -> finish_setup(mob/newcharacter, index) -> setup_role(role)
-\*\*NOTE: execute() here adds dead players and observers to candidates list
-
-## Configuration and variables
-
-### Configuration
-
-Configuration can be done through a `config/dynamic.json` file. One is provided as example in the codebase. This config file, loaded in `/datum/controller/subsystem/dynamic/pre_setup()`, directly overrides the values in the codebase, and so is perfect for making some rulesets harder/easier to get, turning them off completely, changing how much they cost, etc.
-
-The format of this file is:
-
-```json
-{
- "Dynamic": {
- /* Configuration in here will directly override `/datum/controller/subsystem/dynamic` itself. */
- /* Keys are variable names, values are their new values. */
- },
-
- "Roundstart": {
- /* Configuration in here will apply to `/datum/dynamic_ruleset/roundstart` instances. */
- /* Keys are the ruleset names, values are another associative list with keys being variable names and values being new values. */
- "Wizard": {
- /* I, a head admin, have died to wizard, and so I made it cost a lot more threat than it does in the codebase. */
- "cost": 80
- }
- },
-
- "Midround": {
- /* Same as "Roundstart", but for `/datum/dynamic_ruleset/midround` instead. */
- },
-
- "Latejoin": {
- /* Same as "Roundstart", but for `/datum/dynamic_ruleset/latejoin` instead. */
- },
-
- "Station": {
- /* Special threat reductions for dangerous station traits. Traits are selected before dynamic, so traits will always */
- /* reduce threat even if there's no threat for it available. Only "cost" can be modified */
- }
-}
-```
-
-Note: Comments are not possible in this format, and are just in this document for the sake of readability.
-
-### Rulesets
-
-Rulesets have the following variables notable to developers and those interested in tuning.
-
-- `required_candidates` - The number of people that _must be willing_ (in their preferences) to be an antagonist with this ruleset. If the candidates do not meet this requirement, then the ruleset will not bother to be drafted.
-- `antag_cap` - Judges the amount of antagonists to apply, for both solo and teams. Note that some antagonists (such as traitors, lings, heretics, etc) will add more based on how many times they've been scaled. Written as a linear equation--ceil(x/denominator) + offset, or as a fixed constant. If written as a linear equation, will be in the form of `list("denominator" = denominator, "offset" = offset)`.
- - Examples include:
- - Traitor: `antag_cap = list("denominator" = 24)`. This means that for every 24 players, 1 traitor will be added (assuming no scaling).
- - Nuclear Emergency: `antag_cap = list("denominator" = 18, "offset" = 1)`. For every 18 players, 1 nuke op will be added. Starts at 1, meaning at 30 players, 3 nuke ops will be created, rather than 2.
- - Revolution: `antag_cap = 3`. There will always be 3 rev-heads, no matter what.
-- `minimum_required_age` - The minimum age in order to apply for the ruleset.
-- `weight` - How likely this ruleset is to be picked. A higher weight results in a higher chance of drafting.
-- `cost` - The initial cost of the ruleset. This cost is taken from either the roundstart or midround budget, depending on the ruleset.
-- `scaling_cost` - Cost for every _additional_ application of this ruleset.
- - Suppose traitors has a `cost` of 8, and a `scaling_cost` of 5. This means that buying 1 application of the traitor ruleset costs 8 threat, but buying two costs 13 (8 + 5). Buying it a third time is 18 (8 + 5 + 5), etc.
-- `pop_per_requirement` - The range of population each value in `requirements` represents. By default, this is 6.
- - If the value is five the range is 0-4, 5-9, 10-14, 15-19, 20-24, 25-29, 30-34, 35-39, 40-54, 45+.
- - If it is six the range is 0-5, 6-11, 12-17, 18-23, 24-29, 30-35, 36-41, 42-47, 48-53, 54+.
- - If it is seven the range is 0-6, 7-13, 14-20, 21-27, 28-34, 35-41, 42-48, 49-55, 56-62, 63+.
-- `requirements` - A list that represents, per population range (see: `pop_per_requirement`), how much threat is required to _consider_ this ruleset. This is independent of how much it'll actually cost. This uses _threat level_, not the budget--meaning if a round has 50 threat level, but only 10 points of round start threat, a ruleset with a requirement of 40 can still be picked if it can be bought.
- - Suppose wizard has a `requirements` of `list(90,90,70,40,30,20,10,10,10,10)`. This means that, at 0-5 and 6-11 players, A station must have 90 threat in order for a wizard to be possible. At 12-17, 70 threat is required instead, etc.
-- `restricted_roles` - A list of jobs that _can't_ be drafted by this ruleset. For example, cyborgs cannot be changelings, and so are in the `restricted_roles`.
-- `protected_roles` - Serves the same purpose of `restricted_roles`, except it can be turned off through configuration (`protect_roles_from_antagonist`). For example, security officers _shouldn't_ be made traitor, so they are in Traitor's `protected_roles`.
- - When considering putting a role in `protected_roles` or `restricted_roles`, the rule of thumb is if it is _technically infeasible_ to support that job in that role. There's no _technical_ reason a security officer can't be a traitor, and so they are simply in `protected_roles`. There _are_ technical reasons a cyborg can't be a changeling, so they are in `restricted_roles` instead.
-
-This is not a complete list--search "configurable" in this README to learn more.
-
-### Dynamic
-
-The "Dynamic" key has the following configurable values:
-
-- `pop_per_requirement` - The default value of `pop_per_requirement` for any ruleset that does not explicitly set it. Defaults to 6.
-- `latejoin_delay_min`, `latejoin_delay_max` - The time range, in deciseconds (take your seconds, and multiply by 10), for a latejoin to attempt rolling. Once this timer is finished, a new one will be created within the same range.
- - Suppose you have a `latejoin_delay_min` of 600 (60 seconds, 1 minute) and a `latejoin_delay_max` of 1800 (180 seconds, 3 minutes). Once the round starts, a random number in this range will be picked--let's suppose 1.5 minutes. After 1.5 minutes, Dynamic will decide if a latejoin threat should be created (a probability of `/datum/controller/subsystem/dynamic/proc/get_injection_chance()`). Regardless of its decision, a new timer will be started within the range of 1 to 3 minutes, repeatedly.
-- `threat_curve_centre` - A number between -5 and +5. A negative value will give a more peaceful round and a positive value will give a round with higher threat.
-- `threat_curve_width` - A number between 0.5 and 4. Higher value will favour extreme rounds and lower value rounds closer to the average.
-- `roundstart_split_curve_centre` - A number between -5 and +5. Equivalent to threat_curve_centre, but for the budget split. A negative value will weigh towards midround rulesets, and a positive value will weight towards roundstart ones.
-- `roundstart_split_curve_width` - A number between 0.5 and 4. Equivalent to threat_curve_width, but for the budget split. Higher value will favour more variance in splits and lower value rounds closer to the average.
-- `random_event_hijack_minimum` - The minimum amount of time for antag random events to be hijacked. (See [Random Event Hijacking](#random-event-hijacking))
-- `random_event_hijack_maximum` - The maximum amount of time for antag random events to be hijacked. (See [Random Event Hijacking](#random-event-hijacking))
-- `hijacked_random_event_injection_chance` - The amount of injection chance to give to Dynamic when a random event is hijacked. (See [Random Event Hijacking](#random-event-hijacking))
-- `max_threat_level` - Sets the maximum amount of threat that can be rolled. Defaults to 100. You should only use this to _lower_ the maximum threat, as raising it higher will not do anything.
-
-## Random Event "Hijacking"
-
-Random events have the potential to be hijacked by Dynamic to keep the pace of midround injections, while also allowing greenshifts to contain some antagonists.
-
-`/datum/round_event_control/dynamic_should_hijack` is a variable to random events to allow Dynamic to hijack them, and defaults to FALSE. This is set to TRUE for random events that spawn antagonists.
-
-In `/datum/controller/subsystem/dynamic/on_pre_random_event` (in `dynamic_hijacking.dm`), Dynamic hooks to random events. If the `dynamic_should_hijack` variable is TRUE, the following sequence of events occurs:
-
-
-
-`n` is a random value between `random_event_hijack_minimum` and `random_event_hijack_maximum`. Heavy injection chance, should it need to be raised, is increased by `hijacked_random_event_injection_chance_modifier`.
diff --git a/code/controllers/subsystem/dynamic/ruleset_picking.dm b/code/controllers/subsystem/dynamic/ruleset_picking.dm
deleted file mode 100644
index baeceada57c..00000000000
--- a/code/controllers/subsystem/dynamic/ruleset_picking.dm
+++ /dev/null
@@ -1,159 +0,0 @@
-#define ADMIN_CANCEL_MIDROUND_TIME (120 SECONDS) // BUBBER EDIT
-
-///
-///
-/**
- * From a list of rulesets, returns one based on weight and availability.
- * Mutates the list that is passed into it to remove invalid rules.
- *
- * * max_allowed_attempts - Allows you to configure how many times the proc will attempt to pick a ruleset before giving up.
- */
-/datum/controller/subsystem/dynamic/proc/pick_ruleset(list/drafted_rules, max_allowed_attempts = INFINITY)
- if (only_ruleset_executed)
- log_dynamic("FAIL: only_ruleset_executed")
- return null
-
- if(!length(drafted_rules))
- log_dynamic("FAIL: pick ruleset supplied with an empty list of drafted rules.")
- return null
-
- var/attempts = 0
- while (attempts < max_allowed_attempts)
- attempts++
- var/datum/dynamic_ruleset/rule = pick_weight(drafted_rules)
- if (!rule)
- var/list/leftover_rules = list()
- for (var/leftover_rule in drafted_rules)
- leftover_rules += "[leftover_rule]"
-
- log_dynamic("FAIL: No rulesets left to pick. Leftover rules: [leftover_rules.Join(", ")]")
- return null
-
- if (check_blocking(rule.blocking_rules, executed_rules))
- log_dynamic("FAIL: [rule] can't execute as another rulset is blocking it.")
- drafted_rules -= rule
- if(drafted_rules.len <= 0)
- return null
- continue
- else if (
- rule.flags & HIGH_IMPACT_RULESET \
- && threat_level < GLOB.dynamic_stacking_limit \
- && GLOB.dynamic_no_stacking \
- && high_impact_ruleset_executed \
- )
- log_dynamic("FAIL: [rule] can't execute as a high impact ruleset was already executed.")
- drafted_rules -= rule
- if(drafted_rules.len <= 0)
- return null
- continue
-
- return rule
-
- return null
-
-/// Executes a random midround ruleset from the list of drafted rules.
-/datum/controller/subsystem/dynamic/proc/pick_midround_rule(list/drafted_rules, description)
- log_dynamic("Rolling [drafted_rules.len] [description]")
-
- var/datum/dynamic_ruleset/rule = pick_ruleset(drafted_rules)
- if (isnull(rule))
- return null
-
- current_midround_rulesets = drafted_rules - rule
-
- midround_injection_timer_id = addtimer(
- CALLBACK(src, PROC_REF(execute_midround_rule), rule), \
- ADMIN_CANCEL_MIDROUND_TIME, \
- TIMER_STOPPABLE, \
- )
- // SKYRAT EDIT REMOVAL BEGIN - Event notification
- /**
- log_dynamic("[rule] ruleset executing...")
- message_admins("DYNAMIC: Executing midround ruleset [rule] in [DisplayTimeText(ADMIN_CANCEL_MIDROUND_TIME)]. \
- CANCEL | \
- SOMETHING ELSE")
-
- return rule
- */
- // SKYRAT EDIT REMOVAL END - Event notification
-
- // SKYRAT EDIT ADDITION BEGIN - Event notification
- message_admins("Dynamic Event triggering in [DisplayTimeText(ADMIN_CANCEL_MIDROUND_TIME)]: [rule]. (\
- CANCEL | \
- SOMETHING ELSE)")
- for(var/client/staff as anything in GLOB.admins)
- if(staff?.prefs.read_preference(/datum/preference/toggle/comms_notification))
- SEND_SOUND(staff, sound('sound/misc/server-ready.ogg'))
- sleep(ADMIN_CANCEL_MIDROUND_TIME * 0.5)
-
- if(!midround_injection_timer_id == null)
- message_admins("Dynamic Event triggering in [DisplayTimeText(ADMIN_CANCEL_MIDROUND_TIME * 0.5)]: [rule]. (\
- CANCEL | \
- SOMETHING ELSE)")
-
- return rule
- // SKYRAT EDIT ADDITION END - Event notification
-
-/// Fired after admins do not cancel a midround injection.
-/datum/controller/subsystem/dynamic/proc/execute_midround_rule(datum/dynamic_ruleset/rule)
- current_midround_rulesets = null
- midround_injection_timer_id = null
- if (!rule.repeatable)
- midround_rules = remove_from_list(midround_rules, rule.type)
- addtimer(CALLBACK(src, PROC_REF(execute_midround_latejoin_rule), rule), rule.delay)
-
-/// Mainly here to facilitate delayed rulesets. All midround/latejoin rulesets are executed with a timered callback to this proc.
-/datum/controller/subsystem/dynamic/proc/execute_midround_latejoin_rule(sent_rule)
- var/datum/dynamic_ruleset/rule = sent_rule
- spend_midround_budget(rule.cost, threat_log, "[gameTimestamp()]: [rule.ruletype] [rule.name]")
- rule.pre_execute(GLOB.alive_player_list.len)
- if (rule.execute())
- log_dynamic("Injected a [rule.ruletype] ruleset [rule.name].")
- if(rule.flags & HIGH_IMPACT_RULESET)
- high_impact_ruleset_executed = TRUE
- else if(rule.flags & ONLY_RULESET)
- only_ruleset_executed = TRUE
- if(rule.ruletype == LATEJOIN_RULESET)
- var/mob/M = pick(rule.candidates)
- message_admins("[key_name(M)] joined the station, and was selected by the [rule.name] ruleset.")
- log_dynamic("[key_name(M)] joined the station, and was selected by the [rule.name] ruleset.")
- executed_rules += rule
- if (rule.persistent)
- current_rules += rule
- new_snapshot(rule)
- rule.forget_startup()
- return TRUE
- rule.forget_startup()
- rule.clean_up()
- stack_trace("The [rule.ruletype] rule \"[rule.name]\" failed to execute.")
- return FALSE
-
-/// Fired when an admin cancels the current midround injection.
-/datum/controller/subsystem/dynamic/proc/admin_cancel_midround(mob/user, timer_id)
- if (midround_injection_timer_id != timer_id || !deltimer(midround_injection_timer_id))
- to_chat(user, span_notice("Too late!"))
- return
-
- log_admin("[key_name(user)] cancelled the next midround injection.")
- message_admins("[key_name(user)] cancelled the next midround injection.")
- midround_injection_timer_id = null
- current_midround_rulesets = null
-
-/// Fired when an admin requests a different midround injection.
-/datum/controller/subsystem/dynamic/proc/admin_different_midround(mob/user, timer_id)
- if (midround_injection_timer_id != timer_id || !deltimer(midround_injection_timer_id))
- to_chat(user, span_notice("Too late!"))
- return
-
- midround_injection_timer_id = null
-
- if (isnull(current_midround_rulesets) || current_midround_rulesets.len == 0)
- log_admin("[key_name(user)] asked for a different midround injection, but there were none left.")
- message_admins("[key_name(user)] asked for a different midround injection, but there were none left.")
- return
-
- log_admin("[key_name(user)] asked for a different midround injection.")
- message_admins("[key_name(user)] asked for a different midround injection.")
- pick_midround_rule(current_midround_rulesets, "different midround rulesets")
-
-#undef ADMIN_CANCEL_MIDROUND_TIME
diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm
index e97be33d6e5..3863ae8f202 100644
--- a/code/controllers/subsystem/job.dm
+++ b/code/controllers/subsystem/job.dm
@@ -35,8 +35,10 @@ SUBSYSTEM_DEF(job)
var/list/level_order = list(JP_HIGH, JP_MEDIUM, JP_LOW)
- /// Lazylist of mob:occupation_string pairs.
- var/list/dynamic_forced_occupations
+ /// Lazylist of mob:occupation_string pairs. Forces mobs into certain occupations with highest priority.
+ var/list/forced_occupations
+ /// Lazylist of mob:list(occupation_string) pairs. Prevents mobs from taking certain occupations at all.
+ var/list/prevented_occupations
/**
* Keys should be assigned job roles. Values should be >= 1.
@@ -322,7 +324,6 @@ SUBSYSTEM_DEF(job)
if(!player?.mind)
continue
player.mind.set_assigned_role(get_job_type(/datum/job/unassigned))
- player.mind.special_role = null
setup_occupations()
unassigned = list()
if(CONFIG_GET(flag/load_jobs_from_txt))
@@ -415,9 +416,8 @@ SUBSYSTEM_DEF(job)
SEND_SIGNAL(src, COMSIG_OCCUPATIONS_DIVIDED, pure, allow_all)
//Get the players who are ready
- for(var/i in GLOB.new_player_list)
- var/mob/dead/new_player/player = i
- if(player.ready == PLAYER_READY_TO_PLAY && player.check_preferences() && player.mind && is_unassigned_job(player.mind.assigned_role))
+ for(var/mob/dead/new_player/player as anything in GLOB.new_player_list)
+ if(player.ready == PLAYER_READY_TO_PLAY && player.check_job_preferences(!pure) && player.mind && is_unassigned_job(player.mind.assigned_role))
unassigned += player
initial_players_to_assign = length(unassigned)
@@ -710,9 +710,10 @@ SUBSYSTEM_DEF(job)
return 0
/datum/controller/subsystem/job/proc/try_reject_player(mob/dead/new_player/player)
- if(player.mind && player.mind.special_role)
- job_debug("RJCT: Player unable to be rejected due to special_role, Player: [player], SpecialRole: [player.mind.special_role]")
- return FALSE
+ for(var/datum/dynamic_ruleset/roundstart/ruleset in SSdynamic.queued_rulesets)
+ if(player.mind in ruleset.selected_minds)
+ job_debug("RJCT: Player unable to be rejected due to being selected by dynamic, Player: [player], Ruleset: [ruleset]")
+ return FALSE
job_debug("RJCT: Player rejected, Player: [player]")
unassigned -= player
@@ -884,11 +885,12 @@ SUBSYSTEM_DEF(job)
/// Assigns roles that are considered high priority, either due to dynamic needing to force a specific role for a specific ruleset
/// or making sure roles critical to round progression exist where possible every shift.
/datum/controller/subsystem/job/proc/assign_priority_positions()
- job_debug("APP: Assigning Dynamic ruleset forced occupations: [length(dynamic_forced_occupations)]")
- for(var/mob/new_player in dynamic_forced_occupations)
+ job_debug("APP: Assigning Dynamic ruleset forced occupations: [LAZYLEN(forced_occupations)]")
+ for(var/datum/mind/mind as anything in forced_occupations)
+ var/mob/dead/new_player = mind.current
// Eligibility checks already carried out as part of the dynamic ruleset trim_candidates proc.
// However no guarantee of game state between then and now, so don't skip eligibility checks on assign_role.
- assign_role(new_player, get_job(dynamic_forced_occupations[new_player]))
+ assign_role(new_player, get_job_type(LAZYACCESS(forced_occupations, mind)))
// Get JP_HIGH department Heads of Staff in place. Indirectly useful for the Revolution ruleset to have as many Heads as possible.
job_debug("APP: Assigning all JP_HIGH head of staff roles.")
@@ -953,7 +955,7 @@ SUBSYSTEM_DEF(job)
job_debug("[debug_prefix]: Player has no mind, Player: [player][add_job_to_log ? ", Job: [possible_job]" : ""]")
return JOB_UNAVAILABLE_GENERIC
- if(possible_job.title in player.mind.restricted_roles)
+ if(possible_job.title in LAZYACCESS(prevented_occupations, player.mind))
job_debug("[debug_prefix] Error: [get_job_unavailable_error_message(JOB_UNAVAILABLE_ANTAG_INCOMPAT, possible_job.title)], Player: [player][add_job_to_log ? ", Job: [possible_job]" : ""]")
return JOB_UNAVAILABLE_ANTAG_INCOMPAT
@@ -972,7 +974,8 @@ SUBSYSTEM_DEF(job)
return JOB_UNAVAILABLE_BANNED
// Check for character age
- if(possible_job.required_character_age > player.client.prefs.read_preference(/datum/preference/numeric/age) && possible_job.required_character_age != null)
+ var/client/player_client = GET_CLIENT(player)
+ if(isnum(possible_job.required_character_age) && possible_job.required_character_age > player_client.prefs.read_preference(/datum/preference/numeric/age))
job_debug("[debug_prefix] Error: [get_job_unavailable_error_message(JOB_UNAVAILABLE_AGE)], Player: [player][add_job_to_log ? ", Job: [possible_job]" : ""]")
return JOB_UNAVAILABLE_AGE
diff --git a/code/controllers/subsystem/polling.dm b/code/controllers/subsystem/polling.dm
index 99b179af6e7..dccb826a12f 100644
--- a/code/controllers/subsystem/polling.dm
+++ b/code/controllers/subsystem/polling.dm
@@ -285,11 +285,10 @@ SUBSYSTEM_DEF(polling)
if(the_ignore_category)
if(potential_candidate.ckey in GLOB.poll_ignore[the_ignore_category])
return FALSE
- if(role)
+ if(role && potential_candidate.client)
if(!(role in potential_candidate.client.prefs.be_special))
return FALSE
- var/required_time = GLOB.special_roles[role] || 0
- if(potential_candidate.client && potential_candidate.client.get_remaining_days(required_time) > 0)
+ if(potential_candidate.client.get_days_to_play_antag(role) > 0)
return FALSE
if(check_jobban)
diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm
index fc58389340b..6625dfd3ba9 100644
--- a/code/controllers/subsystem/ticker.dm
+++ b/code/controllers/subsystem/ticker.dm
@@ -241,7 +241,7 @@ SUBSYSTEM_DEF(ticker)
return TRUE
if(GLOB.station_was_nuked)
return TRUE
- if(GLOB.revolutionary_win)
+ if(GLOB.revolution_handler?.result == REVOLUTION_VICTORY)
return TRUE
return FALSE
@@ -252,7 +252,7 @@ SUBSYSTEM_DEF(ticker)
CHECK_TICK
//Configure mode and assign player to antagonists
var/can_continue = FALSE
-// can_continue = SSdynamic.pre_setup() //Choose antagonists // BUBBER EDIT - STORYTELLER (note: maybe disable)
+// can_continue = SSdynamic.select_roundstart_antagonists() //Choose antagonists // BUBBER EDIT - STORYTELLER (note: maybe disable)
//BUBBER EDIT BEGIN - STORYTELLER
SSgamemode.init_storyteller()
can_continue = SSgamemode.pre_setup()
@@ -325,7 +325,37 @@ SUBSYSTEM_DEF(ticker)
/datum/controller/subsystem/ticker/proc/PostSetup()
set waitfor = FALSE
- SSdynamic.post_setup()
+
+ // Spawn traitors and stuff
+ for(var/datum/dynamic_ruleset/roundstart/ruleset in SSdynamic.queued_rulesets)
+ ruleset.execute()
+ SSdynamic.queued_rulesets -= ruleset
+ SSdynamic.executed_rulesets += ruleset
+ // Queue roundstart intercept report
+ if(!CONFIG_GET(flag/no_intercept_report))
+ GLOB.communications_controller.queue_roundstart_report()
+ // Queue admin logout report
+ addtimer(CALLBACK(src, PROC_REF(display_roundstart_logout_report)), ROUNDSTART_LOGOUT_REPORT_TIME)
+ // Queue suicide slot handling
+ if(CONFIG_GET(flag/reopen_roundstart_suicide_roles))
+ var/delay = (CONFIG_GET(number/reopen_roundstart_suicide_roles_delay) * 1 SECONDS) || 4 MINUTES
+ addtimer(CALLBACK(src, PROC_REF(reopen_roundstart_suicide_roles)), delay)
+ // Handle database
+ if(SSdbcore.Connect())
+ var/list/to_set = list()
+ var/arguments = list()
+ if(GLOB.revdata.originmastercommit)
+ to_set += "commit_hash = :commit_hash"
+ arguments["commit_hash"] = GLOB.revdata.originmastercommit
+ if(to_set.len)
+ arguments["round_id"] = GLOB.round_id
+ var/datum/db_query/query_round_game_mode = SSdbcore.NewQuery(
+ "UPDATE [format_table_name("round")] SET [to_set.Join(", ")] WHERE id = :round_id",
+ arguments
+ )
+ query_round_game_mode.Execute()
+ qdel(query_round_game_mode)
+
SSgamemode.post_setup() // BUBBER EDIT - Storyteller
GLOB.start_state = new /datum/station_state()
GLOB.start_state.count()
@@ -355,11 +385,97 @@ SUBSYSTEM_DEF(ticker)
if(!iter_human.hardcore_survival_score)
continue
- if(iter_human.mind?.special_role)
+ if(iter_human.is_antag())
to_chat(iter_human, span_notice("You will gain [round(iter_human.hardcore_survival_score) * 2] hardcore random points if you greentext this round!"))
else
to_chat(iter_human, span_notice("You will gain [round(iter_human.hardcore_survival_score)] hardcore random points if you survive this round!"))
+/datum/controller/subsystem/ticker/proc/display_roundstart_logout_report()
+ var/list/msg = list("[span_boldnotice("Roundstart logout report")]\n\n")
+ for(var/i in GLOB.mob_living_list)
+ var/mob/living/L = i
+ var/mob/living/carbon/C = L
+ if (istype(C) && !C.last_mind)
+ continue // never had a client
+
+ if(L.ckey && !GLOB.directory[L.ckey])
+ msg += "[L.name] ([L.key]), the [L.job] (Disconnected)\n"
+
+
+ if(L.ckey && L.client)
+ var/failed = FALSE
+ if(L.client.inactivity >= ROUNDSTART_LOGOUT_AFK_THRESHOLD) //Connected, but inactive (alt+tabbed or something)
+ msg += "[L.name] ([L.key]), the [L.job] (Connected, Inactive)\n"
+ failed = TRUE //AFK client
+ if(!failed && L.stat)
+ if(HAS_TRAIT(L, TRAIT_SUICIDED)) //Suicider
+ msg += "[L.name] ([L.key]), the [L.job] ([span_bolddanger("Suicide")])\n"
+ failed = TRUE //Disconnected client
+ if(!failed && (L.stat == UNCONSCIOUS || L.stat == HARD_CRIT))
+ msg += "[L.name] ([L.key]), the [L.job] (Dying)\n"
+ failed = TRUE //Unconscious
+ if(!failed && L.stat == DEAD)
+ msg += "[L.name] ([L.key]), the [L.job] (Dead)\n"
+ failed = TRUE //Dead
+
+ continue //Happy connected client
+ for(var/mob/dead/observer/D in GLOB.dead_mob_list)
+ if(D.mind && D.mind.current == L)
+ if(L.stat == DEAD)
+ if(HAS_TRAIT(L, TRAIT_SUICIDED)) //Suicider
+ msg += "[L.name] ([ckey(D.mind.key)]), the [L.job] ([span_bolddanger("Suicide")])\n"
+ continue //Disconnected client
+ else
+ msg += "[L.name] ([ckey(D.mind.key)]), the [L.job] (Dead)\n"
+ continue //Dead mob, ghost abandoned
+ else
+ if(D.can_reenter_corpse)
+ continue //Adminghost, or cult/wizard ghost
+ else
+ msg += "[L.name] ([ckey(D.mind.key)]), the [L.job] ([span_bolddanger("Ghosted")])\n"
+ continue //Ghosted while alive
+
+ var/concatenated_message = msg.Join()
+ log_admin(concatenated_message)
+ to_chat(GLOB.admins, concatenated_message)
+
+/datum/controller/subsystem/ticker/proc/reopen_roundstart_suicide_roles()
+ var/include_command = CONFIG_GET(flag/reopen_roundstart_suicide_roles_command_positions)
+ var/list/reopened_jobs = list()
+
+ for(var/mob/living/quitter in GLOB.suicided_mob_list)
+ var/datum/job/job = SSjob.get_job(quitter.job)
+ if(!job || !(job.job_flags & JOB_REOPEN_ON_ROUNDSTART_LOSS))
+ continue
+ if(!include_command && job.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND)
+ continue
+ job.current_positions = max(job.current_positions - 1, 0)
+ reopened_jobs += quitter.job
+
+ if(CONFIG_GET(flag/reopen_roundstart_suicide_roles_command_report))
+ if(reopened_jobs.len)
+ var/reopened_job_report_positions
+ for(var/dead_dudes_job in reopened_jobs)
+ reopened_job_report_positions = "[reopened_job_report_positions ? "[reopened_job_report_positions]\n":""][dead_dudes_job]"
+
+ var/suicide_command_report = {"
+ [command_name()] Human Resources Board
+ Notice of Personnel Change
+ To personnel management staff aboard [station_name()]:
+ Our medical staff have detected a series of anomalies in the vital sensors
+ of some of the staff aboard your station.
+ Further investigation into the situation on our end resulted in us discovering
+ a series of rather... unforturnate decisions that were made on the part of said staff.
+ As such, we have taken the liberty to automatically reopen employment opportunities for the positions of the crew members
+ who have decided not to partake in our research. We will be forwarding their cases to our employment review board
+ to determine their eligibility for continued service with the company (and of course the
+ continued storage of cloning records within the central medical backup server.)
+ The following positions have been reopened on our behalf:
+ [reopened_job_report_positions]
+ "}
+
+ print_command_report(suicide_command_report, "Central Command Personnel Update")
+
//These callbacks will fire after roundstart key transfer
/datum/controller/subsystem/ticker/proc/OnRoundstart(datum/callback/cb)
if(!HasRoundStarted())
diff --git a/code/datums/ai_laws/ai_laws.dm b/code/datums/ai_laws/ai_laws.dm
index 3b3848f3bf0..a472ef04f50 100644
--- a/code/datums/ai_laws/ai_laws.dm
+++ b/code/datums/ai_laws/ai_laws.dm
@@ -261,11 +261,11 @@ GLOBAL_VAR(round_default_lawset)
return FALSE
// If the owner is an antag (has a special role) they also shouldn't be wiped
- if(owner?.mind?.special_role)
+ if(owner?.is_antag())
return FALSE
if (isAI(owner))
var/mob/living/silicon/ai/ai_owner = owner
- if(ai_owner.deployed_shell?.mind?.special_role)
+ if(ai_owner.deployed_shell?.is_antag())
return FALSE
zeroth = null
diff --git a/code/datums/communications.dm b/code/datums/communications.dm
index c24602e4a26..ce598f11f6c 100644
--- a/code/datums/communications.dm
+++ b/code/datums/communications.dm
@@ -20,6 +20,11 @@ GLOBAL_DATUM_INIT(communications_controller, /datum/communciations_controller, n
/// The location where the special xenomorph egg was planted
var/area/captivity_area
+ /// What is the lower bound of when the roundstart announcement is sent out?
+ var/waittime_l = 60 SECONDS
+ /// What is the higher bound of when the roundstart announcement is sent out?
+ var/waittime_h = 180 SECONDS
+
/datum/communciations_controller/proc/can_announce(mob/living/user, is_silicon)
if(is_silicon && COOLDOWN_FINISHED(src, silicon_message_cooldown))
return TRUE
@@ -58,6 +63,75 @@ GLOBAL_DATUM_INIT(communications_controller, /datum/communciations_controller, n
printed_paper.add_raw_text(sending.content)
printed_paper.update_appearance()
+// Called AFTER everyone is equipped with their job
+/datum/communciations_controller/proc/queue_roundstart_report()
+ addtimer(CALLBACK(src, PROC_REF(send_roundstart_report)), rand(waittime_l, waittime_h))
+
+/datum/communciations_controller/proc/send_roundstart_report(greenshift)
+ if(block_command_report) //If we don't want the report to be printed just yet, we put it off until it's ready
+ addtimer(CALLBACK(src, PROC_REF(send_roundstart_report), greenshift), 10 SECONDS)
+ return
+
+ var/dynamic_report = SSdynamic.get_advisory_report()
+ if(isnull(greenshift)) // if we're not forced to be greenshift or not - check if we are an actual greenshift
+ greenshift = SSdynamic.current_tier.tier == 0 && dynamic_report == /datum/dynamic_tier/greenshift::advisory_report
+
+ . = "Nanotrasen Department of Intelligence Threat Advisory, Spinward Sector, TCD [time2text(world.realtime, "DDD, MMM DD")], [CURRENT_STATION_YEAR]:"
+ . += dynamic_report
+
+ SSstation.generate_station_goals(greenshift ? INFINITY : CONFIG_GET(number/station_goal_budget))
+
+ var/list/datum/station_goal/goals = SSstation.get_station_goals()
+ if(length(goals))
+ var/list/texts = list("Special Orders for [station_name()]: ")
+ for(var/datum/station_goal/station_goal as anything in goals)
+ station_goal.on_report()
+ texts += station_goal.get_report()
+ . += texts.Join("")
+
+ var/list/trait_list_strings = list()
+ for(var/datum/station_trait/station_trait as anything in SSstation.station_traits)
+ if(!station_trait.show_in_report)
+ continue
+ trait_list_strings += "[station_trait.get_report()] "
+ if(trait_list_strings.len > 0)
+ . += "Identified shift divergencies: " + trait_list_strings.Join()
+
+ if(length(command_report_footnotes))
+ var/footnote_pile = ""
+
+ for(var/datum/command_footnote/footnote as anything in command_report_footnotes)
+ footnote_pile += "[footnote.message] "
+ footnote_pile += "[footnote.signature] "
+ footnote_pile += " "
+
+ . += "Additional Notes:
" + footnote_pile
+
+#ifndef MAP_TEST
+ print_command_report(., "[command_name()] Status Summary", announce=FALSE)
+ if(greenshift)
+ priority_announce(
+ "Thanks to the tireless efforts of our security and intelligence divisions, \
+ there are currently no credible threats to [station_name()]. \
+ All station construction projects have been authorized. Have a secure shift!",
+ "Security Report",
+ SSstation.announcer.get_rand_report_sound(),
+ color_override = "green",
+ )
+ else
+ if(SSsecurity_level.get_current_level_as_number() < SEC_LEVEL_BLUE)
+ SSsecurity_level.set_level(SEC_LEVEL_BLUE, announce = FALSE)
+ priority_announce(
+ "[SSsecurity_level.current_security_level.elevating_to_announcement]\n\n\
+ A summary has been copied and printed to all communications consoles.",
+ "Security level elevated.",
+ ANNOUNCER_INTERCEPT,
+ color_override = SSsecurity_level.current_security_level.announcement_color,
+ )
+#endif
+
+ return .
+
#undef COMMUNICATION_COOLDOWN
#undef COMMUNICATION_COOLDOWN_AI
#undef COMMUNICATION_COOLDOWN_MEETING
diff --git a/code/datums/mind/_mind.dm b/code/datums/mind/_mind.dm
index ad05f409ff6..5bbc69f6101 100644
--- a/code/datums/mind/_mind.dm
+++ b/code/datums/mind/_mind.dm
@@ -48,8 +48,6 @@
/// Job datum indicating the mind's role. This should always exist after initialization, as a reference to a singleton.
var/datum/job/assigned_role
- var/special_role
- var/list/restricted_roles = list()
/// List of antag datums on this mind
var/list/antag_datums
@@ -89,7 +87,9 @@
///Skill multiplier list, just slap your multiplier change onto this with the type it is coming from as key.
var/list/experience_multiplier_reasons = list()
- /// A lazy list of statuses to add next to this mind in the traitor panel
+ /// A lazy list of roles to display that this mind has, stuff like "Traitor" or "Special Creature"
+ var/list/special_roles
+ /// A lazy list of statuses to display that this mind has, stuff like "Infected" or "Mindshielded"
var/list/special_statuses
///Assoc list of addiction values, key is the type of withdrawal (as singleton type), and the value is the amount of addiction points (as number)
@@ -124,7 +124,7 @@
.["memories"] = memories
.["antag_datums"] = antag_datums
.["holy_role"] = holy_role
- .["special_role"] = special_role
+ .["special_role"] = jointext(get_special_roles(), " | ")
.["assigned_role"] = assigned_role.title
.["current"] = current
@@ -492,16 +492,6 @@
var/datum/addiction/affected_addiction = SSaddiction.all_addictions[type]
return affected_addiction.on_lose_addiction_points(src)
-/// Whether or not we can roll for midrounds, specifically checking if we have any major antag datums that should block it
-/datum/mind/proc/can_roll_midround(datum/antagonist/antag_type)
- if(SEND_SIGNAL(current, COMSIG_MOB_MIND_BEFORE_MIDROUND_ROLL, src, antag_type) & CANCEL_ROLL)
- return FALSE
- for(var/datum/antagonist/antag as anything in antag_datums)
- if(antag.block_midrounds)
- return FALSE
-
- return TRUE
-
/// Setter for the assigned_role job datum.
/datum/mind/proc/set_assigned_role(datum/job/new_role)
if(assigned_role == new_role)
diff --git a/code/datums/mind/antag.dm b/code/datums/mind/antag.dm
index 7f65cb8fdc7..9f1efc3b154 100644
--- a/code/datums/mind/antag.dm
+++ b/code/datums/mind/antag.dm
@@ -61,37 +61,6 @@
return TRUE
return FALSE
-/*
- Removes antag type's references from a mind.
- objectives, uplinks, powers etc are all handled.
-*/
-
-/datum/mind/proc/remove_changeling()
- var/datum/antagonist/changeling/C = has_antag_datum(/datum/antagonist/changeling)
- if(C)
- remove_antag_datum(/datum/antagonist/changeling)
- special_role = null
-
-/datum/mind/proc/remove_traitor()
- remove_antag_datum(/datum/antagonist/traitor)
-
-/datum/mind/proc/remove_nukeop()
- var/datum/antagonist/nukeop/nuke = has_antag_datum(/datum/antagonist/nukeop,TRUE)
- if(nuke)
- remove_antag_datum(nuke.type)
- special_role = null
-
-/datum/mind/proc/remove_wizard()
- remove_antag_datum(/datum/antagonist/wizard)
- special_role = null
-
-/datum/mind/proc/remove_rev()
- var/datum/antagonist/rev/rev = has_antag_datum(/datum/antagonist/rev)
- if(rev)
- remove_antag_datum(rev.type)
- special_role = null
-
-
/datum/mind/proc/remove_antag_equip()
if(!current)
return
@@ -227,7 +196,7 @@
current.log_message("has been enslaved to [key_name(creator)].", LOG_GAME)
log_admin("[key_name(current)] has been enslaved to [key_name(creator)].")
- if(creator.mind?.special_role)
+ if(creator.is_antag())
message_admins("[ADMIN_LOOKUPFLW(current)] has been created by [ADMIN_LOOKUPFLW(creator)], an antagonist.")
to_chat(current, span_userdanger("Despite your creator's current allegiances, your true master remains [creator.real_name]. If their loyalties change, so do yours. This will never change unless your creator's body is destroyed."))
@@ -274,33 +243,12 @@
/datum/mind/proc/take_uplink()
qdel(find_syndicate_uplink())
-/datum/mind/proc/make_traitor()
- if(!(has_antag_datum(/datum/antagonist/traitor)))
- add_antag_datum(/datum/antagonist/traitor)
-
-/datum/mind/proc/make_changeling()
- var/datum/antagonist/changeling/C = has_antag_datum(/datum/antagonist/changeling)
- if(!C)
- C = add_antag_datum(/datum/antagonist/changeling)
- special_role = ROLE_CHANGELING
- return C
-
-
/datum/mind/proc/make_wizard()
if(has_antag_datum(/datum/antagonist/wizard))
return
set_assigned_role(SSjob.get_job_type(/datum/job/space_wizard))
- special_role = ROLE_WIZARD
add_antag_datum(/datum/antagonist/wizard)
-
-/datum/mind/proc/make_rev()
- var/datum/antagonist/rev/head/head = new()
- head.give_flash = TRUE
- head.give_hud = TRUE
- add_antag_datum(head)
- special_role = ROLE_REV_HEAD
-
/// Sets our can_hijack to the fastest speed our antag datums allow.
/datum/mind/proc/get_hijack_speed()
. = 0
diff --git a/code/datums/mind/initialization.dm b/code/datums/mind/initialization.dm
index a09cb040dbe..d40fa3d8759 100644
--- a/code/datums/mind/initialization.dm
+++ b/code/datums/mind/initialization.dm
@@ -36,7 +36,6 @@
/mob/living/silicon/pai/mind_initialize()
. = ..()
mind.set_assigned_role(SSjob.get_job_type(/datum/job/personal_ai))
- mind.special_role = ""
/// Signal proc for [COMSIG_ADMIN_DELETING], to ghostize a mob beforehand if an admin is manually deleting it.
/mob/proc/ghost_before_admin_delete(datum/source)
diff --git a/code/datums/proximity_monitor/fields/heretic_arena.dm b/code/datums/proximity_monitor/fields/heretic_arena.dm
index 1f9d85094df..fc89fe824d1 100644
--- a/code/datums/proximity_monitor/fields/heretic_arena.dm
+++ b/code/datums/proximity_monitor/fields/heretic_arena.dm
@@ -272,7 +272,7 @@ GLOBAL_LIST_EMPTY(heretic_arenas)
replace_banned = FALSE
objectives = list()
antag_hud_name = "brainwashed"
- block_midrounds = FALSE
+ antag_flags = ANTAG_FAKE
/datum/antagonist/heretic_arena_participant/on_gain()
forge_objectives()
diff --git a/code/datums/station_traits/_station_trait.dm b/code/datums/station_traits/_station_trait.dm
index be2f14dea39..7073b9d0bd2 100644
--- a/code/datums/station_traits/_station_trait.dm
+++ b/code/datums/station_traits/_station_trait.dm
@@ -33,10 +33,6 @@ GLOBAL_LIST_EMPTY(lobby_station_traits)
var/list/lobby_buttons = list()
/// The ID that we look for in dynamic.json. Not synced with 'name' because I can already see this go wrong
var/dynamic_threat_id
- /// If ran during dynamic, do we reduce the total threat? Will be overridden by config if set
- var/threat_reduction = 0
- /// Which ruleset flags to allow dynamic to use. NONE to disregard
- var/dynamic_category = NONE
/// Trait should not be instantiated in a round if its type matches this type
var/abstract_type = /datum/station_trait
@@ -45,10 +41,6 @@ GLOBAL_LIST_EMPTY(lobby_station_traits)
RegisterSignal(SSticker, COMSIG_TICKER_ROUND_STARTING, PROC_REF(on_round_start))
- if(threat_reduction)
- GLOB.dynamic_station_traits[src] = threat_reduction
- if(dynamic_category)
- GLOB.dynamic_ruleset_categories = dynamic_category
/* BUBBER EDIT REMOVAL - We have our own lobby buttons
if(sign_up_button)
GLOB.lobby_station_traits += src
@@ -64,7 +56,6 @@ GLOBAL_LIST_EMPTY(lobby_station_traits)
destroy_lobby_buttons()
SSstation.station_traits -= src
GLOB.lobby_station_traits -= src
- GLOB.dynamic_station_traits -= src
REMOVE_TRAIT(SSstation, trait_to_give, STATION_TRAIT)
return ..()
diff --git a/code/datums/station_traits/job_traits.dm b/code/datums/station_traits/job_traits.dm
index 05774b5345b..f42a86031dc 100644
--- a/code/datums/station_traits/job_traits.dm
+++ b/code/datums/station_traits/job_traits.dm
@@ -1,7 +1,3 @@
-#define CAN_ROLL_ALWAYS 1 //always can roll for antag
-#define CAN_ROLL_PROTECTED 2 //can roll if config lets protected roles roll
-#define CAN_ROLL_NEVER 3 //never roll antag
-
/**
* A station trait which enables a temporary job
* Generally speaking these should always all be mutually exclusive, don't have too many at once
@@ -11,8 +7,6 @@
abstract_type = /datum/station_trait/job
/// What tooltip to show on the button
var/button_desc = "Sign up to gain some kind of unusual job, not available in most rounds."
- /// Can this job roll antag?
- var/can_roll_antag = CAN_ROLL_ALWAYS
/// How many positions to spawn?
var/position_amount = 1
/// Type of job to enable
@@ -22,11 +16,6 @@
/datum/station_trait/job/New()
. = ..()
- switch(can_roll_antag)
- if(CAN_ROLL_PROTECTED)
- SSstation.antag_protected_roles += job_to_add::title
- if(CAN_ROLL_NEVER)
- SSstation.antag_restricted_roles += job_to_add::title
blacklist += subtypesof(/datum/station_trait/job) - type // All but ourselves
RegisterSignal(SSdcs, COMSIG_GLOB_PRE_JOBS_ASSIGNED, PROC_REF(pre_jobs_assigned))
/* SKYRAT EDIT REMOVAL
@@ -86,7 +75,6 @@
button_desc = "Sign up to become the Cargo Gorilla, a peaceful shepherd of boxes."
weight = 1
show_in_report = FALSE // Selective attention test. Did you spot the gorilla?
- can_roll_antag = CAN_ROLL_NEVER
job_to_add = /datum/job/cargo_gorilla
/datum/station_trait/job/cargorilla/New()
@@ -120,7 +108,6 @@
weight = 2
report_message = "We have installed a Bridge Assistant on your station."
show_in_report = TRUE
- can_roll_antag = CAN_ROLL_PROTECTED
job_to_add = /datum/job/bridge_assistant
/datum/station_trait/job/bridge_assistant/New()
@@ -174,7 +161,6 @@
weight = 2
report_message = "Veteran Security Advisor has been assigned to your station to help with Security matters."
show_in_report = TRUE
- can_roll_antag = CAN_ROLL_PROTECTED
job_to_add = /datum/job/veteran_advisor
/* SKYRAT EDIT -- REMOVAL -- We handle the lobby a bit differently for time being
@@ -190,7 +176,6 @@
trait_flags = parent_type::trait_flags | STATION_TRAIT_REQUIRES_AI
report_message = "Our recent technological advancements in machine Artificial Intelligence has proven futile. In the meantime, we're sending an Intern to help out."
show_in_report = TRUE
- can_roll_antag = CAN_ROLL_PROTECTED
job_to_add = /datum/job/human_ai
trait_to_give = STATION_TRAIT_HUMAN_AI
@@ -258,7 +243,6 @@
weight = 0 //Unrollable by default, available all day during monkey day.
report_message = "We've evaluated the bartender's monkey to have the mental capacity of the average crewmember. As such, we made them one."
show_in_report = TRUE
- can_roll_antag = CAN_ROLL_ALWAYS
job_to_add = /datum/job/pun_pun
/datum/station_trait/job/pun_pun/New()
@@ -274,7 +258,3 @@
. = ..()
overlays += LAZYFIND(lobby_candidates, lobby_button.get_mob()) ? "pun_pun_on" : "pun_pun_off"
*/
-
-#undef CAN_ROLL_ALWAYS
-#undef CAN_ROLL_PROTECTED
-#undef CAN_ROLL_NEVER
diff --git a/code/datums/station_traits/negative_traits.dm b/code/datums/station_traits/negative_traits.dm
index 848025cfe81..4432ff599fd 100644
--- a/code/datums/station_traits/negative_traits.dm
+++ b/code/datums/station_traits/negative_traits.dm
@@ -559,7 +559,6 @@
trait_to_give = STATION_TRAIT_RADIOACTIVE_NEBULA
blacklist = list(/datum/station_trait/random_event_weight_modifier/rad_storms)
- threat_reduction = 30
dynamic_threat_id = "Radioactive Nebula"
intensity_increment_time = 10 MINUTES // BUBBER EDIT: ORG - 5 MINUTES
diff --git a/code/datums/station_traits/neutral_traits.dm b/code/datums/station_traits/neutral_traits.dm
index 8d785c7e0a1..7e2375eb12e 100644
--- a/code/datums/station_traits/neutral_traits.dm
+++ b/code/datums/station_traits/neutral_traits.dm
@@ -501,16 +501,27 @@
/// Crew don't ever spawn as enemies of the station. Obsesseds, blob infection, space changelings etc can still happen though
/datum/station_trait/background_checks
name = "Station-Wide Background Checks"
- report_message = "We replaced the intern doing your crew's background checks with a trained screener for this shift! That said, our enemies may just find another way to infiltrate the station, so be careful."
+ report_message = "We replaced the intern doing your crew's background checks with a trained screener for this shift! \
+ That said, our enemies may just find another way to infiltrate the station, so be careful."
trait_type = STATION_TRAIT_NEUTRAL
weight = 1
show_in_report = TRUE
can_revert = FALSE
- dynamic_category = RULESET_CATEGORY_NO_WITTING_CREW_ANTAGONISTS
- threat_reduction = 15
dynamic_threat_id = "Background Checks"
+/datum/station_trait/background_checks/New()
+ . = ..()
+ RegisterSignal(SSdynamic, COMSIG_DYNAMIC_PRE_ROUNDSTART, PROC_REF(modify_config))
+
+/datum/station_trait/background_checks/proc/modify_config(datum/source, list/dynamic_config)
+ SIGNAL_HANDLER
+
+ for(var/datum/dynamic_ruleset/ruleset as anything in subtypesof(/datum/dynamic_ruleset))
+ if(ruleset.ruleset_flags & RULESET_INVADER)
+ continue
+ dynamic_config[initial(ruleset.config_tag)] ||= list()
+ dynamic_config[initial(ruleset.config_tag)][NAMEOF(ruleset, weight)] = 0
/* BUBBER EDIT REMOVAL BEGIN - Lobby buttons
/datum/station_trait/pet_day
name = "Bring Your Pet To Work Day"
diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm
index bc8bed1340a..e8d3db7694b 100644
--- a/code/game/gamemodes/objective.dm
+++ b/code/game/gamemodes/objective.dm
@@ -241,7 +241,7 @@ GLOBAL_LIST_EMPTY(objectives) //SKYRAT EDIT ADDITION
/datum/objective/assassinate/update_explanation_text()
..()
if(target?.current)
- explanation_text = "Assassinate [target.name], the [!target_role_type ? target.assigned_role.title : target.special_role] ONCE." //SKYRAT EDIT CHANGE
+ explanation_text = "Assassinate [target.name], the [!target_role_type ? target.assigned_role.title : english_list(target.get_special_roles())] ONCE." // BUBBER EDIT ADDITION - Add ONCE
else
explanation_text = "Free objective."
@@ -291,7 +291,7 @@ GLOBAL_LIST_EMPTY(objectives) //SKYRAT EDIT ADDITION
/datum/objective/mutiny/update_explanation_text()
..()
if(target?.current)
- explanation_text = "Assassinate or exile [target.name], the [!target_role_type ? target.assigned_role.title : target.special_role]."
+ explanation_text = "Assassinate or exile [target.name], the [!target_role_type ? target.assigned_role.title : english_list(target.get_special_roles())]."
else
explanation_text = "Free objective."
@@ -313,7 +313,7 @@ GLOBAL_LIST_EMPTY(objectives) //SKYRAT EDIT ADDITION
/datum/objective/maroon/update_explanation_text()
if(target?.current)
- explanation_text = "Prevent [target.name], the [!target_role_type ? target.assigned_role.title : target.special_role], from escaping alive."
+ explanation_text = "Prevent [target.name], the [!target_role_type ? target.assigned_role.title : english_list(target.get_special_roles())], from escaping alive."
else
explanation_text = "Free objective."
@@ -344,7 +344,7 @@ GLOBAL_LIST_EMPTY(objectives) //SKYRAT EDIT ADDITION
/datum/objective/debrain/update_explanation_text()
..()
if(target?.current)
- explanation_text = "Steal the brain of [target.name], the [!target_role_type ? target.assigned_role.title : target.special_role]."
+ explanation_text = "Steal the brain of [target.name], the [!target_role_type ? target.assigned_role.title : english_list(target.get_special_roles())]."
else
explanation_text = "Free objective."
@@ -370,7 +370,7 @@ GLOBAL_LIST_EMPTY(objectives) //SKYRAT EDIT ADDITION
/datum/objective/protect/update_explanation_text()
..()
if(target?.current)
- explanation_text = "Protect [target.name], the [!target_role_type ? target.assigned_role.title : target.special_role]."
+ explanation_text = "Protect [target.name], the [!target_role_type ? target.assigned_role.title : english_list(target.get_special_roles())]."
else
explanation_text = "Free objective."
@@ -395,7 +395,7 @@ GLOBAL_LIST_EMPTY(objectives) //SKYRAT EDIT ADDITION
/datum/objective/jailbreak/update_explanation_text()
..()
if(target?.current)
- explanation_text = "Ensure that [target.name], the [!target_role_type ? target.assigned_role.title : target.special_role] escapes alive and out of custody."
+ explanation_text = "Ensure that [target.name], the [!target_role_type ? target.assigned_role.title : english_list(target.get_special_roles())] escapes alive and out of custody."
else
explanation_text = "Free objective."
@@ -411,7 +411,7 @@ GLOBAL_LIST_EMPTY(objectives) //SKYRAT EDIT ADDITION
/datum/objective/jailbreak/detain/update_explanation_text()
..()
if(target?.current)
- explanation_text = "Ensure that [target.name], the [!target_role_type ? target.assigned_role.title : target.special_role] is delivered to Nanotrasen alive and in custody."
+ explanation_text = "Ensure that [target.name], the [!target_role_type ? target.assigned_role.title : english_list(target.get_special_roles())] is delivered to Nanotrasen alive and in custody."
else
explanation_text = "Free objective."
diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm
index 7e74246ab3c..de0c1c54d26 100755
--- a/code/game/machinery/computer/communications.dm
+++ b/code/game/machinery/computer/communications.dm
@@ -856,7 +856,6 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
#define HACK_PIRATE "Pirates"
#define HACK_FUGITIVES "Fugitives"
#define HACK_SLEEPER "Sleeper Agents"
-#define HACK_THREAT "Threat Boost"
/// The minimum number of ghosts / observers to have the chance of spawning pirates.
#define MIN_GHOSTS_FOR_PIRATES 4
@@ -900,7 +899,7 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
*/
/obj/machinery/computer/communications/proc/hack_console(mob/living/hacker)
// All hack results we'll choose from.
- var/list/hack_options = list(HACK_THREAT)
+ var/list/hack_options = list(HACK_SLEEPER)
// If we have a certain amount of ghosts, we'll add some more !!fun!! options to the list
var/num_ghosts = length(GLOB.current_observers_list) + length(GLOB.dead_player_list)
@@ -915,11 +914,6 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
if(num_ghosts >= MIN_GHOSTS_FOR_FUGITIVES)
hack_options += HACK_FUGITIVES
- if (!EMERGENCY_PAST_POINT_OF_NO_RETURN)
- // If less than a certain percent of the population is ghosts, consider sleeper agents
- if(num_ghosts < (length(GLOB.clients) * MAX_PERCENT_GHOSTS_FOR_SLEEPER))
- hack_options += HACK_SLEEPER
-
var/picked_option = pick(hack_options)
message_admins("[ADMIN_LOOKUPFLW(hacker)] hacked a [name] located at [ADMIN_VERBOSEJMP(src)], resulting in: [picked_option]!")
hacker.log_message("hacked a communications console, resulting in: [picked_option].", LOG_GAME, log_globally = TRUE)
@@ -927,59 +921,29 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
if(HACK_PIRATE) // Triggers pirates, which the crew may be able to pay off to prevent
var/list/pirate_rulesets = list(
/datum/dynamic_ruleset/midround/pirates,
- /datum/dynamic_ruleset/midround/dangerous_pirates,
+ /datum/dynamic_ruleset/midround/pirates/heavy,
)
- priority_announce(
- "Attention crew: sector monitoring reports a massive jump-trace from an enemy vessel destined for your system. Prepare for imminent hostile contact.",
- "[command_name()] High-Priority Update",
- )
- SSdynamic.picking_specific_rule(pick(pirate_rulesets), forced = TRUE, ignore_cost = TRUE)
+ SSdynamic.force_run_midround(pick(pirate_rulesets))
if(HACK_FUGITIVES) // Triggers fugitives, which can cause confusion / chaos as the crew decides which side help
priority_announce(
"Attention crew: sector monitoring reports a jump-trace from an unidentified vessel destined for your system. Prepare for probable contact.",
"[command_name()] High-Priority Update",
)
-
- force_event_after(/datum/round_event_control/fugitives, "[hacker] hacking a communications console", rand(20 SECONDS, 1 MINUTES))
-
- if(HACK_THREAT) // Force an unfavorable situation on the crew
- priority_announce(
- "Attention crew, the Nanotrasen Department of Intelligence has received intel suggesting increased enemy activity in your sector beyond that initially reported in today's threat advisory.",
- "[command_name()] High-Priority Update",
- )
-
- for(var/mob/crew_member as anything in GLOB.player_list)
- if(!is_station_level(crew_member.z))
- continue
- shake_camera(crew_member, 15, 1)
-
- SSdynamic.unfavorable_situation()
+ SSdynamic.force_run_midround(/datum/dynamic_ruleset/midround/from_ghosts/fugitives)
if(HACK_SLEEPER) // Trigger one or multiple sleeper agents with the crew (or for latejoining crew)
- var/datum/dynamic_ruleset/midround/sleeper_agent_type = /datum/dynamic_ruleset/midround/from_living/autotraitor
- var/max_number_of_sleepers = clamp(round(length(GLOB.alive_player_list) / 20), 1, 3)
- var/num_agents_created = 0
- for(var/num_agents in 1 to rand(1, max_number_of_sleepers))
- if(!SSdynamic.picking_specific_rule(sleeper_agent_type, forced = TRUE, ignore_cost = TRUE))
- break
- num_agents_created++
-
- if(num_agents_created <= 0)
- // We failed to run any midround sleeper agents, so let's be patient and run latejoin traitor
- SSdynamic.picking_specific_rule(/datum/dynamic_ruleset/latejoin/infiltrator, forced = TRUE, ignore_cost = TRUE)
-
- else
- // We spawned some sleeper agents, nice - give them a report to kickstart the paranoia
- priority_announce(
- "Attention crew, it appears that someone on your station has hijacked your telecommunications and broadcasted an unknown signal.",
- "[command_name()] High-Priority Update",
- )
+ priority_announce(
+ "Attention crew, it appears that someone on your station has hijacked your telecommunications and broadcasted an unknown signal.",
+ "[command_name()] High-Priority Update",
+ )
+ var/max_number_of_sleepers = clamp(round(length(GLOB.alive_player_list) / 40), 1, 3)
+ if(!SSdynamic.force_run_midround(/datum/dynamic_ruleset/midround/from_living/traitor, forced_max_cap = max_number_of_sleepers))
+ SSdynamic.queue_ruleset(/datum/dynamic_ruleset/latejoin/traitor)
#undef HACK_PIRATE
#undef HACK_FUGITIVES
#undef HACK_SLEEPER
-#undef HACK_THREAT
#undef MIN_GHOSTS_FOR_PIRATES
#undef MIN_GHOSTS_FOR_FUGITIVES
diff --git a/code/game/machinery/wishgranter.dm b/code/game/machinery/wishgranter.dm
index 7d03fc8efae..6bfbb57d411 100644
--- a/code/game/machinery/wishgranter.dm
+++ b/code/game/machinery/wishgranter.dm
@@ -22,7 +22,7 @@
to_chat(user, span_boldnotice("You feel a dark stirring inside of the Wish Granter, something you want nothing of. Your instincts are better than any man's."))
return
- else if(is_special_character(user))
+ else if(user.is_antag())
to_chat(user, span_boldnotice("Even to a heart as dark as yours, you know nothing good will come of this. Something instinctual makes you pull away."))
else if (!insisting)
diff --git a/code/game/objects/effects/anomalies/anomalies_pyroclastic.dm b/code/game/objects/effects/anomalies/anomalies_pyroclastic.dm
index 9a33e16f5db..e59116f9688 100644
--- a/code/game/objects/effects/anomalies/anomalies_pyroclastic.dm
+++ b/code/game/objects/effects/anomalies/anomalies_pyroclastic.dm
@@ -54,7 +54,6 @@
if(isnull(chosen_one))
return
pyro.PossessByPlayer(chosen_one.key)
- pyro.mind.special_role = ROLE_PYROCLASTIC_SLIME
pyro.mind.add_antag_datum(/datum/antagonist/pyro_slime)
pyro.log_message("was made into a slime by pyroclastic anomaly", LOG_GAME)
chosen_one = null
diff --git a/code/game/objects/effects/poster_motivational.dm b/code/game/objects/effects/poster_motivational.dm
index 377fa271211..adee497096d 100644
--- a/code/game/objects/effects/poster_motivational.dm
+++ b/code/game/objects/effects/poster_motivational.dm
@@ -18,7 +18,7 @@
/// You can use any spraypaint can on a quirk poster to turn it into a contraband poster from the traitor objective
/obj/item/poster/quirk/attackby(obj/item/postertool, mob/user, list/modifiers, list/attack_modifiers)
- if(!is_special_character(user) || !HAS_TRAIT(user, TRAIT_POSTERBOY) || !istype(postertool, /obj/item/toy/crayon))
+ if(!user.is_antag() || !HAS_TRAIT(user, TRAIT_POSTERBOY) || !istype(postertool, /obj/item/toy/crayon))
return ..()
balloon_alert(user, "converting poster...")
if(!do_after(user, 5 SECONDS, user))
@@ -32,7 +32,7 @@
/// Screentip for the above
/obj/item/poster/quirk/add_context(atom/source, list/context, obj/item/held_item, mob/user)
- if(!is_special_character(user) || !HAS_TRAIT(user, TRAIT_POSTERBOY) || !istype(held_item, /obj/item/toy/crayon))
+ if(!user.is_antag() || !HAS_TRAIT(user, TRAIT_POSTERBOY) || !istype(held_item, /obj/item/toy/crayon))
return NONE
context[SCREENTIP_CONTEXT_LMB] = "Turn into Demoralizing Poster"
return CONTEXTUAL_SCREENTIP_SET
diff --git a/code/game/objects/items/devices/aicard_evil.dm b/code/game/objects/items/devices/aicard_evil.dm
index f4c89c31444..d59df54073a 100644
--- a/code/game/objects/items/devices/aicard_evil.dm
+++ b/code/game/objects/items/devices/aicard_evil.dm
@@ -57,7 +57,7 @@
var/datum/antagonist/nukeop/nuke_datum = new()
nuke_datum.send_to_spawnpoint = FALSE
new_ai.mind.add_antag_datum(nuke_datum, op_datum.nuke_team)
- new_ai.mind.special_role = "Syndicate AI"
+ LAZYADD(new_ai.mind.special_roles, "Syndicate AI")
new_ai.faction |= ROLE_SYNDICATE
// Make it look evil!!!
new_ai.hologram_appearance = mutable_appearance('icons/mob/silicon/ai.dmi',"xeno_queen") //good enough
diff --git a/code/game/objects/items/religion.dm b/code/game/objects/items/religion.dm
index 95746907440..bba45718362 100644
--- a/code/game/objects/items/religion.dm
+++ b/code/game/objects/items/religion.dm
@@ -49,7 +49,7 @@
if(H.mind && (has_job_loyalties || has_role_loyalties))
if(has_job_loyalties && (H.mind.assigned_role.departments_bitflags & job_loyalties))
inspired += H
- else if(has_role_loyalties && (H.mind.special_role in role_loyalties))
+ else if(has_role_loyalties && length(H.mind.get_special_roles() & role_loyalties))
inspired += H
else if(check_inspiration(H))
inspired += H
diff --git a/code/game/objects/items/robot/robot_parts.dm b/code/game/objects/items/robot/robot_parts.dm
index 631775bcb04..5dee6df4308 100644
--- a/code/game/objects/items/robot/robot_parts.dm
+++ b/code/game/objects/items/robot/robot_parts.dm
@@ -321,7 +321,7 @@
brainmob.mind.transfer_to(O)
playsound(O.loc, 'sound/mobs/non-humanoids/cyborg/liveagain.ogg', 75, TRUE)
- if(O.mind && O.mind.special_role)
+ if(O.is_antag())
to_chat(O, span_userdanger("You have been robotized!"))
to_chat(O, span_danger("You must obey your silicon laws and master AI above all else. Your objectives will consider you to be dead."))
diff --git a/code/game/objects/items/storage/uplink_kits.dm b/code/game/objects/items/storage/uplink_kits.dm
index 86f73dcf609..dde40b22393 100644
--- a/code/game/objects/items/storage/uplink_kits.dm
+++ b/code/game/objects/items/storage/uplink_kits.dm
@@ -788,13 +788,7 @@
human_target.reagents.add_reagent(/datum/reagent/toxin, 2)
return FALSE
- /// If all the antag datums are 'fake' or none exist, disallow induction! No self-antagging.
- var/faker
- for(var/datum/antagonist/antag_datum as anything in human_target.mind.antag_datums)
- if((antag_datum.antag_flags & FLAG_FAKE_ANTAG))
- faker = TRUE
-
- if(faker || isnull(human_target.mind.antag_datums)) // GTFO. Technically not foolproof but making a heartbreaker or a paradox clone a nuke op sounds hilarious
+ if(!human_target.is_antag()) // GTFO. Technically not foolproof but making a heartbreaker or a paradox clone a nuke op sounds hilarious
to_chat(human_target, span_notice("Huh? Nothing happened? But you're starting to feel a little ill..."))
human_target.reagents.add_reagent(/datum/reagent/toxin, 15)
return FALSE
diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm
index 99950d227dc..77d3b4d8a06 100644
--- a/code/modules/admin/admin.dm
+++ b/code/modules/admin/admin.dm
@@ -20,22 +20,9 @@
return
var/dat
- if(SSticker.current_state <= GAME_STATE_PREGAME)
- // BUBBER EDIT START - STORYTELLER
- //dat += "(Manage Dynamic Rulesets) "
- //dat += "(Force Roundstart Rulesets) "
- dat += "(Game Mode Panel) "
- // BUBBER EDIT END
- if (GLOB.dynamic_forced_roundstart_ruleset.len > 0)
- for(var/datum/dynamic_ruleset/roundstart/rule in GLOB.dynamic_forced_roundstart_ruleset)
- dat += {"-> [rule.name] <- "}
- dat += "(Clear Rulesets) "
- dat += "(Dynamic mode options) "
- dat += ""
- if(SSticker.IsRoundInProgress())
- dat += "(Game Mode Panel) "
- //dat += "(Manage Dynamic Rulesets) " // BUBBER EDIT - STORYTELLER
- dat += ""
+
+ dat += "Dynamic Panel "
+ dat += ""
dat += {"
Create Object Quick Create Object
@@ -108,134 +95,6 @@ ADMIN_VERB(spawn_cargo, R_SPAWN, "Spawn Cargo", "Spawn a cargo crate.", ADMIN_CA
log_admin("[key_name(user)] spawned cargo pack [chosen] at [AREACOORD(user.mob)]")
BLACKBOX_LOG_ADMIN_VERB("Spawn Cargo")
-/datum/admins/proc/dynamic_mode_options(mob/user)
- var/dat = {"
Common options
- All these options can be changed midround.
-
- Force extended: - Option is [GLOB.dynamic_forced_extended ? "ON" : "OFF"].
- This will force the round to be extended. No rulesets will be drafted.
-
- No stacking: - Option is [GLOB.dynamic_no_stacking ? "ON" : "OFF"].
- Unless the threat goes above [GLOB.dynamic_stacking_limit], only one "round-ender" ruleset will be drafted.
-
- Forced threat level: Current value : [GLOB.dynamic_forced_threat_level].
- The value threat is set to if it is higher than -1.
-
-
- Stacking threeshold: Current value : [GLOB.dynamic_stacking_limit].
- The threshold at which "round-ender" rulesets will stack. A value higher than 100 ensure this never happens.
- "}
-
- var/datum/browser/browser = new(user, "dyn_mode_options", "Dynamic Mode Options", 900, 650)
- browser.set_content(dat)
- browser.open()
-
-/datum/admins/proc/dynamic_ruleset_manager(mob/user)
- var/datum/browser/browser = new(user, "dyn_mode_options", "Dynamic Ruleset Management", 900, 650)
- var/dat = {"
- Change these options to forcibly enable or disable dynamic rulesets.
- Disabled rulesets will never run, even if they would otherwise be valid.
- Enabled rulesets will run even if the qualifying minimum of threat or player count is not present, this does not guarantee that they will necessarily be chosen (for example their weight may be set to 0 in config).
- force enable all
- force disable all
- reset all
- "}
-
- if (SSticker.current_state <= GAME_STATE_PREGAME) // Don't bother displaying after the round has started
- var/static/list/rulesets_by_context = list()
- if (!length(rulesets_by_context))
- for (var/datum/dynamic_ruleset/rule as anything in subtypesof(/datum/dynamic_ruleset))
- if (initial(rule.name) == "")
- continue
- LAZYADD(rulesets_by_context[initial(rule.ruletype)], rule)
-
- dat += dynamic_ruleset_category_pre_start_display("Roundstart", rulesets_by_context[ROUNDSTART_RULESET])
- dat += dynamic_ruleset_category_pre_start_display("Latejoin", rulesets_by_context[LATEJOIN_RULESET])
- dat += dynamic_ruleset_category_pre_start_display("Midround", rulesets_by_context[MIDROUND_RULESET])
- browser.set_content(dat)
- browser.open()
- return
-
- var/pop_count = length(GLOB.alive_player_list)
- var/threat_level = SSdynamic.threat_level
- dat += dynamic_ruleset_category_during_round_display("Latejoin", SSdynamic.latejoin_rules, pop_count, threat_level)
- dat += dynamic_ruleset_category_during_round_display("Midround", SSdynamic.midround_rules, pop_count, threat_level)
- browser.set_content(dat)
- browser.open()
-
-/datum/admins/proc/dynamic_ruleset_category_pre_start_display(title, list/rules)
- var/dat = "
[title]
"
- for (var/datum/dynamic_ruleset/rule as anything in rules)
- var/forced = GLOB.dynamic_forced_rulesets[rule] || RULESET_NOT_FORCED
- var/color = COLOR_SILVER
- switch (forced)
- if (RULESET_FORCE_ENABLED)
- color = COLOR_GREEN
- if (RULESET_FORCE_DISABLED)
- color = COLOR_RED
- dat += "