Skip to content

Commit

Permalink
Boost the settarget rate and make it divisible by SlowUpdate. This ma…
Browse files Browse the repository at this point in the history
…kes units more prone to shoot at their settarget instead of their attack command. See #3649.
  • Loading branch information
GoogleFrog committed Jul 9, 2019
1 parent 01ce092 commit dbb5f36
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions LuaRules/Gadgets/unit_target_on_the_move.lua
Expand Up @@ -151,7 +151,7 @@ local function setTarget(data, sendToWidget)
if spValidUnitID(data.id) then
if not data.targetID then
if locationInRange(data.id, data.unitDefID, data.x, data.y, data.z) then
spSetUnitTarget(data.id, data.x, data.y, data.z)
spSetUnitTarget(data.id, data.x, data.y, data.z, false, true)
GG.UnitSetGroundTarget(data.id)
end
if sendToWidget then
Expand Down Expand Up @@ -286,9 +286,8 @@ local function disSQ(x1,y1,x2,y2)
end

local function setTargetClosestFromList(unitID, unitDefID, team, choiceUnits)

local ux, uy, uz = Spring.GetUnitPosition(unitID)

local bestDis = false
local bestUnit = false

Expand Down Expand Up @@ -459,9 +458,9 @@ end
-- Target update

function gadget:GameFrame(n)
if n%16 == 15 then -- timing synced with slow update to reduce attack jittering
-- 15 causes attack command to override target command
-- 0 causes target command to take precedence
if n%5 == 4 then
-- Slow update every 15 frames
-- Ideally units would run this code the frame after their slow update

local toRemove = {count = 0, data = {}}
for i = 1, unit.count do
Expand Down

0 comments on commit dbb5f36

Please sign in to comment.