Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Aurorastation/Aurora.3 in…
Browse files Browse the repository at this point in the history
…to pochetoscreens
pochetoo committed Jan 14, 2025
2 parents 89365d4 + 6f74952 commit 535dd0e
Showing 45 changed files with 578 additions and 124 deletions.
4 changes: 4 additions & 0 deletions aurorastation.dme
Original file line number Diff line number Diff line change
@@ -153,6 +153,7 @@
#include "code\__DEFINES\traits.dm"
#include "code\__DEFINES\turfs.dm"
#include "code\__DEFINES\typeids.dm"
#include "code\__DEFINES\verb_manager.dm"
#include "code\__DEFINES\verbs.dm"
#include "code\__DEFINES\vv.dm"
#include "code\__DEFINES\webhook.dm"
@@ -375,6 +376,7 @@
#include "code\controllers\subsystems\sound_loops.dm"
#include "code\controllers\subsystems\sounds.dm"
#include "code\controllers\subsystems\spatial_gridmap.dm"
#include "code\controllers\subsystems\speech_controller.dm"
#include "code\controllers\subsystems\statistics.dm"
#include "code\controllers\subsystems\statpanel.dm"
#include "code\controllers\subsystems\stickyban.dm"
@@ -384,6 +386,7 @@
#include "code\controllers\subsystems\ticker.dm"
#include "code\controllers\subsystems\timer.dm"
#include "code\controllers\subsystems\trade.dm"
#include "code\controllers\subsystems\verb_manager.dm"
#include "code\controllers\subsystems\virtual_reality.dm"
#include "code\controllers\subsystems\vis_contents.dm"
#include "code\controllers\subsystems\vote.dm"
@@ -453,6 +456,7 @@
#include "code\datums\statistic.dm"
#include "code\datums\tgs_event_handler.dm"
#include "code\datums\tgui_module.dm"
#include "code\datums\verb_callbacks.dm"
#include "code\datums\weakrefs.dm"
#include "code\datums\changelog\changelog.dm"
#include "code\datums\components\_component.dm"
3 changes: 3 additions & 0 deletions code/__DEFINES/callbacks.dm
Original file line number Diff line number Diff line change
@@ -19,3 +19,6 @@
call(0 || proc_owner, proc_path)(##proc_arguments); \
}; \
}

/// like CALLBACK but specifically for verb callbacks
#define VERB_CALLBACK new /datum/callback/verb_callback
103 changes: 102 additions & 1 deletion code/__DEFINES/cooldowns.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,102 @@
//// COOLDOWN SYSTEMS
/*
* We have 2 cooldown systems: timer cooldowns (divided between stoppable and regular) and world.time cooldowns.
*
* When to use each?
*
* * Adding a commonly-checked cooldown, like on a subsystem to check for processing
* * * Use the world.time ones, as they are cheaper.
*
* * Adding a rarely-used one for special situations, such as giving an uncommon item a cooldown on a target.
* * * Timer cooldown, as adding a new variable on each mob to track the cooldown of said uncommon item is going too far.
*
* * Triggering events at the end of a cooldown.
* * * Timer cooldown, registering to its signal.
*
* * Being able to check how long left for the cooldown to end.
* * * Either world.time or stoppable timer cooldowns, depending on the other factors. Regular timer cooldowns do not support this.
*
* * Being able to stop the timer before it ends.
* * * Either world.time or stoppable timer cooldowns, depending on the other factors. Regular timer cooldowns do not support this.
*/


/*
* Cooldown system based on an datum-level associative lazylist using timers.
*/

//INDEXES
#define COOLDOWN_BORG_SELF_REPAIR "borg_self_repair"
#define COOLDOWN_EXPRESSPOD_CONSOLE "expresspod_console"

//Mecha cooldowns
#define COOLDOWN_MECHA_MESSAGE "mecha_message"
#define COOLDOWN_MECHA_EQUIPMENT(type) ("mecha_equip_[type]")
#define COOLDOWN_MECHA_MELEE_ATTACK "mecha_melee"
#define COOLDOWN_MECHA_SMOKE "mecha_smoke"
#define COOLDOWN_MECHA_SKYFALL "mecha_skyfall"
#define COOLDOWN_MECHA_MISSILE_STRIKE "mecha_missile_strike"
#define COOLDOWN_MECHA_CABIN_SEAL "mecha_cabin_seal"

//car cooldowns
#define COOLDOWN_CAR_HONK "car_honk"

//clown car cooldowns
#define COOLDOWN_CLOWNCAR_RANDOMNESS "clown_car_randomness"

// item cooldowns
#define COOLDOWN_SIGNALLER_SEND "cooldown_signaller_send"
#define COOLDOWN_TOOL_SOUND "cooldown_tool_sound"

