This commit is contained in:
Frank
2020-04-30 01:42:38 +02:00
parent c8d2104c39
commit 422e111857
10 changed files with 224 additions and 143 deletions
@@ -6133,10 +6133,11 @@ function WAREHOUSE:_OnEventBirth(EventData)
end end
else else
--self:T3({wid=wid, uid=self.uid, match=(wid==self.uid), tw=type(wid), tu=type(self.uid)}) -- No request?!
self:E(self.lid..string.format("ERROR: Could not get request when asset spawned! FF investigate! Unit name=%s asset spawed=%s", EventData.IniUnitName, tostring(asset.spawned)))
end end
else else
self:E(self.lid..string.format("ERROR: Could not get request when asset spawned! FF investigate!")) -- Born unit does not belong to this warehouse.
end end
end end
+39 -33
View File
@@ -44,7 +44,7 @@
-- --
-- === -- ===
-- --
-- ![Banner Image](..\Presentations\CarrierAirWing\AIRWING_Main.jpg) -- ![Banner Image](..\Presentations\AirWing\AIRWING_Main.jpg)
-- --
-- # The AIRWING Concept -- # The AIRWING Concept
-- --
@@ -93,7 +93,7 @@ AIRWING = {
--- AIRWING class version. --- AIRWING class version.
-- @field #string version -- @field #string version
AIRWING.version="0.1.7" AIRWING.version="0.2.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ToDo list -- ToDo list
@@ -322,15 +322,20 @@ end
-- @return #AIRWING.Payload Payload table or *nil*. -- @return #AIRWING.Payload Payload table or *nil*.
function AIRWING:FetchPayloadFromStock(UnitType, MissionType) function AIRWING:FetchPayloadFromStock(UnitType, MissionType)
-- Quick check if we have any payloads.
if not self.payloads or #self.payloads==0 then if not self.payloads or #self.payloads==0 then
self:I(self.lid.."WARNING: No payloads in stock!") self:I(self.lid.."WARNING: No payloads in stock!")
return nil return nil
end end
self:I(self.lid..string.format("Looking for payload for unit type=%s and mission type=%s", UnitType, MissionType)) -- Debug.
for i,_payload in pairs(self.payloads) do if self.Debug then
local payload=_payload --#AIRWING.Payload self:I(self.lid..string.format("Looking for payload for unit type=%s and mission type=%s", UnitType, MissionType))
self:I(self.lid..string.format("[%d] Payload type=%s navail=%d unlimited=%s", i, payload.aircrafttype, payload.navail, tostring(payload.unlimited))) for i,_payload in pairs(self.payloads) do
local payload=_payload --#AIRWING.Payload
local performance=self:GetPayloadPeformance(payload, MissionType)
self:I(self.lid..string.format("[%d] Payload type=%s navail=%d unlimited=%s", i, payload.aircrafttype, payload.navail, tostring(payload.unlimited)))
end
end end
--- Sort payload wrt the following criteria: --- Sort payload wrt the following criteria:
@@ -340,56 +345,57 @@ function AIRWING:FetchPayloadFromStock(UnitType, MissionType)
local function sortpayloads(a,b) local function sortpayloads(a,b)
local pA=a --#AIRWING.Payload local pA=a --#AIRWING.Payload
local pB=b --#AIRWING.Payload local pB=b --#AIRWING.Payload
if a and b then --TODO: Strangely, I had the case that a or b were nil even though the self.payloads table was looking okay. Very strange! if a and b then -- I had the case that a or b were nil even though the self.payloads table was looking okay. Very strange! Seems to be solved by pre-selecting valid payloads.
local performanceA=self:GetPayloadPeformance(a, MissionType) local performanceA=self:GetPayloadPeformance(a, MissionType)
local performanceB=self:GetPayloadPeformance(b, MissionType) local performanceB=self:GetPayloadPeformance(b, MissionType)
return (performanceA>performanceB) or (performanceA==performanceB and a.unlimited==true) or (performanceA==performanceB and a.unlimited==true and b.unlimited==true and a.navail>b.navail) return (performanceA>performanceB) or (performanceA==performanceB and a.unlimited==true) or (performanceA==performanceB and a.unlimited==true and b.unlimited==true and a.navail>b.navail)
elseif not a then elseif not a then
env.info("FF ERROR in sortpayloads: a is nil") self:I(self.lid..string.format("FF ERROR in sortpayloads: a is nil"))
return false return false
elseif not b then elseif not b then
env.info("FF ERROR in sortpayloads: b is nil") self:I(self.lid..string.format("FF ERROR in sortpayloads: b is nil"))
return true return true
else else
env.info("FF ERROR in sortpayloads: a and b are nil") self:I(self.lid..string.format("FF ERROR in sortpayloads: a and b are nil"))
return false return false
end end
end end
table.sort(self.payloads, sortpayloads)
-- Pre-selection: filter out only those payloads that are valid for the airframe and mission type and are available.
local payloads={}
for _,_payload in pairs(self.payloads) do
local payload=_payload --#AIRWING.Payload
if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) and payload.navail>0 then
table.insert(payloads, payload)
end
end
-- Debug.
if self.Debug then if self.Debug then
env.info("FF Sorted payloads for mission type X and aircraft type=Y:") self:I(self.lid..string.format("FF Sorted payloads for mission type X and aircraft type=Y:"))
for _,_payload in ipairs(self.payloads) do for _,_payload in ipairs(self.payloads) do
local payload=_payload --#AIRWING.Payload local payload=_payload --#AIRWING.Payload
if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) then if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) then
local performace=self:GetPayloadPeformance(payload, MissionType) local performace=self:GetPayloadPeformance(payload, MissionType)
self:I(string.format("FF %s payload for %s: avail=%d performace=%d", MissionType, payload.aircrafttype, payload.navail, performace)) self:I(self.lid..string.format("FF %s payload for %s: avail=%d performace=%d", MissionType, payload.aircrafttype, payload.navail, performace))
end end
end end
end end
for _,_payload in ipairs(self.payloads) do -- Cases:
local payload=_payload --#AIRWING.Payload if #payloads==0 then
-- No payload available.
self:T(self.lid.."Warning could not find a payload for airframe X mission type Y!")
-- Check right type, mission and available. return nil
if payload.aircrafttype==UnitType and payload.navail>0 and self:CheckMissionCapability(MissionType, payload.capabilities) then elseif #payloads==1 then
-- Only one payload anyway.
-- Consume if not unlimited. return payloads[1]
if not payload.unlimited then else
payload.navail=payload.navail-1 -- Sort payloads.
end table.sort(payloads, sortpayloads)
return payloads[1]
self:T(string.format("FETCHING %s payload for %s: avail=%d performance=%d", MissionType, payload.aircrafttype, payload.navail, self:GetPayloadPeformance(payload, MissionType)))
-- Return a copy of the table.
return payload
end
end end
self:T(self.lid.."Warning could not find a payload for airframe X mission type Y!")
return nil
end end
--- Return payload from asset back to stock. --- Return payload from asset back to stock.
+29 -26
View File
@@ -326,7 +326,7 @@ AUFTRAG.TargetType={
--- AUFTRAG class version. --- AUFTRAG class version.
-- @field #string version -- @field #string version
AUFTRAG.version="0.2.1" AUFTRAG.version="0.2.3"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@@ -348,8 +348,8 @@ AUFTRAG.version="0.2.1"
-- DONE: Evaluate mission result ==> SUCCESS/FAILURE -- DONE: Evaluate mission result ==> SUCCESS/FAILURE
-- DONE: NewAUTO() NewA2G NewA2A -- DONE: NewAUTO() NewA2G NewA2A
-- DONE: Transport mission. -- DONE: Transport mission.
-- TODO: Recon mission. -- TODO: Recon mission. What input? Set of coordinates?
-- TODO: Set mission coalition, e.g. for F10 markers. -- TODO: Set mission coalition, e.g. for F10 markers. Could be derived from target if target has a coalition.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Constructor -- Constructor
@@ -429,27 +429,6 @@ end
-- Create Missions -- Create Missions
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Create a RESCUE HELO mission.
-- @param #AUFTRAG self
-- @param Wrapper.Unit#UNIT Carrier The carrier unit.
-- @return #AUFTRAG self
function AUFTRAG:NewRESCUEHELO(Carrier)
local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO)
mission:_TargetFromObject(Carrier)
-- Mission options:
mission.missionTask=ENUMS.MissionTask.NOTHING
mission.missionFraction=0.5
mission.optionROE=ENUMS.ROE.WeaponHold
mission.optionROT=ENUMS.ROT.NoReaction
mission.DCStask=mission:GetDCSMissionTask()
return mission
end
--- Create an ANTI-SHIP mission. --- Create an ANTI-SHIP mission.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Wrapper.Positionable#POSITIONABLE Target The target to attack. Can be passed as a @{Wrapper.Group#GROUP} or @{Wrapper.Unit#UNIT} object. -- @param Wrapper.Positionable#POSITIONABLE Target The target to attack. Can be passed as a @{Wrapper.Group#GROUP} or @{Wrapper.Unit#UNIT} object.
@@ -478,7 +457,7 @@ function AUFTRAG:NewANTISHIP(Target, Altitude)
return mission return mission
end end
--- Create an ORBIT mission. --- Create an ORBIT mission, which can be either a circular orbit or a race-track pattern.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Core.Point#COORDINATE Coordinate Where to orbit. -- @param Core.Point#COORDINATE Coordinate Where to orbit.
-- @param #number Altitude Orbit altitude in feet. Default is y component of `Coordinate`. -- @param #number Altitude Orbit altitude in feet. Default is y component of `Coordinate`.
@@ -504,8 +483,10 @@ function AUFTRAG:NewORBIT(Coordinate, Altitude, Speed, Heading, Leg)
if Heading and Leg then if Heading and Leg then
self.orbitHeading=Heading self.orbitHeading=Heading
self.orbitLeg=Leg self.orbitLeg=UTILS.NMToMeters(Leg)
self.orbitRaceTrack=Coordinate:Translate(self.orbitLeg, self.orbitHeading, true) self.orbitRaceTrack=Coordinate:Translate(self.orbitLeg, self.orbitHeading, true)
Coordinate:MarkToAll("Orbit RT 1 ")
self.orbitRaceTrack:MarkToAll("Orbit RT 2")
end end
@@ -992,6 +973,28 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT
return mission return mission
end end
--- Create a RESCUE HELO mission.
-- @param #AUFTRAG self
-- @param Wrapper.Unit#UNIT Carrier The carrier unit.
-- @return #AUFTRAG self
function AUFTRAG:NewRESCUEHELO(Carrier)
local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO)
mission:_TargetFromObject(Carrier)
-- Mission options:
mission.missionTask=ENUMS.MissionTask.NOTHING
mission.missionFraction=0.5
mission.optionROE=ENUMS.ROE.WeaponHold
mission.optionROT=ENUMS.ROT.NoReaction
mission.DCStask=mission:GetDCSMissionTask()
return mission
end
--- Create a TROOP TRANSPORT mission. --- Create a TROOP TRANSPORT mission.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Core.Set#SET_GROUP TransportGroupSet The set group(s) to be transported. -- @param Core.Set#SET_GROUP TransportGroupSet The set group(s) to be transported.
+70 -65
View File
@@ -104,7 +104,7 @@
-- --
-- === -- ===
-- --
-- ![Banner Image](..\Presentations\CarrierAirWing\FLIGHTGROUP_Main.jpg) -- ![Banner Image](..\Presentations\FlightGroup\FLIGHTGROUP_Main.jpg)
-- --
-- # The FLIGHTGROUP Concept -- # The FLIGHTGROUP Concept
-- --
@@ -374,7 +374,7 @@ FLIGHTGROUP.ROT={
--- FLIGHTGROUP class version. --- FLIGHTGROUP class version.
-- @field #string version -- @field #string version
FLIGHTGROUP.version="0.3.9" FLIGHTGROUP.version="0.4.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@@ -683,8 +683,8 @@ function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, dur
self:T3({newtask=newtask}) self:T3({newtask=newtask})
-- Update route. -- Update route.
self:_CheckFlightDone(1) --self:_CheckFlightDone(1)
--self:__UpdateRoute(-1) self:__UpdateRoute(-1)
return newtask return newtask
end end
@@ -1157,16 +1157,23 @@ end
-- @return #FLIGHTGROUP self -- @return #FLIGHTGROUP self
function FLIGHTGROUP:Activate(delay) function FLIGHTGROUP:Activate(delay)
if self:IsAlive()==false then if delay and delay>0 then
if delay then
self:T2(self.lid..string.format("Activating late activated group in %d seconds", delay)) self:T2(self.lid..string.format("Activating late activated group in %d seconds", delay))
self:ScheduleOnce(delay, FLIGHTGROUP.Activate, self) self:ScheduleOnce(delay, FLIGHTGROUP.Activate, self)
else else
if self:IsAlive()==false then
self:T(self.lid.."Activating late activated group") self:T(self.lid.."Activating late activated group")
self.group:Activate() self.group:Activate()
self.isLateActivated=false
elseif self:IsAlive()==true then
self:E(self.lid.."WARNING: Activating group that is already activated")
else
self:E(self.lid.."ERROR: Activating group that is does not exist!")
end end
else
self:E(self.lid..string.format("ERROR: Cannot activate group as IsAlive()==%s", tostring(self:IsAlive())))
end end
return self return self
@@ -1178,19 +1185,26 @@ end
-- @return #FLIGHTGROUP self -- @return #FLIGHTGROUP self
function FLIGHTGROUP:StartUncontrolled(delay) function FLIGHTGROUP:StartUncontrolled(delay)
if self:IsAlive() then if delay and delay>0 then
--TODO: check Alive==true and Alive==false ==> Activate first self:T2(self.lid..string.format("Starting uncontrolled group in %d seconds", delay))
self:I(self.lid.."Starting uncontrolled group") self:ScheduleOnce(delay, FLIGHTGROUP.StartUncontrolled, self)
self.group:StartUncontrolled(delay)
else else
self:E(self.lid.."ERROR: Could not start uncontrolled group as it is NOT alive (yet)!")
self.group:StartUncontrolled(delay) if self:IsAlive() then
--TODO: check Alive==true and Alive==false ==> Activate first
self:I(self.lid.."Starting uncontrolled group")
self.group:StartUncontrolled(delay)
self.isUncontrolled=true
else
self:E(self.lid.."ERROR: Could not start uncontrolled group as it is NOT alive!")
end
end end
return self return self
end end
--- Set DCS task. --- Set DCS task. Enroute tasks are injected automatically.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @param #table DCSTask DCS task structure. -- @param #table DCSTask DCS task structure.
-- @return #FLIGHTGROUP self -- @return #FLIGHTGROUP self
@@ -1221,7 +1235,7 @@ function FLIGHTGROUP:SetTask(DCSTask)
end end
end end
-- Set task -- Set task.
self.group:SetTask(DCSTask) self.group:SetTask(DCSTask)
-- Debug info. -- Debug info.
@@ -1233,6 +1247,7 @@ function FLIGHTGROUP:SetTask(DCSTask)
end end
self:I(self.lid..text) self:I(self.lid..text)
end end
return self return self
end end
@@ -1241,8 +1256,13 @@ end
-- @param #table DCSTask DCS task structure. -- @param #table DCSTask DCS task structure.
-- @return #FLIGHTGROUP self -- @return #FLIGHTGROUP self
function FLIGHTGROUP:PushTask(DCSTask) function FLIGHTGROUP:PushTask(DCSTask)
if self:IsAlive() then if self:IsAlive() then
self.group:PushTask(DCSTask, 1)
-- Push task.
self.group:PushTask(DCSTask)
-- Debug info.
local text=string.format("PUSHING Task %s", tostring(DCSTask.id)) local text=string.format("PUSHING Task %s", tostring(DCSTask.id))
if tostring(DCSTask.id)=="ComboTask" then if tostring(DCSTask.id)=="ComboTask" then
for i,task in pairs(DCSTask.params.tasks) do for i,task in pairs(DCSTask.params.tasks) do
@@ -1251,6 +1271,7 @@ function FLIGHTGROUP:PushTask(DCSTask)
end end
self:I(self.lid..text) self:I(self.lid..text)
end end
return self return self
end end
@@ -2769,7 +2790,10 @@ function FLIGHTGROUP:_CheckFlightDone(delay)
end end
-- Number of tasks remaining.
local nTasks=self:CountRemainingTasks() local nTasks=self:CountRemainingTasks()
-- Number of mission remaining.
local nMissions=self:CountRemainingMissison() local nMissions=self:CountRemainingMissison()
-- Final waypoint passed? -- Final waypoint passed?
@@ -3227,7 +3251,7 @@ function FLIGHTGROUP:onafterHolding(From, Event, To)
end end
--- On after "Engage" event. Order to engage a set of units. --- On after "EngageTargets" event. Order to engage a set of units.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @param #string From From state. -- @param #string From From state.
-- @param #string Event Event. -- @param #string Event Event.
@@ -3249,8 +3273,7 @@ function FLIGHTGROUP:onafterEngageTargets(From, Event, To, TargetUnitSet)
--TODO needs a task function that calls EngageDone or so event and updates the route again. --TODO needs a task function that calls EngageDone or so event and updates the route again.
-- Lets try if pushtask actually leaves the remaining tasks untouched. -- Lets try if pushtask actually leaves the remaining tasks untouched.
-- TODO: the problem is if UpdateRoute is called because it would destroy this task! self:SetTask(DCSTask)
self:PushTask(DCSTask)
end end
@@ -3798,18 +3821,18 @@ end
function FLIGHTGROUP:onbeforeMissionStart(From, Event, To, Mission) function FLIGHTGROUP:onbeforeMissionStart(From, Event, To, Mission)
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled()))) self:I(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled())))
-- Delay for route to mission. Group needs to be activated and controlled. -- Delay for route to mission. Group needs to be activated and controlled.
local delay=0 local delay=1
-- Check if group is spawned. -- Check if group is spawned.
if self:IsInUtero() then if self:IsInUtero() then
-- Activate group if it is late activated. -- Activate group if it is late activated.
if self:IsLateActivated() then if self:IsLateActivated() then
self:Activate() self:Activate(delay)
delay=delay+2 delay=delay+1
end end
end end
@@ -3818,8 +3841,8 @@ function FLIGHTGROUP:onbeforeMissionStart(From, Event, To, Mission)
if self:IsParking() and self:IsUncontrolled() then if self:IsParking() and self:IsUncontrolled() then
self:StartUncontrolled(delay) self:StartUncontrolled(delay)
else else
env.info("FF hallo!") --env.info("FF hallo!")
self:StartUncontrolled(5) --self:StartUncontrolled(5)
end end
return true return true
@@ -3833,6 +3856,7 @@ end
-- @param Ops.Auftrag#AUFTRAG Mission The mission table. -- @param Ops.Auftrag#AUFTRAG Mission The mission table.
function FLIGHTGROUP:onafterMissionStart(From, Event, To, Mission) function FLIGHTGROUP:onafterMissionStart(From, Event, To, Mission)
-- Debug output.
local text=string.format("Starting %s Mission %s, target %s", Mission.type, tostring(Mission.name), Mission:GetTargetName()) local text=string.format("Starting %s Mission %s, target %s", Mission.type, tostring(Mission.name), Mission:GetTargetName())
self:T(self.lid..text) self:T(self.lid..text)
MESSAGE:New(text, 30, self.groupname):ToAllIf(true) MESSAGE:New(text, 30, self.groupname):ToAllIf(true)
@@ -3847,7 +3871,8 @@ function FLIGHTGROUP:onafterMissionStart(From, Event, To, Mission)
Mission:Started() Mission:Started()
-- Route flight to mission zone. -- Route flight to mission zone.
self:RouteToMission(Mission, 5) self:RouteToMission(Mission, 3)
end end
--- On after "MissionExecute" event. Mission execution began. --- On after "MissionExecute" event. Mission execution began.
@@ -4179,6 +4204,7 @@ end
-- @return #FLIGHTGROUP self -- @return #FLIGHTGROUP self
function FLIGHTGROUP:_InitGroup() function FLIGHTGROUP:_InitGroup()
-- First check if group was already initialized.
if self.groupinitialized then if self.groupinitialized then
self:E(self.lid.."WARNING: Group was already initialized!") self:E(self.lid.."WARNING: Group was already initialized!")
return return
@@ -4190,6 +4216,12 @@ function FLIGHTGROUP:_InitGroup()
-- Helo group. -- Helo group.
self.ishelo=self.group:IsHelicopter() self.ishelo=self.group:IsHelicopter()
-- Is (template) group uncontrolled.
self.isUncontrolled=self.template.uncontrolled
-- Is (template) group late activated.
self.isLateActivated=self.template.lateActivation
-- Max speed in km/h. -- Max speed in km/h.
self.speedmax=self.group:GetSpeedMax() self.speedmax=self.group:GetSpeedMax()
@@ -4201,7 +4233,7 @@ function FLIGHTGROUP:_InitGroup()
-- Initial fuel mass. -- Initial fuel mass.
-- TODO: this is a unit property! -- TODO: this is a unit property!
self.fuelmass=0 --self.template.pylons.fuel self.fuelmass=0
self.traveldist=0 self.traveldist=0
self.traveltime=timer.getAbsTime() self.traveltime=timer.getAbsTime()
@@ -4218,12 +4250,11 @@ function FLIGHTGROUP:_InitGroup()
self.radioModuDefault=self.radioModu self.radioModuDefault=self.radioModu
end end
-- Get first unit. This is used to extract other parameters.
local unit=self.group:GetUnit(1) local unit=self.group:GetUnit(1)
if unit then if unit then
--local nunits=self.group:GetUnits()
self.rangemax=unit:GetRange() self.rangemax=unit:GetRange()
self.descriptors=unit:GetDesc() self.descriptors=unit:GetDesc()
@@ -4254,7 +4285,7 @@ function FLIGHTGROUP:_InitGroup()
text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter())) text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter()))
text=text..string.format("Elements = %d\n", #self.elements) text=text..string.format("Elements = %d\n", #self.elements)
text=text..string.format("Waypoints = %d\n", #self.waypoints) text=text..string.format("Waypoints = %d\n", #self.waypoints)
text=text..string.format("Radio = %.1f%d %s\n", self.radioFreq, self.radioModu, tostring(self.radioOn)) text=text..string.format("Radio = %.1f MHz %s %s\n", self.radioFreq, UTILS.GetModulationName(self.radioModu), tostring(self.radioOn))
text=text..string.format("FSM state = %s\n", self:GetState()) text=text..string.format("FSM state = %s\n", self:GetState())
text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive())) text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive()))
text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated())) text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated()))
@@ -4597,44 +4628,18 @@ function FLIGHTGROUP:IsLandingAirbase(wp)
end end
--- Check if this group is "late activated" and needs to be "activated" to appear in the mission. --- Check if this group is currently "late activated" and needs to be "activated" to appear in the mission.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @return #boolean Hot start? -- @return #boolean Hot start?
function FLIGHTGROUP:IsLateActivated() function FLIGHTGROUP:IsLateActivated()
return self.isLateActivated
local template=_DATABASE:GetGroupTemplate(self.groupname)
if template then
if template.lateActivation==true then
return true
else
return false
end
end
return nil
end end
--- Check if this group is "uncontrolled" and needs to be "started" to begin its route. --- Check if this group is currently "uncontrolled" and needs to be "started" to begin its route.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @return #boolean Hot start? -- @return #boolean Hot start?
function FLIGHTGROUP:IsUncontrolled() function FLIGHTGROUP:IsUncontrolled()
return self.isUncontrolled
local template=_DATABASE:GetGroupTemplate(self.groupname)
if template then
if template.uncontrolled==true then
return true
else
return false
end
end
return nil
end end
--- Check if task description is unique. --- Check if task description is unique.
@@ -4808,7 +4813,7 @@ function FLIGHTGROUP:InitWaypoints(waypoints)
self.homebase=self:GetHomebaseFromWaypoints() self.homebase=self:GetHomebaseFromWaypoints()
self.destbase=self:GetDestinationFromWaypoints() self.destbase=self:GetDestinationFromWaypoints()
-- Remove the landing waypoint. We use RTB for that. -- Remove the landing waypoint. We use RTB for that. It makes adding new waypoints easier as we do not have to check if the last waypoint is the landing waypoint.
if self.destbase then if self.destbase then
table.remove(self.waypoints, #self.waypoints) table.remove(self.waypoints, #self.waypoints)
else else
@@ -4827,8 +4832,8 @@ function FLIGHTGROUP:InitWaypoints(waypoints)
end end
-- Update route (when airborne). -- Update route (when airborne).
self:_CheckFlightDone(1) --self:_CheckFlightDone(1)
--self:__UpdateRoute(-1) self:__UpdateRoute(-1)
end end
return self return self
+1 -2
View File
@@ -27,7 +27,7 @@
-- @field #number dTforget Time interval in seconds before a known contact which is not detected any more is forgotten. -- @field #number dTforget Time interval in seconds before a known contact which is not detected any more is forgotten.
-- @extends Core.Fsm#FSM -- @extends Core.Fsm#FSM
--- Be surprised! --- Top Secret!
-- --
-- === -- ===
-- --
@@ -172,7 +172,6 @@ function INTEL:New(DetectionSet, Coalition)
end end
self.Debug=true self.Debug=true
return self return self
end end
+1 -1
View File
@@ -48,7 +48,7 @@
-- --
-- === -- ===
-- --
-- ![Banner Image](..\Presentations\CarrierAirWing\SQUADRON_Main.jpg) -- ![Banner Image](..\Presentations\Squadron\SQUADRON_Main.jpg)
-- --
-- # The SQUADRON Concept -- # The SQUADRON Concept
-- --
@@ -28,7 +28,7 @@
-- --
-- === -- ===
-- --
-- ![Banner Image](..\Presentations\CarrierAirWing\WINGCOMMANDER_Main.jpg) -- ![Banner Image](..\Presentations\WingCommander\WINGCOMMANDER_Main.jpg)
-- --
-- # The WINGCOMMANDER Concept -- # The WINGCOMMANDER Concept
-- --
@@ -161,3 +161,57 @@ ENUMS.MissionTask={
SEAD="SEAD", SEAD="SEAD",
TRANSPORT="Transport", TRANSPORT="Transport",
} }
--- Formations (new). See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki.
-- @type ENUMS.Formation
ENUMS.Formation={}
ENUMS.Formation.FixedWing={}
ENUMS.Formation.FixedWing.LineAbreast={}
ENUMS.Formation.FixedWing.LineAbreast.Close = 65537
ENUMS.Formation.FixedWing.LineAbreast.Open = 65538
ENUMS.Formation.FixedWing.LineAbreast.Group = 65539
ENUMS.Formation.FixedWing.Trail={}
ENUMS.Formation.FixedWing.Trail.Close = 131073
ENUMS.Formation.FixedWing.Trail.Open = 131074
ENUMS.Formation.FixedWing.Trail.Group = 131075
ENUMS.Formation.RotaryWing={}
ENUMS.Formation.RotaryWing.Column={}
ENUMS.Formation.RotaryWing.Column.D70=720896
ENUMS.Formation.RotaryWing.Wedge={}
ENUMS.Formation.RotaryWing.Wedge.D70=8
ENUMS.Formation.RotaryWing.FrontRight={}
ENUMS.Formation.RotaryWing.FrontRight.D300=655361
ENUMS.Formation.RotaryWing.FrontRight.D600=655362
ENUMS.Formation.RotaryWing.FrontLeft={}
ENUMS.Formation.RotaryWing.FrontLeft.D300=655617
ENUMS.Formation.RotaryWing.FrontLeft.D600=655618
ENUMS.Formation.RotaryWing.EchelonRight={}
ENUMS.Formation.RotaryWing.EchelonRight.D70 =589825
ENUMS.Formation.RotaryWing.EchelonRight.D300=589826
ENUMS.Formation.RotaryWing.EchelonRight.D600=589827
ENUMS.Formation.RotaryWing.EchelonLeft={}
ENUMS.Formation.RotaryWing.EchelonLeft.D70 =590081
ENUMS.Formation.RotaryWing.EchelonLeft.D300=590082
ENUMS.Formation.RotaryWing.EchelonLeft.D600=590083
--- Formations (old). The old format is a simplified version of the new formation enums, which allow more sophisticated settings.
-- See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki.
-- @type ENUMS.FormationOld
ENUMS.FormationOld={}
ENUMS.FormationOld.FixedWing={}
ENUMS.FormationOld.FixedWing.LineAbreast=1
ENUMS.FormationOld.FixedWing.Trail=2
ENUMS.FormationOld.FixedWing.Wedge=3
ENUMS.FormationOld.FixedWing.EchelonRight=4
ENUMS.FormationOld.FixedWing.EchelonLeft=5
ENUMS.FormationOld.FixedWing.FingerFour=6
ENUMS.FormationOld.FixedWing.SpreadFour=7
ENUMS.FormationOld.FixedWing.BomberElement=12
ENUMS.FormationOld.FixedWing.BomberElementHeight=13
ENUMS.FormationOld.FixedWing.FighterVic=14
ENUMS.FormationOld={}
ENUMS.FormationOld.RotaryWing={}
ENUMS.FormationOld.RotaryWing.Wedge=8
ENUMS.FormationOld.RotaryWing.Echelon=9
ENUMS.FormationOld.RotaryWing.Front=10
ENUMS.FormationOld.RotaryWing.Column=11
+22 -9
View File
@@ -1,5 +1,4 @@
--- This module contains derived utilities taken from the MIST framework, --- This module contains derived utilities taken from the MIST framework, which are excellent tools to be reused in an OO environment.
-- which are excellent tools to be reused in an OO environment!.
-- --
-- ### Authors: -- ### Authors:
-- --
@@ -116,6 +115,7 @@ CALLSIGN={
--- Utilities static class. --- Utilities static class.
-- @type UTILS -- @type UTILS
-- @field #number _MarkID Marker index counter. Running number when marker is added.
UTILS = { UTILS = {
_MarkID = 1 _MarkID = 1
} }
@@ -183,7 +183,9 @@ UTILS.IsInstanceOf = function( object, className )
end end
--from http://lua-users.org/wiki/CopyTable --- Deep copy a table. See http://lua-users.org/wiki/CopyTable
-- @param #table object The input table.
-- @return #table Copy of the input table.
UTILS.DeepCopy = function(object) UTILS.DeepCopy = function(object)
local lookup_table = {} local lookup_table = {}
local function _copy(object) local function _copy(object)
@@ -204,7 +206,8 @@ UTILS.DeepCopy = function(object)
end end
-- porting in Slmod's serialize_slmod2 --- Porting in Slmod's serialize_slmod2.
-- @param #table tbl Input table.
UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function
lookup_table = {} lookup_table = {}
@@ -340,18 +343,30 @@ UTILS.MiphToMps = function( miph )
return miph * 0.44704 return miph * 0.44704
end end
--- Convert meters per second to miles per hour.
-- @param #number mps Speed in m/s.
-- @return #number Speed in miles per hour.
UTILS.MpsToMiph = function( mps ) UTILS.MpsToMiph = function( mps )
return mps / 0.44704 return mps / 0.44704
end end
--- Convert meters per second to knots.
-- @param #number knots Speed in m/s.
-- @return #number Speed in knots.
UTILS.MpsToKnots = function( mps ) UTILS.MpsToKnots = function( mps )
return mps * 1.94384 --3600 / 1852 return mps * 1.94384 --3600 / 1852
end end
--- Convert knots to meters per second.
-- @param #number knots Speed in knots.
-- @return #number Speed in m/s.
UTILS.KnotsToMps = function( knots ) UTILS.KnotsToMps = function( knots )
return knots / 1.94384 --* 1852 / 3600 return knots / 1.94384 --* 1852 / 3600
end end
--- Convert temperature from Celsius to Farenheit.
-- @param #number Celcius Temperature in degrees Celsius.
-- @return #number Temperature in degrees Farenheit.
UTILS.CelciusToFarenheit = function( Celcius ) UTILS.CelciusToFarenheit = function( Celcius )
return Celcius * 9/5 + 32 return Celcius * 9/5 + 32
end end
@@ -982,7 +997,7 @@ end
--- Returns the DCS map/theatre as optained by env.mission.theatre --- Returns the DCS map/theatre as optained by env.mission.theatre
-- @return #string DCS map name . -- @return #string DCS map name.
function UTILS.GetDCSMap() function UTILS.GetDCSMap()
return env.mission.theatre return env.mission.theatre
end end
@@ -1100,7 +1115,7 @@ end
--- Get the callsign name from its enumerator value --- Get the callsign name from its enumerator value
-- @param #number Callsign The enumerator callsign. -- @param #number Callsign The enumerator callsign.
-- @return #string The callsign name. -- @return #string The callsign name or "Ghostrider".
function UTILS.GetCallsignName(Callsign) function UTILS.GetCallsignName(Callsign)
for name, value in pairs(CALLSIGN.Aircraft) do for name, value in pairs(CALLSIGN.Aircraft) do
@@ -1127,7 +1142,5 @@ function UTILS.GetCallsignName(Callsign)
end end
end end
return "Unknown Calsing" return "Ghostrider"
end end
-- Just a test to see commits in new environment for Wingthor
@@ -751,7 +751,7 @@ end
function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay) function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay)
-- Command to set the callsign. -- Command to set the callsign.
local CommandSetCallsign={id='SetCallsign', params={callname=CallName, callnumber=CallNumber or 1}} local CommandSetCallsign={id='SetCallsign', params={callname=CallName, number=CallNumber or 1}}
if Delay and Delay>0 then if Delay and Delay>0 then
SCHEDULER:New(nil, self.CommandSetCallsign, {self, CallName, CallNumber}, Delay) SCHEDULER:New(nil, self.CommandSetCallsign, {self, CallName, CallNumber}, Delay)