mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Improvements
This commit is contained in:
parent
d874456361
commit
1ff41ec7ec
@ -127,19 +127,30 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
||||
|
||||
local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||
|
||||
if not AttackUnit then
|
||||
self.AttackSetUnit.AttackIndex = 1
|
||||
AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||
end
|
||||
local AttackUnitTasks = {}
|
||||
|
||||
-- if not AttackUnit then
|
||||
-- self.AttackSetUnit.AttackIndex = 1
|
||||
-- AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||
-- end
|
||||
-- if AttackUnit then
|
||||
-- if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
-- self:T( { "BAI Unit:", AttackUnit:GetName() } )
|
||||
-- AttackUnitTasks[#AttackUnitTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
-- end
|
||||
-- end
|
||||
|
||||
if AttackUnit then
|
||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
self:T( { "BAI Unit:", AttackUnit:GetName() } )
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
for AttackUnitIndex, AttackUnit in ipairs( AttackSetUnitPerThreatLevel or {} ) do
|
||||
if AttackUnit then
|
||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
self:T( { "BAI Unit:", AttackUnit:GetName() } )
|
||||
AttackUnitTasks[#AttackUnitTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if #AttackTasks == 0 then
|
||||
if #AttackUnitTasks == 0 then
|
||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||
self:Return()
|
||||
self:__RTB( self.TaskDelay )
|
||||
@ -148,6 +159,7 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
||||
DefenderGroup:OptionROTEvadeFire()
|
||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskCombo( AttackUnitTasks )
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||
end
|
||||
|
||||
@ -74,7 +74,7 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
||||
|
||||
if DefenderGroup:IsAlive() then
|
||||
|
||||
local EngageAltitude = math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude )
|
||||
local EngageAltitude = math.random( self.EngageFloorAltitude or 500, self.EngageCeilingAltitude or 1000 )
|
||||
local EngageSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
||||
|
||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||
@ -121,21 +121,33 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
||||
|
||||
local AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
|
||||
|
||||
local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||
--local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||
|
||||
if not AttackUnit then
|
||||
self.AttackSetUnit.AttackIndex = 1
|
||||
AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||
end
|
||||
|
||||
if AttackUnit then
|
||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
self:F( { "CAS Unit:", AttackUnit:GetName() } )
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
local AttackUnitTasks = {}
|
||||
|
||||
-- if not AttackUnit then
|
||||
-- self.AttackSetUnit.AttackIndex = 1
|
||||
-- AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||
-- end
|
||||
--
|
||||
-- if AttackUnit then
|
||||
-- if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
-- self:F( { "CAS Unit:", AttackUnit:GetName() } )
|
||||
-- AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
-- end
|
||||
-- end
|
||||
|
||||
for AttackUnitIndex, AttackUnit in ipairs( AttackSetUnitPerThreatLevel or {} ) do
|
||||
if AttackUnit then
|
||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
self:T( { "CAS Unit:", AttackUnit:GetName() } )
|
||||
AttackUnitTasks[#AttackUnitTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if #AttackTasks == 0 then
|
||||
if #AttackUnitTasks == 0 then
|
||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||
self:Return()
|
||||
self:__RTB( self.TaskDelay )
|
||||
@ -144,6 +156,7 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
||||
DefenderGroup:OptionROTEvadeFire()
|
||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskCombo( AttackUnitTasks )
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||
end
|
||||
|
||||
@ -2089,8 +2089,8 @@ do -- AI_A2G_DISPATCHER
|
||||
Sead.Name = SquadronName
|
||||
Sead.EngageMinSpeed = EngageMinSpeed
|
||||
Sead.EngageMaxSpeed = EngageMaxSpeed
|
||||
Sead.EngageFloorAltitude = EngageFloorAltitude
|
||||
Sead.EngageCeilingAltitude = EngageCeilingAltitude
|
||||
Sead.EngageFloorAltitude = EngageFloorAltitude or 500
|
||||
Sead.EngageCeilingAltitude = EngageCeilingAltitude or 1000
|
||||
Sead.Defend = true
|
||||
|
||||
self:F( { Sead = Sead } )
|
||||
@ -2186,8 +2186,8 @@ do -- AI_A2G_DISPATCHER
|
||||
Cas.Name = SquadronName
|
||||
Cas.EngageMinSpeed = EngageMinSpeed
|
||||
Cas.EngageMaxSpeed = EngageMaxSpeed
|
||||
Cas.EngageFloorAltitude = EngageFloorAltitude
|
||||
Cas.EngageCeilingAltitude = EngageCeilingAltitude
|
||||
Cas.EngageFloorAltitude = EngageFloorAltitude or 500
|
||||
Cas.EngageCeilingAltitude = EngageCeilingAltitude or 1000
|
||||
Cas.Defend = true
|
||||
|
||||
self:F( { Cas = Cas } )
|
||||
@ -2284,8 +2284,8 @@ do -- AI_A2G_DISPATCHER
|
||||
Bai.Name = SquadronName
|
||||
Bai.EngageMinSpeed = EngageMinSpeed
|
||||
Bai.EngageMaxSpeed = EngageMaxSpeed
|
||||
Bai.EngageFloorAltitude = EngageFloorAltitude
|
||||
Bai.EngageCeilingAltitude = EngageCeilingAltitude
|
||||
Bai.EngageFloorAltitude = EngageFloorAltitude or 500
|
||||
Bai.EngageCeilingAltitude = EngageCeilingAltitude or 1000
|
||||
Bai.Defend = true
|
||||
|
||||
self:F( { Bai = Bai } )
|
||||
@ -3942,7 +3942,7 @@ do -- AI_A2G_DISPATCHER
|
||||
if DefenseProbability <= DistanceProbability / ( 300 / 30 ) then
|
||||
|
||||
-- Now check if this coordinate is not in a danger zone, meaning, that the attack line is not crossing other coordinates.
|
||||
-- (y1 – y2)x + (x2 – x1)y + (x1y2 – x2y1) = 0
|
||||
-- (y1 – y2)x + (x2 – x1)y + (x1y2 – x2y1) = 0
|
||||
|
||||
local c1 = DefenseCoordinate
|
||||
local c2 = AttackCoordinate
|
||||
@ -4029,7 +4029,8 @@ do -- AI_A2G_DISPATCHER
|
||||
|
||||
if self.TacticalDisplay then
|
||||
-- Show tactical situation
|
||||
Report:Add( string.format( " - %s ( %s ): ( #%d - %4s ) %s" , DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Type or " --- ", DetectedItem.Set:GetObjectNames() ) )
|
||||
local ThreatLevel = DetectedItem.Set:CalculateThreatLevelA2G()
|
||||
Report:Add( string.format( " - %s ( %s ): ( #%d - %4s ) %s" , DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Type or " --- ", string.rep( "■", ThreatLevel ) ) )
|
||||
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||
local Defender = Defender -- Wrapper.Group#GROUP
|
||||
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
||||
|
||||
@ -129,7 +129,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
||||
-- If it is less than 50km, then attack without a route.
|
||||
-- Otherwise perform a route attack.
|
||||
|
||||
local EngageAltitude = math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude )
|
||||
local EngageAltitude = math.random( self.EngageFloorAltitude or 500, self.EngageCeilingAltitude or 1000 )
|
||||
local EngageSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
||||
|
||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||
@ -150,7 +150,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
||||
POINT_VEC3.RoutePointType.TurningPoint,
|
||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||
EngageSpeed,
|
||||
true
|
||||
false
|
||||
)
|
||||
|
||||
EngageRoute[#EngageRoute+1] = FromWP
|
||||
@ -174,28 +174,28 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
||||
|
||||
local AttackTasks = {}
|
||||
|
||||
self.AttackSetUnit.AttackIndex = self.AttackSetUnit.AttackIndex and self.AttackSetUnit.AttackIndex + 1 or 1
|
||||
if self.AttackSetUnit.AttackIndex > self.AttackSetUnit:Count() then
|
||||
self.AttackSetUnit.AttackIndex = 1
|
||||
end
|
||||
|
||||
-- self.AttackSetUnit.AttackIndex = self.AttackSetUnit.AttackIndex and self.AttackSetUnit.AttackIndex + 1 or 1
|
||||
-- if self.AttackSetUnit.AttackIndex > self.AttackSetUnit:Count() then
|
||||
-- self.AttackSetUnit.AttackIndex = 1
|
||||
-- end
|
||||
--
|
||||
local AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
|
||||
|
||||
local AttackUnitTasks = {}
|
||||
|
||||
for AttackUnitID, AttackUnit in ipairs( AttackSetUnitPerThreatLevel ) do
|
||||
if AttackUnitID >= self.AttackSetUnit.AttackIndex then
|
||||
if AttackUnit then
|
||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
local HasRadar = AttackUnit:HasSEAD()
|
||||
if HasRadar then
|
||||
self:F( { "SEAD Unit:", AttackUnit:GetName() } )
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
end
|
||||
if AttackUnit then
|
||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||
local HasRadar = AttackUnit:HasSEAD()
|
||||
if HasRadar then
|
||||
self:F( { "SEAD Unit:", AttackUnit:GetName() } )
|
||||
AttackUnitTasks[#AttackUnitTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if #AttackTasks == 0 then
|
||||
if #AttackUnitTasks == 0 then
|
||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||
self:Return()
|
||||
self:__RTB( self.TaskDelay )
|
||||
@ -205,6 +205,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||
--DefenderGroup:OptionRTBAmmo( Weapon.flag.AnyASM )
|
||||
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskCombo( AttackUnitTasks )
|
||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||
end
|
||||
|
||||
@ -788,7 +788,7 @@ do -- DETECTION_BASE
|
||||
-- IsDetected = false!
|
||||
-- This is used in A2A_TASK_DISPATCHER to initiate fighter sweeping! The TASK_A2A_INTERCEPT tasks will be replaced with TASK_A2A_SWEEP tasks.
|
||||
for DetectedObjectName, DetectedObject in pairs( self.DetectedObjects ) do
|
||||
if self.DetectedObjects[DetectedObjectName].IsDetected == true and self.DetectedObjects[DetectedObjectName].DetectionTimeStamp + 60 <= DetectionTimeStamp then
|
||||
if self.DetectedObjects[DetectedObjectName].IsDetected == true and self.DetectedObjects[DetectedObjectName].DetectionTimeStamp + 300 <= DetectionTimeStamp then
|
||||
self.DetectedObjects[DetectedObjectName].IsDetected = false
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user