Files
Ghom 043677c6f6 Storing objects with slowdown in a backpack or belt (or any such storage) now properly updates your speed (#93967)
## About The Pull Request
Another one of those things that I've noticed when playing around with
fish tanks; The slowdown lingered even when the fish tank (which depends
on the total weight of fish inside it) was no longer held and was only
updated another item is equipped or held.

This is because `attempt_insert` doesn't end up calling `DoUnEquip`,
which along with `equip_to_slot`, is one of the cornerstones of the
whole inventory system that we have had for over a decade. Luckily, this
doesn't break things entirely because `item/doMove` seems to have a
fallback, but it only covers held items and only does half of what
`DoUnEquip` does, because it's its own copypaste code, disconnected from
the standard unequip call stack.

I've done some changes to make sure `DoUnEquip` is always called on
`doMove` if we find that the item still has the IN_INVENTORY flag. I've
also updated the code comment for it as well, to emphasize that the
measure is a fallback and not an excuse to call forceMove or Move if we
know that the object is held or equipped on a mob.
If something doesn't work, it'll be likely caught by the CI (it's a core
feature of the game after all) or stack traces.

Also, despite equipment slowdown supporting all mob types, when
equipping/unequipping items it's only applied to carbon mobs. This is
not _strictly_ a contributing factor to the titled issue but it still
limits a balance feature that ought to affect all mobs with hands and/or
equipment slots.

## Why It's Good For The Game
Fixing issues with inventory and storages. Hopefully improving and
modernizing years old code a little.
2025-12-04 17:40:16 -06:00

81 lines
2.1 KiB
Plaintext

// Drone inventory procs
/mob/living/basic/drone/doUnEquip(obj/item/item_dropping, force, newloc, no_move, invdrop = TRUE, silent = FALSE)
if(..())
update_held_items()
if(item_dropping == head)
head = null
update_worn_head()
if(item_dropping == internal_storage)
internal_storage = null
update_inv_internal_storage()
return TRUE
return FALSE
/mob/living/basic/drone/can_equip(obj/item/item, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE, ignore_equipped = FALSE, indirect_action = FALSE)
switch(slot)
if(ITEM_SLOT_HEAD)
if(head)
return FALSE
if(!((item.slot_flags & ITEM_SLOT_HEAD) || (item.slot_flags & ITEM_SLOT_MASK)))
return FALSE
return TRUE
if(ITEM_SLOT_DEX_STORAGE)
if(internal_storage)
return FALSE
return TRUE
..()
/mob/living/basic/drone/get_item_by_slot(slot_id)
switch(slot_id)
if(ITEM_SLOT_HEAD)
return head
if(ITEM_SLOT_DEX_STORAGE)
return internal_storage
return ..()
/mob/living/basic/drone/get_slot_by_item(obj/item/looking_for)
if(internal_storage == looking_for)
return ITEM_SLOT_DEX_STORAGE
if(head == looking_for)
return ITEM_SLOT_HEAD
return ..()
/mob/living/basic/drone/equip_to_slot(obj/item/equipping, slot, initial = FALSE, redraw_mob = FALSE, indirect_action = FALSE)
if(!slot)
return
if(!istype(equipping))
return
var/index = get_held_index_of_item(equipping)
if(index)
held_items[index] = null
update_held_items()
if(equipping.pulledby)
equipping.pulledby.stop_pulling()
equipping.screen_loc = null // will get moved if inventory is visible
equipping.forceMove(src) //This has to come before has_equipped is called.
SET_PLANE_EXPLICIT(equipping, ABOVE_HUD_PLANE, src)
switch(slot)
if(ITEM_SLOT_HEAD)
head = equipping
update_worn_head()
if(ITEM_SLOT_DEX_STORAGE)
internal_storage = equipping
update_inv_internal_storage()
else
to_chat(src, span_danger("You are trying to equip this item to an unsupported inventory slot. Report this to a coder!"))
return
//Call back for item being equipped to drone
has_equipped(equipping, slot)
/mob/living/basic/drone/getBackSlot()
return ITEM_SLOT_DEX_STORAGE