Added smoke color per RECCE

This commit is contained in:
Applevangelist 2021-10-25 16:28:11 +02:00
parent 07754cdf5f
commit c52e30ceae

View File

@ -31,6 +31,7 @@
-- * Targets are lased by threat priority order -- * Targets are lased by threat priority order
-- * Use FSM events to link functionality into your scripts -- * Use FSM events to link functionality into your scripts
-- * Easy set-up -- * Easy set-up
-- * Set laser codes and smoke colors per Recce unit
-- --
-- # 2 Basic usage -- # 2 Basic usage
-- --
@ -46,7 +47,7 @@
-- --
-- local autolaser = AUTOLASE:New(FoxSet,coalition.side.BLUE,"Wolfpack",Pilotset) -- local autolaser = AUTOLASE:New(FoxSet,coalition.side.BLUE,"Wolfpack",Pilotset)
-- --
-- ## 2.5 Example - Using a fixed laser code for a specific Recce unit: -- ## 2.5 Example - Using a fixed laser code and color for a specific Recce unit:
-- --
-- local recce = SPAWN:New("Reaper") -- local recce = SPAWN:New("Reaper")
-- :InitDelayOff() -- :InitDelayOff()
@ -55,6 +56,7 @@
-- local unit = group:GetUnit(1) -- local unit = group:GetUnit(1)
-- local name = unit:GetName() -- local name = unit:GetName()
-- autolaser:SetRecceLaserCode(name,1688) -- autolaser:SetRecceLaserCode(name,1688)
-- autolaser:SetRecceSmokeColor(name,SMOKECOLOR.Red)
-- end -- end
-- ) -- )
-- :InitCleanUp(60) -- :InitCleanUp(60)
@ -107,7 +109,7 @@ AUTOLASE = {
--- AUTOLASE class version. --- AUTOLASE class version.
-- @field #string version -- @field #string version
AUTOLASE.version = "0.0.8" AUTOLASE.version = "0.0.9"
------------------------------------------------------------------- -------------------------------------------------------------------
-- Begin Functional.Autolase.lua -- Begin Functional.Autolase.lua
@ -169,6 +171,7 @@ function AUTOLASE:New(RecceSet, Coalition, Alias, PilotSet)
self.UnitsByThreat = {} self.UnitsByThreat = {}
self.RecceNames = {} self.RecceNames = {}
self.RecceLaserCode = {} self.RecceLaserCode = {}
self.RecceSmokeColor = {}
self.RecceUnitNames= {} self.RecceUnitNames= {}
self.maxlasing = 4 self.maxlasing = 4
self.CurrentLasing = {} self.CurrentLasing = {}
@ -330,6 +333,20 @@ function AUTOLASE:GetLaserCode(RecceName)
return code return code
end end
--- (Internal) Function to get a smoke color by recce name
-- @param #AUTOLASE self
-- @param #string RecceName Unit(!) name of the Recce
-- @return #AUTOLASE self
function AUTOLASE:GetSmokeColor(RecceName)
local color = self.smokecolor
if self.RecceSmokeColor[RecceName] == nil then
self.RecceSmokeColor[RecceName] = color
else
color = self.RecceLaserCode[RecceName]
end
return color
end
--- (User) Function enable sending messages via SRS. --- (User) Function enable sending messages via SRS.
-- @param #AUTOLASE self -- @param #AUTOLASE self
-- @param #boolean OnOff Switch usage on and off -- @param #boolean OnOff Switch usage on and off
@ -374,6 +391,17 @@ function AUTOLASE:SetRecceLaserCode(RecceName, Code)
return self return self
end end
--- (User) Function to set a specific smoke color for a Recce.
-- @param #AUTOLASE self
-- @param #string RecceName (Unit!) Name of the Recce
-- @param #number Color The color, e.g. SMOKECOLOR.Red, SMOKECOLOR.Green etc
-- @return #AUTOLASE self
function AUTOLASE:SetRecceSmokeColor(RecceName, Color)
local color = Color or self.smokecolor
self.RecceSmokeColor[RecceName] = color
return self
end
--- (User) Function to force laser cooldown and cool down time --- (User) Function to force laser cooldown and cool down time
-- @param #AUTOLASE self -- @param #AUTOLASE self
-- @param #boolean OnOff Switch cool down on (true) or off (false) - defaults to true -- @param #boolean OnOff Switch cool down on (true) or off (false) - defaults to true
@ -812,7 +840,8 @@ function AUTOLASE:onafterMonitor(From, Event, To)
} }
if self.smoketargets then if self.smoketargets then
local coord = unit:GetCoordinate() local coord = unit:GetCoordinate()
coord:Smoke(self.smokecolor) local color = self:GetSmokeColor(reccename)
coord:Smoke(color)
end end
self.lasingindex = self.lasingindex + 1 self.lasingindex = self.lasingindex + 1
self.CurrentLasing[self.lasingindex] = laserspot self.CurrentLasing[self.lasingindex] = laserspot