From e9acb9fde46dc6d3c75155c7b0fd8d304989008e Mon Sep 17 00:00:00 2001 From: GDN <96800819+GDNgit@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:37:09 -0500 Subject: [PATCH] prevents xenos catching thrown items they can't hold (#21766) * prevents xenos catching thrown items they can't hold * gogo gadget duplicate code * trait solution --- code/__HELPERS/trait_helpers.dm | 1 + code/_globalvars/traits.dm | 3 ++- code/game/objects/items.dm | 2 +- code/modules/mob/living/carbon/alien/alien_defense.dm | 5 ++++- code/modules/mob/living/carbon/alien/special/facehugger.dm | 4 +--- code/modules/mob/living/carbon/carbon_defense.dm | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/code/__HELPERS/trait_helpers.dm b/code/__HELPERS/trait_helpers.dm index 47bbaeb1a1c..d04faa93480 100644 --- a/code/__HELPERS/trait_helpers.dm +++ b/code/__HELPERS/trait_helpers.dm @@ -207,6 +207,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define TRAIT_NOSELFIGNITION_HEAD_ONLY "no_selfignition_head_only" #define TRAIT_CONTORTED_BODY "contorted_body" #define TRAIT_DEFLECTS_PROJECTILES "trait_deflects_projectiles" +#define TRAIT_XENO_INTERACTABLE "can_be_interacted_with_by_xenos" //***** ITEM AND MOB TRAITS *****// /// Show what machine/door wires do when held. diff --git a/code/_globalvars/traits.dm b/code/_globalvars/traits.dm index ae94c049701..154827e166d 100644 --- a/code/_globalvars/traits.dm +++ b/code/_globalvars/traits.dm @@ -86,7 +86,8 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_BUTCHER_HUMANS" = TRAIT_BUTCHERS_HUMANS, "TRAIT_CMAGGED" = TRAIT_CMAGGED, "TRAIT_FORCES_OPEN_DOORS" = TRAIT_FORCES_OPEN_DOORS_ITEM, - "TRAIT_OBSCURED_WIRES" = TRAIT_OBSCURED_WIRES + "TRAIT_OBSCURED_WIRES" = TRAIT_OBSCURED_WIRES, + "TRAIT_XENO_INTERACTABLE" = TRAIT_XENO_INTERACTABLE ) )) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index c85911b0732..7fa90759ac8 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -335,7 +335,7 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons /obj/item/attack_alien(mob/user) var/mob/living/carbon/alien/A = user - if(!A.has_fine_manipulation) + if(!A.has_fine_manipulation && !HAS_TRAIT(src, TRAIT_XENO_INTERACTABLE)) if(src in A.contents) // To stop Aliens having items stuck in their pockets A.unEquip(src) to_chat(user, "Your claws aren't capable of such fine manipulation!") diff --git a/code/modules/mob/living/carbon/alien/alien_defense.dm b/code/modules/mob/living/carbon/alien/alien_defense.dm index 5b45fd6181b..de23bdcd5bb 100644 --- a/code/modules/mob/living/carbon/alien/alien_defense.dm +++ b/code/modules/mob/living/carbon/alien/alien_defense.dm @@ -1,5 +1,8 @@ /mob/living/carbon/alien/hitby(atom/movable/AM, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum) - ..(AM, hitpush = FALSE) + if(!skipcatch && in_throw_mode && !HAS_TRAIT(src, TRAIT_HANDS_BLOCKED) && HAS_TRAIT(AM, TRAIT_XENO_INTERACTABLE) && !restrained()) + throw_mode_off() + AM.attack_hand(src) + ..(AM, skipcatch = TRUE, hitpush = FALSE) /*Code for aliens attacking aliens. Because aliens act on a hivemind, I don't see them as very aggressive with each other. As such, they can either help or harm other aliens. Help works like the human help command while harm is a simple nibble. diff --git a/code/modules/mob/living/carbon/alien/special/facehugger.dm b/code/modules/mob/living/carbon/alien/special/facehugger.dm index e76cd3f68c8..342cc29e2ea 100644 --- a/code/modules/mob/living/carbon/alien/special/facehugger.dm +++ b/code/modules/mob/living/carbon/alien/special/facehugger.dm @@ -27,6 +27,7 @@ /obj/item/clothing/mask/facehugger/Initialize(mapload) . = ..() AddComponent(/datum/component/proximity_monitor) + ADD_TRAIT(src, TRAIT_XENO_INTERACTABLE, UID()) /obj/item/clothing/mask/facehugger/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, attack_dir) ..() @@ -36,9 +37,6 @@ /obj/item/clothing/mask/facehugger/attackby(obj/item/O, mob/user, params) return O.attack_obj(src, user, params) -/obj/item/clothing/mask/facehugger/attack_alien(mob/user) //can be picked up by aliens - return attack_hand(user) - /obj/item/clothing/mask/facehugger/attack_hand(mob/user) if((stat != DEAD && !sterile) && !isalien(user)) if(Attach(user)) diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 2d446a7e1ec..6a19650f051 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -8,9 +8,9 @@ if(AM.GetComponent(/datum/component/two_handed)) if(get_inactive_hand()) return FALSE + throw_mode_off() put_in_active_hand(AM) visible_message("[src] catches [AM]!") - throw_mode_off() SEND_SIGNAL(src, COMSIG_CARBON_THROWN_ITEM_CAUGHT, AM) return TRUE return ..()