Skip to content

Commit

Permalink
add a cooldown + low message distance to spesstv alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Jan 24, 2025
1 parent ec0090a commit b216671
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions code/modules/modular_computers/computers/item/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@
* The program calling this proc.
* The message that the program wishes to display.
*/
/obj/item/modular_computer/proc/alert_call(datum/computer_file/program/origin, alerttext, sound = 'sound/machines/twobeep_high.ogg')
/obj/item/modular_computer/proc/alert_call(datum/computer_file/program/origin, alerttext, sound = 'sound/machines/twobeep_high.ogg', vision_distance = DEFAULT_MESSAGE_RANGE)
if(QDELETED(loc) || QDELETED(origin) || !origin.alert_able || origin.alert_silenced || !alerttext) //Yeah, we're checking alert_able. No, you don't get to make alerts that the user can't silence.
return FALSE
playsound(src, sound, 50, TRUE)
loc.visible_message(span_notice("<img class='icon' src='\ref[src]'> The [src] displays a [origin.filedesc] notification: [alerttext]"), push_appearance = src)
loc.visible_message(span_notice("<img class='icon' src='\ref[src]'> \The [src] displays a [origin.filedesc] notification: [alerttext]"), vision_distance = vision_distance, push_appearance = src)

/obj/item/modular_computer/proc/ring(ringtone, list/balloon_alertees) // bring bring
if(HAS_TRAIT(SSstation, STATION_TRAIT_PDA_GLITCHED))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// Global lazylist containing
#define STREAM_ALERT_COOLDOWN (5 SECONDS)
/// Global lazylist containing who's watching what spesstv streams.
GLOBAL_LIST(spesstv_viewers)

/datum/computer_file/program/secureye/spesstv
Expand All @@ -13,6 +14,8 @@ GLOBAL_LIST(spesstv_viewers)
network = list()
/// The radio used to listen to the entertainment channel.
var/obj/item/radio/entertainment/speakers/pda/radio
/// Coolwdown for stream alerts.
COOLDOWN_DECLARE(alert_cooldown)

/datum/computer_file/program/secureye/spesstv/New()
. = ..()
Expand Down Expand Up @@ -55,8 +58,9 @@ GLOBAL_LIST(spesstv_viewers)
alert_pending = FALSE
LAZYREMOVE(GLOB.spesstv_viewers, REF(src))
if(!QDELETED(computer))
if(announcement)
computer.alert_call(src, announcement)
if(announcement && COOLDOWN_FINISHED(src, alert_cooldown))
computer.alert_call(src, announcement, vision_distance = 2)
COOLDOWN_START(src, alert_cooldown, STREAM_ALERT_COOLDOWN)
INVOKE_ASYNC(computer, TYPE_PROC_REF(/datum, update_static_data_for_all_viewers))

/obj/item/radio/entertainment/speakers/pda
Expand Down Expand Up @@ -90,3 +94,5 @@ GLOBAL_LIST(spesstv_viewers)
LAZYREMOVE(GLOB.spesstv_viewers, key)
else
LAZYSET(GLOB.spesstv_viewers, key, active_camera.c_tag)

#undef STREAM_ALERT_COOLDOWN

0 comments on commit b216671

Please sign in to comment.