Skip to content

Commit

Permalink
Fixes tactical reload intercepting worn magazines. (#219)
Browse files Browse the repository at this point in the history
* Fix powerpacks double reloading (#15732)

* Fix bluetooth tactical reload (#15893)

* Update gun_helpers.dm

---------

Co-authored-by: Xander3359 <[email protected]>
  • Loading branch information
Helg2 and Xander3359 authored Sep 6, 2024
1 parent 4681c6b commit 9c87e95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@

#define iscell(I) (istype(I, /obj/item/cell))

#define islascell(I) (istype(I, /obj/item/cell/lasgun))

#define isfactorypart(I) (istype(I, /obj/item/factory_part))

#define isfactoryrefill(I) (istype(I, /obj/item/factory_refill))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
/obj/item/weapon/powerfist/attackby(obj/item/I, mob/user, params)
if(!istype(I, /obj/item/cell))
return ..()
if(!istype(I, /obj/item/cell/lasgun))
if(!islascell(I))
to_chat(user, span_warning("The powerfist only accepts lasgun cells!"))
return
if(I.w_class >= WEIGHT_CLASS_BULKY)
Expand Down
16 changes: 14 additions & 2 deletions code/modules/projectiles/gun_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,21 @@

//tactical reloads
/obj/item/weapon/gun/afterattack(atom/target, mob/user, has_proximity, click_parameters)
if(istype(target, /obj/item/ammo_magazine) || istype(target, /obj/item/cell))
. = ..()
if(!has_proximity)
return

if(isammomagazine(target))
var/obj/item/ammo_magazine/mag_to_reload = target
if(mag_to_reload.flags_magazine & MAGAZINE_WORN)
return
tactical_reload(target, user)

if(islascell(target))
var/obj/item/cell/lasgun/cell_to_reload = target
if(CHECK_BITFIELD(get_flags_magazine_features(cell_to_reload), MAGAZINE_WORN))
return
tactical_reload(target, user)
return ..()

/obj/item/weapon/gun/mob_can_equip(mob/user, slot, warning = TRUE, override_nodrop = FALSE, bitslot = FALSE)
//Cannot equip wielded items or items burst firing.
Expand Down

0 comments on commit 9c87e95

Please sign in to comment.