Work around a recursive loop in TargetAndAttack
This commit is contained in:
@@ -245,6 +245,10 @@ ProduceAircraft = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
TargetAndAttack = function(yak, target)
|
TargetAndAttack = function(yak, target)
|
||||||
|
if yak.IsDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not target or target.IsDead or (not target.IsInWorld) then
|
if not target or target.IsDead or (not target.IsInWorld) then
|
||||||
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == player and self.HasProperty("Health") and yak.CanTarget(self) end)
|
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == player and self.HasProperty("Health") and yak.CanTarget(self) end)
|
||||||
|
|
||||||
@@ -260,7 +264,11 @@ TargetAndAttack = function(yak, target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
yak.CallFunc(function()
|
yak.CallFunc(function()
|
||||||
TargetAndAttack(yak, target)
|
-- TODO: Replace this with an idle trigger once that works for aircraft
|
||||||
|
-- Add a delay of one tick to fix an endless recursive call
|
||||||
|
Trigger.AfterDelay(1, function()
|
||||||
|
TargetAndAttack(yak, target)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -264,6 +264,10 @@ ProduceAircraft = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
TargetAndAttack = function(yak, target)
|
TargetAndAttack = function(yak, target)
|
||||||
|
if yak.IsDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not target or target.IsDead or (not target.IsInWorld) then
|
if not target or target.IsDead or (not target.IsInWorld) then
|
||||||
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == greece and self.HasProperty("Health") and yak.CanTarget(self) end)
|
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == greece and self.HasProperty("Health") and yak.CanTarget(self) end)
|
||||||
if #enemies > 0 then
|
if #enemies > 0 then
|
||||||
@@ -278,7 +282,11 @@ TargetAndAttack = function(yak, target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
yak.CallFunc(function()
|
yak.CallFunc(function()
|
||||||
TargetAndAttack(yak, target)
|
-- TODO: Replace this with an idle trigger once that works for aircraft
|
||||||
|
-- Add a delay of one tick to fix an endless recursive call
|
||||||
|
Trigger.AfterDelay(1, function()
|
||||||
|
TargetAndAttack(yak, target)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,10 @@ ProduceAircraft = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
TargetAndAttack = function(yak, target)
|
TargetAndAttack = function(yak, target)
|
||||||
|
if yak.IsDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not target or target.IsDead or (not target.IsInWorld) then
|
if not target or target.IsDead or (not target.IsInWorld) then
|
||||||
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == player and self.HasProperty("Health") and yak.CanTarget(self) end)
|
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == player and self.HasProperty("Health") and yak.CanTarget(self) end)
|
||||||
if #enemies > 0 then
|
if #enemies > 0 then
|
||||||
@@ -173,7 +177,11 @@ TargetAndAttack = function(yak, target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
yak.CallFunc(function()
|
yak.CallFunc(function()
|
||||||
TargetAndAttack(yak, target)
|
-- TODO: Replace this with an idle trigger once that works for aircraft
|
||||||
|
-- Add a delay of one tick to fix an endless recursive call
|
||||||
|
Trigger.AfterDelay(1, function()
|
||||||
|
TargetAndAttack(yak, target)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,10 @@ ProduceAircraft = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
TargetAndAttack = function(yak, target)
|
TargetAndAttack = function(yak, target)
|
||||||
|
if yak.IsDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not target or target.IsDead or (not target.IsInWorld) then
|
if not target or target.IsDead or (not target.IsInWorld) then
|
||||||
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == player and self.HasProperty("Health") and yak.CanTarget(self) end)
|
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == player and self.HasProperty("Health") and yak.CanTarget(self) end)
|
||||||
if #enemies > 0 then
|
if #enemies > 0 then
|
||||||
@@ -185,7 +189,11 @@ TargetAndAttack = function(yak, target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
yak.CallFunc(function()
|
yak.CallFunc(function()
|
||||||
TargetAndAttack(yak, target)
|
-- TODO: Replace this with an idle trigger once that works for aircraft
|
||||||
|
-- Add a delay of one tick to fix an endless recursive call
|
||||||
|
Trigger.AfterDelay(1, function()
|
||||||
|
TargetAndAttack(yak, target)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ ProduceAircraft = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
TargetAndAttack = function(yak, target)
|
TargetAndAttack = function(yak, target)
|
||||||
|
if yak.IsDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not target or target.IsDead or (not target.IsInWorld) then
|
if not target or target.IsDead or (not target.IsInWorld) then
|
||||||
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == greece and self.HasProperty("Health") and yak.CanTarget(self) end)
|
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == greece and self.HasProperty("Health") and yak.CanTarget(self) end)
|
||||||
if #enemies > 0 then
|
if #enemies > 0 then
|
||||||
@@ -148,7 +152,11 @@ TargetAndAttack = function(yak, target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
yak.CallFunc(function()
|
yak.CallFunc(function()
|
||||||
TargetAndAttack(yak, target)
|
-- TODO: Replace this with an idle trigger once that works for aircraft
|
||||||
|
-- Add a delay of one tick to fix an endless recursive call
|
||||||
|
Trigger.AfterDelay(1, function()
|
||||||
|
TargetAndAttack(yak, target)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -130,9 +130,13 @@ ProduceAircraft = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
TargetAndAttack = function(mig, target)
|
TargetAndAttack = function(mig, target)
|
||||||
|
if mig.IsDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not target or target.IsDead or (not target.IsInWorld) then
|
if not target or target.IsDead or (not target.IsInWorld) then
|
||||||
local enemies = Utils.Where(greece.GetActors(), function(actor)
|
local enemies = Utils.Where(greece.GetActors(), function(actor)
|
||||||
return actor.HasProperty("Health") and actor.Type ~= "brik"
|
return actor.HasProperty("Health") and actor.Type ~= "brik" and mig.CanTarget(target)
|
||||||
end)
|
end)
|
||||||
if #enemies > 0 then
|
if #enemies > 0 then
|
||||||
target = Utils.Random(enemies)
|
target = Utils.Random(enemies)
|
||||||
@@ -146,7 +150,11 @@ TargetAndAttack = function(mig, target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
mig.CallFunc(function()
|
mig.CallFunc(function()
|
||||||
TargetAndAttack(mig, target)
|
-- TODO: Replace this with an idle trigger once that works for aircraft
|
||||||
|
-- Add a delay of one tick to fix an endless recursive call
|
||||||
|
Trigger.AfterDelay(1, function()
|
||||||
|
TargetAndAttack(mig, target)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -129,9 +129,13 @@ ProduceAircraft = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
TargetAndAttack = function(mig, target)
|
TargetAndAttack = function(mig, target)
|
||||||
|
if mig.IsDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not target or target.IsDead or (not target.IsInWorld) then
|
if not target or target.IsDead or (not target.IsInWorld) then
|
||||||
local enemies = Utils.Where(greece.GetActors(), function(actor)
|
local enemies = Utils.Where(greece.GetActors(), function(actor)
|
||||||
return actor.HasProperty("Health") and actor.Type ~= "brik"
|
return actor.HasProperty("Health") and actor.Type ~= "brik" and mig.CanTarget(target)
|
||||||
end)
|
end)
|
||||||
if #enemies > 0 then
|
if #enemies > 0 then
|
||||||
target = Utils.Random(enemies)
|
target = Utils.Random(enemies)
|
||||||
@@ -145,7 +149,11 @@ TargetAndAttack = function(mig, target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
mig.CallFunc(function()
|
mig.CallFunc(function()
|
||||||
TargetAndAttack(mig, target)
|
-- TODO: Replace this with an idle trigger once that works for aircraft
|
||||||
|
-- Add a delay of one tick to fix an endless recursive call
|
||||||
|
Trigger.AfterDelay(1, function()
|
||||||
|
TargetAndAttack(mig, target)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user