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
+21 -16
View File
@@ -4,10 +4,10 @@
layer = STRUCTURE_LAYER
blocks_emissive = EMISSIVE_BLOCK_GENERIC
pass_flags_self = PASSSTRUCTURE
should_use_health = TRUE
var/material_alteration = MATERIAL_ALTERATION_ALL // Overrides for material shit. Set them manually if you don't want colors etc. See wood chairs/office chairs.
var/climbable
var/breakable
var/parts
var/list/climbers
var/list/footstep_sound //footstep sounds when stepped on
@@ -40,15 +40,23 @@
material = null
return ..()
/obj/structure/attackby(obj/item/attacking_item, mob/user, params)
. = ..()
if(user?.a_intent == I_HURT && maxhealth)
user.do_attack_animation(src)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
add_damage(attacking_item.force, attacking_item.damage_flags(), attacking_item.damtype, attacking_item.armor_penetration, attacking_item)
if(hitsound)
playsound(user, hitsound, attacking_item.get_clamped_volume())
/obj/structure/attack_hand(mob/living/user)
if(breakable)
if((user.mutations & HULK) && !(user.isSynthetic()) && !(isvaurca(user)))
user.say(pick(";RAAAAAAAARGH!", ";HNNNNNNNNNGGGGGGH!", ";GWAAAAAAAARRRHHH!", "NNNNNNNNGGGGGGGGHH!", ";AAAAAAARRRGH!" ))
attack_generic(user,1,"smashes")
else if(istype(user,/mob/living/carbon/human))
var/mob/living/carbon/human/H = user
if(H.species.can_shred(user))
attack_generic(user,1,"slices")
if((user.mutations & HULK) && !(user.isSynthetic()) && !(isvaurca(user)))
user.say(pick("RAAAAAAAARGH!!!", "HNNNNNNNNNGGGGGGH!!!", "GWAAAAAAAARRRHHH!!!", "NNNNNNNNGGGGGGGGHH!!!", "AAAAAAARRRGH!!!" ))
attack_generic(user, 25, "smashes")
else if(istype(user,/mob/living/carbon/human))
var/mob/living/carbon/human/H = user
if(H.species.can_shred(user))
attack_generic(user, 25, "slices")
if(LAZYLEN(climbers) && !(user in climbers))
user.visible_message(SPAN_WARNING("[user] shakes \the [src]."), \
@@ -75,6 +83,8 @@
dismantle_material = SSmaterials.get_material_by_name(DEFAULT_WALL_MATERIAL) //if there is no defined material, it will use steel
else
dismantle_material = get_material()
if(should_use_health && health <= 0)
build_amt /= rand(2, 4) //if the structure is destroyed by damage, it will yield less materials
for(var/i = 1 to build_amt)
dismantle_material.place_sheet(loc)
qdel(src)
@@ -227,13 +237,8 @@
return 0
return 1
/obj/structure/attack_generic(mob/user, damage, attack_message, environment_smash, armor_penetration, attack_flags, damage_type)
if(!breakable || !damage || !environment_smash)
return 0
visible_message(SPAN_DANGER("[user] [attack_verb] the [src] apart!"))
user.do_attack_animation(src)
qdel(src)
return 1
/obj/structure/on_death(damage, damage_flags, damage_type, armor_penetration, obj/weapon)
dismantle()
/obj/structure/get_material()
return material