BSA now checks if the APC has enough power to reload (#27012)

* BSA now checks if the APC has enough power to reload.

* Update bsa.dm

* removes a redundant instance of setting firing cooldown to a nonsensical value

* Update bsa.dm
This commit is contained in:
Migratingcocofruit
2024-10-29 19:25:14 +02:00
committed by GitHub
parent 41f44ea833
commit 647df9541f
+19 -7
View File
@@ -115,9 +115,12 @@
var/cannon_direction = WEST
var/static/image/top_layer = null
var/ex_power = 3
var/power_used_per_shot = 2000000 //enough to kil standard apc - todo : make this use wires instead and scale explosion power with it
/// Amount of energy required to reload the BSA (Joules)
var/energy_used_per_shot = 2 MJ //enough to kil standard apc - todo : make this use wires instead and scale explosion power with it
/// The gun's cooldown
var/reload_cooldown_time = 10 MINUTES
var/reload_cooldown_time = 10 MINUTES
/// Are we trying to reload? Should only be true if we failed to reload due to lack of power.
var/try_reload = FALSE
COOLDOWN_DECLARE(firing_cooldown)
pixel_y = -32
@@ -136,7 +139,7 @@
cannon_direction = EAST
/obj/machinery/bsa/full/admin
power_used_per_shot = 0
energy_used_per_shot = 0
reload_cooldown_time = 100 SECONDS
/obj/machinery/bsa/full/admin/east
@@ -221,8 +224,17 @@
reload()
/obj/machinery/bsa/full/proc/reload()
use_power(power_used_per_shot)
COOLDOWN_START(src, firing_cooldown, reload_cooldown_time)
if(machine_powernet?.powernet_apc?.cell?.charge KJ >= energy_used_per_shot)
try_reload = FALSE
use_power(energy_used_per_shot)
COOLDOWN_START(src, firing_cooldown, reload_cooldown_time)
else
try_reload = TRUE
/// If we failed a reload keep trying until the APC has enough energy available.
/obj/machinery/bsa/full/process()
if(try_reload)
reload()
/obj/item/circuitboard/machine/bsa/back
board_name = "Bluespace Artillery Generator"
@@ -330,8 +342,8 @@
if(target)
data["target"] = get_target_name()
if(cannon)
data["reloadtime_text"] = seconds_to_clock(round(COOLDOWN_TIMELEFT(cannon, firing_cooldown) / 10))
data["ready"] = COOLDOWN_FINISHED(cannon, firing_cooldown)
data["reloadtime_text"] = cannon.try_reload ? "Insufficient Energy For Reloading" : seconds_to_clock(round(COOLDOWN_TIMELEFT(cannon, firing_cooldown) / 10))
data["ready"] = !cannon.try_reload && COOLDOWN_FINISHED(cannon, firing_cooldown)
else
data["ready"] = FALSE
return data