This commit is contained in:
SandPoot
2023-01-23 20:44:28 -03:00
parent e292452aae
commit 54641ce201
103 changed files with 730 additions and 232 deletions
+40 -17
View File
@@ -3,6 +3,8 @@
//this datum is used by the events controller to dictate how it selects events
/datum/round_event_control
var/name //The human-readable name of the event
var/category //The category of the event
var/description //The description of the event
var/typepath //The typepath of the event datum /datum/round_event
var/weight = 10 //The weight this event has in the random-selection process.
@@ -38,6 +40,7 @@
min_players = CEILING(min_players * CONFIG_GET(number/events_min_players_mul), 1)
/datum/round_event_control/wizard
category = EVENT_CATEGORY_WIZARD
wizardevent = TRUE
var/can_be_midround_wizard = TRUE
@@ -107,13 +110,22 @@
log_admin_private("[key_name(usr)] cancelled event [name].")
SSblackbox.record_feedback("tally", "event_admin_cancelled", 1, typepath)
/datum/round_event_control/proc/runEvent(random = FALSE)
/*
Runs the event
* Arguments:
* - random: shows if the event was triggered randomly, or by on purpose by an admin or an item
* - announce_chance_override: if the value is not null, overrides the announcement chance when an admin calls an event
*/
/datum/round_event_control/proc/runEvent(random = FALSE, announce_chance_override = null, admin_forced = FALSE)
var/datum/round_event/E = new typepath()
E.current_players = get_active_player_count(alive_check = 1, afk_check = 1, human_check = 1)
E.control = src
SSblackbox.record_feedback("tally", "event_ran", 1, "[E]")
occurrences++
if(announce_chance_override != null)
E.announce_chance = announce_chance_override
testing("[time2text(world.time, "hh:mm:ss")] [E.type]")
if(random)
log_game("Random Event triggering: [name] ([typepath])")
@@ -129,18 +141,29 @@
var/processing = TRUE
var/datum/round_event_control/control
var/startWhen = 0 //When in the lifetime to call start().
var/announceWhen = 0 //When in the lifetime to call announce(). Set an event's announceWhen to -1 if announcement should not be shown.
var/endWhen = 0 //When in the lifetime the event should end.
/// When in the lifetime to call start().
/// This is in seconds - so 1 = ~2 seconds in.
var/start_when = 0
/// When in the lifetime to call announce(). If you don't want it to announce use announce_chance, below.
/// This is in seconds - so 1 = ~2 seconds in.
var/announce_when = 0
/// Probability of announcing, used in prob(), 0 to 100, default 100. Called in process, and for a second time in the ion storm event.
var/announce_chance = 100
/// When in the lifetime the event should end.
/// This is in seconds - so 1 = ~2 seconds in.
var/end_when = 0
var/activeFor = 0 //How long the event has existed. You don't need to change this.
var/current_players = 0 //Amount of of alive, non-AFK human players on server at the time of event start
/// How long the event has existed. You don't need to change this.
var/activeFor = 0
/// Amount of of alive, non-AFK human players on server at the time of event start
var/current_players = 0
var/threat = 0
var/fakeable = TRUE //Can be faked by fake news event.
/// Can be faked by fake news event.
var/fakeable = TRUE
//Called first before processing.
//Allows you to setup your event, such as randomly
//setting the startWhen and or announceWhen variables.
//setting the start_when and or announce_when variables.
//Only called once.
//EDIT: if there's anything you want to override within the new() call, it will not be overridden by the time this proc is called.
//It will only have been overridden by the time we get to announce() start() tick() or end() (anything but setup basically).
@@ -148,7 +171,7 @@
/datum/round_event/proc/setup()
return
//Called when the tick is equal to the startWhen variable.
//Called when the tick is equal to the start_when variable.
//Allows you to start before announcing or vice versa.
//Only called once.
/datum/round_event/proc/start()
@@ -165,20 +188,20 @@
notify_ghosts("[control.name] has an object of interest: [atom_of_interest]!", source=atom_of_interest, action=NOTIFY_ORBIT, header="Something's Interesting!")
return
//Called when the tick is equal to the announceWhen variable.
//Called when the tick is equal to the announce_when variable.
//Allows you to announce before starting or vice versa.
//Only called once.
/datum/round_event/proc/announce(fake)
return
//Called on or after the tick counter is equal to startWhen.
//Called on or after the tick counter is equal to start_when.
//You can include code related to your event or add your own
//time stamped events.
//Called more than once.
/datum/round_event/proc/tick()
return
//Called on or after the tick is equal or more than endWhen
//Called on or after the tick is equal or more than end_when
//You can include code related to the event ending.
//Do not place spawn() in here, instead use tick() to check for
//the activeFor variable.
@@ -197,28 +220,28 @@
if(!processing)
return
if(activeFor == startWhen)
if(activeFor == start_when)
processing = FALSE
start()
processing = TRUE
if(activeFor == announceWhen)
if(activeFor == announce_when && prob(announce_chance))
processing = FALSE
announce(FALSE)
processing = TRUE
if(startWhen < activeFor && activeFor < endWhen)
if(start_when < activeFor && activeFor < end_when)
processing = FALSE
tick()
processing = TRUE
if(activeFor == endWhen)
if(activeFor == end_when)
processing = FALSE
end()
processing = TRUE
// Everything is done, let's clean up.
if(activeFor >= endWhen && activeFor >= announceWhen && activeFor >= startWhen)
if(activeFor >= end_when && activeFor >= announce_when && activeFor >= start_when)
processing = FALSE
kill()