mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#AUTOLASE
* Added option for blacklist atttributes * Added higher priority for radar units * Removed the "#001-01" appendix of spawned Recce on messages
This commit is contained in:
parent
c0bc3d8061
commit
27408c191d
@ -111,7 +111,7 @@ AUTOLASE = {
|
|||||||
|
|
||||||
--- AUTOLASE class version.
|
--- AUTOLASE class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AUTOLASE.version = "0.1.15"
|
AUTOLASE.version = "0.1.20"
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
-- Begin Functional.Autolase.lua
|
-- Begin Functional.Autolase.lua
|
||||||
@ -195,6 +195,7 @@ function AUTOLASE:New(RecceSet, Coalition, Alias, PilotSet)
|
|||||||
self.SRSMod = radio.modulation.AM
|
self.SRSMod = radio.modulation.AM
|
||||||
self.NoMenus = false
|
self.NoMenus = false
|
||||||
self.minthreatlevel = 0
|
self.minthreatlevel = 0
|
||||||
|
self.blacklistattributes = {}
|
||||||
|
|
||||||
-- Set some string id for output to DCS.log file.
|
-- Set some string id for output to DCS.log file.
|
||||||
self.lid=string.format("AUTOLASE %s (%s) | ", self.alias, self.coalition and UTILS.GetCoalitionName(self.coalition) or "unknown")
|
self.lid=string.format("AUTOLASE %s (%s) | ", self.alias, self.coalition and UTILS.GetCoalitionName(self.coalition) or "unknown")
|
||||||
@ -307,7 +308,7 @@ function AUTOLASE:SetPilotMenu()
|
|||||||
local Unit = _unit -- Wrapper.Unit#UNIT
|
local Unit = _unit -- Wrapper.Unit#UNIT
|
||||||
if Unit and Unit:IsAlive() then
|
if Unit and Unit:IsAlive() then
|
||||||
local Group = Unit:GetGroup()
|
local Group = Unit:GetGroup()
|
||||||
local lasemenu = MENU_GROUP_COMMAND:New(Group,"Autolase Status",nil,self.ShowStatus,self,Group)
|
local lasemenu = MENU_GROUP_COMMAND:New(Group,"Autolase Status",nil,self.ShowStatus,self,Group,Unit)
|
||||||
lasemenu:Refresh()
|
lasemenu:Refresh()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -341,6 +342,29 @@ function AUTOLASE:SetMinThreatLevel(Level)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (User) Set list of #UNIT level attributes that won't be lased. For list of attributes see [Hoggit Wiki](https://wiki.hoggitworld.com/view/DCS_enum_attributes) and [GitHub](https://github.com/mrSkortch/DCS-miscScripts/tree/master/ObjectDB)
|
||||||
|
-- @param #AUTOLASE self
|
||||||
|
-- @param #table Attributes Table of #string attributes to blacklist. Can be handed over as a single #string.
|
||||||
|
-- @return #AUTOLASE self
|
||||||
|
-- @usage To exclude e.g. manpads from being lased:
|
||||||
|
--
|
||||||
|
-- `myautolase:AddBlackListAttributes("MANPADS")`
|
||||||
|
--
|
||||||
|
-- To exclude trucks and artillery:
|
||||||
|
--
|
||||||
|
-- `myautolase:AddBlackListAttributes({"Trucks","Artillery"})`
|
||||||
|
--
|
||||||
|
function AUTOLASE:AddBlackListAttributes(Attributes)
|
||||||
|
local attributes = Attributes
|
||||||
|
if type(attributes) ~= "table" then
|
||||||
|
attributes = {attributes}
|
||||||
|
end
|
||||||
|
for _,_attr in pairs(attributes) do
|
||||||
|
table.insert(self.blacklistattributes,_attr)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- (Internal) Function to get a laser code by recce name
|
--- (Internal) Function to get a laser code by recce name
|
||||||
-- @param #AUTOLASE self
|
-- @param #AUTOLASE self
|
||||||
-- @param #string RecceName Unit(!) name of the Recce
|
-- @param #string RecceName Unit(!) name of the Recce
|
||||||
@ -613,15 +637,19 @@ end
|
|||||||
--- (Internal) Function to show status.
|
--- (Internal) Function to show status.
|
||||||
-- @param #AUTOLASE self
|
-- @param #AUTOLASE self
|
||||||
-- @param Wrapper.Group#GROUP Group (Optional) show to a certain group
|
-- @param Wrapper.Group#GROUP Group (Optional) show to a certain group
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit (Optional) show to a certain unit
|
||||||
-- @return #AUTOLASE self
|
-- @return #AUTOLASE self
|
||||||
function AUTOLASE:ShowStatus(Group)
|
function AUTOLASE:ShowStatus(Group,Unit)
|
||||||
local report = REPORT:New("Autolase")
|
local report = REPORT:New("Autolase")
|
||||||
local reccetable = self.RecceSet:GetSetObjects()
|
local reccetable = self.RecceSet:GetSetObjects()
|
||||||
for _,_recce in pairs(reccetable) do
|
for _,_recce in pairs(reccetable) do
|
||||||
if _recce and _recce:IsAlive() then
|
if _recce and _recce:IsAlive() then
|
||||||
local unit = _recce:GetUnit(1)
|
local unit = _recce:GetUnit(1)
|
||||||
local name = unit:GetName()
|
local name = unit:GetName()
|
||||||
local code = self:GetLaserCode(name)
|
if string.find(name,"#") then
|
||||||
|
name = string.match(name,"^(.*)#")
|
||||||
|
end
|
||||||
|
local code = self:GetLaserCode(unit:GetName())
|
||||||
report:Add(string.format("Recce %s has code %d",name,code))
|
report:Add(string.format("Recce %s has code %d",name,code))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -629,10 +657,18 @@ function AUTOLASE:ShowStatus(Group)
|
|||||||
for _ind,_entry in pairs(self.CurrentLasing) do
|
for _ind,_entry in pairs(self.CurrentLasing) do
|
||||||
local entry = _entry -- #AUTOLASE.LaserSpot
|
local entry = _entry -- #AUTOLASE.LaserSpot
|
||||||
local reccename = entry.reccename
|
local reccename = entry.reccename
|
||||||
|
if string.find(reccename,"#") then
|
||||||
|
reccename = string.match(reccename,"^(.*)#")
|
||||||
|
end
|
||||||
local typename = entry.unittype
|
local typename = entry.unittype
|
||||||
local code = entry.lasercode
|
local code = entry.lasercode
|
||||||
local locationstring = entry.location
|
local locationstring = entry.location
|
||||||
local playername = Group:GetPlayerName()
|
local playername = nil
|
||||||
|
if Unit and Unit:IsAlive() then
|
||||||
|
playername = Unit:GetPlayerName()
|
||||||
|
elseif Group and Group:IsAlive() then
|
||||||
|
playername = Group:GetPlayerName()
|
||||||
|
end
|
||||||
if playername then
|
if playername then
|
||||||
local settings = _DATABASE:GetPlayerSettings(playername)
|
local settings = _DATABASE:GetPlayerSettings(playername)
|
||||||
if settings then
|
if settings then
|
||||||
@ -652,7 +688,9 @@ function AUTOLASE:ShowStatus(Group)
|
|||||||
end
|
end
|
||||||
local reporttime = self.reporttimelong
|
local reporttime = self.reporttimelong
|
||||||
if lines == 0 then reporttime = self.reporttimeshort end
|
if lines == 0 then reporttime = self.reporttimeshort end
|
||||||
if Group and Group:IsAlive() then
|
if Unit and Unit:IsAlive() then
|
||||||
|
local m = MESSAGE:New(report:Text(),reporttime,"Info"):ToUnit(Unit)
|
||||||
|
elseif Group and Group:IsAlive() then
|
||||||
local m = MESSAGE:New(report:Text(),reporttime,"Info"):ToGroup(Group)
|
local m = MESSAGE:New(report:Text(),reporttime,"Info"):ToGroup(Group)
|
||||||
else
|
else
|
||||||
local m = MESSAGE:New(report:Text(),reporttime,"Info"):ToCoalition(self.coalition)
|
local m = MESSAGE:New(report:Text(),reporttime,"Info"):ToCoalition(self.coalition)
|
||||||
@ -724,6 +762,20 @@ end
|
|||||||
-- @param Wrapper.Unit#UNIT Unit The lased #UNIT
|
-- @param Wrapper.Unit#UNIT Unit The lased #UNIT
|
||||||
-- @return #boolean outcome True or false
|
-- @return #boolean outcome True or false
|
||||||
function AUTOLASE:CanLase(Recce,Unit)
|
function AUTOLASE:CanLase(Recce,Unit)
|
||||||
|
|
||||||
|
local function HasNoBlackListAttribute(Unit)
|
||||||
|
local nogos = self.blacklistattributes or {}
|
||||||
|
local having = true
|
||||||
|
local unit = Unit -- Wrapper.Unit#UNIT
|
||||||
|
for _,_attribute in pairs (nogos) do
|
||||||
|
if unit:HasAttribute(_attribute) then
|
||||||
|
having = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return having
|
||||||
|
end
|
||||||
|
|
||||||
local canlase = false
|
local canlase = false
|
||||||
-- cooldown?
|
-- cooldown?
|
||||||
if Recce and Recce:IsAlive() == true then
|
if Recce and Recce:IsAlive() == true then
|
||||||
@ -744,7 +796,7 @@ function AUTOLASE:CanLase(Recce,Unit)
|
|||||||
-- calculate distance
|
-- calculate distance
|
||||||
local distance = math.floor(reccecoord:Get3DDistance(unitcoord))
|
local distance = math.floor(reccecoord:Get3DDistance(unitcoord))
|
||||||
local lasedistance = self:GetLosFromUnit(Recce)
|
local lasedistance = self:GetLosFromUnit(Recce)
|
||||||
if distance <= lasedistance and islos then
|
if distance <= lasedistance and islos and HasNoBlackListAttribute(Unit) then
|
||||||
canlase = true
|
canlase = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -836,6 +888,10 @@ function AUTOLASE:onafterMonitor(From, Event, To)
|
|||||||
local coord = unit:GetCoordinate()
|
local coord = unit:GetCoordinate()
|
||||||
if threat > 0 then
|
if threat > 0 then
|
||||||
local unitname = unit:GetName()
|
local unitname = unit:GetName()
|
||||||
|
-- prefer radar units
|
||||||
|
if unit:HasAttribute("RADAR_BAND1_FOR_ARM") or unit:HasAttribute("RADAR_BAND2_FOR_ARM") or unit:HasAttribute("Optical Tracker") then
|
||||||
|
threat = 11
|
||||||
|
end
|
||||||
table.insert(unitsbythreat,{unit,threat})
|
table.insert(unitsbythreat,{unit,threat})
|
||||||
self.RecceUnitNames[unitname] = reccename
|
self.RecceUnitNames[unitname] = reccename
|
||||||
end
|
end
|
||||||
@ -1001,7 +1057,11 @@ function AUTOLASE:onbeforeLasing(From,Event,To,LaserSpot)
|
|||||||
self:T({From, Event, To, LaserSpot.unittype})
|
self:T({From, Event, To, LaserSpot.unittype})
|
||||||
if self.notifypilots or self.debug then
|
if self.notifypilots or self.debug then
|
||||||
local laserspot = LaserSpot -- #AUTOLASE.LaserSpot
|
local laserspot = LaserSpot -- #AUTOLASE.LaserSpot
|
||||||
local text = string.format("%s is lasing %s code %d\nat %s",laserspot.reccename,laserspot.unittype,laserspot.lasercode,laserspot.location)
|
local name = laserspot.reccename
|
||||||
|
if string.find(name,"#") then
|
||||||
|
name = string.match(name,"^(.*)#")
|
||||||
|
end
|
||||||
|
local text = string.format("%s is lasing %s code %d\nat %s",name,laserspot.unittype,laserspot.lasercode,laserspot.location)
|
||||||
self:NotifyPilots(text,self.reporttimeshort+5)
|
self:NotifyPilots(text,self.reporttimeshort+5)
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user