Merge pull request #1730 from FlightControl-Master/FF/Ops

OPS
This commit is contained in:
Frank 2022-05-12 10:50:47 +02:00 committed by GitHub
commit 9bb2b17c77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 4 deletions

View File

@ -1510,6 +1510,8 @@ function CHIEF:onafterStatus(From, Event, To)
end end
--- ---
-- Defcon -- Defcon
--- ---
@ -1530,6 +1532,58 @@ 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:CheckTargetQueue() self:CheckTargetQueue()
-- Loop over targets.
for _,_target in pairs(self.targetqueue) do
local target=_target --Ops.Target#TARGET
if target and target:IsAlive() and target.mission and target.mission:IsNotOver() then
local inborder=self:CheckTargetInZones(target, self.borderzoneset)
local inyellow=self:CheckTargetInZones(target, self.yellowzoneset)
local inattack=self:CheckTargetInZones(target, self.engagezoneset)
if self.strategy==CHIEF.Strategy.PASSIVE then
-- Passive: No targets are engaged at all.
self:T(self.lid..string.format("Cancelling mission for target %s as strategy is PASSIVE", target:GetName()))
target.mission:Cancel()
elseif self.strategy==CHIEF.Strategy.DEFENSIVE then
-- Defensive: Cancel if not in border.
if not inborder then
self:T(self.lid..string.format("Cancelling mission for target %s as strategy is DEFENSIVE and not inside border", target:GetName()))
target.mission:Cancel()
end
elseif self.strategy==CHIEF.Strategy.OFFENSIVE then
-- Offensive: Cancel if not in border or conflict.
if not (inborder or inyellow) then
self:T(self.lid..string.format("Cancelling mission for target %s as strategy is OFFENSIVE and not inside border or conflict", target:GetName()))
target.mission:Cancel()
end
elseif self.strategy==CHIEF.Strategy.AGGRESSIVE then
-- Aggessive: Cancel if not in border, conflict or attack.
if not (inborder or inyellow or inattack) then
self:T(self.lid..string.format("Cancelling mission for target %s as strategy is AGGRESSIVE and not inside border, conflict or attack", target:GetName()))
target.mission:Cancel()
end
elseif self.strategy==CHIEF.Strategy.TOTALWAR then
-- Total War: No missions are cancelled.
end
end
end
--- ---
-- Check Strategic Zone Queue -- Check Strategic Zone Queue
--- ---

View File

@ -837,7 +837,7 @@ function FLIGHTGROUP:Status()
-- ROE and Alarm State. -- ROE and Alarm State.
local roe=self:GetROE() or -1 local roe=self:GetROE() or -1
local als=self:GetAlarmstate() or -1 local rot=self:GetROT() or -1
-- Waypoint stuff. -- Waypoint stuff.
local wpidxCurr=self.currentwp local wpidxCurr=self.currentwp
@ -882,8 +882,8 @@ function FLIGHTGROUP:Status()
local curr=self.currbase and self.currbase:GetName() or "N/A" local curr=self.currbase and self.currbase:GetName() or "N/A"
-- Info text. -- Info text.
local text=string.format("%s [%d/%d]: ROE/AS=%d/%d | T/M=%d/%d | Wp=%d[%d]-->%d[%d]/%d [%s] | Life=%.1f | v=%.1f (%d) | Hdg=%03d | Ammo=%d | Detect=%s | Cargo=%.1f | Base=%s [%s-->%s]", local text=string.format("%s [%d/%d]: ROE/ROT=%d/%d | T/M=%d/%d | Wp=%d[%d]-->%d[%d]/%d [%s] | Life=%.1f | v=%.1f (%d) | Hdg=%03d | Ammo=%d | Detect=%s | Cargo=%.1f | Base=%s [%s-->%s]",
fsmstate, nelem, Nelem, roe, als, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, wpN, wpF, life, speed, speedEx, hdg, ammo, ndetected, cargo, curr, home, dest) fsmstate, nelem, Nelem, roe, rot, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, wpN, wpF, life, speed, speedEx, hdg, ammo, ndetected, cargo, curr, home, dest)
self:I(self.lid..text) self:I(self.lid..text)
end end
@ -1809,6 +1809,11 @@ function FLIGHTGROUP:onafterArrived(From, Event, To)
self.flightcontrol:SetFlightStatus(self, FLIGHTCONTROL.FlightStatus.ARRIVED) self.flightcontrol:SetFlightStatus(self, FLIGHTCONTROL.FlightStatus.ARRIVED)
end end
if not self.isAI then
-- Player landed. No despawn.
return
end
--TODO: Check that current base is airwing base. --TODO: Check that current base is airwing base.
local airwing=self:GetAirWing() --airwing:GetAirbaseName()==self.currbase:GetName() local airwing=self:GetAirWing() --airwing:GetAirbaseName()==self.currbase:GetName()

View File

@ -4395,6 +4395,7 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
if Task.description=="Task_Land_At" then if Task.description=="Task_Land_At" then
self:T(self.lid.."Taske DONE Task_Land_At ==> Wait") self:T(self.lid.."Taske DONE Task_Land_At ==> Wait")
self:Cruise()
self:Wait(20, 100) self:Wait(20, 100)
else else
self:T(self.lid.."Task Done but NO mission found ==> _CheckGroupDone in 1 sec") self:T(self.lid.."Task Done but NO mission found ==> _CheckGroupDone in 1 sec")
@ -4791,6 +4792,11 @@ function OPSGROUP:onafterMissionExecute(From, Event, To, Mission)
-- Set mission status to EXECUTING. -- Set mission status to EXECUTING.
Mission:Executing() Mission:Executing()
-- Group is holding but has waypoints ==> Cruise.
if self:IsHolding() and not self:HasPassedFinalWaypoint() then
self:Cruise()
end
-- Set auto engage detected targets. -- Set auto engage detected targets.
if Mission.engagedetectedOn then if Mission.engagedetectedOn then
self:SetEngageDetectedOn(UTILS.MetersToNM(Mission.engagedetectedRmax), Mission.engagedetectedTypes, Mission.engagedetectedEngageZones, Mission.engagedetectedNoEngageZones) self:SetEngageDetectedOn(UTILS.MetersToNM(Mission.engagedetectedRmax), Mission.engagedetectedTypes, Mission.engagedetectedEngageZones, Mission.engagedetectedNoEngageZones)
@ -9698,6 +9704,8 @@ function OPSGROUP:_CheckDamage()
for _,_element in pairs(self.elements) do for _,_element in pairs(self.elements) do
local element=_element --Ops.OpsGroup#OPSGROUP.Element local element=_element --Ops.OpsGroup#OPSGROUP.Element
if element.status~=OPSGROUP.ElementStatus.DEAD and element.status~=OPSGROUP.ElementStatus.INUTERO then
-- Current life points. -- Current life points.
local life=element.unit:GetLife() local life=element.unit:GetLife()
@ -9711,6 +9719,8 @@ function OPSGROUP:_CheckDamage()
end end
end
if damaged then if damaged then
self:Damaged() self:Damaged()
end end
@ -11845,7 +11855,7 @@ function OPSGROUP:GetAmmoTot()
Ammo.MissilesCR=0 Ammo.MissilesCR=0
Ammo.MissilesSA=0 Ammo.MissilesSA=0
for _,_unit in pairs(units) do for _,_unit in pairs(units or {}) do
local unit=_unit --Wrapper.Unit#UNIT local unit=_unit --Wrapper.Unit#UNIT
if unit and unit:IsAlive()~=nil then if unit and unit:IsAlive()~=nil then