mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-05 03:10:57 +01:00
06f19cdecb
* WIP - Clown Car, Bugged key insert, buckle, driver can't drive * WIP - Needs Movement, Testing * Compiles * Sealed port * Car * Clown Car Cannon * Formats for comments * Linters * Linters again * Linters * Attack chains * Dump mobs on supermatter dust, instead of dusting everything * Supermatter bump change for clown car * Headlights fix * Fixes runechat for car, fixes opening trunk do-after, removed excess code * Another do-after fix * Fixed squishing prone people, fixed buckle bug * Better trait handling, fixes some silicon issues * Fixes emergency lube foam * Fixes AI getting nullspaced on eject * Fixes hands remaining bound when ejected after using cannon mode, fixes cannon mode, adds var-editable thing * Updated clown car actions * Update code/modules/vehicle/tg_vehicles/cars/clowncar.dm Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> --------- Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
93 lines
3.7 KiB
Plaintext
93 lines
3.7 KiB
Plaintext
|
|
//// 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.
|
|
*/
|
|
|
|
|
|
//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)
|
|
|
|
//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))
|
|
|
|
#define TIMER_COOLDOWN_CHECK(cd_source, cd_index) LAZYACCESS(cd_source.cooldowns, cd_index)
|
|
|
|
#define TIMER_COOLDOWN_END(cd_source, cd_index) LAZYREMOVE(cd_source.cooldowns, cd_index)
|
|
|
|
|
|
/// 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))
|
|
|
|
|
|
/*
|
|
* Stoppable timer cooldowns.
|
|
* Use indexes the same as the regular tiemr cooldowns.
|
|
* They make use of the TIMER_COOLDOWN_CHECK() 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_CHECK(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.
|
|
*/
|
|
|
|
#define COOLDOWN_DECLARE(cd_index) var/##cd_index = 0
|
|
|
|
#define STATIC_COOLDOWN_DECLARE(cd_index) var/static/##cd_index = 0
|
|
|
|
#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_RESET(cd_source, cd_index) cd_source.cd_index = 0
|
|
|
|
#define COOLDOWN_TIMELEFT(cd_source, cd_index) (max(0, cd_source.cd_index - world.time))
|
|
|
|
///adds to existing cooldown timer if its started, otherwise starts anew
|
|
#define COOLDOWN_INCREMENT(cd_source, cd_index, cd_increment) \
|
|
if(COOLDOWN_FINISHED(cd_source, cd_index)) { \
|
|
COOLDOWN_START(cd_source, cd_index, cd_increment); \
|
|
return; \
|
|
} \
|
|
cd_source.cd_index += (cd_increment);
|