Skip to content

Commit 46c1460

Browse files
authored
Auto Trajectory Patch 6 (#4216)
This one makes High Trajectory inherit Low Trajectory's target if Low Trajectory had one when it switched to High. Also calibrates the high trajectory threshold a little bit to be slightly more reactive.
1 parent 7ff0878 commit 46c1460

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

luarules/gadgets/unit_weapon_smart_select_helper.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ local priorityAutoAggro = 12 -- how much aggro is accumulated per frameCheckModu
4444
local priorityManualAggro = 24 -- how much aggro is accumulated per frameCheckModulo that the priority weapon successfully aims with a manually assigned target
4545
local prioritySwitchThreshold = -1 --the aggro at which priority weapon switch is triggered. Aggro is decayed closer to 0 every frameCheckModulo
4646

47-
local backupAutoAggro = 4 -- how much aggro is accumulated per frameCheckModulo that the priority weapon fails to aim
47+
local backupAutoAggro = 5.5 -- how much aggro is accumulated per frameCheckModulo that the priority weapon fails to aim
4848
local backupManualAggro = 16 --how much aggro is accumulated per frameCheckModulo that the priority weapon fails to aim with a manually assigned target
4949
local backupSwitchThreshold = backupAutoAggro * 2.4 * -1 --the aggro at which backup weapon switch is triggered. Aggro is decayed closer to 0 every frameCheckModulo
5050

@@ -62,6 +62,7 @@ local spGetUnitWeaponHaveFreeLineOfFire = Spring.GetUnitWeaponHaveFreeLineOfFire
6262
local spGetUnitWeaponTarget = Spring.GetUnitWeaponTarget
6363
local spGetUnitWeaponState = Spring.GetUnitWeaponState
6464
local spGetUnitEstimatedPath = Spring.GetUnitEstimatedPath
65+
local spSetUnitTarget = Spring.SetUnitTarget
6566
local mathMin = math.min
6667
local mathMax = math.max
6768

@@ -150,9 +151,15 @@ local function updateAimingState(attackerID)
150151
if priorityTargetType == UNIT_TARGET then
151152
priorityCanShoot = spGetUnitWeaponHaveFreeLineOfFire(attackerID, defData.trajectoryCheckWeapon, priorityTarget)
152153
newMatchTargetNumber = priorityTarget
154+
if data.aggroBias >= prioritySwitchThreshold then
155+
spSetUnitTarget(attackerID, priorityTarget, false, priorityIsUserTarget, defData.backupWeapon)
156+
end
153157
elseif priorityTargetType == GROUND_TARGET then
154158
priorityCanShoot = spGetUnitWeaponHaveFreeLineOfFire(attackerID, defData.trajectoryCheckWeapon, nil, nil, nil, priorityTarget[1], priorityTarget[2], priorityTarget[3])
155159
newMatchTargetNumber = priorityTarget[1]
160+
if data.aggroBias >= prioritySwitchThreshold then
161+
spSetUnitTarget(attackerID, priorityTarget[1], priorityTarget[2], priorityTarget[3], false, priorityIsUserTarget, defData.backupWeapon)
162+
end
156163
end
157164

158165
-- prevent misfire from triggering when a target is first acquired from idle state

0 commit comments

Comments
 (0)