mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #457 from FlightControl-Master/386-ai-designate
386 ai designate
This commit is contained in:
commit
9586ab9fc6
@ -122,9 +122,9 @@ do -- AI_DESIGNATE
|
|||||||
--- AI_DESIGNATE Constructor. This class is an abstract class and should not be instantiated.
|
--- AI_DESIGNATE Constructor. This class is an abstract class and should not be instantiated.
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
-- @param Functional.Detection#DETECTION_BASE Detection
|
-- @param Functional.Detection#DETECTION_BASE Detection
|
||||||
-- @param Core.Set#SET_GROUP GroupSet The set of groups to designate for.
|
-- @param Core.Set#SET_GROUP AttackSet The Attack collection of GROUP objects to designate and report for.
|
||||||
-- @return #AI_DESIGNATE
|
-- @return #AI_DESIGNATE
|
||||||
function AI_DESIGNATE:New( Detection, GroupSet )
|
function AI_DESIGNATE:New( Detection, AttackSet )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, FSM:New() ) -- #AI_DESIGNATE
|
local self = BASE:Inherit( self, FSM:New() ) -- #AI_DESIGNATE
|
||||||
self:F( { Detection } )
|
self:F( { Detection } )
|
||||||
@ -295,18 +295,22 @@ do -- AI_DESIGNATE
|
|||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
|
|
||||||
self.Detection = Detection
|
self.Detection = Detection
|
||||||
self.GroupSet = GroupSet
|
self.AttackSet = AttackSet
|
||||||
self.RecceSet = Detection:GetDetectionSetGroup()
|
self.RecceSet = Detection:GetDetectionSetGroup()
|
||||||
self.Spots = {}
|
self.Recces = {}
|
||||||
self.Designating = {}
|
self.Designating = {}
|
||||||
|
|
||||||
self:SetLaserCodes( 1688 )
|
self.LaseDuration = 60
|
||||||
|
|
||||||
|
self:SetLaserCodes( 1688 ) -- set self.LaserCodes
|
||||||
|
self:SetAutoLase( false ) -- set self.Autolase
|
||||||
|
|
||||||
self.LaserCodesUsed = {}
|
self.LaserCodesUsed = {}
|
||||||
|
|
||||||
|
|
||||||
self.Detection:__Start( 2 )
|
self.Detection:__Start( 2 )
|
||||||
|
|
||||||
|
self:SetDesignateMenu()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -327,6 +331,29 @@ do -- AI_DESIGNATE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set auto lase.
|
||||||
|
-- Auto lase will start lasing targets immediately when these are in range.
|
||||||
|
-- @param #AI_DESIGNATE self
|
||||||
|
-- @param #boolean AutoLase
|
||||||
|
-- @return #AI_DESIGNATE
|
||||||
|
function AI_DESIGNATE:SetAutoLase( AutoLase )
|
||||||
|
|
||||||
|
self.AutoLase = AutoLase
|
||||||
|
|
||||||
|
local AutoLaseOnOff = ( AutoLase == true ) and "On" or "Off"
|
||||||
|
|
||||||
|
local Recce = self.RecceSet:GetFirst()
|
||||||
|
|
||||||
|
if Recce then
|
||||||
|
Recce:MessageToSetGroup( "Auto Lase " .. AutoLaseOnOff .. ".", 15, self.AttackSet )
|
||||||
|
end
|
||||||
|
|
||||||
|
self:ActivateAutoLase()
|
||||||
|
self:SetDesignateMenu()
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
@ -335,7 +362,11 @@ do -- AI_DESIGNATE
|
|||||||
|
|
||||||
self:__Detect( -60 )
|
self:__Detect( -60 )
|
||||||
|
|
||||||
|
self:ActivateAutoLase()
|
||||||
|
|
||||||
self:SendStatus()
|
self:SendStatus()
|
||||||
|
|
||||||
|
|
||||||
self:SetDesignateMenu()
|
self:SetDesignateMenu()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -357,11 +388,32 @@ do -- AI_DESIGNATE
|
|||||||
|
|
||||||
local RecceLeader = self.RecceSet:GetFirst() -- Wrapper.Group#GROUP
|
local RecceLeader = self.RecceSet:GetFirst() -- Wrapper.Group#GROUP
|
||||||
|
|
||||||
self.GroupSet:ForEachGroup(
|
RecceLeader:MessageToSetGroup( DetectedReport:Text( "\n" ), 15, self.AttackSet )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Coordinates the Auto Lase.
|
||||||
|
-- @param #AI_DESIGNATE self
|
||||||
|
-- @return #AI_DESIGNATE
|
||||||
|
function AI_DESIGNATE:ActivateAutoLase()
|
||||||
|
|
||||||
|
self.AttackSet:Flush()
|
||||||
|
|
||||||
|
self.AttackSet:ForEachGroup(
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP GroupReport
|
--- @param Wrapper.Group#GROUP GroupReport
|
||||||
function( AttackGroup )
|
function( AttackGroup )
|
||||||
RecceLeader:MessageToGroup( DetectedReport:Text( "\n" ), 15, AttackGroup )
|
|
||||||
|
local DetectedItems = self.Detection:GetDetectedItems()
|
||||||
|
|
||||||
|
for Index, DetectedItemData in pairs( DetectedItems ) do
|
||||||
|
if self.AutoLase then
|
||||||
|
if not self.Designating[Index] then
|
||||||
|
self:LaseOn( Index, self.LaseDuration )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -373,9 +425,9 @@ do -- AI_DESIGNATE
|
|||||||
-- @return #AI_DESIGNATE
|
-- @return #AI_DESIGNATE
|
||||||
function AI_DESIGNATE:SetDesignateMenu()
|
function AI_DESIGNATE:SetDesignateMenu()
|
||||||
|
|
||||||
self.GroupSet:Flush()
|
self.AttackSet:Flush()
|
||||||
|
|
||||||
self.GroupSet:ForEachGroup(
|
self.AttackSet:ForEachGroup(
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP GroupReport
|
--- @param Wrapper.Group#GROUP GroupReport
|
||||||
function( AttackGroup )
|
function( AttackGroup )
|
||||||
@ -389,6 +441,15 @@ do -- AI_DESIGNATE
|
|||||||
self:E(DesignateMenu)
|
self:E(DesignateMenu)
|
||||||
AttackGroup:SetState( AttackGroup, "DesignateMenu", DesignateMenu )
|
AttackGroup:SetState( AttackGroup, "DesignateMenu", DesignateMenu )
|
||||||
|
|
||||||
|
-- Set Menu option for auto lase
|
||||||
|
|
||||||
|
if self.AutoLase then
|
||||||
|
MENU_GROUP_COMMAND:New( AttackGroup, "Auto Lase Off", DesignateMenu, self.MenuAutoLase, self, false )
|
||||||
|
else
|
||||||
|
MENU_GROUP_COMMAND:New( AttackGroup, "Auto Lase On", DesignateMenu, self.MenuAutoLase, self, true )
|
||||||
|
end
|
||||||
|
|
||||||
|
MENU_GROUP_COMMAND:New( AttackGroup, "Report Designation Status", DesignateMenu, self.MenuStatus, self, AttackGroup )
|
||||||
|
|
||||||
local DetectedItems = self.Detection:GetDetectedItems()
|
local DetectedItems = self.Detection:GetDetectedItems()
|
||||||
|
|
||||||
@ -398,14 +459,14 @@ do -- AI_DESIGNATE
|
|||||||
|
|
||||||
if not self.Designating[Index] then
|
if not self.Designating[Index] then
|
||||||
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu )
|
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Lase target 60 secs", DetectedMenu, self.MenuLaseOn, self, AttackGroup, Index, 60 )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Lase target 60 secs", DetectedMenu, self.MenuLaseOn, self, Index, 60 )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Lase target 120 secs", DetectedMenu, self.MenuLaseOn, self,AttackGroup, Index, 120 )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Lase target 120 secs", DetectedMenu, self.MenuLaseOn, self, Index, 120 )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke red", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Red )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke red", DetectedMenu, self.MenuSmoke, self, Index, SMOKECOLOR.Red )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke blue", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Blue )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke blue", DetectedMenu, self.MenuSmoke, self, Index, SMOKECOLOR.Blue )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke green", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Green )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke green", DetectedMenu, self.MenuSmoke, self, Index, SMOKECOLOR.Green )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke white", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.White )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke white", DetectedMenu, self.MenuSmoke, self, Index, SMOKECOLOR.White )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke orange", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Orange )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke orange", DetectedMenu, self.MenuSmoke, self, Index, SMOKECOLOR.Orange )
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Illuminate", DetectedMenu, self.MenuIlluminate, self, AttackGroup, Index )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Illuminate", DetectedMenu, self.MenuIlluminate, self, Index )
|
||||||
else
|
else
|
||||||
if self.Designating[Index] == "Laser" then
|
if self.Designating[Index] == "Laser" then
|
||||||
Report = "Lasing " .. Report
|
Report = "Lasing " .. Report
|
||||||
@ -416,7 +477,7 @@ do -- AI_DESIGNATE
|
|||||||
end
|
end
|
||||||
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu )
|
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu )
|
||||||
if self.Designating[Index] == "Laser" then
|
if self.Designating[Index] == "Laser" then
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Stop lasing", DetectedMenu, self.MenuLaseOff, self, AttackGroup, Index )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Stop lasing", DetectedMenu, self.MenuLaseOff, self, Index )
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -426,85 +487,111 @@ do -- AI_DESIGNATE
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @param #AI_DESIGNATE self
|
||||||
|
function AI_DESIGNATE:MenuStatus( AttackGroup )
|
||||||
|
|
||||||
|
self:E("Status")
|
||||||
|
|
||||||
|
self.RecceSet:ForEachGroup(
|
||||||
|
function( RecceGroup )
|
||||||
|
local RecceUnits = RecceGroup:GetUnits()
|
||||||
|
for UnitID, RecceData in pairs( RecceUnits ) do
|
||||||
|
local Recce = RecceData -- Wrapper.Unit#UNIT
|
||||||
|
if Recce:IsLasing() then
|
||||||
|
Recce:MessageToGroup( "Marking " .. Recce:GetSpot().Target:GetTypeName() .. " with laser " .. Recce:GetSpot().LaserCode .. ".", 5, AttackGroup )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
function AI_DESIGNATE:MenuSmoke( AttackGroup, Index, Color )
|
function AI_DESIGNATE:MenuAutoLase( AutoLase )
|
||||||
|
|
||||||
self:E("Designate through Smoke")
|
self:E("AutoLase")
|
||||||
|
|
||||||
self.Designating[Index] = "Smoke"
|
self:SetAutoLase( AutoLase )
|
||||||
self:__Smoke( 1, AttackGroup, Index, Color )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
function AI_DESIGNATE:MenuIlluminate( AttackGroup, Index )
|
function AI_DESIGNATE:MenuSmoke( Index, Color )
|
||||||
|
|
||||||
|
self:E("Designate through Smoke")
|
||||||
|
|
||||||
|
self.Designating[Index] = "Smoke"
|
||||||
|
self:__Smoke( 1, Index, Color )
|
||||||
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @param #AI_DESIGNATE self
|
||||||
|
function AI_DESIGNATE:MenuIlluminate( Index )
|
||||||
|
|
||||||
self:E("Designate through Illumination")
|
self:E("Designate through Illumination")
|
||||||
|
|
||||||
self.Designating[Index] = "Illuminate"
|
self.Designating[Index] = "Illuminate"
|
||||||
|
|
||||||
self:__Illuminate( 1, AttackGroup, Index )
|
self:__Illuminate( 1, Index )
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
function AI_DESIGNATE:MenuLaseOn( AttackGroup, Index, Duration )
|
function AI_DESIGNATE:MenuLaseOn( Index, Duration )
|
||||||
|
|
||||||
self:E("Designate through Lase")
|
self:E("Designate through Lase")
|
||||||
|
|
||||||
self.Designating[Index] = "Laser"
|
self:__LaseOn( 1, Index, Duration )
|
||||||
self:__LaseOn( 1, AttackGroup, Index, Duration )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
function AI_DESIGNATE:MenuLaseOff( AttackGroup, Index, Duration )
|
function AI_DESIGNATE:MenuLaseOff( Index, Duration )
|
||||||
|
|
||||||
self:E("Lasing off")
|
self:E("Lasing off")
|
||||||
|
|
||||||
self.Designating[Index] = nil
|
self.Designating[Index] = nil
|
||||||
self:__LaseOff( 1, AttackGroup, Index )
|
self:__LaseOff( 1, Index )
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
-- @return #AI_DESIGNATE
|
function AI_DESIGNATE:onafterLaseOn( From, Event, To, Index, Duration )
|
||||||
function AI_DESIGNATE:onafterLaseOn( From, Event, To, AttackGroup, Index, Duration )
|
|
||||||
|
|
||||||
self:__Lasing( 5, AttackGroup, Index, Duration )
|
|
||||||
|
|
||||||
|
self.Designating[Index] = "Laser"
|
||||||
|
self:Lasing( Index, Duration )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
-- @return #AI_DESIGNATE
|
-- @return #AI_DESIGNATE
|
||||||
function AI_DESIGNATE:onafterLasing( From, Event, To, AttackGroup, Index, Duration )
|
function AI_DESIGNATE:onafterLasing( From, Event, To, Index, Duration )
|
||||||
|
|
||||||
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
||||||
|
|
||||||
TargetSetUnit:Flush()
|
TargetSetUnit:Flush()
|
||||||
|
|
||||||
for TargetUnit, SpotData in pairs( self.Spots ) do
|
for TargetUnit, RecceData in pairs( self.Recces ) do
|
||||||
local Spot = SpotData -- Core.Spot#SPOT
|
local Recce = RecceData -- Wrapper.Unit#UNIT
|
||||||
if not Spot:IsLasing() then
|
if not Recce:IsLasing() then
|
||||||
local LaserCode = Spot.LaserCode --(Not deleted when stopping with lasing).
|
local LaserCode = Recce:GetLaserCode() --(Not deleted when stopping with lasing).
|
||||||
self.LaserCodesUsed[LaserCode] = nil
|
self.LaserCodesUsed[LaserCode] = nil
|
||||||
self.Spots[TargetUnit] = nil
|
self.Recces[TargetUnit] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local MoreTargets = false
|
|
||||||
|
|
||||||
TargetSetUnit:ForEachUnit(
|
TargetSetUnit:ForEachUnit(
|
||||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
--- @param Wrapper.Unit#UNIT SmokeUnit
|
||||||
function( TargetUnit )
|
function( TargetUnit )
|
||||||
self:E("In procedure")
|
self:E("In procedure")
|
||||||
if TargetUnit:IsAlive() then
|
if TargetUnit:IsAlive() then
|
||||||
local Spot = self.Spots[TargetUnit]
|
local Recce = self.Recces[TargetUnit]
|
||||||
if (not Spot) or ( Spot and Spot:IsLasing() == false ) then
|
if not Recce then
|
||||||
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
||||||
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
||||||
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
||||||
@ -513,46 +600,40 @@ do -- AI_DESIGNATE
|
|||||||
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
||||||
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
||||||
if not self.LaserCodesUsed[LaserCode] then
|
if not self.LaserCodesUsed[LaserCode] then
|
||||||
MoreTargets = true
|
|
||||||
self.LaserCodesUsed[LaserCode] = LaserCodeIndex
|
self.LaserCodesUsed[LaserCode] = LaserCodeIndex
|
||||||
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
||||||
|
local AttackSet = self.AttackSet
|
||||||
function Spot:OnAfterDestroyed( From, Event, To )
|
function Spot:OnAfterDestroyed( From, Event, To )
|
||||||
self:E( "Destroyed Message" )
|
self:E( "Destroyed Message" )
|
||||||
self.Recce:MessageToGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed." .. TargetSetUnit:Count() .. " targets left.", 5, AttackGroup )
|
self.Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed." .. TargetSetUnit:Count() .. " targets left.", 15, AttackSet )
|
||||||
end
|
end
|
||||||
self.Spots[TargetUnit] = Spot
|
self.Recces[TargetUnit] = RecceUnit
|
||||||
RecceUnit:MessageToGroup( "Lasing " .. TargetUnit:GetTypeName() .. " for " .. Duration .. "s, code: " .. Spot.LaserCode, 5, AttackGroup )
|
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet )
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
RecceUnit:MessageToSetGroup( "Can't lase " .. TargetUnit:GetTypeName(), 5, self.AttackSet )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- The Recce is lasing, but the Target is not detected or within LOS. So stop lasing and send a report.
|
-- The Recce is lasing, but the Target is not detected or within LOS. So stop lasing and send a report.
|
||||||
if not RecceUnit:IsDetected( TargetUnit ) or not RecceUnit:IsLOS( TargetUnit ) then
|
if not RecceUnit:IsDetected( TargetUnit ) or not RecceUnit:IsLOS( TargetUnit ) then
|
||||||
local Spot = self.Spots[TargetUnit] -- Core.Spot#SPOT
|
local Recce = self.Recces[TargetUnit] -- Wrapper.Unit#UNIT
|
||||||
if Spot then
|
if Recce then
|
||||||
Spot.Recce:LaseOff()
|
Recce:LaseOff()
|
||||||
Spot.Recce:MessageToGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, AttackGroup )
|
Recce:MessageToGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
MoreTargets = true
|
Recce:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
||||||
local RecceUnit = Spot.Recce
|
|
||||||
RecceUnit:MessageToGroup( "Lasing " .. TargetUnit:GetTypeName() .. ", code " .. Spot.LaserCode, 5, AttackGroup )
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
self.Spots[TargetUnit] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
if MoreTargets == true then
|
self:__Lasing( 15, Index, Duration )
|
||||||
self:__Lasing( 30, AttackGroup, Index, Duration )
|
|
||||||
else
|
|
||||||
self:__LaseOff( 1, AttackGroup, Index )
|
|
||||||
end
|
|
||||||
|
|
||||||
self:SetDesignateMenu()
|
self:SetDesignateMenu()
|
||||||
|
|
||||||
@ -561,22 +642,26 @@ do -- AI_DESIGNATE
|
|||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
-- @return #AI_DESIGNATE
|
-- @return #AI_DESIGNATE
|
||||||
function AI_DESIGNATE:onafterLaseOff( From, Event, To, AttackGroup, Index )
|
function AI_DESIGNATE:onafterLaseOff( From, Event, To, Index )
|
||||||
|
|
||||||
self.RecceSet:GetFirst():MessageToGroup( "Stopped lasing.", 15, AttackGroup )
|
local Recce = self.RecceSet:GetFirst()
|
||||||
|
|
||||||
|
if Recce then
|
||||||
|
Recce:MessageToSetGroup( "Stopped lasing.", 15, self.AttackSet )
|
||||||
|
end
|
||||||
|
|
||||||
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
||||||
|
|
||||||
local Spots = self.Spots
|
local Recces = self.Recces
|
||||||
|
|
||||||
for SpotID, SpotData in pairs( Spots ) do
|
for TargetID, RecceData in pairs( Recces ) do
|
||||||
local Spot = SpotData -- Core.Spot#SPOT
|
local Recce = RecceData -- Wrapper.Unit#UNIT
|
||||||
Spot.Recce:MessageToGroup( "Stopped lasing " .. Spot.Target:GetTypeName() .. ".", 15, AttackGroup )
|
Recce:MessageToSetGroup( "Stopped lasing " .. Recce:GetSpot().Target:GetTypeName() .. ".", 15, self.AttackSet )
|
||||||
Spot:LaseOff()
|
Recce:LaseOff()
|
||||||
end
|
end
|
||||||
|
|
||||||
Spots = nil
|
Recces = nil
|
||||||
self.Spots = {}
|
self.Recces = {}
|
||||||
self.LaserCodesUsed = {}
|
self.LaserCodesUsed = {}
|
||||||
|
|
||||||
self:SetDesignateMenu()
|
self:SetDesignateMenu()
|
||||||
@ -586,7 +671,7 @@ do -- AI_DESIGNATE
|
|||||||
---
|
---
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
-- @return #AI_DESIGNATE
|
-- @return #AI_DESIGNATE
|
||||||
function AI_DESIGNATE:onafterSmoke( From, Event, To, AttackGroup, Index, Color )
|
function AI_DESIGNATE:onafterSmoke( From, Event, To, Index, Color )
|
||||||
|
|
||||||
|
|
||||||
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
||||||
@ -599,15 +684,17 @@ do -- AI_DESIGNATE
|
|||||||
if math.random( 1, TargetSetUnitCount ) == math.random( 1, TargetSetUnitCount ) then
|
if math.random( 1, TargetSetUnitCount ) == math.random( 1, TargetSetUnitCount ) then
|
||||||
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(SmokeUnit:GetPointVec2())
|
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(SmokeUnit:GetPointVec2())
|
||||||
local RecceUnit = RecceGroup:GetUnit( 1 )
|
local RecceUnit = RecceGroup:GetUnit( 1 )
|
||||||
RecceUnit:MessageToGroup( "Smoking " .. SmokeUnit:GetTypeName() .. ".", 5, AttackGroup )
|
if RecceUnit then
|
||||||
SCHEDULER:New( self,
|
RecceUnit:MessageToSetGroup( "Smoking " .. SmokeUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
||||||
function()
|
SCHEDULER:New( self,
|
||||||
if SmokeUnit:IsAlive() then
|
function()
|
||||||
SmokeUnit:Smoke( Color, 150 )
|
if SmokeUnit:IsAlive() then
|
||||||
end
|
SmokeUnit:Smoke( Color, 150 )
|
||||||
self:Done( Index )
|
end
|
||||||
end, {}, math.random( 5, 20 )
|
self:Done( Index )
|
||||||
)
|
end, {}, math.random( 5, 20 )
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@ -618,16 +705,17 @@ do -- AI_DESIGNATE
|
|||||||
--- Illuminating
|
--- Illuminating
|
||||||
-- @param #AI_DESIGNATE self
|
-- @param #AI_DESIGNATE self
|
||||||
-- @return #AI_DESIGNATE
|
-- @return #AI_DESIGNATE
|
||||||
function AI_DESIGNATE:onafterIlluminate( From, Event, To, AttackGroup, Index )
|
function AI_DESIGNATE:onafterIlluminate( From, Event, To, Index )
|
||||||
|
|
||||||
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
||||||
|
|
||||||
local TargetUnit = TargetSetUnit:GetFirst()
|
local TargetUnit = TargetSetUnit:GetFirst()
|
||||||
|
|
||||||
if TargetUnit then
|
if TargetUnit then
|
||||||
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(TargetUnit:GetPointVec2())
|
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(TargetUnit:GetPointVec2())
|
||||||
local RecceUnit = RecceGroup:GetUnit( 1 )
|
local RecceUnit = RecceGroup:GetUnit( 1 )
|
||||||
RecceUnit:MessageToGroup( "Illuminating " .. TargetUnit:GetTypeName() .. ".", 5, AttackGroup )
|
if RecceUnit then
|
||||||
|
RecceUnit:MessageToGroup( "Illuminating " .. TargetUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
||||||
SCHEDULER:New( self,
|
SCHEDULER:New( self,
|
||||||
function()
|
function()
|
||||||
if TargetUnit:IsAlive() then
|
if TargetUnit:IsAlive() then
|
||||||
@ -636,6 +724,7 @@ do -- AI_DESIGNATE
|
|||||||
self:Done( Index )
|
self:Done( Index )
|
||||||
end, {}, math.random( 5, 20 )
|
end, {}, math.random( 5, 20 )
|
||||||
)
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -141,6 +141,8 @@ do
|
|||||||
self.LaseScheduler = SCHEDULER:New( self )
|
self.LaseScheduler = SCHEDULER:New( self )
|
||||||
|
|
||||||
self:SetEventPriority( 5 )
|
self:SetEventPriority( 5 )
|
||||||
|
|
||||||
|
self.Lasing = false
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -162,6 +164,8 @@ do
|
|||||||
self.Target = Target
|
self.Target = Target
|
||||||
self.LaserCode = LaserCode
|
self.LaserCode = LaserCode
|
||||||
|
|
||||||
|
self.Lasing = true
|
||||||
|
|
||||||
local RecceDcsUnit = self.Recce:GetDCSObject()
|
local RecceDcsUnit = self.Recce:GetDCSObject()
|
||||||
|
|
||||||
self.SpotIR = Spot.createInfraRed( RecceDcsUnit, { x = 0, y = 2, z = 0 }, Target:GetPointVec3():AddY(1):GetVec3() )
|
self.SpotIR = Spot.createInfraRed( RecceDcsUnit, { x = 0, y = 2, z = 0 }, Target:GetPointVec3():AddY(1):GetVec3() )
|
||||||
@ -184,7 +188,7 @@ do
|
|||||||
if EventData.IniDCSUnitName == self.Target:GetName() then
|
if EventData.IniDCSUnitName == self.Target:GetName() then
|
||||||
self:E( {"Target dead ", self.Target:GetName() } )
|
self:E( {"Target dead ", self.Target:GetName() } )
|
||||||
self:Destroyed()
|
self:Destroyed()
|
||||||
self:LaseOff( 0.1 )
|
self:LaseOff()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -196,7 +200,7 @@ do
|
|||||||
function SPOT:onafterLasing( From, Event, To )
|
function SPOT:onafterLasing( From, Event, To )
|
||||||
|
|
||||||
if self.Target:IsAlive() then
|
if self.Target:IsAlive() then
|
||||||
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() )
|
||||||
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
||||||
self:__Lasing( -0.2 )
|
self:__Lasing( -0.2 )
|
||||||
else
|
else
|
||||||
@ -214,6 +218,8 @@ do
|
|||||||
|
|
||||||
self:E( {"Stopped lasing for ", self.Target:GetName() , SpotIR = self.SportIR, SpotLaser = self.SpotLaser } )
|
self:E( {"Stopped lasing for ", self.Target:GetName() , SpotIR = self.SportIR, SpotLaser = self.SpotLaser } )
|
||||||
|
|
||||||
|
self.Lasing = false
|
||||||
|
|
||||||
self.SpotIR:destroy()
|
self.SpotIR:destroy()
|
||||||
self.SpotLaser:destroy()
|
self.SpotLaser:destroy()
|
||||||
|
|
||||||
@ -234,15 +240,7 @@ do
|
|||||||
-- @param #SPOT self
|
-- @param #SPOT self
|
||||||
-- @return #boolean true if it is lasing
|
-- @return #boolean true if it is lasing
|
||||||
function SPOT:IsLasing()
|
function SPOT:IsLasing()
|
||||||
self:F2()
|
return self.Lasing
|
||||||
|
|
||||||
local Lasing = false
|
|
||||||
|
|
||||||
if self.SpotIR then
|
|
||||||
Lasing = true
|
|
||||||
end
|
|
||||||
|
|
||||||
return Lasing
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -29,6 +29,8 @@
|
|||||||
-- @type POSITIONABLE
|
-- @type POSITIONABLE
|
||||||
-- @extends Wrapper.Identifiable#IDENTIFIABLE
|
-- @extends Wrapper.Identifiable#IDENTIFIABLE
|
||||||
-- @field #string PositionableName The name of the measurable.
|
-- @field #string PositionableName The name of the measurable.
|
||||||
|
-- @field Core.Spot#SPOT Spot The laser Spot.
|
||||||
|
-- @field #number LaserCode The last assigned laser code.
|
||||||
POSITIONABLE = {
|
POSITIONABLE = {
|
||||||
ClassName = "POSITIONABLE",
|
ClassName = "POSITIONABLE",
|
||||||
PositionableName = "",
|
PositionableName = "",
|
||||||
@ -426,6 +428,30 @@ function POSITIONABLE:MessageToGroup( Message, Duration, MessageGroup, Name )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (R2.1) Send a message to a @{Set#SET_GROUP}.
|
||||||
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param #string Message The message text
|
||||||
|
-- @param Dcs.DCSTypes#Duration Duration The duration of the message.
|
||||||
|
-- @param Core.Set#SET_GROUP MessageSetGroup The SET_GROUP collection receiving the message.
|
||||||
|
-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable.
|
||||||
|
function POSITIONABLE:MessageToSetGroup( Message, Duration, MessageSetGroup, Name )
|
||||||
|
self:F2( { Message, Duration } )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
if DCSObject then
|
||||||
|
if DCSObject:isExist() then
|
||||||
|
MessageSetGroup:ForEachGroup(
|
||||||
|
function( MessageGroup )
|
||||||
|
self:GetMessage( Message, Duration, Name ):ToGroup( MessageGroup )
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Send a message to the players in the @{Group}.
|
--- Send a message to the players in the @{Group}.
|
||||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
@ -477,6 +503,7 @@ function POSITIONABLE:LaseUnit( Target, LaserCode, Duration )
|
|||||||
self:E("bulding spot")
|
self:E("bulding spot")
|
||||||
self.Spot = SPOT:New( self ) -- Core.Spot#SPOT
|
self.Spot = SPOT:New( self ) -- Core.Spot#SPOT
|
||||||
self.Spot:LaseOn( Target, LaserCode, Duration)
|
self.Spot:LaseOn( Target, LaserCode, Duration)
|
||||||
|
self.LaserCode = LaserCode
|
||||||
|
|
||||||
return self.Spot
|
return self.Spot
|
||||||
|
|
||||||
@ -510,3 +537,19 @@ function POSITIONABLE:IsLasing()
|
|||||||
|
|
||||||
return Lasing
|
return Lasing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (R2.1) Get the Spot
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @return Core.Spot#SPOT The Spot
|
||||||
|
function POSITIONABLE:GetSpot()
|
||||||
|
|
||||||
|
return self.Spot
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (R2.1) Get the last assigned laser code
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @return #number The laser code
|
||||||
|
function POSITIONABLE:GetLaserCode()
|
||||||
|
|
||||||
|
return self.LaserCode
|
||||||
|
end
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20170422_1159' )
|
env.info( 'Moose Generation Timestamp: 20170423_0705' )
|
||||||
|
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user