Extract duplicated code to a SetupHuntTrigger function
This commit is contained in:
@@ -69,24 +69,21 @@ IdleTrigger = function(units, dest)
|
|||||||
Trigger.OnIdle(unit, function()
|
Trigger.OnIdle(unit, function()
|
||||||
local bool = Utils.All(units, function(unit) return unit.IsIdle end)
|
local bool = Utils.All(units, function(unit) return unit.IsIdle end)
|
||||||
if bool then
|
if bool then
|
||||||
Utils.Do(units, function(unit)
|
SetupHuntTrigger(units)
|
||||||
if not unit.IsDead then
|
|
||||||
Trigger.ClearAll(unit)
|
|
||||||
Trigger.AfterDelay(0, function()
|
|
||||||
if not unit.IsDead then
|
|
||||||
if dest then unit.AttackMove(dest, 3) end
|
|
||||||
Trigger.OnIdle(unit, unit.Hunt)
|
|
||||||
Trigger.OnCapture(unit, function()
|
|
||||||
Trigger.ClearAll(unit)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Trigger.OnDamaged(unit, function()
|
Trigger.OnDamaged(unit, function()
|
||||||
|
SetupHuntTrigger(units)
|
||||||
|
end)
|
||||||
|
|
||||||
|
Trigger.OnCapture(unit, function()
|
||||||
|
Trigger.ClearAll(unit)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
SetupHuntTrigger = function(units)
|
||||||
Utils.Do(units, function(unit)
|
Utils.Do(units, function(unit)
|
||||||
if not unit.IsDead then
|
if not unit.IsDead then
|
||||||
Trigger.ClearAll(unit)
|
Trigger.ClearAll(unit)
|
||||||
@@ -100,12 +97,6 @@ IdleTrigger = function(units, dest)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
|
||||||
|
|
||||||
Trigger.OnCapture(unit, function()
|
|
||||||
Trigger.ClearAll(unit)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
ticked = TimerTicks
|
ticked = TimerTicks
|
||||||
|
|||||||
Reference in New Issue
Block a user