mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
- CHIEF: added tactical overview
This commit is contained in:
parent
24559c475b
commit
9d703c0af6
@ -32,6 +32,7 @@
|
|||||||
-- @field #string Defcon Defence condition.
|
-- @field #string Defcon Defence condition.
|
||||||
-- @field #string strategy Strategy of the CHIEF.
|
-- @field #string strategy Strategy of the CHIEF.
|
||||||
-- @field Ops.Commander#COMMANDER commander Commander of assigned legions.
|
-- @field Ops.Commander#COMMANDER commander Commander of assigned legions.
|
||||||
|
-- @field #boolean tacview Tactical overview.
|
||||||
-- @extends Ops.Intelligence#INTEL
|
-- @extends Ops.Intelligence#INTEL
|
||||||
|
|
||||||
--- *In preparing for battle I have always found that plans are useless, but planning is indispensable* -- Dwight D Eisenhower
|
--- *In preparing for battle I have always found that plans are useless, but planning is indispensable* -- Dwight D Eisenhower
|
||||||
@ -134,6 +135,7 @@ CHIEF = {
|
|||||||
borderzoneset = nil,
|
borderzoneset = nil,
|
||||||
yellowzoneset = nil,
|
yellowzoneset = nil,
|
||||||
engagezoneset = nil,
|
engagezoneset = nil,
|
||||||
|
tacview = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Defence condition.
|
--- Defence condition.
|
||||||
@ -601,6 +603,23 @@ function CHIEF:GetDefcon(Defcon)
|
|||||||
return self.Defcon
|
return self.Defcon
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set tactical overview on.
|
||||||
|
-- @param #CHIEF self
|
||||||
|
-- @return #CHIEF self
|
||||||
|
function CHIEF:SetTacticalOverviewOn()
|
||||||
|
self.tacview=true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set tactical overview off.
|
||||||
|
-- @param #CHIEF self
|
||||||
|
-- @return #CHIEF self
|
||||||
|
function CHIEF:SetTacticalOverviewOff()
|
||||||
|
self.tacview=false
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set strategy.
|
--- Set strategy.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
-- @param #string Strategy Strategy. See @{#CHIEF.strategy}, e.g. `CHIEF.Strategy.DEFENSIVE` (default).
|
-- @param #string Strategy Strategy. See @{#CHIEF.strategy}, e.g. `CHIEF.Strategy.DEFENSIVE` (default).
|
||||||
@ -1114,7 +1133,7 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- Create TARGETs for all new contacts.
|
-- Create TARGETs for all new contacts.
|
||||||
local Nborder=0 ; local Nconflict=0 ; local Nattack=0
|
self.Nborder=0 ; self.Nconflict=0 ; self.Nattack=0
|
||||||
for _,_contact in pairs(self.Contacts) do
|
for _,_contact in pairs(self.Contacts) do
|
||||||
local contact=_contact --Ops.Intelligence#INTEL.Contact
|
local contact=_contact --Ops.Intelligence#INTEL.Contact
|
||||||
local group=contact.group --Wrapper.Group#GROUP
|
local group=contact.group --Wrapper.Group#GROUP
|
||||||
@ -1122,19 +1141,19 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
-- Check if contact inside of our borders.
|
-- Check if contact inside of our borders.
|
||||||
local inred=self:CheckGroupInBorder(group)
|
local inred=self:CheckGroupInBorder(group)
|
||||||
if inred then
|
if inred then
|
||||||
Nborder=Nborder+1
|
self.Nborder=self.Nborder+1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if contact is in the conflict zones.
|
-- Check if contact is in the conflict zones.
|
||||||
local inyellow=self:CheckGroupInConflict(group)
|
local inyellow=self:CheckGroupInConflict(group)
|
||||||
if inyellow then
|
if inyellow then
|
||||||
Nconflict=Nconflict+1
|
self.Nconflict=self.Nconflict+1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if contact is in the attack zones.
|
-- Check if contact is in the attack zones.
|
||||||
local inattack=self:CheckGroupInAttack(group)
|
local inattack=self:CheckGroupInAttack(group)
|
||||||
if inattack then
|
if inattack then
|
||||||
Nattack=Nattack+1
|
self.Nattack=self.Nattack+1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -1162,9 +1181,9 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- 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 Nborder>0 then
|
if self.Nborder>0 then
|
||||||
self:SetDefcon(CHIEF.DEFCON.RED)
|
self:SetDefcon(CHIEF.DEFCON.RED)
|
||||||
elseif Nconflict>0 then
|
elseif self.Nconflict>0 then
|
||||||
self:SetDefcon(CHIEF.DEFCON.YELLOW)
|
self:SetDefcon(CHIEF.DEFCON.YELLOW)
|
||||||
else
|
else
|
||||||
self:SetDefcon(CHIEF.DEFCON.GREEN)
|
self:SetDefcon(CHIEF.DEFCON.GREEN)
|
||||||
@ -1182,7 +1201,11 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- Check target queue and assign missions to new targets.
|
-- Check target queue and assign missions to new targets.
|
||||||
self:CheckOpsZoneQueue()
|
self:CheckOpsZoneQueue()
|
||||||
|
|
||||||
|
|
||||||
|
-- Display tactival overview.
|
||||||
|
self:_TacticalOverview()
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Info General
|
-- Info General
|
||||||
@ -1196,7 +1219,7 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
-- Info message
|
-- Info message
|
||||||
local text=string.format("Defcon=%s Strategy=%s: Assets=%d, Contacts=%d [Border=%d, Conflict=%d, Attack=%d], Targets=%d, Missions=%d",
|
local text=string.format("Defcon=%s Strategy=%s: Assets=%d, Contacts=%d [Border=%d, Conflict=%d, Attack=%d], Targets=%d, Missions=%d",
|
||||||
self.Defcon, self.strategy, Nassets, Ncontacts, Nborder, Nconflict, Nattack, Ntargets, Nmissions)
|
self.Defcon, self.strategy, Nassets, Ncontacts, self.Nborder, self.Nconflict, self.Nattack, Ntargets, Nmissions)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1470,6 +1493,59 @@ end
|
|||||||
-- Target Functions
|
-- Target Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Display tactical overview.
|
||||||
|
-- @param #CHIEF self
|
||||||
|
function CHIEF:_TacticalOverview()
|
||||||
|
|
||||||
|
if self.tacview then
|
||||||
|
|
||||||
|
local NassetsTotal=self.commander:CountAssets()
|
||||||
|
local NassetsStock=self.commander:CountAssets(true)
|
||||||
|
local Ncontacts=#self.Contacts
|
||||||
|
local Nmissions=#self.commander.missionqueue
|
||||||
|
local Ntargets=#self.targetqueue
|
||||||
|
local Nzones=#self.zonequeue
|
||||||
|
|
||||||
|
-- Info message
|
||||||
|
local text=string.format("Tactical Overview\n")
|
||||||
|
text=text..string.format("=================\n")
|
||||||
|
|
||||||
|
text=text..string.format("Strategy: %s - Defcon: %s\n", self.strategy, self.Defcon)
|
||||||
|
|
||||||
|
text=text..string.format("Contacts: %d [Border=%d, Conflict=%d, Attack=%d]\n", Ncontacts, self.Nborder, self.Nconflict, self.Nattack)
|
||||||
|
|
||||||
|
text=text..string.format("Targets: %d\n", Ntargets)
|
||||||
|
|
||||||
|
text=text..string.format("Missions: %d\n", Nmissions)
|
||||||
|
for _,mtype in pairs(AUFTRAG.Type) do
|
||||||
|
local n=self.commander:CountMissions(mtype)
|
||||||
|
if n>0 then
|
||||||
|
text=text..string.format(" - %s: %d\n", mtype, n)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
text=text..string.format("Assets: %d [Stock %d]\n", NassetsTotal, NassetsStock)
|
||||||
|
|
||||||
|
text=text..string.format("Strategic Zones: %d\n", Nzones)
|
||||||
|
for _,_stratzone in pairs(self.zonequeue) do
|
||||||
|
local stratzone=_stratzone --#CHIEF.StrategicZone
|
||||||
|
local owner=stratzone.opszone:GetOwnerName()
|
||||||
|
text=text..string.format(" - %s: %s - %s [I=%d, P=%d]\n", stratzone.opszone:GetName(), owner, stratzone.opszone:GetState(), stratzone.importance, stratzone.prio)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Message to coalition.
|
||||||
|
MESSAGE:New(text, 60, nil, true):ToCoalition(self.coalition)
|
||||||
|
|
||||||
|
-- Output to log.
|
||||||
|
if self.verbose>=4 then
|
||||||
|
self:I(self.lid..text)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check target queue and assign ONE valid target by adding it to the mission queue of the COMMANDER.
|
--- Check target queue and assign ONE valid target by adding it to the mission queue of the COMMANDER.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
function CHIEF:CheckTargetQueue()
|
function CHIEF:CheckTargetQueue()
|
||||||
|
|||||||
@ -1411,6 +1411,26 @@ function COMMANDER:CountAssets(InStock, MissionTypes, Attributes)
|
|||||||
return N
|
return N
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Count assets of all assigned legions.
|
||||||
|
-- @param #COMMANDER self
|
||||||
|
-- @param #table MissionTypes (Optional) Count only missions of these types. Default is all types.
|
||||||
|
-- @return #number Amount missions.
|
||||||
|
function COMMANDER:CountMissions(MissionTypes)
|
||||||
|
|
||||||
|
local N=0
|
||||||
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
|
-- Check if this mission type is requested.
|
||||||
|
if AUFTRAG.CheckMissionType(mission.type, MissionTypes) then
|
||||||
|
N=N+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return N
|
||||||
|
end
|
||||||
|
|
||||||
--- Count assets of all assigned legions.
|
--- Count assets of all assigned legions.
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param #boolean InStock If true, only assets that are in the warehouse stock/inventory are counted.
|
-- @param #boolean InStock If true, only assets that are in the warehouse stock/inventory are counted.
|
||||||
|
|||||||
@ -413,6 +413,13 @@ function OPSZONE:GetOwner()
|
|||||||
return self.ownerCurrent
|
return self.ownerCurrent
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get coalition name of current owner of the zone.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @return #string Owner coalition.
|
||||||
|
function OPSZONE:GetOwnerName()
|
||||||
|
return UTILS.GetCoalitionName(self.ownerCurrent)
|
||||||
|
end
|
||||||
|
|
||||||
--- Get coordinate of zone.
|
--- Get coordinate of zone.
|
||||||
-- @param #OPSZONE self
|
-- @param #OPSZONE self
|
||||||
-- @return Core.Point#COORDINATE Coordinate of the zone.
|
-- @return Core.Point#COORDINATE Coordinate of the zone.
|
||||||
@ -421,7 +428,7 @@ function OPSZONE:GetCoordinate()
|
|||||||
return coordinate
|
return coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get name.
|
--- Get zone name.
|
||||||
-- @param #OPSZONE self
|
-- @param #OPSZONE self
|
||||||
-- @return #string Name of the zone.
|
-- @return #string Name of the zone.
|
||||||
function OPSZONE:GetName()
|
function OPSZONE:GetName()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user