From f29b48987ec61c25f93b96fbad255a230922472c Mon Sep 17 00:00:00 2001 From: Gandalf <9026500+Gandalf2k15@users.noreply.github.com> Date: Wed, 4 May 2022 10:29:00 +0100 Subject: [PATCH] Event voting system, prelude to event planner (#11270) * wooo * Update event_vote.dm * fixes * Update event_vote.dm * wrrr * allows admins to host a player vote. * weeee * Update event_vote.dm * href * Update event_vote.dm * EEE * finishing touches * Update event_vote.dm * R_SERVER > R_PERMISSIONS, ties, reschedule * Update event_vote.dm * fun > events category * redundant code removal * Update tgstation.dme * Update events.dm * publik event vote * llogging * llogging * Update configuration.dm * Update event_vote.dm * code review and votable * round two review * one little thing kills the world * Update event_vote.dm * woop * Update event_vote.dm * Better event weighting system * Even chaos system * EEE * Update event_chaos_system.dm * Update event_vote.dm * Update event_vote.dm * wweeee * fixes * low chaos event system, * Update event_vote.dm * Update event_chaos_system.dm * vote button QOL * www * stop overlapping * Update event_vote.dm * Update EventPanel.js * Update EventPanel.js * e * e * Update event_vote.dm * data * Update event_vote.dm * Update event_vote.dm * Update event_vote.dm * Update tgstation.dme * Update tgstation.dme * wew * Update skyrat_config.txt * No consecutive high chaos events * Update event_chaos_system.dm * Update sunbeam.dm * more config * no * vote log * Update event_vote.dm * wew * better handling of low chaos events * wew * Update ticker.dm --- code/__DEFINES/~skyrat_defines/events.dm | 12 + code/__DEFINES/~skyrat_defines/logging.dm | 3 + code/controllers/subsystem/events.dm | 32 ++- code/controllers/subsystem/ticker.dm | 1 + code/game/world.dm | 8 +- code/modules/admin/admin_verbs.dm | 1 + code/modules/events/_event.dm | 2 + config/skyrat/skyrat_config.txt | 26 ++ .../code/_globalvars/configuration.dm | 18 ++ .../assault_operatives/code/sunbeam.dm | 1 + .../event_vote/code/event_chaos_system.dm | 256 ++++++++++++++++++ .../modules/event_vote/code/event_vote.dm | 35 ++- .../modules/events/code/event_overrides.dm | 10 - tgstation.dme | 3 + tgui/packages/tgui/interfaces/EventPanel.js | 141 ++++++++++ 15 files changed, 523 insertions(+), 26 deletions(-) create mode 100644 code/__DEFINES/~skyrat_defines/events.dm create mode 100644 modular_skyrat/modules/event_vote/code/event_chaos_system.dm create mode 100644 tgui/packages/tgui/interfaces/EventPanel.js diff --git a/code/__DEFINES/~skyrat_defines/events.dm b/code/__DEFINES/~skyrat_defines/events.dm new file mode 100644 index 00000000000..783496574ea --- /dev/null +++ b/code/__DEFINES/~skyrat_defines/events.dm @@ -0,0 +1,12 @@ +/** + * The events system now operates off of a defined preset of votable pools. + * High, med, low + * Players can vote for whatever one they want and then the subsystem will select a random event from the pool of pre-generated events. + * The random define is for events such as anomalies so they are still run during higher level events. + */ + +#define EVENT_CHAOS_LOW 1 +#define EVENT_CHAOS_MED 2 +#define EVENT_CHAOS_HIGH 3 +#define EVENT_CHAOS_RANDOM 4 +#define EVENT_CHAOS_DISABLED 5 diff --git a/code/__DEFINES/~skyrat_defines/logging.dm b/code/__DEFINES/~skyrat_defines/logging.dm index 55c0b569120..6f4977107b6 100644 --- a/code/__DEFINES/~skyrat_defines/logging.dm +++ b/code/__DEFINES/~skyrat_defines/logging.dm @@ -9,3 +9,6 @@ // Investigate #define INVESTIGATE_CIRCUIT "circuit" + +GLOBAL_VAR(event_vote_log) +GLOBAL_PROTECT(event_vote_log) diff --git a/code/controllers/subsystem/events.dm b/code/controllers/subsystem/events.dm index 96b4267d60c..23e16b129e9 100644 --- a/code/controllers/subsystem/events.dm +++ b/code/controllers/subsystem/events.dm @@ -24,6 +24,12 @@ SUBSYSTEM_DEF(events) control += E //add it to the list of all events (controls) reschedule() getHoliday() + // SKYRAT EDIT ADDITION + if(CONFIG_GET(flag/low_chaos_event_system)) + reschedule_low_chaos() + frequency_lower = CONFIG_GET(number/event_frequency_lower) + frequency_upper = CONFIG_GET(number/event_frequency_upper) + // SKYRAT EDIT END return ..() @@ -47,13 +53,34 @@ SUBSYSTEM_DEF(events) //checks if we should select a random event yet, and reschedules if necessary /datum/controller/subsystem/events/proc/checkEvent() + // SKYRAT EDIT ADDITION + if(scheduled_low_chaos <= world.time && CONFIG_GET(flag/low_chaos_event_system)) + triger_low_chaos_event() + // SKYRAT EDIT END if(scheduled <= world.time) - spawnEvent() + //spawnEvent() //SKYRAT EDIT CHANGE + if(CONFIG_GET(flag/events_use_random)) + spawnEvent() + else + if(CONFIG_GET(flag/events_public_voting)) + start_player_vote_chaos(FALSE) + else + if(CONFIG_GET(flag/admin_event_uses_chaos)) + start_vote_admin_chaos() + else + start_vote_admin() + // SKYRAT EDIT END reschedule() //decides which world.time we should select another random event at. /datum/controller/subsystem/events/proc/reschedule() - scheduled = world.time + rand(frequency_lower, max(frequency_lower,frequency_upper)) + // SKYRAT EDIT CHANGE + var/next_event_time = rand(frequency_lower, max(frequency_lower, frequency_upper)) + if(CONFIG_GET(flag/low_chaos_event_system)) + reschedule_low_chaos(next_event_time / 2) + scheduled = world.time + next_event_time + // SKYRAT EDIT END + //selects a random event based on whether it can occur and it's 'weight'(probability) /datum/controller/subsystem/events/proc/spawnEvent(threat_override = FALSE) //SKYRAT EDIT CHANGE @@ -88,7 +115,6 @@ SUBSYSTEM_DEF(events) if(sum_of_weights <= 0) //we've hit our goal if(TriggerEvent(E)) - previously_run += E //SKYRAT EDIT ADDITION return /datum/controller/subsystem/events/proc/TriggerEvent(datum/round_event_control/E) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index f973d7172ef..ce9b2e7c26f 100644 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -192,6 +192,7 @@ SUBSYSTEM_DEF(ticker) SEND_SIGNAL(src, COMSIG_TICKER_ENTER_SETTING_UP) current_state = GAME_STATE_SETTING_UP Master.SetRunLevel(RUNLEVEL_SETUP) + SSevents.reschedule() // SKYRAT EDIT ADDITION if(start_immediately) fire() diff --git a/code/game/world.dm b/code/game/world.dm index 8eddc6c29ff..67531526616 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -160,6 +160,8 @@ GLOBAL_VAR(restart_counter) GLOB.demo_log = "[GLOB.log_directory]/demo.log" + GLOB.event_vote_log = "[GLOB.log_directory]/event_vote.log" // SKYRAT EDIT ADDITION + #ifdef UNIT_TESTS GLOB.test_log = "[GLOB.log_directory]/tests.log" start_log(GLOB.test_log) @@ -182,8 +184,10 @@ GLOBAL_VAR(restart_counter) start_log(GLOB.world_job_debug_log) start_log(GLOB.tgui_log) start_log(GLOB.world_shuttle_log) - - start_log(GLOB.character_creation_log) // SKYRAT EDIT ADDITION + // SKYRAT EDIT ADDITION + start_log(GLOB.event_vote_log) + start_log(GLOB.character_creation_log) + // SKYRAT EDIT END var/latest_changelog = file("[global.config.directory]/../html/changelogs/archive/" + time2text(world.timeofday, "YYYY-MM") + ".yml") GLOB.changelog_hash = fexists(latest_changelog) ? md5(latest_changelog) : 0 //for telling if the changelog has changed recently diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 61b6683a57b..3e2f35344cc 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -96,6 +96,7 @@ GLOBAL_PROTECT(admin_verbs_sounds) GLOBAL_LIST_INIT(admin_verbs_fun, list( /client/proc/one_click_antag, // SKYRAT EDIT ADDITION - ONE CLICK ANTAG /client/proc/spawn_mob_spawner, // SKYRAT EDIT ADDITION + /client/proc/event_panel, // SKYRAT EDIT ADDITION /client/proc/request_more_opfor, //SKYRAT EDIT ADDITION /client/proc/fix_say, // SKYRAT EDIT ADDITION /client/proc/spawn_sunbeam, // SKYRAT EDIT ADDITION diff --git a/code/modules/events/_event.dm b/code/modules/events/_event.dm index 80e70ce7daf..662d1aa2650 100644 --- a/code/modules/events/_event.dm +++ b/code/modules/events/_event.dm @@ -109,6 +109,8 @@ SSblackbox.record_feedback("tally", "event_ran", 1, "[E]") occurrences++ + SSevents.previously_run += src //SKYRAT EDIT ADDITION + testing("[time2text(world.time, "hh:mm:ss")] [E.type]") if(random) log_game("Random Event triggering: [name] ([typepath])") diff --git a/config/skyrat/skyrat_config.txt b/config/skyrat/skyrat_config.txt index 21fbb625b24..b490bff310f 100644 --- a/config/skyrat/skyrat_config.txt +++ b/config/skyrat/skyrat_config.txt @@ -102,3 +102,29 @@ SSDECAY_DISABLE_NESTS ## Lobby Camera Intro ## Put # in front to disable LOBBY_CAMERA + +## Toggles if the events system will use a vote or random choice to run events +## Comment out to disable +#EVENTS_USE_RANDOM + +## Toggles if the events system uses admin votes or public votes +## Comment out for public votes +#EVENTS_PUBLIC_VOTING + +## If we use admin votes, do we use chaos or all event vote? +ADMIN_EVENT_USES_CHAOS + +## Runs a side timer for low chaos events +LOW_CHAOS_EVENT_SYSTEM + +## Log event votes +LOG_EVENT_VOTES + +## Do we allow consecutive catastrophic events? +ALLOW_CONSECUTIVE_CATASTROPIC_EVENTS + +## What is the most amount of time the next event can run? +EVENT_FREQUENCY_UPPER 12000 + +## What is the least amount of time the next event can run? +EVENT_FREQUENCY_LOWER 9000 diff --git a/modular_skyrat/master_files/code/_globalvars/configuration.dm b/modular_skyrat/master_files/code/_globalvars/configuration.dm index f39b4cd18f3..0b21cd31e5a 100644 --- a/modular_skyrat/master_files/code/_globalvars/configuration.dm +++ b/modular_skyrat/master_files/code/_globalvars/configuration.dm @@ -17,3 +17,21 @@ GLOBAL_VAR_INIT(looc_allowed, TRUE) /datum/config_entry/flag/file_game_log protection = CONFIG_ENTRY_LOCKED + +/datum/config_entry/flag/events_use_random + +/datum/config_entry/flag/events_public_voting + +/datum/config_entry/flag/log_event_votes + +/datum/config_entry/flag/low_chaos_event_system + +/datum/config_entry/flag/allow_consecutive_catastropic_events + +/datum/config_entry/number/event_frequency_upper + default = 20 MINUTES + +/datum/config_entry/number/event_frequency_lower + default = 15 MINUTES + +/datum/config_entry/flag/admin_event_uses_chaos diff --git a/modular_skyrat/modules/assault_operatives/code/sunbeam.dm b/modular_skyrat/modules/assault_operatives/code/sunbeam.dm index 953d49d2a48..86f6e1d0a31 100644 --- a/modular_skyrat/modules/assault_operatives/code/sunbeam.dm +++ b/modular_skyrat/modules/assault_operatives/code/sunbeam.dm @@ -148,6 +148,7 @@ name = "ICARUS Weapons System Ignition" typepath = /datum/round_event/icarus_sunbeam max_occurrences = 0 + weight = 0 /datum/round_event/icarus_sunbeam announceWhen = 1 // Instant announcement diff --git a/modular_skyrat/modules/event_vote/code/event_chaos_system.dm b/modular_skyrat/modules/event_vote/code/event_chaos_system.dm new file mode 100644 index 00000000000..5efe32db9b6 --- /dev/null +++ b/modular_skyrat/modules/event_vote/code/event_chaos_system.dm @@ -0,0 +1,256 @@ +/datum/round_event_control + /// Do we override the votable component? (For events that just end the round) + var/votable = TRUE + + var/chaos_level = EVENT_CHAOS_DISABLED + +/datum/round_event_control/cme/armageddon + votable = FALSE + +/datum/round_event_control/anomaly + votable = FALSE + +/datum/round_event_control/preset + name = "ERROR" + typepath = "error" + votable = FALSE + max_occurrences = 0 + weight = 0 + chaos_level = EVENT_CHAOS_DISABLED // We are abstract + + /// What chaos levels can this preset choose from, empty is abstract. + var/selectable_chaos_level + + /// A list of possible events for us to select from. Cached the first time it's run. + var/list/possible_events = list() + +/datum/round_event_control/preset/runEvent(random) + log_game("Preset Event Triggering: [name] ([typepath])") + if(random) + deadchat_broadcast(" has just been [random ? "randomly " : ""]triggered!", "[name] preset", message_type=DEADCHAT_ANNOUNCEMENT) + if(!LAZYLEN(possible_events)) // List hasn't been populated yet, let's do it now. + for(var/datum/round_event_control/iterating_event in SSevents.control) + if(!iterating_event.votable) + continue + if(iterating_event.chaos_level == selectable_chaos_level) + possible_events += iterating_event + + SSevents.previously_run += src + + var/datum/round_event_control/event_to_run = pick(possible_events) + + event_to_run.runEvent() + + occurrences++ + +/datum/round_event_control/preset/low + name = "Disruptive Random Event" + earliest_start = 0 + max_occurrences = 100 + selectable_chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/preset/moderate + name = "Highly Disruptive Random Event" + max_occurrences = 10 + earliest_start = 10 MINUTES + selectable_chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/preset/high + name = "Catastrophic Random Event" + max_occurrences = 10 + earliest_start = 30 MINUTES + selectable_chaos_level = EVENT_CHAOS_HIGH + min_players = 70 + +/** + * EVENT CHAOS DECLARES + */ + +// LOW CHAOS EVENTS + +/datum/round_event_control/cortical_borer + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/cme/minimal + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/stray_cargo + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/stray_cargo/syndicate + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/wisdomcow + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/wormholes + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/sentience + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/shuttle_catastrophe + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/shuttle_insurance + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/shuttle_loan + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/grey_tide + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/processor_overload + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/grid_check + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/ion_storm + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/meteor_wave/major_dust + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/market_crash + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/mass_hallucination + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/mice_migration + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/electrical_storm + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/bureaucratic_error + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/camera_failure + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/carp_migration + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/communications_blackout + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/obsessed + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/disease_outbreak + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/anomaly/anomaly_grav/high + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/morph + chaos_level = EVENT_CHAOS_LOW + +// MODERATE CHAOS PRESETS + +/datum/round_event_control/cme/moderate + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/space_ninja + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/portal_storm_syndicate + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/nightmare + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/meteor_wave/meaty + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/meteor_wave/threatening + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/meteor_wave + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/immovable_rod + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/fugitives + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/sandstorm + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/brand_intelligence + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/abductor + chaos_level = EVENT_CHAOS_MED + +/datum/round_event_control/revenant + chaos_level = EVENT_CHAOS_MED + +/////////////////////// +// HIGH CHAOS EVENTS // +/////////////////////// + +/datum/round_event_control/slaughter + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/alien_infestation + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/blob + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/pirates + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/space_dragon + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/resonance_cascade + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/spacevine + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/mold + chaos_level = EVENT_CHAOS_HIGH + +/datum/round_event_control/cme/extreme + chaos_level = EVENT_CHAOS_HIGH + + +// RANDOM EVENTS +/datum/round_event_control/anomaly/anomaly_flux + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/anomaly/anomaly_bluespace + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/anomaly/anomaly_grav + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/anomaly/anomaly_pyro + chaos_level = EVENT_CHAOS_LOW + +/datum/round_event_control/anomaly/anomaly_vortex + chaos_level = EVENT_CHAOS_LOW + + +/////////////////////////// +// EVENT CHAOS OVERRIDES // +// FOR SUBTYPES // +/////////////////////////// +/datum/round_event_control/pirates/enclave + chaos_level = EVENT_CHAOS_DISABLED + +/datum/round_event_control/pirates/dutchman + chaos_level = EVENT_CHAOS_DISABLED + +/datum/round_event_control/pirates/silverscales + chaos_level = EVENT_CHAOS_DISABLED + +/datum/round_event_control/pirates/rogues + chaos_level = EVENT_CHAOS_DISABLED diff --git a/modular_skyrat/modules/event_vote/code/event_vote.dm b/modular_skyrat/modules/event_vote/code/event_vote.dm index 209b025ca2d..a97301c36de 100644 --- a/modular_skyrat/modules/event_vote/code/event_vote.dm +++ b/modular_skyrat/modules/event_vote/code/event_vote.dm @@ -7,7 +7,7 @@ #define LOW_CHAOS_TIMER_UPPER 15 MINUTES /// How long does the vote last? -#define EVENT_VOTE_TIME 2 MINUTES +#define EVENT_VOTE_TIME 1 MINUTES /// Public vote amount #define EVENT_PUBLIC_VOTE_AMOUNT 5 @@ -38,21 +38,27 @@ var/low_chaos_timer_lower = LOW_CHAOS_TIMER_LOWER /// Ditto, but max var/low_chaos_timer_upper = LOW_CHAOS_TIMER_UPPER + /// What was the last chaos level run? + var/last_event_chaos_level + /// Have we run the low chaos event system, meaning we need reset? + var/low_chaos_needs_reset = FALSE /// Reschedules our low-chaos event timer /datum/controller/subsystem/events/proc/reschedule_low_chaos(time) if(time) scheduled_low_chaos = world.time + time else - scheduled_low_chaos = world.time + rand(low_chaos_timer_lower, low_chaos_timer_upper) + scheduled_low_chaos = world.time + rand(LOW_CHAOS_TIMER_LOWER, LOW_CHAOS_TIMER_UPPER) + low_chaos_needs_reset = FALSE /// Triggers a random low chaos event /datum/controller/subsystem/events/proc/triger_low_chaos_event() - if(vote_in_progress) // No two events at once. + if(vote_in_progress || low_chaos_needs_reset) // No two events at once. return for(var/datum/round_event_control/preset/preset_event in control) if(preset_event.selectable_chaos_level == EVENT_CHAOS_LOW) preset_event.runEvent(TRUE) + low_chaos_needs_reset = TRUE return /// Starts a vote. @@ -236,6 +242,9 @@ var/list/log_data = list("EVENT VOTE LOG ([world.time])") for(var/datum/round_event_control/control in event_weighted_list) log_data += "Event vote: [control.name] | VOTES: [event_weighted_list[control]]" + if(admin_only) + for(var/admin as anything in votes[control]) + log_data += " - - [admin]" total_votes += event_weighted_list[control] log_data += "TOTAL VOTES: [total_votes]" @@ -258,6 +267,8 @@ if(show_votes && !admin_only) for(var/mob/iterating_user in get_eligible_players()) vote_message(iterating_user, "Vote ended! Winning Event: [winner.name]") + + last_event_chaos_level = winner.chaos_level winner.runEvent(TRUE) reset() @@ -325,6 +336,8 @@ return FALSE if(ispath(typepath, /datum/round_event/ghost_role) && !(GLOB.ghost_role_flags & GHOSTROLE_MIDROUND_EVENT)) return FALSE + if(!CONFIG_GET(flag/allow_consecutive_catastropic_events) && chaos_level == EVENT_CHAOS_HIGH && SSevents.last_event_chaos_level == EVENT_CHAOS_HIGH) + return FALSE var/datum/game_mode/dynamic/dynamic = SSticker.mode if (istype(dynamic) && dynamic_should_hijack && dynamic.random_event_hijacked != HIJACKED_NOTHING) @@ -414,27 +427,27 @@ register_vote(usr, selected_event) return if("end_vote") - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return end_vote(usr) return if("cancel_vote") - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return cancel_vote(usr) return if("start_vote_admin") - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return start_vote_admin() return if("start_vote_admin_chaos") - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return start_vote_admin_chaos() return if("start_player_vote") - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return var/alert_vote = tgui_alert(usr, "Do you want to show the vote outcome?", "Vote outcome", list("Yes", "No")) if(!alert_vote) @@ -445,7 +458,7 @@ start_player_vote(public_vote) return if("start_player_vote_chaos") - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return var/alert_vote = tgui_alert(usr, "Do you want to show the vote outcome?", "Vote outcome", list("Yes", "No")) if(!alert_vote) @@ -456,7 +469,7 @@ start_player_vote_chaos(public_vote) return if("reschedule") - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return var/alert = tgui_alert(usr, "Set custom time?", "Custom time", list("Yes", "No")) if(!alert) @@ -474,7 +487,7 @@ var/time if(alert == "Yes") time = tgui_input_number(usr, "Input custom time in seconds", "Custom time", 60, 6000, 1) * 10 - if(!check_rights(R_ADMIN)) + if(!check_rights(R_PERMISSIONS)) return reschedule_low_chaos(time) message_admins("[key_name_admin(usr)] has rescheduled the LOW CHAOS event system.") diff --git a/modular_skyrat/modules/events/code/event_overrides.dm b/modular_skyrat/modules/events/code/event_overrides.dm index ff87cc71306..b9453fa12fb 100644 --- a/modular_skyrat/modules/events/code/event_overrides.dm +++ b/modular_skyrat/modules/events/code/event_overrides.dm @@ -5,16 +5,6 @@ */ -/** - * Event subsystem - * - * Overriden min and max start times: - * To accomodate for much longer rounds. - */ -/datum/controller/subsystem/events - frequency_lower = 10 MINUTES - frequency_upper = 15 MINUTES - /** * Brain truama * diff --git a/tgstation.dme b/tgstation.dme index 97dc6f4ecb2..8df8b764e64 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -280,6 +280,7 @@ #include "code\__DEFINES\~skyrat_defines\combat.dm" #include "code\__DEFINES\~skyrat_defines\culture.dm" #include "code\__DEFINES\~skyrat_defines\DNA.dm" +#include "code\__DEFINES\~skyrat_defines\events.dm" #include "code\__DEFINES\~skyrat_defines\examine_defines.dm" #include "code\__DEFINES\~skyrat_defines\faction.dm" #include "code\__DEFINES\~skyrat_defines\factions.dm" @@ -5138,6 +5139,8 @@ #include "modular_skyrat\modules\energy_axe\code\energy_fireaxe_case.dm" #include "modular_skyrat\modules\ERT_Factions\FTU\code\items.dm" #include "modular_skyrat\modules\ERT_Factions\FTU\code\projectiles.dm" +#include "modular_skyrat\modules\event_vote\code\event_chaos_system.dm" +#include "modular_skyrat\modules\event_vote\code\event_vote.dm" #include "modular_skyrat\modules\events\code\_event_globalvars.dm" #include "modular_skyrat\modules\events\code\event_overrides.dm" #include "modular_skyrat\modules\events\code\event_spawner.dm" diff --git a/tgui/packages/tgui/interfaces/EventPanel.js b/tgui/packages/tgui/interfaces/EventPanel.js new file mode 100644 index 00000000000..777caa4ecb0 --- /dev/null +++ b/tgui/packages/tgui/interfaces/EventPanel.js @@ -0,0 +1,141 @@ +import { useBackend } from '../backend'; +import { Section, Button, NoticeBox, LabeledList, Stack } from '../components'; +import { toFixed } from 'common/math'; +import { Window } from '../layouts'; + +export const EventPanel = (props, context) => { + const { act, data } = useBackend(context); + const { + event_list = [], + end_time, + vote_in_progress, + previous_events, + admin_mode, + show_votes, + next_vote_time, + next_low_chaos_time, + } = data; + return ( + + + + {!!admin_mode && ( + +
+ + {"Next vote in " + toFixed(next_vote_time, 0) + " seconds."} + + + {"Low chaos event in " + toFixed(next_low_chaos_time, 0) + " seconds."} + +
+
+ )} + +
+ {vote_in_progress ? ( + + {event_list.map(event => ( + act('register_vote', { + event_ref: event.ref, + })} /> + )} > + {!!show_votes || !!admin_mode && ( + event.votes + )} + + ))} + + ) : ( + + No vote in progress. + + )} +
+
+ {!!admin_mode && ( + +
+ {previous_events.length > 0 ? ( + + {previous_events.map(event => ( + + {event} + + ))} + + ) : ( + + No previous events. + + )} +
+
+ )} +
+
+
+ ); +};