Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Polygon zones
- local polyzone =
- {
- }
- --Dynamic Movement Table
- local AutoMovement =
- {
- }
- --Populate polyzones from mission
- local int = 1
- for GName, Data in pairs(mist.DBs.groupsByName) do
- if Data.category == "vehicle" then
- if string.sub(GName,1,string.len("POLYZONE"))=="POLYZONE" then
- polyzone[int] = GName
- AutoMovement[GName] = "stop"
- int = int+1
- end
- end
- end
- --Run polygon continues test for units
- for i,name in pairs(polyzone) do
- for k,v in pairs({"red","blue"}) do
- mist.flagFunc.units_in_polygon
- {
- units = {'['..v..'][helicopter]','['..v..'][plane]'},
- zone = mist.getGroupPoints(name),
- flag = v..name,
- req_num = 1,
- interval = 10,
- toggle = true
- }
- end
- end
- --movement manager
- function MoveManager()
- for i, PZName in pairs(polyzone) do
- local movement = {}
- for k,v in pairs({"red","blue"}) do
- if trigger.misc.getUserFlag(v..PZName) == 1 then
- table.insert(movement,v)
- end
- end
- if (#movement == 2 or #movement == 0) and AutoMovement[PZName] ~= "stop" then
- AutoMovement[PZName] = "stop"
- GoToRoute(PZName,movement)
- elseif #movement == 1 and AutoMovement[PZName] ~= movement[1] then
- AutoMovement[PZName] = movement[1]
- GoToRoute(PZName,AutoMovement[PZName])
- end
- trigger.action.outText("movement:"..#movement.."/n"..mist.utils.tableShow(movement).."/nAutomovement:/n"..mist.utils.tableShow(AutoMovement), 10)
- end
- timer.scheduleFunction(MoveManager, {}, timer.getTime() + 10)
- end
- --Moving groups in polyzone
- function GoToRoute(path,coa)
- for GName, GTable in pairs(mist.DBs.groupsByName) do
- if GTable.category == "vehicle" then
- local unitName = GTable.units[1].unitName
- local unit = Unit.getByName(unitName)
- if unit then
- local pos = unit:getPosition().p
- local zone = mist.getGroupPoints(path)
- if mist.pointInPolygon(pos, zone) and coa == "stop" then
- mist.groupRandomDistSelf(GName, 1)
- elseif mist.pointInPolygon(pos, zone) and GTable.coalition == coa then
- ReturnToRoute(GName,coa..path)
- elseif mist.pointInPolygon(pos, zone) and (GTable.coalition ~= coa and coa~="stop") then
- mist.groupRandomDistSelf(GName, 1)
- end
- end
- end
- end
- end
- MoveManager()
- --mist.scheduleFunction(MoveManager, {}, timer.getTime() + 10, 7200)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement