From 8b4048f65f046f0d95a8f9027a27604f8bf53496 Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Sun, 27 Jun 2021 14:06:51 -0400 Subject: [PATCH] Improve E-quip hotkey --- code/modules/mob/inventory.dm | 4 +-- .../mob/living/carbon/human/inventory.dm | 31 +++++++++++++++++-- code/modules/mob/living/inventory.dm | 16 +++++++--- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 35df5ef8a13..13bc02dda48 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -50,7 +50,7 @@ var/list/slot_equipment_priority = list( \ /mob/proc/equip_to_slot_if_possible(obj/item/W as obj, slot, del_on_fail = 0, disable_warning = 0, redraw_mob = 1) if(!W) return 0 - if(!W.mob_can_equip(src, slot)) + if(!W.mob_can_equip(src, slot, disable_warning)) if(del_on_fail) qdel(W) @@ -93,7 +93,7 @@ var/list/slot_equipment_priority = list( \ return 0 -/mob/proc/equip_to_storage(obj/item/newitem) +/mob/proc/equip_to_storage(obj/item/newitem, user_initiated = FALSE) return 0 /* Hands */ diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index d756271286d..7aa1dee24f9 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -16,13 +16,40 @@ This saves us from having to call add_fingerprint() any time something is put in if(!I) to_chat(H, "You are not holding anything to equip.") return + + var/moved = FALSE + + // Try an equipment slot if(H.equip_to_appropriate_slot(I)) + moved = TRUE + + // No? Try a storage item. + else if(H.equip_to_storage(I, TRUE)) + moved = TRUE + + // No?! Well, give up. + if(!moved) + to_chat(H, "You are unable to equip that.") + + // Update hand icons + else if(hand) update_inv_l_hand(0) else update_inv_r_hand(0) - else - to_chat(H, "You are unable to equip that.") + +/mob/living/carbon/human/equip_to_storage(obj/item/newitem, user_initiated = FALSE) + // Try put it in their belt first + if(istype(src.belt,/obj/item/weapon/storage)) + var/obj/item/weapon/storage/wornbelt = src.belt + if(wornbelt.can_be_inserted(newitem, 1)) + if(user_initiated) + wornbelt.handle_item_insertion(newitem) + else + newitem.forceMove(wornbelt) + return wornbelt + + return ..() /mob/living/carbon/human/proc/equip_in_one_of_slots(obj/item/W, list/slots, del_on_fail = 1) for (var/slot in slots) diff --git a/code/modules/mob/living/inventory.dm b/code/modules/mob/living/inventory.dm index 8d4a66def31..c2ea2986836 100644 --- a/code/modules/mob/living/inventory.dm +++ b/code/modules/mob/living/inventory.dm @@ -6,19 +6,25 @@ var/obj/item/weapon/tank/internal = null//Human/Monkey var/obj/item/clothing/mask/wear_mask = null//Carbon -/mob/living/equip_to_storage(obj/item/newitem) +/mob/living/equip_to_storage(obj/item/newitem, user_initiated = FALSE) // Try put it in their backpack if(istype(src.back,/obj/item/weapon/storage)) var/obj/item/weapon/storage/backpack = src.back if(backpack.can_be_inserted(newitem, 1)) - newitem.forceMove(src.back) - return 1 + if(user_initiated) + backpack.handle_item_insertion(newitem) + else + newitem.forceMove(src.back) + return src.back // Try to place it in any item that can store stuff, on the mob. for(var/obj/item/weapon/storage/S in src.contents) if (S.can_be_inserted(newitem, 1)) - newitem.forceMove(S) - return 1 + if(user_initiated) + S.handle_item_insertion(newitem) + else + newitem.forceMove(S) + return S return 0 //Returns the thing in our active hand