From 9608eb8a660a67ff0d877cdde50a20f9a101c393 Mon Sep 17 00:00:00 2001 From: TDSSS <32099540+TDSSS@users.noreply.github.com> Date: Fri, 26 Feb 2021 14:49:56 +0100 Subject: [PATCH 1/3] no more storing nodrop items --- code/game/machinery/suit_storage_unit.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index d4b2641b22f..2e16012feb7 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -332,6 +332,8 @@ I.play_tool_sound(user, I.tool_volume) /obj/machinery/suit_storage_unit/proc/store_item(obj/item/I, mob/user) + if(I.flags & NODROP) + return . = FALSE if(istype(I, /obj/item/clothing/suit) && !suit) suit = I From b2bf6ae1dee8f544550ee8307314522fc21bb970 Mon Sep 17 00:00:00 2001 From: TDSSS <32099540+TDSSS@users.noreply.github.com> Date: Fri, 26 Feb 2021 22:00:42 +0100 Subject: [PATCH 2/3] now uses canunequip --- code/game/machinery/suit_storage_unit.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index 2e16012feb7..9a8ec73040e 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -332,7 +332,7 @@ I.play_tool_sound(user, I.tool_volume) /obj/machinery/suit_storage_unit/proc/store_item(obj/item/I, mob/user) - if(I.flags & NODROP) + if(!user.canUnEquip(I)) return . = FALSE if(istype(I, /obj/item/clothing/suit) && !suit) From fd8e1a1a3ecd3ca649a65a90768bb1b20e9a0781 Mon Sep 17 00:00:00 2001 From: TDSSS <32099540+TDSSS@users.noreply.github.com> Date: Sat, 27 Feb 2021 00:39:53 +0100 Subject: [PATCH 3/3] refactored proc --- code/game/machinery/suit_storage_unit.dm | 46 +++++++++++++++--------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index 9a8ec73040e..b4749f0fac2 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -331,28 +331,42 @@ if(default_deconstruction_screwdriver(user, "panel", "close", I)) I.play_tool_sound(user, I.tool_volume) +/** + * Tries to store the item into whatever slot it can go, returns true if the item is stored successfully. + * +**/ /obj/machinery/suit_storage_unit/proc/store_item(obj/item/I, mob/user) - if(!user.canUnEquip(I)) - return - . = FALSE if(istype(I, /obj/item/clothing/suit) && !suit) - suit = I - . = TRUE + if(try_store_item(I, user)) + suit = I + return TRUE if(istype(I, /obj/item/clothing/head) && !helmet) - helmet = I - . = TRUE + if(try_store_item(I, user)) + helmet = I + return TRUE if(istype(I, /obj/item/clothing/mask) && !mask) - mask = I - . = TRUE + if(try_store_item(I, user)) + mask = I + return TRUE if(istype(I, /obj/item/clothing/shoes) && !boots) - boots = I - . = TRUE - if((istype(I, /obj/item/tank) || I.w_class <= WEIGHT_CLASS_SMALL) && !storage && !.) - storage = I - . = TRUE - if(.) - user.drop_item() + if(try_store_item(I, user)) + boots = I + return TRUE + if((istype(I, /obj/item/tank) || I.w_class <= WEIGHT_CLASS_SMALL) && !storage) + if(try_store_item(I, user)) + storage = I + return TRUE + return FALSE + +/** + * Tries to store the item, returns true if it's moved successfully, false otherwise (because of nodrop etc) + * +**/ +/obj/machinery/suit_storage_unit/proc/try_store_item(obj/item/I, mob/user) + if(user.drop_item()) I.forceMove(src) + return TRUE + return FALSE /obj/machinery/suit_storage_unit/power_change()