//circuit cooldowns
#define COOLDOWN_CIRCUIT_SOUNDEMITTER "circuit_soundemitter"
#define COOLDOWN_CIRCUIT_SPEECH "circuit_speech"
#define COOLDOWN_CIRCUIT_PATHFIND_SAME "circuit_pathfind_same"
#define COOLDOWN_CIRCUIT_PATHFIND_DIF "circuit_pathfind_different"
#define COOLDOWN_CIRCUIT_TARGET_INTERCEPT "circuit_target_intercept"
#define COOLDOWN_CIRCUIT_VIEW_SENSOR "circuit_view_sensor"

// mob cooldowns
#define COOLDOWN_YAWN_PROPAGATION "yawn_propagation_cooldown"

// admin verb cooldowns
#define COOLDOWN_INTERNET_SOUND "internet_sound"

//Shared cooldowns for actions
#define MOB_SHARED_COOLDOWN_1 (1<<0)
#define MOB_SHARED_COOLDOWN_2 (1<<1)
#define MOB_SHARED_COOLDOWN_3 (1<<2)
#define MOB_SHARED_COOLDOWN_BOT_ANNOUNCMENT (1<<3)

//TIMER COOLDOWN MACROS

#define COMSIG_CD_STOP(cd_index) "cooldown_[cd_index]"
#define COMSIG_CD_RESET(cd_index) "cd_reset_[cd_index]"

#define TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(end_cooldown), cd_source, cd_index), cd_time))

/// Checks if a timer based cooldown is NOT finished.
#define TIMER_COOLDOWN_RUNNING(cd_source, cd_index) LAZYACCESS(cd_source.cooldowns, cd_index)

/// Checks if a timer based cooldown is finished.
#define TIMER_COOLDOWN_FINISHED(cd_source, cd_index) (!TIMER_COOLDOWN_RUNNING(cd_source, cd_index))

#define TIMER_COOLDOWN_END(cd_source, cd_index) LAZYREMOVE(cd_source.cooldowns, cd_index)

/*
* Stoppable timer cooldowns.
* Use indexes the same as the regular tiemr cooldowns.
* They make use of the TIMER_COOLDOWN_RUNNING() and TIMER_COOLDOWN_END() macros the same, just not the TIMER_COOLDOWN_START() one.
* A bit more expensive than the regular timers, but can be reset before they end and the time left can be checked.
*/

#define S_TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(end_cooldown), cd_source, cd_index), cd_time, TIMER_STOPPABLE))

#define S_TIMER_COOLDOWN_RESET(cd_source, cd_index) reset_cooldown(cd_source, cd_index)

#define S_TIMER_COOLDOWN_TIMELEFT(cd_source, cd_index) (timeleft(TIMER_COOLDOWN_RUNNING(cd_source, cd_index)))


/*
* Cooldown system based on storing world.time on a variable, plus the cooldown time.
* Better performance over timer cooldowns, lower control. Same functionality.
@@ -10,8 +109,10 @@
#define COOLDOWN_START(cd_source, cd_index, cd_time) (cd_source.cd_index = world.time + (cd_time))

//Returns true if the cooldown has run its course, false otherwise
#define COOLDOWN_FINISHED(cd_source, cd_index) (cd_source.cd_index < world.time)
#define COOLDOWN_FINISHED(cd_source, cd_index) (cd_source.cd_index <= world.time)

#define COOLDOWN_RESET(cd_source, cd_index) cd_source.cd_index = 0

#define COOLDOWN_STARTED(cd_source, cd_index) (cd_source.cd_index != 0)

#define COOLDOWN_TIMELEFT(cd_source, cd_index) (max(0, cd_source.cd_index - world.time))
2 changes: 2 additions & 0 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
@@ -268,6 +268,8 @@
#define FIRE_PRIORITY_RUNECHAT 410
#define FIRE_PRIORITY_TIMER 700
#define FIRE_PRIORITY_SOUND_LOOPS 800
#define FIRE_PRIORITY_SPEECH_CONTROLLER 900
#define FIRE_PRIORITY_DELAYED_VERBS 950

/**
Create a new timer and add it to the queue.
36 changes: 36 additions & 0 deletions code/__DEFINES/verb_manager.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* verb queuing thresholds. remember that since verbs execute after SendMaps the player wont see the effects of the verbs on the game world
* until SendMaps executes next tick, and then when that later update reaches them. thus most player input has a minimum latency of world.tick_lag + player ping.
* however thats only for the visual effect of player input, when a verb processes the actual latency of game state changes or semantic latency is effectively 1/2 player ping,
* unless that verb is queued for the next tick in which case its some number probably smaller than world.tick_lag.
* so some verbs that represent player input are important enough that we only introduce semantic latency if we absolutely need to.
* its for this reason why player clicks are handled in SSinput before even movement - semantic latency could cause someone to move out of range
* when the verb finally processes but it was in range if the verb had processed immediately and overtimed.
*/

