mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updates
This commit is contained in:
parent
1c063ca308
commit
77bee89ea5
@ -74,61 +74,60 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
|
|
||||||
if DefenderGroup:IsAlive() then
|
if DefenderGroup:IsAlive() then
|
||||||
|
|
||||||
|
local EngageAltitude = math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude )
|
||||||
|
local EngageSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
||||||
|
|
||||||
-- Determine the distance to the target.
|
-- Determine the distance to the target.
|
||||||
-- If it is less than 10km, then attack without a route.
|
-- If it is less than 10km, then attack without a route.
|
||||||
-- Otherwise perform a route attack.
|
-- Otherwise perform a route attack.
|
||||||
|
|
||||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||||
DefenderCoord:SetY( math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude ) ) -- Ground targets don't have an altitude.
|
DefenderCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetCoord = self.AttackSetUnit:GetFirst():GetPointVec3()
|
local TargetCoord = self.AttackSetUnit:GetFirst():GetPointVec3()
|
||||||
TargetCoord:SetY( math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude ) ) -- Ground targets don't have an altitude.
|
TargetCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
||||||
|
|
||||||
local EngageRoute = {}
|
local EngageRoute = {}
|
||||||
|
|
||||||
local ToTargetSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
|
||||||
|
|
||||||
--- Calculate the target route point.
|
--- Calculate the target route point.
|
||||||
|
|
||||||
local FromWP = DefenderCoord:WaypointAir(
|
local FromWP = DefenderCoord:WaypointAir(
|
||||||
self.PatrolAltType or "RADIO",
|
self.PatrolAltType or "RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
ToTargetSpeed,
|
EngageSpeed,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = FromWP
|
EngageRoute[#EngageRoute+1] = FromWP
|
||||||
|
|
||||||
local ToCoord = self.AttackSetUnit:GetFirst():GetCoordinate()
|
self:SetTargetDistance( TargetCoord ) -- For RTB status check
|
||||||
self:SetTargetDistance( ToCoord ) -- For RTB status check
|
|
||||||
|
|
||||||
local FromEngageAngle = ToCoord:GetAngleDegrees( ToCoord:GetDirectionVec3( DefenderCoord ) )
|
local FromEngageAngle = TargetCoord:GetAngleDegrees( TargetCoord:GetDirectionVec3( DefenderCoord ) )
|
||||||
local EngageDistance = ( DefenderGroup:IsHelicopter() and 5000 ) or ( DefenderGroup:IsAirPlane() and 10000 )
|
local EngageDistance = ( DefenderGroup:IsHelicopter() and 5000 ) or ( DefenderGroup:IsAirPlane() and 10000 )
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local ToWP = ToCoord:Translate( EngageDistance, FromEngageAngle ):WaypointAir(
|
local ToWP = TargetCoord:Translate( EngageDistance, FromEngageAngle ):WaypointAir(
|
||||||
self.PatrolAltType or "RADIO",
|
self.PatrolAltType or "RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
ToTargetSpeed,
|
EngageSpeed,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
self:F( { Angle = FromEngageAngle, ToTargetSpeed = ToTargetSpeed } )
|
|
||||||
self:F( { self.EngageMinSpeed, self.EngageMaxSpeed, ToTargetSpeed } )
|
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = ToWP
|
EngageRoute[#EngageRoute+1] = ToWP
|
||||||
|
|
||||||
local AttackTasks = {}
|
local AttackTasks = {}
|
||||||
|
|
||||||
for AttackUnitID, AttackUnit in pairs( self.AttackSetUnit:GetSet() ) do
|
for OrderedID, AttackUnit in ipairs( self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 ) ) do
|
||||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
if AttackUnit then
|
||||||
self:T( { "Engage Unit evaluation:", AttackUnit:GetName(), AttackUnit:IsAlive(), AttackUnit:IsGround() } )
|
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||||
self:T( { "Eliminating Unit:", AttackUnit:GetName() } )
|
self:T( { "BAI Unit:", AttackUnit:GetName() } )
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit )
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -139,6 +138,7 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
else
|
else
|
||||||
DefenderGroup:OptionROEOpenFire()
|
DefenderGroup:OptionROEOpenFire()
|
||||||
DefenderGroup:OptionROTEvadeFire()
|
DefenderGroup:OptionROTEvadeFire()
|
||||||
|
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||||
|
|
||||||
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 )
|
||||||
|
|||||||
@ -74,29 +74,26 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
|
|
||||||
if DefenderGroup:IsAlive() then
|
if DefenderGroup:IsAlive() then
|
||||||
|
|
||||||
-- Determine the distance to the target.
|
local EngageAltitude = math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude )
|
||||||
-- If it is less than 10km, then attack without a route.
|
local EngageSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
||||||
-- Otherwise perform a route attack.
|
|
||||||
|
|
||||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||||
DefenderCoord:SetY( math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude ) ) -- Ground targets don't have an altitude.
|
DefenderCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetCoord = self.AttackSetUnit:GetFirst():GetPointVec3()
|
local TargetCoord = self.AttackSetUnit:GetFirst():GetPointVec3()
|
||||||
TargetCoord:SetY( math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude ) ) -- Ground targets don't have an altitude.
|
TargetCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
||||||
|
|
||||||
local EngageRoute = {}
|
local EngageRoute = {}
|
||||||
|
|
||||||
local ToTargetSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
|
||||||
|
|
||||||
--- Calculate the target route point.
|
--- Calculate the target route point.
|
||||||
|
|
||||||
local FromWP = DefenderCoord:WaypointAir(
|
local FromWP = DefenderCoord:WaypointAir(
|
||||||
self.PatrolAltType or "RADIO",
|
self.PatrolAltType or "RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
ToTargetSpeed,
|
EngageSpeed,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -108,25 +105,25 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
local EngageDistance = ( DefenderGroup:IsHelicopter() and 5000 ) or ( DefenderGroup:IsAirPlane() and 10000 )
|
local EngageDistance = ( DefenderGroup:IsHelicopter() and 5000 ) or ( DefenderGroup:IsAirPlane() and 10000 )
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local ToWP = TargetCoord:Translate( EngageDistance, FromEngageAngle ):WaypointAir(
|
local ToWP = TargetCoord:Translate( EngageDistance, FromEngageAngle, true ):WaypointAir(
|
||||||
self.PatrolAltType or "RADIO",
|
self.PatrolAltType or "RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
ToTargetSpeed,
|
EngageSpeed,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
self:F( { Angle = FromEngageAngle, ToTargetSpeed = ToTargetSpeed } )
|
|
||||||
self:F( { self.EngageMinSpeed, self.EngageMaxSpeed, ToTargetSpeed } )
|
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = ToWP
|
EngageRoute[#EngageRoute+1] = ToWP
|
||||||
|
|
||||||
local AttackTasks = {}
|
local AttackTasks = {}
|
||||||
|
|
||||||
for AttackUnitID, AttackUnit in pairs( self.AttackSetUnit:GetSet() ) do
|
for OrderedID, AttackUnit in ipairs( self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 ) ) do
|
||||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
if AttackUnit then
|
||||||
self:T( { "Eliminating Unit:", AttackUnit:GetName() } )
|
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit )
|
self:F( { "CAS Unit:", AttackUnit:GetName() } )
|
||||||
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -137,6 +134,7 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
else
|
else
|
||||||
DefenderGroup:OptionROEOpenFire()
|
DefenderGroup:OptionROEOpenFire()
|
||||||
DefenderGroup:OptionROTEvadeFire()
|
DefenderGroup:OptionROTEvadeFire()
|
||||||
|
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||||
|
|
||||||
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 )
|
||||||
|
|||||||
@ -129,103 +129,80 @@ 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 EngageSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
||||||
|
|
||||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||||
DefenderCoord:SetY( math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude ) ) -- Ground targets don't have an altitude.
|
DefenderCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetCoord = self.AttackSetUnit:GetFirst():GetPointVec3()
|
local TargetCoord = self.AttackSetUnit:GetFirst():GetPointVec3()
|
||||||
TargetCoord:SetY( math.random( self.EngageFloorAltitude, self.EngageCeilingAltitude ) ) -- Ground targets don't have an altitude.
|
TargetCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
||||||
|
|
||||||
-- if TargetDistance >= 50000 then
|
local EngageRoute = {}
|
||||||
|
|
||||||
local EngageRoute = {}
|
|
||||||
|
|
||||||
local ToTargetSpeed = math.random( self.EngageMinSpeed, self.EngageMaxSpeed )
|
--- Calculate the target route point.
|
||||||
|
|
||||||
--- Calculate the target route point.
|
local FromWP = DefenderCoord:WaypointAir(
|
||||||
|
self.PatrolAltType or "RADIO",
|
||||||
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
|
EngageSpeed,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
local FromWP = DefenderCoord:WaypointAir(
|
EngageRoute[#EngageRoute+1] = FromWP
|
||||||
self.PatrolAltType or "RADIO",
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
ToTargetSpeed,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = FromWP
|
self:SetTargetDistance( TargetCoord ) -- For RTB status check
|
||||||
|
|
||||||
local ToCoord = self.AttackSetUnit:GetFirst():GetCoordinate()
|
local FromEngageAngle = TargetCoord:GetAngleDegrees( TargetCoord:GetDirectionVec3( DefenderCoord ) )
|
||||||
self:SetTargetDistance( ToCoord ) -- For RTB status check
|
local EngageDistance = ( DefenderGroup:IsHelicopter() and 5000 ) or ( DefenderGroup:IsAirPlane() and 25000 )
|
||||||
|
|
||||||
local FromEngageAngle = ToCoord:GetAngleDegrees( ToCoord:GetDirectionVec3( DefenderCoord ) )
|
--- Create a route point of type air, 50km from the center of the attack point.
|
||||||
local EngageDistance = ( DefenderGroup:IsHelicopter() and 5000 ) or ( DefenderGroup:IsAirPlane() and 25000 )
|
|
||||||
|
|
||||||
--- Create a route point of type air, 50km from the center of the attack point.
|
local ToWP = TargetCoord:Translate( EngageDistance, FromEngageAngle, true ):WaypointAir(
|
||||||
local ToWP = ToCoord:Translate( EngageDistance, FromEngageAngle ):WaypointAir(
|
self.PatrolAltType or "RADIO",
|
||||||
self.PatrolAltType or "RADIO",
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
EngageSpeed,
|
||||||
ToTargetSpeed,
|
true
|
||||||
true
|
)
|
||||||
)
|
|
||||||
|
|
||||||
self:F( { Angle = FromEngageAngle, ToTargetSpeed = ToTargetSpeed } )
|
EngageRoute[#EngageRoute+1] = ToWP
|
||||||
self:F( { self.EngageMinSpeed, self.EngageMaxSpeed, ToTargetSpeed } )
|
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = ToWP
|
local AttackTasks = {}
|
||||||
|
|
||||||
local AttackTasks = {}
|
for OrderedID, AttackUnit in ipairs( self.AttackSetUnit:GetSetPerThreatLevel( 10, 0 ) ) do
|
||||||
|
if AttackUnit then
|
||||||
for AttackUnitID, AttackUnit in pairs( self.AttackSetUnit:GetSet() ) do
|
|
||||||
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||||
self:T( { "Engage Unit evaluation:", AttackUnit:GetName(), AttackUnit:IsAlive(), AttackUnit:IsGround() } )
|
|
||||||
local HasRadar = AttackUnit:HasSEAD()
|
local HasRadar = AttackUnit:HasSEAD()
|
||||||
if HasRadar then
|
if HasRadar then
|
||||||
self:T( { "Eliminating Unit:", AttackUnit:GetName() } )
|
self:F( { "SEAD Unit:", AttackUnit:GetName() } )
|
||||||
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit )
|
AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit, false, false, nil, nil, EngageAltitude )
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if #AttackTasks == 0 then
|
if #AttackTasks == 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 )
|
||||||
else
|
else
|
||||||
DefenderGroup:OptionROEOpenFire()
|
DefenderGroup:OptionROEOpenFire()
|
||||||
DefenderGroup:OptionROTVertical()
|
DefenderGroup:OptionROTVertical()
|
||||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||||
--DefenderGroup:OptionRTBAmmo( Weapon.flag.AnyASM )
|
--DefenderGroup:OptionRTBAmmo( Weapon.flag.AnyASM )
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
DefenderGroup:Route( EngageRoute, self.TaskDelay )
|
DefenderGroup:Route( EngageRoute, self.TaskDelay )
|
||||||
|
|
||||||
-- else
|
|
||||||
-- local AttackTasks = {}
|
|
||||||
-- --local AttackUnit = self.AttackSetUnit:GetRandom() -- Wrapper.Unit#UNIT
|
|
||||||
-- for AttackUnitID, AttackUnit in pairs( self.AttackSetUnit:GetSet() ) do
|
|
||||||
-- if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
|
||||||
-- local HasRadar = AttackUnit:HasSEAD()
|
|
||||||
-- if HasRadar then
|
|
||||||
-- self:T( { "Eliminating Unit:", AttackUnit:GetName(), AttackUnit:IsAlive(), AttackUnit:IsGround() } )
|
|
||||||
-- AttackTasks[#AttackTasks+1] = DefenderGroup:TaskAttackUnit( AttackUnit )
|
|
||||||
-- AttackTasks[#AttackTasks+1] = DefenderGroup:TaskFunction( "AI_A2G_ENGAGE.EngageRoute", self )
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- local DefenderTask = DefenderGroup:TaskCombo( AttackTasks )
|
|
||||||
--
|
|
||||||
-- DefenderGroup:OptionROEOpenFire()
|
|
||||||
-- DefenderGroup:OptionROTVertical()
|
|
||||||
-- DefenderGroup:OptionKeepWeaponsOnThreat()
|
|
||||||
-- DefenderGroup:OptionRTBAmmo( Weapon.flag.AnyASM )
|
|
||||||
--
|
|
||||||
-- DefenderGroup:SetTask( DefenderTask, 0 )
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
|
|||||||
@ -615,7 +615,7 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
EngageRoute[#EngageRoute+1] = ToRTBRoutePoint
|
EngageRoute[#EngageRoute+1] = ToRTBRoutePoint
|
||||||
|
|
||||||
local Tasks = {}
|
local Tasks = {}
|
||||||
Tasks[#Tasks+1] = AIGroup:TaskFunction( "AI_A2G_ENGAGE.RTBRoute", self )
|
Tasks[#Tasks+1] = AIGroup:TaskFunction( "AI_AIR.RTBRoute", self )
|
||||||
|
|
||||||
EngageRoute[#EngageRoute].task = AIGroup:TaskCombo( Tasks )
|
EngageRoute[#EngageRoute].task = AIGroup:TaskCombo( Tasks )
|
||||||
|
|
||||||
|
|||||||
@ -2033,6 +2033,54 @@ do -- SET_UNIT
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get the SET of the SET_UNIT **sorted per Threat Level**.
|
||||||
|
--
|
||||||
|
-- @param #SET_UNIT self
|
||||||
|
-- @param #number FromThreatLevel The TreatLevel to start the evaluation **From** (this must be a value between 0 and 10).
|
||||||
|
-- @param #number ToThreatLevel The TreatLevel to stop the evaluation **To** (this must be a value between 0 and 10).
|
||||||
|
-- @return #SET_UNIT self
|
||||||
|
-- @usage
|
||||||
|
--
|
||||||
|
--
|
||||||
|
function SET_UNIT:GetSetPerThreatLevel( FromThreatLevel, ToThreatLevel )
|
||||||
|
self:F2( arg )
|
||||||
|
|
||||||
|
local ThreatLevelSet = {}
|
||||||
|
|
||||||
|
if self:Count() ~= 0 then
|
||||||
|
for UnitName, UnitObject in pairs( self.Set ) do
|
||||||
|
local Unit = UnitObject -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
|
local ThreatLevel = Unit:GetThreatLevel()
|
||||||
|
ThreatLevelSet[ThreatLevel] = ThreatLevelSet[ThreatLevel] or {}
|
||||||
|
ThreatLevelSet[ThreatLevel].Set = ThreatLevelSet[ThreatLevel].Set or {}
|
||||||
|
ThreatLevelSet[ThreatLevel].Set[UnitName] = UnitObject
|
||||||
|
self:F( { ThreatLevel = ThreatLevel, ThreatLevelSet = ThreatLevelSet[ThreatLevel].Set } )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local OrderedPerThreatLevelSet = {}
|
||||||
|
|
||||||
|
local ThreatLevelIncrement = FromThreatLevel <= ToThreatLevel and 1 or -1
|
||||||
|
|
||||||
|
|
||||||
|
for ThreatLevel = FromThreatLevel, ToThreatLevel, ThreatLevelIncrement do
|
||||||
|
self:F( { ThreatLevel = ThreatLevel } )
|
||||||
|
local ThreatLevelItem = ThreatLevelSet[ThreatLevel]
|
||||||
|
if ThreatLevelItem then
|
||||||
|
for UnitName, UnitObject in pairs( ThreatLevelItem.Set ) do
|
||||||
|
table.insert( OrderedPerThreatLevelSet, UnitObject )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return OrderedPerThreatLevelSet
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Iterate the SET_UNIT **sorted *per Threat Level** and call an interator function for each **alive** UNIT, providing the UNIT and optional parameters.
|
--- Iterate the SET_UNIT **sorted *per Threat Level** and call an interator function for each **alive** UNIT, providing the UNIT and optional parameters.
|
||||||
--
|
--
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
|
|||||||
@ -400,7 +400,7 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
|
|||||||
local Controller = self:_GetController()
|
local Controller = self:_GetController()
|
||||||
--self:I( "Before SetTask" )
|
--self:I( "Before SetTask" )
|
||||||
Controller:setTask( DCSTask )
|
Controller:setTask( DCSTask )
|
||||||
self:F( { DCSTask = DCSTask } )
|
self:I( { ControllableName = self:GetName(), DCSTask = DCSTask } )
|
||||||
else
|
else
|
||||||
BASE:E( { DCSControllableName .. " is not alive anymore.", DCSTask = DCSTask } )
|
BASE:E( { DCSControllableName .. " is not alive anymore.", DCSTask = DCSTask } )
|
||||||
end
|
end
|
||||||
@ -408,7 +408,7 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
|
|||||||
|
|
||||||
if not WaitTime or WaitTime == 0 then
|
if not WaitTime or WaitTime == 0 then
|
||||||
SetTask( self, DCSTask )
|
SetTask( self, DCSTask )
|
||||||
self:F( { DCSTask = DCSTask } )
|
self:I( { ControllableName = self:GetName(), DCSTask = DCSTask } )
|
||||||
else
|
else
|
||||||
self.TaskScheduler:Schedule( self, SetTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( self, SetTask, { DCSTask }, WaitTime )
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user