Skip to content

Commit

Permalink
Fixes akimbo bug (#4503)
Browse files Browse the repository at this point in the history
# About the pull request

Fixes accidental infinite firing loop when firing akimbo.

In testing I was using pump shotguns and akimbo firing is rather rare in
the first place so didn't pick up on it.

# Explain why it's good for the game

Firing infinitely to kill xenos instantly is bad.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog

:cl: Morrow
fix: Fixed a bug with akimbo firing
/:cl:
  • Loading branch information
morrowwolf authored Sep 26, 2023
1 parent e0ffb74 commit bfd1054
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1109,20 +1109,24 @@ and you're good to go.
if(PB_burst_bullets_fired) //Has a burst been carried over from a PB?
PB_burst_bullets_fired = 0 //Don't need this anymore. The torch is passed.

var/fired_by_akimbo = FALSE
if(dual_wield)
fired_by_akimbo = TRUE

//Dual wielding. Do we have a gun in the other hand and is it the same category?
var/obj/item/weapon/gun/akimbo = user.get_inactive_hand()
if(!reflex && !dual_wield && user)
if(istype(akimbo) && akimbo.gun_category == gun_category && !(akimbo.flags_gun_features & GUN_WIELDED_FIRING_ONLY))
dual_wield = TRUE //increases recoil, increases scatter, and reduces accuracy.

var/fire_return = handle_fire(target, user, params, reflex, dual_wield, check_for_attachment_fire, akimbo)
var/fire_return = handle_fire(target, user, params, reflex, dual_wield, check_for_attachment_fire, akimbo, fired_by_akimbo)
if(!fire_return)
return fire_return

flags_gun_features &= ~GUN_BURST_FIRING // We always want to turn off bursting when we're done, mainly for when we break early mid-burstfire.
return AUTOFIRE_CONTINUE

/obj/item/weapon/gun/proc/handle_fire(atom/target, mob/living/user, params, reflex = FALSE, dual_wield, check_for_attachment_fire, akimbo)
/obj/item/weapon/gun/proc/handle_fire(atom/target, mob/living/user, params, reflex = FALSE, dual_wield, check_for_attachment_fire, akimbo, fired_by_akimbo)
var/turf/curloc = get_turf(user) //In case the target or we are expired.
var/turf/targloc = get_turf(target)

Expand Down Expand Up @@ -1209,7 +1213,7 @@ and you're good to go.

shots_fired++

if(dual_wield)
if(dual_wield && !fired_by_akimbo)
if(user?.client?.prefs?.toggle_prefs & TOGGLE_ALTERNATING_DUAL_WIELD)
user.swap_hand()
else
Expand Down Expand Up @@ -1352,6 +1356,10 @@ and you're good to go.
else
active_attachable.activate_attachment(src, null, TRUE)//No way.

var/fired_by_akimbo = FALSE
if(dual_wield)
fired_by_akimbo = TRUE

//Dual wielding. Do we have a gun in the other hand and is it the same category?
var/obj/item/weapon/gun/akimbo = user.get_inactive_hand()
if(!dual_wield && user)
Expand Down Expand Up @@ -1447,7 +1455,7 @@ and you're good to go.

SEND_SIGNAL(user, COMSIG_MOB_FIRED_GUN, src)

if(dual_wield)
if(dual_wield && !fired_by_akimbo)
if(user?.client?.prefs?.toggle_prefs & TOGGLE_ALTERNATING_DUAL_WIELD)
user.swap_hand()
else
Expand Down

0 comments on commit bfd1054

Please sign in to comment.