From 0ddb4b4d69da7f0e898ac0d1e9b91c85b0ae9ca2 Mon Sep 17 00:00:00 2001 From: ShizCalev Date: Mon, 22 Jul 2019 19:44:02 -0400 Subject: [PATCH] Fixes some dropItemToGround runtimes (#45257) * Simplified * unfucked * Documentation --- code/modules/mob/inventory.dm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index b44b35b05c0..71f883131f1 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -289,12 +289,17 @@ //The following functions are the same save for one small difference -//for when you want the item to end up on the ground -//will force move the item to the ground and call the turf's Entered +/** + * Used to drop an item (if it exists) to the ground. + * * Will pass as TRUE is successfully dropped, or if there is no item to drop. + * * Will pass FALSE if the item can not be dropped due to TRAIT_NODROP via doUnEquip() + * If the item can be dropped, it will be forceMove()'d to the ground and the turf's Entered() will be called. +*/ /mob/proc/dropItemToGround(obj/item/I, force = FALSE) - I.pixel_x = rand(-6,6) - I.pixel_y = rand(-6,6) - return doUnEquip(I, force, drop_location(), FALSE) + . = doUnEquip(I, force, drop_location(), FALSE) + if(. && I) //ensure the item exists and that it was dropped properly. + I.pixel_x = rand(-6,6) + I.pixel_y = rand(-6,6) //for when the item will be immediately placed in a loc other than the ground /mob/proc/transferItemToLoc(obj/item/I, newloc = null, force = FALSE)