From 8f423c500ad636851cc25a7d3c451ffadd67a78b Mon Sep 17 00:00:00 2001
From: Zonespace <41448081+Zonespace27@users.noreply.github.com>
Date: Thu, 28 Sep 2023 00:20:46 -0700
Subject: [PATCH] Fixes yautja relay beacon not uncloaking correctly (#4527)
# About the pull request
The Yautja relay beacons _visibly_ decloak you when you use it, but not
mechanically. This fixes that and adjusts some bracer logic.
# Explain why it's good for the game
Bugs bad
# Testing Photographs and Procedure
Screenshots & Videos
Works
# Changelog
:cl:
fix: Using a Yautja relay beacon now properly decloaks you
/:cl:
---
code/__DEFINES/traits.dm | 15 +++++++++++++++
code/game/turfs/open.dm | 2 +-
code/modules/cm_preds/yaut_bracers.dm | 17 +++++++----------
code/modules/cm_preds/yaut_items.dm | 2 ++
.../abilities/predalien/predalien_powers.dm | 2 +-
5 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm
index 3486988d4d60..b40ae85c3f5f 100644
--- a/code/__DEFINES/traits.dm
+++ b/code/__DEFINES/traits.dm
@@ -102,6 +102,21 @@
}\
} while (0)
+/// Will 100% nuke a trait regardless of source. Preferably use this as little as possible
+#define REMOVE_TRAIT_ALLSOURCES(target, trait) \
+ do { \
+ var/list/_L = target.status_traits; \
+ if (_L?[trait]) { \
+ if (length(_L)) { \
+ _L -= trait; \
+ SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \
+ }; \
+ else { \
+ target.status_traits = null \
+ }; \
+ } \
+ } while (0)
+
#define HAS_TRAIT(target, trait) (target.status_traits ? (target.status_traits[trait] ? TRUE : FALSE) : FALSE)
#define HAS_TRAIT_FROM(target, trait, source) (target.status_traits ? (target.status_traits[trait] ? (source in target.status_traits[trait]) : FALSE) : FALSE)
#define HAS_TRAIT_FROM_ONLY(target, trait, source) (\
diff --git a/code/game/turfs/open.dm b/code/game/turfs/open.dm
index c88f79b43293..a4781e1a6609 100644
--- a/code/game/turfs/open.dm
+++ b/code/game/turfs/open.dm
@@ -515,7 +515,7 @@
if(H.gloves && rand(0,100) < 60)
if(istype(H.gloves,/obj/item/clothing/gloves/yautja/hunter))
var/obj/item/clothing/gloves/yautja/hunter/Y = H.gloves
- if(Y && istype(Y) && Y.cloaked)
+ if(Y && istype(Y) && HAS_TRAIT(H, TRAIT_CLOAKED))
to_chat(H, SPAN_WARNING(" Your bracers hiss and spark as they short out!"))
Y.decloak(H, TRUE, DECLOAK_SUBMERGED)
diff --git a/code/modules/cm_preds/yaut_bracers.dm b/code/modules/cm_preds/yaut_bracers.dm
index 785378b04388..0f52332ee944 100644
--- a/code/modules/cm_preds/yaut_bracers.dm
+++ b/code/modules/cm_preds/yaut_bracers.dm
@@ -35,7 +35,6 @@
var/charge_rate = 30
/// Cooldown on draining power from APC
var/charge_cooldown = COOLDOWN_BRACER_CHARGE
- var/cloaked = 0
var/cloak_timer = 0
var/cloak_malfunction = 0
/// Determines the alpha level of the cloaking device.
@@ -97,7 +96,7 @@
human_holder.update_power_display(perc_charge)
//Non-Yautja have a chance to get stunned with each power drain
- if(!cloaked)
+ if(!HAS_TRAIT(human_holder, TRAIT_CLOAKED))
return
if(human_holder.stat == DEAD)
decloak(human_holder, TRUE)
@@ -294,7 +293,7 @@
var/mob/living/carbon/human/wearer = loc
if(wearer.gloves == src)
wearer.visible_message(SPAN_DANGER("You hear a hiss and crackle!"), SPAN_DANGER("Your bracers hiss and spark!"), SPAN_DANGER("You hear a hiss and crackle!"))
- if(cloaked)
+ if(HAS_TRAIT(wearer, TRAIT_CLOAKED))
decloak(wearer, TRUE, DECLOAK_EMP)
else
var/turf/our_turf = get_turf(src)
@@ -337,7 +336,7 @@
//Non-Yautja have a chance to get stunned with each power drain
if((!HAS_TRAIT(human, TRAIT_YAUTJA_TECH) && !human.hunter_data.thralled) && prob(4))
- if(cloaked)
+ if(HAS_TRAIT(human, TRAIT_CLOAKED))
decloak(human, TRUE, DECLOAK_SPECIES)
shock_user(human)
@@ -345,14 +344,14 @@
/obj/item/clothing/gloves/yautja/hunter/dropped(mob/user)
move_chip_to_bracer()
- if(cloaked)
+ if(HAS_TRAIT(user, TRAIT_CLOAKED))
decloak(user, TRUE)
..()
/obj/item/clothing/gloves/yautja/hunter/on_enter_storage(obj/item/storage/S)
if(ishuman(loc))
var/mob/living/carbon/human/human = loc
- if(cloaked)
+ if(HAS_TRAIT(human, TRAIT_CLOAKED))
decloak(human, TRUE)
. = ..()
@@ -550,7 +549,7 @@
if(!istype(M) || M.is_mob_incapacitated())
return FALSE
- if(cloaked) //Turn it off.
+ if(HAS_TRAIT(caller, TRAIT_CLOAKED)) //Turn it off.
if(cloak_timer > world.time)
to_chat(M, SPAN_WARNING("Your cloaking device is busy! Time left: [max(round((cloak_timer - world.time) / 10), 1)] seconds."))
return FALSE
@@ -571,7 +570,6 @@
if(!drain_power(M, 50))
return FALSE
- cloaked = TRUE
ADD_TRAIT(M, TRAIT_CLOAKED, TRAIT_SOURCE_EQUIPMENT(WEAR_HANDS))
RegisterSignal(M, COMSIG_HUMAN_EXTINGUISH, PROC_REF(wrapper_fizzle_camouflage))
@@ -618,7 +616,6 @@
if(forced)
cloak_malfunction = world.time + decloak_timer
- cloaked = FALSE
REMOVE_TRAIT(user, TRAIT_CLOAKED, TRAIT_SOURCE_EQUIPMENT(WEAR_HANDS))
log_game("[key_name_admin(user)] has disabled their cloaking device.")
user.visible_message(SPAN_WARNING("[user] shimmers into existence!"), SPAN_WARNING("Your cloaking device deactivates."))
@@ -735,7 +732,7 @@
var/mob/living/carbon/human/M = caller
- if(cloaked)
+ if(HAS_TRAIT(M, TRAIT_CLOAKED))
to_chat(M, SPAN_WARNING("Not while you're cloaked. It might disrupt the sequence."))
return
if(M.stat == DEAD)
diff --git a/code/modules/cm_preds/yaut_items.dm b/code/modules/cm_preds/yaut_items.dm
index 9e56d0da7098..c86a3fdd23e2 100644
--- a/code/modules/cm_preds/yaut_items.dm
+++ b/code/modules/cm_preds/yaut_items.dm
@@ -430,10 +430,12 @@
if(do_after(user, 10 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC))
// Display fancy animation for you and the person you might be pulling (Legacy)
+ REMOVE_TRAIT_ALLSOURCES(user, TRAIT_CLOAKED)
user.visible_message(SPAN_WARNING("[icon2html(user, viewers(src))][user] disappears!"))
var/tele_time = animation_teleport_quick_out(user)
var/mob/living/M = user.pulling
if(istype(M)) // Pulled person
+ REMOVE_TRAIT_ALLSOURCES(M, TRAIT_CLOAKED)
M.visible_message(SPAN_WARNING("[icon2html(M, viewers(src))][M] disappears!"))
animation_teleport_quick_out(M)
diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm
index 5c1584c565c6..3b52a60419df 100644
--- a/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm
+++ b/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm
@@ -24,7 +24,7 @@
var/obj/item/clothing/gloves/yautja/hunter/YG = locate(/obj/item/clothing/gloves/yautja/hunter) in human
if(isyautja(human) && YG)
- if(YG.cloaked)
+ if(HAS_TRAIT(human, TRAIT_CLOAKED))
YG.decloak(human, TRUE, DECLOAK_PREDALIEN)
YG.cloak_timer = xeno_cooldown * 0.1