diff --git a/scripts/dynassault.lua b/scripts/dynassault.lua index b8fbeca6ea..b863ce0b26 100644 --- a/scripts/dynassault.lua +++ b/scripts/dynassault.lua @@ -230,10 +230,17 @@ local function RestoreDGun() Turn(lnanohand, x_axis, 0, ARM_SPEED_PITCH) end +local dgunAim = false +local function PrioritiseDgun() + dgunAim = true + Sleep(500) + dgunAim = false +end + function script.AimWeapon(num, heading, pitch) local weaponNum = dyncomm.GetWeapon(num) - if weaponNum == 1 then + if weaponNum == 1 and not dgunAim then Signal(SIG_LASER) SetSignalMask(SIG_LASER) isLasering = true @@ -250,6 +257,9 @@ function script.AimWeapon(num, heading, pitch) StartThread(RestoreLaser) return true elseif weaponNum == 2 then + if dyncomm.IsManualFire(num) and not dgunAim then + StartThread(PrioritiseDgun) + end if starBLaunchers[num] then pitch = ARM_PERPENDICULAR end @@ -282,6 +292,7 @@ function script.FireWeapon(num) dyncomm.EmitWeaponFireSfx(rcannon_flare, num) elseif weaponNum == 2 then dyncomm.EmitWeaponFireSfx(lcannon_flare, num) + dgunAim = false end end diff --git a/scripts/dynrecon.lua b/scripts/dynrecon.lua index cfe1d0c230..1a04643c02 100644 --- a/scripts/dynrecon.lua +++ b/scripts/dynrecon.lua @@ -64,6 +64,7 @@ local canDgun = UnitDefs[unitDefID].canDgun local dead = false local bMoving = false local bAiming = false +local dgunAim = false local shieldOn = true local inJumpMode = false @@ -402,6 +403,12 @@ local function AimRifle(heading, pitch, isDgun) return true end +local function PrioritiseDgun() + dgunAim = true + Sleep(500) + dgunAim = false +end + function script.AimWeapon(num, heading, pitch) local weaponNum = dyncomm.GetWeapon(num) @@ -409,10 +416,13 @@ function script.AimWeapon(num, heading, pitch) return true end - if weaponNum == 1 then + if weaponNum == 1 and not dgunAim then Signal(SIG_AIM) SetSignalMask(SIG_AIM) elseif weaponNum == 2 then + if dyncomm.IsManualFire(num) and not dgunAim then + StartThread(PrioritiseDgun) + end Signal(SIG_AIM_2) SetSignalMask(SIG_AIM_2) else @@ -447,6 +457,9 @@ end function script.Shot(num) dyncomm.EmitWeaponShotSfx(flare, num) + if num == 2 then + dgunAim = false + end end local function JumpExhaust() diff --git a/scripts/dynstrike.lua b/scripts/dynstrike.lua index cf19b12eed..0d262fc424 100644 --- a/scripts/dynstrike.lua +++ b/scripts/dynstrike.lua @@ -533,10 +533,17 @@ local function AimArm(heading, pitch, arm, hand, wait) end end +local dgunAim = false +local function PrioritiseDgun() + dgunAim = true + Sleep(500) + dgunAim = false +end + function script.AimWeapon(num, heading, pitch) local weaponNum = dyncomm.GetWeapon(num) walking = false - if weaponNum == 1 then + if weaponNum == 1 and not dgunAim then resetRestoreTorso = true resetRestoreLeft = true AimArm(heading, pitch, ArmLeft, Gun, true) @@ -546,7 +553,8 @@ function script.AimWeapon(num, heading, pitch) SetSignalMask(SIG_RIGHT) Signal(SIG_RESTORE_RIGHT) resetRestoreTorso = true - if dyncomm.IsManualFire(num) then + if dyncomm.IsManualFire(num) and not dgunAim then + StartThread(PrioritiseDgun) RESTORE_DELAY_RIGHT = RESTORE_DELAY_DGUN else RESTORE_DELAY_RIGHT = RESTORE_DELAY_NANO @@ -566,6 +574,7 @@ function script.FireWeapon(num) dyncomm.EmitWeaponFireSfx(Muzzle, num) elseif weaponNum == 2 then dyncomm.EmitWeaponFireSfx(RightMuzzle, num) + dgunAim = false end end diff --git a/scripts/dynsupport.lua b/scripts/dynsupport.lua index ac00c6398e..d900916668 100644 --- a/scripts/dynsupport.lua +++ b/scripts/dynsupport.lua @@ -53,6 +53,7 @@ local canDgun = UnitDefs[unitDefID].canDgun local dead = false local bMoving = false local bAiming = false +local dgunAim = false local inBuildAnim = false local SPEED_MULT = 1.12 @@ -383,21 +384,32 @@ local function AimRifle(heading, pitch, isDgun) return true end +local function PrioritiseDgun() + dgunAim = true + Sleep(500) + dgunAim = false +end + function script.AimWeapon(num, heading, pitch) local weaponNum = dyncomm.GetWeapon(num) inBuildAnim = false if weaponNum == 1 then + if dgunAim then return false end Signal(SIG_AIM) SetSignalMask(SIG_AIM) bAiming = true return AimRifle(heading, pitch) elseif weaponNum == 2 then + if dyncomm.IsManualFire(num) and not dgunAim then + StartThread(PrioritiseDgun) + end Signal(SIG_AIM) Signal(SIG_AIM_2) SetSignalMask(SIG_AIM_2) bAiming = true return AimRifle(heading, pitch, canDgun) elseif weaponNum == 3 then + if dgunAim then return false end return true end return false @@ -405,6 +417,9 @@ end function script.FireWeapon(num) dyncomm.EmitWeaponFireSfx(flare, num) + if weaponNum == 2 then + dgunAim = false + end end function script.Shot(num)