Refactors health doll, replaces "wounded" screen alert (#87011)

## About The Pull Request

The screen alert for being wounded is deleted

Instead, your health doll will now glow red on any (and all) wounded
limbs


https://github.com/user-attachments/assets/83565684-3e19-4753-8034-d8de6574e2b8

To accomplish this, the doll was refactored a bit. No longer operates
off of overlays, now uses vis contents across every limb, and just
updates the icon state of all those vis contents

## Why It's Good For The Game

Wounds really spam the hell out of you with screen alerts and it often
blocks you from seeing more relevant alerts that you care about

The mere presence of a minor dislocation on your leg prevents you from
noticing that you are no longer breathing. This is a bit troublesome

This can be resolved in other ways, of course - adding a priority value
to alerts? - but instead, I think we can just make better use of our
existing hud elements

I find this decently intuitive, at a glance. 
- The old screen alert gave you a tooltip saying you could click the
alert to examine yourself.
- Clicking on the health doll examines yourself the exact same way.
- So, players may see their doll glowing red, and click on it to self
examine, to see the report of them having a wound on their leg or chest
or whatever.

## Changelog

🆑 Melbert
del: Having any wounds no longer gives you an alert in the top right
qol: Having any wounds now make the corresponding bodypart on your
health doll (the lil dude on the right side of the screen) glow red.
refactor: Refactored how the hud's health doll shows up for humans.
Report any oddities
/🆑
This commit is contained in:
MrMelbert
2024-11-11 00:43:38 -08:00
committed by Majkl-J
parent 6428dcf307
commit aec6324344
11 changed files with 101 additions and 66 deletions
+83 -1
View File
@@ -724,6 +724,88 @@
screen_loc = ui_living_healthdoll
var/filtered = FALSE //so we don't repeatedly create the mask of the mob every update
/atom/movable/screen/healthdoll/human
/// Tracks components of our doll, each limb is a separate atom in our vis_contents
VAR_PRIVATE/list/atom/movable/screen/limbs
/// Lazylist, tracks all body zones that are wounded currently
/// Used so we can sync animations should the list be updated
VAR_PRIVATE/list/animated_zones
/atom/movable/screen/healthdoll/human/Initialize(mapload, datum/hud/hud_owner)
. = ..()
limbs = list()
for(var/i in GLOB.all_body_zones)
var/atom/movable/screen/healthdoll_limb/limb = new(src, null)
// layer chest above other limbs, it's the center after all
limb.layer = i == BODY_ZONE_CHEST ? layer + 0.05 : layer
limbs[i] = limb
// why viscontents? why not overlays? - because i want to animate filters
vis_contents += limb
update_appearance()
/atom/movable/screen/healthdoll/human/Destroy()
QDEL_LIST_ASSOC_VAL(limbs)
vis_contents.Cut()
return ..()
/atom/movable/screen/healthdoll/human/update_icon_state()
. = ..()
var/mob/living/carbon/human/owner = hud?.mymob
if(isnull(owner))
return
if(owner.stat == DEAD)
for(var/limb in limbs)
limbs[limb].icon_state = "[limb]DEAD"
return
var/list/current_animated = LAZYLISTDUPLICATE(animated_zones)
for(var/obj/item/bodypart/body_part as anything in owner.bodyparts)
var/icon_key = 0
var/part_zone = body_part.body_zone
var/list/overridable_key = list(icon_key)
if(body_part.bodypart_disabled)
icon_key = 7
else if(owner.stat == DEAD)
icon_key = "DEAD"
else if(SEND_SIGNAL(body_part, COMSIG_BODYPART_UPDATING_HEALTH_HUD, owner, overridable_key) & OVERRIDE_BODYPART_HEALTH_HUD)
icon_key = overridable_key[1] // thanks i hate it
else if(!owner.has_status_effect(/datum/status_effect/grouped/screwy_hud/fake_healthy))
var/damage = body_part.get_damage() / body_part.max_damage
// calculate what icon state (1-5, or 0 if undamaged) to use based on damage
icon_key = clamp(ceil(damage * 5), 0, 5)
if(length(body_part.wounds))
LAZYSET(animated_zones, part_zone, TRUE)
else
LAZYREMOVE(animated_zones, part_zone)
limbs[part_zone].icon_state = "[part_zone][icon_key]"
// handle leftovers
for(var/missing_zone in owner.get_missing_limbs())
limbs[missing_zone].icon_state = "[missing_zone]6"
LAZYREMOVE(animated_zones, missing_zone)
// time to re-sync animations, something changed
if(animated_zones ~! current_animated)
for(var/animated_zone in animated_zones)
var/atom/wounded_zone = limbs[animated_zone]
var/existing_filter = wounded_zone.get_filter("wound_outline")
if(existing_filter)
animate(existing_filter) // stop animation so we can resync
else
wounded_zone.add_filter("wound_outline", 1, list("type" = "outline", "color" = "#FF0033", "alpha" = 0, "size" = 1.2))
existing_filter = wounded_zone.get_filter("wound_outline")
animate(existing_filter, alpha = 200, time = 1.5 SECONDS, loop = -1)
animate(alpha = 0, time = 1.5 SECONDS)
if(LAZYLEN(current_animated)) // avoid null - list() runtimes please
for(var/lost_zone in current_animated - animated_zones)
limbs[lost_zone].remove_filter("wound_outline")
// Basically just holds an icon we can put a filter on
/atom/movable/screen/healthdoll_limb
screen_loc = ui_living_healthdoll
vis_flags = VIS_INHERIT_ID | VIS_INHERIT_PLANE
/atom/movable/screen/mood
name = "mood"
icon_state = "mood5"
@@ -904,7 +986,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/splash)
animate(get_filter("hunger_outline"), alpha = 200, time = 1.5 SECONDS, loop = -1)
animate(alpha = 0, time = 1.5 SECONDS)
else if(get_filter("hunger_outline"))
else
remove_filter("hunger_outline")
// Update color of the food