mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Optimizations
This commit is contained in:
parent
5a5340431e
commit
1c063ca308
@ -345,7 +345,7 @@ function AI_A2A_PATROL:onafterRoute( AIPatrol, From, Event, To )
|
|||||||
AIPatrol:OptionROEReturnFire()
|
AIPatrol:OptionROEReturnFire()
|
||||||
AIPatrol:OptionROTEvadeFire()
|
AIPatrol:OptionROTEvadeFire()
|
||||||
|
|
||||||
AIPatrol:Route( PatrolRoute, 0.5 )
|
AIPatrol:Route( PatrolRoute, 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -135,7 +135,7 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
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( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
else
|
else
|
||||||
DefenderGroup:OptionROEOpenFire()
|
DefenderGroup:OptionROEOpenFire()
|
||||||
DefenderGroup:OptionROTEvadeFire()
|
DefenderGroup:OptionROTEvadeFire()
|
||||||
@ -144,11 +144,11 @@ function AI_A2G_BAI:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||||
end
|
end
|
||||||
|
|
||||||
DefenderGroup:Route( EngageRoute, 0.5 )
|
DefenderGroup:Route( EngageRoute, self.TaskDelay )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:__RTB( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -133,7 +133,7 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
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( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
else
|
else
|
||||||
DefenderGroup:OptionROEOpenFire()
|
DefenderGroup:OptionROEOpenFire()
|
||||||
DefenderGroup:OptionROTEvadeFire()
|
DefenderGroup:OptionROTEvadeFire()
|
||||||
@ -142,12 +142,12 @@ function AI_A2G_CAS:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit
|
|||||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||||
end
|
end
|
||||||
|
|
||||||
DefenderGroup:Route( EngageRoute, 0.5 )
|
DefenderGroup:Route( EngageRoute, self.TaskDelay )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:__RTB( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -295,10 +295,10 @@ end
|
|||||||
--- @param Wrapper.Group#GROUP AIControllable
|
--- @param Wrapper.Group#GROUP AIControllable
|
||||||
function AI_A2G_ENGAGE.EngageRoute( AIGroup, Fsm )
|
function AI_A2G_ENGAGE.EngageRoute( AIGroup, Fsm )
|
||||||
|
|
||||||
AIGroup:F( { "AI_A2G_ENGAGE.EngageRoute:", AIGroup:GetName() } )
|
AIGroup:I( { "AI_A2G_ENGAGE.EngageRoute:", AIGroup:GetName() } )
|
||||||
|
|
||||||
if AIGroup:IsAlive() then
|
if AIGroup:IsAlive() then
|
||||||
Fsm:__Engage( 0.5 )
|
Fsm:__Engage( Fsm.TaskDelay )
|
||||||
|
|
||||||
--local Task = AIGroup:TaskOrbitCircle( 4000, 400 )
|
--local Task = AIGroup:TaskOrbitCircle( 4000, 400 )
|
||||||
--AIGroup:SetTask( Task )
|
--AIGroup:SetTask( Task )
|
||||||
@ -327,7 +327,7 @@ end
|
|||||||
function AI_A2G_ENGAGE:onafterAbort( AIGroup, From, Event, To )
|
function AI_A2G_ENGAGE:onafterAbort( AIGroup, From, Event, To )
|
||||||
AIGroup:ClearTasks()
|
AIGroup:ClearTasks()
|
||||||
self:Return()
|
self:Return()
|
||||||
self:__RTB( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ function AI_A2G_ENGAGE:OnEventDead( EventData )
|
|||||||
|
|
||||||
if EventData.IniDCSUnit then
|
if EventData.IniDCSUnit then
|
||||||
if self.AttackUnits and self.AttackUnits[EventData.IniUnit] then
|
if self.AttackUnits and self.AttackUnits[EventData.IniUnit] then
|
||||||
self:__Destroy( 1, EventData )
|
self:__Destroy( self.TaskDelay, EventData )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -234,12 +234,12 @@ function AI_A2G_PATROL:onafterPatrol( AIPatrol, From, Event, To )
|
|||||||
|
|
||||||
self:ClearTargetDistance()
|
self:ClearTargetDistance()
|
||||||
|
|
||||||
self:__Route( 1 )
|
self:__Route( self.TaskDelay )
|
||||||
|
|
||||||
AIPatrol:OnReSpawn(
|
AIPatrol:OnReSpawn(
|
||||||
function( PatrolGroup )
|
function( PatrolGroup )
|
||||||
self:__Reset( 1 )
|
self:__Reset( self.TaskDelay )
|
||||||
self:__Route( 5 )
|
self:__Route( self.TaskDelay )
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -306,7 +306,7 @@ function AI_A2G_PATROL:onafterRoute( AIPatrol, From, Event, To )
|
|||||||
AIPatrol:OptionROEReturnFire()
|
AIPatrol:OptionROEReturnFire()
|
||||||
AIPatrol:OptionROTEvadeFire()
|
AIPatrol:OptionROTEvadeFire()
|
||||||
|
|
||||||
AIPatrol:Route( PatrolRoute, 0.5 )
|
AIPatrol:Route( PatrolRoute, self.TaskDelay )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -314,10 +314,10 @@ end
|
|||||||
--- @param Wrapper.Group#GROUP AIPatrol
|
--- @param Wrapper.Group#GROUP AIPatrol
|
||||||
function AI_A2G_PATROL.Resume( AIPatrol, Fsm )
|
function AI_A2G_PATROL.Resume( AIPatrol, Fsm )
|
||||||
|
|
||||||
AIPatrol:I( { "AI_A2G_PATROL.Resume:", AIPatrol:GetName() } )
|
AIPatrol:F( { "AI_A2G_PATROL.Resume:", AIPatrol:GetName() } )
|
||||||
if AIPatrol:IsAlive() then
|
if AIPatrol:IsAlive() then
|
||||||
Fsm:__Reset( 1 )
|
Fsm:__Reset( self.TaskDelay )
|
||||||
Fsm:__Route( 5 )
|
Fsm:__Route( self.TaskDelay )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -191,7 +191,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
|||||||
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( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
else
|
else
|
||||||
DefenderGroup:OptionROEOpenFire()
|
DefenderGroup:OptionROEOpenFire()
|
||||||
DefenderGroup:OptionROTVertical()
|
DefenderGroup:OptionROTVertical()
|
||||||
@ -202,7 +202,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
|||||||
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
EngageRoute[#EngageRoute].task = DefenderGroup:TaskCombo( AttackTasks )
|
||||||
end
|
end
|
||||||
|
|
||||||
DefenderGroup:Route( EngageRoute, 2 )
|
DefenderGroup:Route( EngageRoute, self.TaskDelay )
|
||||||
|
|
||||||
-- else
|
-- else
|
||||||
-- local AttackTasks = {}
|
-- local AttackTasks = {}
|
||||||
@ -230,7 +230,7 @@ function AI_A2G_SEAD:onafterEngage( DefenderGroup, From, Event, To, AttackSetUni
|
|||||||
else
|
else
|
||||||
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:E( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:__RTB( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,8 @@ AI_AIR = {
|
|||||||
ClassName = "AI_AIR",
|
ClassName = "AI_AIR",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AI_AIR.TaskDelay = 0.5 -- The delay of each task given to the AI.
|
||||||
|
|
||||||
--- Creates a new AI_AIR process.
|
--- Creates a new AI_AIR process.
|
||||||
-- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup The group object to receive the A2G Process.
|
-- @param Wrapper.Group#GROUP AIGroup The group object to receive the A2G Process.
|
||||||
@ -524,7 +526,7 @@ function AI_AIR:onafterStatus()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if RTB == true then
|
if RTB == true then
|
||||||
self:__RTB( 0.5 )
|
self:__RTB( self.TaskDelay )
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self:Is("Home") then
|
if not self:Is("Home") then
|
||||||
@ -551,7 +553,7 @@ function AI_AIR.RTBHold( AIGroup, Fsm )
|
|||||||
|
|
||||||
AIGroup:F( { "AI_AIR.RTBHold:", AIGroup:GetName() } )
|
AIGroup:F( { "AI_AIR.RTBHold:", AIGroup:GetName() } )
|
||||||
if AIGroup:IsAlive() then
|
if AIGroup:IsAlive() then
|
||||||
Fsm:__RTB( 0.5 )
|
Fsm:__RTB( Fsm.TaskDelay )
|
||||||
Fsm:Return()
|
Fsm:Return()
|
||||||
local Task = AIGroup:TaskOrbitCircle( 4000, 400 )
|
local Task = AIGroup:TaskOrbitCircle( 4000, 400 )
|
||||||
AIGroup:SetTask( Task )
|
AIGroup:SetTask( Task )
|
||||||
@ -612,18 +614,16 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
EngageRoute[#EngageRoute+1] = FromRTBRoutePoint
|
EngageRoute[#EngageRoute+1] = FromRTBRoutePoint
|
||||||
EngageRoute[#EngageRoute+1] = ToRTBRoutePoint
|
EngageRoute[#EngageRoute+1] = ToRTBRoutePoint
|
||||||
|
|
||||||
|
local Tasks = {}
|
||||||
|
Tasks[#Tasks+1] = AIGroup:TaskFunction( "AI_A2G_ENGAGE.RTBRoute", self )
|
||||||
|
|
||||||
|
EngageRoute[#EngageRoute].task = AIGroup:TaskCombo( Tasks )
|
||||||
|
|
||||||
AIGroup:OptionROEHoldFire()
|
AIGroup:OptionROEHoldFire()
|
||||||
AIGroup:OptionROTEvadeFire()
|
AIGroup:OptionROTEvadeFire()
|
||||||
|
|
||||||
--- Now we're going to do something special, we're going to call a function from a waypoint action at the AIControllable...
|
|
||||||
AIGroup:WayPointInitialize( EngageRoute )
|
|
||||||
|
|
||||||
local Tasks = {}
|
|
||||||
Tasks[#Tasks+1] = AIGroup:TaskFunction( "AI_AIR.RTBRoute", self )
|
|
||||||
EngageRoute[#EngageRoute].task = AIGroup:TaskCombo( Tasks )
|
|
||||||
|
|
||||||
--- NOW ROUTE THE GROUP!
|
--- NOW ROUTE THE GROUP!
|
||||||
AIGroup:Route( EngageRoute, 0 )
|
AIGroup:Route( EngageRoute, self.TaskDelay )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -670,7 +670,7 @@ function AI_AIR.Resume( AIGroup, Fsm )
|
|||||||
|
|
||||||
AIGroup:I( { "AI_AIR.Resume:", AIGroup:GetName() } )
|
AIGroup:I( { "AI_AIR.Resume:", AIGroup:GetName() } )
|
||||||
if AIGroup:IsAlive() then
|
if AIGroup:IsAlive() then
|
||||||
Fsm:__RTB( 0.5 )
|
Fsm:__RTB( Fsm.TaskDelay )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -690,10 +690,19 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
|||||||
|
|
||||||
--- Calculate the target route point.
|
--- Calculate the target route point.
|
||||||
|
|
||||||
local CurrentCoord = AIGroup:GetCoordinate()
|
local FromRefuelCoord = AIGroup:GetCoordinate()
|
||||||
local ToRefuelCoord = Tanker:GetCoordinate()
|
local ToRefuelCoord = Tanker:GetCoordinate()
|
||||||
local ToRefuelSpeed = math.random( self.PatrolMinSpeed, self.PatrolMaxSpeed )
|
local ToRefuelSpeed = math.random( self.PatrolMinSpeed, self.PatrolMaxSpeed )
|
||||||
|
|
||||||
|
--- Create a route point of type air.
|
||||||
|
local FromRefuelRoutePoint = FromRefuelCoord:WaypointAir(
|
||||||
|
self.PatrolAltType,
|
||||||
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
|
ToRefuelSpeed,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local ToRefuelRoutePoint = ToRefuelCoord:WaypointAir(
|
local ToRefuelRoutePoint = ToRefuelCoord:WaypointAir(
|
||||||
self.PatrolAltType,
|
self.PatrolAltType,
|
||||||
@ -705,7 +714,7 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
|||||||
|
|
||||||
self:F( { ToRefuelSpeed = ToRefuelSpeed } )
|
self:F( { ToRefuelSpeed = ToRefuelSpeed } )
|
||||||
|
|
||||||
RefuelRoute[#RefuelRoute+1] = ToRefuelRoutePoint
|
RefuelRoute[#RefuelRoute+1] = FromRefuelRoutePoint
|
||||||
RefuelRoute[#RefuelRoute+1] = ToRefuelRoutePoint
|
RefuelRoute[#RefuelRoute+1] = ToRefuelRoutePoint
|
||||||
|
|
||||||
AIGroup:OptionROEHoldFire()
|
AIGroup:OptionROEHoldFire()
|
||||||
@ -716,7 +725,7 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
|||||||
Tasks[#Tasks+1] = AIGroup:TaskFunction( self:GetClassName() .. ".Resume", self )
|
Tasks[#Tasks+1] = AIGroup:TaskFunction( self:GetClassName() .. ".Resume", self )
|
||||||
RefuelRoute[#RefuelRoute].task = AIGroup:TaskCombo( Tasks )
|
RefuelRoute[#RefuelRoute].task = AIGroup:TaskCombo( Tasks )
|
||||||
|
|
||||||
AIGroup:Route( RefuelRoute, 0.5 )
|
AIGroup:Route( RefuelRoute, self.TaskDelay )
|
||||||
else
|
else
|
||||||
self:RTB()
|
self:RTB()
|
||||||
end
|
end
|
||||||
@ -739,7 +748,7 @@ function AI_AIR:OnCrash( EventData )
|
|||||||
if self.Controllable:IsAlive() and EventData.IniDCSGroupName == self.Controllable:GetName() then
|
if self.Controllable:IsAlive() and EventData.IniDCSGroupName == self.Controllable:GetName() then
|
||||||
self:E( self.Controllable:GetUnits() )
|
self:E( self.Controllable:GetUnits() )
|
||||||
if #self.Controllable:GetUnits() == 1 then
|
if #self.Controllable:GetUnits() == 1 then
|
||||||
self:__Crash( 1, EventData )
|
self:__Crash( self.TaskDelay, EventData )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -749,7 +758,7 @@ end
|
|||||||
function AI_AIR:OnEjection( EventData )
|
function AI_AIR:OnEjection( EventData )
|
||||||
|
|
||||||
if self.Controllable:IsAlive() and EventData.IniDCSGroupName == self.Controllable:GetName() then
|
if self.Controllable:IsAlive() and EventData.IniDCSGroupName == self.Controllable:GetName() then
|
||||||
self:__Eject( 1, EventData )
|
self:__Eject( self.TaskDelay, EventData )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -758,6 +767,6 @@ end
|
|||||||
function AI_AIR:OnPilotDead( EventData )
|
function AI_AIR:OnPilotDead( EventData )
|
||||||
|
|
||||||
if self.Controllable:IsAlive() and EventData.IniDCSGroupName == self.Controllable:GetName() then
|
if self.Controllable:IsAlive() and EventData.IniDCSGroupName == self.Controllable:GetName() then
|
||||||
self:__PilotDead( 1, EventData )
|
self:__PilotDead( self.TaskDelay, EventData )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -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:I( "After SetTask" )
|
self:F( { 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,6 +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 } )
|
||||||
else
|
else
|
||||||
self.TaskScheduler:Schedule( self, SetTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( self, SetTask, { DCSTask }, WaitTime )
|
||||||
end
|
end
|
||||||
@ -1036,7 +1037,7 @@ end
|
|||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param #number Altitude The altitude [m] to hold the position.
|
-- @param #number Altitude The altitude [m] to hold the position.
|
||||||
-- @param #number Speed The speed [m/s] flying when holding the position.
|
-- @param #number Speed The speed [m/s] flying when holding the position.
|
||||||
-- @param Core.Point#COORDINATE Coordinate The coordinate where to orbit.
|
-- @param Core.Point#COORDINATE Coordinate (optional) The coordinate where to orbit. If the coordinate is not given, then the current position of the controllable is used.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:TaskOrbitCircle( Altitude, Speed, Coordinate )
|
function CONTROLLABLE:TaskOrbitCircle( Altitude, Speed, Coordinate )
|
||||||
self:F2( { self.ControllableName, Altitude, Speed } )
|
self:F2( { self.ControllableName, Altitude, Speed } )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user