mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-18 13:16:03 +00:00
Got engage working from the air. Now I need to fix:
- Overhead - Correct Defense Type assignment to engage.
This commit is contained in:
@@ -325,53 +325,53 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
self:AddTransition( "*", "Defend", "*" )
|
self:AddTransition( "*", "Defend", "*" )
|
||||||
|
|
||||||
--- GCI Handler OnBefore for AI_A2G_DISPATCHER
|
--- Defend Handler OnBefore for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] OnBeforeGCI
|
-- @function [parent=#AI_A2G_DISPATCHER] OnBeforeDefend
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
--- GCI Handler OnAfter for AI_A2G_DISPATCHER
|
--- Defend Handler OnAfter for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] OnAfterGCI
|
-- @function [parent=#AI_A2G_DISPATCHER] OnAfterDefend
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
|
||||||
--- GCI Trigger for AI_A2G_DISPATCHER
|
--- Defend Trigger for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] GCI
|
-- @function [parent=#AI_A2G_DISPATCHER] Defend
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
|
|
||||||
--- GCI Asynchronous Trigger for AI_A2G_DISPATCHER
|
--- Defend Asynchronous Trigger for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] __GCI
|
-- @function [parent=#AI_A2G_DISPATCHER] __Defend
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
|
|
||||||
self:AddTransition( "*", "ENGAGE", "*" )
|
self:AddTransition( "*", "Engage", "*" )
|
||||||
|
|
||||||
--- ENGAGE Handler OnBefore for AI_A2G_DISPATCHER
|
--- Engage Handler OnBefore for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] OnBeforeENGAGE
|
-- @function [parent=#AI_A2G_DISPATCHER] OnBeforeEngage
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
--- ENGAGE Handler OnAfter for AI_A2G_DISPATCHER
|
--- Engage Handler OnAfter for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] OnAfterENGAGE
|
-- @function [parent=#AI_A2G_DISPATCHER] OnAfterEngage
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
|
||||||
--- ENGAGE Trigger for AI_A2G_DISPATCHER
|
--- Engage Trigger for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] ENGAGE
|
-- @function [parent=#AI_A2G_DISPATCHER] Engage
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
|
|
||||||
--- ENGAGE Asynchronous Trigger for AI_A2G_DISPATCHER
|
--- Engage Asynchronous Trigger for AI_A2G_DISPATCHER
|
||||||
-- @function [parent=#AI_A2G_DISPATCHER] __ENGAGE
|
-- @function [parent=#AI_A2G_DISPATCHER] __Engage
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
|
|
||||||
@@ -618,7 +618,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
--
|
--
|
||||||
function AI_A2G_DISPATCHER:SetDefenseRadius( DefenseRadius )
|
function AI_A2G_DISPATCHER:SetDefenseRadius( DefenseRadius )
|
||||||
|
|
||||||
self.DefenseRadius = DefenseRadius or 40000
|
self.DefenseRadius = DefenseRadius or 100000
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -765,7 +765,24 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- @return #table A list of the defender friendlies nearby, sorted by distance.
|
-- @return #table A list of the defender friendlies nearby, sorted by distance.
|
||||||
function AI_A2G_DISPATCHER:GetDefenderFriendliesNearBy( DetectedItem )
|
function AI_A2G_DISPATCHER:GetDefenderFriendliesNearBy( DetectedItem )
|
||||||
|
|
||||||
local DefenderFriendliesNearBy = self.Detection:GetFriendliesDistance( DetectedItem )
|
-- local DefenderFriendliesNearBy = self.Detection:GetFriendliesDistance( DetectedItem )
|
||||||
|
|
||||||
|
local DefenderFriendliesNearBy = {}
|
||||||
|
|
||||||
|
local DetectionCoordinate = self.Detection:GetDetectedItemCoordinate( DetectedItem )
|
||||||
|
|
||||||
|
local ScanZone = ZONE_RADIUS:New( "ScanZone", DetectionCoordinate:GetVec2(), self.DefenseRadius )
|
||||||
|
|
||||||
|
ScanZone:Scan( Object.Category.UNIT, { Unit.Category.AIRPLANE, Unit.Category.HELICOPTER } )
|
||||||
|
|
||||||
|
local DefenderUnits = ScanZone:GetScannedUnits()
|
||||||
|
|
||||||
|
for DefenderUnitID, DefenderUnit in pairs( DefenderUnits ) do
|
||||||
|
local DefenderUnit = UNIT:FindByName( DefenderUnit:getName() )
|
||||||
|
|
||||||
|
DefenderFriendliesNearBy[#DefenderFriendliesNearBy+1] = DefenderUnit
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return DefenderFriendliesNearBy
|
return DefenderFriendliesNearBy
|
||||||
end
|
end
|
||||||
@@ -1154,7 +1171,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
if DefenderSquadron.Captured == false then -- We can only spawn new defense if the home airbase has not been captured.
|
if DefenderSquadron.Captured == false then -- We can only spawn new defense if the home airbase has not been captured.
|
||||||
|
|
||||||
if ( not DefenderSquadron.ResourceCount ) or ( DefenderSquadron.ResourceCount and DefenderSquadron.ResourceCount > 0 ) then -- And, if there are sufficient resources.
|
if ( not DefenderSquadron.ResourceCount ) or ( DefenderSquadron.ResourceCount and DefenderSquadron.ResourceCount > 0 ) then -- And, if there are sufficient resources.
|
||||||
if DefenderSquadron[DefenseTaskType] and DefenderSquadron[DefenseTaskType].Defend == true then
|
if DefenderSquadron[DefenseTaskType] and ( DefenderSquadron[DefenseTaskType].Defend == true ) then
|
||||||
return DefenderSquadron, DefenderSquadron[DefenseTaskType]
|
return DefenderSquadron, DefenderSquadron[DefenseTaskType]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2381,7 +2398,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
if Defenders then
|
if Defenders then
|
||||||
|
|
||||||
for DefenderID, Defender in pairs( Defenders ) do
|
for DefenderID, Defender in pairs( Defenders or {} ) do
|
||||||
|
|
||||||
local Fsm = self:GetDefenderTaskFsm( Defender )
|
local Fsm = self:GetDefenderTaskFsm( Defender )
|
||||||
Fsm:__Engage( 1, AttackerDetection.Set ) -- Engage on the TargetSetUnit
|
Fsm:__Engage( 1, AttackerDetection.Set ) -- Engage on the TargetSetUnit
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ function AI_A2G_PATROL:onafterEngage( AIPatrol, From, Event, To, AttackSetUnit )
|
|||||||
for AttackUnitID, AttackUnit in pairs( self.AttackSetUnit:GetSet() ) do
|
for AttackUnitID, AttackUnit in pairs( self.AttackSetUnit:GetSet() ) do
|
||||||
local AttackUnit = AttackUnit -- Wrapper.Unit#UNIT
|
local AttackUnit = AttackUnit -- Wrapper.Unit#UNIT
|
||||||
self:T( { "Attacking Unit:", AttackUnit:GetName(), AttackUnit:IsAlive(), AttackUnit:IsAir() } )
|
self:T( { "Attacking Unit:", AttackUnit:GetName(), AttackUnit:IsAlive(), AttackUnit:IsAir() } )
|
||||||
if AttackUnit:IsAlive() and AttackUnit:IsAir() then
|
if AttackUnit:IsAlive() and AttackUnit:IsGround() then
|
||||||
AttackTasks[#AttackTasks+1] = AIPatrol:TaskAttackUnit( AttackUnit )
|
AttackTasks[#AttackTasks+1] = AIPatrol:TaskAttackUnit( AttackUnit )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -618,6 +618,9 @@ function ZONE_RADIUS:GetVec3( Height )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Scan the zone for the presence of units of the given ObjectCategories.
|
--- Scan the zone for the presence of units of the given ObjectCategories.
|
||||||
-- Note that after a zone has been scanned, the zone can be evaluated by:
|
-- Note that after a zone has been scanned, the zone can be evaluated by:
|
||||||
--
|
--
|
||||||
@@ -629,11 +632,11 @@ end
|
|||||||
-- @{#ZONE_RADIUS.
|
-- @{#ZONE_RADIUS.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param ObjectCategories
|
-- @param ObjectCategories
|
||||||
-- @param Coalition
|
-- @param UnitCategories
|
||||||
-- @usage
|
-- @usage
|
||||||
-- self.Zone:Scan()
|
-- self.Zone:Scan()
|
||||||
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||||
function ZONE_RADIUS:Scan( ObjectCategories )
|
function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
|
||||||
|
|
||||||
self.ScanData = {}
|
self.ScanData = {}
|
||||||
self.ScanData.Coalitions = {}
|
self.ScanData.Coalitions = {}
|
||||||
@@ -660,9 +663,24 @@ function ZONE_RADIUS:Scan( ObjectCategories )
|
|||||||
if ( ObjectCategory == Object.Category.UNIT and ZoneObject:isExist() and ZoneObject:isActive() ) or
|
if ( ObjectCategory == Object.Category.UNIT and ZoneObject:isExist() and ZoneObject:isActive() ) or
|
||||||
(ObjectCategory == Object.Category.STATIC and ZoneObject:isExist()) then
|
(ObjectCategory == Object.Category.STATIC and ZoneObject:isExist()) then
|
||||||
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
||||||
self.ScanData.Coalitions[CoalitionDCSUnit] = true
|
local Include = false
|
||||||
self.ScanData.Units[ZoneObject] = ZoneObject
|
if not UnitCategories then
|
||||||
self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
|
Include = true
|
||||||
|
else
|
||||||
|
local CategoryDCSUnit = ZoneObject:getDesc().category
|
||||||
|
for UnitCategoryID, UnitCategory in pairs( UnitCategories ) do
|
||||||
|
if UnitCategory == CategoryDCSUnit then
|
||||||
|
Include = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if Include then
|
||||||
|
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
||||||
|
self.ScanData.Coalitions[CoalitionDCSUnit] = true
|
||||||
|
self.ScanData.Units[ZoneObject] = ZoneObject
|
||||||
|
self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if ObjectCategory == Object.Category.SCENERY then
|
if ObjectCategory == Object.Category.SCENERY then
|
||||||
local SceneryType = ZoneObject:getTypeName()
|
local SceneryType = ZoneObject:getTypeName()
|
||||||
|
|||||||
Reference in New Issue
Block a user