Files
Aurora.3/code/modules/shieldgen/shield_capacitor.dm
T
b3b4f4b9c6 INDRA, general nuclear fusion update (#21285)
Fixes https://github.com/Aurorastation/Aurora.3/issues/18951
Fixes https://github.com/Aurorastation/Aurora.3/issues/19447
Fixes https://github.com/Aurorastation/Aurora.3/issues/20283
Fixes https://github.com/Aurorastation/Aurora.3/issues/21395

Overhauls a wide variety of INDRA behaviors and related gas/material
properties.
changes:
- balance: "Fusion reaction modifications. Higher radiation and
temperature output, comparable power output."
- balance: "Increased rad resistance modifier of Borosilicate Windows
from 1 -> 4 and (closed) Blast Doors from 1 -> 6."
- balance: "INDRA Field Strength minima/maxima changed from 1-100 ->
20-120. Power costs increased significantly."
- balance: "INDRA instability increase per tick now limited, similar to
Supermatter (prevents sudden instability spike from instantly nuking
it)."
  - balance: "APC cell charge rate increased 10x."
  - balance: "Rebalanced contents of INDRA hard storage compartment."
  - balance: "SMES coils capacities halved, throughputs doubled."
  - balance: "SMES unit maximum coil capacity increased from 6 -> 8."
- balance: "TEG maximum power output increased from 500000 -> 2500000."
- balance: "Power wasted from exceeding TEG maximum power output
decreased from 50% to 33%."
- balance: "Portable generators of all types have had their power
generation capacity doubled."
- rscadd: "New 'Fusion Codex' app added for all crew with ACCESS_ENGINE
that details all available nuclear fusion chains."
- rscadd: "Boron added as a singleton/reagent. Poisonous to vaurca,
still usable in nuclear fusion as fuel assembly rods."
- rscadd: "INDRA Field Strength now scales plasma temperature entropy,
power output from temperature multiplier, and instability increase per
tick."
- refactor: "'Boron' gas renamed to 'Helium-3'. Boron is not a gas. Deal
with it."
  - refactor: "'Steam' gas renamed to 'Water Vapor'."
  - code_imp: "Descriptions added to gas singletons for future use."
  - qol: "Minor remap of INDRA control room for usability."
  - qol: "Standardized gas canister naming conventions."
- qol: "INDRA and APC TGUI interfaces now use use kW, MW abbreviations
for high wattages."
- bugfix: "INDRA Kinetic Harvester no longer rapidly deselects materials
for harvest when too many are being generated at once."
- bugfix: "INDRA EM Field effect no longer considers the camera within
its reactor chamber a destabilizing influence."
  - bugfix: "INDRA reactor core now produces radiation as intended."
- bugfix: "Deuterium and Tritium canisters no longer contain 50%
standard hydrogen (inheritance issue)."

---------

Signed-off-by: Batrachophreno <Batrochophreno@gmail.com>
Co-authored-by: Matt Atlas <mattiathebest2000@hotmail.it>
Co-authored-by: Geeves <22774890+Geevies@users.noreply.github.com>
2025-10-05 20:13:06 +00:00

142 lines
3.9 KiB
Plaintext

/obj/machinery/shield_capacitor
name = "shield capacitor"
desc = "Machine that charges a shield generator."
icon = 'icons/obj/machinery/shielding.dmi'
icon_state = "capacitor"
obj_flags = OBJ_FLAG_ROTATABLE
density = TRUE
/// Doesn't use APC power.
use_power = POWER_USE_OFF
req_one_access = list(ACCESS_CAPTAIN, ACCESS_SECURITY, ACCESS_ENGINE)
var/active = FALSE
/// Not to be confused with power cell charge, this is in Joules.
var/stored_charge = 0
var/last_stored_charge = 0
var/time_since_fail = 100
var/max_charge = 8e6 //8 MJ
var/max_charge_rate = 400000 //400 kW
var/locked = FALSE
var/charge_rate = 100000 //100 kW
var/obj/machinery/shield_gen/owned_gen
/obj/machinery/shield_capacitor/Initialize()
..()
return INITIALIZE_HINT_LATELOAD
/obj/machinery/shield_capacitor/LateInitialize()
. = ..()
for(var/obj/machinery/shield_gen/possible_gen in range(1, src))
if(get_dir(src, possible_gen) == dir)
possible_gen.owned_capacitor = src
break
/obj/machinery/shield_capacitor/emag_act(var/remaining_charges, var/mob/user)
if(prob(75))
locked = !locked
to_chat(user, "Controls are now [locked ? "locked." : "unlocked."]")
. = TRUE
updateDialog()
spark(src, 5, GLOB.alldirs)
/obj/machinery/shield_capacitor/attackby(obj/item/attacking_item, mob/user)
if(istype(attacking_item, /obj/item/card/id))
if(allowed(user))
locked = !locked
to_chat(user, "Controls are now [locked ? "locked." : "unlocked."]")
updateDialog()
else
to_chat(user, SPAN_ALERT("Access denied."))
else if(attacking_item.iswrench())
anchored = !anchored
visible_message(SPAN_NOTICE("\The [src] has been [anchored ? "bolted to the floor" : "unbolted from the floor"] by \the [user]."))
if(anchored)
for(var/obj/machinery/shield_gen/gen in range(1, src))
if(get_dir(src, gen) == src.dir && !gen.owned_capacitor)
owned_gen = gen
owned_gen.owned_capacitor = src
owned_gen.updateDialog()
else
if(owned_gen && owned_gen.owned_capacitor == src)
owned_gen.owned_capacitor = null
owned_gen = null
else
..()
/obj/machinery/shield_capacitor/attack_hand(mob/user)
if(stat & (BROKEN))
return
ui_interact(user)
/obj/machinery/shield_capacitor/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ShieldCapacitor", "Shield Capacitor", 400, 300)
ui.open()
/obj/machinery/shield_capacitor/ui_data(mob/user)
var/list/data = list()
data["anchored"] = anchored
data["locked"] = locked
data["active"] = active
data["time_since_fail"] = time_since_fail
data["charge_rate"] = charge_rate
data["stored_charge"] = stored_charge
data["max_charge"] = max_charge
data["max_charge_rate"] = max_charge_rate
return data
/obj/machinery/shield_capacitor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
switch(action)
if("toggle")
if(!active && !anchored)
to_chat(usr, SPAN_WARNING("\The [src] needs to be firmly secured to the floor first."))
return
active = !active
. = TRUE
if("charge_rate")
charge_rate = between(10000, params["charge_rate"], max_charge_rate)
. = TRUE
/obj/machinery/shield_capacitor/process()
if (!anchored)
active = FALSE
//see if we can connect to a power net.
var/datum/powernet/PN
var/turf/T = loc
if (!istype(T))
active = FALSE
return
var/obj/structure/cable/C = T.get_cable_node()
if (C)
PN = C.powernet
if (PN)
var/power_draw = between(0, max_charge - stored_charge, charge_rate) //what we are trying to draw
power_draw = PN.draw_power(power_draw) //what we actually get
stored_charge += power_draw
time_since_fail++
if(stored_charge < last_stored_charge)
time_since_fail = 0 //losing charge faster than we can draw from PN
last_stored_charge = stored_charge
/obj/machinery/shield_capacitor/power_change()
if(stat & BROKEN)
icon_state = "broke"
else
..()
/obj/machinery/shield_capacitor/multiz
max_charge_rate = 1250000