mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 19:44:58 +01:00
[MIRROR] Kills the quickswap shortcut (#1923)
* Kills the quickswap shortcut (#55209) * Kills the quickswap shortcut Co-authored-by: Ryll Ryll <3589655+Ryll-Ryll@users.noreply.github.com>
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
#define COMSIG_KB_HUMAN_QUICKEQUIP_DOWN "keybinding_human_quickequip_down"
|
||||
#define COMSIG_KB_HUMAN_QUICKEQUIPBELT_DOWN "keybinding_human_quickequipbelt_down"
|
||||
#define COMSIG_KB_HUMAN_BAGEQUIP_DOWN "keybinding_human_bagequip_down"
|
||||
#define COMSIG_KB_HUMAN_EQUIPMENTSWAP_DOWN "keybinding_human_equipmentswap_down"
|
||||
#define COMSIG_KB_HUMAN_SUITEQUIP_DOWN "keybinding_human_suitequip_down"
|
||||
|
||||
//Living
|
||||
|
||||
@@ -56,18 +56,3 @@
|
||||
slot_type = ITEM_SLOT_SUITSTORE
|
||||
slot_item_name = "suit storage slot item"
|
||||
keybind_signal = COMSIG_KB_HUMAN_SUITEQUIP_DOWN
|
||||
|
||||
/datum/keybinding/human/equipment_swap
|
||||
hotkey_keys = list("V")
|
||||
name = "equipment_swap"
|
||||
full_name = "Equipment Swap"
|
||||
description = "Equip the currently held item by swapping it out with the already equipped item after a small delay"
|
||||
keybind_signal = COMSIG_KB_HUMAN_EQUIPMENTSWAP_DOWN
|
||||
|
||||
/datum/keybinding/human/equipment_swap/down(client/user)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
var/mob/living/carbon/human/H = user.mob
|
||||
H.equipment_swap()
|
||||
return TRUE
|
||||
|
||||
@@ -515,11 +515,11 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
|
||||
* * equipper is the mob trying to equip the item
|
||||
* * bypass_equip_delay_self for whether we want to bypass the equip delay
|
||||
*/
|
||||
/obj/item/proc/mob_can_equip(mob/living/M, mob/living/equipper, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE, swap = FALSE)
|
||||
/obj/item/proc/mob_can_equip(mob/living/M, mob/living/equipper, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE)
|
||||
if(!M)
|
||||
return FALSE
|
||||
|
||||
return M.can_equip(src, slot, disable_warning, bypass_equip_delay_self, swap)
|
||||
return M.can_equip(src, slot, disable_warning, bypass_equip_delay_self)
|
||||
|
||||
/obj/item/verb/verb_pickup()
|
||||
set src in oview(1)
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
|
||||
//Returns if a certain item can be equipped to a certain slot.
|
||||
// Currently invalid for two-handed items - call obj/item/mob_can_equip() instead.
|
||||
/mob/proc/can_equip(obj/item/I, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE, swap = FALSE)
|
||||
/mob/proc/can_equip(obj/item/I, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE)
|
||||
return FALSE
|
||||
|
||||
/mob/proc/can_put_in_hand(I, hand_index)
|
||||
@@ -394,12 +394,12 @@
|
||||
return obscured
|
||||
|
||||
|
||||
/obj/item/proc/equip_to_best_slot(mob/M, swap = FALSE, check_hand = TRUE)
|
||||
/obj/item/proc/equip_to_best_slot(mob/M, check_hand = TRUE)
|
||||
if(check_hand && src != M.get_active_held_item())
|
||||
to_chat(M, "<span class='warning'>You are not holding anything to equip!</span>")
|
||||
return FALSE
|
||||
|
||||
if(M.equip_to_appropriate_slot(src, swap))
|
||||
if(M.equip_to_appropriate_slot(src))
|
||||
M.update_inv_hands()
|
||||
return TRUE
|
||||
else
|
||||
@@ -429,18 +429,6 @@
|
||||
if (I)
|
||||
I.equip_to_best_slot(src)
|
||||
|
||||
/mob/verb/equipment_swap()
|
||||
set name = "equipment-swap"
|
||||
set hidden = TRUE
|
||||
|
||||
var/obj/item/I = get_active_held_item()
|
||||
if (I)
|
||||
if(!do_after(src, 1 SECONDS, target = I))
|
||||
to_chat(src, "<span class='warning'>You fumble with your equipment, accidentally dropping it on the floor!</span>")
|
||||
dropItemToGround(I)
|
||||
return
|
||||
I.equip_to_best_slot(src, TRUE)
|
||||
|
||||
//used in code for items usable by both carbon and drones, this gives the proper back slot for each mob.(defibrillator, backpack watertank, ...)
|
||||
/mob/proc/getBackSlot()
|
||||
return ITEM_SLOT_BACK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/mob/living/carbon/human/can_equip(obj/item/I, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE, swap = FALSE)
|
||||
return dna.species.can_equip(I, slot, disable_warning, src, bypass_equip_delay_self, swap)
|
||||
/mob/living/carbon/human/can_equip(obj/item/I, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE)
|
||||
return dna.species.can_equip(I, slot, disable_warning, src, bypass_equip_delay_self)
|
||||
|
||||
// Return the item currently in the slot ID
|
||||
/mob/living/carbon/human/get_item_by_slot(slot_id)
|
||||
@@ -79,40 +79,31 @@
|
||||
|
||||
//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()
|
||||
// Initial is used to indicate whether or not this is the initial equipment (job datums etc) or just a player doing it
|
||||
/mob/living/carbon/human/equip_to_slot(obj/item/I, slot, initial = FALSE, redraw_mob = FALSE, swap = FALSE)
|
||||
/mob/living/carbon/human/equip_to_slot(obj/item/I, slot, initial = FALSE, redraw_mob = FALSE)
|
||||
if(!..()) //a check failed or the item has already found its slot
|
||||
return
|
||||
|
||||
var/obj/item/current_equip
|
||||
var/not_handled = FALSE //Added in case we make this type path deeper one day
|
||||
switch(slot)
|
||||
if(ITEM_SLOT_BELT)
|
||||
if (belt && swap)
|
||||
current_equip = belt
|
||||
if (!dropItemToGround(belt))
|
||||
return
|
||||
if(belt)
|
||||
return
|
||||
belt = I
|
||||
update_inv_belt()
|
||||
if(ITEM_SLOT_ID)
|
||||
if (wear_id && swap)
|
||||
current_equip = wear_id
|
||||
if (!dropItemToGround(wear_id))
|
||||
return
|
||||
if(wear_id)
|
||||
return
|
||||
wear_id = I
|
||||
sec_hud_set_ID()
|
||||
update_inv_wear_id()
|
||||
if(ITEM_SLOT_EARS)
|
||||
if (ears && swap)
|
||||
current_equip = ears
|
||||
if (!dropItemToGround(ears))
|
||||
return
|
||||
if(ears)
|
||||
return
|
||||
ears = I
|
||||
update_inv_ears()
|
||||
if(ITEM_SLOT_EYES)
|
||||
if (glasses && swap)
|
||||
current_equip = glasses
|
||||
if (!dropItemToGround(glasses))
|
||||
return
|
||||
if(glasses)
|
||||
return
|
||||
glasses = I
|
||||
var/obj/item/clothing/glasses/G = I
|
||||
if(G.glass_colour_type)
|
||||
@@ -125,34 +116,21 @@
|
||||
update_sight()
|
||||
update_inv_glasses()
|
||||
if(ITEM_SLOT_GLOVES)
|
||||
if (gloves && swap)
|
||||
current_equip = gloves
|
||||
if (!dropItemToGround(gloves))
|
||||
return
|
||||
if(gloves)
|
||||
return
|
||||
gloves = I
|
||||
update_inv_gloves()
|
||||
if(ITEM_SLOT_FEET)
|
||||
if (shoes && swap)
|
||||
current_equip = shoes
|
||||
if (!dropItemToGround(shoes))
|
||||
return
|
||||
if(shoes)
|
||||
return
|
||||
shoes = I
|
||||
update_inv_shoes()
|
||||
if(ITEM_SLOT_OCLOTHING)
|
||||
var/obj/item/s_store_backup = s_store
|
||||
|
||||
if (swap && wear_suit)
|
||||
current_equip = wear_suit
|
||||
if (!dropItemToGround(wear_suit, invdrop = FALSE))
|
||||
return
|
||||
if(wear_suit)
|
||||
return
|
||||
|
||||
wear_suit = I
|
||||
|
||||
if (swap && s_store_backup)
|
||||
dropItemToGround(s_store_backup)
|
||||
put_in_inactive_hand(s_store_backup, forced = TRUE)
|
||||
equip_to_slot_if_possible(s_store_backup, ITEM_SLOT_SUITSTORE)
|
||||
|
||||
if(I.flags_inv & HIDEJUMPSUIT)
|
||||
update_inv_w_uniform()
|
||||
if(wear_suit.breakouttime) //when equipping a straightjacket
|
||||
@@ -161,10 +139,8 @@
|
||||
update_action_buttons_icon() //certain action buttons will no longer be usable.
|
||||
update_inv_wear_suit()
|
||||
if(ITEM_SLOT_ICLOTHING)
|
||||
if (w_uniform && swap)
|
||||
current_equip = w_uniform
|
||||
if (!dropItemToGround(w_uniform, invdrop = FALSE))
|
||||
return
|
||||
if(w_uniform)
|
||||
return
|
||||
w_uniform = I
|
||||
update_suit_sensors()
|
||||
update_inv_w_uniform()
|
||||
@@ -175,25 +151,20 @@
|
||||
r_store = I
|
||||
update_inv_pockets()
|
||||
if(ITEM_SLOT_SUITSTORE)
|
||||
if (s_store && swap)
|
||||
current_equip = s_store
|
||||
if (!dropItemToGround(s_store))
|
||||
return
|
||||
if(s_store)
|
||||
return
|
||||
s_store = I
|
||||
update_inv_s_store()
|
||||
else
|
||||
to_chat(src, "<span class='danger'>You are trying to equip this item to an unsupported inventory slot. Report this to a coder!</span>")
|
||||
|
||||
if (current_equip)
|
||||
put_in_hands(current_equip)
|
||||
|
||||
//Item is handled and in slot, valid to call callback, for this proc should always be true
|
||||
if(!not_handled)
|
||||
I.equipped(src, slot, initial)
|
||||
|
||||
// Send a signal for when we equip an item that used to cover our feet/shoes. Used for bloody feet
|
||||
if((I.body_parts_covered & FEET) || (I.flags_inv | I.transparent_protection) & HIDESHOES)
|
||||
SEND_SIGNAL(src, COMSIG_CARBON_EQUIP_SHOECOVER, I, slot, initial, redraw_mob, swap)
|
||||
SEND_SIGNAL(src, COMSIG_CARBON_EQUIP_SHOECOVER, I, slot, initial, redraw_mob)
|
||||
|
||||
return not_handled //For future deeper overrides
|
||||
|
||||
|
||||
@@ -964,15 +964,13 @@ GLOBAL_LIST_EMPTY(roundstart_races)
|
||||
// handles the equipping of species-specific gear
|
||||
return
|
||||
|
||||
/datum/species/proc/can_equip(obj/item/I, slot, disable_warning, mob/living/carbon/human/H, bypass_equip_delay_self = FALSE, swap = FALSE)
|
||||
/datum/species/proc/can_equip(obj/item/I, slot, disable_warning, mob/living/carbon/human/H, bypass_equip_delay_self = FALSE)
|
||||
if(slot in no_equip)
|
||||
if(!I.species_exception || !is_type_in_list(src, I.species_exception))
|
||||
return FALSE
|
||||
|
||||
var/obj/item/replaced_item = H.get_item_by_slot(slot)
|
||||
|
||||
// if there's an item in the slot we want, only allow past this if we're trying to swap and the item being replaced isn't NODROP or ABSTRACT
|
||||
if(replaced_item && (!swap || (HAS_TRAIT(replaced_item, TRAIT_NODROP) || (replaced_item.item_flags & ABSTRACT))))
|
||||
// if there's an item in the slot we want, fail
|
||||
if(H.get_item_by_slot(slot))
|
||||
return FALSE
|
||||
|
||||
// this check prevents us from equipping something to a slot it doesn't support, WITH the exceptions of storage slots (pockets, suit storage, and backpacks)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
return null
|
||||
|
||||
//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()
|
||||
/mob/living/carbon/equip_to_slot(obj/item/I, slot, initial = FALSE, redraw_mob = FALSE, swap = FALSE)
|
||||
/mob/living/carbon/equip_to_slot(obj/item/I, slot, initial = FALSE, redraw_mob = FALSE)
|
||||
if(!slot)
|
||||
return
|
||||
if(!istype(I))
|
||||
@@ -50,36 +50,26 @@
|
||||
I.appearance_flags |= NO_CLIENT_COLOR
|
||||
var/not_handled = FALSE
|
||||
|
||||
var/obj/item/current_equip
|
||||
|
||||
switch(slot)
|
||||
if(ITEM_SLOT_BACK)
|
||||
if (back && swap)
|
||||
current_equip = back
|
||||
if (!dropItemToGround(back))
|
||||
return
|
||||
if(back)
|
||||
return
|
||||
back = I
|
||||
update_inv_back()
|
||||
if(ITEM_SLOT_MASK)
|
||||
if (wear_mask && swap)
|
||||
current_equip = wear_mask
|
||||
if (!dropItemToGround(wear_mask))
|
||||
return
|
||||
if(wear_mask)
|
||||
return
|
||||
wear_mask = I
|
||||
wear_mask_update(I, toggle_off = 0)
|
||||
if(ITEM_SLOT_HEAD)
|
||||
if (head && swap)
|
||||
current_equip = head
|
||||
if (!dropItemToGround(head))
|
||||
return
|
||||
if(head)
|
||||
return
|
||||
head = I
|
||||
SEND_SIGNAL(src, COMSIG_CARBON_EQUIP_HAT, I)
|
||||
head_update(I)
|
||||
if(ITEM_SLOT_NECK)
|
||||
if (wear_neck && swap)
|
||||
current_equip = wear_neck
|
||||
if (!dropItemToGround(wear_neck))
|
||||
return
|
||||
if(wear_neck)
|
||||
return
|
||||
wear_neck = I
|
||||
update_inv_neck(I)
|
||||
if(ITEM_SLOT_HANDCUFFED)
|
||||
@@ -97,9 +87,6 @@
|
||||
else
|
||||
not_handled = TRUE
|
||||
|
||||
if (current_equip)
|
||||
put_in_hands(current_equip)
|
||||
|
||||
//Item has been handled at this point and equipped callback can be safely called
|
||||
//We cannot call it for items that have not been handled as they are not yet correctly
|
||||
//in a slot (handled further down inheritance chain, probably living/carbon/human/equip_to_slot
|
||||
|
||||
@@ -324,16 +324,16 @@
|
||||
*
|
||||
* Initial is used to indicate whether or not this is the initial equipment (job datums etc) or just a player doing it
|
||||
*/
|
||||
/mob/proc/equip_to_slot_if_possible(obj/item/W, slot, qdel_on_fail = FALSE, disable_warning = FALSE, redraw_mob = TRUE, bypass_equip_delay_self = FALSE, initial = FALSE, swap = FALSE)
|
||||
/mob/proc/equip_to_slot_if_possible(obj/item/W, slot, qdel_on_fail = FALSE, disable_warning = FALSE, redraw_mob = TRUE, bypass_equip_delay_self = FALSE, initial = FALSE)
|
||||
if(!istype(W))
|
||||
return FALSE
|
||||
if(!W.mob_can_equip(src, null, slot, disable_warning, bypass_equip_delay_self, swap))
|
||||
if(!W.mob_can_equip(src, null, slot, disable_warning, bypass_equip_delay_self))
|
||||
if(qdel_on_fail)
|
||||
qdel(W)
|
||||
else if(!disable_warning)
|
||||
to_chat(src, "<span class='warning'>You are unable to equip that!</span>")
|
||||
return FALSE
|
||||
equip_to_slot(W, slot, initial, redraw_mob, swap) //This proc should not ever fail.
|
||||
equip_to_slot(W, slot, initial, redraw_mob) //This proc should not ever fail.
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
@@ -366,7 +366,7 @@
|
||||
*
|
||||
* returns 0 if it cannot, 1 if successful
|
||||
*/
|
||||
/mob/proc/equip_to_appropriate_slot(obj/item/W, swap=FALSE, qdel_on_fail = FALSE)
|
||||
/mob/proc/equip_to_appropriate_slot(obj/item/W, qdel_on_fail = FALSE)
|
||||
if(!istype(W))
|
||||
return FALSE
|
||||
var/slot_priority = W.slot_equipment_priority
|
||||
@@ -384,7 +384,7 @@
|
||||
)
|
||||
|
||||
for(var/slot in slot_priority)
|
||||
if(equip_to_slot_if_possible(W, slot, FALSE, TRUE, TRUE, FALSE, FALSE, swap)) //qdel_on_fail = FALSE; disable_warning = TRUE; redraw_mob = TRUE;
|
||||
if(equip_to_slot_if_possible(W, slot, FALSE, TRUE, TRUE, FALSE, FALSE)) //qdel_on_fail = FALSE; disable_warning = TRUE; redraw_mob = TRUE;
|
||||
return TRUE
|
||||
|
||||
if(qdel_on_fail)
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include "outfit_sanity.dm"
|
||||
#include "pills.dm"
|
||||
#include "plantgrowth_tests.dm"
|
||||
#include "quick_swap_sanity.dm"
|
||||
#include "reagent_id_typos.dm"
|
||||
#include "reagent_mod_expose.dm"
|
||||
#include "reagent_mod_procs.dm"
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/// Test that quick swap correctly swaps items and invalidates suit storage
|
||||
/datum/unit_test/quick_swap_suit_storage/Run()
|
||||
// Create a human with a medical winter coat and a health analyzer in suit storage
|
||||
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human)
|
||||
|
||||
var/obj/item/coat = allocate(/obj/item/clothing/suit/hooded/wintercoat/medical)
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(coat, ITEM_SLOT_OCLOTHING), "Couldn't equip winter coat")
|
||||
|
||||
var/obj/item/analyzer = allocate(/obj/item/healthanalyzer)
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(analyzer, ITEM_SLOT_SUITSTORE), "Couldn't equip health analyzer")
|
||||
|
||||
// Then, have them quick swap between the coat and a space suit
|
||||
var/obj/item/hardsuit = allocate(/obj/item/clothing/suit/space/hardsuit)
|
||||
TEST_ASSERT(human.equip_to_appropriate_slot(hardsuit, swap = TRUE), "Couldn't quick swap to hardsuit")
|
||||
|
||||
// Check if the human has the hardsuit on
|
||||
TEST_ASSERT_EQUAL(human.wear_suit, hardsuit, "Human didn't equip the hardsuit")
|
||||
|
||||
// Make sure the health analyzer was dropped as part of the swap
|
||||
// Since health analyzers are an invalid suit storage item
|
||||
TEST_ASSERT_EQUAL(human.s_store, null, "Human didn't drop the health analyzer")
|
||||
TEST_ASSERT_EQUAL(human.get_inactive_held_item(), analyzer, "Human doesn't have the health analyzer in their other hand")
|
||||
|
||||
// Give the human an emergency oxygen tank
|
||||
// This is valid suit storage for both the winter coat AND the hardsuit
|
||||
var/obj/item/tank = allocate(/obj/item/tank/internals/emergency_oxygen)
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(tank, ITEM_SLOT_SUITSTORE), "Couldn't equip emergency oxygen tank")
|
||||
|
||||
// Now, quick swap back to the coat
|
||||
// Since the tank is a valid suit storage item, it should not be dropped
|
||||
TEST_ASSERT(human.equip_to_appropriate_slot(coat, swap = TRUE), "Couldn't quick swap to coat")
|
||||
TEST_ASSERT_EQUAL(human.s_store, tank, "Human dropped the oxygen tank, when it was a valid item to keep in suit storage")
|
||||
|
||||
/// Tests that doUnEquip code is ran by checking vision correcting glasses
|
||||
/datum/unit_test/quick_swap_glasses/Run()
|
||||
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human)
|
||||
|
||||
ADD_TRAIT(human, TRAIT_NEARSIGHT, TRAIT_GENERIC)
|
||||
|
||||
var/obj/item/clothing/glasses/regular/glasses = allocate(/obj/item/clothing/glasses/regular)
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(glasses, ITEM_SLOT_EYES), "Couldn't equip glasses")
|
||||
TEST_ASSERT_EQUAL(human.screens["nearsighted"], null, "Human equipped glasses, but still has overlay")
|
||||
|
||||
var/obj/item/clothing/glasses/monocle/monocle = allocate(/obj/item/clothing/glasses/monocle)
|
||||
human.put_in_active_hand(monocle)
|
||||
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(monocle, ITEM_SLOT_EYES, swap = TRUE), "Couldn't quick swap to monocle")
|
||||
TEST_ASSERT_EQUAL(human.get_active_held_item(), glasses, "Human doesn't have previously equipped glasses in their hand")
|
||||
TEST_ASSERT_NOTEQUAL(human.screens["nearsighted"], null, "Human quick swapped to monocle, but has no nearsighted overlay")
|
||||
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(glasses, ITEM_SLOT_EYES, swap = TRUE), "Couldn't quick swap to glasses")
|
||||
TEST_ASSERT_EQUAL(human.screens["nearsighted"], null, "Human quick swapped to glasses, but still has nearsighted overlay")
|
||||
|
||||
/datum/unit_test/quick_swap_jumpsuit/Run()
|
||||
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human)
|
||||
|
||||
var/obj/item/jumpsuit = allocate(/obj/item/clothing/under/color/grey)
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(jumpsuit, ITEM_SLOT_ICLOTHING), "Couldn't equip grey jumpsuit")
|
||||
|
||||
var/obj/item/toolbelt = allocate(/obj/item/storage/belt/utility)
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(toolbelt, ITEM_SLOT_BELT), "Couldn't equip belt")
|
||||
|
||||
var/obj/item/other_jumpsuit = allocate(/obj/item/clothing/under/color/red)
|
||||
TEST_ASSERT(human.equip_to_slot_if_possible(other_jumpsuit, ITEM_SLOT_ICLOTHING, swap = TRUE), "Couldn't quick swap to other jumpsuit")
|
||||
TEST_ASSERT_EQUAL(human.belt, toolbelt, "Human dropped belt after quick swapping to jumpsuit")
|
||||
Reference in New Issue
Block a user