mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-06 06:19:24 +00:00
134 lines
4.4 KiB
Plaintext
134 lines
4.4 KiB
Plaintext
/obj/item/radio/intercom
|
|
name = "station intercom"
|
|
desc = "Talk through this."
|
|
icon_state = "intercom"
|
|
anchored = TRUE
|
|
w_class = WEIGHT_CLASS_BULKY
|
|
canhear_range = 2
|
|
var/number = 0
|
|
var/anyai = 1
|
|
var/mob/living/silicon/ai/ai = list()
|
|
var/last_tick //used to delay the powercheck
|
|
dog_fashion = null
|
|
var/unfastened = FALSE
|
|
|
|
/obj/item/radio/intercom/unscrewed
|
|
unfastened = TRUE
|
|
|
|
/obj/item/radio/intercom/Initialize(mapload, ndir, building)
|
|
. = ..()
|
|
if(building)
|
|
setDir(ndir)
|
|
START_PROCESSING(SSobj, src)
|
|
|
|
/obj/item/radio/intercom/Destroy()
|
|
STOP_PROCESSING(SSobj, src)
|
|
return ..()
|
|
|
|
/obj/item/radio/intercom/examine(mob/user)
|
|
. = ..()
|
|
. += "<span class='notice'>Use [MODE_TOKEN_INTERCOM] when nearby to speak into it.</span>"
|
|
if(!unfastened)
|
|
. += "<span class='notice'>It's <b>screwed</b> and secured to the wall.</span>"
|
|
else
|
|
. += "<span class='notice'>It's <i>unscrewed</i> from the wall, and can be <b>detached</b>.</span>"
|
|
|
|
/obj/item/radio/intercom/attackby(obj/item/I, mob/living/user, params)
|
|
if(I.tool_behaviour == TOOL_SCREWDRIVER)
|
|
if(unfastened)
|
|
user.visible_message("<span class='notice'>[user] starts tightening [src]'s screws...</span>", "<span class='notice'>You start screwing in [src]...</span>")
|
|
if(I.use_tool(src, user, 30, volume=50))
|
|
user.visible_message("<span class='notice'>[user] tightens [src]'s screws!</span>", "<span class='notice'>You tighten [src]'s screws.</span>")
|
|
unfastened = FALSE
|
|
else
|
|
user.visible_message("<span class='notice'>[user] starts loosening [src]'s screws...</span>", "<span class='notice'>You start unscrewing [src]...</span>")
|
|
if(I.use_tool(src, user, 40, volume=50))
|
|
user.visible_message("<span class='notice'>[user] loosens [src]'s screws!</span>", "<span class='notice'>You unscrew [src], loosening it from the wall.</span>")
|
|
unfastened = TRUE
|
|
return
|
|
else if(I.tool_behaviour == TOOL_WRENCH)
|
|
if(!unfastened)
|
|
to_chat(user, "<span class='warning'>You need to unscrew [src] from the wall first!</span>")
|
|
return
|
|
user.visible_message("<span class='notice'>[user] starts unsecuring [src]...</span>", "<span class='notice'>You start unsecuring [src]...</span>")
|
|
I.play_tool_sound(src)
|
|
if(I.use_tool(src, user, 80))
|
|
user.visible_message("<span class='notice'>[user] unsecures [src]!</span>", "<span class='notice'>You detach [src] from the wall.</span>")
|
|
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
|
|
new/obj/item/wallframe/intercom(get_turf(src))
|
|
qdel(src)
|
|
return
|
|
return ..()
|
|
|
|
/obj/item/radio/intercom/attack_ai(mob/user)
|
|
interact(user)
|
|
|
|
/obj/item/radio/intercom/attack_hand(mob/user)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
interact(user)
|
|
|
|
/obj/item/radio/intercom/interact(mob/user)
|
|
..()
|
|
ui_interact(user, state = GLOB.default_state)
|
|
|
|
/obj/item/radio/intercom/can_receive(freq, level)
|
|
if(!on)
|
|
return FALSE
|
|
if(wires.is_cut(WIRE_RX))
|
|
return FALSE
|
|
if(!(0 in level))
|
|
var/turf/position = get_turf(src)
|
|
if(isnull(position) || !(position.z in level))
|
|
return FALSE
|
|
if(!src.listening)
|
|
return FALSE
|
|
if(freq == FREQ_SYNDICATE)
|
|
if(!(src.syndie))
|
|
return FALSE//Prevents broadcast of messages over devices lacking the encryption
|
|
|
|
return TRUE
|
|
|
|
|
|
/obj/item/radio/intercom/Hear(message, atom/movable/speaker, message_langs, raw_message, radio_freq, list/spans, message_mode)
|
|
if (message_mode == MODE_INTERCOM)
|
|
return // Avoid hearing the same thing twice
|
|
if(!anyai && !(speaker in ai))
|
|
return
|
|
..()
|
|
|
|
/obj/item/radio/intercom/process()
|
|
if(((world.timeofday - last_tick) > 30) || ((world.timeofday - last_tick) < 0))
|
|
last_tick = world.timeofday
|
|
|
|
var/area/A = get_area(src)
|
|
if(!A || emped)
|
|
on = FALSE
|
|
else
|
|
on = A.powered(EQUIP) // set "on" to the power status
|
|
|
|
if(!on)
|
|
icon_state = "intercom-p"
|
|
else
|
|
icon_state = initial(icon_state)
|
|
|
|
/obj/item/radio/intercom/add_blood_DNA(list/blood_dna)
|
|
return FALSE
|
|
|
|
/obj/item/radio/intercom/end_emp_effect(curremp)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
on = FALSE
|
|
|
|
//Created through the autolathe or through deconstructing intercoms. Can be applied to wall to make a new intercom on it!
|
|
/obj/item/wallframe/intercom
|
|
name = "intercom frame"
|
|
desc = "A ready-to-go intercom. Just slap it on a wall and screw it in!"
|
|
icon_state = "intercom"
|
|
result_path = /obj/item/radio/intercom/unscrewed
|
|
pixel_shift = 29
|
|
inverse = TRUE
|
|
custom_materials = list(/datum/material/iron = 75, /datum/material/glass = 25)
|