Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rounding in weapon tracking radius sanitization #6536

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/snippets/fix.6536.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions engine/Core/Blueprints/UnitBlueprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions lua/system/blueprints-weapons.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading