PlayerTaskController - SEAD attributes configure (#1769)

Making SEAD attributes for the task decision tree configure-able. Added ` PLAYERTASKCONTROLLER:SetSEADAttributes(Attributes)`
This commit is contained in:
Thomas 2022-08-31 16:57:20 +02:00 committed by GitHub
parent b4e2d3edfe
commit c99a7b6666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -992,6 +992,17 @@ PLAYERTASKCONTROLLER.Type = {
--- Define a new AUFTRAG Type
AUFTRAG.Type.PRECISIONBOMBING = "Precision Bombing"
---
-- @type SeadAttributes
-- @field #number SAM GROUP.Attribute.GROUND_SAM
-- @field #number AAA GROUP.Attribute.GROUND_AAA
-- @field #number EWR GROUP.Attribute.GROUND_EWR
PLAYERTASKCONTROLLER.SeadAttributes = {
SAM = GROUP.Attribute.GROUND_SAM,
AAA = GROUP.Attribute.GROUND_AAA,
EWR = GROUP.Attribute.GROUND_EWR,
}
---
-- @field Messages
PLAYERTASKCONTROLLER.Messages = {
@ -1109,7 +1120,7 @@ PLAYERTASKCONTROLLER.Messages = {
--- PLAYERTASK class version.
-- @field #string version
PLAYERTASKCONTROLLER.version="0.1.25"
PLAYERTASKCONTROLLER.version="0.1.26"
--- Constructor
-- @param #PLAYERTASKCONTROLLER self
@ -1825,6 +1836,41 @@ function PLAYERTASKCONTROLLER:SetTaskBlackList(BlackList)
return self
end
--- [User] Change the list of attributes, which are considered on GROUP or SET\_GROUP level of a target to create SEAD player tasks.
-- @param #PLAYERTASKCONTROLLER self
-- @param #table Attributes Table of attribute types considered to lead to a SEAD type player task.
-- @return #PLAYERTASKCONTROLLER self
-- @usage
-- Default attribute types are: GROUP.Attribute.GROUND_SAM, GROUP.Attribute.GROUND_AAA, and GROUP.Attribute.GROUND_EWR.
-- If you want to e.g. exclude AAA, so target groups with this attribute are assigned CAS or BAI tasks, and not SEAD, use this function as follows:
--
-- `mycontroller:SetSEADAttributes({GROUP.Attribute.GROUND_SAM, GROUP.Attribute.GROUND_EWR})`
--
function PLAYERTASKCONTROLLER:SetSEADAttributes(Attributes)
self:T(self.lid.."SetSEADAttributes")
if type(Attributes) ~= table then
Attributes = {Attributes}
end
self.SeadAttributes = Attributes
return self
end
--- [Internal] Function the check against SeadAttributes
-- @param #PLAYERTASKCONTROLLER self
-- @param #string Attribute
-- @return #boolean IsSead
function PLAYERTASKCONTROLLER:_IsAttributeSead(Attribute)
self:T(self.lid.."_IsAttributeSead?")
local IsSead = false
for _,_attribute in pairs(self.SeadAttributes) do
if Attribute == _attribute then
IsSead = true
break
end
end
return IsSead
end
--- [Internal] Add a task to the task queue
-- @param #PLAYERTASKCONTROLLER self
-- @param Ops.Target#TARGET Target
@ -1852,7 +1898,7 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
elseif targetobject:IsInstanceOf("GROUP") then
self:T("SEAD Check GROUP")
local attribute = targetobject:GetAttribute()
if attribute == GROUP.Attribute.GROUND_SAM or attribute == GROUP.Attribute.GROUND_AAA or attribute == GROUP.Attribute.GROUND_EWR then
if self:_IsAttributeSead(attribute) then
type = AUFTRAG.Type.SEAD
--ttstype = "suppress air defense"
ttstype = self.gettext:GetEntry("SEADTTS",self.locale)
@ -1862,12 +1908,11 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
targetobject:ForEachGroup(
function (group)
local attribute = group:GetAttribute()
if attribute == GROUP.Attribute.GROUND_SAM or attribute == GROUP.Attribute.GROUND_AAA or attribute == GROUP.Attribute.GROUND_EWR then
if self:_IsAttributeSead(attribute) then
type = AUFTRAG.Type.SEAD
--ttstype = "suppress air defense"
ttstype = self.gettext:GetEntry("SEADTTS",self.locale)
end
end
)
elseif targetobject:IsInstanceOf("SET_UNIT") then
self:T("SEAD Check SET_UNIT")
@ -2741,4 +2786,3 @@ end
-- END PLAYERTASKCONTROLLER
-----
end