Skip to content

Commit

Permalink
(+)Power sinks now kick back ~20% APC charge when disconnected. (enou…
Browse files Browse the repository at this point in the history
…gh that equipment breaker on auto should come back online, but lights need charging or to manually set the breaker on)
  • Loading branch information
Tarmunora committed Nov 5, 2021
1 parent 8e70de1 commit 51fb3c8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
33 changes: 26 additions & 7 deletions code/obj/item/device/powersink.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Powersink - used to drain station power
#define POWERSINK_OFF 0
#define POWERSINK_CLAMPED 1
#define POWERSINK_OPERATING 2

/obj/item/device/powersink
desc = "A nulling power sink which drains energy from electrical systems."
Expand All @@ -16,7 +19,7 @@
var/drain_rate = 400000 // amount of power to drain per tick
var/power_drained = 0 // has drained this much power
var/max_power = 2e8 // maximum power that can be drained before exploding
var/mode = 0 // 0 = off, 1=clamped (off), 2=operating
var/mode = POWERSINK_OFF // 0 = off, 1=clamped (off), 2=operating
is_syndicate = 1
mats = 16
rand_pos = 0
Expand All @@ -33,7 +36,7 @@

attackby(var/obj/item/I, var/mob/user)
if (isscrewingtool(I))
if(mode == 0)
if(mode == POWERSINK_OFF)
var/turf/T = loc
if(isturf(T) && !T.intact)
attached = locate() in T
Expand All @@ -42,7 +45,7 @@
return
else
anchored = 1
mode = 1
mode = POWERSINK_CLAMPED
boutput(user, "You attach the device to the cable.")
for(var/mob/M in AIviewers(user))
if(M == user) continue
Expand All @@ -52,8 +55,20 @@
boutput(user, "Device must be placed over an exposed cable to attach to it.")
return
else
if(attached && mode == POWERSINK_OPERATING) //give back some charge when disconnected
var/datum/powernet/PN = attached.get_powernet()
if(PN)
for(var/obj/machinery/power/terminal/T in PN.nodes)
if(istype(T.master, /obj/machinery/power/apc))
var/obj/machinery/power/apc/A = T.master
if(A.operating && A.cell)
var/charge_amt = max(0, A.cell.maxcharge/5 - A.cell.charge)
if(power_drained > charge_amt * 5)
power_drained -= charge_amt * 5
A.cell.charge += charge_amt

anchored = 0
mode = 0
mode = POWERSINK_OFF
boutput(user, "You detach the device from the cable.")
for(var/mob/M in AIviewers(user))
if(M == user) continue
Expand All @@ -71,15 +86,15 @@

attack_hand(var/mob/user)
switch(mode)
if(0)
if(POWERSINK_OFF)
..()

if(1)
if(POWERSINK_CLAMPED)
boutput(user, "You activate the device!")
for(var/mob/M in AIviewers(user))
if(M == user) continue
boutput(M, "[user] activates the power sink!")
mode = 2
mode = POWERSINK_OPERATING
icon_state = "powersink1"
processing_items |= src
logTheThing("combat", user, src, "activated [src] at [log_loc(src)].")
Expand Down Expand Up @@ -115,3 +130,7 @@
processing_items.Remove(src)
explosion(src, src.loc, 3,6,9,12)
qdel(src)

#undef POWERSINK_OFF
#undef POWERSINK_CLAMPED
#undef POWERSINK_OPERATING
3 changes: 3 additions & 0 deletions strings/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

(t)fri nov 05 21
(u)tarmunora
(e)⚖|balance
(+)Power sinks now kick back ~20% APC charge when disconnected.
(u)FlamingLily
(p)6543
(e)|
Expand Down

0 comments on commit 51fb3c8

Please sign in to comment.