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
+1 -1
View File
@@ -351,7 +351,7 @@
return SHAME
user.visible_message("<span class='suicide'>[user] deconstructs [user.p_themselves()] with [src]!</span>")
for(var/obj/item/W in user) // Do not delete all their stuff.
user.unEquip(W) // Dump everything on the floor instead.
user.drop_item_to_ground(W) // Dump everything on the floor instead.
flags &= ~NODROP // NODROP must be removed so the RCD doesn't get dusted along with them. Having this come after the unequipping puts the RCD on top of the pile of stuff.
user.dust() // (held items fall to the floor when dusting).
return OBLITERATION
@@ -41,7 +41,7 @@
if(case)
to_chat(user, "<span class='warning'>There's already a bio-chip in the pad!</span>")
return
user.unEquip(C)
user.unequip(C)
C.forceMove(src)
case = C
update_icon(UPDATE_ICON_STATE)
+1 -2
View File
@@ -210,9 +210,8 @@
if(G.registered_name != registered_name && G.registered_name != "NOT SPECIFIED")
to_chat(user, "The guest pass cannot be attached to this ID.")
return
if(!user.unEquip(G))
if(!user.transfer_item_to(G, src))
return
G.loc = src
guest_pass = G
/obj/item/card/id/GetID()
@@ -80,13 +80,10 @@
to_chat(user, "<span class='notice'>[src] is already full!</span>")
return
if(!user.unEquip(I))
return
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
canisters += I
I.forceMove(src)
update_canister_stats()
if(user.transfer_item_to(I, src))
canisters += I
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
update_canister_stats()
/obj/item/chemical_flamethrower/proc/update_canister_stats()
if(!length(canisters))
+6 -6
View File
@@ -98,7 +98,7 @@ LIGHTERS ARE IN LIGHTERS.DM
// If the target has no cig, try to give them the cig.
var/mob/living/carbon/M = target
if(istype(M) && user.zone_selected == "mouth" && !M.wear_mask && user.a_intent == INTENT_HELP)
user.unEquip(src, TRUE)
user.drop_item_to_ground(src, force = TRUE)
M.equip_to_slot_if_possible(src, ITEM_SLOT_MASK)
if(target != user)
user.visible_message(
@@ -207,7 +207,7 @@ LIGHTERS ARE IN LIGHTERS.DM
e.set_up(round(reagents.get_reagent_amount("plasma") / 2.5, 1), get_turf(src), 0, 0)
e.start()
if(ismob(M))
M.unEquip(src, TRUE)
M.drop_item_to_ground(src, force = TRUE)
qdel(src)
return
@@ -217,7 +217,7 @@ LIGHTERS ARE IN LIGHTERS.DM
e.set_up(round(reagents.get_reagent_amount("fuel") / 5, 1), get_turf(src), 0, 0)
e.start()
if(ismob(M))
M.unEquip(src, TRUE)
M.drop_item_to_ground(src, force = TRUE)
qdel(src)
return
@@ -289,7 +289,7 @@ LIGHTERS ARE IN LIGHTERS.DM
if(ismob(loc))
var/mob/living/M = loc
to_chat(M, "<span class='notice'>Your [name] goes out.</span>")
M.unEquip(src, TRUE) //Force the un-equip so the overlays update
M.drop_item_to_ground(src, force = TRUE) //Force the un-equip so the overlays update
STOP_PROCESSING(SSobj, src)
qdel(src)
@@ -390,8 +390,8 @@ LIGHTERS ARE IN LIGHTERS.DM
to_chat(user, "<span class='warning'>You need to dry this first!</span>")
return
user.unEquip(plant, TRUE)
user.unEquip(src, TRUE)
user.unequip(plant, TRUE)
user.unequip(src, TRUE)
var/obj/item/clothing/mask/cigarette/rollie/custom/custom_rollie = new (get_turf(user))
custom_rollie.reagents.maximum_volume = plant.reagents.total_volume
plant.reagents.trans_to(custom_rollie, plant.reagents.total_volume)
+2 -2
View File
@@ -174,7 +174,7 @@
/obj/item/defibrillator/proc/remove_paddles(mob/user) // from your hands
var/mob/living/carbon/human/M = user
if(paddles in get_both_hands(M))
M.unEquip(paddles)
M.drop_item_to_ground(paddles)
paddles_on_defib = TRUE
update_icon(UPDATE_OVERLAYS)
return
@@ -387,7 +387,7 @@
/obj/item/shockpaddles/proc/check_defib_exists(mainunit, mob/living/carbon/human/M, obj/O)
if(!mainunit || !istype(mainunit, /obj/item/defibrillator)) //To avoid weird issues from admin spawns
M?.unEquip(O)
M?.unequip(O)
qdel(O)
return FALSE
else
+1 -1
View File
@@ -165,7 +165,7 @@
/obj/item/dice/d20/fate/equipped(mob/user, slot)
if(!ishuman(user) || !user.mind || iswizard(user))
to_chat(user, "<span class='warning'>You feel the magic of the dice is restricted to ordinary humans! You should leave it alone.</span>")
user.unEquip(src)
user.drop_item_to_ground(src)
/obj/item/dice/d20/fate/proc/create_smoke(amount)
var/datum/effect_system/smoke_spread/smoke = new
@@ -35,11 +35,10 @@
/obj/item/grenade/plastic/attackby__legacy__attackchain(obj/item/I, mob/user, params)
if(!nadeassembly && istype(I, /obj/item/assembly))
var/obj/item/assembly/A = I
if(!user.unEquip(I))
if(!user.transfer_item_to(A, src))
return ..()
nadeassembly = A
A.master = src
A.loc = src
assemblyattacher = user.ckey
to_chat(user, "<span class='notice'>You add [A] to [src].</span>")
playsound(src, 'sound/weapons/tap.ogg', 20, 1)
@@ -86,8 +85,9 @@
to_chat(user, "<span class='notice'>You start planting [src].[isnull(nadeassembly) ? " The timer is set to [det_time]..." : ""]</span>")
if(do_after(user, 1.5 SECONDS * toolspeed, target = AM))
if(!user.unEquip(src))
if(!user.unequip(src))
return
target = AM
loc = null
@@ -119,7 +119,7 @@
if(!ispath(gift_type,/obj/item)) return
var/obj/item/I = new gift_type(M)
M.unEquip(src, 1)
M.unequip(src, force = TRUE)
M.put_in_hands(I)
I.add_fingerprint(M)
qdel(src)
@@ -61,7 +61,7 @@
return TRUE
var/obj/item/grenade/bananade/G = new /obj/item/grenade/bananade
user.unEquip(src)
user.drop_item_to_ground(src)
user.put_in_hands(G)
G.deliveryamt = deliveryamt
to_chat(user, "<span class='notice'>You lock the assembly shut, readying it for HONK.</span>")
@@ -83,7 +83,7 @@
/obj/item/grenade/proc/update_mob()
if(ismob(loc))
var/mob/M = loc
M.unEquip(src)
M.drop_item_to_ground(src)
/obj/item/grenade/screwdriver_act(mob/living/user, obj/item/I)
if(!modifiable_timer)
+5 -3
View File
@@ -26,11 +26,13 @@
/obj/item/restraints/proc/finish_resist_restraints(mob/living/carbon/user, break_cuffs, silent)
if(!silent)
user.visible_message("<span class='danger'>[user] manages to [break_cuffs ? "break" : "remove"] [src]!</span>", "<span class='notice'>You successfully [break_cuffs ? "break" : "remove"] [src].</span>")
user.unEquip(src)
user.unequip(src)
if(break_cuffs)
qdel(src)
return TRUE
else
forceMove(user.drop_location())
//////////////////////////////
// MARK: HANDCUFFS
@@ -273,7 +275,7 @@
if(!R.use(1))
to_chat(user, "<span class='warning'>[R.amount > 1 ? "These rods" : "This rod"] somehow can't be used for crafting!</span>")
return
if(!user.unEquip(src))
if(!user.unequip(src))
return
var/obj/item/wirerod/W = new /obj/item/wirerod(get_turf(src))
if(!remove_item_from_storage(user))
@@ -290,7 +292,7 @@
to_chat(user, "<span class='notice'>You begin to apply [I] to [src]...</span>")
if(do_after(user, 3.5 SECONDS * M.toolspeed, target = src))
if(!M.use(6) || !user.unEquip(src))
if(!M.use(6) || !user.unequip(src))
return
var/obj/item/restraints/legcuffs/bola/S = new /obj/item/restraints/legcuffs/bola(get_turf(src))
to_chat(user, "<span class='notice'>You make some weights out of [I] and tie them to [src].</span>")
@@ -53,7 +53,7 @@
user.adjustBruteLoss(force)
user.adjustFireLoss(sanctify_force)
user.Weaken(10 SECONDS)
user.unEquip(src, 1)
user.drop_item_to_ground(src, force = TRUE)
user.visible_message("<span class='warning'>[src] slips out of the grip of [user] as they try to pick it up, bouncing upwards and smacking [user.p_them()] in the face!</span>", \
"<span class='warning'>[src] slips out of your grip as you pick it up, bouncing upwards and smacking you in the face!</span>")
playsound(get_turf(user), 'sound/effects/hit_punch.ogg', 50, TRUE, -1)
@@ -279,8 +279,6 @@
if(src.hacked) // That's right, we'll only check the "original" esword.
newSaber.hacked = TRUE
newSaber.item_color = "rainbow"
user.unEquip(W)
user.unEquip(src)
qdel(W)
qdel(src)
user.put_in_hands(newSaber)
@@ -81,7 +81,7 @@
return
if(I.flags & ABSTRACT)
return
if(!user.unEquip(I))
if(!user.unequip(I))
to_chat(user, "<span class='notice'>[I] doesn't seem to want to go into [src]!</span>")
return
I.forceMove(src)
@@ -56,7 +56,7 @@
if(I.w_class > w_class)
to_chat(user, "<span class='warning'>[I] is too large to fit into [src]!</span>")
return FALSE
if(!user.unEquip(I) || I.flags & (ABSTRACT | NODROP | DROPDEL))
if(!user.unequip(I) || I.flags & (ABSTRACT | NODROP | DROPDEL))
to_chat(user, "<span class='warning'>You can't put [I] into [src]!</span>")
return FALSE
loaded_items.Add(I)
@@ -144,7 +144,7 @@
if(tank)
to_chat(user, "<span class='warning'>[src] already has a tank.</span>")
return
if(!user.unEquip(new_tank))
if(!user.unequip(new_tank))
return
to_chat(user, "<span class='notice'>You hook [new_tank] up to [src].</span>")
new_tank.forceMove(src)
+1 -1
View File
@@ -79,7 +79,7 @@
if(tank)
to_chat(user, "<span class='warning'>[src] already has a tank.</span>")
return
if(!user.unEquip(thetank))
if(!user.unequip(thetank))
return
to_chat(user, "<span class='notice'>As you hook [thetank] up to [src], the fist locks into place around your arm.</span>")
tank = thetank
+1 -1
View File
@@ -52,7 +52,7 @@
/obj/item/staff/broom/attackby__legacy__attackchain(obj/O, mob/user)
if(istype(O, /obj/item/clothing/mask/horsehead))
new/obj/item/staff/broom/horsebroom(get_turf(src))
user.unEquip(O)
user.unequip(O)
qdel(O)
qdel(src)
return
@@ -70,11 +70,17 @@
if(!M.restrained() && !M.stat && can_use())
switch(over_object.name)
if("r_hand")
if(M.unEquip(src, silent = TRUE))
M.put_in_r_hand(src)
if(M.unequip(src))
if(M.r_hand)
M.drop_item_to_ground(src)
else
M.put_in_r_hand(src)
if("l_hand")
if(M.unEquip(src, silent = TRUE))
M.put_in_l_hand(src)
if(M.unequip(src))
if(M.l_hand)
M.drop_item_to_ground(src)
else
M.put_in_l_hand(src)
add_fingerprint(usr)
return
@@ -49,10 +49,10 @@
if(!user.restrained() && !user.stat)
switch(over_object.name)
if("r_hand")
user.unEquip(master_item, silent = TRUE)
user.unequip(master_item)
user.put_in_r_hand(master_item)
if("l_hand")
user.unEquip(master_item, silent = TRUE)
user.unequip(master_item)
user.put_in_l_hand(master_item)
master_item.add_fingerprint(user)
return 0
@@ -150,11 +150,11 @@
if(!M.restrained() && !M.stat)
switch(over_object.name)
if("r_hand")
if(!M.unEquip(src, silent = TRUE))
if(!M.unequip(src))
return
M.put_in_r_hand(src)
if("l_hand")
if(!M.unEquip(src, silent = TRUE))
if(!M.unequip(src))
return
M.put_in_l_hand(src)
add_fingerprint(usr)
@@ -445,7 +445,7 @@
if(user)
if(!Adjacent(user) && !isnewplayer(user))
return FALSE
if(!user.unEquip(I, silent = TRUE))
if(!user.unequip(I))
return FALSE
user.update_icons() //update our overlays
if(QDELING(I))
+1 -1
View File
@@ -130,7 +130,7 @@
if(C.maxcharge < hitcost)
to_chat(user, "<span class='warning'>[src] requires a higher capacity cell!</span>")
return
if(!user.unEquip(I))
if(!user.unequip(I))
return
I.forceMove(src)
cell = I
@@ -70,8 +70,7 @@
return
master = F
F.ptank = src
user.unEquip(src)
loc = F
user.transfer_item_to(src, F)
F.update_icon()
else
return ..()
@@ -68,7 +68,7 @@
/obj/item/watertank/proc/remove_noz()
if(ismob(noz.loc))
var/mob/M = noz.loc
M.unEquip(noz, 1)
M.drop_item_to_ground(noz, force = TRUE)
return
/obj/item/watertank/attack_hand(mob/user)
@@ -84,13 +84,13 @@
if("r_hand")
if(H.r_hand)
return
if(!H.unEquip(src))
if(!H.unequip(src))
return
H.put_in_r_hand(src)
if("l_hand")
if(H.l_hand)
return
if(!H.unEquip(src))
if(!H.unequip(src))
return
H.put_in_l_hand(src)
return
+2 -2
View File
@@ -146,7 +146,7 @@
if(HAS_TRAIT(user, TRAIT_HULK))
to_chat(user, "<span class='warning'>You grip the blade too hard and accidentally drop it!</span>")
if(HAS_TRAIT(src, TRAIT_WIELDED))
user.unEquip(src)
user.drop_item_to_ground(src)
return
..()
if(HAS_TRAIT(user, TRAIT_CLUMSY) && HAS_TRAIT(src, TRAIT_WIELDED) && prob(40) && force)
@@ -385,7 +385,7 @@
//Putting heads on spears
/obj/item/spear/attackby__legacy__attackchain(obj/item/I, mob/living/user)
if(istype(I, /obj/item/organ/external/head))
if(user.unEquip(src) && user.drop_item())
if(user.unequip(src) && user.drop_item())
to_chat(user, "<span class='notice'>You stick [I] onto the spear and stand it upright on the ground.</span>")
var/obj/structure/headspear/HS = new /obj/structure/headspear(get_turf(src))
var/matrix/M = matrix()
+4 -4
View File
@@ -142,8 +142,8 @@
S.add_plasmaglass()
S.update_icon()
if(!remove_item_from_storage(user))
user.unEquip(src)
user.unEquip(I)
user.unequip(src)
user.unequip(I)
user.put_in_hands(S)
to_chat(user, "<span class='notice'>You fasten the glass shard to the top of the rod with the cable.</span>")
@@ -154,8 +154,8 @@
var/obj/item/melee/baton/cattleprod/P = new /obj/item/melee/baton/cattleprod
if(!remove_item_from_storage(user))
user.unEquip(src)
user.unEquip(I)
user.unequip(src)
user.unequip(I)
user.put_in_hands(P)
to_chat(user, "<span class='notice'>You fasten [I] to the top of the rod with the cable.</span>")