mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Ops
This commit is contained in:
parent
cda1658541
commit
2e998dc315
@ -44,7 +44,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The AIRWING Concept
|
||||
--
|
||||
@ -66,7 +66,7 @@
|
||||
-- At this point the airwing does not have any assets (aircraft). In order to add these, one needs to first define SQUADRONS.
|
||||
--
|
||||
-- VFA151=SQUADRON:New("F-14 Group", 8, "VFA-151 (Vigilantes)")
|
||||
-- VFA151:AddMissionCapability({AUFTRAG.Type.GCCAP, AUFTRAG.Type.INTERCEPT})
|
||||
-- VFA151:AddMissionCapability({AUFTRAG.Type.GCICAP, AUFTRAG.Type.INTERCEPT})
|
||||
--
|
||||
-- airwing:AddSquadron(VFA151)
|
||||
--
|
||||
@ -78,8 +78,8 @@
|
||||
-- defined in the Mission Editor.
|
||||
--
|
||||
-- -- F-14 payloads for CAP and INTERCEPT. Phoenix are first, sparrows are second choice.
|
||||
-- airwing:NewPayload(GROUP:FindByName("F-14 Payload AIM-54C"), 2, {AUFTRAG.Type.INTERCEPT, AUFTRAG.Type.GCCAP}, 80)
|
||||
-- airwing:NewPayload(GROUP:FindByName("F-14 Payload AIM-7M"), 20, {AUFTRAG.Type.INTERCEPT, AUFTRAG.Type.GCCAP})
|
||||
-- airwing:NewPayload(GROUP:FindByName("F-14 Payload AIM-54C"), 2, {AUFTRAG.Type.INTERCEPT, AUFTRAG.Type.GCICAP}, 80)
|
||||
-- airwing:NewPayload(GROUP:FindByName("F-14 Payload AIM-7M"), 20, {AUFTRAG.Type.INTERCEPT, AUFTRAG.Type.GCICAP})
|
||||
--
|
||||
-- This will add two AIM-54C and 20 AIM-7M payloads.
|
||||
--
|
||||
@ -909,7 +909,7 @@ end
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:CheckCAP()
|
||||
|
||||
local Ncap=self:CountMissionsInQueue({AUFTRAG.Type.GCCAP, AUFTRAG.Type.INTERCEPT})
|
||||
local Ncap=self:CountMissionsInQueue({AUFTRAG.Type.GCICAP, AUFTRAG.Type.INTERCEPT})
|
||||
|
||||
for i=1,self.nflightsCAP-Ncap do
|
||||
|
||||
@ -917,7 +917,7 @@ function AIRWING:CheckCAP()
|
||||
|
||||
local altitude=patrol.altitude+1000*patrol.noccupied
|
||||
|
||||
local missionCAP=AUFTRAG:NewGCCAP(patrol.coord, altitude, patrol.speed, patrol.heading, patrol.leg)
|
||||
local missionCAP=AUFTRAG:NewGCICAP(patrol.coord, altitude, patrol.speed, patrol.heading, patrol.leg)
|
||||
|
||||
missionCAP.patroldata=patrol
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The ARMYGROUP Concept
|
||||
--
|
||||
@ -147,7 +147,7 @@ end
|
||||
-- @return #ARMYGROUP self
|
||||
function ARMYGROUP:SetSpeedCruise(Speed)
|
||||
|
||||
self.speedCruise=Speed and UTILS.KnotsToKmph(Speed) or self.speedmax*0.7
|
||||
self.speedCruise=Speed and UTILS.KnotsToKmph(Speed) or self.speedMax*0.7
|
||||
|
||||
return self
|
||||
end
|
||||
@ -264,7 +264,7 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
||||
|
||||
-- Info text.
|
||||
local text=string.format("%s: Wp=%d/%d-->%d Speed=%.1f (%d) Heading=%03d ROE=%d Alarm=%d Formation=%s Tasks=%d Missions=%d",
|
||||
fsmstate, self.currentwp, #self.waypoints, self:GetWaypointIndexNext(), speed, UTILS.MpsToKnots(self.speed or 0), hdg, self.option.ROE, self.option.Alarm, self.option.Formation, nTaskTot, nMissions)
|
||||
fsmstate, self.currentwp, #self.waypoints, self:GetWaypointIndexNext(), speed, UTILS.MpsToKnots(self.speedWp or 0), hdg, self.option.ROE, self.option.Alarm, self.option.Formation, nTaskTot, nMissions)
|
||||
self:I(self.lid..text)
|
||||
|
||||
else
|
||||
@ -411,7 +411,7 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
|
||||
self.option.Formation=wp.action
|
||||
|
||||
-- Current set speed in m/s.
|
||||
self.speed=wp.speed
|
||||
self.speedWp=wp.speed
|
||||
|
||||
else
|
||||
|
||||
@ -457,14 +457,14 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
|
||||
|
||||
|
||||
-- Current waypoint.
|
||||
local current=self:GetCoordinate():WaypointGround(UTILS.MpsToKmph(self.speed), self.option.Formation)
|
||||
local current=self:GetCoordinate():WaypointGround(UTILS.MpsToKmph(self.speedWp), self.option.Formation)
|
||||
table.insert(waypoints, 1, current)
|
||||
table.insert(waypoints, 1, current) -- Seems to be better to add this twice. Otherwise, the passing waypoint functions is triggered to early!
|
||||
|
||||
if #waypoints>2 then
|
||||
|
||||
self:I(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Formation=%s",
|
||||
self.currentwp, n, #self.waypoints, #waypoints-2, UTILS.MpsToKnots(self.speed), tostring(self.option.Formation)))
|
||||
self.currentwp, n, #self.waypoints, #waypoints-2, UTILS.MpsToKnots(self.speedWp), tostring(self.option.Formation)))
|
||||
|
||||
-- Route group to all defined waypoints remaining.
|
||||
self:Route(waypoints)
|
||||
@ -595,6 +595,11 @@ function ARMYGROUP:onafterStop(From, Event, To)
|
||||
self:UnHandleEvent(EVENTS.Dead)
|
||||
self:UnHandleEvent(EVENTS.RemoveUnit)
|
||||
|
||||
-- Stop check timers.
|
||||
self.timerCheckZone:Stop()
|
||||
self.timerQueueUpdate:Stop()
|
||||
|
||||
-- Stop FSM scheduler.
|
||||
self.CallScheduler:Clear()
|
||||
|
||||
self:I(self.lid.."STOPPED! Unhandled events, cleared scheduler and removed from database.")
|
||||
@ -780,10 +785,10 @@ function ARMYGROUP:_InitGroup()
|
||||
self.isUncontrolled=false
|
||||
|
||||
-- Max speed in km/h.
|
||||
self.speedmax=self.group:GetSpeedMax()
|
||||
self.speedMax=self.group:GetSpeedMax()
|
||||
|
||||
-- Cruise speed in km/h
|
||||
self.speedCruise=self.speedmax*0.7
|
||||
self.speedCruise=self.speedMax*0.7
|
||||
|
||||
-- Group ammo.
|
||||
self.ammo=self:GetAmmoTot()
|
||||
@ -833,7 +838,7 @@ function ARMYGROUP:_InitGroup()
|
||||
-- Debug info.
|
||||
local text=string.format("Initialized Army Group %s:\n", self.groupname)
|
||||
text=text..string.format("Unit type = %s\n", self.actype)
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedMax))
|
||||
text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
|
||||
text=text..string.format("Elements = %d\n", #self.elements)
|
||||
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
||||
|
||||
@ -123,7 +123,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The AUFTRAG Concept
|
||||
--
|
||||
@ -190,9 +190,9 @@
|
||||
--
|
||||
-- An orbit mission can be created with the @{#AUFTRAG.NewORBIT}() function.
|
||||
--
|
||||
-- ## GCCAP
|
||||
-- ## GCICAP
|
||||
--
|
||||
-- An patrol mission can be created with the @{#AUFTRAG.NewGCCAP}() function.
|
||||
-- An patrol mission can be created with the @{#AUFTRAG.NewGCICAP}() function.
|
||||
--
|
||||
-- ## RECON
|
||||
--
|
||||
@ -296,7 +296,7 @@ _AUFTRAGSNR=0
|
||||
-- @field #string FERRY Ferry flight mission.
|
||||
-- @field #string INTERCEPT Intercept mission.
|
||||
-- @field #string ORBIT Orbit mission.
|
||||
-- @field #string GCCAP Similar to CAP but no auto engage targets.
|
||||
-- @field #string GCICAP Similar to CAP but no auto engage targets.
|
||||
-- @field #string RECON Recon mission.
|
||||
-- @field #string RECOVERYTANKER Recovery tanker mission. Not implemented yet.
|
||||
-- @field #string RESCUEHELO Rescue helo.
|
||||
@ -319,7 +319,7 @@ AUFTRAG.Type={
|
||||
FERRY="Ferry Flight",
|
||||
INTERCEPT="Intercept",
|
||||
ORBIT="Orbit",
|
||||
GCCAP="Ground Controlled CAP",
|
||||
GCICAP="Ground Controlled CAP",
|
||||
RECON="Recon",
|
||||
RECOVERYTANKER="Recovery Tanker",
|
||||
RESCUEHELO="Rescue Helo",
|
||||
@ -641,7 +641,7 @@ function AUFTRAG:NewORBIT_RACETRACK(Coordinate, Altitude, Speed, Heading, Leg)
|
||||
return mission
|
||||
end
|
||||
|
||||
--- Create a Ground Controlled CAP (GCCAP) mission. Flights with this task are considered for A2A INTERCEPT missions by the CHIEF class. They will perform a compat air patrol but not engage by
|
||||
--- Create a Ground Controlled CAP (GCICAP) mission. Flights with this task are considered for A2A INTERCEPT missions by the CHIEF class. They will perform a compat air patrol but not engage by
|
||||
-- themselfs. They wait for the CHIEF to tell them whom to engage.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE Coordinate Where to orbit.
|
||||
@ -650,13 +650,13 @@ end
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default random in [0, 360) degrees.
|
||||
-- @param #number Leg Length of race-track in NM. Default 10 NM.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewGCCAP(Coordinate, Altitude, Speed, Heading, Leg)
|
||||
function AUFTRAG:NewGCICAP(Coordinate, Altitude, Speed, Heading, Leg)
|
||||
|
||||
-- Create ORBIT first.
|
||||
local mission=AUFTRAG:NewORBIT_RACETRACK(Coordinate, Altitude, Speed, Heading, Leg)
|
||||
|
||||
-- Mission type GCCAP.
|
||||
mission.type=AUFTRAG.Type.GCCAP
|
||||
-- Mission type GCICAP.
|
||||
mission.type=AUFTRAG.Type.GCICAP
|
||||
|
||||
mission:_SetLogID()
|
||||
|
||||
@ -1341,8 +1341,8 @@ function AUFTRAG:NewAUTO(EngageGroup)
|
||||
mission=AUFTRAG:NewFACA(Target,Designation,DataLink,Frequency,Modulation)
|
||||
elseif auftrag==AUFTRAG.Type.FERRY then
|
||||
-- Not implemented yet.
|
||||
elseif auftrag==AUFTRAG.Type.GCCAP then
|
||||
mission=AUFTRAG:NewGCCAP(Coordinate,Altitude,Speed,Heading,Leg)
|
||||
elseif auftrag==AUFTRAG.Type.GCICAP then
|
||||
mission=AUFTRAG:NewGCICAP(Coordinate,Altitude,Speed,Heading,Leg)
|
||||
elseif auftrag==AUFTRAG.Type.INTERCEPT then
|
||||
mission=AUFTRAG:NewINTERCEPT(Target)
|
||||
elseif auftrag==AUFTRAG.Type.ORBIT then
|
||||
@ -3030,7 +3030,7 @@ function AUFTRAG:GetAssetByName(Name)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Count alive flight groups assigned for this mission.
|
||||
--- Count alive ops groups assigned for this mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #number Number of alive flight groups.
|
||||
function AUFTRAG:CountOpsGroups()
|
||||
@ -3262,10 +3262,10 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
||||
|
||||
-- Done below as also other mission types use the orbit task.
|
||||
|
||||
elseif self.type==AUFTRAG.Type.GCCAP then
|
||||
elseif self.type==AUFTRAG.Type.GCICAP then
|
||||
|
||||
--------------------
|
||||
-- GCCAP Mission --
|
||||
-- GCICAP Mission --
|
||||
--------------------
|
||||
|
||||
-- Done below as also other mission types use the orbit task.
|
||||
@ -3369,7 +3369,7 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
||||
if self.type==AUFTRAG.Type.ORBIT or
|
||||
self.type==AUFTRAG.Type.CAP or
|
||||
self.type==AUFTRAG.Type.CAS or
|
||||
self.type==AUFTRAG.Type.GCCAP or
|
||||
self.type==AUFTRAG.Type.GCICAP or
|
||||
self.type==AUFTRAG.Type.AWACS or
|
||||
self.type==AUFTRAG.Type.TANKER then
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The FLIGHTGROUP Concept
|
||||
--
|
||||
@ -116,7 +116,7 @@ FLIGHTGROUP = {
|
||||
homezone = nil,
|
||||
destzone = nil,
|
||||
actype = nil,
|
||||
speedmax = nil,
|
||||
speedMax = nil,
|
||||
rangemax = nil,
|
||||
ceiling = nil,
|
||||
fuellow = false,
|
||||
@ -2406,7 +2406,7 @@ function FLIGHTGROUP:onafterFuelCritical(From, Event, To)
|
||||
end
|
||||
end
|
||||
|
||||
--- On after Start event. Starts the FLIGHTGROUP FSM and event handlers.
|
||||
--- On after "Stop" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
@ -2439,11 +2439,14 @@ function FLIGHTGROUP:onafterStop(From, Event, To)
|
||||
self:UnHandleEvent(EVENTS.Crash)
|
||||
self:UnHandleEvent(EVENTS.RemoveUnit)
|
||||
|
||||
-- Stop check timers.
|
||||
self.timerCheckZone:Stop()
|
||||
self.timerQueueUpdate:Stop()
|
||||
|
||||
-- Stop FSM scheduler.
|
||||
self.CallScheduler:Clear()
|
||||
|
||||
-- Remove flight from data base.
|
||||
_DATABASE.FLIGHTGROUPS[self.groupname]=nil
|
||||
|
||||
self:I(self.lid.."STOPPED! Unhandled events, cleared scheduler and removed from database.")
|
||||
@ -2530,13 +2533,13 @@ function FLIGHTGROUP:_InitGroup()
|
||||
self.isLateActivated=self.template.lateActivation
|
||||
|
||||
-- Max speed in km/h.
|
||||
self.speedmax=group:GetSpeedMax()
|
||||
self.speedMax=group:GetSpeedMax()
|
||||
|
||||
-- Cruise speed limit 350 kts for fixed and 80 knots for rotary wings.
|
||||
local speedCruiseLimit=self.ishelo and UTILS.KnotsToKmph(80) or UTILS.KnotsToKmph(350)
|
||||
|
||||
-- Cruise speed: 70% of max speed but within limit.
|
||||
self.speedCruise=math.min(self.speedmax*0.7, speedCruiseLimit)
|
||||
self.speedCruise=math.min(self.speedMax*0.7, speedCruiseLimit)
|
||||
|
||||
-- Group ammo.
|
||||
self.ammo=self:GetAmmoTot()
|
||||
@ -2602,7 +2605,7 @@ function FLIGHTGROUP:_InitGroup()
|
||||
if self.verbose>=1 then
|
||||
local text=string.format("Initialized Flight Group %s:\n", self.groupname)
|
||||
text=text..string.format("Unit type = %s\n", self.actype)
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedMax))
|
||||
text=text..string.format("Range max = %.1f km\n", self.rangemax/1000)
|
||||
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))
|
||||
text=text..string.format("Tanker type = %s\n", tostring(self.tankertype))
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The NAVYGROUP Concept
|
||||
--
|
||||
@ -462,7 +462,7 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
||||
local turning=tostring(self:IsTurning())
|
||||
local alt=self.position.y
|
||||
local speed=UTILS.MpsToKnots(self.velocity)
|
||||
local speedExpected=UTILS.MpsToKnots(self.speed or 0)
|
||||
local speedExpected=UTILS.MpsToKnots(self.speedWp or 0)
|
||||
|
||||
local wpidxCurr=self.currentwp
|
||||
local wpuidCurr=0
|
||||
@ -628,7 +628,7 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
||||
end
|
||||
|
||||
-- Current set speed in m/s.
|
||||
self.speed=wp.speed
|
||||
self.speedWp=wp.speed
|
||||
|
||||
-- Current set depth.
|
||||
depth=wp.alt
|
||||
@ -649,14 +649,14 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
||||
end
|
||||
|
||||
-- Current waypoint.
|
||||
local current=self:GetCoordinate():WaypointNaval(UTILS.MpsToKmph(self.speed), depth)
|
||||
local current=self:GetCoordinate():WaypointNaval(UTILS.MpsToKmph(self.speedWp), depth)
|
||||
table.insert(waypoints, 1, current)
|
||||
|
||||
|
||||
if #waypoints>1 then
|
||||
|
||||
self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m",
|
||||
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speed), depth))
|
||||
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speedWp), depth))
|
||||
|
||||
|
||||
-- Route group to all defined waypoints remaining.
|
||||
@ -935,6 +935,11 @@ function NAVYGROUP:onafterStop(From, Event, To)
|
||||
self:UnHandleEvent(EVENTS.Dead)
|
||||
self:UnHandleEvent(EVENTS.RemoveUnit)
|
||||
|
||||
-- Stop check timers.
|
||||
self.timerCheckZone:Stop()
|
||||
self.timerQueueUpdate:Stop()
|
||||
|
||||
-- Stop FSM scheduler.
|
||||
self.CallScheduler:Clear()
|
||||
|
||||
self:I(self.lid.."STOPPED! Unhandled events, cleared scheduler and removed from database.")
|
||||
@ -1117,10 +1122,10 @@ function NAVYGROUP:_InitGroup()
|
||||
self.isUncontrolled=false
|
||||
|
||||
-- Max speed in km/h.
|
||||
self.speedmax=self.group:GetSpeedMax()
|
||||
self.speedMax=self.group:GetSpeedMax()
|
||||
|
||||
-- Cruise speed: 70% of max speed.
|
||||
self.speedCruise=self.speedmax*0.7
|
||||
self.speedCruise=self.speedMax*0.7
|
||||
|
||||
-- Group ammo.
|
||||
self.ammo=self:GetAmmoTot()
|
||||
@ -1170,7 +1175,7 @@ function NAVYGROUP:_InitGroup()
|
||||
-- Debug info.
|
||||
local text=string.format("Initialized Navy Group %s:\n", self.groupname)
|
||||
text=text..string.format("Unit type = %s\n", self.actype)
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedMax))
|
||||
text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
|
||||
text=text..string.format("Elements = %d\n", #self.elements)
|
||||
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
||||
|
||||
@ -38,8 +38,9 @@
|
||||
-- @field #number currentmission The ID (auftragsnummer) of the currently assigned AUFTRAG.
|
||||
-- @field Core.Set#SET_UNIT detectedunits Set of detected units.
|
||||
-- @field #string attribute Generalized attribute.
|
||||
-- @field #number speedmax Max speed in km/h.
|
||||
-- @field #number speedMax Max speed in km/h.
|
||||
-- @field #number speedCruise Cruising speed in km/h.
|
||||
-- @field #number speedWp Speed to the next waypoint in km/h.
|
||||
-- @field #boolean passedfinalwp Group has passed the final waypoint.
|
||||
-- @field #number wpcounter Running number counting waypoints.
|
||||
-- @field #boolean respawning Group is being respawned.
|
||||
@ -81,7 +82,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The OPSGROUP Concept
|
||||
--
|
||||
@ -427,7 +428,7 @@ end
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #number Cruise speed (>0) in knots.
|
||||
function OPSGROUP:GetSpeedCruise()
|
||||
return UTILS.KmphToKnots(self.speedCruise or self.speedmax*0.7)
|
||||
return UTILS.KmphToKnots(self.speedCruise or self.speedMax*0.7)
|
||||
end
|
||||
|
||||
--- Set detection on or off.
|
||||
@ -482,13 +483,81 @@ function OPSGROUP:GetName()
|
||||
return self.groupname
|
||||
end
|
||||
|
||||
--- Get DCS GROUP object.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return DCS#Group DCS group object.
|
||||
function OPSGROUP:GetDCSGroup()
|
||||
local DCSGroup=Group.getByName(self.groupname)
|
||||
return DCSGroup
|
||||
end
|
||||
|
||||
--- Get DCS GROUP object.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return DCS#Group DCS group object.
|
||||
function OPSGROUP:GetUnit(UnitNumber)
|
||||
local DCSGroup=Group.getByName(self.groupname)
|
||||
return DCSGroup
|
||||
end
|
||||
|
||||
--- Get DCS GROUP object.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number UnitNumber Number of the unit in the group. Default first unit.
|
||||
-- @return DCS#Unit DCS group object.
|
||||
function OPSGROUP:GetDCSUnit(UnitNumber)
|
||||
|
||||
local DCSGroup=self:GetDCSGroup()
|
||||
|
||||
if DCSGroup then
|
||||
local unit=DCSGroup:getUnit(UnitNumber or 1)
|
||||
return unit
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Despawn group.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:DespawnGroup()
|
||||
|
||||
local DCSGroup=self:GetDCSGroup()
|
||||
|
||||
if DCSGroup then
|
||||
DCSGroup:destroy()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Despawn a unit.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:DespawnUnit(UnitName)
|
||||
|
||||
local DCSGroup=self:GetDCSGroup()
|
||||
|
||||
if DCSGroup then
|
||||
DCSGroup:destroy()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Get current 3D vector of the group.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return DCS#Vec3 Vector with x,y,z components.
|
||||
function OPSGROUP:GetVec3()
|
||||
if self:IsAlive()~=nil then
|
||||
local vec3=self.group:GetVec3()
|
||||
return vec3
|
||||
if self:IsExist() then
|
||||
|
||||
local unit=self:GetDCSUnit()
|
||||
|
||||
if unit then
|
||||
local vec3=unit:getPoint()
|
||||
|
||||
return vec3
|
||||
end
|
||||
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@ -520,11 +589,21 @@ end
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #number Velocity in m/s.
|
||||
function OPSGROUP:GetVelocity()
|
||||
if self:IsAlive()~=nil then
|
||||
local vel=self.group:GetVelocityMPS()
|
||||
return vel
|
||||
if self:IsExist() then
|
||||
|
||||
local unit=self:GetDCSUnit(1)
|
||||
|
||||
if unit then
|
||||
|
||||
local velvec3=unit:getVelocity()
|
||||
|
||||
local vel=UTILS.VecNorm(velvec3)
|
||||
|
||||
return vel
|
||||
|
||||
end
|
||||
else
|
||||
self:E(self.lid.."WARNING: Group is not alive. Cannot get velocity!")
|
||||
self:E(self.lid.."WARNING: Group does not exist. Cannot get velocity!")
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@ -533,12 +612,30 @@ end
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #number Current heading of the group in degrees.
|
||||
function OPSGROUP:GetHeading()
|
||||
if self:IsAlive()~=nil then
|
||||
local heading=self.group:GetHeading()
|
||||
return heading
|
||||
|
||||
if self:IsExist() then
|
||||
|
||||
local unit=self:GetDCSUnit()
|
||||
|
||||
if unit then
|
||||
|
||||
local pos=unit:getPosition()
|
||||
|
||||
local heading=math.atan2(pos.x.z, pos.x.x)
|
||||
|
||||
if heading<0 then
|
||||
heading=heading+ 2*math.pi
|
||||
end
|
||||
|
||||
heading=math.deg(heading)
|
||||
|
||||
return heading
|
||||
end
|
||||
|
||||
else
|
||||
self:E(self.lid.."WARNING: Group is not alive. Cannot get heading!")
|
||||
self:E(self.lid.."WARNING: Group does not exist. Cannot get heading!")
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -615,6 +712,29 @@ function OPSGROUP:SelfDestruction(Delay, ExplosionPower)
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Check if group is exists.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean If true, the group exists or false if the group does not exist. If nil, the DCS group could not be found.
|
||||
function OPSGROUP:IsExist()
|
||||
|
||||
local DCSGroup=self:GetDCSGroup()
|
||||
|
||||
if DCSGroup then
|
||||
local exists=DCSGroup:isExist()
|
||||
return exists
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Check if group is activated.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean If true, the group exists or false if the group does not exist. If nil, the DCS group could not be found.
|
||||
function OPSGROUP:IsActive()
|
||||
|
||||
end
|
||||
|
||||
--- Check if group is alive.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean *true* if group is exists and is activated, *false* if group is exist but is NOT activated. *nil* otherwise, e.g. the GROUP object is *nil* or the group is not spawned yet.
|
||||
@ -1001,7 +1121,7 @@ function OPSGROUP:GetExpectedSpeed()
|
||||
if self:IsHolding() then
|
||||
return 0
|
||||
else
|
||||
return self.speed or 0
|
||||
return self.speedWp or 0
|
||||
end
|
||||
|
||||
end
|
||||
@ -2804,7 +2924,7 @@ function OPSGROUP:InitWaypoints()
|
||||
local speedknots=UTILS.MpsToKnots(wp.speed)
|
||||
|
||||
if index==1 then
|
||||
self.speed=wp.speed
|
||||
self.speedWp=wp.speed
|
||||
end
|
||||
|
||||
self:AddWaypoint(coordinate, speedknots, index-1, nil, false)
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The SQUADRON Concept
|
||||
--
|
||||
@ -838,12 +838,12 @@ function SQUADRON:RecruitAssets(Mission, Npayloads)
|
||||
-- Asset is already on a mission.
|
||||
---
|
||||
|
||||
-- Check if this asset is currently on a GCCAP mission (STARTED or EXECUTING).
|
||||
if self.airwing:IsAssetOnMission(asset, AUFTRAG.Type.GCCAP) and Mission.type==AUFTRAG.Type.INTERCEPT then
|
||||
-- Check if this asset is currently on a GCICAP mission (STARTED or EXECUTING).
|
||||
if self.airwing:IsAssetOnMission(asset, AUFTRAG.Type.GCICAP) and Mission.type==AUFTRAG.Type.INTERCEPT then
|
||||
|
||||
-- Check if the payload of this asset is compatible with the mission.
|
||||
-- Note: we do not check the payload as an asset that is on a GCCAP mission should be able to do an INTERCEPT as well!
|
||||
self:I(self.lid.."Adding asset on GCCAP mission for an INTERCEPT mission")
|
||||
-- Note: we do not check the payload as an asset that is on a GCICAP mission should be able to do an INTERCEPT as well!
|
||||
self:I(self.lid.."Adding asset on GCICAP mission for an INTERCEPT mission")
|
||||
table.insert(assets, asset)
|
||||
|
||||
end
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
-- 
|
||||
--
|
||||
-- # The TARGET Concept
|
||||
--
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user