From 24972ccc5cdb567aabf9f03ea4a7b68071af24ab Mon Sep 17 00:00:00 2001 From: Firecage Date: Wed, 6 Aug 2014 16:21:24 +0200 Subject: [PATCH] ABSOLUTELY ABSOLUTE --- code/modules/assembly/assembly.dm | 196 ++++++++++----------- code/modules/assembly/helpers.dm | 12 +- code/modules/assembly/holder.dm | 272 ++++++++++++++--------------- code/modules/assembly/infrared.dm | 259 ++++++++++++++------------- code/modules/assembly/mousetrap.dm | 230 ++++++++++++------------ code/modules/assembly/proximity.dm | 229 ++++++++++++------------ code/modules/assembly/signaler.dm | 236 ++++++++++++------------- code/modules/assembly/voice.dm | 46 ++--- 8 files changed, 740 insertions(+), 740 deletions(-) diff --git a/code/modules/assembly/assembly.dm b/code/modules/assembly/assembly.dm index 506a9a988cf..6a62258e991 100644 --- a/code/modules/assembly/assembly.dm +++ b/code/modules/assembly/assembly.dm @@ -24,126 +24,126 @@ var/const/WIRE_RADIO_RECEIVE = 8 //Allows Pulsed(1) to call Activate() var/const/WIRE_RADIO_PULSE = 16 //Allows Pulse(1) to send a radio message - proc/activate() //What the device does when turned on - return +/obj/item/device/assembly/proc/activate() //What the device does when turned on + return - proc/pulsed(var/radio = 0) //Called when another assembly acts on this one, var/radio will determine where it came from for wire calcs - return +/obj/item/device/assembly/proc/pulsed(var/radio = 0) //Called when another assembly acts on this one, var/radio will determine where it came from for wire calcs + return - proc/pulse(var/radio = 0) //Called when this device attempts to act on another device, var/radio determines if it was sent via radio or direct - return +/obj/item/device/assembly/proc/pulse(var/radio = 0) //Called when this device attempts to act on another device, var/radio determines if it was sent via radio or direct + return - proc/toggle_secure() //Code that has to happen when the assembly is un\secured goes here - return +/obj/item/device/assembly/proc/toggle_secure() //Code that has to happen when the assembly is un\secured goes here + return - proc/attach_assembly(var/obj/A, var/mob/user) //Called when an assembly is attacked by another - return +/obj/item/device/assembly/proc/attach_assembly(var/obj/A, var/mob/user) //Called when an assembly is attacked by another + return - proc/process_cooldown() //Called via spawn(10) to have it count down the cooldown var - return +/obj/item/device/assembly/proc/process_cooldown() //Called via spawn(10) to have it count down the cooldown var + return - proc/holder_movement() //Called when the holder is moved - return +/obj/item/device/assembly/proc/holder_movement() //Called when the holder is moved + return - interact(mob/user as mob) //Called when attack_self is called - return +/obj/item/device/assembly/interact(mob/user as mob) //Called when attack_self is called + return - proc/describe() // Called by grenades to describe the state of the trigger (time left, etc) - return "The trigger assembly looks broken!" +/obj/item/device/assembly/proc/describe() // Called by grenades to describe the state of the trigger (time left, etc) + return "The trigger assembly looks broken!" - process_cooldown() - cooldown-- - if(cooldown <= 0) return 0 - spawn(10) - process_cooldown() +/obj/item/device/assembly/process_cooldown() + cooldown-- + if(cooldown <= 0) return 0 + spawn(10) + process_cooldown() + return 1 + + +/obj/item/device/assembly/pulsed(var/radio = 0) + if(holder && (wires & WIRE_RECEIVE)) + activate() + if(radio && (wires & WIRE_RADIO_RECEIVE)) + activate() + return 1 + + +/obj/item/device/assembly/pulse(var/radio = 0) + if(holder && (wires & WIRE_PULSE)) + holder.process_activation(src, 1, 0) + if(holder && (wires & WIRE_PULSE_SPECIAL)) + holder.process_activation(src, 0, 1) + + if(istype(loc,/obj/item/weapon/grenade)) // This is a hack. Todo: Manage this better -Sayu + var/obj/item/weapon/grenade/G = loc + G.prime() // Adios, muchachos +// if(radio && (wires & WIRE_RADIO_PULSE)) + //Not sure what goes here quite yet send signal? + return 1 + + +/obj/item/device/assembly/activate() + if(!secured || (cooldown > 0)) return 0 + cooldown = 2 + spawn(10) + process_cooldown() + return 1 + + +/obj/item/device/assembly/toggle_secure() + secured = !secured + update_icon() + return secured + + +/obj/item/device/assembly/attach_assembly(var/obj/item/device/assembly/A, var/mob/user) + holder = new/obj/item/device/assembly_holder(get_turf(src)) + if(holder.attach(A,src,user)) + user << "\blue You attach \the [A] to \the [src]!" return 1 + return 0 - pulsed(var/radio = 0) - if(holder && (wires & WIRE_RECEIVE)) - activate() - if(radio && (wires & WIRE_RADIO_RECEIVE)) - activate() - return 1 - - - pulse(var/radio = 0) - if(holder && (wires & WIRE_PULSE)) - holder.process_activation(src, 1, 0) - if(holder && (wires & WIRE_PULSE_SPECIAL)) - holder.process_activation(src, 0, 1) - - if(istype(loc,/obj/item/weapon/grenade)) // This is a hack. Todo: Manage this better -Sayu - var/obj/item/weapon/grenade/G = loc - G.prime() // Adios, muchachos -// if(radio && (wires & WIRE_RADIO_PULSE)) - //Not sure what goes here quite yet send signal? - return 1 - - - activate() - if(!secured || (cooldown > 0)) return 0 - cooldown = 2 - spawn(10) - process_cooldown() - return 1 - - - toggle_secure() - secured = !secured - update_icon() - return secured - - - attach_assembly(var/obj/item/device/assembly/A, var/mob/user) - holder = new/obj/item/device/assembly_holder(get_turf(src)) - if(holder.attach(A,src,user)) - user << "\blue You attach \the [A] to \the [src]!" - return 1 - return 0 - - - attackby(obj/item/weapon/W as obj, mob/user as mob) - if(isassembly(W)) - var/obj/item/device/assembly/A = W - if((!A.secured) && (!secured)) - attach_assembly(A,user) - return - if(istype(W, /obj/item/weapon/screwdriver)) - if(toggle_secure()) - user << "\blue \The [src] is ready!" - else - user << "\blue \The [src] can now be attached!" +/obj/item/device/assembly/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(isassembly(W)) + var/obj/item/device/assembly/A = W + if((!A.secured) && (!secured)) + attach_assembly(A,user) return - ..() + if(istype(W, /obj/item/weapon/screwdriver)) + if(toggle_secure()) + user << "\blue \The [src] is ready!" + else + user << "\blue \The [src] can now be attached!" return + ..() + return - process() - processing_objects.Remove(src) - return +/obj/item/device/assembly/process() + processing_objects.Remove(src) + return - examine() - set src in view() - ..() - if((in_range(src, usr) || loc == usr)) - if(secured) - usr << "\The [src] is ready!" - else - usr << "\The [src] can be attached!" - return +/obj/item/device/assembly/examine() + set src in view() + ..() + if((in_range(src, usr) || loc == usr)) + if(secured) + usr << "\The [src] is ready!" + else + usr << "\The [src] can be attached!" + return - attack_self(mob/user as mob) - if(!user) return 0 - user.set_machine(src) - interact(user) - return 1 +/obj/item/device/assembly/attack_self(mob/user as mob) + if(!user) return 0 + user.set_machine(src) + interact(user) + return 1 - interact(mob/user as mob) - return //HTML MENU FOR WIRES GOES HERE +/obj/item/device/assembly/interact(mob/user as mob) + return //HTML MENU FOR WIRES GOES HERE /* var/small_icon_state = null//If this obj will go inside the assembly use this for icons diff --git a/code/modules/assembly/helpers.dm b/code/modules/assembly/helpers.dm index 0c8005ad0bc..ddef24d49b0 100644 --- a/code/modules/assembly/helpers.dm +++ b/code/modules/assembly/helpers.dm @@ -1,29 +1,29 @@ -/proc/isassembly(O) +proc/isassembly(O) if(istype(O, /obj/item/device/assembly)) return 1 return 0 -/proc/isigniter(O) +proc/isigniter(O) if(istype(O, /obj/item/device/assembly/igniter)) return 1 return 0 -/proc/isinfared(O) +proc/isinfared(O) if(istype(O, /obj/item/device/assembly/infra)) return 1 return 0 -/proc/isprox(O) +proc/isprox(O) if(istype(O, /obj/item/device/assembly/prox_sensor)) return 1 return 0 -/proc/issignaler(O) +proc/issignaler(O) if(istype(O, /obj/item/device/assembly/signaler)) return 1 return 0 -/proc/istimer(O) +proc/istimer(O) if(istype(O, /obj/item/device/assembly/timer)) return 1 return 0 diff --git a/code/modules/assembly/holder.dm b/code/modules/assembly/holder.dm index 795ca471f84..50f135941e0 100644 --- a/code/modules/assembly/holder.dm +++ b/code/modules/assembly/holder.dm @@ -13,159 +13,159 @@ var/obj/item/device/assembly/a_left = null var/obj/item/device/assembly/a_right = null - proc/attach(var/obj/item/device/D, var/obj/item/device/D2, var/mob/user) - return +/obj/item/device/assembly_holder/proc/attach(var/obj/item/device/D, var/obj/item/device/D2, var/mob/user) + return - proc/process_activation(var/obj/item/device/D) - return +/obj/item/device/assembly_holder/proc/process_activation(var/obj/item/device/D) + return - IsAssemblyHolder() - return 1 - - - attach(var/obj/item/device/D, var/obj/item/device/D2, var/mob/user) - if((!D)||(!D2)) return 0 - if((!isassembly(D))||(!isassembly(D2))) return 0 - if((D:secured)||(D2:secured)) return 0 - if(user) - user.remove_from_mob(D) - user.remove_from_mob(D2) - D:holder = src - D2:holder = src - D.loc = src - D2.loc = src - a_left = D - a_right = D2 - name = "[D.name]-[D2.name] assembly" - update_icon() - return 1 +/obj/item/device/assembly_holder/IsAssemblyHolder() + return 1 +/obj/item/device/assembly_holder/attach(var/obj/item/device/D, var/obj/item/device/D2, var/mob/user) + if((!D)||(!D2)) return 0 + if((!isassembly(D))||(!isassembly(D2))) return 0 + if((D:secured)||(D2:secured)) return 0 + if(user) + user.remove_from_mob(D) + user.remove_from_mob(D2) + D:holder = src + D2:holder = src + D.loc = src + D2.loc = src + a_left = D + a_right = D2 + name = "[D.name]-[D2.name] assembly" update_icon() - overlays.Cut() - if(a_left) - overlays += "[a_left.icon_state]_left" - for(var/O in a_left.attached_overlays) - overlays += "[O]_l" - if(a_right) - src.overlays += "[a_right.icon_state]_right" - for(var/O in a_right.attached_overlays) - overlays += "[O]_r" - if(master) - master.update_icon() + return 1 - examine() - set src in view() - ..() - if ((in_range(src, usr) || src.loc == usr)) - if (src.secured) - usr << "\The [src] is ready!" - else - usr << "\The [src] can be attached!" +/obj/item/device/assembly_holder/update_icon() + overlays.Cut() + if(a_left) + overlays += "[a_left.icon_state]_left" + for(var/O in a_left.attached_overlays) + overlays += "[O]_l" + if(a_right) + src.overlays += "[a_right.icon_state]_right" + for(var/O in a_right.attached_overlays) + overlays += "[O]_r" + if(master) + master.update_icon() + + +/obj/item/device/assembly_holder/examine() + set src in view() + ..() + if ((in_range(src, usr) || src.loc == usr)) + if (src.secured) + usr << "\The [src] is ready!" + else + usr << "\The [src] can be attached!" + return + + +/obj/item/device/assembly_holder/HasProximity(atom/movable/AM as mob|obj) + if(a_left) + a_left.HasProximity(AM) + if(a_right) + a_right.HasProximity(AM) + + +/obj/item/device/assembly_holder/Crossed(atom/movable/AM as mob|obj) + if(a_left) + a_left.Crossed(AM) + if(a_right) + a_right.Crossed(AM) + +/obj/item/device/assembly_holder/on_found(mob/finder as mob) + if(a_left) + a_left.on_found(finder) + if(a_right) + a_right.on_found(finder) + + +/obj/item/device/assembly_holder/hear_talk(mob/living/M as mob, msg) + if(a_left) + a_left.hear_talk(M, msg) + if(a_right) + a_right.hear_talk(M, msg) + +/obj/item/device/assembly_holder/Move() + ..() + if(a_left && a_right) + a_left.holder_movement() + a_right.holder_movement() + return + + +/obj/item/device/assembly_holder/attack_hand()//Perhapse this should be a holder_pickup proc instead, can add if needbe I guess + if(a_left && a_right) + a_left.holder_movement() + a_right.holder_movement() + ..() + return + + +/obj/item/device/assembly_holder/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(istype(W, /obj/item/weapon/screwdriver)) + if(!a_left || !a_right) + user << "\red BUG:Assembly part missing, please report this!" + return + a_left.toggle_secure() + a_right.toggle_secure() + secured = !secured + if(secured) + user << "\blue \The [src] is ready!" + else + user << "\blue \The [src] can now be taken apart!" + update_icon() return - - - HasProximity(atom/movable/AM as mob|obj) - if(a_left) - a_left.HasProximity(AM) - if(a_right) - a_right.HasProximity(AM) - - - Crossed(atom/movable/AM as mob|obj) - if(a_left) - a_left.Crossed(AM) - if(a_right) - a_right.Crossed(AM) - - on_found(mob/finder as mob) - if(a_left) - a_left.on_found(finder) - if(a_right) - a_right.on_found(finder) - - - hear_talk(mob/living/M as mob, msg) - if(a_left) - a_left.hear_talk(M, msg) - if(a_right) - a_right.hear_talk(M, msg) - - Move() + else ..() - if(a_left && a_right) - a_left.holder_movement() - a_right.holder_movement() - return + return - attack_hand()//Perhapse this should be a holder_pickup proc instead, can add if needbe I guess - if(a_left && a_right) - a_left.holder_movement() - a_right.holder_movement() - ..() - return - - - attackby(obj/item/weapon/W as obj, mob/user as mob) - if(istype(W, /obj/item/weapon/screwdriver)) - if(!a_left || !a_right) - user << "\red BUG:Assembly part missing, please report this!" - return - a_left.toggle_secure() - a_right.toggle_secure() - secured = !secured - if(secured) - user << "\blue \The [src] is ready!" - else - user << "\blue \The [src] can now be taken apart!" - update_icon() +/obj/item/device/assembly_holder/attack_self(mob/user as mob) + src.add_fingerprint(user) + if(src.secured) + if(!a_left || !a_right) + user << "\red Assembly part missing!" + return + if(istype(a_left,a_right.type))//If they are the same type it causes issues due to window code + switch(alert("Which side would you like to use?",,"Left","Right")) + if("Left") a_left.attack_self(user) + if("Right") a_right.attack_self(user) return else - ..() - return + a_left.attack_self(user) + a_right.attack_self(user) + else + var/turf/T = get_turf(src) + if(!T) return 0 + if(a_left) + a_left:holder = null + a_left.loc = T + if(a_right) + a_right:holder = null + a_right.loc = T + qdel(src) + return - attack_self(mob/user as mob) - src.add_fingerprint(user) - if(src.secured) - if(!a_left || !a_right) - user << "\red Assembly part missing!" - return - if(istype(a_left,a_right.type))//If they are the same type it causes issues due to window code - switch(alert("Which side would you like to use?",,"Left","Right")) - if("Left") a_left.attack_self(user) - if("Right") a_right.attack_self(user) - return - else - a_left.attack_self(user) - a_right.attack_self(user) - else - var/turf/T = get_turf(src) - if(!T) return 0 - if(a_left) - a_left:holder = null - a_left.loc = T - if(a_right) - a_right:holder = null - a_right.loc = T - qdel(src) - return - - - process_activation(var/obj/D, var/normal = 1, var/special = 1) - if(!D) return 0 - if((normal) && (a_right) && (a_left)) - if(a_right != D) - a_right.pulsed(0) - if(a_left != D) - a_left.pulsed(0) - if(master) - master.receive_signal() - return 1 +/obj/item/device/assembly_holder/process_activation(var/obj/D, var/normal = 1, var/special = 1) + if(!D) return 0 + if((normal) && (a_right) && (a_left)) + if(a_right != D) + a_right.pulsed(0) + if(a_left != D) + a_left.pulsed(0) + if(master) + master.receive_signal() + return 1 diff --git a/code/modules/assembly/infrared.dm b/code/modules/assembly/infrared.dm index 25d00b4e386..228c6128e9d 100644 --- a/code/modules/assembly/infrared.dm +++ b/code/modules/assembly/infrared.dm @@ -14,156 +14,155 @@ var/visible = 0 var/obj/effect/beam/i_beam/first = null - proc - trigger_beam() - - describe() - return "The infrared trigger is [on?"on":"off"]." - - activate() - if(!..()) return 0//Cooldown check - on = !on - update_icon() - return 1 - - - toggle_secure() - secured = !secured - if(secured) - processing_objects.Add(src) - else - on = 0 - if(first) qdel(first) - processing_objects.Remove(src) - update_icon() - return secured +/obj/item/device/assembly/infra/proc/trigger_beam() +/obj/item/device/assembly/infra/describe() + return "The infrared trigger is [on?"on":"off"]." +/obj/item/device/assembly/infra/activate() + if(!..()) return 0//Cooldown check + on = !on update_icon() - overlays.Cut() - attached_overlays = list() - if(on) - overlays += "infrared_on" - attached_overlays += "infrared_on" - - if(holder) - holder.update_icon() - return + return 1 - process()//Old code - if(!on) - if(first) - qdel(first) - return - if(first || !secured) return - var/turf/T = null - if(istype(loc,/turf)) - T = loc - else if (holder) - if (istype(holder.loc,/turf)) - T = holder.loc - else if (istype(holder.loc.loc,/turf)) //for onetankbombs and other tertiary builds with assemblies - T = holder.loc.loc - else if(istype(loc,/obj/item/weapon/grenade) && istype(loc.loc,/turf)) - T = loc.loc - if(T) - var/obj/effect/beam/i_beam/I = new /obj/effect/beam/i_beam(T) - I.master = src - I.density = 1 - I.dir = dir - step(I, I.dir) - if(I) - I.density = 0 - first = I - I.vis_spread(visible) - spawn(0) - if(I) - //world << "infra: setting limit" - I.limit = 8 - //world << "infra: processing beam \ref[I]" - I.process() - return - return +/obj/item/device/assembly/infra/toggle_secure() + secured = !secured + if(secured) + processing_objects.Add(src) + else + on = 0 + if(first) qdel(first) + processing_objects.Remove(src) + update_icon() + return secured - attack_hand() - qdel(first) - ..() - return +/obj/item/device/assembly/infra/update_icon() + overlays.Cut() + attached_overlays = list() + if(on) + overlays += "infrared_on" + attached_overlays += "infrared_on" + + if(holder) + holder.update_icon() + return - Move() - var/t = dir - ..() - dir = t - qdel(first) - return - - - holder_movement() - if(!holder) return 0 -// dir = holder.dir - qdel(first) - return 1 - - - trigger_beam() - if((!secured)||(!on)||(cooldown > 0)) return 0 - pulse(0) - visible_message("\icon[src] *beep* *beep*") - cooldown = 2 - spawn(10) - process_cooldown() - return - - - interact(mob/user as mob)//TODO: change this this to the wire control panel - if(!secured) return - user.set_machine(src) - var/dat = text("Infrared Laser\nStatus: []
\nVisibility: []
\n
", (on ? text("On", src) : text("Off", src)), (src.visible ? text("Visible", src) : text("Invisible", src))) - dat += "

