This commit is contained in:
FlightControl 2017-04-21 06:58:28 +02:00
parent f4fd7d43f3
commit a79bc11834

View File

@ -237,6 +237,9 @@ do -- AI_DESIGNATE
self:SetLaserCodes( 1688 ) self:SetLaserCodes( 1688 )
self.LaserCodesUsed = {}
self.Detection:__Start( 2 ) self.Detection:__Start( 2 )
@ -253,6 +256,8 @@ do -- AI_DESIGNATE
self.LaserCodes = ( type( LaserCodes ) == "table" ) and LaserCodes or { LaserCodes } self.LaserCodes = ( type( LaserCodes ) == "table" ) and LaserCodes or { LaserCodes }
self:E(self.LaserCodes) self:E(self.LaserCodes)
self.LaserCodesUsed = {}
return self return self
end end
@ -330,39 +335,35 @@ do -- AI_DESIGNATE
DesignateMenu DesignateMenu
) )
if self.Spots[Index] then MENU_GROUP_COMMAND:New(
AttackGroup,
MENU_GROUP_COMMAND:New( "Lase target 60 secs",
AttackGroup, DetectedMenu,
"Switch laser Off", self.MenuLaseOn,
DetectedMenu, self,
self.MenuLaseOff, AttackGroup,
self, Index,
AttackGroup, 60
Index )
) MENU_GROUP_COMMAND:New(
else AttackGroup,
MENU_GROUP_COMMAND:New( "Lase target 120 secs",
AttackGroup, DetectedMenu,
"Lase target 60 secs", self.MenuLaseOn,
DetectedMenu, self,
self.MenuLaseOn, AttackGroup,
self, Index,
AttackGroup, 120
Index, )
60 MENU_GROUP_COMMAND:New(
) AttackGroup,
MENU_GROUP_COMMAND:New( "Switch laser Off",
AttackGroup, DetectedMenu,
"Lase target 120 secs", self.MenuLaseOff,
DetectedMenu, self,
self.MenuLaseOn, AttackGroup,
self, Index
AttackGroup, )
Index,
120
)
end
MENU_GROUP_COMMAND:New( MENU_GROUP_COMMAND:New(
AttackGroup, AttackGroup,
@ -425,32 +426,37 @@ do -- AI_DESIGNATE
function AI_DESIGNATE:onafterLasing( From, Event, To, AttackGroup, Index, Duration ) function AI_DESIGNATE:onafterLasing( From, Event, To, AttackGroup, Index, Duration )
local TargetSetUnit = self.Detection:GetDetectedSet( Index ) local TargetSetUnit = self.Detection:GetDetectedSet( Index )
local Targets = false local Targets = false
TargetSetUnit:ForEachUnit( TargetSetUnit:ForEachUnit(
--- @param Wrapper.Unit#UNIT SmokeUnit --- @param Wrapper.Unit#UNIT SmokeUnit
function( SmokeUnit ) function( TargetUnit )
self:E("In procedure") self:E("In procedure")
--if math.random( 1, ( 100 * TargetSetUnit:Count() ) / 100 ) <= 100 then --if math.random( 1, ( 100 * TargetSetUnit:Count() ) / 100 ) <= 100 then
if SmokeUnit:IsAlive() then if TargetUnit:IsAlive() then
local NearestRecceGroup = self.RecceSet:FindNearestGroupFromPointVec2( SmokeUnit:GetPointVec2() ) local Spot = self.Spots[TargetUnit]
if NearestRecceGroup then if (not Spot) or ( Spot and Spot:IsLasing() == false ) then
for UnitID, UnitData in pairs( NearestRecceGroup:GetUnits() or {} ) do local NearestRecceGroup = self.RecceSet:FindNearestGroupFromPointVec2( TargetUnit:GetPointVec2() )
local RecceUnit = UnitData -- Wrapper.Unit#UNIT if NearestRecceGroup then
Targets = true for UnitID, UnitData in pairs( NearestRecceGroup:GetUnits() or {} ) do
if RecceUnit:IsLasing() == false then local RecceUnit = UnitData -- Wrapper.Unit#UNIT
self.Spots[Index] = self.Spots[Index] or {} Targets = true
local Spots = self.Spots[Index] if RecceUnit:IsLasing() == false then
local LaserCode = self.LaserCodes[math.random(1, #self.LaserCodes)] local LaserCode = self.LaserCodes[math.random(1, #self.LaserCodes)]
local Spot = RecceUnit:LaseUnit( SmokeUnit, LaserCode, Duration ) local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
Spots[RecceUnit] = Spot self.Spots[TargetUnit] = Spot
RecceUnit:MessageToGroup( "Lasing " .. SmokeUnit:GetTypeName() .. " for " .. Duration .. " seconds. Laser Code: " .. Spot.LaserCode, 15, AttackGroup ) RecceUnit:MessageToGroup( "Lasing " .. TargetUnit:GetTypeName() .. " for " .. Duration .. " seconds. Laser Code: " .. Spot.LaserCode, 15, AttackGroup )
break break
else end
end end
end end
else
local RecceUnit = Spot.Recce
RecceUnit:MessageToGroup( "Lasing " .. TargetUnit:GetTypeName() .. " for " .. Duration .. " seconds. Laser Code: " .. Spot.LaserCode, 15, AttackGroup )
end end
else
self.Spots[TargetUnit] = nil
end end
--end --end
end end
@ -473,7 +479,7 @@ do -- AI_DESIGNATE
local TargetSetUnit = self.Detection:GetDetectedSet( Index ) local TargetSetUnit = self.Detection:GetDetectedSet( Index )
local Spots = self.Spots[Index] local Spots = self.Spots
for SpotID, SpotData in pairs( Spots ) do for SpotID, SpotData in pairs( Spots ) do
local Spot = SpotData -- Core.Spot#SPOT local Spot = SpotData -- Core.Spot#SPOT
@ -482,7 +488,7 @@ do -- AI_DESIGNATE
end end
Spots = nil Spots = nil
self.Spots[Index] = nil self.Spots = {}
self:SetDesignateMenu() self:SetDesignateMenu()
end end