Files
Polaris/code/game/objects/structures/electricchair.dm
Leshana ccef6cc908 Implements "static" area machinery power usage
- Instead of using auto_use_power to re-tally up machinery's power usage every cycle, track the steady "static" load separately from the transient "oneoff" usage.  Machines then only need to inform the area when they use oneoff power or *change* their steady usage.
- Remove auto_use_power and stop SSmachines from calling it.
- Add vars to track "static" usage for each of the three power channels to /area
- Rename the existing three vars to "oneoff" so its clear what they mean (and to catch people accidentally updating them directly)
- Update area power procs and APCs to use the new variables.
- Rename /area/proc/use_power() to use_power_oneoff() to make it clear what it is doing.
- Deprecate /obj/machinery/use_power() in favor of use_power_oneoff() but don't delete yet.  Can transition gradually.
- Add logic to the update_power procs on machines to calculate the deltas and update static area power whenever their usage changes.
- Add logic to machines to update area power when they are created, destroyed, or move.
- Moved /obj/machinery procs related to area power usage into machinery_power.dm to make them easier to find.
- Added or updated comments in several places to explain what is going on and how to use it.
2020-05-19 20:17:48 -04:00

80 lines
2.0 KiB
Plaintext

/obj/structure/bed/chair/e_chair
name = "electric chair"
desc = "Looks absolutely SHOCKING!"
icon_state = "echair0"
var/on = 0
var/obj/item/assembly/shock_kit/part = null
var/last_time = 1.0
/obj/structure/bed/chair/e_chair/New()
..()
overlays += image('icons/obj/objects.dmi', src, "echair_over", MOB_LAYER + 1, dir)
return
/obj/structure/bed/chair/e_chair/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(W.is_wrench())
var/obj/structure/bed/chair/C = new /obj/structure/bed/chair(loc)
playsound(src, W.usesound, 50, 1)
C.set_dir(dir)
part.loc = loc
part.master = null
part = null
qdel(src)
return
return
/obj/structure/bed/chair/e_chair/verb/toggle()
set name = "Toggle Electric Chair"
set category = "Object"
set src in oview(1)
if(on)
on = 0
icon_state = "echair0"
else
on = 1
icon_state = "echair1"
to_chat(usr, "<span class='notice'>You switch [on ? "on" : "off"] [src].</span>")
return
/obj/structure/bed/chair/e_chair/rotate_clockwise()
..()
overlays.Cut()
overlays += image('icons/obj/objects.dmi', src, "echair_over", MOB_LAYER + 1, dir) //there's probably a better way of handling this, but eh. -Pete
return
/obj/structure/bed/chair/e_chair/proc/shock()
if(!on)
return
if(last_time + 50 > world.time)
return
last_time = world.time
// special power handling
var/area/A = get_area(src)
if(!isarea(A))
return
if(!A.powered(EQUIP))
return
A.use_power_oneoff(5000, EQUIP)
var/light = A.power_light
A.updateicon()
flick("echair1", src)
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(12, 1, src)
s.start()
if(has_buckled_mobs())
for(var/a in buckled_mobs)
var/mob/living/L = a
L.burn_skin(85)
to_chat(L, "<span class='danger'>You feel a deep shock course through your body!</span>")
sleep(1)
L.burn_skin(85)
L.Stun(600)
visible_message("<span class='danger'>The electric chair went off!</span>", "<span class='danger'>You hear a deep sharp shock!</span>")
A.power_light = light
A.updateicon()
return