Skip to content

Commit

Permalink
Iteration VI
Browse files Browse the repository at this point in the history
Removing the use of 2 variables to make the system more consistent
  • Loading branch information
OverDriveZ committed Oct 9, 2023
1 parent b66d2cf commit 79a1e93
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
44 changes: 21 additions & 23 deletions code/modules/mob/inventory.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//This variable is needed in order to remember the origin of the storage of an item.
GLOBAL_VAR_INIT(quick_equip_memory_item, 0)
GLOBAL_VAR_INIT(quick_equip_memory_origin, 0)
// GLOBAL_VAR_INIT(quick_equip_memory_item, 0)
// GLOBAL_VAR_INIT(quick_equip_memory_origin, 0)
GLOBAL_VAR_INIT(quick_equip_cowboy_delay_negation, 0)
//These procs handle putting s tuff in your hands
//as they handle all relevant stuff like adding it to the player's screen and updating their overlays.
Expand Down Expand Up @@ -476,24 +476,26 @@ GLOBAL_VAR_INIT(quick_equip_cowboy_delay_negation, 0)
var/obj/item/storage
var/obj/item/I = get_active_held_item()

if(I)
if(I == GLOB.quick_equip_memory_item) //did I unsheathe my item from a holster or my boots?
if(GLOB.quick_equip_memory_origin == "SLOT_NECK") //was it previously coming from my holster?
GLOB.quick_equip_memory_item = null //hard reset all variables
GLOB.quick_equip_memory_origin = null
//obj/item/melee/onehanded

if(I) //are we holding something in our hands?
storage = get_item_by_slot(SLOT_S_STORE)
if(storage) //if it's empty, put the revolver there (if I'm carrying a pouch there for example)
if(istype(I, /obj/item/gun/ballistic/revolver) || istype(I, /obj/item/gun/ballistic/automatic/pistol))
storage = get_item_by_slot(SLOT_NECK)
SEND_SIGNAL(storage, COMSIG_TRY_STORAGE_INSERT, I, src) //store this exact item where it was coming from
return
else if(GLOB.quick_equip_memory_origin == "SLOT_SHOES") //was it previously coming from my boots?
GLOB.quick_equip_memory_item = null //Hard reset all variables
GLOB.quick_equip_memory_origin = null
storage = get_item_by_slot(SLOT_SHOES)
SEND_SIGNAL(storage, COMSIG_TRY_STORAGE_INSERT, I, src) //store this exact item where it was coming from
return
GLOB.quick_equip_memory_item = null //hard reset for both variables, we want to forget the location immediately.
GLOB.quick_equip_memory_origin = null
if(storage)
if(SEND_SIGNAL(storage, COMSIG_CONTAINS_STORAGE))
if(SEND_SIGNAL(storage, COMSIG_TRY_STORAGE_INSERT, I, src))
return

storage = get_item_by_slot(SLOT_SHOES)
if(istype(I, /obj/item/melee/onehanded/knife))
if(storage)
if(SEND_SIGNAL(storage, COMSIG_CONTAINS_STORAGE))
if(SEND_SIGNAL(storage, COMSIG_TRY_STORAGE_INSERT, I, src))
return
I.equip_to_best_slot(src)
return

else //Are we empty handed?
storage = get_item_by_slot(SLOT_S_STORE)
if(storage) //Are we carrying something in this storage slot?
Expand All @@ -518,20 +520,16 @@ GLOBAL_VAR_INIT(quick_equip_cowboy_delay_negation, 0)
if(firearm && !firearm.on_found(src))
GLOB.quick_equip_cowboy_delay_negation = 1
firearm.attack_hand(src) //Slap my hands with the contents of this storage, which is allegedly only one item.
GLOB.quick_equip_memory_item = firearm
GLOB.quick_equip_memory_origin = "SLOT_NECK"
spawn(1) //it's not needed, but let's wait for the system to actually process the firedelay.
GLOB.quick_equip_cowboy_delay_negation = 0
return
return
storage = get_item_by_slot(SLOT_SHOES) //Shoes are a little different, we don't want to return the item itself, but rather its contents.
if(storage) //Are we carrying something in this storage slot?
if(SEND_SIGNAL(storage, COMSIG_CONTAINS_STORAGE)) //Is this a storage item?
if(storage.contents.len) //there's something to take out.
I = storage.contents[storage.contents.len] //take the item out
if(I && !I.on_found(src))
I.attack_hand(src) //Slap my hands with the contents of this storage, which is allegedly only one item.
GLOB.quick_equip_memory_item = I
GLOB.quick_equip_memory_origin = "SLOT_SHOES"
return

//used in code for items usable by both carbon and drones, this gives the proper back slot for each mob.(defibrillator, backpack watertank, ...)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
stored.attack_hand(src) // take out thing from backpack
return

/mob/living/carbon/human/proc/smart_equipbelt() // put held thing in belt or take most recent item out of belt
/mob/living/carbon/human/proc/smart_equipbelt() // put held thing in belt or take most recent item out of belt //
if(incapacitated())
return
var/obj/item/thing = get_active_held_item()
Expand Down

0 comments on commit 79a1e93

Please sign in to comment.