This commit is contained in:
Frank
2020-08-26 00:01:52 +02:00
parent 06600b2a94
commit f9ec21a2b5
6 changed files with 48 additions and 39 deletions
+3
View File
@@ -1571,6 +1571,9 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
-- Create a flight group. -- Create a flight group.
local flightgroup=self:_CreateFlightGroup(asset) local flightgroup=self:_CreateFlightGroup(asset)
-- Set home base.
flightgroup.homebase=self.airbase
--- ---
-- Asset -- Asset
--- ---
+15 -7
View File
@@ -388,9 +388,7 @@ function CHIEF:onafterStatus(From, Event, To)
end end
-- Create missions for all new contacts. -- Create missions for all new contacts.
local Nred=0 local Nred=0 ; local Nyellow=0 ; local Nengage=0
local Nyellow=0
local Nengage=0
for _,_contact in pairs(self.Contacts) do for _,_contact in pairs(self.Contacts) do
local contact=_contact --#CHIEF.Contact local contact=_contact --#CHIEF.Contact
local group=contact.group --Wrapper.Group#GROUP local group=contact.group --Wrapper.Group#GROUP
@@ -438,7 +436,10 @@ function CHIEF:onafterStatus(From, Event, To)
end end
-- Set defcon. ---
-- Defcon
---
-- TODO: Need to introduce time check to avoid fast oscillation between different defcon states in case groups move in and out of the zones. -- TODO: Need to introduce time check to avoid fast oscillation between different defcon states in case groups move in and out of the zones.
if Nred>0 then if Nred>0 then
self:SetDefcon(CHIEF.DEFCON.RED) self:SetDefcon(CHIEF.DEFCON.RED)
@@ -447,15 +448,22 @@ function CHIEF:onafterStatus(From, Event, To)
else else
self:SetDefcon(CHIEF.DEFCON.GREEN) self:SetDefcon(CHIEF.DEFCON.GREEN)
end end
---
-- Mission Queue
---
-- Check mission queue and assign one PLANNED mission. -- Check mission queue and assign one PLANNED mission.
self:CheckMissionQueue() self:CheckMissionQueue()
local text=string.format("Defcon=%s Missions=%d Contacts: Total=%d Yellow=%d Red=%d", self.Defcon, #self.missionqueue, #self.Contacts, Nyellow, Nred) local text=string.format("Defcon=%s Missions=%d Contacts: Total=%d Yellow=%d Red=%d", self.Defcon, #self.missionqueue, #self.Contacts, Nyellow, Nred)
self:I(self.lid..text) self:I(self.lid..text)
---
-- Contacts
---
-- Infor about contacts. -- Info about contacts.
if #self.Contacts>0 then if #self.Contacts>0 then
local text="Contacts:" local text="Contacts:"
for i,_contact in pairs(self.Contacts) do for i,_contact in pairs(self.Contacts) do
+18 -21
View File
@@ -728,9 +728,9 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
-- Short info. -- Short info.
if self.verbose>0 then if self.verbose>0 then
local text=string.format("Status %s [%d/%d]: Tasks=%d (%d,%d) Current=%d. Missions=%s. Waypoint=%d/%d. Detected=%d. Destination=%s, FC=%s", local text=string.format("Status %s [%d/%d]: Tasks=%d (%d,%d) Curr=%d, Missions=%s, Waypoint=%d/%d, Detected=%d, Home=%s, Destination=%s",
fsmstate, #self.elements, #self.elements, nTaskTot, nTaskSched, nTaskWP, self.taskcurrent, nMissions, self.currentwp or 0, self.waypoints and #self.waypoints or 0, fsmstate, #self.elements, #self.elements, nTaskTot, nTaskSched, nTaskWP, self.taskcurrent, nMissions, self.currentwp or 0, self.waypoints and #self.waypoints or 0,
self.detectedunits:Count(), self.destbase and self.destbase:GetName() or "unknown", self.flightcontrol and self.flightcontrol.airbasename or "none") self.detectedunits:Count(), self.homebase and self.homebase:GetName() or "unknown", self.destbase and self.destbase:GetName() or "unknown")
self:I(self.lid..text) self:I(self.lid..text)
end end
@@ -890,6 +890,8 @@ end
-- @param Core.Event#EVENTDATA EventData Event data. -- @param Core.Event#EVENTDATA EventData Event data.
function FLIGHTGROUP:OnEventBirth(EventData) function FLIGHTGROUP:OnEventBirth(EventData)
env.info(string.format("EVENT: Birth for unit %s", tostring(EventData.IniUnitName)))
-- Check that this is the right group. -- Check that this is the right group.
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then
local unit=EventData.IniUnit local unit=EventData.IniUnit
@@ -899,11 +901,6 @@ function FLIGHTGROUP:OnEventBirth(EventData)
-- Set group. -- Set group.
self.group=self.group or EventData.IniGroup self.group=self.group or EventData.IniGroup
if not self.groupinitialized then
--TODO: actually that is not very good here as if the first unit is born and in initgroup we initialize all elements!
self:_InitGroup()
end
if self.respawning then if self.respawning then
local function reset() local function reset()
@@ -934,7 +931,7 @@ function FLIGHTGROUP:OnEventBirth(EventData)
end end
-- Set element to spawned state. -- Set element to spawned state.
self:T(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown")) self:I(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown"))
self:ElementSpawned(element) self:ElementSpawned(element)
end end
@@ -1365,7 +1362,12 @@ end
-- @param #string Event Event. -- @param #string Event Event.
-- @param #string To To state. -- @param #string To To state.
function FLIGHTGROUP:onafterSpawned(From, Event, To) function FLIGHTGROUP:onafterSpawned(From, Event, To)
self:T(self.lid..string.format("Flight spawned")) self:I(self.lid..string.format("Flight spawned"))
-- TODO: general routine in opsgroup
self.traveldist=0
self.traveltime=timer.getAbsTime()
self.position=self:GetCoordinate()
if self.ai then if self.ai then
@@ -1776,14 +1778,17 @@ function FLIGHTGROUP:_CheckGroupDone(delay)
-- Number of remaining tasks/missions? -- Number of remaining tasks/missions?
if nTasks==0 and nMissions==0 then if nTasks==0 and nMissions==0 then
local destbase=self.destbase or self.homebase
local destzone=self.destzone or self.homezone
-- Send flight to destination. -- Send flight to destination.
if self.destbase then if destbase then
self:I(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTB!") self:I(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTB!")
self:__RTB(-3, self.destbase) self:__RTB(-3, destbase)
elseif self.destzone then elseif destzone then
self:I(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTZ!") self:I(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTZ!")
self:__RTZ(-3, self.destzone) self:__RTZ(-3, destzone)
else else
self:I(self.lid.."Passed Final WP and NO Tasks/Missions left. No DestBase or DestZone ==> Wait!") self:I(self.lid.."Passed Final WP and NO Tasks/Missions left. No DestBase or DestZone ==> Wait!")
self:__Wait(-1) self:__Wait(-1)
@@ -2501,14 +2506,6 @@ function FLIGHTGROUP:_InitGroup()
-- Group ammo. -- Group ammo.
self.ammo=self:GetAmmoTot() self.ammo=self:GetAmmoTot()
-- Initial fuel mass.
-- TODO: this is a unit property!
self.fuelmass=0
self.traveldist=0
self.traveltime=timer.getAbsTime()
self.position=self:GetCoordinate()
-- Radio parameters from template. -- Radio parameters from template.
self.radio.On=self.template.communication self.radio.On=self.template.communication
self.radio.Freq=self.template.frequency self.radio.Freq=self.template.frequency
+3 -1
View File
@@ -15,6 +15,7 @@
-- @type INTEL -- @type INTEL
-- @field #string ClassName Name of the class. -- @field #string ClassName Name of the class.
-- @field #boolean Debug Debug mode. Messages to all about status. -- @field #boolean Debug Debug mode. Messages to all about status.
-- @field #number verbose Verbosity level.
-- @field #string lid Class id string for output to DCS log file. -- @field #string lid Class id string for output to DCS log file.
-- @field #number coalition Coalition side number, e.g. `coalition.side.RED`. -- @field #number coalition Coalition side number, e.g. `coalition.side.RED`.
-- @field #string alias Name of the agency. -- @field #string alias Name of the agency.
@@ -47,6 +48,7 @@
INTEL = { INTEL = {
ClassName = "INTEL", ClassName = "INTEL",
Debug = nil, Debug = nil,
verbose = 2,
lid = nil, lid = nil,
alias = nil, alias = nil,
filterCategory = {}, filterCategory = {},
@@ -355,7 +357,7 @@ function INTEL:onafterStatus(From, Event, To)
self:I(self.lid..text) self:I(self.lid..text)
end end
self:__Status(-30) self:__Status(-60)
end end
+1 -1
View File
@@ -661,7 +661,7 @@ function TARGET:GetTargetVec3(Target)
local object=Target.Object --Wrapper.Static#STATIC local object=Target.Object --Wrapper.Static#STATIC
if object and object:IsAlive() then if object and object:IsAlive() then
return Target.Object:GetCoordinate() return object:GetVec3()
end end
elseif Target.Type==TARGET.ObjectType.AIRBASE then elseif Target.Type==TARGET.ObjectType.AIRBASE then
+8 -9
View File
@@ -670,14 +670,15 @@ end
-- @param #number UnitNumber The number of the UNIT wrapper class to be returned. -- @param #number UnitNumber The number of the UNIT wrapper class to be returned.
-- @return Wrapper.Unit#UNIT The UNIT wrapper class. -- @return Wrapper.Unit#UNIT The UNIT wrapper class.
function GROUP:GetUnit( UnitNumber ) function GROUP:GetUnit( UnitNumber )
self:F3( { self.GroupName, UnitNumber } )
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject()
if DCSGroup then if DCSGroup then
local DCSUnit = DCSGroup:getUnit( UnitNumber ) local DCSUnit = DCSGroup:getUnit( UnitNumber )
local UnitFound = UNIT:Find( DCSGroup:getUnit( UnitNumber ) )
self:T2( UnitFound ) local UnitFound = UNIT:Find(DCSUnit)
return UnitFound return UnitFound
end end
@@ -690,13 +691,11 @@ end
-- @param #number UnitNumber The number of the DCS Unit to be returned. -- @param #number UnitNumber The number of the DCS Unit to be returned.
-- @return DCS#Unit The DCS Unit. -- @return DCS#Unit The DCS Unit.
function GROUP:GetDCSUnit( UnitNumber ) function GROUP:GetDCSUnit( UnitNumber )
self:F3( { self.GroupName, UnitNumber } )
local DCSGroup = self:GetDCSObject() local DCSGroup=self:GetDCSObject()
if DCSGroup then if DCSGroup then
local DCSUnitFound = DCSGroup:getUnit( UnitNumber ) local DCSUnitFound=DCSGroup:getUnit( UnitNumber )
self:T3( DCSUnitFound )
return DCSUnitFound return DCSUnitFound
end end
@@ -708,14 +707,14 @@ end
-- @param #GROUP self -- @param #GROUP self
-- @return #number The DCS Group size. -- @return #number The DCS Group size.
function GROUP:GetSize() function GROUP:GetSize()
self:F3( { self.GroupName } )
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject()
if DCSGroup then if DCSGroup then
local GroupSize = DCSGroup:getSize() local GroupSize = DCSGroup:getSize()
if GroupSize then if GroupSize then
self:T3( GroupSize )
return GroupSize return GroupSize
else else
return 0 return 0