diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index f799bf2e2..1e316d905 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -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,22 +1898,21 @@ 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 - type = AUFTRAG.Type.SEAD - --ttstype = "suppress air defense" - ttstype = self.gettext:GetEntry("SEADTTS",self.locale) - end + if self:_IsAttributeSead(attribute) then + type = AUFTRAG.Type.SEAD + --ttstype = "suppress air defense" + ttstype = self.gettext:GetEntry("SEADTTS",self.locale) + end elseif targetobject:IsInstanceOf("SET_GROUP") then self:T("SEAD Check SET_GROUP") 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 - type = AUFTRAG.Type.SEAD - --ttstype = "suppress air defense" - ttstype = self.gettext:GetEntry("SEADTTS",self.locale) - end - end + if self:_IsAttributeSead(attribute) then + type = AUFTRAG.Type.SEAD + --ttstype = "suppress air defense" + ttstype = self.gettext:GetEntry("SEADTTS",self.locale) + end ) elseif targetobject:IsInstanceOf("SET_UNIT") then self:T("SEAD Check SET_UNIT") @@ -2741,4 +2786,3 @@ end -- END PLAYERTASKCONTROLLER ----- end -