Jump to content

[MOOSE] how to add waypoints from scratch?


omskTransmash

Recommended Posts

Hello.

 

I was pretty sure this was asked and answered, and tried my best to search the forum and internet but was no good.

 

 

What I am trying to do is spawn a group then set the groups route (set of waypoints) to follow a route, which must be set dynamically from the script (not in the ME)

 

 

From what i gather,

 

The route is copied and set when spawned from pre-defined template(group) in ME which the group spawned from.

: But it's fixed so i cannot change them during the mission, from the script)

 

 

I can copy route from some other template and group on the fly: Route( .. GetTaskRoute))

: But it's also fixed since other template's route is fixed from the ME.

 

But how can I build route (set of waypoints) on the fly?

Searched through MOOSE manual many times but cannot find functions like Route.Add, Route.Remove, TaskRoute.Add ..

 

I think it's fundamentally possible as

 

Ex1) I found manually setting / adding waypoint without MOOSE

https://forums.eagle.ru/showthread.php?t=188936

 

Ex2) with MIST

https://forums.eagle.ru/showthread.php?t=203315

 

 

 

But could not find how to do it with MOOSE. I found Group:Route gets table Route as paramter. but could not find what a table (variable) Route is.. is it the same with Ex2)? then how to build it with MOOSE?

 

 

any help would be greatly appreciated!

 

 

 

 

EDIT: I just found a good example in the MOOSE.lua itself, so sharing it here for the future reference.

 

 

 



-- ## Example 14: Strategic Bombing
--
-- This example shows how to employ strategic bombers in a mission. Three B-52s are launched at Kobuleti with the assignment to wipe out the enemy warehouse at Sukhumi.
-- The bombers will get a flight path and make their approach from the South at an altitude of 5000 m ASL. After their bombing run, they will return to Kobuleti and
-- added back to stock.
--
--     -- Start warehouses
--     warehouse.Kobuleti:Start()
--     warehouse.Sukhumi:Start()
--
--     -- Add a strategic bomber assets
--     warehouse.Kobuleti:AddAsset("B-52H", 3)
--
--     -- Request bombers for specific task of bombing Sukhumi warehouse.
--     warehouse.Kobuleti:AddRequest(warehouse.Kobuleti, WAREHOUSE.Descriptor.ATTRIBUTE, WAREHOUSE.Attribute.AIR_BOMBER, WAREHOUSE.Quantity.ALL, nil, nil, nil, "Bomb Sukhumi")
--
--     -- Specify assignment after bombers have been spawned.
--     function warehouse.Kobuleti:OnAfterSelfRequest(From, Event, To, groupset, request)
--       local groupset=groupset --Core.Set#SET_GROUP
--
--       -- Get assignment of this request.
--       local assignment=warehouse.Kobuleti:GetAssignment(request)
--
--       if assignment=="Bomb Sukhumi" then
--
--         for _,_group in pairs(groupset:GetSet()) do
--           local group=_group --Wrapper.Group#GROUP
--
--           -- Start uncontrolled aircraft.
--           group:StartUncontrolled()
--
--           -- Target coordinate!
--           local ToCoord=warehouse.Sukhumi:GetCoordinate():SetAltitude(5000)
--
--           -- Home coordinate.
--           local HomeCoord=warehouse.Kobuleti:GetCoordinate():SetAltitude(3000)
--
--           -- Task bomb Sukhumi warehouse using all bombs (2032) from direction 180 at altitude 5000 m.
--           local task=group:TaskBombing(warehouse.Sukhumi:GetCoordinate():GetVec2(), false, "All", nil , 180, 5000, 2032)
--
--           -- Define waypoints.
--           local WayPoints={}
--
--           -- Take off position.
--           WayPoints[1]=warehouse.Kobuleti:GetCoordinate():WaypointAirTakeOffParking()
--           -- Begin bombing run 20 km south of target.
--           WayPoints[2]=ToCoord:Translate(20*1000, 180):WaypointAirTurningPoint(nil, 600, {task}, "Bombing Run")
--           -- Return to base.
--           WayPoints[3]=HomeCoord:WaypointAirTurningPoint()
--           -- Land at homebase. Bombers are added back to stock and can be employed in later assignments.
--           WayPoints[4]=warehouse.Kobuleti:GetCoordinate():WaypointAirLanding()
--
--           -- Route bombers.
--           group:Route(WayPoints)
--         end
--
--       end
--     end




Edited by zakk95
  • Thanks 1
Link to comment
Share on other sites

This has worked for me in the past. I created a function called NewPoint and used it to build a list of points to add to a route.

 

 

 

NewPoint = function(UnitType, X,Y,Alt, Action, Type, Speed, WPname)

 

-- AIRPLANE = 0

-- HELICOPTER = 1

-- GROUND = 2

-- SHIP = 3

-- TRAIN = 4

local points = {

["y"] = Y,

["x"] = X,

["alt"] = Alt,

["action"] = Action,

["speed"] = Speed,

["type"] = Type,

["formation_template"] = "",

--["speed_locked"] = true,

["name"] = WPname,

["task"] =

{

["id"] = "ComboTask",

["params"] =

{

["tasks"] =

{

}, -- end of ["tasks"]

}, -- end of ["params"]

}, -- end of ["task"]

 

 

}

 

 

return points

end

 

 

 

 

Sorry this is not for MOOSE, this was just me coding without third party tools.


Edited by Novan
Correction
  • Thanks 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...