Files
Yogstation/code/datums/world_topic.dm
Molti df51b30a0c Deletes all gamemodes in favor of storytellers (#22661)
* storytellers

* Update _base_event.dm

* Update _base_event.dm

* storytellers and midround events

* work

* antags

* last

* Update vote.dm

* fixes

* Update backrooms.dm

* so long gay dynamic

* Update vote.dm

* dynamic unit test

* cleanup

* delete minimum pop

* fix

* storyteller tweaks

* traitor awakening

* Update traitor.dm

* Update _basemap.dm

* Update ghost.dm

* oh god so much stuff

* Update _logging.dm

* buh bye events

* Update nuclearbomb.dm

* Update collections.ts

* Revert "Update collections.ts"

This reverts commit ff93cf170a.

* maybe

* fix

* fix

* Update game_mode.dm

* fixes

* fixes and more logging

* oh good gravy

* Update portal_storm.dm

* bring them back

* Update gamemode_subsystem.dm

* Update admin_verbs.dm

* Update force_event.dm

* damnit

* Update _base_event.dm

* fixes

* more

* it compiles :)

* more

* passes linter

* Update radiation_leak.dm

* Update dolphin_migration.dm

* Update brother.dm

* Update gamemode_subsystem.dm

* Update _base_event.dm

* Update _base_event.dm

* updates

* fixup

* add vampire remove prompt

* Update vampire.dm

* Update vampire.dm

* Update vampire.dm

* Update _base_event.dm

* Update gamemode_subsystem.dm

* Update gamemode_subsystem.dm

* Update dolphin_migration.dm

* fix migration

* title icon

* fixes

* formatting

* Update gamemode_subsystem.dm

* Update tzimisce.dm

* Update tzimisce.dm

* Update gamemode_subsystem.dm

* Update storytellers.dm

* tweak for our pop

* Update darkspawn.dm

* Update gamemode_subsystem.dm

* tweaks and fixes

* more and less roundstart

* Update ghost.dm

* lol lets just port the voting system

* Update scrubber_overflow.dm

* fix scrubber

* bye gamemode

* cleanup

* Update clown_operative.dm

* Update clown_operative.dm

* Update _base_event.dm

* probably fixed

* Update supermatter_surge.dm

* buh bye

* Update brain_trauma.dm

* more

* new pseudogamemode vote

* tweaks

* Update gamemode_subsystem.dm

* Update high_priority_bounty.dm

* Update gamemode_subsystem.dm

* Update storytellers.dm

* Update high_priority_bounty.dm

* tweaks

* Update high_priority_bounty.dm

* Update high_priority_bounty.dm

* fixes

* fixes

* tweak

* Update obsessed.dm

* so long pal

* Update battleroyale.dm

* deletions

* Update implant_dusting.dm

* bye

* uplinks fix

* Update uplink_items.dm

* Update uplink_items.dm

* delete more gamemodes

* more

* lol one ctrl f change

* hm what

* Update antagonists.dm

* Revert "Update antagonists.dm"

This reverts commit c3c2ee192e.

* Revert "hm what"

This reverts commit 43dbbcebcf.

* Revert "lol one ctrl f change"

This reverts commit 95e28f5221.

* cleanup

* more stuff

* more deletion

* this one gone too

* you and only you i shall save

* Update revolution.dm

* hold this please

* it's done

* bye admin stuff

* Update uplink.dm

* Update alert.dm

* should be fine

* fixes

* tweaks

* fixes

* fixes

* Update ticker.dm

* this is important

* Update heretic.dm

* Update clown_operative.dm

* rewrite

* fixes

* Update clockwork_cult.dm

* fixes

* Update uplink_items.dm

* reorganize

* Update objective.dm

* rewrite nightmare

* Update storytellers.dm

* tweak

* tweaks

* Update stray_cargo.dm

* Update stray_cargo.dm

* Update stray_cargo.dm

* delete unneeded tgui

* Update ticker.dm

* Update roundend.dm

* Update anomaly_grav.dm

