Files
Bubberstation/code/game/alternate_appearance.dm
SkyratBot 2e0e84a6dd [MIRROR] Antag HUDs will now animate if you have multiple antagonists, and will no longer clear on deconversion [MDB IGNORE] (#9397)
* Antag HUDs will now animate if you have multiple antagonists, and will no longer clear on deconversion (#62718)

About The Pull Request

This is for the admin combo HUD. Players shouldn't notice any difference (except at roundend).
2021-11-09T16-27-26.mp4

Removes the ability to set custom antag HUDs for custom admin teams for complexity, though if there's a large enough demand I can try to bring it back in another PR.

Fixes #59767

TM candidate only so that I can make sure antags aren't getting leaked to people who shouldn't see them.
Changelog

cl
fix: Antag HUDs will no longer clear on deconversion if the player was another antag.
qol: Antag HUDs (as seen by admins and at the round end) will now animate between all antagonists, rather than just choosing the most latest.
/cl

* Antag HUDs will now animate if you have multiple antagonists, and will no longer clear on deconversion

* Update sol_fed.dm

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
2021-11-14 23:27:01 +00:00

163 lines
4.4 KiB
Plaintext

GLOBAL_LIST_EMPTY(active_alternate_appearances)
/atom/proc/remove_alt_appearance(key)
if(alternate_appearances)
for(var/K in alternate_appearances)
var/datum/atom_hud/alternate_appearance/AA = alternate_appearances[K]
if(AA.appearance_key == key)
AA.remove_from_hud(src)
break
/atom/proc/add_alt_appearance(type, key, ...)
if(!type || !key)
return
if(alternate_appearances && alternate_appearances[key])
return
if(!ispath(type, /datum/atom_hud/alternate_appearance))
CRASH("Invalid type passed in: [type]")
var/list/arguments = args.Copy(2)
return new type(arglist(arguments))
/datum/atom_hud/alternate_appearance
var/appearance_key
var/transfer_overlays = FALSE
/datum/atom_hud/alternate_appearance/New(key)
..()
GLOB.active_alternate_appearances += src
appearance_key = key
for(var/mob in GLOB.player_list)
if(mobShouldSee(mob))
add_hud_to(mob)
/datum/atom_hud/alternate_appearance/Destroy()
GLOB.active_alternate_appearances -= src
return ..()
/datum/atom_hud/alternate_appearance/proc/onNewMob(mob/M)
if(mobShouldSee(M))
add_hud_to(M)
/datum/atom_hud/alternate_appearance/proc/mobShouldSee(mob/M)
return FALSE
/datum/atom_hud/alternate_appearance/add_to_hud(atom/A, image/I)
. = ..()
if(.)
LAZYINITLIST(A.alternate_appearances)
A.alternate_appearances[appearance_key] = src
/datum/atom_hud/alternate_appearance/remove_from_hud(atom/A)
. = ..()
if(.)
LAZYREMOVE(A.alternate_appearances, appearance_key)
/datum/atom_hud/alternate_appearance/proc/copy_overlays(atom/other, cut_old)
return
//an alternate appearance that attaches a single image to a single atom
/datum/atom_hud/alternate_appearance/basic
var/atom/target
var/image/image
var/add_ghost_version = FALSE
var/ghost_appearance
/datum/atom_hud/alternate_appearance/basic/New(key, image/I, options = AA_TARGET_SEE_APPEARANCE)
..()
transfer_overlays = options & AA_MATCH_TARGET_OVERLAYS
image = I
target = I.loc
if(transfer_overlays)
I.copy_overlays(target)
hud_icons = list(appearance_key)
add_to_hud(target, I)
if((options & AA_TARGET_SEE_APPEARANCE) && ismob(target))
add_hud_to(target)
if(add_ghost_version)
var/image/ghost_image = image(icon = I.icon , icon_state = I.icon_state, loc = I.loc)
ghost_image.override = FALSE
ghost_image.alpha = 128
ghost_appearance = new /datum/atom_hud/alternate_appearance/basic/observers(key + "_observer", ghost_image, NONE)
/datum/atom_hud/alternate_appearance/basic/Destroy()
. = ..()
QDEL_NULL(image)
target = null
if(ghost_appearance)
QDEL_NULL(ghost_appearance)
/datum/atom_hud/alternate_appearance/basic/add_to_hud(atom/A)
LAZYINITLIST(A.hud_list)
A.hud_list[appearance_key] = image
. = ..()
/datum/atom_hud/alternate_appearance/basic/remove_from_hud(atom/A)
. = ..()
A.hud_list -= appearance_key
if(. && !QDELETED(src))
qdel(src)
/datum/atom_hud/alternate_appearance/basic/copy_overlays(atom/other, cut_old)
image.copy_overlays(other, cut_old)
/datum/atom_hud/alternate_appearance/basic/everyone
add_ghost_version = TRUE
/datum/atom_hud/alternate_appearance/basic/everyone/mobShouldSee(mob/M)
return !isdead(M)
/datum/atom_hud/alternate_appearance/basic/silicons
/datum/atom_hud/alternate_appearance/basic/silicons/mobShouldSee(mob/M)
if(issilicon(M))
return TRUE
return FALSE
/datum/atom_hud/alternate_appearance/basic/observers
add_ghost_version = FALSE //just in case, to prevent infinite loops
/datum/atom_hud/alternate_appearance/basic/observers/mobShouldSee(mob/M)
return isobserver(M)
/datum/atom_hud/alternate_appearance/basic/noncult
/datum/atom_hud/alternate_appearance/basic/noncult/mobShouldSee(mob/M)
if(!IS_CULTIST(M))
return TRUE
return FALSE
/datum/atom_hud/alternate_appearance/basic/cult
/datum/atom_hud/alternate_appearance/basic/cult/mobShouldSee(mob/M)
if(IS_CULTIST(M))
return TRUE
return FALSE
/datum/atom_hud/alternate_appearance/basic/blessed_aware
/datum/atom_hud/alternate_appearance/basic/blessed_aware/mobShouldSee(mob/M)
if(M.mind?.holy_role)
return TRUE
if (istype(M, /mob/living/simple_animal/hostile/construct/wraith))
return TRUE
if(isrevenant(M) || IS_WIZARD(M))
return TRUE
return FALSE
/datum/atom_hud/alternate_appearance/basic/one_person
var/mob/seer
/datum/atom_hud/alternate_appearance/basic/one_person/mobShouldSee(mob/M)
if(M == seer)
return TRUE
return FALSE
/datum/atom_hud/alternate_appearance/basic/one_person/New(key, image/I, mob/living/M)
..(key, I, FALSE)
seer = M
/datum/atom_hud/alternate_appearance/basic/food_demands