Files
CHOMPStation2/code/game/objects/items/devices/e_beacon.dm
CHOMPStation2StaffMirrorBot 651c8bc1af [MIRROR] Simultaneous map definitions (#10295)
Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
Co-authored-by: Kashargul <KashL@t-online.de>
2025-08-10 00:51:17 +02:00

69 lines
3.2 KiB
Plaintext

/obj/item/emergency_beacon
name = "personal emergency beacon"
desc = "The hardy PersonaL Emergency Beacon, or PLEB, is a simple device that, once activated, sends out a wideband distress signal that can punch through almost all forms of interference. They are commonly issued to miners and remote exploration teams who may find themselves in need of means to call for assistance whilst being out of conventional communications range."
icon = 'icons/obj/device_vr.dmi'
icon_state = "e_beacon_off"
var/beacon_active = FALSE
var/list/levels_for_distress
var/obj/item/gps/gps = null
pickup_sound = 'sound/items/pickup/device.ogg'
drop_sound = 'sound/items/drop/device.ogg'
/obj/item/emergency_beacon/Initialize(mapload)
gps = new/obj/item/gps/emergency_beacon(src)
for(var/i in 1 to length(levels_for_distress))
var/current = levels_for_distress[i]
if(isnum(current))
continue
levels_for_distress[i] = GLOB.map_templates_loaded[current]
if(!levels_for_distress)
levels_for_distress = list(1)
return ..()
/obj/item/gps/emergency_beacon
gps_tag = "EMERGENCY BEACON"
/obj/item/emergency_beacon/attack_self(mob/user)
var/T = user.loc
if(!beacon_active)
if(!isturf(T))
to_chat(user,span_warning("You cannot activate the beacon when you are not on a turf!"))
return
else if(isnonsolidturf(T))
to_chat(user,span_warning("You cannot activate the beacon when you are not on sufficiently solid ground!"))
return
else
var/answer = tgui_alert(user, "Would you like to activate this personal emergency beacon?","\The [src]", list("Yes", "No"))
if(answer != "Yes")
return
else if(do_after(user, (3 SECONDS))) //short delay, so they can still abort if they want to
user.visible_message(span_warning("[user] activates \the [src]!"),span_warning("You activate \the [src], spiking it into the ground!"))
beacon_active = TRUE
icon_state = "e_beacon_active"
user.drop_item()
anchored = TRUE
gps.tracking = TRUE
admin_chat_message(message = "'[user?.ckey || "Unknown"]' activated a personal emergency beacon", color = "#FF2222")
var/message = "This is an automated distress signal from a MIL-DTL-93352-compliant personal emergency beacon transmitting on [PUB_FREQ*0.1]kHz. \
This beacon was activated in '\the [get_area(src)]' at X[src.loc.x], Y[src.loc.y]. Due to the limited signal strength, no further information can be provided at this time. \
Per the Interplanetary Convention on Space SAR, those receiving this message must attempt rescue, \
or relay the message to those who can."
for(var/zlevel in levels_for_distress)
priority_announcement.Announce(message, new_title = "Automated Personal Distress Signal", new_sound = 'sound/AI/sos.ogg', zlevel = zlevel)
else
to_chat(user,"\The [src] is already active, or is otherwise malfunctioning. There's nothing you can do but wait. And possibly pray.")
/obj/item/emergency_beacon/attack_hand(mob/user)
if(beacon_active)
to_chat(user,span_warning("The beacon is already active and cannot be moved!"))
return
. = ..()
/obj/item/emergency_beacon/attackby(obj/item/W, mob/user)
if(W.is_wrench() && beacon_active)
gps.tracking = FALSE
user.visible_message("[user] disassembles \the [src].")
qdel(src)