mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2026-08-31 00:26:56 +01:00
Better autocryo.
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
// Should the system check for ghosts to delete too?
|
||||
/datum/config_entry/flag/ghost_checking
|
||||
|
||||
// Should the system check for silicons to delete too?
|
||||
/datum/config_entry/flag/silicon_checking
|
||||
|
||||
//Max amount of mobs cryo'd per tick
|
||||
/datum/config_entry/number/max_cryo_per_tick
|
||||
default = 1
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Define config entries for cryo
|
||||
#define SUBSYSTEM_CRYO_CAN_RUN CONFIG_GET(flag/autocryo_enabled)
|
||||
#define SUBSYSTEM_CRYO_CHECK_GHOSTS CONFIG_GET(flag/ghost_checking)
|
||||
#define SUBSYSTEM_CRYO_CHECK_SILICONS CONFIG_GET(flag/silicon_checking)
|
||||
#define SUBSYSTEM_CRYO_TIME CONFIG_GET(number/autocryo_time_trigger)
|
||||
#define SUBSYSTEM_CRYO_GHOST_PERIOD CONFIG_GET(number/ghost_check_time)
|
||||
#define MAX_CRYO_PER_TICK CONFIG_GET(number/max_cryo_per_tick)
|
||||
@@ -9,22 +10,24 @@
|
||||
SUBSYSTEM_DEF(auto_cryo)
|
||||
name = "Automated Cryogenics"
|
||||
flags = SS_BACKGROUND
|
||||
wait = 2 MINUTES
|
||||
wait = 10 MINUTES
|
||||
|
||||
/datum/controller/subsystem/auto_cryo/Initialize()
|
||||
// Check config before running
|
||||
if(!SUBSYSTEM_CRYO_CAN_RUN && !SUBSYSTEM_CRYO_CHECK_GHOSTS)
|
||||
if(!SUBSYSTEM_CRYO_CAN_RUN && !SUBSYSTEM_CRYO_CHECK_GHOSTS && !SUBSYSTEM_CRYO_CHECK_SILICONS)
|
||||
can_fire = FALSE
|
||||
|
||||
return ..()
|
||||
|
||||
/datum/controller/subsystem/auto_cryo/fire()
|
||||
if(SUBSYSTEM_CRYO_CAN_RUN)
|
||||
cryo_mobs()
|
||||
cryo_human_mobs()
|
||||
if(SUBSYSTEM_CRYO_CHECK_GHOSTS)
|
||||
cull_ghosts()
|
||||
cryo_ghosts()
|
||||
if(SUBSYSTEM_CRYO_CHECK_SILICONS)
|
||||
cryo_silicon_mobs()
|
||||
|
||||
/datum/controller/subsystem/auto_cryo/proc/cryo_mobs()
|
||||
/datum/controller/subsystem/auto_cryo/proc/cryo_human_mobs()
|
||||
// Check for any targets
|
||||
if(!LAZYLEN(GLOB.ssd_mob_list))
|
||||
// No SSD mobs exist
|
||||
@@ -34,7 +37,7 @@ SUBSYSTEM_DEF(auto_cryo)
|
||||
var/processed_mobs = 0
|
||||
|
||||
// Check possible targets
|
||||
for(var/mob/living/cryo_mob in GLOB.ssd_mob_list)
|
||||
for(var/mob/living/human/cryo_mob in GLOB.ssd_mob_list)
|
||||
// Stop if we've hit the limit for this tick
|
||||
if(processed_mobs >= MAX_CRYO_PER_TICK)
|
||||
break
|
||||
@@ -59,6 +62,41 @@ SUBSYSTEM_DEF(auto_cryo)
|
||||
// Increment the processed mobs counter
|
||||
processed_mobs++
|
||||
|
||||
/datum/controller/subsystem/auto_cryo/proc/cryo_silicon_mobs()
|
||||
// Check for any targets
|
||||
if(!LAZYLEN(GLOB.ssd_mob_list))
|
||||
// No SSD mobs exist
|
||||
return
|
||||
|
||||
// Initialize a counter for the number of mobs processed
|
||||
var/processed_silicon_mobs = 0
|
||||
|
||||
// Check possible targets
|
||||
for(var/mob/living/silicon/silicon_mob in GLOB.ssd_mob_list)
|
||||
// Stop if we've hit the limit for this tick
|
||||
if(processed_silicon_mobs >= MAX_CRYO_PER_TICK)
|
||||
break
|
||||
|
||||
// Get SSD time
|
||||
// This is set when disconnecting
|
||||
var/afk_time = world.time - silicon_mob.lastclienttime
|
||||
|
||||
// Check if client meets the time requirement
|
||||
if(afk_time < SUBSYSTEM_CRYO_TIME)
|
||||
continue
|
||||
|
||||
// Send to cryo
|
||||
cryoMob(silicon_mob, effects = TRUE)
|
||||
|
||||
// Remove from SSD list
|
||||
GLOB.ssd_mob_list -= silicon_mob
|
||||
|
||||
// Log cryo interaction
|
||||
log_game("Silicon [silicon_mob] was sent to cryo after being SSD for [afk_time] ticks.")
|
||||
|
||||
// Increment the processed mobs counter
|
||||
processed_silicon_mobs++
|
||||
|
||||
/datum/controller/subsystem/auto_cryo/proc/cull_ghosts()
|
||||
// Check for any targets
|
||||
if(!LAZYLEN(GLOB.dead_mob_list))
|
||||
@@ -78,7 +116,7 @@ SUBSYSTEM_DEF(auto_cryo)
|
||||
var/afk_time = world.time - ghost_mob.lastclienttime
|
||||
|
||||
// Check if client meets the time requirement
|
||||
if(ghost_mob.client || afk_time < SUBSYSTEM_CRYO_GHOST_PERIOD)
|
||||
if(afk_time < SUBSYSTEM_CRYO_GHOST_PERIOD)
|
||||
continue
|
||||
|
||||
// Log del interaction
|
||||
@@ -93,6 +131,7 @@ SUBSYSTEM_DEF(auto_cryo)
|
||||
// Remove defines
|
||||
#undef SUBSYSTEM_CRYO_CAN_RUN
|
||||
#undef SUBSYSTEM_CRYO_CHECK_GHOSTS
|
||||
#undef SUBSYSTEM_CRYO_CHECK_SILICONS
|
||||
#undef SUBSYSTEM_CRYO_TIME
|
||||
#undef SUBSYSTEM_CRYO_GHOST_PERIOD
|
||||
#undef MAX_CRYO_PER_TICK
|
||||
|
||||
Reference in New Issue
Block a user