Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible sentry message lag fixes #43

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading