Skip to content

Commit

Permalink
Possible sentry message lag fixes (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Nov 4, 2023
1 parent 1f0217a commit f715314
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 12 additions & 2 deletions code/modules/defenses/sentry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f715314

Please sign in to comment.