Files
Bubberstation/code/modules/events/scrubber_overflow.dm
T
Rhials 40873e0a98 Non-random events now provide a cause in their deadchat broadcast (#74904)
## About The Pull Request

Most calls of runEvent() now provide a cause that is read out to
deadchat. announce_deadchat() has been slightly adjusted to accommodate
this.

Previously, everything that wasn't a truly random event would broadcast
with the same generic "XYZ has just been triggered!" message. Now, you
get a little bit more detail as to why/what triggered the event.

Some helpers in the __HELPERS/events.dm file have been made, for forcing
events normally/async/after a delay (using an addtimer). This also moves
a lot (but not all) instances of events being forced to these helpers.

Some samples:


![image](https://user-images.githubusercontent.com/28870487/233735108-aea2996b-aff4-45e2-ae0c-3e07f86de9b7.png)
Traitors using uplink viruses to turn off the power/comms.


![image](https://user-images.githubusercontent.com/28870487/233734371-18a31dff-198e-4a4a-a43f-15be6cbb545e.png)
Beer nuke!


![image](https://user-images.githubusercontent.com/28870487/233731635-7c93c1ef-641d-40df-975e-a916af4d1129.png)
For when a traitor takes an Space Dragon final objective, which summons
a carp migration event.


![image](https://user-images.githubusercontent.com/28870487/233727323-e2cfc46f-909f-4754-a0f9-a2763360a376.png)
Wizard ritual events!


![image](https://user-images.githubusercontent.com/28870487/233733025-5c8284bc-02e1-41c8-aae4-76a5c2124d97.png)
Even this one!

This also changes runEvent() to run_event(), because I figured I'd be
touching every single instance of the proc anyways.

## Why It's Good For The Game

Better feedback, less confusion amongst deadchat's constituents. 

Some of them may be a bit self-explanatory, but in some cases
(especially the apocalypse rune) it's beneficial to know that an admin
isn't the one behind it.

<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

🆑 Rhials
qol: Deadchat now gets more juicy details on what has triggered a
non-randomly occurring random event.
code: There are now helpers for forcing events in a variety of ways.
More events! More events!!!!!!!
/🆑
2023-04-24 18:45:41 -06:00

179 lines
6.5 KiB
Plaintext

/datum/round_event_control/scrubber_overflow
name = "Scrubber Overflow: Normal"
typepath = /datum/round_event/scrubber_overflow
weight = 10
max_occurrences = 3
min_players = 10
category = EVENT_CATEGORY_JANITORIAL
description = "The scrubbers release a tide of mostly harmless froth."
admin_setup = list(/datum/event_admin_setup/listed_options/scrubber_overflow)
/datum/round_event/scrubber_overflow
announce_when = 1
start_when = 5
/// The probability that the ejected reagents will be dangerous
var/danger_chance = 1
/// Amount of reagents ejected from each scrubber
var/reagents_amount = 50
/// Probability of an individual scrubber overflowing
var/overflow_probability = 50
/// Specific reagent to force all scrubbers to use, null for random reagent choice
var/datum/reagent/forced_reagent_type
/// A list of scrubbers that will have reagents ejected from them
var/list/scrubbers = list()
/// The list of chems that scrubbers can produce
var/list/safer_chems = list(/datum/reagent/water,
/datum/reagent/carbon,
/datum/reagent/consumable/flour,
/datum/reagent/space_cleaner,
/datum/reagent/carpet/royal/blue,
/datum/reagent/carpet/orange,
/datum/reagent/consumable/nutriment,
/datum/reagent/consumable/condensedcapsaicin,
/datum/reagent/drug/mushroomhallucinogen,
/datum/reagent/lube,
/datum/reagent/glitter/blue,
/datum/reagent/glitter/pink,
/datum/reagent/cryptobiolin,
/datum/reagent/blood,
/datum/reagent/medicine/c2/multiver,
/datum/reagent/water/holywater,
/datum/reagent/consumable/ethanol,
/datum/reagent/consumable/hot_coco,
/datum/reagent/consumable/yoghurt,
/datum/reagent/consumable/tinlux,
/datum/reagent/hydrogen_peroxide,
/datum/reagent/bluespace,
/datum/reagent/pax,
/datum/reagent/consumable/laughter,
/datum/reagent/concentrated_barbers_aid,
/datum/reagent/baldium,
/datum/reagent/colorful_reagent,
/datum/reagent/consumable/salt,
/datum/reagent/consumable/ethanol/beer,
/datum/reagent/hair_dye,
/datum/reagent/consumable/sugar,
/datum/reagent/glitter/white,
/datum/reagent/gravitum,
/datum/reagent/growthserum,
/datum/reagent/yuck,
)
//needs to be chemid unit checked at some point
/datum/round_event/scrubber_overflow/announce_deadchat(random, cause)
if(!forced_reagent_type)
//nothing out of the ordinary, so default announcement
return ..()
deadchat_broadcast(" has just been[random ? " randomly" : ""] triggered[cause ? " by [cause]" : ""]!", "<b>Scrubber Overflow: [initial(forced_reagent_type.name)]</b>", message_type=DEADCHAT_ANNOUNCEMENT)
/datum/round_event/scrubber_overflow/announce(fake)
priority_announce("The scrubbers network is experiencing a backpressure surge. Some ejection of contents may occur.", "Atmospherics alert")
/datum/round_event/scrubber_overflow/setup()
for(var/obj/machinery/atmospherics/components/unary/vent_scrubber/temp_vent in GLOB.machines)
var/turf/scrubber_turf = get_turf(temp_vent)
if(!scrubber_turf)
continue
if(!is_station_level(scrubber_turf.z))
continue
if(temp_vent.welded)
continue
if(!prob(overflow_probability))
continue
scrubbers += temp_vent
if(!scrubbers.len)
return kill()
/datum/round_event_control/scrubber_overflow/can_spawn_event(players_amt, allow_magic = FALSE)
. = ..()
if(!.)
return
for(var/obj/machinery/atmospherics/components/unary/vent_scrubber/temp_vent in GLOB.machines)
var/turf/scrubber_turf = get_turf(temp_vent)
if(!scrubber_turf)
continue
if(!is_station_level(scrubber_turf.z))
continue
if(temp_vent.welded)
continue
return TRUE //there's at least one. we'll let the codergods handle the rest with prob() i guess.
return FALSE
/// proc that will run the prob check of the event and return a safe or dangerous reagent based off of that.
/datum/round_event/scrubber_overflow/proc/get_overflowing_reagent(dangerous)
return dangerous ? get_random_reagent_id() : pick(safer_chems)
/datum/round_event/scrubber_overflow/start()
for(var/obj/machinery/atmospherics/components/unary/vent_scrubber/vent as anything in scrubbers)
if(!vent.loc)
CRASH("SCRUBBER SURGE: [vent] has no loc somehow?")
var/datum/reagents/dispensed_reagent = new /datum/reagents(reagents_amount)
dispensed_reagent.my_atom = vent
if (forced_reagent_type)
dispensed_reagent.add_reagent(forced_reagent_type, reagents_amount)
else if (prob(danger_chance))
dispensed_reagent.add_reagent(get_overflowing_reagent(dangerous = TRUE), reagents_amount)
new /mob/living/basic/cockroach(get_turf(vent))
new /mob/living/basic/cockroach(get_turf(vent))
else
dispensed_reagent.add_reagent(get_overflowing_reagent(dangerous = FALSE), reagents_amount)
dispensed_reagent.create_foam(/datum/effect_system/fluid_spread/foam/short, reagents_amount)
CHECK_TICK
/datum/round_event_control/scrubber_overflow/threatening
name = "Scrubber Overflow: Threatening"
typepath = /datum/round_event/scrubber_overflow/threatening
weight = 4
min_players = 25
max_occurrences = 1
earliest_start = 35 MINUTES
description = "The scrubbers release a tide of moderately harmless froth."
min_wizard_trigger_potency = 0
max_wizard_trigger_potency = 4
/datum/round_event/scrubber_overflow/threatening
danger_chance = 10
reagents_amount = 100
/datum/round_event_control/scrubber_overflow/catastrophic
name = "Scrubber Overflow: Catastrophic"
typepath = /datum/round_event/scrubber_overflow/catastrophic
weight = 2
min_players = 35
max_occurrences = 1
earliest_start = 45 MINUTES
description = "The scrubbers release a tide of mildly harmless froth."
min_wizard_trigger_potency = 3
max_wizard_trigger_potency = 6
/datum/round_event/scrubber_overflow/catastrophic
danger_chance = 30
reagents_amount = 150
/datum/round_event_control/scrubber_overflow/every_vent
name = "Scrubber Overflow: Every Vent"
typepath = /datum/round_event/scrubber_overflow/every_vent
weight = 0
max_occurrences = 0
description = "The scrubbers release a tide of mostly harmless froth, but every scrubber is affected."
/datum/round_event/scrubber_overflow/every_vent
overflow_probability = 100
reagents_amount = 100
/datum/event_admin_setup/listed_options/scrubber_overflow
normal_run_option = "Random Reagents"
special_run_option = "Random Single Reagent"
/datum/event_admin_setup/listed_options/scrubber_overflow/get_list()
return sort_list(subtypesof(/datum/reagent), /proc/cmp_typepaths_asc)
/datum/event_admin_setup/listed_options/scrubber_overflow/apply_to_event(datum/round_event/scrubber_overflow/event)
if(chosen == special_run_option)
chosen = event.get_overflowing_reagent(dangerous = prob(event.danger_chance))
event.forced_reagent_type = chosen