mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Improvements
This commit is contained in:
parent
8a5a33d191
commit
20b4ebfb2b
@ -448,6 +448,8 @@ do -- AI_DESIGNATE
|
|||||||
else
|
else
|
||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Auto Lase On", DesignateMenu, self.MenuAutoLase, self, true )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Auto Lase On", DesignateMenu, self.MenuAutoLase, self, true )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
MENU_GROUP_COMMAND:New( AttackGroup, "Report Designation Status", DesignateMenu, self.MenuStatus, self, AttackGroup )
|
||||||
|
|
||||||
local DetectedItems = self.Detection:GetDetectedItems()
|
local DetectedItems = self.Detection:GetDetectedItems()
|
||||||
|
|
||||||
@ -485,6 +487,27 @@ 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
|
||||||
@ -556,7 +579,7 @@ do -- AI_DESIGNATE
|
|||||||
for TargetUnit, RecceData in pairs( self.Recces ) do
|
for TargetUnit, RecceData in pairs( self.Recces ) do
|
||||||
local Recce = RecceData -- Wrapper.Unit#UNIT
|
local Recce = RecceData -- Wrapper.Unit#UNIT
|
||||||
if not Recce:IsLasing() then
|
if not Recce:IsLasing() then
|
||||||
local LaserCode = self.LaserCodesUsed[Recce] --(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.Recces[TargetUnit] = nil
|
self.Recces[TargetUnit] = nil
|
||||||
end
|
end
|
||||||
@ -568,7 +591,7 @@ do -- AI_DESIGNATE
|
|||||||
self:E("In procedure")
|
self:E("In procedure")
|
||||||
if TargetUnit:IsAlive() then
|
if TargetUnit:IsAlive() then
|
||||||
local Recce = self.Recces[TargetUnit]
|
local Recce = self.Recces[TargetUnit]
|
||||||
if (not Recce) or ( Recce and Recce: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
|
||||||
@ -579,14 +602,17 @@ do -- AI_DESIGNATE
|
|||||||
if not self.LaserCodesUsed[LaserCode] then
|
if not self.LaserCodesUsed[LaserCode] then
|
||||||
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:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed." .. TargetSetUnit:Count() .. " targets left.", 15, self.AttackSet )
|
self.Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed." .. TargetSetUnit:Count() .. " targets left.", 15, AttackSet )
|
||||||
end
|
end
|
||||||
self.Recces[TargetUnit] = RecceUnit
|
self.Recces[TargetUnit] = RecceUnit
|
||||||
RecceUnit:MessageToSetGroup( "Lasing " .. TargetUnit:GetTypeName() .. " for " .. Duration .. "s, code: " .. RecceUnit:GetSpot().LaserCode, 5, self.AttackSet )
|
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.
|
||||||
@ -601,11 +627,8 @@ do -- AI_DESIGNATE
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local RecceUnit = Recce.Recce
|
Recce:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
||||||
RecceUnit:MessageToSetGroup( "Lasing " .. TargetUnit:GetTypeName() .. ", code " .. Recce.LaserCode, 5, self.AttackSet )
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
self.Recces[TargetUnit] = nil
|
|
||||||
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
|
||||||
@ -198,7 +202,7 @@ do
|
|||||||
if self.Target:IsAlive() then
|
if self.Target:IsAlive() then
|
||||||
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):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.05 )
|
self:__Lasing( -0.2 )
|
||||||
else
|
else
|
||||||
self:E( { "Target is not alive", self.Target:IsAlive() } )
|
self:E( { "Target is not alive", self.Target:IsAlive() } )
|
||||||
end
|
end
|
||||||
@ -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 = "",
|
||||||
@ -501,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
|
||||||
|
|
||||||
@ -542,3 +545,11 @@ function POSITIONABLE:GetSpot()
|
|||||||
|
|
||||||
return self.Spot
|
return self.Spot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (R2.1) Get the last assigned laser code
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @return #number The laser code
|
||||||
|
function POSITIONABLE:GetLaserCode()
|
||||||
|
|
||||||
|
return self.LaserCode
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user