Improvements

This commit is contained in:
FlightControl
2019-02-25 19:16:18 +01:00
parent d874456361
commit 1ff41ec7ec
5 changed files with 73 additions and 46 deletions

View File

@@ -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