///queuing tick_usage threshold for verbs that are high enough priority that they only queue if the server is overtiming.
///ONLY use for critical verbs
#define VERB_OVERTIME_QUEUE_THRESHOLD 100
///queuing tick_usage threshold for verbs that need lower latency more than most verbs.
#define VERB_HIGH_PRIORITY_QUEUE_THRESHOLD 95
///default queuing tick_usage threshold for most verbs which can allow a small amount of latency to be processed in the next tick
#define VERB_DEFAULT_QUEUE_THRESHOLD 85

///attempt to queue this verb process if the server is overloaded. evaluates to FALSE if queuing isnt necessary or if it failed.
///_verification_args... are only necessary if the verb_manager subsystem youre using checks them in can_queue_verb()
///if you put anything in _verification_args that ISNT explicitely put in the can_queue_verb() override of the subsystem youre using,
///it will runtime.
#define TRY_QUEUE_VERB(_verb_callback, _tick_check, _subsystem_to_use, _verification_args...) (_queue_verb(_verb_callback, _tick_check, _subsystem_to_use, _verification_args))
///queue wrapper for TRY_QUEUE_VERB() when you want to call the proc if the server isnt overloaded enough to queue
#define QUEUE_OR_CALL_VERB(_verb_callback, _tick_check, _subsystem_to_use, _verification_args...) \
if(!TRY_QUEUE_VERB(_verb_callback, _tick_check, _subsystem_to_use, _verification_args)) {\
_verb_callback:InvokeAsync() \
};

//goes straight to SSverb_manager with default tick threshold
#define DEFAULT_TRY_QUEUE_VERB(_verb_callback, _verification_args...) (TRY_QUEUE_VERB(_verb_callback, VERB_DEFAULT_QUEUE_THRESHOLD, null, _verification_args))
#define DEFAULT_QUEUE_OR_CALL_VERB(_verb_callback, _verification_args...) QUEUE_OR_CALL_VERB(_verb_callback, VERB_DEFAULT_QUEUE_THRESHOLD, null, _verification_args)

//default tick threshold but nondefault subsystem
#define TRY_QUEUE_VERB_FOR(_verb_callback, _subsystem_to_use, _verification_args...) (TRY_QUEUE_VERB(_verb_callback, VERB_DEFAULT_QUEUE_THRESHOLD, _subsystem_to_use, _verification_args))
#define QUEUE_OR_CALL_VERB_FOR(_verb_callback, _subsystem_to_use, _verification_args...) QUEUE_OR_CALL_VERB(_verb_callback, VERB_DEFAULT_QUEUE_THRESHOLD, _subsystem_to_use, _verification_args)
26 changes: 16 additions & 10 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
@@ -264,27 +264,33 @@ Proc for attack log creation, because really why not

//update our pda and id if we have them on our person
var/list/searching = GetAllContents()
var/search_id = 1
var/search_pda = 1
var/search_id = TRUE
var/search_pda = TRUE

for(var/A in searching)
if( search_id && istype(A,/obj/item/card/id) )
if(search_id && istype(A, /obj/item/card/id) )
var/obj/item/card/id/ID = A
if(ID.registered_name == oldname)
ID.registered_name = newname
ID.name = "[newname]'s ID Card ([ID.assignment])"
if(!search_pda) break
search_id = 0
search_id = FALSE

else if(search_pda && istype(A,/obj/item/modular_computer))
if(!search_pda)
break

else if(search_pda && istype(A, /obj/item/modular_computer))
var/obj/item/modular_computer/PDA = A
if(!PDA.registered_id)
continue
if(PDA.registered_id.name == oldname)

if(PDA.registered_id.registered_name == oldname)
PDA.name = "PDA-[newname] ([PDA.registered_id.assignment])"
if(!search_id) break
search_pda = 0
return 1
search_pda = FALSE

if(!search_id)
break

return TRUE

// Generalised helper proc for letting mobs rename themselves
/mob/proc/rename_self(var/role, var/allow_numbers=0)
5 changes: 5 additions & 0 deletions code/controllers/subsystems/speech_controller.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// verb_manager subsystem just for handling say's
VERB_MANAGER_SUBSYSTEM_DEF(speech_controller)
name = "Speech Controller"
wait = 1
priority = FIRE_PRIORITY_SPEECH_CONTROLLER//has to be high priority, second in priority ONLY to SSinput
Loading

0 comments on commit 535dd0e

Please sign in to comment.