Refactor /mob/unEquip. (#27720)

* Refactor /mob/unEquip.

* fix things found in testing

* more fixes from testing

* fix removal of hooded suits

* fix flayers inability to deploy swarmprod

* fix changeling blade activation

* unnecessary parens

* pass default unequip args to proc overrides

* fix belts being able to forceMove into full hands
This commit is contained in:
warriorstar-orion
2025-01-10 01:58:35 +00:00
committed by GitHub
parent 17602326bc
commit 0eafad8475
213 changed files with 587 additions and 585 deletions
@@ -84,9 +84,7 @@
/datum/action/changeling/biodegrade/proc/dissolve_restraint(mob/living/carbon/human/user, obj/O)
if(O && (user.handcuffed == O || user.legcuffed == O || user.wear_suit == O))
user.unEquip(O)
O.visible_message("<span class='warning'>[O] dissolves into a puddle of sizzling goop.</span>")
O.forceMove(get_turf(user))
qdel(O)
/datum/action/changeling/biodegrade/proc/open_closet(mob/living/carbon/human/user, obj/structure/closet/C)
@@ -27,7 +27,7 @@
/datum/action/changeling/weapon/sting_action(mob/user)
SEND_SIGNAL(user, COMSIG_MOB_WEAPON_APPEARS)
if(!user.drop_item())
if(user.get_active_hand() && !user.drop_item())
to_chat(user, "[user.get_active_hand()] is stuck to your hand, you cannot grow a [weapon_name_simple] over it!")
return FALSE
var/obj/item/W = new weapon_type(user, silent, src)
@@ -97,15 +97,14 @@
..(H, target)
/datum/action/changeling/suit/sting_action(mob/living/carbon/human/user)
if(!user.unEquip(user.wear_suit))
to_chat(user, "\the [user.wear_suit] is stuck to your body, you cannot grow a [suit_name_simple] over it!")
return FALSE
if(!user.unEquip(user.head))
to_chat(user, "\the [user.head] is stuck on your head, you cannot grow a [helmet_name_simple] over it!")
return FALSE
user.unEquip(user.head)
user.unEquip(user.wear_suit)
if(user.wear_suit)
if(!user.drop_item_to_ground(user.wear_suit))
to_chat(user, "\the [user.wear_suit] is stuck to your body, you cannot grow a [suit_name_simple] over it!")
return FALSE
if(user.head)
if(!user.drop_item_to_ground(user.head))
to_chat(user, "\the [user.head] is stuck on your head, you cannot grow a [helmet_name_simple] over it!")
return FALSE
user.equip_to_slot_if_possible(new suit_type(user), ITEM_SLOT_OUTER_SUIT, TRUE, TRUE)
user.equip_to_slot_if_possible(new helmet_type(user), ITEM_SLOT_HEAD, TRUE, TRUE)
@@ -438,7 +437,7 @@
var/mob/living/carbon/human/H = loc
H.visible_message("<span class='warning'>With a sickening crunch, [H] reforms [H.p_their()] shield into an arm!</span>", "<span class='notice'>We assimilate our shield into our body</span>", "<span class='italics'>You hear organic matter ripping and tearing!</span>")
playsound(loc, 'sound/effects/bone_break_2.ogg', 100, TRUE)
H.unEquip(src, 1)
H.unequip(src, force = TRUE)
qdel(src)
return FALSE
else
@@ -576,9 +575,9 @@
// you've torn it up, get rid of it.
new /obj/effect/decal/cleanable/shreds(owner.loc)
// just unequip them since they qdel on drop
owner.unEquip(src, TRUE, TRUE)
owner.drop_item_to_ground(src, force = TRUE, silent = TRUE)
if(istype(owner.head, /obj/item/clothing/head/helmet/changeling))
owner.unEquip(owner.head, TRUE, TRUE)
owner.drop_item_to_ground(owner.head, force = TRUE, silent = TRUE)
return TRUE
@@ -50,7 +50,7 @@ RESTRICT_TYPE(/datum/antagonist/cultist)
if(remove_gear_on_removal)
for(var/I in H.contents)
if(is_type_in_list(I, CULT_CLOTHING))
H.unEquip(I)
H.drop_item_to_ground(I)
return ..()
@@ -38,7 +38,7 @@
create_new_weapon()
weapon_ref.flags |= (ABSTRACT | NODROP) // Just in case the item doesn't start with both of these, or somehow loses them.
if(!user.drop_item() || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
if(HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || (user.get_active_hand() && !user.drop_item()))
flayer.send_swarm_message("We cannot manifest [weapon_ref] into our active hand...")
return FALSE
@@ -53,8 +53,7 @@
SIGNAL_HANDLER // COMSIG_MOB_WILLINGLY_DROP + COMSIG_FLAYER_RETRACT_IMPLANTS
if(!any_hand && !istype(owner.get_active_hand(), weapon_type))
return
INVOKE_ASYNC(owner, TYPE_PROC_REF(/mob, unEquip), weapon_ref, TRUE)
INVOKE_ASYNC(weapon_ref, TYPE_PROC_REF(/atom/movable, forceMove), owner) // Just kinda shove it into the user
owner.transfer_item_to(weapon_ref, owner, force = TRUE, silent = TRUE)
owner.update_inv_l_hand()
owner.update_inv_r_hand()
playsound(get_turf(owner), 'sound/mecha/mechmove03.ogg', 25, TRUE, ignore_walls = FALSE)
@@ -362,7 +362,7 @@
if(M.back) //Lets not bork modsuits in funny ways.
var/obj/modsuit_safety = M.back
M.unEquip(modsuit_safety)
M.drop_item_to_ground(modsuit_safety)
stuff_to_transfer += modsuit_safety
// Regular items get removed in second
for(var/obj/item/I in M)
@@ -385,14 +385,14 @@
qdel(I)
continue
if(M.unEquip(I))
if(M.drop_item_to_ground(I))
stuff_to_transfer += I
// Remove accessories from the suit if present
if(length(H.w_uniform?.accessories))
for(var/obj/item/clothing/accessory/A in H.w_uniform.accessories)
H.w_uniform.detach_accessory(A, null)
H.unEquip(A)
H.drop_item_to_ground(A)
stuff_to_transfer += A
// Transfer it all (or drop it if not possible)