Files
Bubberstation/code/modules/admin/force_event.dm
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

101 lines
3.0 KiB
Plaintext

///Allows an admin to force an event
/client/proc/forceEvent()
set name = "Trigger Event"
set category = "Admin.Events"
if(!holder || !check_rights(R_FUN))
return
holder.forceEvent()
///Opens up the Force Event Panel
/datum/admins/proc/forceEvent()
if(!check_rights(R_FUN))
return
var/datum/force_event/ui = new(usr)
ui.ui_interact(usr)
/// Force Event Panel
/datum/force_event
/datum/force_event/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ForceEvent")
ui.open()
/datum/force_event/ui_state(mob/user)
return GLOB.fun_state
/datum/force_event/ui_static_data(mob/user)
var/static/list/category_to_icons
if(!category_to_icons)
category_to_icons = list(
EVENT_CATEGORY_AI = "robot",
EVENT_CATEGORY_ANOMALIES = "cloud-bolt",
EVENT_CATEGORY_BUREAUCRATIC = "print",
EVENT_CATEGORY_ENGINEERING = "wrench",
EVENT_CATEGORY_ENTITIES = "ghost",
EVENT_CATEGORY_FRIENDLY = "face-smile",
EVENT_CATEGORY_HEALTH = "brain",
EVENT_CATEGORY_HOLIDAY = "calendar",
EVENT_CATEGORY_INVASION = "user-group",
EVENT_CATEGORY_JANITORIAL = "bath",
EVENT_CATEGORY_SPACE = "meteor",
EVENT_CATEGORY_WIZARD = "hat-wizard",
)
var/list/data = list()
var/list/categories_seen = list()
var/list/categories = list()
var/list/events = list()
for(var/datum/round_event_control/event_control as anything in SSevents.control)
//add category
if(!categories_seen[event_control.category])
categories_seen[event_control.category] = TRUE
UNTYPED_LIST_ADD(categories, list(
"name" = event_control.category,
"icon" = category_to_icons[event_control.category],
))
//add event, with one value matching up the category
UNTYPED_LIST_ADD(events, list(
"name" = event_control.name,
"description" = event_control.description,
"type" = event_control.type,
"category" = event_control.category,
"has_customization" = !!length(event_control.admin_setup),
))
data["categories"] = categories
data["events"] = events
return data
/datum/force_event/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return
if(!check_rights(R_FUN))
return
switch(action)
if("forceevent")
var/announce_event = params["announce"]
var/string_path = params["type"]
if(!string_path)
return
var/event_to_run_type = text2path(string_path)
if(!event_to_run_type)
return
var/datum/round_event_control/event = locate(event_to_run_type) in SSevents.control
if(!event)
return
if(length(event.admin_setup))
for(var/datum/event_admin_setup/admin_setup_datum in event.admin_setup)
if(admin_setup_datum.prompt_admins() == ADMIN_CANCEL_EVENT)
return
var/always_announce_chance = 100
var/no_announce_chance = 0
event.run_event(announce_chance_override = announce_event ? always_announce_chance : no_announce_chance, admin_forced = TRUE)
message_admins("[key_name_admin(usr)] has triggered an event. ([event.name])")
log_admin("[key_name(usr)] has triggered an event. ([event.name])")