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

View File

@ -1571,6 +1571,9 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
-- Create a flight group.
local flightgroup=self:_CreateFlightGroup(asset)
-- Set home base.
flightgroup.homebase=self.airbase
---
-- Asset
---

View File

@ -388,9 +388,7 @@ function CHIEF:onafterStatus(From, Event, To)
end
-- Create missions for all new contacts.
local Nred=0
local Nyellow=0
local Nengage=0
local Nred=0 ; local Nyellow=0 ; local Nengage=0
for _,_contact in pairs(self.Contacts) do
local contact=_contact --#CHIEF.Contact
local group=contact.group --Wrapper.Group#GROUP
@ -438,7 +436,10 @@ function CHIEF:onafterStatus(From, Event, To)
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.
if Nred>0 then
self:SetDefcon(CHIEF.DEFCON.RED)
@ -447,15 +448,22 @@ function CHIEF:onafterStatus(From, Event, To)
else
self:SetDefcon(CHIEF.DEFCON.GREEN)
end
---
-- Mission Queue
---
-- Check mission queue and assign one PLANNED mission.
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)
self:I(self.lid..text)
---
-- Contacts
---
-- Infor about contacts.
-- Info about contacts.
if #self.Contacts>0 then
local text="Contacts:"
for i,_contact in pairs(self.Contacts) do

View File

@ -728,9 +728,9 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
-- Short info.
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,
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)
end
@ -890,6 +890,8 @@ end
-- @param Core.Event#EVENTDATA EventData Event data.
function FLIGHTGROUP:OnEventBirth(EventData)
env.info(string.format("EVENT: Birth for unit %s", tostring(EventData.IniUnitName)))
-- Check that this is the right group.
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then
local unit=EventData.IniUnit
@ -899,11 +901,6 @@ function FLIGHTGROUP:OnEventBirth(EventData)
-- Set group.
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
local function reset()
@ -934,7 +931,7 @@ function FLIGHTGROUP:OnEventBirth(EventData)
end
-- 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)
end
@ -1365,7 +1362,12 @@ end
-- @param #string Event Event.
-- @param #string To To state.
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
@ -1776,14 +1778,17 @@ function FLIGHTGROUP:_CheckGroupDone(delay)
-- Number of remaining tasks/missions?
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.
if self.destbase then
if destbase then
self:I(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTB!")
self:__RTB(-3, self.destbase)
elseif self.destzone then
self:__RTB(-3, destbase)
elseif destzone then
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
self:I(self.lid.."Passed Final WP and NO Tasks/Missions left. No DestBase or DestZone ==> Wait!")
self:__Wait(-1)
@ -2501,14 +2506,6 @@ function FLIGHTGROUP:_InitGroup()
-- Group ammo.
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.
self.radio.On=self.template.communication
self.radio.Freq=self.template.frequency

View File

@ -15,6 +15,7 @@
-- @type INTEL
-- @field #string ClassName Name of the class.
-- @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 #number coalition Coalition side number, e.g. `coalition.side.RED`.
-- @field #string alias Name of the agency.
@ -47,6 +48,7 @@
INTEL = {
ClassName = "INTEL",
Debug = nil,
verbose = 2,
lid = nil,
alias = nil,
filterCategory = {},
@ -355,7 +357,7 @@ function INTEL:onafterStatus(From, Event, To)
self:I(self.lid..text)
end
self:__Status(-30)
self:__Status(-60)
end

View File

@ -661,7 +661,7 @@ function TARGET:GetTargetVec3(Target)
local object=Target.Object --Wrapper.Static#STATIC
if object and object:IsAlive() then
return Target.Object:GetCoordinate()
return object:GetVec3()
end
elseif Target.Type==TARGET.ObjectType.AIRBASE then

View File

@ -670,14 +670,15 @@ end
-- @param #number UnitNumber The number of the UNIT wrapper class to be returned.
-- @return Wrapper.Unit#UNIT The UNIT wrapper class.
function GROUP:GetUnit( UnitNumber )
self:F3( { self.GroupName, UnitNumber } )
local DCSGroup = self:GetDCSObject()
if DCSGroup then
local DCSUnit = DCSGroup:getUnit( UnitNumber )
local UnitFound = UNIT:Find( DCSGroup:getUnit( UnitNumber ) )
self:T2( UnitFound )
local UnitFound = UNIT:Find(DCSUnit)
return UnitFound
end
@ -690,13 +691,11 @@ end
-- @param #number UnitNumber The number of the DCS Unit to be returned.
-- @return DCS#Unit The DCS Unit.
function GROUP:GetDCSUnit( UnitNumber )
self:F3( { self.GroupName, UnitNumber } )
local DCSGroup = self:GetDCSObject()
local DCSGroup=self:GetDCSObject()
if DCSGroup then
local DCSUnitFound = DCSGroup:getUnit( UnitNumber )
self:T3( DCSUnitFound )
local DCSUnitFound=DCSGroup:getUnit( UnitNumber )
return DCSUnitFound
end
@ -708,14 +707,14 @@ end
-- @param #GROUP self
-- @return #number The DCS Group size.
function GROUP:GetSize()
self:F3( { self.GroupName } )
local DCSGroup = self:GetDCSObject()
if DCSGroup then
local GroupSize = DCSGroup:getSize()
if GroupSize then
self:T3( GroupSize )
return GroupSize
else
return 0