From 1d74dab7f6813ba16d8fe0fbce65cb230ee7593b Mon Sep 17 00:00:00 2001 From: Menshin Date: Wed, 3 Sep 2014 11:13:14 +0200 Subject: [PATCH 1/2] Made the SMES terminal constructible/deconstructible --- code/modules/power/smes.dm | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index 78c01b24636..c523c73dcc8 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -68,10 +68,12 @@ capacity = C / (15000) * 1e6 /obj/machinery/power/smes/attackby(obj/item/I, mob/user) + //opening using screwdriver if(default_deconstruction_screwdriver(user, "[initial(icon_state)]-o", initial(icon_state), I)) update_icon() return + //changing direction using wrench if(default_change_direction_wrench(user, I)) terminal = null var/turf/T = get_step(src, dir) @@ -94,9 +96,83 @@ update_icon() return + //exchanging parts using the RPE if(exchange_parts(user, I)) return + //building and linking a terminal + if(istype(I, /obj/item/stack/cable_coil)) + var/dir = get_dir(user,src) + if(dir & (dir-1))//we don't want diagonal click + return + + if(terminal) //is there already a terminal ? + user << "This SMES already have a power terminal!" + return + + if(!panel_open) //is the panel open ? + user << "You must open the maintenance panel first!" + return + + var/turf/T = get_turf(user) + if (T.intact) //is the floor plating removed ? + user << "You must first remove the floor plating!" + return + + + var/obj/item/stack/cable_coil/C = I + if(C.amount < 10) + user << "You need more wires." + return + + user << "You start building the power terminal..." + playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + + if(do_after(user, 20) && C.amount >= 10) + var/obj/structure/cable/N = T.get_cable_node() //get the connecting node cable, if there's one + if (prob(50) && electrocute_mob(usr, N, N)) //animate the electrocution if uncautious and unlucky + var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread + s.set_up(5, 1, src) + s.start() + return + + C.use(10) + user.visible_message(\ + "[user.name] has build a power terminal!",\ + "You build the power terminal.") + + //build the terminal and link it to the network + make_terminal(T) + terminal.connect_to_network() + return + + //disassembling the terminal + if(istype(I, /obj/item/weapon/wirecutters) && terminal && panel_open) + var/turf/T = get_turf(terminal) + if (T.intact) //is the floor plating removed ? + user << "You must first expose the power terminal!" + return + + user << "You begin to dismantle the power terminal..." + playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + + if(do_after(user, 50)) + if (prob(50) && electrocute_mob(usr, terminal.powernet, terminal)) //animate the electrocution if uncautious and unlucky + var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread + s.set_up(5, 1, src) + s.start() + return + + //give the wires back and delete the terminal + new /obj/item/stack/cable_coil(T,10) + user.visible_message(\ + "[user.name] cuts the cables and dismantles the power terminal.",\ + "You cut the cables and dismantle the power terminal.") + inputting = 0 //stop inputting, since we have don't have a terminal anymore + qdel(terminal) + return + + //crowbarring it ! default_deconstruction_crowbar(I) /obj/machinery/power/smes/Destroy() @@ -109,6 +185,13 @@ disconnect_terminal() ..() +// create a terminal object pointing towards the SMES +// wires will attach to this +/obj/machinery/power/smes/proc/make_terminal(var/turf/T) + terminal = new/obj/machinery/power/terminal(T) + terminal.dir = get_dir(T,src) + terminal.master = src + /obj/machinery/power/smes/disconnect_terminal() if(terminal) terminal.master = null From b7aea4f050b91f929ab41337c12f171ba40ba23a Mon Sep 17 00:00:00 2001 From: Menshin Date: Wed, 10 Sep 2014 13:16:47 +0200 Subject: [PATCH 2/2] Forgot to remove connecting from a cable for SMES (prevents inputting/outputting in the same powernet) --- code/modules/power/smes.dm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index c523c73dcc8..2f0e57e313d 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -83,12 +83,6 @@ terminal.master = src user << "Terminal found." break - if(!terminal) - for(var/obj/structure/cable/C in T) - if(C.d1 == turn(dir, 180) || C.d2 == turn(dir, 180)) - terminal = C - user << "Cable found." - break if(!terminal) user << "No power source found." return