mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPSGROUP
- Fixes that ARMY and NAVYGROUPS only go to first waypoint - Fixes for PATROL and RECON missions that waypoints are added at the end - Some other stuff - Still need to fix adinfinitum
This commit is contained in:
@@ -1150,16 +1150,12 @@ end
|
|||||||
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
||||||
function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
||||||
|
|
||||||
|
-- Create coordinate.
|
||||||
local coordinate=self:_CoordinateFromObject(Coordinate)
|
local coordinate=self:_CoordinateFromObject(Coordinate)
|
||||||
|
|
||||||
-- Set waypoint index.
|
-- Set waypoint index.
|
||||||
local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID)
|
local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID)
|
||||||
|
|
||||||
-- Check if final waypoint is still passed.
|
|
||||||
if wpnumber>self.currentwp then
|
|
||||||
self:_PassedFinalWaypoint(false, "ARMYGROUP.AddWaypoint: wpnumber>self.currentwp")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
Speed=Speed or self:GetSpeedCruise()
|
Speed=Speed or self:GetSpeedCruise()
|
||||||
|
|
||||||
@@ -1185,8 +1181,7 @@ function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation
|
|||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
if Updateroute==nil or Updateroute==true then
|
if Updateroute==nil or Updateroute==true then
|
||||||
self:UpdateRoute()
|
self:__UpdateRoute(-0.01)
|
||||||
--self:_CheckGroupDone(1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return waypoint
|
return waypoint
|
||||||
|
|||||||
@@ -2275,7 +2275,7 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Flight (status=%s) did NOT pass the final waypoint yet ==> update route", self:GetState()))
|
self:T(self.lid..string.format("Flight (status=%s) did NOT pass the final waypoint yet ==> update route in -0.01 sec", self:GetState()))
|
||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
self:__UpdateRoute(-0.01)
|
self:__UpdateRoute(-0.01)
|
||||||
@@ -3466,18 +3466,17 @@ end
|
|||||||
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
||||||
function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Altitude, Updateroute)
|
function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Altitude, Updateroute)
|
||||||
|
|
||||||
|
-- Create coordinate.
|
||||||
|
local coordinate=self:_CoordinateFromObject(Coordinate)
|
||||||
|
|
||||||
-- Set waypoint index.
|
-- Set waypoint index.
|
||||||
local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID)
|
local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID)
|
||||||
|
|
||||||
if wpnumber>self.currentwp then
|
|
||||||
self:_PassedFinalWaypoint(false, "FLIGHTGROUP:AddWaypoint wpnumber>self.currentwp")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
Speed=Speed or self.speedCruise
|
Speed=Speed or self.speedCruise
|
||||||
|
|
||||||
-- Create air waypoint.
|
-- Create air waypoint.
|
||||||
local wp=Coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(Speed), true, nil, {})
|
local wp=coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(Speed), true, nil, {})
|
||||||
|
|
||||||
-- Create waypoint data table.
|
-- Create waypoint data table.
|
||||||
local waypoint=self:_CreateWaypoint(wp)
|
local waypoint=self:_CreateWaypoint(wp)
|
||||||
|
|||||||
@@ -146,8 +146,8 @@ function NAVYGROUP:New(group)
|
|||||||
self:AddTransition("*", "CollisionWarning", "*") -- Collision warning.
|
self:AddTransition("*", "CollisionWarning", "*") -- Collision warning.
|
||||||
self:AddTransition("*", "ClearAhead", "*") -- Clear ahead.
|
self:AddTransition("*", "ClearAhead", "*") -- Clear ahead.
|
||||||
|
|
||||||
self:AddTransition("*", "Dive", "Diving") -- Command a submarine to dive.
|
self:AddTransition("*", "Dive", "*") -- Command a submarine to dive.
|
||||||
self:AddTransition("Diving", "Surface", "Cruising") -- Command a submarine to go to the surface.
|
self:AddTransition("Diving", "Surface", "*") -- Command a submarine to go to the surface.
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
--- Pseudo Functions ---
|
--- Pseudo Functions ---
|
||||||
@@ -1105,30 +1105,17 @@ end
|
|||||||
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
||||||
function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Updateroute)
|
function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Updateroute)
|
||||||
|
|
||||||
-- Check if a coordinate was given or at least a positionable.
|
-- Create coordinate.
|
||||||
if not Coordinate:IsInstanceOf("COORDINATE") then
|
local coordinate=self:_CoordinateFromObject(Coordinate)
|
||||||
if Coordinate:IsInstanceOf("POSITIONABLE") or Coordinate:IsInstanceOf("ZONE_BASE") then
|
|
||||||
self:T(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE or ZONE. Trying to get coordinate")
|
|
||||||
Coordinate=Coordinate:GetCoordinate()
|
|
||||||
else
|
|
||||||
self:E(self.lid.."ERROR: Coordinate is neither a COORDINATE nor any POSITIONABLE or ZONE!")
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set waypoint index.
|
-- Set waypoint index.
|
||||||
local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID)
|
local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID)
|
||||||
|
|
||||||
-- Check if final waypoint is still passed.
|
|
||||||
if wpnumber>self.currentwp then
|
|
||||||
self:_PassedFinalWaypoint(false, "NAVYGROUP:AddWaypoint wpnumber>self.currentwp")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
Speed=Speed or self:GetSpeedCruise()
|
Speed=Speed or self:GetSpeedCruise()
|
||||||
|
|
||||||
-- Create a Naval waypoint.
|
-- Create a Naval waypoint.
|
||||||
local wp=Coordinate:WaypointNaval(UTILS.KnotsToKmph(Speed), Depth)
|
local wp=coordinate:WaypointNaval(UTILS.KnotsToKmph(Speed), Depth)
|
||||||
|
|
||||||
-- Create waypoint data table.
|
-- Create waypoint data table.
|
||||||
local waypoint=self:_CreateWaypoint(wp)
|
local waypoint=self:_CreateWaypoint(wp)
|
||||||
@@ -1141,7 +1128,7 @@ function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Up
|
|||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
if Updateroute==nil or Updateroute==true then
|
if Updateroute==nil or Updateroute==true then
|
||||||
self:_CheckGroupDone(1)
|
self:__UpdateRoute(-0.01)
|
||||||
end
|
end
|
||||||
|
|
||||||
return waypoint
|
return waypoint
|
||||||
|
|||||||
@@ -402,6 +402,7 @@ OPSGROUP.TaskType={
|
|||||||
-- @field #number roaddist Distance to closest point on road.
|
-- @field #number roaddist Distance to closest point on road.
|
||||||
-- @field Wrapper.Marker#MARKER marker Marker on the F10 map.
|
-- @field Wrapper.Marker#MARKER marker Marker on the F10 map.
|
||||||
-- @field #string formation Ground formation. Similar to action but on/off road.
|
-- @field #string formation Ground formation. Similar to action but on/off road.
|
||||||
|
-- @field #number missionUID Mission UID (Auftragsnr) this waypoint belongs to.
|
||||||
|
|
||||||
--- Cargo Carrier status.
|
--- Cargo Carrier status.
|
||||||
-- @type OPSGROUP.CarrierStatus
|
-- @type OPSGROUP.CarrierStatus
|
||||||
@@ -2502,6 +2503,18 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
|||||||
|
|
||||||
-- Number of waypoints before delete.
|
-- Number of waypoints before delete.
|
||||||
local N=#self.waypoints
|
local N=#self.waypoints
|
||||||
|
|
||||||
|
-- Always keep at least one waypoint.
|
||||||
|
if N==1 then
|
||||||
|
self:E(self.lid..string.format("ERROR: Cannot remove waypoint with index=%d! It is the only waypoint and a group needs at least ONE waypoint", wpindex))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check that wpindex is not larger than the number of waypoints in the table.
|
||||||
|
if wpindex>N then
|
||||||
|
self:E(self.lid..string.format("ERROR: Cannot remove waypoint with index=%d as there are only N=%d waypoints!", wpindex, N))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
-- Remove waypoint marker.
|
-- Remove waypoint marker.
|
||||||
local wp=self:GetWaypoint(wpindex)
|
local wp=self:GetWaypoint(wpindex)
|
||||||
@@ -2525,12 +2538,14 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
|||||||
-- Removed a FUTURE waypoint
|
-- Removed a FUTURE waypoint
|
||||||
---
|
---
|
||||||
|
|
||||||
-- TODO: patrol adinfinitum.
|
-- TODO: patrol adinfinitum. Not sure this is handled correctly. If patrol adinfinitum and we have now only one WP left, we should at least go back.
|
||||||
|
|
||||||
if self.currentwp>=n then
|
-- Could be that the waypoint we are currently moving to was the LAST waypoint. Then we now passed the final waypoint.
|
||||||
self:_PassedFinalWaypoint(true, "Removed FUTURE waypoint")
|
if self.currentwp>=n and not self.adinfinitum then
|
||||||
|
self:_PassedFinalWaypoint(true, "Removed FUTURE waypoint we are currently moving to and that was the LAST waypoint")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check if group is done.
|
||||||
self:_CheckGroupDone(1)
|
self:_CheckGroupDone(1)
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -3199,6 +3214,9 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
--env.info("FF adding current task to queue")
|
--env.info("FF adding current task to queue")
|
||||||
table.insert(self.taskqueue, Task)
|
table.insert(self.taskqueue, Task)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get mission of this task (if any).
|
||||||
|
local Mission=self:GetMissionByTaskID(self.taskcurrent)
|
||||||
|
|
||||||
if Task.dcstask.id=="Formation" then
|
if Task.dcstask.id=="Formation" then
|
||||||
|
|
||||||
@@ -3241,15 +3259,21 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
-- Speed and altitude.
|
-- Speed and altitude.
|
||||||
local Speed=UTILS.KmphToKnots(Task.dcstask.params.speed or self.speedCruise)
|
local Speed=UTILS.KmphToKnots(Task.dcstask.params.speed or self.speedCruise)
|
||||||
local Altitude=Task.dcstask.params.altitude and UTILS.MetersToFeet(Task.dcstask.params.altitude) or nil
|
local Altitude=Task.dcstask.params.altitude and UTILS.MetersToFeet(Task.dcstask.params.altitude) or nil
|
||||||
|
|
||||||
|
local currUID=self:GetWaypointCurrent().uid
|
||||||
|
|
||||||
-- New waypoint.
|
-- New waypoint.
|
||||||
|
local wp=nil --#OPSGROUP.Waypoint
|
||||||
if self.isFlightgroup then
|
if self.isFlightgroup then
|
||||||
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
elseif self.isArmygroup then
|
elseif self.isArmygroup then
|
||||||
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation)
|
wp=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Formation)
|
||||||
elseif self.isNavygroup then
|
elseif self.isNavygroup then
|
||||||
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=NAVYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set mission UID.
|
||||||
|
wp.missionUID=Mission and Mission.auftragsnummer or nil
|
||||||
|
|
||||||
elseif Task.dcstask.id=="ReconMission" then
|
elseif Task.dcstask.id=="ReconMission" then
|
||||||
|
|
||||||
@@ -3272,16 +3296,22 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
local Altitude=Task.dcstask.params.altitude and UTILS.MetersToFeet(Task.dcstask.params.altitude) or nil
|
local Altitude=Task.dcstask.params.altitude and UTILS.MetersToFeet(Task.dcstask.params.altitude) or nil
|
||||||
|
|
||||||
--Coordinate:MarkToAll("Next waypoint", ReadOnly,Text)
|
--Coordinate:MarkToAll("Next waypoint", ReadOnly,Text)
|
||||||
|
|
||||||
|
local currUID=self:GetWaypointCurrent().uid
|
||||||
|
|
||||||
-- New waypoint.
|
-- New waypoint.
|
||||||
|
local wp=nil --#OPSGROUP.Waypoint
|
||||||
if self.isFlightgroup then
|
if self.isFlightgroup then
|
||||||
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
elseif self.isArmygroup then
|
elseif self.isArmygroup then
|
||||||
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation)
|
wp=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Formation)
|
||||||
elseif self.isNavygroup then
|
elseif self.isNavygroup then
|
||||||
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=NAVYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set mission UID.
|
||||||
|
wp.missionUID=Mission and Mission.auftragsnummer or nil
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- If task is scheduled (not waypoint) set task.
|
-- If task is scheduled (not waypoint) set task.
|
||||||
@@ -3328,10 +3358,9 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get mission of this task (if any).
|
|
||||||
local Mission=self:GetMissionByTaskID(self.taskcurrent)
|
-- Set AUFTRAG status.
|
||||||
if Mission then
|
if Mission then
|
||||||
-- Set AUFTRAG status.
|
|
||||||
self:MissionExecute(Mission)
|
self:MissionExecute(Mission)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3922,7 +3951,15 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
|||||||
-- Remove mission waypoint.
|
-- Remove mission waypoint.
|
||||||
local wpidx=Mission:GetGroupWaypointIndex(self)
|
local wpidx=Mission:GetGroupWaypointIndex(self)
|
||||||
if wpidx then
|
if wpidx then
|
||||||
self:RemoveWaypointByID(wpidx)
|
--self:RemoveWaypointByID(wpidx)
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=#self.waypoints,1,-1 do
|
||||||
|
local wp=self.waypoints[i] --#OPSGROUP.Waypoint
|
||||||
|
if wp.missionUID==Mission.auftragsnummer then
|
||||||
|
--table.remove(self.waypoints, i)
|
||||||
|
self:RemoveWaypoint(i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Decrease patrol data.
|
-- Decrease patrol data.
|
||||||
@@ -4097,7 +4134,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
|||||||
--waypointcoord:MarkToAll(string.format("Mission %s alt=%d m", mission:GetName(), waypointcoord.y))
|
--waypointcoord:MarkToAll(string.format("Mission %s alt=%d m", mission:GetName(), waypointcoord.y))
|
||||||
|
|
||||||
-- Add waypoint.
|
-- Add waypoint.
|
||||||
local waypoint=self:AddWaypoint(waypointcoord, SpeedToMission, nil, formation, false) ; waypoint.ismission=true
|
local waypoint=self:AddWaypoint(waypointcoord, SpeedToMission, uid, formation, false) ; waypoint.missionUID=mission.auftragsnummer
|
||||||
|
|
||||||
-- Add waypoint task. UpdateRoute is called inside.
|
-- Add waypoint task. UpdateRoute is called inside.
|
||||||
local waypointtask=self:AddTaskWaypoint(mission.DCStask, waypoint, mission.name, mission.prio, mission.duration)
|
local waypointtask=self:AddTaskWaypoint(mission.DCStask, waypoint, mission.name, mission.prio, mission.duration)
|
||||||
@@ -4109,9 +4146,10 @@ function OPSGROUP:RouteToMission(mission, delay)
|
|||||||
-- Set waypoint index.
|
-- Set waypoint index.
|
||||||
mission:SetGroupWaypointIndex(self, waypoint.uid)
|
mission:SetGroupWaypointIndex(self, waypoint.uid)
|
||||||
|
|
||||||
|
-- Add egress waypoint.
|
||||||
local egress=mission:GetMissionEgressCoord()
|
local egress=mission:GetMissionEgressCoord()
|
||||||
if egress then
|
if egress then
|
||||||
local waypoint=self:AddWaypoint(egress, SpeedToMission, nil, formation, false) ; waypoint.ismission=true
|
local waypointEgress=self:AddWaypoint(egress, SpeedToMission, waypoint.uid, formation, false) ; waypointEgress.missionUID=mission.auftragsnummer
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -4287,6 +4325,12 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
|
|
||||||
-- Get the current task.
|
-- Get the current task.
|
||||||
local task=self:GetTaskCurrent()
|
local task=self:GetTaskCurrent()
|
||||||
|
|
||||||
|
-- Get the corresponding mission.
|
||||||
|
local mission=nil --Ops.Auftrag#AUFTRAG
|
||||||
|
if task then
|
||||||
|
mission=self:GetMissionByTaskID(task.id)
|
||||||
|
end
|
||||||
|
|
||||||
if task and task.dcstask.id=="PatrolZone" then
|
if task and task.dcstask.id=="PatrolZone" then
|
||||||
|
|
||||||
@@ -4302,14 +4346,18 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
-- Speed and altitude.
|
-- Speed and altitude.
|
||||||
local Speed=UTILS.KmphToKnots(task.dcstask.params.speed or self.speedCruise)
|
local Speed=UTILS.KmphToKnots(task.dcstask.params.speed or self.speedCruise)
|
||||||
local Altitude=task.dcstask.params.altitude and UTILS.MetersToFeet(task.dcstask.params.altitude) or nil
|
local Altitude=task.dcstask.params.altitude and UTILS.MetersToFeet(task.dcstask.params.altitude) or nil
|
||||||
|
|
||||||
|
local currUID=self:GetWaypointCurrent().uid
|
||||||
|
|
||||||
|
local wp=nil --#OPSGROUP.Waypoint
|
||||||
if self.isFlightgroup then
|
if self.isFlightgroup then
|
||||||
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
elseif self.isArmygroup then
|
elseif self.isArmygroup then
|
||||||
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation)
|
wp=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Formation)
|
||||||
elseif self.isNavygroup then
|
elseif self.isNavygroup then
|
||||||
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=NAVYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
end
|
end
|
||||||
|
wp.missionUID=mission and mission.auftragsnummer or nil
|
||||||
|
|
||||||
elseif task and task.dcstask.id=="ReconMission" then
|
elseif task and task.dcstask.id=="ReconMission" then
|
||||||
|
|
||||||
@@ -4332,14 +4380,18 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
|
|
||||||
-- Debug.
|
-- Debug.
|
||||||
--Coordinate:MarkToAll("Recon Waypoint n="..tostring(n))
|
--Coordinate:MarkToAll("Recon Waypoint n="..tostring(n))
|
||||||
|
|
||||||
|
local currUID=self:GetWaypointCurrent().uid
|
||||||
|
|
||||||
|
local wp=nil --#OPSGROUP.Waypoint
|
||||||
if self.isFlightgroup then
|
if self.isFlightgroup then
|
||||||
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
elseif self.isArmygroup then
|
elseif self.isArmygroup then
|
||||||
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation)
|
wp=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Formation)
|
||||||
elseif self.isNavygroup then
|
elseif self.isNavygroup then
|
||||||
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
wp=NAVYGROUP.AddWaypoint(self, Coordinate, Speed, currUID, Altitude)
|
||||||
end
|
end
|
||||||
|
wp.missionUID=mission and mission.auftragsnummer or nil
|
||||||
|
|
||||||
-- Increase counter.
|
-- Increase counter.
|
||||||
task.dcstask.params.lastindex=task.dcstask.params.lastindex+1
|
task.dcstask.params.lastindex=task.dcstask.params.lastindex+1
|
||||||
@@ -4365,26 +4417,43 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
---
|
||||||
|
-- No special task active
|
||||||
|
---
|
||||||
|
|
||||||
-- Apply tasks of this waypoint.
|
-- Apply tasks of this waypoint.
|
||||||
local ntasks=self:_SetWaypointTasks(Waypoint)
|
local ntasks=self:_SetWaypointTasks(Waypoint)
|
||||||
|
|
||||||
-- Get waypoint index.
|
-- Get waypoint index.
|
||||||
local wpindex=self:GetWaypointIndex(Waypoint.uid)
|
local wpindex=self:GetWaypointIndex(Waypoint.uid)
|
||||||
|
|
||||||
-- Final waypoint reached?
|
-- Final waypoint reached?
|
||||||
if wpindex==nil or wpindex==#self.waypoints then
|
if wpindex==nil or wpindex==#self.waypoints then
|
||||||
|
|
||||||
-- Set switch to true.
|
-- Set switch to true.
|
||||||
if not self.adinfinitum or #self.waypoints<=1 then
|
if self.adinfinitum then
|
||||||
|
if #self.waypoints<=1 then
|
||||||
|
self:_PassedFinalWaypoint(true, "PassingWaypoint: adinfinitum but only ONE WAYPOINT left")
|
||||||
|
else
|
||||||
|
local uid=self:GetWaypointID(1)
|
||||||
|
self:GotoWaypoint(uid)
|
||||||
|
end
|
||||||
|
else
|
||||||
self:_PassedFinalWaypoint(true, "PassingWaypoint: wpindex=nil or wpindex=#self.waypoints")
|
self:_PassedFinalWaypoint(true, "PassingWaypoint: wpindex=nil or wpindex=#self.waypoints")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Passing mission waypoint?
|
||||||
|
if Waypoint.missionUID then
|
||||||
|
self:T(self.lid.."FF passing mission waypoint")
|
||||||
|
--self:RemoveWaypointByID(Waypoint.uid)
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if all tasks/mission are done?
|
-- Check if all tasks/mission are done?
|
||||||
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
|
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
|
||||||
if ntasks==0 and (self:HasPassedFinalWaypoint()) then-- or self:IsArmygroup() or self:IsNavygroup()) then
|
if ntasks==0 and self:HasPassedFinalWaypoint() then
|
||||||
self:_CheckGroupDone(0.01)
|
self:_CheckGroupDone(0.01)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -7958,7 +8027,6 @@ function OPSGROUP:_CreateWaypoint(waypoint)
|
|||||||
local taskswp={}
|
local taskswp={}
|
||||||
|
|
||||||
-- At each waypoint report passing.
|
-- At each waypoint report passing.
|
||||||
--local TaskPassingWaypoint=self.group:TaskFunction("OPSGROUP._PassingWaypoint", self, waypoint.uid)
|
|
||||||
local TaskPassingWaypoint=self:_SimpleTaskFunction("OPSGROUP._PassingWaypoint", waypoint.uid)
|
local TaskPassingWaypoint=self:_SimpleTaskFunction("OPSGROUP._PassingWaypoint", waypoint.uid)
|
||||||
table.insert(taskswp, TaskPassingWaypoint)
|
table.insert(taskswp, TaskPassingWaypoint)
|
||||||
|
|
||||||
@@ -7988,7 +8056,7 @@ function OPSGROUP:_AddWaypoint(waypoint, wpnumber)
|
|||||||
|
|
||||||
-- Now we obviously did not pass the final waypoint.
|
-- Now we obviously did not pass the final waypoint.
|
||||||
if self.currentwp and wpnumber>self.currentwp then
|
if self.currentwp and wpnumber>self.currentwp then
|
||||||
self:_PassedFinalWaypoint(false, "_AddWaypoint self.currentwp and wpnumber>self.currentwp")
|
self:_PassedFinalWaypoint(false, string.format("_AddWaypoint: wpnumber/index %d>%d self.currentwp", wpnumber, self.currentwp))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -8017,7 +8085,7 @@ function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
|
|||||||
local wp=self.waypoints0[i] --DCS#Waypoint
|
local wp=self.waypoints0[i] --DCS#Waypoint
|
||||||
|
|
||||||
-- Coordinate of the waypoint.
|
-- Coordinate of the waypoint.
|
||||||
local coordinate=COORDINATE:NewFromWaypoint(wp)
|
local Coordinate=COORDINATE:NewFromWaypoint(wp)
|
||||||
|
|
||||||
-- Strange!
|
-- Strange!
|
||||||
wp.speed=wp.speed or 0
|
wp.speed=wp.speed or 0
|
||||||
@@ -8025,14 +8093,25 @@ function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
|
|||||||
-- Speed at the waypoint.
|
-- Speed at the waypoint.
|
||||||
local speedknots=UTILS.MpsToKnots(wp.speed)
|
local speedknots=UTILS.MpsToKnots(wp.speed)
|
||||||
|
|
||||||
if i==1 then
|
-- Expected speed to the first waypoint.
|
||||||
|
if i<=2 then
|
||||||
self.speedWp=wp.speed
|
self.speedWp=wp.speed
|
||||||
end
|
end
|
||||||
|
|
||||||
local waypoint=self:_CreateWaypoint(wp)
|
-- Speed in knots.
|
||||||
|
local Speed=UTILS.MpsToKnots(wp.speed)
|
||||||
|
|
||||||
|
--local waypoint=self:_CreateWaypoint(wp)
|
||||||
|
--self:_AddWaypoint(waypoint)
|
||||||
|
|
||||||
|
if self:IsFlightgroup() then
|
||||||
|
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, nil, Altitude, false)
|
||||||
|
elseif self:IsArmygroup() then
|
||||||
|
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, nil, wp.action, false)
|
||||||
|
elseif self:IsNavygroup() then
|
||||||
|
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, nil, Depth, false)
|
||||||
|
end
|
||||||
|
|
||||||
self:_AddWaypoint(waypoint)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
@@ -8052,6 +8131,7 @@ function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
|
|||||||
table.remove(self.waypoints, #self.waypoints)
|
table.remove(self.waypoints, #self.waypoints)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set destination to homebase.
|
||||||
if self.destbase==nil then
|
if self.destbase==nil then
|
||||||
self.destbase=self.homebase
|
self.destbase=self.homebase
|
||||||
end
|
end
|
||||||
@@ -9890,7 +9970,8 @@ function OPSGROUP:_CoordinateFromObject(Object)
|
|||||||
else
|
else
|
||||||
if Object:IsInstanceOf("POSITIONABLE") or Object:IsInstanceOf("ZONE_BASE") then
|
if Object:IsInstanceOf("POSITIONABLE") or Object:IsInstanceOf("ZONE_BASE") then
|
||||||
self:T(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE or ZONE. Trying to get coordinate")
|
self:T(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE or ZONE. Trying to get coordinate")
|
||||||
return Object:GetCoordinate()
|
local coord=Object:GetCoordinate()
|
||||||
|
return coord
|
||||||
else
|
else
|
||||||
self:E(self.lid.."ERROR: Coordinate is neither a COORDINATE nor any POSITIONABLE or ZONE!")
|
self:E(self.lid.."ERROR: Coordinate is neither a COORDINATE nor any POSITIONABLE or ZONE!")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user