Refresh" - dat += "

Close" - user << browse(dat, "window=infra") - onclose(user, "infra") - return - - - Topic(href, href_list) - ..() - if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) - usr << browse(null, "window=infra") - onclose(usr, "infra") +/obj/item/device/assembly/infra/process()//Old code + if(!on) + if(first) + qdel(first) return - - if(href_list["state"]) - on = !(on) - update_icon() - - if(href_list["visible"]) - visible = !(visible) + if(first || !secured) return + var/turf/T = null + if(istype(loc,/turf)) + T = loc + else if (holder) + if (istype(holder.loc,/turf)) + T = holder.loc + else if (istype(holder.loc.loc,/turf)) //for onetankbombs and other tertiary builds with assemblies + T = holder.loc.loc + else if(istype(loc,/obj/item/weapon/grenade) && istype(loc.loc,/turf)) + T = loc.loc + if(T) + var/obj/effect/beam/i_beam/I = new /obj/effect/beam/i_beam(T) + I.master = src + I.density = 1 + I.dir = dir + step(I, I.dir) + if(I) + I.density = 0 + first = I + I.vis_spread(visible) spawn(0) - if(first) - first.vis_spread(visible) + if(I) + //world << "infra: setting limit" + I.limit = 8 + //world << "infra: processing beam \ref[I]" + I.process() + return + return - if(href_list["close"]) - usr << browse(null, "window=infra") - return - if(usr) - attack_self(usr) +/obj/item/device/assembly/infra/attack_hand() + qdel(first) + ..() + return + +/obj/item/device/assembly/infra/Move() + var/t = dir + ..() + dir = t + qdel(first) + return + + +/obj/item/device/assembly/infra/holder_movement() + if(!holder) return 0 +// dir = holder.dir + qdel(first) + return 1 + + +/obj/item/device/assembly/infra/trigger_beam() + if((!secured)||(!on)||(cooldown > 0)) return 0 + pulse(0) + visible_message("\icon[src] *beep* *beep*") + cooldown = 2 + spawn(10) + process_cooldown() + return + + +/obj/item/device/assembly/infra/interact(mob/user as mob)//TODO: change this this to the wire control panel + if(!secured) return + user.set_machine(src) + var/dat = text("Infrared Laser\nStatus: []
\nVisibility: []
\n
", (on ? text("On", src) : text("Off", src)), (src.visible ? text("Visible", src) : text("Invisible", src))) + dat += "

