Exosuit Nuclear Power Cores (#18268)

* Added power cores, a type of large battery cell that get used by
exosuits. The nuclear and phoron variants are self-charging.
* Combat mechs now start with nuclear power cores, allowing them to
sustain themselves indefinitely, so long as they stay out of the action
for a bit.
* Removed basic power cells from the mechfab, replaced with the mech
powercores.
* Mech cell statuses now instantly update as soon as the cell charges or
discharges.
* Added a stack of 10 uranium to the machinist's workshop, which can
print two nuclear power cores.
This commit is contained in:
Geeves
2024-06-09 23:14:59 +02:00
committed by GitHub
parent 566aeaa2da
commit 2bf39c7ee9
22 changed files with 178 additions and 74 deletions

View File

@@ -159,6 +159,7 @@
#include "code\__DEFINES\dcs\signals\signals_atom\signals_atom_movable.dm"
#include "code\__DEFINES\dcs\signals\signals_atom\signals_atom_movement.dm"
#include "code\__DEFINES\dcs\signals\signals_atom\signals_atom_x_act.dm"
#include "code\__DEFINES\dcs\signals\signals_atom\signals_power_cell.dm"
#include "code\__DEFINES\dcs\signals\signals_mob\signals_mob_living.dm"
#include "code\__DEFINES\dcs\signals\signals_mob\signals_mob_main.dm"
#include "code\__DEFINES\dcs\signals\signals_object\signals_object.dm"

View File

@@ -0,0 +1,5 @@
// Signals related to charge level of power cells
// Sent from cell.dm
/// This is fired whenever a cell's charge changes. The data attached is the integer value of the cell's charge
#define COMSIG_CELL_CHARGE "cell_charge"

View File

@@ -166,6 +166,9 @@
if(cell)
to_chat(user, SPAN_WARNING("There is \a [cell] already installed here."))
else
if(attacking_item.w_class != ITEMSIZE_NORMAL)
to_chat(user, SPAN_WARNING("\The [attacking_item] is too [attacking_item.w_class < ITEMSIZE_NORMAL ? "small" : "large"] to fit here."))
return
user.drop_from_inventory(attacking_item,src)
cell = attacking_item
to_chat(user, SPAN_NOTICE("You insert \the [cell]."))

View File

@@ -17,6 +17,9 @@
matter = list(DEFAULT_WALL_MATERIAL = 700, MATERIAL_GLASS = 50)
recyclable = TRUE
/// Percentage of maxcharge to recharge per minute, though it will trickle charge every process tick (every ~2 seconds), leave null for no self-recharge
var/self_charge_percentage
/// Smaller variant, used by energy guns and similar small devices
/obj/item/cell/device
name = "device power cell"
@@ -82,13 +85,6 @@
maxcharge = 10000
matter = list(DEFAULT_WALL_MATERIAL = 700, MATERIAL_GLASS = 60)
/obj/item/cell/mecha
name = "exosuit-grade power cell"
origin_tech = list(TECH_POWER = 3)
icon_state = "hcell"
maxcharge = 15000
matter = list(DEFAULT_WALL_MATERIAL = 700, MATERIAL_GLASS = 70)
/obj/item/cell/high/empty/Initialize()
. = ..()
charge = 0
@@ -151,42 +147,20 @@
icon_state = "yellow slime extract"
maxcharge = 15000
matter = null
var/next_recharge
/obj/item/cell/slime/Initialize()
. = ..()
START_PROCESSING(SSprocessing, src)
/obj/item/cell/slime/Destroy()
STOP_PROCESSING(SSprocessing, src)
return ..()
/obj/item/cell/slime/process()
if(next_recharge < world.time)
charge = min(charge + (maxcharge / 10), maxcharge)
next_recharge = world.time + 1 MINUTE
// slime cores recharges 10% every one minute
self_charge_percentage = 10
/obj/item/cell/nuclear
name = "miniaturized nuclear power core"
desc = "A small self-charging thorium core that can store an immense amount of charge."
name = "miniaturized nuclear power cell"
desc = "A small self-charging cell with a thorium core that can store an immense amount of charge."
origin_tech = list(TECH_POWER = 8, TECH_ILLEGAL = 4)
icon_state = "icell"
maxcharge = 50000
matter = null
var/next_recharge
/obj/item/cell/nuclear/Initialize()
. = ..()
START_PROCESSING(SSprocessing, src)
/obj/item/cell/nuclear/Destroy()
STOP_PROCESSING(SSprocessing, src)
return ..()
/obj/item/cell/nuclear/process()
if(next_recharge < world.time)
charge = min(charge + (maxcharge / 10), maxcharge)
next_recharge = world.time + 30 SECONDS
// nuclear cores recharges 20% every one minute
self_charge_percentage = 10
/obj/item/cell/device/emergency_light
name = "miniature power cell"
@@ -222,3 +196,31 @@
drop_sound = 'sound/items/drop/gascan.ogg'
pickup_sound = 'sound/items/pickup/gascan.ogg'
origin_tech = list(TECH_POWER = 4)
/obj/item/cell/mecha
name = "power core"
origin_tech = list(TECH_POWER = 2)
icon_state = "core"
w_class = ITEMSIZE_LARGE
maxcharge = 20000
matter = list(DEFAULT_WALL_MATERIAL = 20000, MATERIAL_GLASS = 10000)
/obj/item/cell/mecha/nuclear
name = "nuclear power core"
origin_tech = list(TECH_POWER = 3, TECH_MATERIAL = 3)
icon_state = "nuclear_core"
maxcharge = 30000
matter = list(DEFAULT_WALL_MATERIAL = 20000, MATERIAL_GLASS = 10000, MATERIAL_URANIUM = 10000)
// nuclear mecha cores recharges 5% every one minute
self_charge_percentage = 5
/obj/item/cell/mecha/phoron
name = "phoron power core"
origin_tech = list(TECH_POWER = 5, TECH_MATERIAL = 5)
icon_state = "phoron_core"
maxcharge = 50000
matter = list(DEFAULT_WALL_MATERIAL = 20000, MATERIAL_GLASS = 10000, MATERIAL_PHORON = 5000)
// nuclear mecha cores recharges 10% every one minute
self_charge_percentage = 10

View File

@@ -70,6 +70,9 @@
/obj/item/melee/baton/attackby(obj/item/attacking_item, mob/user)
if(istype(attacking_item, /obj/item/cell))
if(attacking_item.w_class != ITEMSIZE_NORMAL)
to_chat(user, SPAN_WARNING("\The [attacking_item] is too [attacking_item.w_class < ITEMSIZE_NORMAL ? "small" : "large"] to fit here."))
return
if(!bcell)
user.drop_from_inventory(attacking_item, src)
bcell = attacking_item

View File

@@ -30,10 +30,12 @@
icon = 'icons/obj/random.dmi'
icon_state = "cell"
problist = list(
/obj/item/cell/crap = 10,
/obj/item/cell = 40,
/obj/item/cell/high = 40,
/obj/item/cell/crap = 10,
/obj/item/cell/mecha = 10,
/obj/item/cell/super = 9,
/obj/item/cell/mecha/nuclear = 5,
/obj/item/cell/hyper = 1
)

View File

@@ -17,7 +17,8 @@
var/mech_health = 600
var/obj/item/robot_parts/robot_component/diagnosis_unit/diagnostics
var/obj/item/cell/cell
var/obj/item/cell/mecha/cell
var/cell_type = /obj/item/cell/mecha
var/obj/item/robot_parts/robot_component/armor/mech_armor
var/obj/machinery/portable_atmospherics/canister/air_supply
var/datum/gas_mixture/cockpit
@@ -120,8 +121,9 @@
/obj/item/mech_component/chassis/prebuild()
diagnostics = new(src)
cell = new /obj/item/cell/mecha(src)
cell.charge = cell.maxcharge
if(cell_type)
cell = new cell_type(src)
cell.charge = cell.maxcharge
/obj/item/mech_component/chassis/attackby(obj/item/attacking_item, mob/user)
if(istype(attacking_item, /obj/item/robot_parts/robot_component/diagnosis_unit))

View File

@@ -65,19 +65,7 @@
var/obj/screen/mecha/hardpoint/H = hardpoint_hud_elements[hardpoint]
if(H) H.update_system_info()
handle_hud_icons_health()
var/obj/item/cell/C = get_cell()
if(istype(C))
var/power_percentage = round((get_cell()?.charge / get_cell()?.maxcharge) * 100)
if(power_percentage >= 100)
hud_power?.maptext_x = 21
else if(power_percentage < 10)
hud_power?.maptext_x = 25
else if(power_percentage < 100)
hud_power?.maptext_x = 22
hud_power.maptext = "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 8px;\">[power_percentage]%</span>"
else
hud_power?.maptext_x = 13
hud_power?.maptext = "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 7px;\">NO CELL</span>"
handle_power_hud()
refresh_hud()
@@ -120,3 +108,18 @@
GLOB.mecha_damage_overlay_cache["[part]-[state]"] = I
hud_health?.overlays |= GLOB.mecha_damage_overlay_cache["[part]-[state]"]
/mob/living/heavy_vehicle/proc/handle_power_hud()
var/obj/item/cell/C = get_cell()
if(istype(C))
var/power_percentage = round((get_cell()?.charge / get_cell()?.maxcharge) * 100)
if(power_percentage >= 100)
hud_power?.maptext_x = 21
else if(power_percentage < 10)
hud_power?.maptext_x = 25
else
hud_power?.maptext_x = 22
hud_power?.maptext = "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 8px;\">[power_percentage]%</span>"
else
hud_power?.maptext_x = 13
hud_power?.maptext = "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 7px;\">NO CELL</span>"

View File

@@ -65,10 +65,12 @@
return
var/obj/structure/heavy_vehicle_frame/frame = dest
if(istype(frame))
frame.body = body
if(body.cell)
UnregisterSignal(body.cell, COMSIG_CELL_CHARGE)
body.forceMove(dest)
body = null

View File

@@ -445,9 +445,13 @@
visible_message(SPAN_NOTICE("\The [user] pries out \the [body.cell] using the \the [attacking_item]."))
power = MECH_POWER_OFF
hud_power_control.update_icon()
UnregisterSignal(body.cell, COMSIG_CELL_CHARGE)
body.cell = null
return
else if(istype(attacking_item, /obj/item/cell))
if(!istype(attacking_item, /obj/item/cell/mecha))
to_chat(user, SPAN_WARNING("You can only use power cores in \the [src]!"))
return
if(!maintenance_protocols)
to_chat(user, SPAN_WARNING("The cell compartment remains locked while maintenance protocols are disabled."))
return
@@ -458,9 +462,9 @@
if(user.unEquip(attacking_item))
attacking_item.forceMove(body)
body.cell = attacking_item
to_chat(user, SPAN_NOTICE("You install \the [body.cell] into \the [src]."))
RegisterSignal(body.cell, COMSIG_CELL_CHARGE, PROC_REF(handle_cell_charge))
playsound(user.loc, 'sound/items/Screwdriver.ogg', 50, 1)
visible_message(SPAN_NOTICE("\The [user] installs \the [body.cell] into \the [src]."))
user.visible_message(SPAN_NOTICE("\The [user] installs \the [body.cell] into \the [src]."), SPAN_NOTICE("You install \the [body.cell] into \the [src]."))
return
else if(istype(attacking_item, /obj/item/device/robotanalyzer))
to_chat(user, SPAN_NOTICE("Diagnostic Report for \the [src]:"))
@@ -730,3 +734,8 @@
say("Following [ID.registered_name].")
break
return
/mob/living/heavy_vehicle/proc/handle_cell_charge(var/obj/item/cell/cell, var/new_charge)
SIGNAL_HANDLER
handle_power_hud()

View File

@@ -208,6 +208,8 @@
if(source_frame.body)
source_frame.body.forceMove(src)
body = source_frame.body
if(body.cell)
RegisterSignal(body.cell, COMSIG_CELL_CHARGE, PROC_REF(handle_cell_charge))
updatehealth()

View File

@@ -41,6 +41,8 @@
head.color = e_color
if(!body && e_body)
body = new e_body(src)
if(body.cell)
RegisterSignal(body.cell, COMSIG_CELL_CHARGE, PROC_REF(handle_cell_charge))
if(e_color)
body.color = e_color
if(!arms && e_arms)

View File

@@ -59,6 +59,8 @@
has_hardpoints = list(HARDPOINT_BACK)
power_use = 500
cell_type = /obj/item/cell/mecha/nuclear
/obj/item/mech_component/chassis/heavy/prebuild()
. = ..()
mech_armor = new /obj/item/robot_parts/robot_component/armor/mech/combat(src)

View File

@@ -76,12 +76,16 @@
)
. = ..()
/obj/item/mech_component/chassis/light/nuclear
cell_type = /obj/item/cell/mecha/nuclear
/mob/living/heavy_vehicle/premade/light/legion
name = "legion support exosuit"
desc = "A light and agile exosuit painted in the colours of the Tau Ceti Foreign Legion."
icon_state = "odysseus"
e_color = COLOR_TCFL
e_body = /obj/item/mech_component/chassis/light/nuclear
h_head = /obj/item/mecha_equipment/light
h_back = /obj/item/mecha_equipment/sleeper
@@ -96,6 +100,7 @@
icon_state = "odysseus"
e_color = COLOR_IAC
e_body = /obj/item/mech_component/chassis/light/nuclear
h_head = /obj/item/mecha_equipment/light
h_back = /obj/item/mecha_equipment/sleeper
@@ -109,6 +114,7 @@
desc = "A light and nimble exosuit, bearing the colour scheme of the Unathi Kataphracts."
e_color = COLOR_CHESTNUT
e_body = /obj/item/mech_component/chassis/light/nuclear
h_back = /obj/item/mecha_equipment/quick_enter
h_l_hand = /obj/item/mecha_equipment/clamp
@@ -120,8 +126,9 @@
desc = "A light and nimble recon exosuit, bearing the colour scheme of the Solarian Armed Forces."
e_color = COLOR_DARK_GREEN_GRAY
e_arms = /obj/item/mech_component/manipulators/combat
e_head = /obj/item/mech_component/sensors/combat
e_body = /obj/item/mech_component/chassis/light/nuclear
e_arms = /obj/item/mech_component/manipulators/combat
e_legs = /obj/item/mech_component/propulsion/hover/light
h_back = /obj/item/mecha_equipment/quick_enter

