SMES Destruction (#11075)

This commit is contained in:
Geeves
2021-01-30 15:58:25 +01:00
committed by GitHub
parent 578101775a
commit b20403b2f8
3 changed files with 77 additions and 6 deletions
+31 -5
View File
@@ -21,12 +21,16 @@
/obj/machinery/power/smes
name = "power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit."
desc_info = "It can be repaired with a welding tool."
icon_state = "smes"
density = 1
anchored = 1
use_power = 0
clicksound = /decl/sound_category/switch_sound
var/health = 500
var/busted = FALSE // this it to prevent the damage text from playing repeatedly
var/capacity = 5e6 // maximum charge
var/charge = 1e6 // actual charge
var/max_coils = 0
@@ -116,6 +120,8 @@
/obj/machinery/power/smes/examine(mob/user)
. = ..()
if(is_badly_damaged())
to_chat(user, SPAN_DANGER("\The [src] is damaged to the point of non-function!"))
if(open_hatch)
to_chat(user, SPAN_SUBTLE("The maintenance hatch is open."))
if (max_coils > 1 && Adjacent(user))
@@ -124,6 +130,18 @@
coils += C
to_chat(user, "The [max_coils] coil slots contain: [counting_english_list(coils)]")
/obj/machinery/power/smes/proc/can_function()
if(is_badly_damaged())
return FALSE
if(stat & BROKEN)
return FALSE
return TRUE
/obj/machinery/power/smes/proc/is_badly_damaged()
if(health < initial(health) / 5)
return TRUE
return FALSE
/obj/machinery/power/smes/add_avail(var/amount)
if(..(amount))
powernet.smes_newavail += amount
@@ -140,7 +158,7 @@
/obj/machinery/power/smes/update_icon()
cut_overlays()
if(stat & BROKEN)
if(!can_function())
return
if(inputting == 2)
@@ -196,7 +214,8 @@
time = ((time_secs / 3600) > 1) ? ("[round(time_secs / 3600)] hours, [round((time_secs % 3600) / 60)] minutes") : ("[round(time_secs / 60)] minutes, [round(time_secs % 60)] seconds")
/obj/machinery/power/smes/machinery_process()
if(stat & BROKEN) return
if(!can_function())
return
if(failure_timer) // Disabled by gridcheck.
failure_timer--
return
@@ -236,7 +255,7 @@
// called after all power processes are finished
// restores charge level to smes if there was excess this ptick
/obj/machinery/power/smes/proc/restore(var/percent_load)
if(stat & BROKEN)
if(!can_function())
return
if(!outputting)
@@ -310,6 +329,9 @@
/obj/machinery/power/smes/attackby(var/obj/item/W as obj, var/mob/user as mob)
if(W.isscrewdriver())
if(!open_hatch)
if(is_badly_damaged())
to_chat(user, SPAN_WARNING("\The [src]'s maintenance panel is broken open!"))
return
open_hatch = 1
user.visible_message(\
"<span class='notice'>\The [user] opens the maintenance hatch of \the [src].</span>",\
@@ -372,8 +394,12 @@
return 1
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(stat & BROKEN)
if(!can_function())
if(!terminal)
to_chat(user, SPAN_WARNING("\The [src] is lacking a terminal!"))
return
if(is_badly_damaged())
to_chat(user, SPAN_WARNING("\The [src] is too damaged to function!"))
return
// this is the data which will be sent to the ui
+40 -1
View File
@@ -87,6 +87,29 @@
SSmachinery.queue_rcon_update()
return ..()
/obj/machinery/power/smes/buildable/bullet_act(obj/item/projectile/P, def_zone)
. = ..()
visible_message(SPAN_WARNING("\The [src] is hit by \the [P]!"))
health_check(P.damage)
/obj/machinery/power/smes/buildable/proc/health_check(var/health_reduction = 0)
health -= health_reduction
if(health < 0)
visible_message(SPAN_DANGER("\The [src] blows apart!"))
for(var/thing in component_parts)
var/obj/O = thing
if(prob(40))
O.forceMove(loc)
O.throw_at_random(FALSE, 3, THROWNOBJ_KNOCKBACK_SPEED)
else
qdel(O)
explosion(loc, 1, 2, 4, 8) //copied from the catastrophic failure code
qdel(src)
else if(is_badly_damaged() && !busted)
busted = TRUE
open_hatch = TRUE
visible_message(SPAN_DANGER("\The [src]'s maintenance hatch [open_hatch ? "releases a torrent of sparks" : "blows open with a flurry of sparks"]!"))
// Proc: process()
// Parameters: None
// Description: Uses parent process, but if grounding wire is cut causes sparks to fly around.
@@ -316,7 +339,23 @@
// - Hatch is open, so we can modify the SMES
// - No action was taken in parent function (terminal de/construction atm).
if (..())
if(W.iswelder())
if(health == initial(health))
to_chat(user, SPAN_WARNING("\The [src] is already repaired."))
return
var/obj/item/weldingtool/WT = W
if(!WT.welding)
to_chat(user, SPAN_WARNING("\The [src] isn't lit."))
return
if(WT.get_fuel() < 2)
to_chat(user, SPAN_WARNING("You don't have enough fuel to repair \the [src]."))
return
if(do_after(user, 5 SECONDS) && WT.remove_fuel(2, user))
health = min(health + 100, initial(health))
to_chat(user, SPAN_NOTICE("You repair \the [src], it is now [round((health / initial(health)) * 100)]% repaired."))
if(health == initial(health))
busted = FALSE
return
// Multitool - change RCON tag
if(W.ismultitool())
var/newtag = input(user, "Enter new RCON tag. Use \"NO_TAG\" to disable RCON or leave empty to cancel.", "SMES RCON system") as text