Adds an universal object health system. (#21266)

https://www.youtube.com/watch?v=ZpUYjpKg9KY

As per title. The goal is to add health to most objects in the game and
thus allow them to be dynamically destructible, while also avoiding
shitcode like each structure having its own snowflake health update
proc.

---------

Signed-off-by: Matt Atlas <mattiathebest2000@hotmail.it>
Co-authored-by: Matt Atlas <liermattia@gmail.com>
Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com>
This commit is contained in:
Matt Atlas
2026-04-16 23:22:08 +00:00
committed by GitHub
co-authored by Matt Atlas SleepyGemmy
parent 1d2871729f
commit d5931c5ffe
213 changed files with 1448 additions and 1424 deletions
@@ -29,6 +29,7 @@
icon_state = "box"
item_state = "box"
contained_sprite = TRUE
maxhealth = OBJECT_HEALTH_EXTREMELY_LOW
color = COLOR_CARDBOARD
var/label = "label"
var/illustration = "writing"
@@ -39,19 +40,17 @@
///Boolean, if set, can be crushed into a trash item when empty
var/trash = null
var/maxHealth = 20 //health is already defined
use_sound = 'sound/items/storage/box.ogg'
drop_sound = 'sound/items/drop/cardboardbox.ogg'
pickup_sound = 'sound/items/pickup/cardboardbox.ogg'
var/chewable = TRUE
/obj/item/storage/box/condition_hints(mob/user, distance, is_adjacent)
. += ..()
if (health < maxHealth)
if (health >= (maxHealth * 0.5))
. += SPAN_WARNING("It is slightly torn.")
/obj/item/storage/box/get_damage_condition_hints(mob/user, distance, is_adjacent)
if (health < maxhealth)
if (health >= (maxhealth * 0.5))
. = SPAN_WARNING("It is slightly torn.")
else
. += SPAN_DANGER("It is full of tears and holes.")
. = SPAN_DANGER("It is full of tears and holes.")
/obj/item/storage/box/mechanics_hints(mob/user, distance, is_adjacent)
. += ..()
@@ -74,7 +73,8 @@
/obj/item/storage/box/Initialize()
. = ..()
health = maxHealth
if(illustration)
AddOverlays(illustration)
update_icon()
/obj/item/storage/box/proc/damage(var/severity)
@@ -556,7 +556,6 @@
/obj/item/reagent_containers/food/snacks/truffle/random
)
starts_with = list(/obj/item/reagent_containers/food/snacks/truffle/random = 8)
maxHealth = 40
/obj/item/storage/box/fancy/chocolate_box/fill()
for(var/i=1; i <= storage_slots; i++)
+2 -1
View File
@@ -44,7 +44,8 @@
anchored = TRUE
mouse_opacity = MOUSE_OPACITY_ICON
var/health = 50
maxhealth = OBJECT_HEALTH_VERY_LOW
var/mob/living/affecting = null //Who it is currently affecting, if anyone.
/obj/effect/energy_net/Initialize()