Fixes problems with multiple sources of alpha on humans (#25884)

* lets gooooo

* this too

* comments

* update code

* im so good

* tested, it works now

* Update code/game/dna/mutations/mutation_powers.dm

Co-authored-by: BiancaWilkson <42818125+BiancaWilkson@users.noreply.github.com>
Signed-off-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

---------

Signed-off-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Co-authored-by: BiancaWilkson <42818125+BiancaWilkson@users.noreply.github.com>
This commit is contained in:
Contrabang
2024-09-26 18:06:44 +00:00
committed by GitHub
co-authored by BiancaWilkson
parent 5e3dad1289
commit ee6f73973e
11 changed files with 118 additions and 30 deletions
@@ -103,3 +103,6 @@
var/list/bodyparts = list()
/// map organ names to organs
var/list/bodyparts_by_name = list()
/// Lazylist of sources to track what our alpha should be, alpha is set to the minimum. Use the `set_alpha_tracking` and `get_alpha` helpers.
var/list/alpha_sources
@@ -2034,3 +2034,30 @@ Eyes need to have significantly high darksight to shine unless the mob has the X
dna.ResetUIFrom(src)
flavor_text = ""
/**
* Helper for tracking alpha, use this to set an alpha source
*
* alpha_num - num between 0 and 255 that represents the alpha from `source`
* source - a datum that is the cause of the alpha source. This will be turned into a key via UID.
* update_alpha - boolean if alpha should be updated with this proc. Set this to false if you plan to animate the alpha after this call.
*/
/mob/living/carbon/human/proc/set_alpha_tracking(alpha_num, datum/source, update_alpha = TRUE)
alpha_num = round(alpha_num)
if(alpha_num >= ALPHA_VISIBLE)
LAZYREMOVE(alpha_sources, source.UID())
else
LAZYSET(alpha_sources, source.UID(), max(alpha_num, 0))
if(update_alpha)
alpha = get_alpha()
/**
* Gets the target alpha of the human
*
* optional_source - use this to get the alpha of an exact source. This is unsafe, only use if you 100% know it will be in the list. For the best safety, only call this as get_alpha(src)
*/
/mob/living/carbon/human/proc/get_alpha(datum/optional_source)
if(optional_source)
return alpha_sources[optional_source.UID()]
. = ALPHA_VISIBLE
for(var/source in alpha_sources)
. = min(., alpha_sources[source])
@@ -564,6 +564,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
update_fire()
update_icons()
update_emissive_block()
alpha = get_alpha()
if(player_logged) //make sure the SSD overlay stays
overlays += image('icons/effects/effects.dmi', icon_state = "zzz_glow")
+4
View File
@@ -1360,6 +1360,10 @@ GLOBAL_LIST_INIT(holy_areas, typecacheof(list(
alpha = initial(alpha)
add_to_all_human_data_huds()
/mob/living/carbon/human/reset_visibility()
..()
alpha = get_alpha()
/mob/proc/make_invisible()
invisibility = INVISIBILITY_LEVEL_TWO
alpha = 128