diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 85ea2fb471c..a8a34a3ea07 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -929,6 +929,18 @@ /// called on implants, after an implant has been removed: (mob/living/source, silent, special) #define COMSIG_IMPLANT_REMOVED "implant_removed" +/// called as a mindshield is implanted: (mob/user) +#define COMSIG_PRE_MINDSHIELD_IMPLANT "pre_mindshield_implant" + /// Did they successfully get mindshielded? + #define COMPONENT_MINDSHIELD_PASSED (NONE) + /// Did they resist the mindshield? + #define COMPONENT_MINDSHIELD_RESISTED (1<<0) + +/// called once a mindshield is implanted: (mob/user) +#define COMSIG_MINDSHIELD_IMPLANTED "mindshield_implanted" + /// Are we the reason for deconversion? + #define COMPONENT_MINDSHIELD_DECONVERTED (1<<0) + ///called on implants being implanted into someone with an uplink implant: (datum/component/uplink) #define COMSIG_IMPLANT_EXISTING_UPLINK "implant_uplink_exists" //This uses all return values of COMSIG_IMPLANT_OTHER diff --git a/code/game/objects/items/implants/implant_mindshield.dm b/code/game/objects/items/implants/implant_mindshield.dm index e95d132ab28..21a6449642c 100644 --- a/code/game/objects/items/implants/implant_mindshield.dm +++ b/code/game/objects/items/implants/implant_mindshield.dm @@ -1,7 +1,7 @@ /obj/item/implant/mindshield name = "mindshield implant" desc = "Protects against brainwashing." - activated = 0 + activated = FALSE /obj/item/implant/mindshield/get_data() var/dat = {"Implant Specifications:
@@ -17,50 +17,37 @@ /obj/item/implant/mindshield/implant(mob/living/target, mob/user, silent = FALSE, force = FALSE) - if(..()) - if(!target.mind) - ADD_TRAIT(target, TRAIT_MINDSHIELD, IMPLANT_TRAIT) - target.sec_hud_set_implants() - return TRUE - var/deconverted = FALSE - if(target.mind.has_antag_datum(/datum/antagonist/brainwashed)) - target.mind.remove_antag_datum(/datum/antagonist/brainwashed) - deconverted = TRUE - - if(target.mind.has_antag_datum(/datum/antagonist/rev/head)|| target.mind.unconvertable) + . = ..() + if(!.) + return FALSE + if(target.mind) + if((SEND_SIGNAL(target.mind, COMSIG_PRE_MINDSHIELD_IMPLANT, user) & COMPONENT_MINDSHIELD_RESISTED) || target.mind.unconvertable) if(!silent) target.visible_message(span_warning("[target] seems to resist the implant!"), span_warning("You feel something interfering with your mental conditioning, but you resist it!")) - removed(target, 1) + removed(target, TRUE) qdel(src) - return TRUE //the implant is still used - - var/datum/antagonist/rev/rev = target.mind.has_antag_datum(/datum/antagonist/rev) - if(rev) - deconverted = TRUE - rev.remove_revolutionary(FALSE, user) - if(!silent) - if(target.mind.has_antag_datum(/datum/antagonist/cult)) - to_chat(target, span_warning("You feel something interfering with your mental conditioning, but you resist it!")) - else - to_chat(target, span_notice("You feel a sense of peace and security. You are now protected from brainwashing.")) - ADD_TRAIT(target, TRAIT_MINDSHIELD, IMPLANT_TRAIT) - target.sec_hud_set_implants() - if(deconverted) + return TRUE + if(SEND_SIGNAL(target.mind, COMSIG_MINDSHIELD_IMPLANTED, user) & COMPONENT_MINDSHIELD_DECONVERTED) if(prob(1) || SSevents.holidays && SSevents.holidays[APRIL_FOOLS]) target.say("I'm out! I quit! Whose kidneys are these?", forced = "They're out! They quit! Whose kidneys do they have?") - return TRUE - return FALSE -/obj/item/implant/mindshield/removed(mob/target, silent = FALSE, special = 0) - if(..()) - if(isliving(target)) - var/mob/living/L = target - REMOVE_TRAIT(L, TRAIT_MINDSHIELD, IMPLANT_TRAIT) - L.sec_hud_set_implants() - if(target.stat != DEAD && !silent) - to_chat(target, span_boldnotice("Your mind suddenly feels terribly vulnerable. You are no longer safe from brainwashing.")) - return TRUE - return FALSE + ADD_TRAIT(target, TRAIT_MINDSHIELD, IMPLANT_TRAIT) + target.sec_hud_set_implants() + if(!silent) + to_chat(target, span_notice("You feel a sense of peace and security. You are now protected from brainwashing.")) + return TRUE + +/obj/item/implant/mindshield/removed(mob/target, silent = FALSE, special = FALSE) + . = ..() + if(!.) + return FALSE + if(isliving(target)) + var/mob/living/L = target + REMOVE_TRAIT(L, TRAIT_MINDSHIELD, IMPLANT_TRAIT) + L.sec_hud_set_implants() + if(target.stat != DEAD && !silent) + to_chat(target, span_boldnotice("Your mind suddenly feels terribly vulnerable. You are no longer safe from brainwashing.")) + return TRUE /obj/item/implanter/mindshield name = "implanter (mindshield)" diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm index f33716dc9d9..3ee03c617a8 100644 --- a/code/modules/antagonists/_common/antag_datum.dm +++ b/code/modules/antagonists/_common/antag_datum.dm @@ -102,6 +102,16 @@ GLOBAL_LIST_EMPTY(antagonists) /datum/antagonist/proc/remove_innate_effects(mob/living/mob_override) return +/// This is called when the antagonist is being mindshielded. +/datum/antagonist/proc/pre_mindshield(mob/implanter, mob/living/mob_override) + SIGNAL_HANDLER + return COMPONENT_MINDSHIELD_PASSED + +/// This is called when the antagonist is successfully mindshielded. +/datum/antagonist/proc/on_mindshield(mob/implanter, mob/living/mob_override) + SIGNAL_HANDLER + return + // Adds the specified antag hud to the player. Usually called in an antag datum file /datum/antagonist/proc/add_antag_hud(antag_hud_type, antag_hud_name, mob/living/mob_override) var/datum/atom_hud/antag/hud = GLOB.huds[antag_hud_type] @@ -151,6 +161,8 @@ GLOBAL_LIST_EMPTY(antagonists) info_button.Trigger() apply_innate_effects() give_antag_moodies() + RegisterSignal(owner, COMSIG_PRE_MINDSHIELD_IMPLANT, .proc/pre_mindshield) + RegisterSignal(owner, COMSIG_MINDSHIELD_IMPLANTED, .proc/on_mindshield) if(is_banned(owner.current) && replace_banned) replace_banned_player() else if(owner.current.client?.holder && (CONFIG_GET(flag/auto_deadmin_antagonists) || owner.current.client.prefs?.toggles & DEADMIN_ANTAGONIST)) @@ -200,6 +212,8 @@ GLOBAL_LIST_EMPTY(antagonists) QDEL_NULL(info_button) if(!silent && owner.current) farewell() + UnregisterSignal(owner, COMSIG_PRE_MINDSHIELD_IMPLANT) + UnregisterSignal(owner, COMSIG_MINDSHIELD_IMPLANTED) var/datum/team/team = get_team() if(team) team.remove_member(owner) diff --git a/code/modules/antagonists/brainwashing/brainwashing.dm b/code/modules/antagonists/brainwashing/brainwashing.dm index bd7a9a43cb0..43478742e69 100644 --- a/code/modules/antagonists/brainwashing/brainwashing.dm +++ b/code/modules/antagonists/brainwashing/brainwashing.dm @@ -49,6 +49,10 @@ owner_mob.log_message("is no longer brainwashed with the objectives: [english_list(objectives)].", LOG_ATTACK) owner.announce_objectives() +/datum/antagonist/brainwashed/on_mindshield(mob/implanter) + owner.remove_antag_datum(/datum/antagonist/brainwashed) + return COMPONENT_MINDSHIELD_DECONVERTED + /datum/antagonist/brainwashed/admin_add(datum/mind/new_owner,mob/admin) var/mob/living/carbon/C = new_owner.current if(!istype(C)) diff --git a/code/modules/antagonists/cult/cult.dm b/code/modules/antagonists/cult/cult.dm index 6602082f831..9eee916acb6 100644 --- a/code/modules/antagonists/cult/cult.dm +++ b/code/modules/antagonists/cult/cult.dm @@ -139,6 +139,11 @@ H.remove_overlay(HALO_LAYER) H.update_body() +/datum/antagonist/cult/on_mindshield(mob/implanter) + if(!silent) + to_chat(owner.current, span_warning("You feel something interfering with your mental conditioning, but you resist it!")) + return + /datum/antagonist/cult/on_removal() if(!silent) owner.current.visible_message(span_deconversion_message("[owner.current] looks like [owner.current.p_theyve()] just reverted to [owner.current.p_their()] old faith!"), null, null, null, owner.current) diff --git a/code/modules/antagonists/revolution/revolution.dm b/code/modules/antagonists/revolution/revolution.dm index 8428a01c47e..b0dc0a36f34 100644 --- a/code/modules/antagonists/revolution/revolution.dm +++ b/code/modules/antagonists/revolution/revolution.dm @@ -39,6 +39,10 @@ remove_antag_hud(antag_hud_type, M) handle_clown_mutation(M, removing = FALSE) +/datum/antagonist/rev/on_mindshield(mob/implanter) + remove_revolutionary(FALSE, implanter) + return COMPONENT_MINDSHIELD_DECONVERTED + /datum/antagonist/rev/proc/equip_rev() return @@ -163,6 +167,9 @@ var/give_flash = FALSE var/give_hud = TRUE +/datum/antagonist/rev/head/pre_mindshield(mob/implanter, mob/living/mob_override) + return COMPONENT_MINDSHIELD_RESISTED + /datum/antagonist/rev/head/on_removal() if(give_hud) var/mob/living/carbon/C = owner.current