mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
AUFTRAG - Added mission task param for RECON, PATROLZONE and TROOPTRANSPORT FLIGHTGROUP - Fixed CheckGroupDone if group is engaging and has a paused mission TARGET - Added GetThreatLevelMax functions CHIEF - Added :AddGciCapZone() function
This commit is contained in:
parent
ec33dfb76c
commit
f32eb8d710
@ -1501,6 +1501,8 @@ function AUFTRAG:NewTROOPTRANSPORT(TransportGroupSet, DropoffCoordinate, PickupC
|
||||
|
||||
mission.transportPickup=PickupCoordinate or mission:GetTargetCoordinate()
|
||||
mission.transportDropoff=DropoffCoordinate
|
||||
|
||||
mission.missionTask=mission:GetMissionTaskforMissionType(AUFTRAG.Type.TROOPTRANSPORT)
|
||||
|
||||
-- Debug.
|
||||
mission.transportPickup:MarkToAll("Pickup")
|
||||
@ -1644,6 +1646,8 @@ function AUFTRAG:NewPATROLZONE(Zone, Speed, Altitude)
|
||||
end
|
||||
|
||||
mission:_TargetFromObject(Zone)
|
||||
|
||||
mission.missionTask=mission:GetMissionTaskforMissionType(AUFTRAG.Type.PATROLZONE)
|
||||
|
||||
mission.optionROE=ENUMS.ROE.OpenFire
|
||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||
@ -1673,6 +1677,8 @@ function AUFTRAG:NewRECON(ZoneSet, Speed, Altitude, Adinfinitum, Randomly)
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.RECON)
|
||||
|
||||
mission:_TargetFromObject(ZoneSet)
|
||||
|
||||
mission.missionTask=mission:GetMissionTaskforMissionType(AUFTRAG.Type.RECON)
|
||||
|
||||
mission.optionROE=ENUMS.ROE.WeaponHold
|
||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||
@ -5005,8 +5011,12 @@ function AUFTRAG:GetMissionTaskforMissionType(MissionType)
|
||||
mtask=ENUMS.MissionTask.RUNWAYATTACK
|
||||
elseif MissionType==AUFTRAG.Type.CAP then
|
||||
mtask=ENUMS.MissionTask.CAP
|
||||
elseif MissionType==AUFTRAG.Type.GCICAP then
|
||||
mtask=ENUMS.MissionTask.CAP
|
||||
elseif MissionType==AUFTRAG.Type.CAS then
|
||||
mtask=ENUMS.MissionTask.CAS
|
||||
elseif MissionType==AUFTRAG.Type.PATROLZONE then
|
||||
mtask=ENUMS.MissionTask.CAS
|
||||
elseif MissionType==AUFTRAG.Type.ESCORT then
|
||||
mtask=ENUMS.MissionTask.ESCORT
|
||||
elseif MissionType==AUFTRAG.Type.FACA then
|
||||
|
||||
@ -815,9 +815,9 @@ function CHIEF:AddRefuellingZone(RefuellingZone)
|
||||
return supplyzone
|
||||
end
|
||||
|
||||
--- Add a CAP zone.
|
||||
--- Add a CAP zone. Flights will engage detected targets inside this zone.
|
||||
-- @param #CHIEF self
|
||||
-- @param Core.Zone#ZONE Zone Zone.
|
||||
-- @param Core.Zone#ZONE Zone CAP Zone. Has to be a circular zone.
|
||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
@ -831,6 +831,21 @@ function CHIEF:AddCapZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
return zone
|
||||
end
|
||||
|
||||
--- Add a GCI CAP.
|
||||
-- @param #CHIEF self
|
||||
-- @param Core.Zone#ZONE Zone Zone, where the flight orbits.
|
||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @return Ops.AirWing#AIRWING.PatrolZone The CAP zone data.
|
||||
function CHIEF:AddGciCapZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
-- Hand over to commander.
|
||||
local zone=self.commander:AddGciCapZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
return zone
|
||||
end
|
||||
|
||||
--- Add an AWACS zone.
|
||||
-- @param #CHIEF self
|
||||
@ -1460,11 +1475,17 @@ function CHIEF:CheckTargetQueue()
|
||||
for _,_target in pairs(self.targetqueue) do
|
||||
local target=_target --Ops.Target#TARGET
|
||||
|
||||
-- Is target still alive.
|
||||
local isAlive=target:IsAlive()
|
||||
|
||||
-- Is this target important enough.
|
||||
local isImportant=(target.importance==nil or target.importance<=vip)
|
||||
|
||||
-- Get threat level of target.
|
||||
local threatlevel=target:GetThreatLevelMax()
|
||||
|
||||
-- Is this a threat?
|
||||
local isThreat=target.threatlevel0>=self.threatLevelMin and target.threatlevel0<=self.threatLevelMax
|
||||
local isThreat=threatlevel>=self.threatLevelMin and threatlevel<=self.threatLevelMax
|
||||
|
||||
-- Airbases, Zones and Coordinates have threat level 0. We consider them threads independent of min/max threat level set.
|
||||
if target.category==TARGET.Category.AIRBASE or target.category==TARGET.Category.ZONE or target.Category==TARGET.Category.COORDINATE then
|
||||
@ -1542,7 +1563,7 @@ function CHIEF:CheckTargetQueue()
|
||||
if valid then
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Got valid target %s: category=%s, threatlevel=%d", target:GetName(), target.category, target.threatlevel0))
|
||||
self:I(self.lid..string.format("Got valid target %s: category=%s, threatlevel=%d", target:GetName(), target.category, threatlevel))
|
||||
|
||||
-- Get mission performances for the given target.
|
||||
local MissionPerformances=self:_GetMissionPerformanceFromTarget(target)
|
||||
@ -1563,13 +1584,9 @@ function CHIEF:CheckTargetQueue()
|
||||
local NassetsMin=1
|
||||
local NassetsMax=1
|
||||
|
||||
local threat = target.threatlevel0 / target.N0 -- avg threatlevel
|
||||
local NoUnits = target.N0 -- no of units in here
|
||||
|
||||
--if target.threatlevel0>=8 then
|
||||
if threat>=8 and NoUnits >=10 then
|
||||
if threatlevel>=8 and target.N0 >=10 then
|
||||
NassetsMax=3
|
||||
elseif threat>=5 then
|
||||
elseif threatlevel>=5 then
|
||||
NassetsMax=2
|
||||
else
|
||||
NassetsMax=1
|
||||
@ -1683,13 +1700,10 @@ function CHIEF:CheckOpsZoneQueue()
|
||||
if ownercoalition~=self.coalition and (stratzone.importance==nil or stratzone.importance<=vip) then
|
||||
|
||||
-- Has a patrol mission?
|
||||
--local hasMissionPatrol=stratzone.missionPatrol and stratzone.missionPatrol:IsNotOver() or false
|
||||
local hasMissionPatrol=stratzone.opszone:_FindMissions(self.coalition,AUFTRAG.Type.PATROLZONE)
|
||||
local hasMissionPatrol=stratzone.opszone:_FindMissions(self.coalition,AUFTRAG.Type.ONGUARD)
|
||||
-- Has a CAS mission?
|
||||
--local hasMissionCAS=stratzone.missionCAS and stratzone.missionCAS:IsNotOver() or false
|
||||
local hasMissionCAS=stratzone.opszone:_FindMissions(self.coalition,AUFTRAG.Type.CAS)
|
||||
-- Has a ARTY mission?
|
||||
--local hasMissionARTY=stratzone.missionARTY and stratzone.missionARTY:IsNotOver() or false
|
||||
local hasMissionARTY=stratzone.opszone:_FindMissions(self.coalition,AUFTRAG.Type.ARTY)
|
||||
|
||||
-- Debug info.
|
||||
@ -1764,11 +1778,9 @@ function CHIEF:CheckOpsZoneQueue()
|
||||
local ownercoalition=stratzone.opszone:GetOwner()
|
||||
|
||||
-- Has a patrol mission?
|
||||
--local hasMissionPatrol=stratzone.missionPatrol and stratzone.missionPatrol:IsNotOver() or false
|
||||
local hasMissionPATROL=stratzone.opszone:_FindMissions(self.coalition,AUFTRAG.Type.PATROLZONE)
|
||||
|
||||
-- Has a CAS mission?
|
||||
--local hasMissionCAS=stratzone.missionCAS and stratzone.missionCAS:IsNotOver() or false
|
||||
local hasMissionCAS, CASMissions = stratzone.opszone:_FindMissions(self.coalition,AUFTRAG.Type.CAS)
|
||||
local hasMissionARTY, ARTYMissions = stratzone.opszone:_FindMissions(self.coalition,AUFTRAG.Type.ARTY)
|
||||
|
||||
@ -1782,18 +1794,14 @@ function CHIEF:CheckOpsZoneQueue()
|
||||
end
|
||||
|
||||
if ownercoalition==self.coalition and hasMissionARTY then
|
||||
-- Cancel CAS mission if zone is ours and no enemies are present.
|
||||
-- TODO: Might want to check if we still have ARTY capable assets in stock?!
|
||||
--stratzone.missionCAS:Cancel()
|
||||
-- Cancel ARTY mission if zone is ours and no enemies are present.
|
||||
for _,_auftrag in pairs(ARTYMissions) do
|
||||
_auftrag:Cancel()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -2112,19 +2112,19 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Check FLIGHTGROUP [state=%s] done? (t=%.4f)", fsmstate, timer.getTime()))
|
||||
|
||||
-- First check if there is a paused mission that
|
||||
if self.missionpaused then
|
||||
self:T(self.lid..string.format("Found paused mission %s [%s]. Unpausing mission...", self.missionpaused.name, self.missionpaused.type))
|
||||
self:UnpauseMission()
|
||||
return
|
||||
end
|
||||
|
||||
-- Group is currently engaging.
|
||||
if self:IsEngaging() then
|
||||
self:T(self.lid.."Engaging! Group NOT done...")
|
||||
return
|
||||
end
|
||||
|
||||
-- First check if there is a paused mission.
|
||||
if self.missionpaused then
|
||||
self:T(self.lid..string.format("Found paused mission %s [%s]. Unpausing mission...", self.missionpaused.name, self.missionpaused.type))
|
||||
self:UnpauseMission()
|
||||
return
|
||||
end
|
||||
|
||||
-- Group is ordered to land at an airbase.
|
||||
if self.isLandingAtAirbase then
|
||||
self:T(self.lid..string.format("Landing at airbase %s! Group NOT done...", self.isLandingAtAirbase:GetName()))
|
||||
|
||||
@ -883,6 +883,86 @@ function TARGET:GetLife()
|
||||
return N
|
||||
end
|
||||
|
||||
--- Get target threat level
|
||||
-- @param #TARGET self
|
||||
-- @param #TARGET.Object Target Target object.
|
||||
-- @return #number Threat level of target.
|
||||
function TARGET:GetTargetThreatLevelMax(Target)
|
||||
|
||||
if Target.Type==TARGET.ObjectType.GROUP then
|
||||
|
||||
local group=Target.Object --Wrapper.Group#GROUP
|
||||
|
||||
if group and group:IsAlive() then
|
||||
|
||||
local tl=group:GetThreatLevel()
|
||||
|
||||
return tl
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.UNIT then
|
||||
|
||||
local unit=Target.Object --Wrapper.Unit#UNIT
|
||||
|
||||
if unit and unit:IsAlive() then
|
||||
|
||||
-- Note! According to the profiler, there is a big difference if we "return unit:GetLife()" or "local life=unit:GetLife(); return life"!
|
||||
local life=unit:GetThreatLevel()
|
||||
return life
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.STATIC then
|
||||
|
||||
return 0
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.SCENERY then
|
||||
|
||||
return 0
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.AIRBASE then
|
||||
|
||||
return 0
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.COORDINATE then
|
||||
|
||||
return 0
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.ZONE then
|
||||
|
||||
return 0
|
||||
|
||||
else
|
||||
self:E("ERROR: unknown target object type in GetTargetThreatLevel!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Get threat level.
|
||||
-- @param #TARGET self
|
||||
-- @return #number Threat level.
|
||||
function TARGET:GetThreatLevelMax()
|
||||
|
||||
local N=0
|
||||
|
||||
for _,_target in pairs(self.targets) do
|
||||
local Target=_target --#TARGET.Object
|
||||
|
||||
local n=self:GetTargetThreatLevelMax(Target)
|
||||
|
||||
if n>N then
|
||||
N=n
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return N
|
||||
end
|
||||
|
||||
--- Get target 2D position vector.
|
||||
-- @param #TARGET self
|
||||
-- @param #TARGET.Object Target Target object.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user