From d0cfc1cf1eb3e69be4ed0d3e8fcf91deee09f732 Mon Sep 17 00:00:00 2001 From: Morrow Date: Fri, 3 Nov 2023 12:06:23 -0400 Subject: [PATCH] possible sentry message lag --- code/modules/defenses/sentry.dm | 14 ++++++++++++-- code/modules/projectiles/projectile.dm | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/code/modules/defenses/sentry.dm b/code/modules/defenses/sentry.dm index 24bff3d869..8beec534fb 100644 --- a/code/modules/defenses/sentry.dm +++ b/code/modules/defenses/sentry.dm @@ -62,6 +62,12 @@ can_be_near_defense = TRUE + /// Delay sending no ammo messages + COOLDOWN_DECLARE(no_ammo_message_cooldown) + + /// Delay for the beep before firing after not firing for a while + COOLDOWN_DECLARE(beep_fire_sound_cooldown) + /obj/structure/machinery/defenses/sentry/Initialize() . = ..() spark_system = new /datum/effect_system/spark_spread @@ -317,14 +323,18 @@ if(!(world.time-last_fired >= fire_delay) || !turned_on || !ammo || QDELETED(target)) return - if(world.time-last_fired >= 30 SECONDS) //if we haven't fired for a while, beep first + if(COOLDOWN_FINISHED(src, beep_fire_sound_cooldown)) //if we haven't fired for a while, beep first playsound(loc, 'sound/machines/twobeep.ogg', 50, 1) if(ammo && ammo.current_rounds <= 0) - to_chat(usr, SPAN_WARNING("[name] does not have any ammo.")) + if(COOLDOWN_FINISHED(src, no_ammo_message_cooldown)) + visible_message(SPAN_WARNING("[src] beeps steadily and its ammo light blinks red.")) + COOLDOWN_START(src, no_ammo_message_cooldown, (3 SECONDS)) + return last_fired = world.time + COOLDOWN_START(src, beep_fire_sound_cooldown, (30 SECONDS)) if(QDELETED(owner_mob)) owner_mob = src diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 71e0a75aed..531afd2f4a 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -520,8 +520,10 @@ else if(!L.lying) animatation_displace_reset(L) if(ammo.sound_miss) playsound_client(L.client, ammo.sound_miss, get_turf(L), 75, TRUE) - L.visible_message(SPAN_AVOIDHARM("[src] misses [L]!"), - SPAN_AVOIDHARM("[src] narrowly misses you!"), null, 4, CHAT_TYPE_TAKING_HIT) + if(COOLDOWN_FINISHED(L, shot_cooldown)) + L.visible_message(SPAN_AVOIDHARM("[src] misses [L]!"), + SPAN_AVOIDHARM("[src] narrowly misses you!"), null, 4, CHAT_TYPE_TAKING_HIT) + COOLDOWN_START(L, shot_cooldown, 1 SECONDS) var/log_message = "[src] narrowly missed [key_name(L)]" var/mob/living/carbon/shotby = firer