From d450359baa862c86cd000142909ecc90de9fc38e Mon Sep 17 00:00:00 2001 From: jimmyl <70376633+mc-oofert@users.noreply.github.com> Date: Mon, 8 Jul 2024 05:40:54 +0200 Subject: [PATCH] blood brother hud (#84704) ## About The Pull Request bloodbros get a hud teambased antagonists may not see the HUDs of other teams ![2024-07-06 11_12_17-Window](https://github.com/tgstation/tgstation/assets/70376633/e4c6dfde-47fe-4e45-9350-956e14bf18fb) additionally if TESTING is defined flashing a clientless mindless mob works ## Why It's Good For The Game fixes #83617 ## Changelog :cl: qol: blood bros get a hud to see eachother code: teambased antagonists may not see the HUDs of other teams /:cl: --------- Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- code/modules/antagonists/_common/antag_datum.dm | 1 + code/modules/antagonists/_common/antag_hud.dm | 8 +++++++- code/modules/antagonists/brother/brother.dm | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm index c72c97fb734..d51885d5143 100644 --- a/code/modules/antagonists/_common/antag_datum.dm +++ b/code/modules/antagonists/_common/antag_datum.dm @@ -525,6 +525,7 @@ GLOBAL_LIST_EMPTY(antagonists) "antag_team_hud_[REF(src)]", hud_image_on(target), antag_to_check || type, + get_team() && WEAKREF(get_team()), )) // Add HUDs that they couldn't see before diff --git a/code/modules/antagonists/_common/antag_hud.dm b/code/modules/antagonists/_common/antag_hud.dm index 228bfc354df..863d52ef5ff 100644 --- a/code/modules/antagonists/_common/antag_hud.dm +++ b/code/modules/antagonists/_common/antag_hud.dm @@ -4,9 +4,12 @@ GLOBAL_LIST_EMPTY_TYPED(has_antagonist_huds, /datum/atom_hud/alternate_appearanc /// An alternate appearance that will only show if you have the antag datum /datum/atom_hud/alternate_appearance/basic/has_antagonist var/antag_datum_type + /// Optionally, a weakref to antag team + var/datum/weakref/team_ref -/datum/atom_hud/alternate_appearance/basic/has_antagonist/New(key, image/I, antag_datum_type) +/datum/atom_hud/alternate_appearance/basic/has_antagonist/New(key, image/I, antag_datum_type, datum/weakref/team) src.antag_datum_type = antag_datum_type + team_ref = team GLOB.has_antagonist_huds += src return ..(key, I, NONE) @@ -15,6 +18,9 @@ GLOBAL_LIST_EMPTY_TYPED(has_antagonist_huds, /datum/atom_hud/alternate_appearanc return ..() /datum/atom_hud/alternate_appearance/basic/has_antagonist/mobShouldSee(mob/M) + var/datum/team/antag_team = team_ref?.resolve() + if(!isnull(antag_team)) + return !!(M.mind in antag_team.members) return !!M.mind?.has_antag_datum(antag_datum_type) /// An alternate appearance that will show all the antagonists this mob has diff --git a/code/modules/antagonists/brother/brother.dm b/code/modules/antagonists/brother/brother.dm index b62b18a02ae..13707df2c05 100644 --- a/code/modules/antagonists/brother/brother.dm +++ b/code/modules/antagonists/brother/brother.dm @@ -75,9 +75,14 @@ flashed.balloon_alert(source, "unconscious!") return +#ifdef TESTING + if (isnull(flashed.mind)) + flashed.mind_initialize() +#else if (isnull(flashed.mind) || !GET_CLIENT(flashed)) flashed.balloon_alert(source, "[flashed.p_their()] mind is vacant!") return +#endif for(var/datum/objective/brother_objective as anything in source.mind.get_all_objectives()) // If the objective has a target, are we flashing them? @@ -183,6 +188,11 @@ message_admins("[key_name_admin(admin)] made [key_name_admin(new_owner)] into a blood brother.") log_admin("[key_name(admin)] made [key_name(new_owner)] into a blood brother.") +/datum/antagonist/brother/apply_innate_effects(mob/living/mob_override) + . = ..() + var/mob/living/the_mob = owner.current || mob_override + add_team_hud(the_mob) + /datum/antagonist/brother/ui_static_data(mob/user) var/list/data = list() data["antag_name"] = name @@ -219,8 +229,13 @@ /// Adds a new brother to the team /datum/team/brother_team/proc/add_brother(mob/living/new_brother, source) +#ifndef TESTING if (isnull(new_brother) || isnull(new_brother.mind) || !GET_CLIENT(new_brother) || new_brother.mind.has_antag_datum(/datum/antagonist/brother)) return FALSE +#else + if (isnull(new_brother) || new_brother.mind.has_antag_datum(/datum/antagonist/brother)) + return FALSE +#endif set_brothers_left(brothers_left - 1) for (var/datum/mind/brother_mind as anything in members)