Skip to content

Commit

Permalink
Merge pull request #3947 from out-of-phaze/fix/accessory-attackhand
Browse files Browse the repository at this point in the history
Fix being unable to open storage on accessories
  • Loading branch information
MistakeNot4892 authored Apr 28, 2024
2 parents 9b87f71 + 0348726 commit a353cde
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code/datums/extensions/storage/subtypes_tray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
allow_quick_gather = 1
use_sound = null

/datum/storage/remove_from_storage(mob/user, obj/item/W, atom/new_location, skip_update)
/datum/storage/tray/remove_from_storage(mob/user, obj/item/W, atom/new_location, skip_update)
. = ..()
W.vis_flags = initial(W.vis_flags)
W.appearance_flags = initial(W.appearance_flags)
Expand Down
7 changes: 6 additions & 1 deletion code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,18 @@
. = ..()
squash_item()

/// Whether this item can be picked up.
/// Primarily exists to be overridden to prevent, e.g. accessories from being removed by clicking on them while worn.
/obj/item/proc/can_be_picked_up(mob/user)
return !anchored

/obj/item/attack_hand(mob/user)

. = ..()
if(.)
return

if(anchored)
if(!can_be_picked_up(user))
return ..()

if(!user.check_dexterity(DEXTERITY_EQUIP_ITEM, silent = TRUE))
Expand Down
18 changes: 16 additions & 2 deletions code/modules/clothing/_clothing_accessories.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,23 @@
accessory.emp_act(severity)
..()

/obj/item/clothing/attack_hand(var/mob/user)
// Make 'strict' a bit less strict, for accessories.
// If we're checking strictly and our parent is an accessory,
// This will need to be handled differently if we ever allow non-clothing accessories!
/obj/item/clothing/can_interact_with_storage(user, strict = FALSE)
if((. = ..(user, FALSE)) || !strict) // Ignore the parent strictness check.
return .
if(istype(loc, /obj/item/clothing))
return TRUE //we aren't an object on the ground so don't call parent
var/obj/item/clothing/parent = loc
return (src in parent.accessories) && loc.can_interact_with_storage(user, strict)
return user == loc // Same as in parent, since we pass strict = FALSE to it.

/obj/item/clothing/can_be_picked_up(mob/user)
. = ..()
var/obj/item/clothing/parent = loc
return . && (!istype(parent) || !(src in parent.accessories))

/obj/item/clothing/attack_hand(var/mob/user)
//only forward to the attached accessory if the clothing is equipped (not in a storage)
if(!length(accessories) || loc != user)
return ..()
Expand Down

0 comments on commit a353cde

Please sign in to comment.