Replace TargetAndAttack with a global aircraft attack function
This commit is contained in:
@@ -259,34 +259,7 @@ ProduceAircraft = function()
|
||||
Trigger.AfterDelay(DateTime.Minutes(1), ProduceAircraft)
|
||||
end
|
||||
|
||||
TargetAndAttack(yak)
|
||||
end)
|
||||
end
|
||||
|
||||
TargetAndAttack = function(yak, target)
|
||||
if yak.IsDead then
|
||||
return
|
||||
end
|
||||
|
||||
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)
|
||||
if #enemies > 0 then
|
||||
target = Utils.Random(enemies)
|
||||
end
|
||||
end
|
||||
|
||||
if target and yak.AmmoCount() > 0 and yak.CanTarget(target) then
|
||||
yak.Attack(target)
|
||||
else
|
||||
yak.ReturnToBase()
|
||||
end
|
||||
|
||||
yak.CallFunc(function()
|
||||
-- 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)
|
||||
InitializeAttackAircraft(yak, greece)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
World:
|
||||
LuaScript:
|
||||
Scripts: allies05a.lua, allies05a-AI.lua
|
||||
Scripts: campaign-global.lua, allies05a.lua, allies05a-AI.lua
|
||||
MissionData:
|
||||
Briefing: Rescue Tanya.\n\nOnce disguised, your spy can move past any enemy unit, except dogs, without being detected. Direct him into the weapons factory located at a nearby Soviet Base where he will hijack a truck and free Tanya.\n\nWith Tanya's help, take out the air defenses on the island and a Chinook will arrive to rescue her.\n\nThen destroy all remaining Soviet buildings and units.
|
||||
BriefingVideo: ally5.vqa
|
||||
|
||||
Reference in New Issue
Block a user