mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Fixed issues with CAS and CAP
* AI_CAP_ZONE: Fixed CAP engaging. * AI_CAS_ZONE: Fixed CAS engaging.
This commit is contained in:
parent
9226ab9fa9
commit
ec7cc9e547
@ -358,16 +358,20 @@ function AI_CAP_ZONE:onafterStart( Controllable, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- todo: need to fix this global function
|
|
||||||
|
|
||||||
--- @param Wrapper.Controllable#CONTROLLABLE AIControllable
|
--- @param AI.AI_CAP#AI_CAP_ZONE
|
||||||
function _NewEngageCapRoute( AIControllable )
|
-- @param Wrapper.Group#GROUP EngageGroup
|
||||||
|
function AI_CAP_ZONE.EngageRoute( EngageGroup, Fsm )
|
||||||
|
|
||||||
AIControllable:T( "NewEngageRoute" )
|
EngageGroup:F( { "AI_CAP_ZONE.EngageRoute:", EngageGroup:GetName() } )
|
||||||
local EngageZone = AIControllable:GetState( AIControllable, "EngageZone" ) -- AI.AI_Cap#AI_CAP_ZONE
|
|
||||||
EngageZone:__Engage( 1 )
|
if EngageGroup:IsAlive() then
|
||||||
|
Fsm:__Engage( 1 )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_CAP_ZONE self
|
--- @param #AI_CAP_ZONE self
|
||||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
|
||||||
-- @param #string From The From State string.
|
-- @param #string From The From State string.
|
||||||
@ -503,28 +507,20 @@ function AI_CAP_ZONE:onafterEngage( Controllable, From, Event, To )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Now we're going to do something special, we're going to call a function from a waypoint action at the AIControllable...
|
|
||||||
self.Controllable:WayPointInitialize( EngageRoute )
|
|
||||||
|
|
||||||
|
|
||||||
if #AttackTasks == 0 then
|
if #AttackTasks == 0 then
|
||||||
self:F("No targets found -> Going back to Patrolling")
|
self:F("No targets found -> Going back to Patrolling")
|
||||||
self:__Abort( 1 )
|
self:__Abort( 1 )
|
||||||
self:__Route( 1 )
|
self:__Route( 1 )
|
||||||
self:SetDetectionActivated()
|
self:SetDetectionActivated()
|
||||||
else
|
else
|
||||||
|
|
||||||
|
AttackTasks[#AttackTasks+1] = Controllable:TaskFunction( "AI_CAP_ZONE.EngageRoute", self )
|
||||||
EngageRoute[1].task = Controllable:TaskCombo( AttackTasks )
|
EngageRoute[1].task = Controllable:TaskCombo( AttackTasks )
|
||||||
|
|
||||||
--- Do a trick, link the NewEngageRoute function of the object to the AIControllable in a temporary variable ...
|
|
||||||
self.Controllable:SetState( self.Controllable, "EngageZone", self )
|
|
||||||
|
|
||||||
self.Controllable:WayPointFunction( #EngageRoute, 1, "_NewEngageCapRoute" )
|
|
||||||
|
|
||||||
self:SetDetectionDeactivated()
|
self:SetDetectionDeactivated()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- NOW ROUTE THE GROUP!
|
Controllable:Route( EngageRoute, 0.5 )
|
||||||
self.Controllable:WayPointExecute( 1, 2 )
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -373,12 +373,15 @@ function AI_CAS_ZONE:onafterStart( Controllable, From, Event, To )
|
|||||||
self:SetDetectionDeactivated() -- When not engaging, set the detection off.
|
self:SetDetectionDeactivated() -- When not engaging, set the detection off.
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param Wrapper.Controllable#CONTROLLABLE AIControllable
|
--- @param AI.AI_CAS#AI_CAS_ZONE
|
||||||
function _NewEngageRoute( AIControllable )
|
-- @param Wrapper.Group#GROUP EngageGroup
|
||||||
|
function AI_CAS_ZONE.EngageRoute( EngageGroup, Fsm )
|
||||||
|
|
||||||
AIControllable:T( "NewEngageRoute" )
|
EngageGroup:F( { "AI_CAS_ZONE.EngageRoute:", EngageGroup:GetName() } )
|
||||||
local EngageZone = AIControllable:GetState( AIControllable, "EngageZone" ) -- AI.AI_Cas#AI_CAS_ZONE
|
|
||||||
EngageZone:__Engage( 1, EngageZone.EngageSpeed, EngageZone.EngageAltitude, EngageZone.EngageWeaponExpend, EngageZone.EngageAttackQty, EngageZone.EngageDirection )
|
if EngageGroup:IsAlive() then
|
||||||
|
Fsm:__Engage( 1, Fsm.EngageSpeed, Fsm.EngageAltitude, Fsm.EngageWeaponExpend, Fsm.EngageAttackQty, Fsm.EngageDirection )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -464,6 +467,9 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
|
|
||||||
if Controllable:IsAlive() then
|
if Controllable:IsAlive() then
|
||||||
|
|
||||||
|
Controllable:OptionROEOpenFire()
|
||||||
|
Controllable:OptionROTVertical()
|
||||||
|
|
||||||
local EngageRoute = {}
|
local EngageRoute = {}
|
||||||
|
|
||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
@ -485,7 +491,7 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
|
|
||||||
local AttackTasks = {}
|
local AttackTasks = {}
|
||||||
|
|
||||||
for DetectedUnitID, DetectedUnit in pairs( self.DetectedUnits ) do
|
for DetectedUnit, Detected in pairs( self.DetectedUnits ) do
|
||||||
local DetectedUnit = DetectedUnit -- Wrapper.Unit#UNIT
|
local DetectedUnit = DetectedUnit -- Wrapper.Unit#UNIT
|
||||||
self:T( DetectedUnit )
|
self:T( DetectedUnit )
|
||||||
if DetectedUnit:IsAlive() then
|
if DetectedUnit:IsAlive() then
|
||||||
@ -503,7 +509,8 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
EngageRoute[1].task = Controllable:TaskCombo( AttackTasks )
|
AttackTasks[#AttackTasks+1] = Controllable:TaskFunction( "AI_CAS_ZONE.EngageRoute", self )
|
||||||
|
EngageRoute[#EngageRoute].task = Controllable:TaskCombo( AttackTasks )
|
||||||
|
|
||||||
--- Define a random point in the @{Zone}. The AI will fly to that point within the zone.
|
--- Define a random point in the @{Zone}. The AI will fly to that point within the zone.
|
||||||
|
|
||||||
@ -524,20 +531,8 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
)
|
)
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = ToTargetRoutePoint
|
EngageRoute[#EngageRoute+1] = ToTargetRoutePoint
|
||||||
|
|
||||||
--- Now we're going to do something special, we're going to call a function from a waypoint action at the AIControllable...
|
Controllable:Route( EngageRoute, 0.5 )
|
||||||
Controllable:WayPointInitialize( EngageRoute )
|
|
||||||
|
|
||||||
--- Do a trick, link the NewEngageRoute function of the object to the AIControllable in a temporary variable ...
|
|
||||||
Controllable:SetState( Controllable, "EngageZone", self )
|
|
||||||
|
|
||||||
Controllable:WayPointFunction( #EngageRoute, 1, "_NewEngageRoute" )
|
|
||||||
|
|
||||||
--- NOW ROUTE THE GROUP!
|
|
||||||
Controllable:WayPointExecute( 1 )
|
|
||||||
|
|
||||||
Controllable:OptionROEOpenFire()
|
|
||||||
Controllable:OptionROTVertical()
|
|
||||||
|
|
||||||
self:SetRefreshTimeInterval( 2 )
|
self:SetRefreshTimeInterval( 2 )
|
||||||
self:SetDetectionActivated()
|
self:SetDetectionActivated()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user