Add distress beacon

This commit is contained in:
Aronai Sieyes
2021-06-09 16:59:50 -04:00
parent 650de1bdd8
commit 10a08e84fc
7 changed files with 117 additions and 0 deletions
+36
View File
@@ -25,6 +25,7 @@
var/hide_from_reports = FALSE
var/has_distress_beacon
var/list/levels_for_distress
/obj/effect/overmap/visitable/Initialize()
. = ..()
@@ -164,6 +165,40 @@
// prior to being moved to the overmap. This blocks that. Use set_invisibility to adjust invisibility as needed instead.
/obj/effect/overmap/visitable/sector/hide()
/obj/effect/overmap/visitable/proc/distress(mob/user)
if(has_distress_beacon)
return FALSE
has_distress_beacon = TRUE
admin_chat_message(message = "Overmap panic button hit on z[z] ([scanner_name || name]) by '[user.ckey]'", color = "#FF2222") //VOREStation Add
var/message = "A distress signal has been received from a beacon conforming to MIL-DTL-93352. The signal has been relayed via the local telecomms array. \
The beacon was launched from '[scanner_name || name]'. It provided this information: [get_distress_info()]. \
Per the Interplanetary Convention on Space SAR, which your organization is party to, those receiving this message must attempt rescue, \
or relay the message to those who can. This message will repeat once in 5 minutes. Thank you for your cooperation."
if(!levels_for_distress)
levels_for_distress = list(1)
for(var/zlevel in levels_for_distress)
priority_announcement.Announce(message, new_title = "Distress Beacon Detected", new_sound = 'sound/misc/interference.ogg', zlevel = zlevel)
var/image/I = image(icon, icon_state = "distress")
I.plane = PLANE_LIGHTING_ABOVE
I.appearance_flags = KEEP_APART|RESET_TRANSFORM|RESET_COLOR
add_overlay(I)
addtimer(CALLBACK(src, .proc/distress_update), 5 MINUTES)
return TRUE
/obj/effect/overmap/visitable/proc/get_distress_info()
return "\[X:[x],Y:[y]\]"
/obj/effect/overmap/visitable/proc/distress_update()
var/message = "This is the final message from the distress beacon launched from '[scanner_name || name]'. The beacon sent this update: [get_distress_info()].\
Please render assistance under your obligations per the Interplanetary Convention on Space SAR, or relay this message to a party who can. Thank you for your cooperation."
for(var/zlevel in levels_for_distress)
priority_announcement.Announce(message, new_title = "Distress Beacon Update", new_sound = 'sound/misc/interference.ogg', zlevel = zlevel)
/proc/build_overmap()
if(!global.using_map.use_overmap)
return 1
@@ -186,3 +221,4 @@
testing("Overmap build complete.")
return 1
+74
View File
@@ -0,0 +1,74 @@
/obj/structure/panic_button
name = "distress beacon trigger"
desc = "WARNING: Will deploy ship's distress beacon and request help. Misuse may result in fines and jail time."
description_info = "Using this device (smashing the glas on harm intent, and then pressing the button) will send a message to people on other z-levels requesting their aid. It may take them a while to come get you, as they'll need to prepare. You should only use this if you really need it."
icon = 'icons/obj/objects_vr.dmi'
icon_state = "panicbutton"
anchored = TRUE
var/glass = TRUE
var/launched = FALSE
// In case we're annihilated by a meteor
/obj/structure/panic_button/Destroy()
if(!launched)
launch()
return ..()
/obj/structure/panic_button/update_icon()
if(launched)
icon_state = "[initial(icon_state)]_launched"
else if(!glass)
icon_state = "[initial(icon_state)]_open"
else
icon_state = "[initial(icon_state)]"
/obj/structure/panic_button/attack_hand(mob/living/user)
if(!istype(user))
return ..()
if(user.incapacitated())
return
// Already launched
if(launched)
to_chat(user, "<span class='warning'>The button is already depressed; the beacon has been launched already.</span>")
// Glass present
else if(glass)
if(user.a_intent == I_HURT)
user.custom_emote(VISIBLE_MESSAGE, "smashes the glass on [src]!")
glass = FALSE
playsound(src, 'sound/effects/hit_on_shattered_glass.ogg')
update_icon()
else
user.custom_emote(VISIBLE_MESSAGE, "pats [src] in a friendly manner.")
to_chat(user, "<span class='warning'>If you're trying to break the glass, you'll have to hit it harder than that...</span>")
// Must be !glass and !launched
else
user.custom_emote(VISIBLE_MESSAGE, "pushes the button on [src]!")
launch(user)
playsound(src, get_sfx("button"))
update_icon()
/obj/structure/panic_button/proc/launch(mob/living/user)
if(launched)
return
launched = TRUE
var/obj/effect/overmap/visitable/S = get_overmap_sector(z)
if(!S)
error("Distress button hit on z[z] but that's not an overmap sector...")
return
S.distress(user)
//Kind of pricey, but this is a one-time thing that can't be reused, so I'm not too worried.
var/list/hear_z = GetConnectedZlevels(z) // multiz 'physical' connections only, not crazy overmap connections
var/mapsize = (world.maxx+world.maxy)*0.5
var/turf/us = get_turf(src)
for(var/hz in hear_z)
for(var/m in GLOB.players_by_zlevel[hz])
var/mob/M = m
var/sound/SND = sound('sound/misc/emergency_beacon_launched.ogg') // Inside the loop because playsound_local modifies it for each person, so, need separate instances
var/turf/them = get_turf(M)
var/volume = max(0.20, 1-(get_dist(us,them) / mapsize*0.8))*100
M.playsound_local(get_turf(M), SND, vol = volume)
+6
View File
@@ -260,6 +260,12 @@
/obj/effect/overmap/visitable/ship/proc/get_landed_info()
return "This ship cannot land."
/obj/effect/overmap/visitable/ship/get_distress_info()
var/turf/T = get_turf(src) // Usually we're on the turf, but sometimes we might be landed or something.
var/x_to_use = T?.x || "UNK"
var/y_to_use = T?.y || "UNK"
return "\[X:[x_to_use],Y:[y_to_use],VEL:[get_speed() * 1000],HDG:[get_heading_degrees()]\]"
#undef MOVING
#undef SANITIZE_SPEED
#undef CHANGE_SPEED_BY