Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exosuit Nuclear Power Cores #18268

Merged
merged 11 commits into from
Jun 9, 2024
1 change: 1 addition & 0 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,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"
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/signals_atom/signals_power_cell.dm
Original file line number Diff line number Diff line change
@@ -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"
Geevies marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions code/game/objects/items/devices/suit_cooling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]."))
Expand Down
72 changes: 37 additions & 35 deletions code/game/objects/items/weapons/power_cells.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions code/game/objects/items/weapons/stunbaton.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion code/game/objects/random/tech.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
8 changes: 5 additions & 3 deletions code/modules/heavy_vehicle/components/body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -118,8 +119,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))
Expand Down
29 changes: 16 additions & 13 deletions code/modules/heavy_vehicle/interface/_interface.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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>"
4 changes: 3 additions & 1 deletion code/modules/heavy_vehicle/mech_construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions code/modules/heavy_vehicle/mech_interaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]:"))
Expand Down Expand Up @@ -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()
2 changes: 2 additions & 0 deletions code/modules/heavy_vehicle/mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,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))
Comment on lines +210 to +211
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unregister it on destroy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as i'm aware, signals are already unregistered when any datum gets destroyed, so it shouldn't be necessary, unless i missed something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be right


updatehealth()

Expand Down
2 changes: 2 additions & 0 deletions code/modules/heavy_vehicle/premade/_premade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Geevies marked this conversation as resolved.
Show resolved Hide resolved
if(e_color)
body.color = e_color
if(!arms && e_arms)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/heavy_vehicle/premade/heavy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion code/modules/heavy_vehicle/premade/light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions code/modules/heavy_vehicle/premade/military.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions code/modules/heavy_vehicle/premade/pra.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading
Loading