diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 6f77ed14c4c..bf39244b235 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -85,7 +85,7 @@ var/image/item_overlay = image(holding) item_overlay.alpha = 92 - if(!holding.mob_can_equip(user, slot_id, disable_warning = TRUE)) + if(!holding.mob_can_equip(user, slot_id, disable_warning = TRUE, is_overlay_check = TRUE)) item_overlay.color = "#ff0000" else item_overlay.color = "#00ff00" diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 664ad28c2d4..a0db4bf11c4 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -672,11 +672,13 @@ GLOBAL_LIST_INIT(slot_flags_enumeration, list( "[slot_pants]" = SLOT_PANTS )) -//the mob M is attempting to equip this item into the slot passed through as 'slot'. Return 1 if it can do this and 0 if it can't. -//If you are making custom procs but would like to retain partial or complete functionality of this one, include a 'return ..()' to where you want this to happen. -//Set disable_warning to 1 if you wish it to not give you outputs. -//Should probably move the bulk of this into mob code some time, as most of it is related to the definition of slots and not item-specific -/obj/item/proc/mob_can_equip(M as mob, slot, disable_warning = FALSE, bypass_blocked_check = FALSE) +/** + * the mob M is attempting to equip this item into the slot passed through as 'slot'. Return 1 if it can do this and 0 if it can't. + * If you are making custom procs but would like to retain partial or complete functionality of this one, include a 'return ..()' to where you want this to happen. + * Set disable_warning to 1 if you wish it to not give you outputs. + * Should probably move the bulk of this into mob code some time, as most of it is related to the definition of slots and not item-specific + */ +/obj/item/proc/mob_can_equip(mob/M, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) if(!slot) return 0 if(!M) return 0 diff --git a/code/game/objects/items/devices/auto_cpr.dm b/code/game/objects/items/devices/auto_cpr.dm index 50d18b6d280..0e58484c64e 100644 --- a/code/game/objects/items/devices/auto_cpr.dm +++ b/code/game/objects/items/devices/auto_cpr.dm @@ -163,7 +163,7 @@ if(panel_open) AddOverlays("panel_open[battery ? "_battery" : ""]") -/obj/item/auto_cpr/mob_can_equip(mob/living/carbon/human/H, slot, disable_warning = 0, force = 0) +/obj/item/auto_cpr/mob_can_equip(mob/living/carbon/human/H, slot, disable_warning = 0, force = 0, bypass_blocked_check = FALSE, is_overlay_check = FALSE) . = ..() if(slot == slot_wear_suit) if(panel_open) diff --git a/code/game/objects/items/weapons/material/twohanded.dm b/code/game/objects/items/weapons/material/twohanded.dm index 3eba17f35fc..3c327178ceb 100644 --- a/code/game/objects/items/weapons/material/twohanded.dm +++ b/code/game/objects/items/weapons/material/twohanded.dm @@ -67,12 +67,13 @@ . = ..() update_icon() -/obj/item/material/twohanded/mob_can_equip(var/mob/user, slot, disable_warning = FALSE) - if(wielded) - unwield() - var/obj/item/material/twohanded/offhand/O = user.get_inactive_hand() - if(istype(O)) - O.unwield() +/obj/item/material/twohanded/mob_can_equip(var/mob/user, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) + if(!is_overlay_check) + if(wielded) + unwield() + var/obj/item/material/twohanded/offhand/O = user.get_inactive_hand() + if(istype(O)) + O.unwield() return ..() /obj/item/material/twohanded/can_swap_hands(mob/user) diff --git a/code/game/objects/items/weapons/storage/backpack.dm b/code/game/objects/items/weapons/storage/backpack.dm index 73a2465f70e..889fe622c86 100644 --- a/code/game/objects/items/weapons/storage/backpack.dm +++ b/code/game/objects/items/weapons/storage/backpack.dm @@ -75,7 +75,7 @@ H.update_icon() H.update_inv_back() -/obj/item/storage/backpack/mob_can_equip(M as mob, slot, disable_warning = FALSE) +/obj/item/storage/backpack/mob_can_equip(M as mob, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) //if we can't equip the item anyway, don't bother with species_restricted (cuts down on spam) if (!..()) diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index f8e7b1e4930..698bf98f632 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -18,7 +18,7 @@ /obj/item/storage/internal/attack_hand() return //make sure this is never picked up -/obj/item/storage/internal/mob_can_equip(M, slot, disable_warning = FALSE) +/obj/item/storage/internal/mob_can_equip(M, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) return 0 //make sure this is never picked up //Helper procs to cleanly implement internal storages - storage items that provide inventory slots for other items. diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index e66e905753b..bb58a969f5a 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -119,7 +119,7 @@ return 0 //BS12: Species-restricted clothing check. -/obj/item/clothing/mob_can_equip(M as mob, slot, disable_warning = FALSE, bypass_blocked_check = FALSE) +/obj/item/clothing/mob_can_equip(M as mob, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) //if we can't equip the item anyway, don't bother with species_restricted (cuts down on spam) if (!..()) @@ -564,7 +564,7 @@ /obj/item/clothing/gloves/proc/Touch(var/atom/A, mob/user, var/proximity) return 0 // return 1 to cancel attack_hand() -/obj/item/clothing/gloves/mob_can_equip(mob/user, slot, disable_warning = FALSE) +/obj/item/clothing/gloves/mob_can_equip(mob/user, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) var/mob/living/carbon/human/H = user if(slot && slot == slot_gloves) if(istype(H.gloves, /obj/item/clothing/ring)) diff --git a/code/modules/clothing/shoes/magboots.dm b/code/modules/clothing/shoes/magboots.dm index 30f860269d7..2d6e06f6032 100644 --- a/code/modules/clothing/shoes/magboots.dm +++ b/code/modules/clothing/shoes/magboots.dm @@ -79,7 +79,7 @@ else return 0 -/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user, slot, disable_warning = FALSE) +/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) if(slot != slot_shoes) return ..() diff --git a/code/modules/mining/mine_items.dm b/code/modules/mining/mine_items.dm index 6f1b60d139f..7b967ace984 100644 --- a/code/modules/mining/mine_items.dm +++ b/code/modules/mining/mine_items.dm @@ -70,7 +70,7 @@ item_state = initial(item_state) update_held_icon() -/obj/item/pickaxe/mob_can_equip(M, slot, disable_warning = FALSE) +/obj/item/pickaxe/mob_can_equip(M, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) //Cannot equip wielded items. if(wielded) to_chat(M, SPAN_WARNING("Unwield the [initial(name)] first!")) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 1401a939e94..6d627ec0414 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -40,7 +40,7 @@ if(item_to_equip.item_flags & ITEM_FLAG_NO_MOVE) //Cannot move ITEM_FLAG_NO_MOVE items from one inventory slot to another. Cannot do canremove here because then BSTs spawn naked. return FALSE - if(!item_to_equip.mob_can_equip(src, slot, disable_warning, bypass_blocked_check)) + if(!item_to_equip.mob_can_equip(src, slot, disable_warning, bypass_blocked_check, is_overlay_check = FALSE)) if(delete_on_fail) qdel(item_to_equip) else diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index ee43a4339f2..93322adcb47 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -908,13 +908,14 @@ ABSTRACT_TYPE(/obj/item/gun) #undef LYING_DOWN_FIRE_DELAY_AND_RECOIL_STAT_MULTIPLIER #undef LYING_DOWN_ACCURACY_STAT_MULTIPLIER -/obj/item/gun/mob_can_equip(mob/user, slot, disable_warning, ignore_blocked) +/obj/item/gun/mob_can_equip(mob/user, slot, disable_warning, bypass_blocked_check = FALSE, is_overlay_check = FALSE) //Cannot equip wielded items. - if(wielded) - unwield() - var/obj/item/offhand/O = user.get_inactive_hand() - if(istype(O)) - O.unwield() + if(!is_overlay_check) + if(wielded) + unwield() + var/obj/item/offhand/O = user.get_inactive_hand() + if(istype(O)) + O.unwield() return ..() /obj/item/gun/throw_at() @@ -991,7 +992,7 @@ ABSTRACT_TYPE(/obj/item/gun) if (!QDELETED(src)) qdel(src) -/obj/item/offhand/mob_can_equip(var/mob/M, slot, disable_warning = FALSE) +/obj/item/offhand/mob_can_equip(var/mob/M, slot, disable_warning = FALSE, bypass_blocked_check = FALSE, is_overlay_check = FALSE) var/static/list/equippable_slots = list(slot_l_hand, slot_r_hand) if(slot in equippable_slots) return TRUE diff --git a/html/changelogs/Fenodyree-FixGunUnwield.yml b/html/changelogs/Fenodyree-FixGunUnwield.yml new file mode 100644 index 00000000000..b829756f457 --- /dev/null +++ b/html/changelogs/Fenodyree-FixGunUnwield.yml @@ -0,0 +1,7 @@ +author: Fenodyree + +delete-after: True + +changes: + - bugfix: "Fixed guns getting unwielded when mousing over UI elements." + - bugfix: "Fixed mob_can_equip using M as mob, instead of mob/M. Also adds its parameters to all its children."