diff --git a/code/modules/power/batteryrack.dm b/code/modules/power/batteryrack.dm index e7a46b60fdc..393e924a899 100644 --- a/code/modules/power/batteryrack.dm +++ b/code/modules/power/batteryrack.dm @@ -32,6 +32,29 @@ var/cells_amount = 0 var/capacitors_amount = 0 + // Smaller capacity, but higher I/O + // Starts fully charged, as it's used in substations. This replaces Engineering SMESs round start charge. +/obj/machinery/power/smes/batteryrack/substation + name = "Substation PSU" + desc = "A rack of power cells working as a PSU. This one seems to be equipped for higher power loads." + output = 150000 + chargelevel = 150000 + chargemode = 1 + online = 1 + + // One high capacity cell, two regular cells. Lots of room for engineer upgrades + // Also five basic capacitors. Again, upgradeable. +/obj/machinery/power/smes/batteryrack/substation/add_parts() + component_parts = list() + component_parts += new /obj/item/weapon/circuitboard/batteryrack + component_parts += new /obj/item/weapon/cell/high + component_parts += new /obj/item/weapon/cell + component_parts += new /obj/item/weapon/cell + component_parts += new /obj/item/weapon/stock_parts/capacitor + component_parts += new /obj/item/weapon/stock_parts/capacitor + component_parts += new /obj/item/weapon/stock_parts/capacitor + component_parts += new /obj/item/weapon/stock_parts/capacitor + component_parts += new /obj/item/weapon/stock_parts/capacitor /obj/machinery/power/smes/batteryrack/New() ..() @@ -224,7 +247,7 @@ var/load = min((capacity * 1.5 - charge)/SMESRATE, chargelevel) // charge at set rate, limited to spare capacity load = add_load(load) // add the load to the terminal side network charge += load * SMESRATE // increase the charge - + else // if not enough capacity charging = 0 // stop charging diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index c7b0e096a56..3446a1e98f4 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -1,8 +1,23 @@ // the SMES // stores power -#define SMESMAXCHARGELEVEL 200000 -#define SMESMAXOUTPUT 200000 +//Board +/obj/item/weapon/circuitboard/smes + name = "Circuit board (SMES Cell)" + build_path = "/obj/machinery/power/smes" + board_type = "machine" + origin_tech = "powerstorage=6;engineering=4" // Board itself is high tech. Coils have to be ordered from cargo or salvaged from existing SMESs. + frame_desc = "Requires 1 superconducting magnetic coil and 30 wires." + req_components = list("/obj/item/weapon/smes_coil" = 1, "/obj/item/stack/cable_coil" = 30) + +//Construction Item +/obj/item/weapon/smes_coil + name = "Superconducting Magnetic Coil" + desc = "Heavy duty superconducting magnetic coil, mainly used in construction of SMES units." + icon = 'icons/obj/stock_parts.dmi' + icon_state = "smes_coil" // Just few icons patched together. If someone wants to make better icon, feel free to do so! + w_class = 4.0 // It's LARGE (backpack size) + /obj/machinery/power/smes name = "power storage unit" @@ -11,15 +26,15 @@ density = 1 anchored = 1 use_power = 0 - var/output = 50000 //Amount of power it tries to output + var/output = 0 //Amount of power it tries to output var/lastout = 0 //Amount of power it actually outputs to the powernet var/loaddemand = 0 //For use in restore() var/capacity = 5e6 //Maximum amount of power it can hold - var/charge = 1e6 //Current amount of power it holds + var/charge = 0 //Current amount of power it holds var/charging = 0 //1 if it's actually charging, 0 if not var/chargemode = 0 //1 if it's trying to charge, 0 if not. //var/chargecount = 0 - var/chargelevel = 50000 //Amount of power it tries to charge from powernet + var/chargelevel = 0 //Amount of power it tries to charge from powernet var/online = 1 //1 if it's outputting power, 0 if not. var/name_tag = null var/obj/machinery/power/terminal/terminal = null @@ -29,15 +44,29 @@ var/last_online = 0 var/open_hatch = 0 var/building_terminal = 0 //Suggestions about how to avoid clickspam building several terminals accepted! - var/input_level_max = SMESMAXCHARGELEVEL - var/output_level_max = SMESMAXOUTPUT + var/input_level_max = 250000 // It is now coil amount based, so no need for DEFINE + var/output_level_max = 250000 + + var/storage_per_coil = 5000000 + var/IO_per_coil = 250000 + var/max_coils = 6 //30M capacity, 1.5MW input/output when fully upgraded + var/cur_coils = 1 // Current amount of installed coils /obj/machinery/power/smes/New() + component_parts = list() + component_parts += new /obj/item/stack/cable_coil(src,30) + component_parts += new /obj/item/weapon/circuitboard/smes(src) + + // Allows for mapped-in SMESs with larger capacity/IO + for(var/i = 1, i <= cur_coils, i++) + component_parts += new /obj/item/weapon/smes_coil(src) + ..() + recalc_coils() spawn(5) if(!powernet) connect_to_network() - + dir_loop: for(var/d in cardinal) var/turf/T = get_step(src, d) @@ -54,6 +83,15 @@ updateicon() return +/obj/machinery/power/smes/proc/recalc_coils() + if ((cur_coils <= max_coils) && (cur_coils >= 1)) + capacity = cur_coils * storage_per_coil + charge = between(0, charge, capacity) + output_level_max = cur_coils * IO_per_coil + output = between(0, output, output_level_max) + input_level_max = cur_coils * IO_per_coil + chargelevel = between(0, chargelevel, input_level_max) + /obj/machinery/power/smes/proc/updateicon() overlays.Cut() @@ -255,6 +293,40 @@ del(terminal) building_terminal = 0 + // PSUs have their own code in batteryrack.dm + else if(istype(W, /obj/item/weapon/crowbar) && !(istype(src, /obj/machinery/power/smes/batteryrack))) + if (charge < (capacity / 100)) + if (!online && !chargemode) + if (!terminal) + playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1) + usr << "\red You begin to disassemble the SMES cell!" + if (do_after(usr, 100 * cur_coils)) // More coils = takes longer to disassemble. It's complex so largest one with 5 coils will take 50s + usr << "\red You have disassembled the SMES cell!" + var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc) + M.state = 2 + M.icon_state = "box_1" + for(var/obj/I in component_parts) + if(I.reliability != 100 && crit_fail) + I.crit_fail = 1 + I.loc = src.loc + del(src) + return 1 + else + user << "You have to disassemble the terminal first!" + else + user << "Turn off the [src] before dismantling it." + else + user << "Better let [src] discharge before dismantling it." + else if(istype(W, /obj/item/weapon/smes_coil)) + if (cur_coils < 5) + usr << "You install the coil into the SMES unit!" + user.drop_item() + cur_coils ++ + component_parts += W + W.loc = src + recalc_coils() + else + usr << "\red You can't insert more coils to this SMES unit!" /obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) @@ -388,10 +460,10 @@ name = "magical power storage unit" desc = "A high-capacity superconducting magnetic energy storage (SMES) unit. Magically produces power." capacity = 9000000 - output = SMESMAXOUTPUT + output = 250000 /obj/machinery/power/smes/magical/process() - charge = 9000000 + charge = 5000000 ..() /proc/rate_control(var/S, var/V, var/C, var/Min=1, var/Max=5, var/Limit=null) diff --git a/icons/obj/stock_parts.dmi b/icons/obj/stock_parts.dmi index 77a6f9cfe2a..fec89e31a17 100644 Binary files a/icons/obj/stock_parts.dmi and b/icons/obj/stock_parts.dmi differ