From 2a3921ca9025427409df3232836dd2a16e4fd1bd Mon Sep 17 00:00:00 2001 From: CrimsonShrike <29737699+CrimsonShrike@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:05:12 +0000 Subject: [PATCH] [MIRROR] Allows action buttons from accessories --- code/_onclick/hud/action.dm | 12 ++++++++ .../clothing/under/accessories/_accessory.dm | 1 + .../clothing/under/accessories/goggle_mods.dm | 29 +++++++++++++++---- code/modules/mob/living/living_defense.dm | 12 ++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/code/_onclick/hud/action.dm b/code/_onclick/hud/action.dm index 6ed88508b4e41..325e5edfa0545 100644 --- a/code/_onclick/hud/action.dm +++ b/code/_onclick/hud/action.dm @@ -9,6 +9,7 @@ #define AB_CHECK_LYING 4 #define AB_CHECK_ALIVE 8 #define AB_CHECK_INSIDE 16 +#define AB_CHECK_INSIDE_ACCESSORY 32 /datum/action @@ -112,6 +113,11 @@ if(check_flags & AB_CHECK_INSIDE) if(!(target in owner)) return 0 + if(check_flags & AB_CHECK_INSIDE_ACCESSORY) + if(!(target in owner)) + var/obj/item/clothing/C = target.loc + if (!(istype(C) && (C in owner) && (target in C.accessories))) + return 0 return 1 /datum/action/proc/UpdateName() @@ -237,6 +243,12 @@ /datum/action/item_action/CheckRemoval(mob/living/user) return !(target in user) +/datum/action/item_action/accessory + check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_ALIVE|AB_CHECK_INSIDE_ACCESSORY + +/datum/action/item_action/accessory/CheckRemoval(mob/living/user) + return !(target in user || (target.loc && (target.loc in user))) + /datum/action/item_action/hands_free check_flags = AB_CHECK_ALIVE|AB_CHECK_INSIDE diff --git a/code/modules/clothing/under/accessories/_accessory.dm b/code/modules/clothing/under/accessories/_accessory.dm index 2c98c7c7d559d..1f43dfc8a08ef 100644 --- a/code/modules/clothing/under/accessories/_accessory.dm +++ b/code/modules/clothing/under/accessories/_accessory.dm @@ -9,6 +9,7 @@ item_state = "" //no inhands slot_flags = SLOT_TIE w_class = ITEM_SIZE_SMALL + default_action_type = /datum/action/item_action/accessory var/accessory_flags = ACCESSORY_DEFAULT_FLAGS var/slot = ACCESSORY_SLOT_DECOR var/body_location = UPPER_TORSO //most accessories are here diff --git a/code/modules/clothing/under/accessories/goggle_mods.dm b/code/modules/clothing/under/accessories/goggle_mods.dm index ce62a81ef2c35..043a762e562ae 100644 --- a/code/modules/clothing/under/accessories/goggle_mods.dm +++ b/code/modules/clothing/under/accessories/goggle_mods.dm @@ -19,6 +19,13 @@ ) activation_sound = 'sound/items/goggles_charge.ogg' +/obj/item/clothing/accessory/glassesmod/attack_self(mob/user) + if(toggleable && !user.incapacitated()) + if(active) + deactivate(user) + else + activate(user) + /obj/item/clothing/accessory/glassesmod/proc/process_hud(mob/M) return @@ -29,19 +36,23 @@ /obj/item/clothing/accessory/glassesmod/activate() ..() - parent.CutOverlays(inv_overlay) + if (parent) + parent.CutOverlays(inv_overlay) inv_overlay = null inv_overlay = get_inv_overlay() - parent.AddOverlays(inv_overlay) - parent.update_vision() + if (parent) + parent.AddOverlays(inv_overlay) + parent.update_vision() /obj/item/clothing/accessory/glassesmod/deactivate() ..() - parent.CutOverlays(inv_overlay) + if (parent) + parent.CutOverlays(inv_overlay) inv_overlay = null inv_overlay = get_inv_overlay() - parent.AddOverlays(inv_overlay) - parent.update_vision() + if (parent) + parent.AddOverlays(inv_overlay) + parent.update_vision() /obj/item/clothing/accessory/glassesmod/thermal name = "thermal sights" @@ -57,6 +68,7 @@ tint = TINT_MODERATE activation_sound = 'sound/items/metal_clicking_4.ogg' deactivation_sound = 'sound/items/metal_clicking_4.ogg' + action_button_name = "Toggle Thermals" /obj/item/clothing/accessory/glassesmod/nvg @@ -73,6 +85,10 @@ tint = TINT_MODERATE activation_sound = 'sound/items/metal_clicking_4.ogg' deactivation_sound = 'sound/items/metal_clicking_4.ogg' + action_button_name = "Toggle Night Vision" + +/obj/item/clothing/accessory/glassesmod/hud + action_button_name = "Toggle HUD" /obj/item/clothing/accessory/glassesmod/hud/process_hud(mob/M) return @@ -125,6 +141,7 @@ deactivation_sound = 'sound/items/metal_clicking_13.ogg' toggle_on_message = "You flip the lenses down to protect your eyes." toggle_off_message = "You push the lenses up out of your face." + action_button_name = "Toggle welding lenses" /obj/item/clothing/accessory/glassesmod/vision/welding/activate(mob/usr) . = ..() diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index bad11f3e1992e..a06ff47313552 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -335,6 +335,18 @@ I.action.name = I.action_button_name I.action.SetTarget(I) I.action.Grant(src) + + //Clothing accessories + var/obj/item/clothing/C = I + if (istype(C)) + for(var/obj/item/clothing/accessory/CA in C.accessories) + if(CA.action_button_name) + if(!CA.action) + CA.action = new CA.default_action_type + CA.action.name = CA.action_button_name + CA.action.SetTarget(CA) + CA.action.Grant(src) + return /mob/living/update_action_buttons()