Skip to content

Commit 55bb81c

Browse files
Quick equip from active storage, as well as a hotkey to close storage interfaces, and open equipped/held storage items (#669)
1 parent e5b94c4 commit 55bb81c

4 files changed

Lines changed: 85 additions & 10 deletions

File tree

code/modules/mob/inventory.dm

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,18 +458,43 @@
458458

459459
/// Tries to equip an item, store it in open storage, or in next best storage
460460
/obj/item/proc/equip_to_best_slot(mob/user)
461+
// NON-MODULE CHANGE START : prioritize active storage over suit storage and pockets
462+
var/slot_priority = src.slot_equipment_priority
463+
464+
if(!slot_priority)
465+
slot_priority = list( \
466+
ITEM_SLOT_BACK, ITEM_SLOT_ID,\
467+
ITEM_SLOT_ICLOTHING, ITEM_SLOT_OCLOTHING,\
468+
ITEM_SLOT_MASK, ITEM_SLOT_HEAD, ITEM_SLOT_NECK,\
469+
ITEM_SLOT_FEET, ITEM_SLOT_GLOVES,\
470+
ITEM_SLOT_EARS, ITEM_SLOT_EYES,\
471+
ITEM_SLOT_BELT\
472+
)
473+
474+
var/can_equip = FALSE
475+
476+
for(var/slot in slot_priority)
477+
if(src.mob_can_equip(user, slot, TRUE, TRUE))
478+
can_equip = TRUE
479+
break
480+
481+
if(!can_equip && user.active_storage?.attempt_insert(src, user, messages = FALSE))
482+
return TRUE
483+
461484
if(user.equip_to_appropriate_slot(src))
462485
user.update_held_items()
463486
return TRUE
464487
else
465488
if(equip_delay_self)
466489
return
467-
490+
/*
468491
if(user.active_storage?.attempt_insert(src, user, messages = FALSE))
469492
return TRUE
470-
493+
*/
494+
// NON-MODULE CHANGE END
471495
var/list/obj/item/possible = list(
472496
user.get_inactive_held_item(),
497+
user.get_item_by_slot(ITEM_SLOT_SUITSTORE), // NON-MODULE CHANGE : holsters, *maybe* some other things?
473498
user.get_item_by_slot(ITEM_SLOT_BELT),
474499
user.get_item_by_slot(ITEM_SLOT_DEX_STORAGE),
475500
user.get_item_by_slot(ITEM_SLOT_BACK),
@@ -502,17 +527,21 @@
502527
. += item
503528

504529
///proc extender of [/mob/verb/quick_equip] used to make the verb queuable if the server is overloaded
530+
531+
// NON-MODULE CHANGE START : quick equip to active storage if available
505532
/mob/proc/execute_quick_equip()
506533
var/obj/item/I = get_active_held_item()
507534
if(!I)
508-
to_chat(src, span_warning("You are not holding anything to equip!"))
509-
return
510-
if (temporarilyRemoveItemFromInventory(I) && !QDELETED(I))
511-
if(I.equip_to_best_slot(src))
512-
return
513-
if(put_in_active_hand(I))
514-
return
515-
I.forceMove(drop_location())
535+
var/datum/storage/storage = src.active_storage
536+
if(storage?.real_location.contents.len)
537+
var/obj/item/stored = storage.real_location.contents[storage.real_location.contents.len]
538+
if(!stored || stored.on_found(src))
539+
to_chat(src, span_warning("You are not holding anything to equip!"))
540+
return
541+
stored.attack_hand(src) // take out thing from item in storage slot
542+
if(!QDELETED(I))
543+
I.equip_to_best_slot(src)
544+
// NON-MODULE CHANGE END
516545

517546
//used in code for items usable by both carbon and drones, this gives the proper back slot for each mob.(defibrillator, backpack watertank, ...)
518547
/mob/proc/getBackSlot()

maplestation.dme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6598,6 +6598,7 @@
65986598
#include "maplestation_modules\code\modules\projectiles\projectile\bullets\shotgun.dm"
65996599
#include "maplestation_modules\code\modules\projectiles\projectile\energy\laser.dm"
66006600
#include "maplestation_modules\code\modules\projectiles\projectile\energy\ppc.dm"
6601+
#include "maplestation_modules\code\modules\quick_store\open_close_storage.dm"
66016602
#include "maplestation_modules\code\modules\radio_emote_helper\emote_helper.dm"
66026603
#include "maplestation_modules\code\modules\reagents\machines.dm"
66036604
#include "maplestation_modules\code\modules\reagents\chemistry\reagents\drink_reagents.dm"

maplestation_modules/code/__DEFINES/keybinding.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
#define COMSIG_KB_CLIENT_LOOC_DOWN "keybinding_client_looc_down"
33
#define COMSIG_KB_MOB_PIXEL_SHIFT_DOWN "keybinding_mob_pixel_shift_down"
44
#define COMSIG_KB_MOB_PIXEL_SHIFT_UP "keybinding_mob_pixel_shift_up"
5+
#define COMSIG_KB_HUMAN_OPENCLOSESTORAGE_DOWN "keybinding_human_opencclosestorage_down"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/datum/keybinding/human/open_close_storage
2+
hotkey_keys = list("ShiftR")
3+
name = "open_close_storage"
4+
full_name = "Open/Close storage"
5+
description = "Close the current storage interface, or open equipped storage if available"
6+
keybind_signal = COMSIG_KB_HUMAN_OPENCLOSESTORAGE_DOWN
7+
8+
/datum/keybinding/human/open_close_storage/down(client/user)
9+
. = ..()
10+
if(.)
11+
return
12+
var/mob/living/carbon/human/human = user.mob
13+
human.open_close_storage()
14+
return TRUE
15+
16+
/mob/living/carbon/human/proc/open_best_storage(mob/user)
17+
18+
var/list/obj/item/possible = list(
19+
user.get_active_held_item(),
20+
user.get_inactive_held_item(),
21+
user.get_item_by_slot(ITEM_SLOT_BACK),
22+
user.get_item_by_slot(ITEM_SLOT_BELT),
23+
user.get_item_by_slot(ITEM_SLOT_SUITSTORE),
24+
)
25+
for(var/thing in possible)
26+
if(isnull(thing))
27+
continue
28+
var/obj/item/gear = thing
29+
if(gear.atom_storage?.open_storage(user))
30+
return TRUE
31+
32+
/mob/living/carbon/human/verb/open_close_storage()
33+
set name = "open-close-storage"
34+
set hidden = TRUE
35+
36+
DEFAULT_QUEUE_OR_CALL_VERB(VERB_CALLBACK(src, PROC_REF(execute_open_close_storage)))
37+
38+
/mob/living/carbon/human/proc/execute_open_close_storage()
39+
var/datum/storage/storage = src.active_storage
40+
if(storage)
41+
storage.hide_contents(src)
42+
return
43+
open_best_storage(src)
44+
return

0 commit comments

Comments
 (0)