Merge pull request #4684 from Menshin/SMES_terminal_2

SMES constructible terminals (reopen)
This commit is contained in:
Remie Richards
2014-09-19 16:41:36 +01:00
+83 -6
View File
@@ -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)
@@ -81,12 +83,6 @@
terminal.master = src
user << "<span class='notice'>Terminal found.</span>"
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 << "<span class='notice'>Cable found.</span>"
break
if(!terminal)
user << "<span class='alert'>No power source found.</span>"
return
@@ -94,9 +90,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 << "<span class='alert'>This SMES already have a power terminal!</span>"
return
if(!panel_open) //is the panel open ?
user << "<span class='alert'>You must open the maintenance panel first!</span>"
return
var/turf/T = get_turf(user)
if (T.intact) //is the floor plating removed ?
user << "<span class='alert'>You must first remove the floor plating!</span>"
return
var/obj/item/stack/cable_coil/C = I
if(C.amount < 10)
user << "<span class='alert'>You need more wires.</span>"
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(\
"<span class='alert'>[user.name] has build a power terminal!</span>",\
"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 << "<span class='alert'>You must first expose the power terminal!</span>"
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(\
"<span class='alert'>[user.name] cuts the cables and dismantles the power terminal.</span>",\
"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 +179,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