diff --git a/changelog/snippets/fix.6536.md b/changelog/snippets/fix.6536.md new file mode 100644 index 0000000000..6042c245f0 --- /dev/null +++ b/changelog/snippets/fix.6536.md @@ -0,0 +1,5 @@ +- (#6536) Fix the tracking radius for unit weapons being floored to the nearest tenth, which made units not track targets that are near the outside of their range. + - Mobile unit weapons: 1.0x of weapon range -> 1.05x + - Anti-air weapons: 1.10x -> 1.15x + - Bomber weapons: 1.2x -> 1.25x + - Structure weapons: 1x -> 1x diff --git a/engine/Core/Blueprints/UnitBlueprint.lua b/engine/Core/Blueprints/UnitBlueprint.lua index 4d3783ec71..64095e33f0 100644 --- a/engine/Core/Blueprints/UnitBlueprint.lua +++ b/engine/Core/Blueprints/UnitBlueprint.lua @@ -145,6 +145,7 @@ ---@see SetAutoMode ---@field InitialAutoMode boolean --- unit should unpack before firing weapon +--- Engine sets tracking radius to 1x, calls OnLostTarget when given a move order, and OnGotTarget only when not moving ---@field NeedUnpack boolean --- this muliplier is applied when a staging platform is refueling an air unit ---@field RefuelingMultiplier number diff --git a/lua/system/blueprints-weapons.lua b/lua/system/blueprints-weapons.lua index d85757fa18..ef9a5044c8 100644 --- a/lua/system/blueprints-weapons.lua +++ b/lua/system/blueprints-weapons.lua @@ -1,11 +1,10 @@ - local weaponTargetCheckUpperLimit = 6000 ---@param unit UnitBlueprint ---@param weapon WeaponBlueprint ---@param projectile? ProjectileBlueprint local function ProcessWeapon(unit, weapon, projectile) - -- pre-compute flags + -- pre-compute flags local isAir = false local isStructure = false local isBomber = false @@ -81,7 +80,7 @@ local function ProcessWeapon(unit, weapon, projectile) end end - -- process target tracking radius + -- process target tracking radius -- if it is set then we use that - allows us to make adjustments as we see fit if weapon.TrackingRadius == nil then @@ -99,7 +98,7 @@ local function ProcessWeapon(unit, weapon, projectile) end -- add significant target checking radius for bombers - if isBomber then + if isBomber then weapon.TrackingRadius = 1.25 end end @@ -112,8 +111,8 @@ local function ProcessWeapon(unit, weapon, projectile) -- by default, do not recheck targets as that is expensive when a lot of units are stacked on top of another weapon.AlwaysRecheckTarget = false - -- allow - if weapon.RangeCategory == 'UWRC_DirectFire' or + -- allow + if weapon.RangeCategory == 'UWRC_DirectFire' or weapon.RangeCategory == "UWRC_IndirectFire" or weapon.MaxRadius > 50 and (weapon.RangeCategory ~= "UWRC_AntiNavy") then weapon.AlwaysRecheckTarget = true @@ -137,8 +136,8 @@ local function ProcessWeapon(unit, weapon, projectile) weapon.AlwaysRecheckTarget = false end + -- Floor target check interval to ticks weapon.TargetCheckInterval = 0.1 * math.floor(10 * weapon.TargetCheckInterval) - weapon.TrackingRadius = 0.1 * math.floor(10 * weapon.TrackingRadius) end ---@param allBlueprints BlueprintsTable