View File

@@ -44,10 +44,10 @@
mech_health = 3500
power_use = 1500
cell_type = /obj/item/cell/mecha/nuclear
/obj/item/mech_component/chassis/superheavy/prebuild()
. = ..()
QDEL_NULL(cell)
cell = new /obj/item/cell/super(src)
mech_armor = new /obj/item/robot_parts/robot_component/armor/mech/combat(src)
/mob/living/heavy_vehicle/premade/superheavy

View File

@@ -94,6 +94,8 @@
max_damage = 150
power_use = 250
cell_type = /obj/item/cell/mecha/nuclear
/obj/item/mech_component/chassis/pra_egg/armored/prebuild()
. = ..()
mech_armor = new /obj/item/robot_parts/robot_component/armor/mech/combat(src)

View File

@@ -4,9 +4,30 @@
/obj/item/cell/Initialize()
. = ..()
charge = maxcharge
if(self_charge_percentage)
START_PROCESSING(SSprocessing, src)
update_icon()
/obj/item/cell/Destroy()
if(self_charge_percentage)
STOP_PROCESSING(SSprocessing, src)
return ..()
/obj/item/cell/process(seconds_per_tick)
if(self_charge_percentage)
// we wanna recharge [self_charge_percentage% of the max charge] amount every 60 seconds
var/recharge_amount_per_minute = (maxcharge / 100) * self_charge_percentage
// since process fires every ~2 seconds, we wanna get the recharge amount per second
var/recharge_amount_per_second = recharge_amount_per_minute / 60
// multiply the amount per second with how many seconds this tick took, then round it to prevent float errors
var/recharge_for_this_process = round(recharge_amount_per_second * (seconds_per_tick / 10)) // divides seconds_per_tick by 10 to turn deciseconds into seconds
// finally, charge the cell
give(recharge_for_this_process)
/obj/item/cell/Created()
//Newly built cells spawn with no charge to prevent power exploits
charge = 0
@@ -59,6 +80,7 @@
return 0
var/used = min(charge, amount)
charge -= used
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
return used
// Checks if the specified amount can be provided. If it can, it removes the amount
@@ -78,6 +100,7 @@
var/amount_used = min(maxcharge-charge,amount)
charge += amount_used
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
return amount_used
@@ -180,6 +203,7 @@
charge -= maxcharge / severity
if (charge < 0)
charge = 0
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
/**
* Drains a percentage of the power from the battery
@@ -196,6 +220,7 @@
charge -= maxcharge / divisor
if (charge < 0)
charge = 0
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
/obj/item/cell/ex_act(severity)

View File

@@ -1,5 +1,5 @@
/datum/design/item/powercell
build_type = PROTOLATHE | MECHFAB
build_type = PROTOLATHE
category = "Misc" // For the mechfab
p_category = "Power Cell Designs"
@@ -48,3 +48,22 @@
req_tech = list(TECH_POWER = 2)
materials = list(DEFAULT_WALL_MATERIAL = 150, MATERIAL_GLASS = 10)
build_path = /obj/item/cell/device/high
/datum/design/item/powercell/mecha
name = "Power Core"
build_type = MECHFAB
req_tech = list(TECH_POWER = 2)
materials = list(DEFAULT_WALL_MATERIAL = 20000, MATERIAL_GLASS = 10000)
build_path = /obj/item/cell/mecha
/datum/design/item/powercell/mecha/nuclear
name = "Nuclear Power Core"
req_tech = list(TECH_POWER = 3, TECH_MATERIAL = 3)
materials = list(DEFAULT_WALL_MATERIAL = 20000, MATERIAL_GLASS = 10000, MATERIAL_URANIUM = 10000)
build_path = /obj/item/cell/mecha/nuclear
/datum/design/item/powercell/mecha/phoron
name = "Phoron Power Core"
req_tech = list(TECH_POWER = 5, TECH_MATERIAL = 5)
materials = list(DEFAULT_WALL_MATERIAL = 20000, MATERIAL_GLASS = 10000, MATERIAL_PHORON = 5000)
build_path = /obj/item/cell/mecha/phoron

View File

@@ -0,0 +1,10 @@
author: Geeves
delete-after: True
changes:
- rscadd: "Added power cores, a type of large battery cell that get used by exosuits. The nuclear and phoron variants are self-charging."
- balance: "Combat mechs now start with nuclear power cores, allowing them to sustain themselves indefinitely, so long as they stay out of the action for a bit."
- rscdel: "Removed basic power cells from the mechfab, replaced with the mech powercores."
- rscadd: "Mech cell statuses now instantly update as soon as the cell charges or discharges."
- rscadd: "Added a stack of 10 uranium to the machinist's workshop, which can print two nuclear power cores."

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -10479,6 +10479,9 @@
/obj/item/stack/material/phoron{
amount = 20
},
/obj/item/stack/material/uranium{
amount = 10
},
/turf/simulated/floor/tiled/dark/full,
/area/operations/lower/machinist)
"eTf" = (

View File

@@ -25869,11 +25869,11 @@
},
/obj/effect/floor_decal/industrial/hatch/yellow,
/obj/machinery/button/remote/blast_door{
dir = 1;
id = "smindicate2";
name = "internal blast door";
pixel_y = 26;
req_access = list(150);
dir = 1
req_access = list(150)
},
/obj/machinery/door/blast/regular{
density = 0;
@@ -25943,11 +25943,11 @@
},
/obj/effect/floor_decal/industrial/hatch/yellow,
/obj/machinery/button/remote/blast_door{
dir = 1;
id = "smindicate";
name = "external blast door";
pixel_y = 26;
req_access = list(150);
dir = 1
req_access = list(150)
},
/turf/simulated/floor/tiled/dark,
/area/shuttle/mercenary)
@@ -28906,12 +28906,12 @@
},
/obj/machinery/access_button{
command = "cycle_exterior";
dir = 1;
frequency = 1380;
master_tag = "raider_east_control";
pixel_x = -26;
pixel_y = 12;
req_access = list(150);
dir = 1
req_access = list(150)
},
/obj/machinery/door/blast/regular/open{
dir = 2;
@@ -28922,8 +28922,8 @@
id = "raiderblastdoor";
name = "blast door";
pixel_x = 25;
req_access = list(150);
pixel_y = 13
pixel_y = 13;
req_access = list(150)
},
/turf/simulated/floor/plating,
/area/shuttle/skipjack)
@@ -29004,10 +29004,10 @@
/area/shuttle/skipjack)
"bwc" = (
/obj/machinery/airlock_sensor{
dir = 4;
frequency = 1380;
id_tag = "raider_east_sensor";
pixel_x = -25;
dir = 4
pixel_x = -25
},
/obj/effect/decal/cleanable/dirt,
/obj/machinery/light/small{
@@ -29250,14 +29250,14 @@
},
/obj/effect/decal/cleanable/dirt,
/obj/machinery/embedded_controller/radio/airlock/docking_port{
dir = 4;
frequency = 1380;
id_tag = "raider_east_control";
pixel_x = -24;
tag_airpump = "raider_east_vent";
tag_chamber_sensor = "raider_east_sensor";
tag_exterior_door = "raider_northeast_lock";
tag_interior_door = "raider_southeast_lock";
dir = 4
tag_interior_door = "raider_southeast_lock"
},
/obj/vehicle/bike{
dir = 4
@@ -34681,7 +34681,7 @@
/obj/item/wirecutters,
/obj/item/weldingtool,
/obj/item/device/hand_labeler,
/obj/item/cell/nuclear,
/obj/item/cell/mecha/phoron,
/turf/simulated/floor/carpet/rubber,
/area/antag/jockey)
"eWy" = (
@@ -37437,7 +37437,7 @@
/obj/item/wirecutters,
/obj/item/weldingtool,
/obj/item/device/hand_labeler,
/obj/item/cell/nuclear,
/obj/item/cell/mecha/phoron,
/turf/simulated/floor/carpet/rubber,
/area/antag/jockey)
"oyi" = (
@@ -37826,7 +37826,7 @@
dir = 8
},
/obj/item/device/hand_labeler,
/obj/item/cell/nuclear,
/obj/item/cell/mecha/phoron,
/turf/simulated/floor/carpet/rubber,
/area/antag/jockey)
"pEO" = (