From c143e02c04819258dbbb339ff1bd7d0612f481b4 Mon Sep 17 00:00:00 2001 From: Geeves Date: Fri, 8 Nov 2024 17:34:49 +0200 Subject: [PATCH] Quick Armor Swap (#19902) * You can now instantly replace the armor accessories on plate carriers by clicking on it with the new plate or guard you want to replace them with. --- code/modules/clothing/clothing_accessories.dm | 1 + code/modules/clothing/suits/modular_armor.dm | 8 ++++++++ .../clothing/under/accessories/accessory.dm | 4 ++++ code/modules/clothing/under/accessories/armor.dm | 16 ++++++++++++++++ html/changelogs/geeves-quick_swap.yml | 6 ++++++ 5 files changed, 35 insertions(+) create mode 100644 html/changelogs/geeves-quick_swap.yml diff --git a/code/modules/clothing/clothing_accessories.dm b/code/modules/clothing/clothing_accessories.dm index 71c6d3c4f78..2e9a67a28e4 100644 --- a/code/modules/clothing/clothing_accessories.dm +++ b/code/modules/clothing/clothing_accessories.dm @@ -22,6 +22,7 @@ return var/obj/item/clothing/accessory/A = attacking_item + A.before_attached(src, user) if(can_attach_accessory(A)) user.drop_item() attach_accessory(user, A) diff --git a/code/modules/clothing/suits/modular_armor.dm b/code/modules/clothing/suits/modular_armor.dm index a1784258339..d527e4f6237 100644 --- a/code/modules/clothing/suits/modular_armor.dm +++ b/code/modules/clothing/suits/modular_armor.dm @@ -150,6 +150,14 @@ bomb = ARMOR_BOMB_PADDED ) +/obj/item/clothing/accessory/armor_plate/before_attached(var/obj/item/clothing/clothing, var/mob/user) + if(!clothing.valid_accessory_slots || !(slot in clothing.valid_accessory_slots)) + return + var/obj/item/clothing/accessory/armor_plate/existing_plate = locate() in clothing.accessories + if(!existing_plate) + return + clothing.remove_accessory(user, existing_plate) + /obj/item/clothing/accessory/armor_plate/generic name = "standard armor plate" desc = "A light-weight kevlar armor plate in drab black colors. A galactic favourite of Zavodskoi fans." diff --git a/code/modules/clothing/under/accessories/accessory.dm b/code/modules/clothing/under/accessories/accessory.dm index c3f828e3371..98723601c83 100644 --- a/code/modules/clothing/under/accessories/accessory.dm +++ b/code/modules/clothing/under/accessories/accessory.dm @@ -83,6 +83,10 @@ accessory_mob_overlay.appearance_flags = RESET_ALPHA|RESET_COLOR return accessory_mob_overlay +/// Gets called before 'can_attach_accessory()' is called in clothing_accessories.dm +/obj/item/clothing/accessory/proc/before_attached(var/obj/item/clothing/S, var/mob/user) + return + //when user attached an accessory to S /obj/item/clothing/accessory/proc/on_attached(var/obj/item/clothing/S, var/mob/user) if(!istype(S)) diff --git a/code/modules/clothing/under/accessories/armor.dm b/code/modules/clothing/under/accessories/armor.dm index 5fa61c32b50..e19bed2b994 100644 --- a/code/modules/clothing/under/accessories/armor.dm +++ b/code/modules/clothing/under/accessories/armor.dm @@ -20,6 +20,14 @@ drop_sound = 'sound/items/drop/boots.ogg' pickup_sound = 'sound/items/pickup/boots.ogg' +/obj/item/clothing/accessory/leg_guard/before_attached(var/obj/item/clothing/clothing, var/mob/user) + if(!clothing.valid_accessory_slots || !(slot in clothing.valid_accessory_slots)) + return + var/obj/item/clothing/accessory/leg_guard/existing_guard = locate() in clothing.accessories + if(!existing_guard) + return + clothing.remove_accessory(user, existing_guard) + /obj/item/clothing/accessory/leg_guard/generic name = "standard leg guards" icon_state = "legguards_generic" @@ -195,6 +203,14 @@ drop_sound = 'sound/items/drop/axe.ogg' pickup_sound = 'sound/items/pickup/axe.ogg' +/obj/item/clothing/accessory/arm_guard/before_attached(var/obj/item/clothing/clothing, var/mob/user) + if(!clothing.valid_accessory_slots || !(slot in clothing.valid_accessory_slots)) + return + var/obj/item/clothing/accessory/arm_guard/existing_guard = locate() in clothing.accessories + if(!existing_guard) + return + clothing.remove_accessory(user, existing_guard) + /obj/item/clothing/accessory/arm_guard/generic name = "standard arm guards" icon_state = "armguards_generic" diff --git a/html/changelogs/geeves-quick_swap.yml b/html/changelogs/geeves-quick_swap.yml new file mode 100644 index 00000000000..ec6f2a0b0f9 --- /dev/null +++ b/html/changelogs/geeves-quick_swap.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "You can now instantly replace the armor accessories on plate carriers by clicking on it with the new plate or guard you want to replace them with." \ No newline at end of file