[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:
SkyratBot
2020-11-29 17:07:15 +01:00
committed by GitHub
parent ec0ccbd9f6
commit 38bab4eecd
10 changed files with 44 additions and 182 deletions
+3 -15
View File
@@ -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)
+9 -22
View File
@@ -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
+5 -5
View File
@@ -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)