From 41396aab453907855d0a3d2b052d63ff64bfb5cc Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Wed, 29 Mar 2023 23:30:56 +0200
Subject: [PATCH] [MIRROR] Adds IS_TRAITOR macro [MDB IGNORE] (#20153)
* Adds IS_TRAITOR macro (#74293)
## About The Pull Request
i was making another PR and found that we have cultist, heretic, and
nuke op IS macros but not one for traitors
this adds one and then replaces it where applicable, mostly in checks
where a traitor device does something different if you are not a traitor
## Why It's Good For The Game
better for people making traitor only devices to have this macro, as it
is more clear and also cleaner in general i think
## Changelog
:cl:
code: adds IS_TRAITOR macro
/:cl:
* Adds IS_TRAITOR macro
---------
Co-authored-by: Sol N <116288367+flowercuco@users.noreply.github.com>
---
code/__DEFINES/antagonists.dm | 3 +++
code/game/machinery/computer/communications.dm | 2 +-
code/game/objects/items/AI_modules/hacked.dm | 2 +-
code/game/objects/items/dna_probe.dm | 2 +-
.../modules/antagonists/traitor/objectives/locate_weakpoint.dm | 2 +-
.../antagonists/traitor/objectives/sabotage_machinery.dm | 2 +-
code/modules/antagonists/traitor/objectives/steal.dm | 2 +-
7 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/code/__DEFINES/antagonists.dm b/code/__DEFINES/antagonists.dm
index b2a7203135e..9c217f8907c 100644
--- a/code/__DEFINES/antagonists.dm
+++ b/code/__DEFINES/antagonists.dm
@@ -199,6 +199,9 @@ GLOBAL_LIST_INIT(ai_employers, list(
#define UPLINK_THEME_UNDERWORLD_MARKET "neutral"
+/// Checks if the given mob is a traitor
+#define IS_TRAITOR(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/traitor))
+
/// Checks if the given mob is a blood cultist
#define IS_CULTIST(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/cult))
diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm
index 53d9ddd4c78..e3d0296a083 100755
--- a/code/game/machinery/computer/communications.dm
+++ b/code/game/machinery/computer/communications.dm
@@ -130,7 +130,7 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
/obj/machinery/computer/communications/emag_act(mob/user, obj/item/card/emag/emag_card)
if(istype(emag_card, /obj/item/card/emag/battlecruiser))
- if(!user.mind?.has_antag_datum(/datum/antagonist/traitor))
+ if(!IS_TRAITOR(user))
to_chat(user, span_danger("You get the feeling this is a bad idea."))
return
var/obj/item/card/emag/battlecruiser/caller_card = emag_card
diff --git a/code/game/objects/items/AI_modules/hacked.dm b/code/game/objects/items/AI_modules/hacked.dm
index a0779cf4242..b9ddb5c65ed 100644
--- a/code/game/objects/items/AI_modules/hacked.dm
+++ b/code/game/objects/items/AI_modules/hacked.dm
@@ -44,7 +44,7 @@
var/functional = TRUE
/obj/item/ai_module/malf/transmitInstructions(datum/ai_laws/law_datum, mob/sender, overflow)
- if(!sender.mind?.has_antag_datum(/datum/antagonist/traitor))
+ if(!IS_TRAITOR(sender))
to_chat(sender, span_warning("You have no clue how to use this thing."))
return
if(!functional)
diff --git a/code/game/objects/items/dna_probe.dm b/code/game/objects/items/dna_probe.dm
index f6239d54701..56d11f7c5d3 100644
--- a/code/game/objects/items/dna_probe.dm
+++ b/code/game/objects/items/dna_probe.dm
@@ -86,7 +86,7 @@
/obj/item/dna_probe/carp_scanner/examine_more(mob/user)
. = ..()
- if(user.mind.has_antag_datum(/datum/antagonist/traitor))
+ if(IS_TRAITOR(user))
. = list(span_notice("Using this on a Space Carp will harvest its DNA. Use it in-hand once complete to mutate it with yourself."))
/obj/item/dna_probe/carp_scanner/attack_self(mob/user, modifiers)
diff --git a/code/modules/antagonists/traitor/objectives/locate_weakpoint.dm b/code/modules/antagonists/traitor/objectives/locate_weakpoint.dm
index 91d68b4080d..39f03f517c4 100644
--- a/code/modules/antagonists/traitor/objectives/locate_weakpoint.dm
+++ b/code/modules/antagonists/traitor/objectives/locate_weakpoint.dm
@@ -245,7 +245,7 @@
if(!user.mind)
return
- if(!user.mind.has_antag_datum(/datum/antagonist/traitor))
+ if(!IS_TRAITOR(user))
to_chat(user, span_warning("You can't seem to find a way to detonate the charge."))
return
diff --git a/code/modules/antagonists/traitor/objectives/sabotage_machinery.dm b/code/modules/antagonists/traitor/objectives/sabotage_machinery.dm
index b5e26c725ad..71f56927dab 100644
--- a/code/modules/antagonists/traitor/objectives/sabotage_machinery.dm
+++ b/code/modules/antagonists/traitor/objectives/sabotage_machinery.dm
@@ -153,7 +153,7 @@ GLOBAL_DATUM_INIT(objective_machine_handler, /datum/objective_target_machine_han
/obj/item/traitor_machine_trapper/examine(mob/user)
. = ..()
- if(!user.mind?.has_antag_datum(/datum/antagonist/traitor))
+ if(!IS_TRAITOR(user))
return
if(target_machine_path)
. += span_notice("This device must be placed by clicking on a [initial(target_machine_path.name)] with it. It can be removed with a screwdriver.")
diff --git a/code/modules/antagonists/traitor/objectives/steal.dm b/code/modules/antagonists/traitor/objectives/steal.dm
index 4bce915c758..9ff7cdc5134 100644
--- a/code/modules/antagonists/traitor/objectives/steal.dm
+++ b/code/modules/antagonists/traitor/objectives/steal.dm
@@ -265,7 +265,7 @@ GLOBAL_DATUM_INIT(steal_item_handler, /datum/objective_item_handler, new())
if(planted_on)
return
- if(user.mind?.has_antag_datum(/datum/antagonist/traitor))
+ if(IS_TRAITOR(user))
if(target_object_type)
. += span_notice("This device must be placed by clicking on the [initial(target_object_type.name)] with it.")
. += span_notice("Remember, you may leave behind fingerprints or fibers on the device. Use soap or similar to scrub it clean to be safe!")