From fa1632e64714d984a226de2d2172255cb9c8b5ae Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 5 Sep 2024 04:21:09 +0200 Subject: [PATCH] [MIRROR] Cardborg costume no longer gets its appearance deleted when you drop a second hat/suit you are holding in your hand (#29627) Cardborg costume no longer gets its appearance deleted when you drop a second hat/suit you are holding in your hand (#86037) ## About The Pull Request Closes #35748 Refactored how the costume works by moving most logic onto the suit and instead tracking the helmet via signals. A bit more complex, but bug-free ## Changelog :cl: fix: Cardborg costume no longer gets its appearance deleted when you drop a second hat/suit you are holding in your hand /:cl: --------- Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/modules/clothing/head/costume.dm | 12 +++------ code/modules/clothing/suits/costume.dm | 35 +++++++++++++++++++------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/code/modules/clothing/head/costume.dm b/code/modules/clothing/head/costume.dm index 5442210aecd..a1cfd37ec0d 100644 --- a/code/modules/clothing/head/costume.dm +++ b/code/modules/clothing/head/costume.dm @@ -119,14 +119,10 @@ /obj/item/clothing/head/costume/cardborg/equipped(mob/living/user, slot) ..() if(ishuman(user) && (slot & ITEM_SLOT_HEAD)) - var/mob/living/carbon/human/H = user - if(istype(H.wear_suit, /obj/item/clothing/suit/costume/cardborg)) - var/obj/item/clothing/suit/costume/cardborg/CB = H.wear_suit - CB.disguise(user, src) - -/obj/item/clothing/head/costume/cardborg/dropped(mob/living/user) - ..() - user.remove_alt_appearance("standard_borg_disguise") + var/mob/living/carbon/human/human_user = user + if(istype(human_user.wear_suit, /obj/item/clothing/suit/costume/cardborg)) + var/obj/item/clothing/suit/costume/cardborg/suit = human_user.wear_suit + suit.disguise(user, src) /obj/item/clothing/head/costume/bronze name = "bronze hat" diff --git a/code/modules/clothing/suits/costume.dm b/code/modules/clothing/suits/costume.dm index 75c1c5d850d..5184e879296 100644 --- a/code/modules/clothing/suits/costume.dm +++ b/code/modules/clothing/suits/costume.dm @@ -166,6 +166,7 @@ body_parts_covered = CHEST|GROIN|LEGS flags_inv = HIDEJUMPSUIT dog_fashion = /datum/dog_fashion/back + var/in_use = FALSE /obj/item/clothing/suit/costume/cardborg/equipped(mob/living/user, slot) ..() @@ -174,17 +175,33 @@ /obj/item/clothing/suit/costume/cardborg/dropped(mob/living/user) ..() + if (!in_use) + return user.remove_alt_appearance("standard_borg_disguise") + in_use = FALSE + var/mob/living/carbon/human/human_user = user + if (istype(human_user.head, /obj/item/clothing/head/costume/cardborg)) + UnregisterSignal(human_user.head, COMSIG_ITEM_DROPPED) -/obj/item/clothing/suit/costume/cardborg/proc/disguise(mob/living/carbon/human/H, obj/item/clothing/head/costume/cardborg/borghead) - if(istype(H)) - if(!borghead) - borghead = H.head - if(istype(borghead, /obj/item/clothing/head/costume/cardborg)) //why is this done this way? because equipped() is called BEFORE THE ITEM IS IN THE SLOT WHYYYY - var/image/I = image(icon = 'icons/mob/silicon/robots.dmi' , icon_state = "robot", loc = H) - I.override = 1 - I.add_overlay(mutable_appearance('icons/mob/silicon/robots.dmi', "robot_e")) //gotta look realistic - add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/silicons, "standard_borg_disguise", I) //you look like a robot to robots! (including yourself because you're totally a robot) +/obj/item/clothing/suit/costume/cardborg/proc/disguise(mob/living/carbon/human/human_user, obj/item/clothing/head/costume/cardborg/borghead) + if(!istype(human_user)) + return + if(!borghead) + borghead = human_user.head + if(!istype(borghead, /obj/item/clothing/head/costume/cardborg)) //why is this done this way? because equipped() is called BEFORE THE ITEM IS IN THE SLOT WHYYYY + return + RegisterSignal(borghead, COMSIG_ITEM_DROPPED, PROC_REF(helmet_drop)) // Don't need to worry about qdeleting since dropped will be called from there + in_use = TRUE + var/image/override_image = image(icon = 'icons/mob/silicon/robots.dmi' , icon_state = "robot", loc = human_user) + override_image.override = TRUE + override_image.add_overlay(mutable_appearance('icons/mob/silicon/robots.dmi', "robot_e")) //gotta look realistic + add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/silicons, "standard_borg_disguise", override_image) //you look like a robot to robots! (including yourself because you're totally a robot) + +/obj/item/clothing/suit/costume/cardborg/proc/helmet_drop(datum/source, mob/living/user) + SIGNAL_HANDLER + UnregisterSignal(source, COMSIG_ITEM_DROPPED) + user.remove_alt_appearance("standard_borg_disguise") + in_use = FALSE /obj/item/clothing/suit/costume/snowman name = "snowman outfit"