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]
|
local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||||
|
|
||||||
if not AttackUnit then
|
local AttackUnitTasks = {}
|
||||||
self.AttackSetUnit.AttackIndex = 1
|
|
||||||
AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
-- if not AttackUnit then
|
||||||
end
|
-- 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
|
for AttackUnitIndex, AttackUnit in ipairs( AttackSetUnitPerThreatLevel or {} ) do
|
||||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
if AttackUnit then
|
||||||
self:T( { "BAI Unit:", AttackUnit:GetName() } )
|
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
self:T( { "BAI Unit:", AttackUnit:GetName() } )
|
||||||
|
AttackUnitTasks[#AttackUnitTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if #AttackTasks == 0 then
|
if #AttackUnitTasks == 0 then
|
||||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:__RTB( self.TaskDelay )
|
self:__RTB( self.TaskDelay )
|
||||||
@ -148,6 +159,7 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
DefenderGroup:OptionROTEvadeFire()
|
DefenderGroup:OptionROTEvadeFire()
|
||||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||||
|
|
||||||
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskCombo( AttackUnitTasks )
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
||||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -74,7 +74,7 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
|
|
||||||
if DefenderGroup:IsAlive() then
|
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 EngageSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
||||||
|
|
||||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
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 AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
|
||||||
|
|
||||||
local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
--local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||||
|
|
||||||
if not AttackUnit then
|
local AttackUnitTasks = {}
|
||||||
self.AttackSetUnit.AttackIndex = 1
|
|
||||||
AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
-- if not AttackUnit then
|
||||||
end
|
-- self.AttackSetUnit.AttackIndex = 1
|
||||||
|
-- AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
|
||||||
if AttackUnit then
|
-- end
|
||||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
--
|
||||||
self:F( { "CAS Unit:", AttackUnit:GetName() } )
|
-- if AttackUnit then
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
-- 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if #AttackTasks == 0 then
|
if #AttackUnitTasks == 0 then
|
||||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:__RTB( self.TaskDelay )
|
self:__RTB( self.TaskDelay )
|
||||||
@ -144,6 +156,7 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
DefenderGroup:OptionROTEvadeFire()
|
DefenderGroup:OptionROTEvadeFire()
|
||||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||||
|
|
||||||
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskCombo( AttackUnitTasks )
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
||||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2089,8 +2089,8 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Sead.Name = SquadronName
|
Sead.Name = SquadronName
|
||||||
Sead.EngageMinSpeed = EngageMinSpeed
|
Sead.EngageMinSpeed = EngageMinSpeed
|
||||||
Sead.EngageMaxSpeed = EngageMaxSpeed
|
Sead.EngageMaxSpeed = EngageMaxSpeed
|
||||||
Sead.EngageFloorAltitude = EngageFloorAltitude
|
Sead.EngageFloorAltitude = EngageFloorAltitude or 500
|
||||||
Sead.EngageCeilingAltitude = EngageCeilingAltitude
|
Sead.EngageCeilingAltitude = EngageCeilingAltitude or 1000
|
||||||
Sead.Defend = true
|
Sead.Defend = true
|
||||||
|
|
||||||
self:F( { Sead = Sead } )
|
self:F( { Sead = Sead } )
|
||||||
@ -2186,8 +2186,8 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Cas.Name = SquadronName
|
Cas.Name = SquadronName
|
||||||
Cas.EngageMinSpeed = EngageMinSpeed
|
Cas.EngageMinSpeed = EngageMinSpeed
|
||||||
Cas.EngageMaxSpeed = EngageMaxSpeed
|
Cas.EngageMaxSpeed = EngageMaxSpeed
|
||||||
Cas.EngageFloorAltitude = EngageFloorAltitude
|
Cas.EngageFloorAltitude = EngageFloorAltitude or 500
|
||||||
Cas.EngageCeilingAltitude = EngageCeilingAltitude
|
Cas.EngageCeilingAltitude = EngageCeilingAltitude or 1000
|
||||||
Cas.Defend = true
|
Cas.Defend = true
|
||||||
|
|
||||||
self:F( { Cas = Cas } )
|
self:F( { Cas = Cas } )
|
||||||
@ -2284,8 +2284,8 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Bai.Name = SquadronName
|
Bai.Name = SquadronName
|
||||||
Bai.EngageMinSpeed = EngageMinSpeed
|
Bai.EngageMinSpeed = EngageMinSpeed
|
||||||
Bai.EngageMaxSpeed = EngageMaxSpeed
|
Bai.EngageMaxSpeed = EngageMaxSpeed
|
||||||
Bai.EngageFloorAltitude = EngageFloorAltitude
|
Bai.EngageFloorAltitude = EngageFloorAltitude or 500
|
||||||
Bai.EngageCeilingAltitude = EngageCeilingAltitude
|
Bai.EngageCeilingAltitude = EngageCeilingAltitude or 1000
|
||||||
Bai.Defend = true
|
Bai.Defend = true
|
||||||
|
|
||||||
self:F( { Bai = Bai } )
|
self:F( { Bai = Bai } )
|
||||||
@ -3942,7 +3942,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
if DefenseProbability <= DistanceProbability / ( 300 / 30 ) then
|
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.
|
-- 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 c1 = DefenseCoordinate
|
||||||
local c2 = AttackCoordinate
|
local c2 = AttackCoordinate
|
||||||
@ -4029,7 +4029,8 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
if self.TacticalDisplay then
|
if self.TacticalDisplay then
|
||||||
-- Show tactical situation
|
-- 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
|
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||||
local Defender = Defender -- Wrapper.Group#GROUP
|
local Defender = Defender -- Wrapper.Group#GROUP
|
||||||
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
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.
|
-- If it is less than 50km, then attack without a route.
|
||||||
-- Otherwise perform a route attack.
|
-- 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 EngageSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
||||||
|
|
||||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||||
@ -150,7 +150,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
|||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
EngageSpeed,
|
EngageSpeed,
|
||||||
true
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = FromWP
|
EngageRoute[#EngageRoute+1] = FromWP
|
||||||
@ -174,28 +174,28 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
|||||||
|
|
||||||
local AttackTasks = {}
|
local AttackTasks = {}
|
||||||
|
|
||||||
self.AttackSetUnit.AttackIndex = self.AttackSetUnit.AttackIndex and self.AttackSetUnit.AttackIndex + 1 or 1
|
-- self.AttackSetUnit.AttackIndex = self.AttackSetUnit.AttackIndex and self.AttackSetUnit.AttackIndex + 1 or 1
|
||||||
if self.AttackSetUnit.AttackIndex > self.AttackSetUnit:Count() then
|
-- if self.AttackSetUnit.AttackIndex > self.AttackSetUnit:Count() then
|
||||||
self.AttackSetUnit.AttackIndex = 1
|
-- self.AttackSetUnit.AttackIndex = 1
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
local AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
|
local AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
|
||||||
|
|
||||||
|
local AttackUnitTasks = {}
|
||||||
|
|
||||||
for AttackUnitID, AttackUnit in ipairs( AttackSetUnitPerThreatLevel ) do
|
for AttackUnitID, AttackUnit in ipairs( AttackSetUnitPerThreatLevel ) do
|
||||||
if AttackUnitID >= self.AttackSetUnit.AttackIndex then
|
if AttackUnit then
|
||||||
if AttackUnit then
|
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
local HasRadar = AttackUnit:HasSEAD()
|
||||||
local HasRadar = AttackUnit:HasSEAD()
|
if HasRadar then
|
||||||
if HasRadar then
|
self:F( { "SEAD Unit:", AttackUnit:GetName() } )
|
||||||
self:F( { "SEAD Unit:", AttackUnit:GetName() } )
|
AttackUnitTasks[#AttackUnitTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #AttackTasks == 0 then
|
if #AttackUnitTasks == 0 then
|
||||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:__RTB( self.TaskDelay )
|
self:__RTB( self.TaskDelay )
|
||||||
@ -205,6 +205,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
|||||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||||
--DefenderGroup:OptionRTBAmmo( Weapon.flag.AnyASM )
|
--DefenderGroup:OptionRTBAmmo( Weapon.flag.AnyASM )
|
||||||
|
|
||||||
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskCombo( AttackUnitTasks )
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
||||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -788,7 +788,7 @@ do -- DETECTION_BASE
|
|||||||
-- IsDetected = false!
|
-- 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.
|
-- 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
|
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
|
self.DetectedObjects[DetectedObjectName].IsDetected = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user