From 02c42ab23c470d482158ec5084060d3334a9e1be Mon Sep 17 00:00:00 2001 From: morrow <8919187+morrowwolf@users.noreply.github.com> Date: Fri, 5 Apr 2024 22:01:32 -0400 Subject: [PATCH] Fixes a few things --- code/__DEFINES/dcs/signals/atom/signals_item.dm | 5 +++++ code/datums/components/attached_headset.dm | 16 +++++++--------- code/modules/mob/living/carbon/human/human.dm | 3 +++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/code/__DEFINES/dcs/signals/atom/signals_item.dm b/code/__DEFINES/dcs/signals/atom/signals_item.dm index 532437e4a0..96b81129d2 100644 --- a/code/__DEFINES/dcs/signals/atom/signals_item.dm +++ b/code/__DEFINES/dcs/signals/atom/signals_item.dm @@ -15,6 +15,11 @@ ///from base of obj/item/dropped(): (mob/user) #define COMSIG_ITEM_DROPPED "item_drop" + +///from base of /mob/living/carbon/human/equip_to_slot_if_possible : (/obj/item/equipping_item, mob/living/carbon/human/user, slot) +#define COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP "item_attempting_human_equip" + #define COMPONENT_ITEM_CANCEL_ATTEMPTING_HUMAN_EQUIP (1<<0) + /// From base of /obj/item/proc/equipped(): (mob/user, slot) #define COMSIG_ITEM_EQUIPPED "item_equipped" /// From base of /obj/item/proc/unequipped(): (mob/user, slot) diff --git a/code/datums/components/attached_headset.dm b/code/datums/components/attached_headset.dm index 64a34d264f..1ad680c68e 100644 --- a/code/datums/components/attached_headset.dm +++ b/code/datums/components/attached_headset.dm @@ -43,7 +43,7 @@ /datum/component/attached_headset/Destroy() . = ..() - if(!headset.loc && !QDELETED(headset)) + if(!QDELETED(headset) && !headset.loc) qdel(headset) headset = null @@ -54,22 +54,20 @@ /datum/component/attached_headset/RegisterWithParent() . = ..() - RegisterSignal(parent, COMSIG_HUMAN_ATTEMPTING_EQUIP, PROC_REF(on_attempted_equip)) + RegisterSignal(parent, COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP, PROC_REF(on_attempted_equip)) RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equipped)) RegisterSignal(parent, COMSIG_ITEM_ATTACKED, PROC_REF(attackby)) RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(dropped)) RegisterSignal(headset, COMSIG_PARENT_QDELETING, PROC_REF(headset_deletion)) /datum/component/attached_headset/UnregisterFromParent() - UnregisterSignal(parent, COMSIG_HUMAN_ATTEMPTING_EQUIP) + UnregisterSignal(parent, COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP) UnregisterSignal(parent, COMSIG_ITEM_EQUIPPED) UnregisterSignal(parent, COMSIG_ITEM_ATTACKED) UnregisterSignal(parent, COMSIG_ITEM_DROPPED) UnregisterSignal(headset, COMSIG_PARENT_QDELETING) . = ..() - //Unregister your shit - Morrow - /datum/component/attached_headset/InheritComponent(datum/component/C, i_am_original) if(!istype(item_parent.loc, /mob)) return @@ -78,15 +76,15 @@ to_chat(user, SPAN_NOTICE("[parent] already has [headset] attached to it. Looks like you could remove it with a screwdriver.")) /// Cancels equipping parent if there's a headset already on the left ear -/datum/component/attached_headset/proc/on_attempted_equip(mob/living/carbon/human/user, obj/item/equipping_item, slot) +/datum/component/attached_headset/proc/on_attempted_equip(obj/item/equipping_item, mob/living/carbon/human/user, slot) SIGNAL_HANDLER if(slot != parent_activation_slot) return - if(user.wear_l_ear) - to_chat(user, SPAN_NOTICE("[equipping_item] has [headset] attached to it. It can't fit while you're wearing [user.wear_l_ear].")) - return COMPONENT_HUMAN_CANCEL_ATTEMPT_EQUIP + if(user.wear_l_ear || istype(user.wear_r_ear, /obj/item/device/radio/headset)) + to_chat(user, SPAN_NOTICE("[equipping_item] has [headset] attached to it. It can't fit while you're wearing [user.wear_l_ear ? user.wear_l_ear : user.wear_r_ear].")) + return COMPONENT_ITEM_CANCEL_ATTEMPTING_HUMAN_EQUIP /// When parent is equipped we check if it's the right slot, if so then we deploy our headset /datum/component/attached_headset/proc/on_equipped(obj/item/equipping_item, mob/user, slot) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index f37b1d6a86..3250ea2a71 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1653,6 +1653,9 @@ if(SEND_SIGNAL(src, COMSIG_HUMAN_ATTEMPTING_EQUIP, equipping_item, slot) & COMPONENT_HUMAN_CANCEL_ATTEMPT_EQUIP) return FALSE + if(SEND_SIGNAL(equipping_item, COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP, src, slot) & COMPONENT_ITEM_CANCEL_ATTEMPTING_HUMAN_EQUIP) + return FALSE + . = ..() /mob/living/carbon/human/make_dizzy(amount)