Files
Bubberstation/code/game/objects/items/devices/radio/intercom.dm
Fox McCloud 057aa31cda Kills off /obj/item/device (#37297)
* Kills off /obj/item/device

* whoops

* whoops

* Fix
2018-04-23 15:00:23 +02:00

150 lines
5.1 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/ratvar
name = "hierophant intercom"
desc = "A modified intercom that uses the Hierophant network instead of subspace tech. Can listen to and broadcast on any frequency."
icon_state = "intercom_ratvar"
freerange = TRUE
/obj/item/radio/intercom/ratvar/attackby(obj/item/I, mob/living/user, params)
if(istype(I, /obj/item/screwdriver))
to_chat(user, "<span class='danger'>[src] is fastened to the wall with [is_servant_of_ratvar(user) ? "replicant alloy" : "some material you've never seen"], and can't be removed.</span>")
return //no unfastening!
. = ..()
/obj/item/radio/intercom/ratvar/process()
if(!istype(SSticker.mode, /datum/game_mode/clockwork_cult))
invisibility = INVISIBILITY_OBSERVER
alpha = 125
emped = TRUE
else
invisibility = initial(invisibility)
alpha = initial(alpha)
emped = FALSE
..()
/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)
..()
if(!unfastened)
to_chat(user, "<span class='notice'>It's <b>screwed</b> and secured to the wall.</span>")
else
to_chat(user, "<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(istype(I, /obj/item/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(istype(I, /obj/item/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, 1)
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
//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
materials = list(MAT_METAL = 75, MAT_GLASS = 25)