Bearfoot Posted May 7, 2020 Posted May 7, 2020 I am trying to spawn a new group on the ground at a base, have it take off, fly to one offset point (random within zone), and from there fly to another point (another random within zone, say the IP), and from there attack a (known) unit. I can get it to do one (e.g., fly to a point within a zone OR attack), but not both. That is, the following has the spawned group correctly attack: function generate_attack1() NavStrikeSpawner = SPAWN:New("Strike #001") :OnSpawnGroup( function (SpawnGroup) target_unit = UNIT:FindByName("Target #001") attack_task = SpawnGroup:TaskAttackUnit(target_unit) SpawnGroup:PushTask(attack_task) end ) :Spawn() end But, obviously, there is no attack. And the following (seems to) route the spawned group correctly, but it does not attack. function generate_attack2() NavStrikeSpawner = SPAWN:New("Strike #001") :OnSpawnGroup( function (SpawnGroup) offset_zone = ZONE:New("Offset Zone #001") attack_zone = ZONE:New("Attack Zone #001") SpawnGroup:TaskRouteToZone(offset_zone, true, 450, "Line Abreast") SpawnGroup:TaskRouteToZone(attack_zone, true, 450, "Line Abreast") target_unit = UNIT:FindByName("Target #001") attack_task = SpawnGroup:TaskAttackUnit(target_unit) SpawnGroup:PushTask(attack_task) -- also tried: SpawnGroup:SetTask(attack_task) end ) :Spawn() end I am actually not sure if this is the correct way to route groups through zones. When I tried to PushTask with the routing I got an error. But it seems to work without that? The Spawned group are a couple of bombers with no waypoints or anything if it makes a difference. BTW, bonus points if someone can tell me how to set the flight altitude on the way to the zone so it goes nap of earth and then really low over the water!
Hardcard Posted May 7, 2020 Posted May 7, 2020 Post your mission file, it'll be easier. [sIGPIC][/sIGPIC]
Bearfoot Posted May 8, 2020 Author Posted May 8, 2020 Thanks! I figured out how to do this thanks to help from the MOOSE discord. I will share the mission file anyway, so people (or the future me!) can see how to get it done.
Recommended Posts