Refresh" + dat += "

Close" + user << browse(dat, "window=infra") + onclose(user, "infra") + return + + +/obj/item/device/assembly/infra/Topic(href, href_list) + ..() + if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) + usr << browse(null, "window=infra") + onclose(usr, "infra") return + if(href_list["state"]) + on = !(on) + update_icon() - verb/rotate()//This could likely be better - set name = "Rotate Infrared Laser" - set category = "Object" - set src in usr + if(href_list["visible"]) + visible = !(visible) + spawn(0) + if(first) + first.vis_spread(visible) - dir = turn(dir, 90) + if(href_list["close"]) + usr << browse(null, "window=infra") return + if(usr) + attack_self(usr) + + return + + +/obj/item/device/assembly/infra/verb/rotate()//This could likely be better + set name = "Rotate Infrared Laser" + set category = "Object" + set src in usr + + dir = turn(dir, 90) + return + /***************************IBeam*********************************/ diff --git a/code/modules/assembly/mousetrap.dm b/code/modules/assembly/mousetrap.dm index 61cce72718b..a1cbfbb7759 100644 --- a/code/modules/assembly/mousetrap.dm +++ b/code/modules/assembly/mousetrap.dm @@ -7,124 +7,124 @@ var/armed = 0 - examine() - ..() - if(armed) - usr << "It looks like it's armed." +/obj/item/device/assembly/mousetrap/examine() + ..() + if(armed) + usr << "It looks like it's armed." - activate() - if(..()) - armed = !armed - if(!armed) - if(ishuman(usr)) - var/mob/living/carbon/human/user = usr - if(((user.getBrainLoss() >= 60 || (CLUMSY in user.mutations)) && prob(50))) - user << "Your hand slips, setting off the trigger." - pulse(0) - update_icon() - if(usr) - playsound(usr.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3) - - describe() - return "The pressure switch is [armed?"primed":"safe"]." - - update_icon() - if(armed) - icon_state = "mousetraparmed" - else - icon_state = "mousetrap" - if(holder) - holder.update_icon() - - proc/triggered(mob/target as mob, var/type = "feet") - if(!armed) - return - var/obj/item/organ/limb/affecting = null - if(ishuman(target)) - var/mob/living/carbon/human/H = target - switch(type) - if("feet") - if(!H.shoes) - affecting = H.get_organ(pick("l_leg", "r_leg")) - H.Weaken(3) - if("l_hand", "r_hand") - if(!H.gloves) - affecting = H.get_organ(type) - H.Stun(3) - if(affecting) - if(affecting.take_damage(1, 0)) - H.update_damage_overlays(0) - H.updatehealth() - else if(ismouse(target)) - var/mob/living/simple_animal/mouse/M = target - visible_message("\red SPLAT!") - M.splat() - playsound(src.loc, 'sound/effects/snap.ogg', 50, 1) - armed = 0 - update_icon() - pulse(0) - - - attack_self(mob/living/user as mob) - if(!armed) - user << "You arm [src]." - else - if(((user.getBrainLoss() >= 60 || (CLUMSY in user.mutations)) && prob(50))) - var/which_hand = "l_hand" - if(!user.hand) - which_hand = "r_hand" - triggered(user, which_hand) - user.visible_message("[user] accidentally sets off [src], breaking their fingers.", \ - "You accidentally trigger [src]!") - return - user << "You disarm [src]." +/obj/item/device/assembly/mousetrap/activate() + if(..()) armed = !armed - update_icon() - playsound(user.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3) - - - attack_hand(mob/living/user as mob) - if(armed) - if(((user.getBrainLoss() >= 60 || CLUMSY in user.mutations)) && prob(50)) - var/which_hand = "l_hand" - if(!user.hand) - which_hand = "r_hand" - triggered(user, which_hand) - user.visible_message("[user] accidentally sets off [src], breaking their fingers.", \ - "You accidentally trigger [src]!") - return - ..() - - - Crossed(var/atom/movable/AM as mob|obj) - if(armed) - if(ishuman(AM)) - var/mob/living/carbon/H = AM - if(H.m_intent == "run") - triggered(H) - H.visible_message("[H] accidentally steps on [src].", \ - "You accidentally step on [src]") - else if(ismouse(AM)) - triggered(AM) - else if(AM.density) // For mousetrap grenades, set off by anything heavy - triggered(AM) - ..() - - - on_found(mob/finder as mob) - if(armed) - finder.visible_message("[finder] accidentally sets off [src], breaking their fingers.", \ - "You accidentally trigger [src]!") - triggered(finder, finder.hand ? "l_hand" : "r_hand") - return 1 //end the search! - return 0 - - - hitby(A as mob|obj) if(!armed) - return ..() - visible_message("[src] is triggered by [A].") - triggered(null) + if(ishuman(usr)) + var/mob/living/carbon/human/user = usr + if(((user.getBrainLoss() >= 60 || (CLUMSY in user.mutations)) && prob(50))) + user << "Your hand slips, setting off the trigger." + pulse(0) + update_icon() + if(usr) + playsound(usr.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3) + +/obj/item/device/assembly/mousetrap/describe() + return "The pressure switch is [armed?"primed":"safe"]." + +/obj/item/device/assembly/mousetrap/update_icon() + if(armed) + icon_state = "mousetraparmed" + else + icon_state = "mousetrap" + if(holder) + holder.update_icon() + +/obj/item/device/assembly/mousetrap/proc/triggered(mob/target as mob, var/type = "feet") + if(!armed) + return + var/obj/item/organ/limb/affecting = null + if(ishuman(target)) + var/mob/living/carbon/human/H = target + switch(type) + if("feet") + if(!H.shoes) + affecting = H.get_organ(pick("l_leg", "r_leg")) + H.Weaken(3) + if("l_hand", "r_hand") + if(!H.gloves) + affecting = H.get_organ(type) + H.Stun(3) + if(affecting) + if(affecting.take_damage(1, 0)) + H.update_damage_overlays(0) + H.updatehealth() + else if(ismouse(target)) + var/mob/living/simple_animal/mouse/M = target + visible_message("\red SPLAT!") + M.splat() + playsound(src.loc, 'sound/effects/snap.ogg', 50, 1) + armed = 0 + update_icon() + pulse(0) + + +/obj/item/device/assembly/mousetrap/attack_self(mob/living/user as mob) + if(!armed) + user << "You arm [src]." + else + if(((user.getBrainLoss() >= 60 || (CLUMSY in user.mutations)) && prob(50))) + var/which_hand = "l_hand" + if(!user.hand) + which_hand = "r_hand" + triggered(user, which_hand) + user.visible_message("[user] accidentally sets off [src], breaking their fingers.", \ + "You accidentally trigger [src]!") + return + user << "You disarm [src]." + armed = !armed + update_icon() + playsound(user.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3) + + +/obj/item/device/assembly/mousetrap/attack_hand(mob/living/user as mob) + if(armed) + if(((user.getBrainLoss() >= 60 || CLUMSY in user.mutations)) && prob(50)) + var/which_hand = "l_hand" + if(!user.hand) + which_hand = "r_hand" + triggered(user, which_hand) + user.visible_message("[user] accidentally sets off [src], breaking their fingers.", \ + "You accidentally trigger [src]!") + return + ..() + + +/obj/item/device/assembly/mousetrap/Crossed(var/atom/movable/AM as mob|obj) + if(armed) + if(ishuman(AM)) + var/mob/living/carbon/H = AM + if(H.m_intent == "run") + triggered(H) + H.visible_message("[H] accidentally steps on [src].", \ + "You accidentally step on [src]") + else if(ismouse(AM)) + triggered(AM) + else if(AM.density) // For mousetrap grenades, set off by anything heavy + triggered(AM) + ..() + + +/obj/item/device/assembly/mousetrap/on_found(mob/finder as mob) + if(armed) + finder.visible_message("[finder] accidentally sets off [src], breaking their fingers.", \ + "You accidentally trigger [src]!") + triggered(finder, finder.hand ? "l_hand" : "r_hand") + return 1 //end the search! + return 0 + + +/obj/item/device/assembly/mousetrap/hitby(A as mob|obj) + if(!armed) + return ..() + visible_message("[src] is triggered by [A].") + triggered(null) /obj/item/device/assembly/mousetrap/armed diff --git a/code/modules/assembly/proximity.dm b/code/modules/assembly/proximity.dm index 644a41462b6..05b9b508e9c 100644 --- a/code/modules/assembly/proximity.dm +++ b/code/modules/assembly/proximity.dm @@ -12,134 +12,135 @@ var/timing = 0 var/time = 10 - proc - toggle_scan() - sense() - - describe() - if(timing) - return "\blue The proximity sensor is arming." - return "The proximity sensor is [scanning?"armed":"disarmed"]." - - activate() - if(!..()) return 0//Cooldown check - timing = !timing - update_icon() - return 0 +/obj/item/device/assembly/prox_sensor/proc/toggle_scan() - toggle_secure() - secured = !secured - if(secured) - processing_objects.Add(src) - else - scanning = 0 - timing = 0 - processing_objects.Remove(src) - update_icon() - return secured - - - HasProximity(atom/movable/AM as mob|obj) - if (istype(AM, /obj/effect/beam)) return - if (AM.move_speed < 12) sense() - return - - - sense() - if((!secured)||(!scanning)||(cooldown > 0)) return 0 - pulse(0) - visible_message("\icon[src] *beep* *beep*", "*beep* *beep*") - cooldown = 2 - spawn(10) - process_cooldown() - return - - - process() - if(timing && (time >= 0)) - time-- - if(timing && time <= 0) - timing = 0 - toggle_scan() - time = 10 - return - - - dropped() - spawn(0) - sense() - return - return - - - toggle_scan() - if(!secured) return 0 - scanning = !scanning - update_icon() - return +/obj/item/device/assembly/prox_sensor/proc/sense() +/obj/item/device/assembly/prox_sensor/describe() + if(timing) + return "\blue The proximity sensor is arming." + return "The proximity sensor is [scanning?"armed":"disarmed"]." +/obj/item/device/assembly/prox_sensor/activate() + if(!..()) return 0//Cooldown check + timing = !timing update_icon() - overlays.Cut() - attached_overlays = list() - if(timing) - overlays += "prox_timing" - attached_overlays += "prox_timing" - if(scanning) - overlays += "prox_scanning" - attached_overlays += "prox_scanning" - if(holder) - holder.update_icon() - return + return 0 - Move() - ..() +/obj/item/device/assembly/prox_sensor/toggle_secure() + secured = !secured + if(secured) + processing_objects.Add(src) + else + scanning = 0 + timing = 0 + processing_objects.Remove(src) + update_icon() + return secured + + +/obj/item/device/assembly/prox_sensor/HasProximity(atom/movable/AM as mob|obj) + if (istype(AM, /obj/effect/beam)) return + if (AM.move_speed < 12) sense() + return + + +/obj/item/device/assembly/prox_sensor/sense() + if((!secured)||(!scanning)||(cooldown > 0)) return 0 + pulse(0) + visible_message("\icon[src] *beep* *beep*", "*beep* *beep*") + cooldown = 2 + spawn(10) + process_cooldown() + return + + +/obj/item/device/assembly/prox_sensor/process() + if(timing && (time >= 0)) + time-- + if(timing && time <= 0) + timing = 0 + toggle_scan() + time = 10 + return + + +/obj/item/device/assembly/prox_sensor/dropped() + spawn(0) sense() return + return - interact(mob/user as mob)//TODO: Change this to the wires thingy - if(!secured) - user.show_message("\red The [name] is unsecured!") - return 0 - var/second = time % 60 - var/minute = (time - second) / 60 - var/dat = text("Proximity Sensor\n[] []:[]\n- - + +\n", (timing ? text("Arming", src) : text("Not Arming", src)), minute, second, src, src, src, src) - dat += "
[scanning?"Armed":"Unarmed"] (Movement sensor active when armed!)" - dat += "

