mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
ooofff! waypoint functions and route setting is now working how i wanted it to work
This commit is contained in:
parent
17838d7099
commit
09776a60c9
@ -197,7 +197,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Repeat then
|
if Repeat then
|
||||||
self:__CAP( self:GetCAPDelay( SquadronName ), SquadronName, true )
|
self:__CAP( -self:GetCAPDelay( SquadronName ), SquadronName, true )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
DefendersCount = DefendersCount + AIGroup:GetSize()
|
DefendersCount = DefendersCount + AIGroup:GetSize()
|
||||||
|
|
||||||
local Fsm = AI_A2A_INTERCEPT:New( AIGroup )
|
local Fsm = AI_A2A_INTERCEPT:New( AIGroup, Intercept.MinSpeed, Intercept.MaxSpeed )
|
||||||
Fsm:__Engage( 1, TargetSetUnit ) -- Engage on the TargetSetUnit
|
Fsm:__Engage( 1, TargetSetUnit ) -- Engage on the TargetSetUnit
|
||||||
|
|
||||||
self.DefenderTasks = self.DefenderTasks or {}
|
self.DefenderTasks = self.DefenderTasks or {}
|
||||||
@ -374,6 +374,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
local Cap = self.DefenderSquadrons[SquadronName].Cap
|
local Cap = self.DefenderSquadrons[SquadronName].Cap
|
||||||
if Cap then
|
if Cap then
|
||||||
local CapCount = self:CountCapAirborne( SquadronName )
|
local CapCount = self:CountCapAirborne( SquadronName )
|
||||||
|
self:F( { CapCount = CapCount, CapLimit = Cap.Limit } )
|
||||||
if CapCount < Cap.Limit then
|
if CapCount < Cap.Limit then
|
||||||
local Probability = math.random()
|
local Probability = math.random()
|
||||||
if Probability <= Cap.Probability then
|
if Probability <= Cap.Probability then
|
||||||
@ -393,6 +394,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
local Intercept = self.DefenderSquadrons[SquadronName].Intercept
|
local Intercept = self.DefenderSquadrons[SquadronName].Intercept
|
||||||
Intercept.Name = SquadronName
|
Intercept.Name = SquadronName
|
||||||
|
Intercept.MinSpeed = MinSpeed
|
||||||
Intercept.MaxSpeed = MaxSpeed
|
Intercept.MaxSpeed = MaxSpeed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -309,11 +309,12 @@ end
|
|||||||
-- todo: need to fix this global function
|
-- todo: need to fix this global function
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AIControllable
|
--- @param Wrapper.Group#GROUP AIControllable
|
||||||
function _NewEngageInterceptRoute( AIControllable )
|
function AI_A2A_INTERCEPT.InterceptRoute( AIControllable )
|
||||||
|
|
||||||
AIControllable:T( "NewEngageRoute" )
|
AIControllable:T( "NewEngageRoute" )
|
||||||
local EngageZone = AIControllable:GetState( AIControllable, "EngageZone" ) -- AI.AI_Cap#AI_A2A_INTERCEPT
|
local EngageZone = AIControllable:GetState( AIControllable, "EngageZone" ) -- AI.AI_Cap#AI_A2A_INTERCEPT
|
||||||
EngageZone:__Engage( 1 )
|
EngageZone:__Engage( 1 )
|
||||||
|
AIControllable:MessageToAll( AIControllable:GetName() .. " Engaging", 15 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A_INTERCEPT self
|
--- @param #AI_A2A_INTERCEPT self
|
||||||
@ -357,49 +358,42 @@ function AI_A2A_INTERCEPT:onafterEngage( AIGroup, From, Event, To, AttackSetUnit
|
|||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
|
|
||||||
local CurrentCoord = AIGroup:GetCoordinate()
|
local CurrentCoord = AIGroup:GetCoordinate()
|
||||||
|
local ToTargetCoord = self.AttackSetUnit:GetFirst():GetCoordinate()
|
||||||
local ToTargetSpeed = math.random( self.MinSpeed, self.MaxSpeed )
|
local ToTargetSpeed = math.random( self.MinSpeed, self.MaxSpeed )
|
||||||
|
local ToInterceptAngle = CurrentCoord:GetAngleDegrees( CurrentCoord:GetDirectionVec3( ToTargetCoord ) )
|
||||||
|
self:F( { Angle = ToInterceptAngle, ToTargetSpeed = ToTargetSpeed } )
|
||||||
|
|
||||||
if not AIGroup:GetUnit(1):IsAboveRunway() then
|
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
|
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
-- local CurrentRoutePoint = CurrentCoord:RoutePointAir(
|
||||||
local CurrentSpeed = AIGroup:GetUnit(1):GetVelocityKMH()
|
-- self.PatrolAltType,
|
||||||
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
-- POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
local CurrentRoutePoint = CurrentCoord:RoutePointAir(
|
-- POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
self.PatrolAltType,
|
-- ToTargetSpeed,
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
-- true
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
-- )
|
||||||
ToTargetSpeed,
|
-- EngageRoute[#EngageRoute+1] = CurrentRoutePoint
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = CurrentRoutePoint
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Find the target point.
|
--- Find the target point.
|
||||||
|
|
||||||
|
|
||||||
local ToTargetCoord = self.AttackSetUnit:GetFirst():GetCoordinate()
|
|
||||||
|
|
||||||
local ToInterceptAngle = CurrentCoord:GetAngleDegrees( CurrentCoord:GetDirectionVec3( ToTargetCoord ) )
|
|
||||||
local ToInterceptCoord = CurrentCoord:Translate( 5000, ToInterceptAngle )
|
|
||||||
|
|
||||||
self:T2( { self.MinSpeed, self.MaxSpeed, ToTargetSpeed } )
|
self:T2( { self.MinSpeed, self.MaxSpeed, ToTargetSpeed } )
|
||||||
|
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local ToPatrolRoutePoint = ToInterceptCoord:RoutePointAir(
|
local ToPatrolRoutePoint = CurrentCoord:Translate( 5000, ToInterceptAngle ):RoutePointAir(
|
||||||
self.PatrolAltType,
|
self.PatrolAltType,
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
ToTargetSpeed,
|
ToTargetSpeed,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = ToPatrolRoutePoint
|
EngageRoute[#EngageRoute+1] = ToPatrolRoutePoint
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AIGroup:OptionROEOpenFire()
|
AIGroup:OptionROEOpenFire()
|
||||||
AIGroup:OptionROTPassiveDefense()
|
AIGroup:OptionROTPassiveDefense()
|
||||||
|
|
||||||
@ -418,15 +412,14 @@ function AI_A2A_INTERCEPT:onafterEngage( AIGroup, From, Event, To, AttackSetUnit
|
|||||||
|
|
||||||
|
|
||||||
if #AttackTasks == 0 then
|
if #AttackTasks == 0 then
|
||||||
self:E("No targets found -> Going back to Patrolling")
|
self:E("No targets found -> Going RTB")
|
||||||
self:__RTB( 1 )
|
self:__RTB( 1 )
|
||||||
else
|
else
|
||||||
|
AttackTasks[#AttackTasks+1] = AIGroup:TaskFunction( 1, #AttackTasks, "AI_A2A_INTERCEPT.InterceptRoute" )
|
||||||
EngageRoute[1].task = AIGroup:TaskCombo( AttackTasks )
|
EngageRoute[1].task = AIGroup:TaskCombo( AttackTasks )
|
||||||
|
|
||||||
--- Do a trick, link the NewEngageRoute function of the object to the AIControllable in a temporary variable ...
|
--- Do a trick, link the NewEngageRoute function of the object to the AIControllable in a temporary variable ...
|
||||||
AIGroup:SetState( AIGroup, "EngageZone", self )
|
AIGroup:SetState( AIGroup, "EngageZone", self )
|
||||||
|
|
||||||
AIGroup:WayPointFunction( #EngageRoute, 1, "_NewEngageCapRoute" )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- NOW ROUTE THE GROUP!
|
--- NOW ROUTE THE GROUP!
|
||||||
|
|||||||
@ -2194,7 +2194,7 @@ function CONTROLLABLE:TaskFunction( WayPoint, WayPointIndex, FunctionString, Fun
|
|||||||
), WayPointIndex
|
), WayPointIndex
|
||||||
)
|
)
|
||||||
|
|
||||||
self:T3( DCSTask )
|
self:T( DCSTask )
|
||||||
|
|
||||||
return DCSTask
|
return DCSTask
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user