Files
vgstation13/code/modules/power/terminal.dm
ComicIronic 2bf2ea1f6f SMES Cleanup + Portable Batteries
SMESs now fall under a battery type, which is a charge-storing power machine.
The battery charges and outputs in an OOP way.
SMESs now make terminals in the general way, which is also used for APCs.
Terminal is now a power machinery level var.
Currently impossible to get but fully functional are portable batteries.

Portable batteries:
 - Only work when connected to battery ports, but can be pushed around otherwise
 - Charge from the battery port's terminal, and output onto its tile, like SMESs.
 - That's basically it. What more do you want? It's a movable SMES, essentially.

Known issue with the portable batteries: they don't show load in the UI, because they never proc resolve(), but it's not major.
2015-05-20 16:26:30 +01:00

79 lines
2.2 KiB
Plaintext

// the underfloor wiring terminal for the APC
// autogenerated when an APC is placed
// all conduit connects go to this object instead of the APC
// using this solves the problem of having the APC in a wall yet also inside an area
/obj/machinery/power/terminal
name = "terminal"
icon_state = "term"
desc = "It's an underfloor wiring terminal for power equipment."
level = 1
layer = TURF_LAYER
var/obj/machinery/power/master
anchored = 1
layer = 2.6 // a bit above wires
/obj/machinery/power/terminal/New()
..()
var/turf/T = src.loc
if(level==1) hide(T.intact)
return
/obj/machinery/power/terminal/hide(var/i)
if(i)
invisibility = 101
icon_state = "term-f"
else
invisibility = 0
icon_state = "term"
/obj/machinery/power/terminal/Destroy()
if (master)
master:terminal = null
master = null
..()
/obj/machinery/power/terminal/attackby(obj/item/W, mob/user)
if(iswirecutter(W) && !master) //Sanity in the rare case something destroys a machine and leaves a terminal
getFromPool(/obj/item/stack/cable_coil, get_turf(src), 10)
qdel(src)
return
..()
/obj/machinery/power/proc/make_terminal(mob/user)
if(!can_attach_terminal(user))
user << "<span class='warning'>You can't wire \the [src] like that!</span>"
return 0
var/turf/T = get_turf(user)
if(T.intact)
user << "<span class='warning'>The floor plating must be removed first.</span>"
return 0
user << "<span class='notice'>You start adding cable to \the [src].</span>"
playsound(get_turf(src), 'sound/items/zip.ogg', 100, 1)
if (do_after(user, 100) && !T.intact && can_attach_terminal(user))
//Shock chance
var/obj/structure/cable/N = T.get_cable_node()
if (prob(50) && electrocute_mob(user, N, N))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
return 0
finalise_terminal(get_turf(user))
return 1
return 0
/obj/machinery/power/proc/finalise_terminal(newloc)
terminal = new /obj/machinery/power/terminal(newloc)
terminal.dir = get_dir(newloc, src)
terminal.master = src
/obj/machinery/power/proc/can_attach_terminal(mob/user)
return user.loc != src.loc && (get_dir(user, src) in cardinal) && !terminal