mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS (#1723)
**INTEL** - Added nil check for cluster position update **OPSGROUP** - Improved fire at point task to take only max avail shots and relative shot amount - Fixed tasks not executed after teleport
This commit is contained in:
@@ -896,10 +896,13 @@ function ARMYGROUP:onafterSpawned(From, Event, To)
|
||||
-- Will be set in update route.
|
||||
--self.option.Formation=self.optionDefault.Formation
|
||||
end
|
||||
|
||||
-- Number of waypoints.
|
||||
local Nwp=#self.waypoints
|
||||
|
||||
-- Update route.
|
||||
if #self.waypoints>1 then
|
||||
self:T(self.lid.."Got waypoints on spawn ==> Cruise in -0.1 sec!")
|
||||
if Nwp>1 and self.isMobile then
|
||||
self:T(self.lid..string.format("Got %d waypoints on spawn ==> Cruise in -1.0 sec!", Nwp))
|
||||
self:__Cruise(-1, nil, self.option.Formation)
|
||||
else
|
||||
self:T(self.lid.."No waypoints on spawn ==> Full Stop!")
|
||||
@@ -920,8 +923,13 @@ end
|
||||
-- @param #number Speed Speed in knots. Default cruise speed.
|
||||
-- @param #number Formation Formation of the group.
|
||||
function ARMYGROUP:onbeforeUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
||||
|
||||
-- Is transition allowed? We assume yes until proven otherwise.
|
||||
local allowed=true
|
||||
local trepeat=nil
|
||||
|
||||
if self:IsWaiting() then
|
||||
self:T(self.lid.."Update route denied. Group is WAIRING!")
|
||||
self:T(self.lid.."Update route denied. Group is WAITING!")
|
||||
return false
|
||||
elseif self:IsInUtero() then
|
||||
self:T(self.lid.."Update route denied. Group is INUTERO!")
|
||||
@@ -936,7 +944,54 @@ function ARMYGROUP:onbeforeUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
||||
self:T(self.lid.."Update route denied. Group is holding position!")
|
||||
return false
|
||||
end
|
||||
return true
|
||||
|
||||
-- Check for a current task.
|
||||
if self.taskcurrent>0 then
|
||||
|
||||
-- Get the current task. Must not be executing already.
|
||||
local task=self:GetTaskByID(self.taskcurrent)
|
||||
|
||||
if task then
|
||||
if task.dcstask.id=="PatrolZone" then
|
||||
-- For patrol zone, we need to allow the update as we insert new waypoints.
|
||||
self:T2(self.lid.."Allowing update route for Task: PatrolZone")
|
||||
elseif task.dcstask.id=="ReconMission" then
|
||||
-- For recon missions, we need to allow the update as we insert new waypoints.
|
||||
self:T2(self.lid.."Allowing update route for Task: ReconMission")
|
||||
elseif task.dcstask.id==AUFTRAG.SpecialTask.RELOCATECOHORT then
|
||||
-- For relocate
|
||||
self:T2(self.lid.."Allowing update route for Task: Relocate Cohort")
|
||||
else
|
||||
local taskname=task and task.description or "No description"
|
||||
self:T(self.lid..string.format("WARNING: Update route denied because taskcurrent=%d>0! Task description = %s", self.taskcurrent, tostring(taskname)))
|
||||
allowed=false
|
||||
end
|
||||
else
|
||||
-- Now this can happen, if we directly use TaskExecute as the task is not in the task queue and cannot be removed. Therefore, also directly executed tasks should be added to the queue!
|
||||
self:T(self.lid..string.format("WARNING: before update route taskcurrent=%d (>0!) but no task?!", self.taskcurrent))
|
||||
-- Anyhow, a task is running so we do not allow to update the route!
|
||||
allowed=false
|
||||
end
|
||||
end
|
||||
|
||||
-- Not good, because mission will never start. Better only check if there is a current task!
|
||||
--if self.currentmission then
|
||||
--end
|
||||
|
||||
-- Only AI flights.
|
||||
if not self.isAI then
|
||||
allowed=false
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:T2(self.lid..string.format("Onbefore Updateroute in state %s: allowed=%s (repeat in %s)", self:GetState(), tostring(allowed), tostring(trepeat)))
|
||||
|
||||
-- Try again?
|
||||
if trepeat then
|
||||
self:__UpdateRoute(trepeat, n)
|
||||
end
|
||||
|
||||
return allowed
|
||||
end
|
||||
|
||||
--- On after "UpdateRoute" event.
|
||||
@@ -1239,6 +1294,33 @@ function ARMYGROUP:onafterRearmed(From, Event, To)
|
||||
self:_CheckGroupDone(1)
|
||||
end
|
||||
|
||||
--- On before "RTZ" event.
|
||||
-- @param #ARMYGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Core.Zone#ZONE Zone The zone to return to.
|
||||
-- @param #number Formation Formation of the group.
|
||||
function ARMYGROUP:onbeforeRTZ(From, Event, To, Zone, Formation)
|
||||
|
||||
-- Zone.
|
||||
local zone=Zone or self.homezone
|
||||
|
||||
if zone then
|
||||
|
||||
if (not self.isMobile) and (not self:IsInZone(zone)) then
|
||||
self:Teleport(zone:GetCoordinate(), 0, true)
|
||||
self:__RTZ(-1, Zone, Formation)
|
||||
return false
|
||||
end
|
||||
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--- On after "RTZ" event.
|
||||
-- @param #ARMYGROUP self
|
||||
-- @param #string From From state.
|
||||
@@ -1618,8 +1700,12 @@ function ARMYGROUP:onafterCruise(From, Event, To, Speed, Formation)
|
||||
-- Not waiting anymore.
|
||||
self.Twaiting=nil
|
||||
self.dTwait=nil
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid.."Cruise ==> Update route in 0.01 sec")
|
||||
|
||||
self:__UpdateRoute(-0.1, nil, nil, Speed, Formation)
|
||||
-- Update route.
|
||||
self:__UpdateRoute(-0.01, nil, nil, Speed, Formation)
|
||||
|
||||
end
|
||||
|
||||
@@ -1712,6 +1798,13 @@ function ARMYGROUP:_InitGroup(Template)
|
||||
-- Max speed in km/h.
|
||||
self.speedMax=self.group:GetSpeedMax()
|
||||
|
||||
-- Is group mobile?
|
||||
if self.speedMax>3.6 then
|
||||
self.isMobile=true
|
||||
else
|
||||
self.isMobile=false
|
||||
end
|
||||
|
||||
-- Cruise speed in km/h
|
||||
self.speedCruise=self.speedMax*0.7
|
||||
|
||||
|
||||
Reference in New Issue
Block a user