Refresh" - dat += "

Close" - user << browse(dat, "window=prox") - onclose(user, "prox") +/obj/item/device/assembly/prox_sensor/toggle_scan() + if(!secured) return 0 + scanning = !scanning + update_icon() + return + + +/obj/item/device/assembly/prox_sensor/update_icon() + overlays.Cut() + attached_overlays = list() + if(timing) + overlays += "prox_timing" + attached_overlays += "prox_timing" + if(scanning) + overlays += "prox_scanning" + attached_overlays += "prox_scanning" + if(holder) + holder.update_icon() + return + + +/obj/item/device/assembly/prox_sensor/Move() + ..() + sense() + return + + +/obj/item/device/assembly/prox_sensor/interact(mob/user as mob)//TODO: Change this to the wires thingy + if(!secured) + user.show_message("\red The [name] is unsecured!") + return 0 + var/second = time % 60 + var/minute = (time - second) / 60 + var/dat = text("Proximity Sensor\n[] []:[]\n- - + +\n", (timing ? text("Arming", src) : text("Not Arming", src)), minute, second, src, src, src, src) + dat += "
[scanning?"Armed":"Unarmed"] (Movement sensor active when armed!)" + dat += "

Refresh" + dat += "

Close" + user << browse(dat, "window=prox") + onclose(user, "prox") + return + + +/obj/item/device/assembly/prox_sensor/Topic(href, href_list) + ..() + if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) + usr << browse(null, "window=prox") + onclose(usr, "prox") return + if(href_list["scanning"]) + toggle_scan() - Topic(href, href_list) - ..() - if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) - usr << browse(null, "window=prox") - onclose(usr, "prox") - return - - if(href_list["scanning"]) - toggle_scan() - - if(href_list["time"]) - timing = text2num(href_list["time"]) - update_icon() - - if(href_list["tp"]) - var/tp = text2num(href_list["tp"]) - time += tp - time = min(max(round(time), 0), 600) - - if(href_list["close"]) - usr << browse(null, "window=prox") - return - - if(usr) - attack_self(usr) + if(href_list["time"]) + timing = text2num(href_list["time"]) + update_icon() + if(href_list["tp"]) + var/tp = text2num(href_list["tp"]) + time += tp + time = min(max(round(time), 0), 600) + if(href_list["close"]) + usr << browse(null, "window=prox") return + + if(usr) + attack_self(usr) + + + return diff --git a/code/modules/assembly/signaler.dm b/code/modules/assembly/signaler.dm index f421cc7c033..325b1688a5b 100644 --- a/code/modules/assembly/signaler.dm +++ b/code/modules/assembly/signaler.dm @@ -16,102 +16,102 @@ var/datum/wires/connected = null var/datum/radio_frequency/radio_connection - New() - ..() - spawn(40) - set_frequency(frequency) +/obj/item/device/assembly/signaler/New() + ..() + spawn(40) + set_frequency(frequency) + return + + +/obj/item/device/assembly/signaler/activate() + if(cooldown > 0) return 0 + cooldown = 2 + spawn(10) + process_cooldown() + + signal() + return 1 + +/obj/item/device/assembly/signaler/update_icon() + if(holder) + holder.update_icon() + return + +/obj/item/device/assembly/signaler/interact(mob/user as mob, flag1) + var/t1 = "-------" +// if ((src.b_stat && !( flag1 ))) +// t1 = text("-------
\nGreen Wire: []
\nRed Wire: []
\nBlue Wire: []
\n", (src.wires & 4 ? text("Cut Wire", src) : text("Mend Wire", src)), (src.wires & 2 ? text("Cut Wire", src) : text("Mend Wire", src)), (src.wires & 1 ? text("Cut Wire", src) : text("Mend Wire", src))) +// else +// t1 = "-------" Speaker: [src.listening ? "Engaged" : "Disengaged"]
+ var/dat = {" + + +Send Signal
+Frequency/Code for signaler:
+Frequency: +- +- +[format_frequency(src.frequency)] ++ ++
+ +Code: +- +- +[src.code] ++ ++
+[t1] +
"} + user << browse(dat, "window=radio") + onclose(user, "radio") + return + + +/obj/item/device/assembly/signaler/Topic(href, href_list) + ..() + + if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) + usr << browse(null, "window=radio") + onclose(usr, "radio") return + if (href_list["freq"]) + var/new_frequency = (frequency + text2num(href_list["freq"])) + if(new_frequency < 1200 || new_frequency > 1600) + new_frequency = sanitize_frequency(new_frequency) + set_frequency(new_frequency) - activate() - if(cooldown > 0) return 0 - cooldown = 2 - spawn(10) - process_cooldown() + if(href_list["code"]) + src.code += text2num(href_list["code"]) + src.code = round(src.code) + src.code = min(100, src.code) + src.code = max(1, src.code) - signal() - return 1 + if(href_list["send"]) + spawn( 0 ) + signal() - update_icon() - if(holder) - holder.update_icon() - return + if(usr) + attack_self(usr) - interact(mob/user as mob, flag1) - var/t1 = "-------" -// if ((src.b_stat && !( flag1 ))) -// t1 = text("-------
\nGreen Wire: []
\nRed Wire: []
\nBlue Wire: []
\n", (src.wires & 4 ? text("Cut Wire", src) : text("Mend Wire", src)), (src.wires & 2 ? text("Cut Wire", src) : text("Mend Wire", src)), (src.wires & 1 ? text("Cut Wire", src) : text("Mend Wire", src))) -// else -// t1 = "-------" Speaker: [src.listening ? "Engaged" : "Disengaged"]
- var/dat = {" - - - Send Signal
- Frequency/Code for signaler:
- Frequency: - - - - - [format_frequency(src.frequency)] - + - +
- - Code: - - - - - [src.code] - + - +
- [t1] -
"} - user << browse(dat, "window=radio") - onclose(user, "radio") - return + return - Topic(href, href_list) - ..() +/obj/item/device/assembly/signaler/proc/signal() + if(!radio_connection) return - if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) - usr << browse(null, "window=radio") - onclose(usr, "radio") - return + var/datum/signal/signal = new + signal.source = src + signal.encryption = code + signal.data["message"] = "ACTIVATE" + radio_connection.post_signal(src, signal) - if (href_list["freq"]) - var/new_frequency = (frequency + text2num(href_list["freq"])) - if(new_frequency < 1200 || new_frequency > 1600) - new_frequency = sanitize_frequency(new_frequency) - set_frequency(new_frequency) + var/time = time2text(world.realtime,"hh:mm:ss") + var/turf/T = get_turf(src) + lastsignalers.Add("[time] : [usr.key] used [src] @ location ([T.x],[T.y],[T.z]) : [format_frequency(frequency)]/[code]") - if(href_list["code"]) - src.code += text2num(href_list["code"]) - src.code = round(src.code) - src.code = min(100, src.code) - src.code = max(1, src.code) - - if(href_list["send"]) - spawn( 0 ) - signal() - - if(usr) - attack_self(usr) - - return - - - proc/signal() - if(!radio_connection) return - - var/datum/signal/signal = new - signal.source = src - signal.encryption = code - signal.data["message"] = "ACTIVATE" - radio_connection.post_signal(src, signal) - - var/time = time2text(world.realtime,"hh:mm:ss") - var/turf/T = get_turf(src) - lastsignalers.Add("[time] : [usr.key] used [src] @ location ([T.x],[T.y],[T.z]) : [format_frequency(frequency)]/[code]") - - return + return /* for(var/obj/item/device/assembly/signaler/S in world) if(!S) continue @@ -122,32 +122,32 @@ return 0*/ - pulse(var/radio = 0) - if(src.connected && src.wires) - connected.Pulse(src) - else - return ..(radio) +/obj/item/device/assembly/signaler/pulse(var/radio = 0) + if(src.connected && src.wires) + connected.Pulse(src) + else + return ..(radio) - receive_signal(datum/signal/signal) - if(!signal) return 0 - if(signal.encryption != code) return 0 - if(!(src.wires & WIRE_RADIO_RECEIVE)) return 0 - pulse(1) - for(var/mob/O in hearers(1, src.loc)) - O.show_message(text("\icon[] *beep* *beep*", src), 3, "*beep* *beep*", 2) - return - - - proc/set_frequency(new_frequency) - if(!radio_controller) - sleep(20) - if(!radio_controller) - return - radio_controller.remove_object(src, frequency) - frequency = new_frequency - radio_connection = radio_controller.add_object(src, frequency, RADIO_CHAT) +/obj/item/device/assembly/signaler/receive_signal(datum/signal/signal) + if(!signal) return 0 + if(signal.encryption != code) return 0 + if(!(src.wires & WIRE_RADIO_RECEIVE)) return 0 + pulse(1) + for(var/mob/O in hearers(1, src.loc)) + O.show_message(text("\icon[] *beep* *beep*", src), 3, "*beep* *beep*", 2) + return + + +/obj/item/device/assembly/signaler/proc/set_frequency(new_frequency) + if(!radio_controller) + sleep(20) + if(!radio_controller) return + radio_controller.remove_object(src, frequency) + frequency = new_frequency + radio_connection = radio_controller.add_object(src, frequency, RADIO_CHAT) + return // Embedded signaller used in grenade construction. // It's necessary because the signaler doens't have an off state. @@ -155,19 +155,19 @@ /obj/item/device/assembly/signaler/reciever var/on = 0 - proc/toggle_safety() - on = !on +/obj/item/device/assembly/signaler/reciever/proc/toggle_safety() + on = !on - activate() - toggle_safety() - return 1 +/obj/item/device/assembly/signaler/reciever/activate() + toggle_safety() + return 1 - describe() - return "The radio reciever is [on?"on":"off"]." +/obj/item/device/assembly/signaler/reciever/describe() + return "The radio reciever is [on?"on":"off"]." - receive_signal(datum/signal/signal) - if(!on) return - return ..(signal) +/obj/item/device/assembly/signaler/reciever/receive_signal(datum/signal/signal) + if(!on) return + return ..(signal) // Embedded signaller used in anomalies. diff --git a/code/modules/assembly/voice.dm b/code/modules/assembly/voice.dm index 4eb06965fa0..d8ee49932ce 100644 --- a/code/modules/assembly/voice.dm +++ b/code/modules/assembly/voice.dm @@ -8,30 +8,30 @@ var/listening = 0 var/recorded //the activation message - hear_talk(mob/living/M as mob, msg) - if(listening) - recorded = msg - listening = 0 - var/turf/T = get_turf(src) //otherwise it won't work in hand - T.visible_message("\icon[src] beeps, \"Activation message is '[recorded]'.\"") - else - if(findtext(msg, recorded)) - pulse(0) +/obj/item/device/assembly/voice/hear_talk(mob/living/M as mob, msg) + if(listening) + recorded = msg + listening = 0 + var/turf/T = get_turf(src) //otherwise it won't work in hand + T.visible_message("\icon[src] beeps, \"Activation message is '[recorded]'.\"") + else + if(findtext(msg, recorded)) + pulse(0) +/obj/item/device/assembly/voice/activate() + if(secured) + if(!holder) + listening = !listening + var/turf/T = get_turf(src) + T.visible_message("\icon[src] beeps, \"[listening ? "Now" : "No longer"] recording input.\"") + + +/obj/item/device/assembly/voice/attack_self(mob/user) + if(!user) return 0 activate() - if(secured) - if(!holder) - listening = !listening - var/turf/T = get_turf(src) - T.visible_message("\icon[src] beeps, \"[listening ? "Now" : "No longer"] recording input.\"") + return 1 - attack_self(mob/user) - if(!user) return 0 - activate() - return 1 - - - toggle_secure() - . = ..() - listening = 0 \ No newline at end of file +/obj/item/device/assembly/voice/toggle_secure() + . = ..() + listening = 0 \ No newline at end of file