mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Single lase commands
This commit is contained in:
parent
e6dd040a43
commit
c2965e0736
@ -990,6 +990,8 @@ do -- DESIGNATE
|
|||||||
function DESIGNATE:onafterLaseOn( From, Event, To, Index, Duration, LaserCode )
|
function DESIGNATE:onafterLaseOn( From, Event, To, Index, Duration, LaserCode )
|
||||||
|
|
||||||
self.Designating[Index] = "Laser"
|
self.Designating[Index] = "Laser"
|
||||||
|
self.LaseStart = timer.getTime()
|
||||||
|
self.LaseDuration = Duration
|
||||||
self:__Lasing( -1, Index, Duration, LaserCode )
|
self:__Lasing( -1, Index, Duration, LaserCode )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1038,59 +1040,84 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.AutoLase or ( not self.AutoLase and ( self.LaseStart + Duration >= timer.getTime() ) ) then
|
||||||
|
|
||||||
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
||||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
--- @param Wrapper.Unit#UNIT SmokeUnit
|
||||||
function( TargetUnit )
|
function( TargetUnit )
|
||||||
|
|
||||||
self:F( { TargetUnit = TargetUnit:GetName() } )
|
self:F( { TargetUnit = TargetUnit:GetName() } )
|
||||||
|
|
||||||
if MarkingCount < self.MaximumMarkings then
|
|
||||||
|
|
||||||
if TargetUnit:IsAlive() then
|
|
||||||
|
|
||||||
local Recce = self.Recces[TargetUnit]
|
if MarkingCount < self.MaximumMarkings then
|
||||||
|
|
||||||
if not Recce then
|
if TargetUnit:IsAlive() then
|
||||||
|
|
||||||
self:E( "Lasing..." )
|
local Recce = self.Recces[TargetUnit]
|
||||||
self.RecceSet:Flush()
|
|
||||||
|
if not Recce then
|
||||||
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
|
||||||
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
self:E( "Lasing..." )
|
||||||
|
self.RecceSet:Flush()
|
||||||
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
|
||||||
local RecceUnitDesc = RecceUnit:GetDesc()
|
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
||||||
--self:F( { RecceUnit = RecceUnit:GetName(), RecceDescription = RecceUnitDesc } )
|
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
||||||
|
|
||||||
if RecceUnit:IsLasing() == false then
|
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
||||||
--self:F( { IsDetected = RecceUnit:IsDetected( TargetUnit ), IsLOS = RecceUnit:IsLOS( TargetUnit ) } )
|
local RecceUnitDesc = RecceUnit:GetDesc()
|
||||||
|
--self:F( { RecceUnit = RecceUnit:GetName(), RecceDescription = RecceUnitDesc } )
|
||||||
if RecceUnit:IsDetected( TargetUnit ) and RecceUnit:IsLOS( TargetUnit ) then
|
|
||||||
|
if RecceUnit:IsLasing() == false then
|
||||||
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
--self:F( { IsDetected = RecceUnit:IsDetected( TargetUnit ), IsLOS = RecceUnit:IsLOS( TargetUnit ) } )
|
||||||
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
|
||||||
--self:F( { LaserCode = LaserCode, LaserCodeUsed = self.LaserCodesUsed[LaserCode] } )
|
if RecceUnit:IsDetected( TargetUnit ) and RecceUnit:IsLOS( TargetUnit ) then
|
||||||
|
|
||||||
if LaserCodeRequested and LaserCodeRequested ~= LaserCode then
|
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
||||||
LaserCode = LaserCodeRequested
|
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
||||||
LaserCodeRequested = nil
|
--self:F( { LaserCode = LaserCode, LaserCodeUsed = self.LaserCodesUsed[LaserCode] } )
|
||||||
end
|
|
||||||
|
if LaserCodeRequested and LaserCodeRequested ~= LaserCode then
|
||||||
if not self.LaserCodesUsed[LaserCode] then
|
LaserCode = LaserCodeRequested
|
||||||
|
LaserCodeRequested = nil
|
||||||
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:ToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed. " .. TargetSetUnit:Count() .. " targets left.", 5, AttackSet, self.DesignateName )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.Recces[TargetUnit] = RecceUnit
|
if not self.LaserCodesUsed[LaserCode] then
|
||||||
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet, self.DesignateName )
|
|
||||||
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
|
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:ToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed. " .. TargetSetUnit:Count() .. " targets left.", 5, AttackSet, self.DesignateName )
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Recces[TargetUnit] = RecceUnit
|
||||||
|
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet, self.DesignateName )
|
||||||
|
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
|
||||||
|
MarkingCount = MarkingCount + 1
|
||||||
|
local TargetUnitType = TargetUnit:GetTypeName()
|
||||||
|
if not MarkedTypes[TargetUnitType] then
|
||||||
|
MarkedTypes[TargetUnitType] = true
|
||||||
|
ReportTypes:Add(TargetUnitType)
|
||||||
|
end
|
||||||
|
ReportLaserCodes:Add(RecceUnit.LaserCode)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
else
|
||||||
|
--RecceUnit:MessageToSetGroup( "Can't mark " .. 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 Recce = self.Recces[TargetUnit] -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
|
if Recce then
|
||||||
|
Recce:LaseOff()
|
||||||
|
Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet, self.DesignateName )
|
||||||
|
end
|
||||||
|
else
|
||||||
MarkingCount = MarkingCount + 1
|
MarkingCount = MarkingCount + 1
|
||||||
local TargetUnitType = TargetUnit:GetTypeName()
|
local TargetUnitType = TargetUnit:GetTypeName()
|
||||||
if not MarkedTypes[TargetUnitType] then
|
if not MarkedTypes[TargetUnitType] then
|
||||||
@ -1098,59 +1125,39 @@ do -- DESIGNATE
|
|||||||
ReportTypes:Add(TargetUnitType)
|
ReportTypes:Add(TargetUnitType)
|
||||||
end
|
end
|
||||||
ReportLaserCodes:Add(RecceUnit.LaserCode)
|
ReportLaserCodes:Add(RecceUnit.LaserCode)
|
||||||
return
|
end
|
||||||
end
|
|
||||||
else
|
|
||||||
--RecceUnit:MessageToSetGroup( "Can't mark " .. TargetUnit:GetTypeName(), 5, self.AttackSet )
|
|
||||||
end
|
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 Recce = self.Recces[TargetUnit] -- Wrapper.Unit#UNIT
|
|
||||||
|
|
||||||
if Recce then
|
|
||||||
Recce:LaseOff()
|
|
||||||
Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet, self.DesignateName )
|
|
||||||
end
|
|
||||||
else
|
|
||||||
MarkingCount = MarkingCount + 1
|
|
||||||
local TargetUnitType = TargetUnit:GetTypeName()
|
|
||||||
if not MarkedTypes[TargetUnitType] then
|
|
||||||
MarkedTypes[TargetUnitType] = true
|
|
||||||
ReportTypes:Add(TargetUnitType)
|
|
||||||
end
|
|
||||||
ReportLaserCodes:Add(RecceUnit.LaserCode)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
MarkingCount = MarkingCount + 1
|
||||||
|
local TargetUnitType = TargetUnit:GetTypeName()
|
||||||
|
if not MarkedTypes[TargetUnitType] then
|
||||||
|
MarkedTypes[TargetUnitType] = true
|
||||||
|
ReportTypes:Add(TargetUnitType)
|
||||||
|
end
|
||||||
|
ReportLaserCodes:Add(Recce.LaserCode)
|
||||||
|
--Recce:MessageToSetGroup( self.DesignateName .. ": Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
||||||
end
|
end
|
||||||
else
|
|
||||||
MarkingCount = MarkingCount + 1
|
|
||||||
local TargetUnitType = TargetUnit:GetTypeName()
|
|
||||||
if not MarkedTypes[TargetUnitType] then
|
|
||||||
MarkedTypes[TargetUnitType] = true
|
|
||||||
ReportTypes:Add(TargetUnitType)
|
|
||||||
end
|
|
||||||
ReportLaserCodes:Add(Recce.LaserCode)
|
|
||||||
--Recce:MessageToSetGroup( self.DesignateName .. ": Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
local MarkedTypesText = ReportTypes:Text(', ')
|
||||||
|
local MarkedLaserCodesText = ReportLaserCodes:Text(', ')
|
||||||
|
for MarkedType, MarketCount in pairs( MarkedTypes ) do
|
||||||
|
self.CC:GetPositionable():MessageToSetGroup( "Marking " .. MarkingCount .. " x " .. MarkedTypesText .. " with lasers " .. MarkedLaserCodesText .. ".", 5, self.AttackSet, self.DesignateName )
|
||||||
end
|
end
|
||||||
)
|
|
||||||
|
self:__Lasing( -30, Index, Duration, LaserCodeRequested )
|
||||||
|
|
||||||
|
self:SetDesignateMenu()
|
||||||
|
|
||||||
local MarkedTypesText = ReportTypes:Text(', ')
|
else
|
||||||
local MarkedLaserCodesText = ReportLaserCodes:Text(', ')
|
self:__LaseOff( 1 )
|
||||||
for MarkedType, MarketCount in pairs( MarkedTypes ) do
|
|
||||||
self.CC:GetPositionable():MessageToSetGroup( "Marking " .. MarkingCount .. " x " .. MarkedTypesText .. " with lasers " .. MarkedLaserCodesText .. ".", 5, self.AttackSet, self.DesignateName )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self:__Lasing( -30, Index, Duration )
|
|
||||||
|
|
||||||
self:SetDesignateMenu()
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user