Improvements in the attack methods! This is going to be great!

This commit is contained in:
FlightControl
2019-01-29 19:58:06 +01:00
parent 77bee89ea5
commit f2b2b1974d
4 changed files with 48 additions and 23 deletions
+15 -7
View File
@@ -120,14 +120,22 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
EngageRoute[#EngageRoute+1] = ToWP EngageRoute[#EngageRoute+1] = ToWP
local AttackTasks = {} local AttackTasks = {}
self.AttackSetUnit.AttackIndex = self.AttackSetUnit.AttackIndex and self.AttackSetUnit.AttackIndex + 1 or 1
for OrderedID, AttackUnit in ipairs( self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 ) ) do local AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
if AttackUnit then
if AttackUnit:IsAlive() and AttackUnit:IsGround() then local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
self:T( { "BAI Unit:", AttackUnit:GetName() } )
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude ) if not AttackUnit then
break self.AttackSetUnit.AttackIndex = 1
end AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
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 )
end end
end end
+15 -7
View File
@@ -116,14 +116,22 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
EngageRoute[#EngageRoute+1] = ToWP EngageRoute[#EngageRoute+1] = ToWP
local AttackTasks = {} local AttackTasks = {}
self.AttackSetUnit.AttackIndex = self.AttackSetUnit.AttackIndex and self.AttackSetUnit.AttackIndex + 1 or 1
for OrderedID, AttackUnit in ipairs( self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 ) ) do local AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
if AttackUnit then
if AttackUnit:IsAlive() and AttackUnit:IsGround() then local AttackUnit = AttackSetUnitPerThreatLevel[self.AttackSetUnit.AttackIndex]
self:F( { "CAS Unit:", AttackUnit:GetName() } )
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude ) if not AttackUnit then
break self.AttackSetUnit.AttackIndex = 1
end 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
end end
@@ -3557,13 +3557,14 @@ do -- AI_A2G_DISPATCHER
function Fsm:onafterRTB( Defender, From, Event, To ) function Fsm:onafterRTB( Defender, From, Event, To )
self:F({"Defender RTB", Defender:GetName()}) self:F({"Defender RTB", Defender:GetName()})
self:GetParent(self).onafterRTB( self, Defender, From, Event, To )
local DefenderName = Defender:GetName() local DefenderName = Defender:GetName()
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
local Squadron = Dispatcher:GetSquadronFromDefender( Defender ) local Squadron = Dispatcher:GetSquadronFromDefender( Defender )
Dispatcher:MessageToPlayers( "Squadron " .. Squadron.Name .. ", " .. DefenderName .. " returning." ) Dispatcher:MessageToPlayers( "Squadron " .. Squadron.Name .. ", " .. DefenderName .. " returning." )
self:GetParent(self).onafterRTB( self, Defender, From, Event, To )
Dispatcher:ClearDefenderTaskTarget( Defender ) Dispatcher:ClearDefenderTaskTarget( Defender )
end end
+16 -8
View File
@@ -173,15 +173,23 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
EngageRoute[#EngageRoute+1] = ToWP EngageRoute[#EngageRoute+1] = ToWP
local AttackTasks = {} 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
local AttackSetUnitPerThreatLevel = self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 )
for OrderedID, AttackUnit in ipairs( self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 ) ) do for AttackUnitID, AttackUnit in ipairs( AttackSetUnitPerThreatLevel ) do
if AttackUnit then if AttackUnitID >= self.AttackSetUnit.AttackIndex then
if AttackUnit:IsAlive() and AttackUnit:IsGround() then if AttackUnit then
local HasRadar = AttackUnit:HasSEAD() if AttackUnit:IsAlive() and AttackUnit:IsGround() then
if HasRadar then local HasRadar = AttackUnit:HasSEAD()
self:F( { "SEAD Unit:", AttackUnit:GetName() } ) if HasRadar then
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude ) self:F( { "SEAD Unit:", AttackUnit:GetName() } )
break AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
end
end end
end end
end end