* Update gamemode_subsystem.dm

* Update statpanel.dm

* Update statpanel.dm

* no additional delay

* clean up

* Update _base_event.dm

* Update _event.dm

* antag token and brothers

* no token picked

* Update _base_event.dm

---------

Co-authored-by: Byemoh <baiomurang@gmail.com>
2024-10-18 17:20:14 -05:00

316 lines
9.7 KiB
Plaintext

// SETUP
/proc/TopicHandlers()
. = list()
var/list/all_handlers = subtypesof(/datum/world_topic)
for(var/I in all_handlers)
var/datum/world_topic/WT = I
var/keyword = initial(WT.keyword)
if(!keyword)
stack_trace("[WT] has no keyword! Ignoring...")
continue
var/existing_path = .[keyword]
if(existing_path)
stack_trace("[existing_path] and [WT] have the same keyword! Ignoring [WT]...")
else if(keyword == "key")
stack_trace("[WT] has keyword 'key'! Ignoring...")
else
.[keyword] = WT
// DATUM
/datum/world_topic
var/keyword
var/log = TRUE
var/key_valid
var/require_comms_key = FALSE
/datum/world_topic/proc/TryRun(list/input)
key_valid = config && (CONFIG_GET(string/comms_key) == input["key"])
if(require_comms_key && !key_valid)
return "Bad Key"
input -= "key"
. = Run(input)
if(islist(.))
. = list2params(.)
/datum/world_topic/proc/Run(list/input)
CRASH("Run() not implemented for [type]!")
// TOPICS
/datum/world_topic/ping
keyword = "ping"
log = FALSE
/datum/world_topic/ping/Run(list/input)
. = 0
for (var/client/C in GLOB.clients)
++.
/datum/world_topic/playing
keyword = "playing"
log = FALSE
/datum/world_topic/playing/Run(list/input)
return GLOB.player_list.len
/datum/world_topic/pr_announce
keyword = "announce"
require_comms_key = TRUE
var/static/list/PRcounts = list() //PR id -> number of times announced this round
/datum/world_topic/pr_announce/Run(list/input)
var/list/payload = json_decode(input["payload"])
var/id = "[payload["pull_request"]["id"]]"
if(!PRcounts[id])
PRcounts[id] = 1
else
++PRcounts[id]
if(PRcounts[id] > PR_ANNOUNCEMENTS_PER_ROUND)
return
var/final_composed = span_announce("PR: [input[keyword]]")
for(var/client/C in GLOB.clients)
C.AnnouncePR(final_composed)
/datum/world_topic/ahelp_relay
keyword = "Ahelp"
require_comms_key = TRUE
/datum/world_topic/ahelp_relay/Run(list/input)
relay_msg_admins(span_adminnotice("<b><font color=red>HELP: </font> [input["source"]] [input["message_sender"]]: [input["message"]]</b>"))
/datum/world_topic/comms_console
keyword = "Comms_Console"
require_comms_key = TRUE
/datum/world_topic/comms_console/Run(list/input)
minor_announce(input["message"], "Incoming message from [input["message_sender"]]")
for(var/obj/machinery/computer/communications/CM in GLOB.machines)
CM.override_cooldown()
/datum/world_topic/news_report
keyword = "News_Report"
require_comms_key = TRUE
/datum/world_topic/news_report/Run(list/input)
minor_announce(input["message"], "Breaking Update From [input["message_sender"]]")
/datum/world_topic/ooc_relay
keyword = "ooc_relay"
require_comms_key = TRUE
/datum/world_topic/ooc_relay/Run(list/input)
var/messages = json_decode(input["message"])
var/oocmsg = messages["normal"]
var/oocmsg_toadmins = messages["admin"]
var/source = json_decode(input["message_sender"])
var/sourceadmin = source["is_admin"]
var/sourcekey = source["key"]
//SENDING THE MESSAGES OUT
for(var/c in GLOB.clients)
var/client/C = c // God bless typeless for-loops
if( (C.prefs.chat_toggles & CHAT_OOC) && (sourceadmin || !(sourcekey in C.prefs.ignoring)) )
var/sentmsg // The message we're sending to this specific person
if(C.holder) // If they're an admin-ish
sentmsg = oocmsg_toadmins // Get the admin one
else
sentmsg = oocmsg
sentmsg = "[span_prefix("RELAY: [input["source"]]")] " + sentmsg
//no pinging across servers, thats intentional
to_chat(C,sentmsg)
/datum/world_topic/server_hop
keyword = "server_hop"
require_comms_key = TRUE
/datum/world_topic/server_hop/Run(list/input)
var/expected_key = input[keyword]
for(var/mob/dead/observer/O in GLOB.player_list)
if(O.key == expected_key)
if(O.client)
new /atom/movable/screen/splash(null, O.client, TRUE)
break
/datum/world_topic/adminmsg
keyword = "adminmsg"
require_comms_key = TRUE
/datum/world_topic/adminmsg/Run(list/input)
return IrcPm(input[keyword], input["msg"], input["sender"])
/datum/world_topic/namecheck
keyword = "namecheck"
require_comms_key = TRUE
/datum/world_topic/namecheck/Run(list/input)
//Oh this is a hack, someone refactor the functionality out of the chat command PLS
var/datum/tgs_chat_command/namecheck/NC = new
var/datum/tgs_chat_user/user = new
user.friendly_name = input["sender"]
user.mention = user.friendly_name
return NC.Run(user, input["namecheck"])
/datum/world_topic/adminwho
keyword = "adminwho"
require_comms_key = TRUE
/datum/world_topic/adminwho/Run(list/input)
return ircadminwho()
/datum/world_topic/mentorwho
keyword = "mentorwho"
require_comms_key = TRUE
/datum/world_topic/mentorwho/Run(list/input)
var/list/message = list("Mentors: ")
for(var/client/mentor in GLOB.mentors)
if(LAZYLEN(message) > 1)
message += ", [mentor.key]"
else
message += "[mentor.key]"
return jointext(message, "")
// Plays a voice announcement, given the ID of a voice annoucnement datum and a filename of a file in the shared folder, among other things
/datum/world_topic/voice_announce
keyword = "voice_announce"
require_comms_key = TRUE
/datum/world_topic/voice_announce/Run(list/input)
var/datum/voice_announce/A = GLOB.voice_announce_list[input["voice_announce"]]
if(istype(A))
A.handle_announce(input["ogg_file"], input["uploaded_file"], input["ip"], text2num(input["duration"]) SECONDS)
// Cancels a voice announcement, given the ID of voice announcement datum, used if the user closes their browser window instead of uploading
/datum/world_topic/voice_announce_cancel
keyword = "voice_announce_cancel"
require_comms_key = TRUE
/datum/world_topic/voice_announce_cancel/Run(list/input)
var/datum/voice_announce/A = GLOB.voice_announce_list[input["voice_announce_cancel"]]
if(istype(A))
qdel(A)
// Queries information about a voice announcement.
/datum/world_topic/voice_announce_query
keyword = "voice_announce_query"
require_comms_key = TRUE
/datum/world_topic/voice_announce_query/Run(list/input)
. = list()
var/datum/voice_announce/A = GLOB.voice_announce_list[input["voice_announce_query"]]
if(istype(A))
A.was_queried = TRUE
.["exists"] = TRUE
.["is_ai"] = A.is_ai
else
.["exists"] = FALSE
/datum/world_topic/status
keyword = "status"
/datum/world_topic/status/Run(list/input)
. = list()
.["version"] = GLOB.game_version
.["mode"] = GLOB.master_mode
.["respawn"] = config ? !CONFIG_GET(flag/norespawn) : FALSE
.["enter"] = GLOB.enter_allowed
.["vote"] = CONFIG_GET(flag/allow_vote_mode)
.["ai"] = CONFIG_GET(flag/allow_ai)
.["host"] = world.host ? world.host : null
.["round_id"] = GLOB.round_id
.["players"] = GLOB.clients.len
.["revision"] = GLOB.revdata?.commit
.["revision_date"] = GLOB.revdata?.date
var/list/adm = get_admin_counts()
var/list/presentmins = adm["present"]
var/list/afkmins = adm["afk"]
.["admins"] = presentmins.len + afkmins.len //equivalent to the info gotten from adminwho
.["gamestate"] = SSticker.current_state
.["map_name"] = SSmapping.config?.map_name || "Loading..."
if(key_valid)
.["active_players"] = get_active_player_count()
if(SSticker.HasRoundStarted())
.["real_mode"] = SSgamemode.name
// Key-authed callers may know the truth behind the "secret"
.["security_level"] = SSsecurity_level.get_current_level_as_text()
.["round_duration"] = SSticker ? round((world.time-SSticker.round_start_time)/10) : 0
// Amount of world's ticks in seconds, useful for calculating round duration
//Time dilation stats.
.["time_dilation_current"] = SStime_track.time_dilation_current
.["time_dilation_avg"] = SStime_track.time_dilation_avg
.["time_dilation_avg_slow"] = SStime_track.time_dilation_avg_slow
.["time_dilation_avg_fast"] = SStime_track.time_dilation_avg_fast
//pop cap stats
.["soft_popcap"] = CONFIG_GET(number/soft_popcap) || 0
.["hard_popcap"] = CONFIG_GET(number/hard_popcap) || 0
.["extreme_popcap"] = CONFIG_GET(number/extreme_popcap) || 0
.["popcap"] = max(CONFIG_GET(number/soft_popcap), CONFIG_GET(number/hard_popcap), CONFIG_GET(number/extreme_popcap)) //generalized field for this concept for use across ss13 codebases
if(SSshuttle && SSshuttle.emergency)
.["shuttle_mode"] = SSshuttle.emergency.mode
// Shuttle status, see /__DEFINES/stat.dm
.["shuttle_timer"] = SSshuttle.emergency.timeLeft()
// Shuttle timer, in seconds
/datum/world_topic/systemmsg
keyword = "systemmsg"
require_comms_key = TRUE
/datum/world_topic/systemmsg/Run(list/input)
to_chat(world, span_boldannounce(input["message"]))
//////// Discord Tickets ///////////
/datum/world_topic/ticket_administer
keyword = "ticket_administer"
require_comms_key = TRUE
/datum/world_topic/ticket_administer/Run(list/input)
var/id = text2num(input["id"])
if(!id) return "ERROR: [input["id"]] is not a number"
var/datum/admin_help/ticket = GLOB.ahelp_tickets.TicketByID(id)
if(!ticket) return "ERROR: Ticket not found"
return ticket.DiscordAdminister(input["ckey"], TRUE)
/datum/world_topic/ticket_reply
keyword = "ticket_reply"
require_comms_key = TRUE
/datum/world_topic/ticket_reply/Run(list/input)
var/id = text2num(input["id"])
if(!id) return "ERROR: [input["id"]] is not a number"
var/datum/admin_help/ticket = GLOB.ahelp_tickets.TicketByID(id)
if(!ticket) return "ERROR: Ticket not found"
return ticket.DiscordReply(input["ckey"], url_decode(input["message"]))
/datum/world_topic/ticket_resolve
keyword = "ticket_resolve"
require_comms_key = TRUE
/datum/world_topic/ticket_resolve/Run(list/input)
var/id = text2num(input["id"])
if(!id) return "ERROR: [input["id"]] is not a number"
var/datum/admin_help/ticket = GLOB.ahelp_tickets.TicketByID(id)
if(!ticket) return "ERROR: Ticket not found"
return ticket.DiscordResolve(input["ckey"])
/datum/world_topic/ticket_status
keyword = "ticket_status"
require_comms_key = TRUE
/datum/world_topic/ticket_status/Run(list/input)
webhook_send_ticket_refresh() // Sending by webhook to not break things
return "Data sent"