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.
|
||||
-- @param #AI_DESIGNATE self
|
||||
-- @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
|
||||
function AI_DESIGNATE:New( Detection, GroupSet )
|
||||
function AI_DESIGNATE:New( Detection, AttackSet )
|
||||
|
||||
local self = BASE:Inherit( self, FSM:New() ) -- #AI_DESIGNATE
|
||||
self:F( { Detection } )
|
||||
@ -295,18 +295,22 @@ do -- AI_DESIGNATE
|
||||
-- @param #number Delay
|
||||
|
||||
self.Detection = Detection
|
||||
self.GroupSet = GroupSet
|
||||
self.AttackSet = AttackSet
|
||||
self.RecceSet = Detection:GetDetectionSetGroup()
|
||||
self.Spots = {}
|
||||
self.Recces = {}
|
||||
self.Designating = {}
|
||||
|
||||
self:SetLaserCodes( 1688 )
|
||||
self.LaseDuration = 60
|
||||
|
||||
self:SetLaserCodes( 1688 ) -- set self.LaserCodes
|
||||
self:SetAutoLase( false ) -- set self.Autolase
|
||||
|
||||
self.LaserCodesUsed = {}
|
||||
|
||||
|
||||
self.Detection:__Start( 2 )
|
||||
|
||||
|
||||
self:SetDesignateMenu()
|
||||
|
||||
return self
|
||||
end
|
||||
@ -327,6 +331,29 @@ do -- AI_DESIGNATE
|
||||
return self
|
||||
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
|
||||
@ -335,7 +362,11 @@ do -- AI_DESIGNATE
|
||||
|
||||
self:__Detect( -60 )
|
||||
|
||||
self:ActivateAutoLase()
|
||||
|
||||
self:SendStatus()
|
||||
|
||||
|
||||
self:SetDesignateMenu()
|
||||
|
||||
return self
|
||||
@ -357,11 +388,32 @@ do -- AI_DESIGNATE
|
||||
|
||||
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
|
||||
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
|
||||
)
|
||||
|
||||
@ -373,9 +425,9 @@ do -- AI_DESIGNATE
|
||||
-- @return #AI_DESIGNATE
|
||||
function AI_DESIGNATE:SetDesignateMenu()
|
||||
|
||||
self.GroupSet:Flush()
|
||||
self.AttackSet:Flush()
|
||||
|
||||
self.GroupSet:ForEachGroup(
|
||||
self.AttackSet:ForEachGroup(
|
||||
|
||||
--- @param Wrapper.Group#GROUP GroupReport
|
||||
function( AttackGroup )
|
||||
@ -389,6 +441,15 @@ do -- AI_DESIGNATE
|
||||
self:E(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()
|
||||
|
||||
@ -398,14 +459,14 @@ do -- AI_DESIGNATE
|
||||
|
||||
if not self.Designating[Index] then
|
||||
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 120 secs", DetectedMenu, self.MenuLaseOn, self,AttackGroup, Index, 120 )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke red", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Red )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke blue", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Blue )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke green", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Green )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke white", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.White )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke orange", DetectedMenu, self.MenuSmoke, self, AttackGroup, Index, SMOKECOLOR.Orange )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Illuminate", DetectedMenu, self.MenuIlluminate, self, AttackGroup, Index )
|
||||
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, Index, 120 )
|
||||
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, Index, SMOKECOLOR.Blue )
|
||||
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, Index, SMOKECOLOR.White )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke orange", DetectedMenu, self.MenuSmoke, self, Index, SMOKECOLOR.Orange )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Illuminate", DetectedMenu, self.MenuIlluminate, self, Index )
|
||||
else
|
||||
if self.Designating[Index] == "Laser" then
|
||||
Report = "Lasing " .. Report
|
||||
@ -416,7 +477,7 @@ do -- AI_DESIGNATE
|
||||
end
|
||||
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu )
|
||||
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
|
||||
end
|
||||
end
|
||||
@ -426,85 +487,111 @@ do -- AI_DESIGNATE
|
||||
|
||||
return self
|
||||
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
|
||||
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:__Smoke( 1, AttackGroup, Index, Color )
|
||||
self:SetAutoLase( AutoLase )
|
||||
end
|
||||
|
||||
---
|
||||
-- @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.Designating[Index] = "Illuminate"
|
||||
|
||||
self:__Illuminate( 1, AttackGroup, Index )
|
||||
self:__Illuminate( 1, Index )
|
||||
end
|
||||
|
||||
---
|
||||
-- @param #AI_DESIGNATE self
|
||||
function AI_DESIGNATE:MenuLaseOn( AttackGroup, Index, Duration )
|
||||
function AI_DESIGNATE:MenuLaseOn( Index, Duration )
|
||||
|
||||
self:E("Designate through Lase")
|
||||
|
||||
self.Designating[Index] = "Laser"
|
||||
self:__LaseOn( 1, AttackGroup, Index, Duration )
|
||||
self:__LaseOn( 1, Index, Duration )
|
||||
end
|
||||
|
||||
---
|
||||
-- @param #AI_DESIGNATE self
|
||||
function AI_DESIGNATE:MenuLaseOff( AttackGroup, Index, Duration )
|
||||
function AI_DESIGNATE:MenuLaseOff( Index, Duration )
|
||||
|
||||
self:E("Lasing off")
|
||||
|
||||
self.Designating[Index] = nil
|
||||
self:__LaseOff( 1, AttackGroup, Index )
|
||||
self:__LaseOff( 1, Index )
|
||||
end
|
||||
|
||||
---
|
||||
-- @param #AI_DESIGNATE self
|
||||
-- @return #AI_DESIGNATE
|
||||
function AI_DESIGNATE:onafterLaseOn( From, Event, To, AttackGroup, Index, Duration )
|
||||
|
||||
self:__Lasing( 5, AttackGroup, Index, Duration )
|
||||
function AI_DESIGNATE:onafterLaseOn( From, Event, To, Index, Duration )
|
||||
|
||||
self.Designating[Index] = "Laser"
|
||||
self:Lasing( Index, Duration )
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- @param #AI_DESIGNATE self
|
||||
-- @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 )
|
||||
|
||||
TargetSetUnit:Flush()
|
||||
|
||||
for TargetUnit, SpotData in pairs( self.Spots ) do
|
||||
local Spot = SpotData -- Core.Spot#SPOT
|
||||
if not Spot:IsLasing() then
|
||||
local LaserCode = Spot.LaserCode --(Not deleted when stopping with lasing).
|
||||
for TargetUnit, RecceData in pairs( self.Recces ) do
|
||||
local Recce = RecceData -- Wrapper.Unit#UNIT
|
||||
if not Recce:IsLasing() then
|
||||
local LaserCode = Recce:GetLaserCode() --(Not deleted when stopping with lasing).
|
||||
self.LaserCodesUsed[LaserCode] = nil
|
||||
self.Spots[TargetUnit] = nil
|
||||
self.Recces[TargetUnit] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local MoreTargets = false
|
||||
|
||||
TargetSetUnit:ForEachUnit(
|
||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
||||
function( TargetUnit )
|
||||
self:E("In procedure")
|
||||
if TargetUnit:IsAlive() then
|
||||
local Spot = self.Spots[TargetUnit]
|
||||
if (not Spot) or ( Spot and Spot:IsLasing() == false ) then
|
||||
local Recce = self.Recces[TargetUnit]
|
||||
if not Recce then
|
||||
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
||||
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
||||
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
||||
@ -513,46 +600,40 @@ do -- AI_DESIGNATE
|
||||
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
||||
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
||||
if not self.LaserCodesUsed[LaserCode] then
|
||||
MoreTargets = true
|
||||
self.LaserCodesUsed[LaserCode] = LaserCodeIndex
|
||||
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
||||
local AttackSet = self.AttackSet
|
||||
function Spot:OnAfterDestroyed( From, Event, To )
|
||||
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
|
||||
self.Spots[TargetUnit] = Spot
|
||||
RecceUnit:MessageToGroup( "Lasing " .. TargetUnit:GetTypeName() .. " for " .. Duration .. "s, code: " .. Spot.LaserCode, 5, AttackGroup )
|
||||
self.Recces[TargetUnit] = RecceUnit
|
||||
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet )
|
||||
break
|
||||
end
|
||||
else
|
||||
RecceUnit:MessageToSetGroup( "Can't lase " .. TargetUnit:GetTypeName(), 5, self.AttackSet )
|
||||
end
|
||||
else
|
||||
-- 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
|
||||
local Spot = self.Spots[TargetUnit] -- Core.Spot#SPOT
|
||||
if Spot then
|
||||
Spot.Recce:LaseOff()
|
||||
Spot.Recce:MessageToGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, AttackGroup )
|
||||
local Recce = self.Recces[TargetUnit] -- Wrapper.Unit#UNIT
|
||||
if Recce then
|
||||
Recce:LaseOff()
|
||||
Recce:MessageToGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
MoreTargets = true
|
||||
local RecceUnit = Spot.Recce
|
||||
RecceUnit:MessageToGroup( "Lasing " .. TargetUnit:GetTypeName() .. ", code " .. Spot.LaserCode, 5, AttackGroup )
|
||||
Recce:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
||||
end
|
||||
else
|
||||
self.Spots[TargetUnit] = nil
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
if MoreTargets == true then
|
||||
self:__Lasing( 30, AttackGroup, Index, Duration )
|
||||
else
|
||||
self:__LaseOff( 1, AttackGroup, Index )
|
||||
end
|
||||
self:__Lasing( 15, Index, Duration )
|
||||
|
||||
self:SetDesignateMenu()
|
||||
|
||||
@ -561,22 +642,26 @@ do -- AI_DESIGNATE
|
||||
---
|
||||
-- @param #AI_DESIGNATE self
|
||||
-- @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 Spots = self.Spots
|
||||
local Recces = self.Recces
|
||||
|
||||
for SpotID, SpotData in pairs( Spots ) do
|
||||
local Spot = SpotData -- Core.Spot#SPOT
|
||||
Spot.Recce:MessageToGroup( "Stopped lasing " .. Spot.Target:GetTypeName() .. ".", 15, AttackGroup )
|
||||
Spot:LaseOff()
|
||||
for TargetID, RecceData in pairs( Recces ) do
|
||||
local Recce = RecceData -- Wrapper.Unit#UNIT
|
||||
Recce:MessageToSetGroup( "Stopped lasing " .. Recce:GetSpot().Target:GetTypeName() .. ".", 15, self.AttackSet )
|
||||
Recce:LaseOff()
|
||||
end
|
||||
|
||||
Spots = nil
|
||||
self.Spots = {}
|
||||
Recces = nil
|
||||
self.Recces = {}
|
||||
self.LaserCodesUsed = {}
|
||||
|
||||
self:SetDesignateMenu()
|
||||
@ -586,7 +671,7 @@ do -- AI_DESIGNATE
|
||||
---
|
||||
-- @param #AI_DESIGNATE self
|
||||
-- @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 )
|
||||
@ -599,15 +684,17 @@ do -- AI_DESIGNATE
|
||||
if math.random( 1, TargetSetUnitCount ) == math.random( 1, TargetSetUnitCount ) then
|
||||
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(SmokeUnit:GetPointVec2())
|
||||
local RecceUnit = RecceGroup:GetUnit( 1 )
|
||||
RecceUnit:MessageToGroup( "Smoking " .. SmokeUnit:GetTypeName() .. ".", 5, AttackGroup )
|
||||
SCHEDULER:New( self,
|
||||
function()
|
||||
if SmokeUnit:IsAlive() then
|
||||
SmokeUnit:Smoke( Color, 150 )
|
||||
end
|
||||
self:Done( Index )
|
||||
end, {}, math.random( 5, 20 )
|
||||
)
|
||||
if RecceUnit then
|
||||
RecceUnit:MessageToSetGroup( "Smoking " .. SmokeUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
||||
SCHEDULER:New( self,
|
||||
function()
|
||||
if SmokeUnit:IsAlive() then
|
||||
SmokeUnit:Smoke( Color, 150 )
|
||||
end
|
||||
self:Done( Index )
|
||||
end, {}, math.random( 5, 20 )
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -618,16 +705,17 @@ do -- AI_DESIGNATE
|
||||
--- Illuminating
|
||||
-- @param #AI_DESIGNATE self
|
||||
-- @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 TargetUnit = TargetSetUnit:GetFirst()
|
||||
|
||||
if TargetUnit then
|
||||
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(TargetUnit:GetPointVec2())
|
||||
local RecceUnit = RecceGroup:GetUnit( 1 )
|
||||
RecceUnit:MessageToGroup( "Illuminating " .. TargetUnit:GetTypeName() .. ".", 5, AttackGroup )
|
||||
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(TargetUnit:GetPointVec2())
|
||||
local RecceUnit = RecceGroup:GetUnit( 1 )
|
||||
if RecceUnit then
|
||||
RecceUnit:MessageToGroup( "Illuminating " .. TargetUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
||||
SCHEDULER:New( self,
|
||||
function()
|
||||
if TargetUnit:IsAlive() then
|
||||
@ -636,6 +724,7 @@ do -- AI_DESIGNATE
|
||||
self:Done( Index )
|
||||
end, {}, math.random( 5, 20 )
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -141,6 +141,8 @@ do
|
||||
self.LaseScheduler = SCHEDULER:New( self )
|
||||
|
||||
self:SetEventPriority( 5 )
|
||||
|
||||
self.Lasing = false
|
||||
|
||||
return self
|
||||
end
|
||||
@ -162,6 +164,8 @@ do
|
||||
self.Target = Target
|
||||
self.LaserCode = LaserCode
|
||||
|
||||
self.Lasing = true
|
||||
|
||||
local RecceDcsUnit = self.Recce:GetDCSObject()
|
||||
|
||||
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
|
||||
self:E( {"Target dead ", self.Target:GetName() } )
|
||||
self:Destroyed()
|
||||
self:LaseOff( 0.1 )
|
||||
self:LaseOff()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -196,7 +200,7 @@ do
|
||||
function SPOT:onafterLasing( From, Event, To )
|
||||
|
||||
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:__Lasing( -0.2 )
|
||||
else
|
||||
@ -214,6 +218,8 @@ do
|
||||
|
||||
self:E( {"Stopped lasing for ", self.Target:GetName() , SpotIR = self.SportIR, SpotLaser = self.SpotLaser } )
|
||||
|
||||
self.Lasing = false
|
||||
|
||||
self.SpotIR:destroy()
|
||||
self.SpotLaser:destroy()
|
||||
|
||||
@ -234,15 +240,7 @@ do
|
||||
-- @param #SPOT self
|
||||
-- @return #boolean true if it is lasing
|
||||
function SPOT:IsLasing()
|
||||
self:F2()
|
||||
|
||||
local Lasing = false
|
||||
|
||||
if self.SpotIR then
|
||||
Lasing = true
|
||||
end
|
||||
|
||||
return Lasing
|
||||
return self.Lasing
|
||||
end
|
||||
|
||||
end
|
||||
@ -29,6 +29,8 @@
|
||||
-- @type POSITIONABLE
|
||||
-- @extends Wrapper.Identifiable#IDENTIFIABLE
|
||||
-- @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 = {
|
||||
ClassName = "POSITIONABLE",
|
||||
PositionableName = "",
|
||||
@ -426,6 +428,30 @@ function POSITIONABLE:MessageToGroup( Message, Duration, MessageGroup, Name )
|
||||
return nil
|
||||
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}.
|
||||
-- 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
|
||||
@ -477,6 +503,7 @@ function POSITIONABLE:LaseUnit( Target, LaserCode, Duration )
|
||||
self:E("bulding spot")
|
||||
self.Spot = SPOT:New( self ) -- Core.Spot#SPOT
|
||||
self.Spot:LaseOn( Target, LaserCode, Duration)
|
||||
self.LaserCode = LaserCode
|
||||
|
||||
return self.Spot
|
||||
|
||||
@ -510,3 +537,19 @@ function POSITIONABLE:IsLasing()
|
||||
|
||||
return Lasing
|
||||
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 Generation Timestamp: 20170422_1159' )
|
||||
env.info( 'Moose Generation Timestamp: 20170423_0705' )
|
||||
|
||||
local base = _G
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user