Thankyou all for your help, its been tremendous.
To expand on what im doing. I am recreating the Arma style 'invade and annex' MP mission.
I have 5 primary objectives, which is to clear airbases in a 'push/pull' style battle with the AI, and I have around 15 side missions, which are smaller targets for variety.
Only 1 of each mission is current at any one time. As you clear an objective, the next one spawns in. Sequentially for the primary objectives, random for the secondary.
I wish to have an F10 request system to allow players when only a few people are on to request support aircraft. CAP, CAS, SEAD.
I want the support aircraft to proceed directly from their spawn point, to either the primary or secondary objective, as requested by the player.
So far, i'm 90% of the way there with the help I have received here. This is my current code.
local function AICASSecondary()
if (trigger.misc.getUserFlag(10) == 1) then
BanditWP = ZONE:FindByName( "Side1" )
elseif (trigger.misc.getUserFlag(10) == 2) then
BanditWP = ZONE:FindByName( "Side2" )
elseif (trigger.misc.getUserFlag(10) == 3) then
BanditWP = ZONE:FindByName( "Side3" )
elseif (trigger.misc.getUserFlag(10) == 4) then
BanditWP = ZONE:FindByName( "Side4" )
elseif (trigger.misc.getUserFlag(10) == 5) then
BanditWP = ZONE:FindByName( "Side5" )
elseif (trigger.misc.getUserFlag(10) == 6) then
BanditWP = ZONE:FindByName( "Side6" )
elseif (trigger.misc.getUserFlag(10) == 7) then
BanditWP = ZONE:FindByName( "Side7" )
elseif (trigger.misc.getUserFlag(10) == 8) then
BanditWP = ZONE:FindByName( "Side8" )
elseif (trigger.misc.getUserFlag(10) == 9) then
BanditWP = ZONE:FindByName( "Side9" )
elseif (trigger.misc.getUserFlag(10) == 10) then
BanditWP = ZONE:FindByName( "Side10" )
elseif (trigger.misc.getUserFlag(10) == 11) then
BanditWP = ZONE:FindByName( "Side11" )
end
BanditWPVec2 = BanditWP:GetVec2() -- Map position for bandit WP
local SpawnObject = SPAWN
:New( "aiCAS" )
:OnSpawnGroup(function( SpawnGroup )
SpawnGroup:TaskRouteToVec2( BanditWPVec2, 600 )
end
)
local SAMSpawnCommand = SpawnObject:Spawn()
end
Thus far, it works perfectly in the sense that, the A10 spawns, and when I click on it, it routes perfectly to my chosen objective. The only thing left is to somehow tell it its task. As of now, it simply flies over the target with nav lights on without engaging.
I tried to replace the onspawn function with this (after changing BanditWP to a specific unit, not a zone)
:OnSpawnGroup(function( SpawnGroup )
SpawnGroup:TaskAttackUnit(BanditWP)
GrpTask = SpawnGroup:TaskAttackUnit(BanditWP)
SpawnGroup:PushTask(GrpTask)
SpawnGroup:TaskRouteToVec2( BanditWPVec2, 600 )
end
However that deletes their route so they get lost before the get to the target.
Thats it!
Thanks again for your help, making an old dude much less stressed.