mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
#PLAYERTASK
* Added option to whitelist task types * Added localization. Contains "en" and "de" texts and tts texts
This commit is contained in:
parent
0166b53e21
commit
c38a737421
@ -683,6 +683,10 @@ end
|
||||
-- @field #string MenuName
|
||||
-- @field #boolean NoScreenOutput
|
||||
-- @field #number TargetRadius
|
||||
-- @field #boolean UseWhiteList
|
||||
-- @field #table WhiteList
|
||||
-- @field Core.TextAndSound#TEXTANDSOUND gettext
|
||||
-- @field #string locale
|
||||
--
|
||||
|
||||
|
||||
@ -701,6 +705,10 @@ PLAYERTASKCONTROLLER = {
|
||||
ClusterRadius = 1250,
|
||||
NoScreenOutput = false,
|
||||
TargetRadius = 500,
|
||||
UseWhiteList = false,
|
||||
WhiteList = {},
|
||||
gettext = nil,
|
||||
locale = "en",
|
||||
}
|
||||
|
||||
---
|
||||
@ -711,9 +719,112 @@ PLAYERTASKCONTROLLER.Type = {
|
||||
["A2S"] = "Air-To-Sea",
|
||||
}
|
||||
|
||||
---
|
||||
-- @field Messages
|
||||
PLAYERTASKCONTROLLER.Messages = {
|
||||
EN = {
|
||||
TASKABORT = "Task aborted!",
|
||||
NOACTIVETASK = "No active task!",
|
||||
FREQUENCIES = "frequencies ",
|
||||
FREQUENCY = "frequency %.3f",
|
||||
BROADCAST = "%s, %s, switch to %s for task assignment!",
|
||||
CASTTS = "close air support",
|
||||
SEADTTS = "suppress air defense",
|
||||
BOMBTTS = "bombing",
|
||||
BAITTS = "battle field air interdiction",
|
||||
ANTISHIPTTS = "anti-ship",
|
||||
INTERCEPTTS = "intercept",
|
||||
BOMBRUNWAYTTS = "bomb runway",
|
||||
HAVEACTIVETASK = "You already have one active task! Complete it first!",
|
||||
PILOTJOINEDTASK = "%s, pilot %s joined task %03d",
|
||||
TASKNAME = "%s Task ID %03d",
|
||||
TASKNAMETTS = "%s Task ID %03d",
|
||||
THREATHIGH = "high",
|
||||
THREATMEDIUM = "medium",
|
||||
THREATLOW = "low",
|
||||
THREATTEXT = "%s\nThreat: %s\nTargets left: %d\nCoord: %s",
|
||||
THREATTEXTTTS = "%s, %s. Target information for %s. Threat level %s. Targets left %d. Target location %s.",
|
||||
MARKTASK = "%s, copy pilot %s, task %03d location marked on map!",
|
||||
SMOKETASK = "%s, copy pilot %s, task %03d location smoked!",
|
||||
FLARETASK = "%s, copy pilot %s, task %03d location illuminated!",
|
||||
ABORTTASK = "%s, all stations, pilot %s aborted task %03d!",
|
||||
UNKNOWN = "Unknown",
|
||||
MENUTASKING = " Tasking ",
|
||||
MENUACTIVE = "Active Task",
|
||||
MENUINFO = "Info",
|
||||
MENUMARK = "Mark on map",
|
||||
MENUSMOKE = "Smoke",
|
||||
MENUFLARE = "Flare",
|
||||
MENUABORT = "Abort",
|
||||
MENUJOIN = "Join Task",
|
||||
MENUTASKNO = "TaskNo",
|
||||
MENUNOTASKS = "Currently no tasks available.",
|
||||
TASKCANCELLED = "Task #%03d %s is cancelled!",
|
||||
TASKCANCELLEDTTS = "%s, task %03d %s is cancelled!",
|
||||
TASKSUCCESS = "Task #%03d %s completed successfully!",
|
||||
TASKSUCCESSTTS = "%s, task %03d %s completed successfully!",
|
||||
TASKFAILED = "Task #%03d %s was a failure!",
|
||||
TASKFAILEDTTS = "%s, task %03d %s was a failure!",
|
||||
TASKFAILEDREPLAN = "Task #%03d %s was a failure! Replanning!",
|
||||
TASKFAILEDREPLANTTS = "%s, task %03d %s was a failure! Replanning!",
|
||||
TASKADDED = "%s has a new task %s",
|
||||
PILOTS = "\nPilot(s): ",
|
||||
PILOTSTTS = ". Pilot(s): ",
|
||||
},
|
||||
DE = {
|
||||
TASKABORT = "Auftrag abgebrochen!",
|
||||
NOACTIVETASK = "Kein aktiver Auftrag!",
|
||||
FREQUENCIES = "Frequenzen ",
|
||||
FREQUENCY = "Frequenz %.3f",
|
||||
BROADCAST = "%s, %s, Radio %s für Aufgabenzuteilung!",
|
||||
CASTTS = "Nahbereichsunterstützung",
|
||||
SEADTTS = "Luftabwehr ausschalten",
|
||||
BOMBTTS = "Bombardieren",
|
||||
BAITTS = "Luftunterstützung",
|
||||
ANTISHIPTTS = "Anti-Schiff",
|
||||
INTERCEPTTS = "Abfangen",
|
||||
BOMBRUNWAYTTS = "Startbahn Bombardieren",
|
||||
HAVEACTIVETASK = "Du hast einen aktiven Auftrag! Beende ihn zuerst!",
|
||||
PILOTJOINEDTASK = "%s, Pilot %s hat Auftrag %03d angenommen",
|
||||
TASKNAME = "%s Auftrag ID %03d",
|
||||
TASKNAMETTS = "%s Auftrag ID %03d",
|
||||
THREATHIGH = "hoch",
|
||||
THREATMEDIUM = "mittel",
|
||||
THREATLOW = "niedrig",
|
||||
THREATTEXT = "%s\nGefahrstufe: %s\nZiele: %d\nKoord: %s",
|
||||
THREATTEXTTTS = "%s, %s. Zielinformation zu %s. Gefahrstufe %s. Ziele %d. Zielposition %s.",
|
||||
MARKTASK = "%s, verstanden Pilot %s, Auftrag %03d auf der Karte markiert!",
|
||||
SMOKETASK = "%s, verstanden Pilot %s, Auftrag %03d mit Rauch markiert!",
|
||||
FLARETASK = "%s, verstanden Pilot %s, Auftrag %03d beleuchtet!",
|
||||
ABORTTASK = "%s, an alle, Pilot %s hat Auftrag %03d abgebrochen!",
|
||||
UNKNOWN = "Unbekannt",
|
||||
MENUTASKING = " Aufträge ",
|
||||
MENUACTIVE = "Aktiver Auftrag",
|
||||
MENUINFO = "Information",
|
||||
MENUMARK = "Kartenmarkierung",
|
||||
MENUSMOKE = "Rauchgranate",
|
||||
MENUFLARE = "Leuchtgranate",
|
||||
MENUABORT = "Abbrechen",
|
||||
MENUJOIN = "Auftrag annehmen",
|
||||
MENUTASKNO = "AuftragsNr",
|
||||
MENUNOTASKS = "Momentan keine Aufträge verfügbar.",
|
||||
TASKCANCELLED = "Auftrag #%03d %s wurde beendet!",
|
||||
TASKCANCELLEDTTS = "%s, Auftrag %03d %s wurde beendet!",
|
||||
TASKSUCCESS = "Auftrag #%03d %s erfolgreich!",
|
||||
TASKSUCCESSTTS = "%s, Auftrag %03d %s erfolgreich!",
|
||||
TASKFAILED = "Auftrag #%03d %s gescheitert!",
|
||||
TASKFAILEDTTS = "%s, Auftrag %03d %s gescheitert!",
|
||||
TASKFAILEDREPLAN = "Auftrag #%03d %s gescheitert! Neuplanung!",
|
||||
TASKFAILEDREPLANTTS = "%s, Auftrag %03d %s gescheitert! Neuplanung!",
|
||||
TASKADDED = "%s hat einen neuen Auftrag %s",
|
||||
PILOTS = "\nPilot(en): ",
|
||||
PILOTSTTS = ". Pilot(en): ",
|
||||
},
|
||||
}
|
||||
|
||||
--- PLAYERTASK class version.
|
||||
-- @field #string version
|
||||
PLAYERTASKCONTROLLER.version="0.0.12"
|
||||
PLAYERTASKCONTROLLER.version="0.1.14"
|
||||
|
||||
--- Constructor
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
@ -761,6 +872,8 @@ function PLAYERTASKCONTROLLER:New(Name, Coalition, Type, ClientFilter)
|
||||
|
||||
self.lid=string.format("PlayerTaskController %s %s | ", self.Name, tostring(self.Type))
|
||||
|
||||
self:_InitLocalization()
|
||||
|
||||
-- FSM start state is STOPPED.
|
||||
self:SetStartState("Stopped")
|
||||
|
||||
@ -784,7 +897,7 @@ function PLAYERTASKCONTROLLER:New(Name, Coalition, Type, ClientFilter)
|
||||
self:HandleEvent(EVENTS.PilotDead, self._EventHandler)
|
||||
self:HandleEvent(EVENTS.PlayerEnterAircraft, self._EventHandler)
|
||||
|
||||
self:I(self.lid.."Started.")
|
||||
self:I(self.lid..self.version.." Started.")
|
||||
|
||||
return self
|
||||
|
||||
@ -842,6 +955,21 @@ function PLAYERTASKCONTROLLER:New(Name, Coalition, Type, ClientFilter)
|
||||
|
||||
end
|
||||
|
||||
function PLAYERTASKCONTROLLER:_InitLocalization()
|
||||
self:T(self.lid.."_InitLocalization")
|
||||
self.gettext = TEXTANDSOUND:New("PLAYERTASKCONTROLLER","en") -- Core.TextAndSound#TEXTANDSOUND
|
||||
self.locale = "en"
|
||||
for locale,table in pairs(self.Messages) do
|
||||
local Locale = string.lower(tostring(locale))
|
||||
self:T("**** Adding locale: "..Locale)
|
||||
for ID,Text in pairs(table) do
|
||||
self:T(string.format('Adding ID %s',tostring(ID)))
|
||||
self.gettext:AddEntry(Locale,tostring(ID),Text)
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- [internal] Event handling
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
@ -861,10 +989,12 @@ function PLAYERTASKCONTROLLER:_EventHandler(EventData)
|
||||
local Client = _DATABASE:FindClient( EventData.IniPlayerName )
|
||||
if Client then
|
||||
task:RemoveClient(Client)
|
||||
text = "Task aborted!"
|
||||
--text = "Task aborted!"
|
||||
text = self.gettext:GetEntry("TASKABORT",self.locale)
|
||||
end
|
||||
else
|
||||
text = "No active task!"
|
||||
--text = "No active task!"
|
||||
text = self.gettext:GetEntry("NOACTIVETASK",self.locale)
|
||||
end
|
||||
self:T(self.lid..text)
|
||||
end
|
||||
@ -874,14 +1004,18 @@ function PLAYERTASKCONTROLLER:_EventHandler(EventData)
|
||||
local frequency = self.Frequency
|
||||
local freqtext = ""
|
||||
if type(frequency) == "table" then
|
||||
freqtext = "frequencies "..table.concat(frequency,", ")
|
||||
freqtext = self.gettext:GetEntry("FREQUENCIES",self.locale)
|
||||
freqtext = freqtext..table.concat(frequency,", ")
|
||||
else
|
||||
freqtext = string.format("frequency %.3f",frequency)
|
||||
local freqt = self.gettext:GetEntry("FREQUENCY",self.locale)
|
||||
freqtext = string.format(freqt,frequency)
|
||||
end
|
||||
local modulation = self.Modulation
|
||||
if type(modulation) == "table" then modulation = modulation[1] end
|
||||
modulation = UTILS.GetModulationName(modulation)
|
||||
local text = string.format("%s, %s, switch to %s for task assignment!",EventData.IniPlayerName,self.MenuName or self.Name,freqtext)
|
||||
local switchtext = self.gettext:GetEntry("BROADCAST",self.locale)
|
||||
--local text = string.format("%s, %s, switch to %s for task assignment!",EventData.IniPlayerName,self.MenuName or self.Name,freqtext)
|
||||
local text = string.format(switchtext,self.MenuName or self.Name,EventData.IniPlayerName,freqtext)
|
||||
self.SRSQueue:NewTransmission(text,nil,self.SRS,timer.getAbsTime()+60,2,{EventData.IniGroup},text,30,self.BCFrequency,self.BCModulation)
|
||||
end
|
||||
end
|
||||
@ -893,6 +1027,16 @@ function PLAYERTASKCONTROLLER:_DummyMenu(group)
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Set locale for localization. Defaults to "en"
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
-- @param #string Locale The locale to use
|
||||
-- @return #PLAYERTASKCONTROLLER self
|
||||
function PLAYERTASKCONTROLLER:SetLocale(Locale)
|
||||
self:T(self.lid.."SetLocale")
|
||||
self.locale = Locale or "en"
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Switch screen output.
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
-- @param #boolean OnOff. Switch screen output off (true) or on (false)
|
||||
@ -1056,6 +1200,45 @@ function PLAYERTASKCONTROLLER:AddTarget(Target)
|
||||
return self
|
||||
end
|
||||
|
||||
--- [Internal] Check for allowed task type, if there is a (positive) whitelist
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
-- @param #string Type
|
||||
-- @return #boolean Outcome
|
||||
function PLAYERTASKCONTROLLER:_CheckTaskTypeAllowed(Type)
|
||||
self:T(self.lid.."_CheckTaskTypeAllowed")
|
||||
local Outcome = false
|
||||
if self.UseWhiteList then
|
||||
for _,_type in pairs(self.WhiteList) do
|
||||
if Type == _type then
|
||||
Outcome = true
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
return true
|
||||
end
|
||||
return Outcome
|
||||
end
|
||||
|
||||
--- [User] Set up a (positive) whitelist of allowed task types. Only these types will be generated.
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
-- @param #table WhiteList Table of task types that can be generated. Use to restrict available types.
|
||||
-- @return #PLAYERTASKCONTROLLER self
|
||||
-- @usage Currently, the following task types will be generated, if detection has been set up:
|
||||
-- A2A - AUFTRAG.Type.INTERCEPT
|
||||
-- A2S - AUFTRAG.Type.ANTISHIP
|
||||
-- A2G - AUFTRAG.Type.CAS, AUFTRAG.Type.BAI, AUFTRAG.Type.SEAD, AUFTRAG.Type.BOMBING, AUFTRAG.Type.BOMBRUNWAY
|
||||
-- If you don't want SEAD tasks generated, use as follows:
|
||||
--
|
||||
-- `mycontroller:SetTaskWhiteList(AUFTRAG.Type.CAS, AUFTRAG.Type.BAI, AUFTRAG.Type.BOMBING, AUFTRAG.Type.BOMBRUNWAY)`
|
||||
--
|
||||
function PLAYERTASKCONTROLLER:SetTaskWhiteList(WhiteList)
|
||||
self:T(self.lid.."SetTaskWhiteList")
|
||||
self.WhiteList = WhiteList
|
||||
self.UseWhiteList = true
|
||||
return self
|
||||
end
|
||||
|
||||
--- [Internal] Add a task to the task queue
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
-- @param Ops.Target#TARGET Target
|
||||
@ -1064,7 +1247,8 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
|
||||
self:T(self.lid.."_AddTask")
|
||||
local cat = Target:GetCategory()
|
||||
local type = AUFTRAG.Type.CAS
|
||||
local ttstype = "close air support"
|
||||
--local ttstype = "close air support"
|
||||
local ttstype = self.gettext:GetEntry("CASTTS",self.locale)
|
||||
|
||||
if cat == TARGET.Category.GROUND then
|
||||
type = AUFTRAG.Type.CAS
|
||||
@ -1074,23 +1258,26 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
|
||||
self:T("SEAD Check UNIT")
|
||||
if targetobject:HasSEAD() then
|
||||
type = AUFTRAG.Type.SEAD
|
||||
ttstype = "suppress air defense"
|
||||
--ttstype = "suppress air defense"
|
||||
ttstype = self.gettext:GetEntry("SEADTTS",self.locale)
|
||||
end
|
||||
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 then
|
||||
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 = "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 then
|
||||
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 = "suppress air defense"
|
||||
ttstype = self.gettext:GetEntry("SEADTTS",self.locale)
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -1100,14 +1287,16 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
|
||||
function (unit)
|
||||
if unit:HasSEAD() then
|
||||
type = AUFTRAG.Type.SEAD
|
||||
ttstype = "suppress air defenses"
|
||||
--ttstype = "suppress air defenses"
|
||||
ttstype = self.gettext:GetEntry("SEADTTS",self.locale)
|
||||
end
|
||||
end
|
||||
)
|
||||
elseif targetobject:IsInstanceOf("SET_STATIC") or targetobject:IsInstanceOf("STATIC") then
|
||||
self:T("BOMBING SET_STATIC or STATIC")
|
||||
type = AUFTRAG.Type.BOMBING
|
||||
ttstype = "bombing"
|
||||
--ttstype = "bombing"
|
||||
ttstype = self.gettext:GetEntry("BOMBTTS",self.locale)
|
||||
end
|
||||
-- if there are no friendlies nearby ~0.5km and task isn't SEAD, then it's BAI
|
||||
local targetcoord = Target:GetCoordinate()
|
||||
@ -1121,19 +1310,23 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
|
||||
local friendlyset = SET_GROUP:New():FilterCategoryGround():FilterCoalitions(filtercoalition):FilterZones({targetzone}):FilterOnce()
|
||||
if friendlyset:Count() == 0 and type == AUFTRAG.Type.CAS then
|
||||
type = AUFTRAG.Type.BAI
|
||||
ttstype = "battle field air interdiction"
|
||||
--ttstype = "battle field air interdiction"
|
||||
ttstype = self.gettext:GetEntry("BAITTS",self.locale)
|
||||
end
|
||||
elseif cat == TARGET.Category.NAVAL then
|
||||
type = AUFTRAG.Type.ANTISHIP
|
||||
ttstype = "anti-ship"
|
||||
--ttstype = "anti-ship"
|
||||
ttstype = self.gettext:GetEntry("ANTISHIPTTS",self.locale)
|
||||
elseif cat == TARGET.Category.AIRCRAFT then
|
||||
type = AUFTRAG.Type.INTERCEPT
|
||||
ttstype = "intercept"
|
||||
--ttstype = "intercept"
|
||||
ttstype = self.gettext:GetEntry("INTERCEPTTS",self.locale)
|
||||
elseif cat == TARGET.Category.AIRBASE then
|
||||
--TODO: Define Success Criteria, AB hit? Runway blocked, how to determine? change of coalition? Void of enemies?
|
||||
-- Current implementation - bombing in AFB zone (EVENTS.Shot)
|
||||
type = AUFTRAG.Type.BOMBRUNWAY
|
||||
ttstype = "bomb runway"
|
||||
-- ttstype = "bomb runway"
|
||||
ttstype = self.gettext:GetEntry("BOMBRUNWAYTTS",self.locale)
|
||||
elseif cat == TARGET.Category.COORDINATE or cat == TARGET.Category.ZONE then
|
||||
--TODO: Define Success Criteria, void of enemies?
|
||||
-- Current implementation - find SET of enemies in ZONE or 500m radius around coordinate, and assign as targets
|
||||
@ -1156,6 +1349,12 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
|
||||
return self
|
||||
end
|
||||
|
||||
if self.UseWhiteList then
|
||||
if not self:_CheckTaskTypeAllowed(type) then
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
local task = PLAYERTASK:New(type,Target,self.repeatonfailed,self.repeattimes,ttstype)
|
||||
|
||||
task.coalition = self.Coalition
|
||||
@ -1167,10 +1366,19 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
|
||||
local data = EventData -- Core.Event#EVENTDATA EventData
|
||||
local wcat = data.Weapon:getCategory() -- cat 2 or 3
|
||||
local coord = data.IniUnit:GetCoordinate() or data.IniGroup:GetCoordinate()
|
||||
local vec2 = coord:GetVec2() or {x=0, y=0}
|
||||
local coal = data.IniCoalition
|
||||
local afbzone = AIRBASE:FindByName(Target:GetName()):GetZone()
|
||||
local inzone = afbzone:IsVec2InZone(coord:GetVec2() or {x=0, y=0})
|
||||
if coal == task.coalition and (wcat == 2 or wcat == 3) and inzone then
|
||||
local runways = AIRBASE:FindByName(Target:GetName()):GetRunways() or {}
|
||||
local inrunwayzone = false
|
||||
for _,_runway in pairs(runways) do
|
||||
local runway = _runway -- Wrapper.Airbase#AIRBASE.Runway
|
||||
if runway.zone:IsVec2InZone(vec2) then
|
||||
inrunwayzone = true
|
||||
end
|
||||
end
|
||||
local inzone = afbzone:IsVec2InZone(vec2)
|
||||
if coal == task.coalition and (wcat == 2 or wcat == 3) and (inrunwayzone or inzone) then
|
||||
-- bombing/rockets inside target AFB zone - well done!
|
||||
task:__Success(-20)
|
||||
end
|
||||
@ -1196,7 +1404,8 @@ function PLAYERTASKCONTROLLER:_JoinTask(Group, Client, Task)
|
||||
if self.TasksPerPlayer:HasUniqueID(playername) then
|
||||
-- Player already has a task
|
||||
if not self.NoScreenOutput then
|
||||
local m=MESSAGE:New("You already have one active task! Complete it first!","10","Tasking"):ToGroup(Group)
|
||||
local text = self.gettext:GetEntry("HAVEACTIVETASK",self.locale)
|
||||
local m=MESSAGE:New(text,"10","Tasking"):ToGroup(Group)
|
||||
end
|
||||
return self
|
||||
end
|
||||
@ -1206,7 +1415,8 @@ function PLAYERTASKCONTROLLER:_JoinTask(Group, Client, Task)
|
||||
if taskstate ~= "Executing" and taskstate ~= "Done" then
|
||||
Task:__Requested(-1)
|
||||
Task:__Executing(-2)
|
||||
local text = string.format("%s, pilot %s joined task %03d", self.MenuName or self.Name, playername, Task.PlayerTaskNr)
|
||||
local joined = self.gettext:GetEntry("PILOTJOINEDTASK",self.locale)
|
||||
local text = string.format(joined, self.MenuName or self.Name, playername, Task.PlayerTaskNr)
|
||||
self:T(self.lid..text)
|
||||
if not self.NoScreenOutput then
|
||||
local m=MESSAGE:New(text,"10","Tasking"):ToAll()
|
||||
@ -1234,8 +1444,12 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client)
|
||||
-- TODO: Show multiple?
|
||||
--local task = self.TasksPerPlayer:GetIDStack()
|
||||
local task = self.TasksPerPlayer:ReadByID(playername) -- Ops.PlayerTask#PLAYERTASK
|
||||
local taskname = string.format("%s Task ID %03d",task.Type,task.PlayerTaskNr)
|
||||
local ttstaskname = string.format("%s Task ID %03d",task.TTSType,task.PlayerTaskNr)
|
||||
local tname = self.gettext:GetEntry("TASKNAME",self.locale)
|
||||
local ttsname = self.gettext:GetEntry("TASKNAMETTS",self.locale)
|
||||
local taskname = string.format(tname,task.Type,task.PlayerTaskNr)
|
||||
local ttstaskname = string.format(ttsname,task.TTSType,task.PlayerTaskNr)
|
||||
--local taskname = string.format("%s Task ID %03d",task.Type,task.PlayerTaskNr)
|
||||
--local ttstaskname = string.format("%s Task ID %03d",task.TTSType,task.PlayerTaskNr)
|
||||
local Coordinate = task.Target:GetCoordinate()
|
||||
local CoordText = ""
|
||||
if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then
|
||||
@ -1244,28 +1458,36 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client)
|
||||
CoordText = Coordinate:ToStringA2A(Client)
|
||||
end
|
||||
local ThreatLevel = task.Target:GetThreatLevelMax()
|
||||
local ThreatLevelText = "high"
|
||||
--local ThreatLevelText = "high"
|
||||
local ThreatLevelText = self.gettext:GetEntry("THREATHIGH",self.locale)
|
||||
if ThreatLevel > 3 and ThreatLevel < 8 then
|
||||
ThreatLevelText = "medium"
|
||||
--ThreatLevelText = "medium"
|
||||
ThreatLevelText = self.gettext:GetEntry("THREATMEDIUM",self.locale)
|
||||
elseif ThreatLevel <= 3 then
|
||||
ThreatLevelText = "low"
|
||||
--ThreatLevelText = "low"
|
||||
ThreatLevelText = self.gettext:GetEntry("THREATLOW",self.locale)
|
||||
end
|
||||
local targets = task.Target:CountTargets() or 0
|
||||
local clientlist = task:GetClients()
|
||||
local ThreatGraph = "[" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]: "..ThreatLevel
|
||||
text = string.format("%s\nThreat: %s\nTargets left: %d\nCoord: %s", taskname, ThreatGraph, targets, CoordText)
|
||||
local clienttxt = "\nPilot(s): "
|
||||
local ThreatLocaleText = self.gettext:GetEntry("THREATTEXT",self.locale)
|
||||
text = string.format(ThreatLocaleText, taskname, ThreatGraph, targets, CoordText)
|
||||
--text = string.format("%s\nThreat: %s\nTargets left: %d\nCoord: %s", taskname, ThreatGraph, targets, CoordText)
|
||||
--local clienttxt = "\nPilot(s): "
|
||||
local clienttxt = self.gettext:GetEntry("PILOTS",self.locale)
|
||||
for _,_name in pairs(clientlist) do
|
||||
clienttxt = clienttxt .. _name .. ", "
|
||||
end
|
||||
clienttxt=string.gsub(clienttxt,", $",".")
|
||||
text = text .. clienttxt
|
||||
if self.UseSRS then
|
||||
local ttstext = string.format("%s, %s. Target information for %s. Threat level %s. Targets left %d. Target location %s.",self.MenuName or self.Name,playername,ttstaskname,ThreatLevelText, targets, CoordText)
|
||||
local ThreatLocaleTextTTS = self.gettext:GetEntry("THREATTEXTTTS",self.locale)
|
||||
local ttstext = string.format(ThreatLocaleTextTTS,self.MenuName or self.Name,playername,ttstaskname,ThreatLevelText, targets, CoordText)
|
||||
--local ttstext = string.format("%s, %s. Target information for %s. Threat level %s. Targets left %d. Target location %s.",self.MenuName or self.Name,playername,ttstaskname,ThreatLevelText, targets, CoordText)
|
||||
self.SRSQueue:NewTransmission(ttstext,nil,self.SRS,nil,2)
|
||||
end
|
||||
else
|
||||
text = "No active task!"
|
||||
text = self.gettext:GetEntry("NOACTIVETASK",self.locale)
|
||||
end
|
||||
if not self.NoScreenOutput then
|
||||
local m=MESSAGE:New(text,15,"Tasking"):ToGroup(Group)
|
||||
@ -1285,13 +1507,15 @@ function PLAYERTASKCONTROLLER:_MarkTask(Group, Client)
|
||||
if self.TasksPerPlayer:HasUniqueID(playername) then
|
||||
local task = self.TasksPerPlayer:ReadByID(playername) -- Ops.PlayerTask#PLAYERTASK
|
||||
task:MarkTargetOnF10Map()
|
||||
text = string.format("%s, copy pilot %s, task %03d location marked on map!", self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
local textmark = self.gettext:GetEntry("MARKTASK",self.locale)
|
||||
--text = string.format("%s, copy pilot %s, task %03d location marked on map!", self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
text = string.format(textmark, self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
self:T(self.lid..text)
|
||||
if self.UseSRS then
|
||||
self.SRSQueue:NewTransmission(text,nil,self.SRS,nil,2)
|
||||
end
|
||||
else
|
||||
text = "No active task!"
|
||||
text = self.gettext:GetEntry("NOACTIVETASK",self.locale)
|
||||
end
|
||||
if not self.NoScreenOutput then
|
||||
local m=MESSAGE:New(text,"10","Tasking"):ToGroup(Group)
|
||||
@ -1311,14 +1535,15 @@ function PLAYERTASKCONTROLLER:_SmokeTask(Group, Client)
|
||||
if self.TasksPerPlayer:HasUniqueID(playername) then
|
||||
local task = self.TasksPerPlayer:ReadByID(playername) -- Ops.PlayerTask#PLAYERTASK
|
||||
task:SmokeTarget()
|
||||
text = string.format("%s, copy pilot %s, task %03d location smoked!", self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
local textmark = self.gettext:GetEntry("SMOKETASK",self.locale)
|
||||
text = string.format(textmark, self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
self:T(self.lid..text)
|
||||
--local m=MESSAGE:New(text,"10","Tasking"):ToAll()
|
||||
if self.UseSRS then
|
||||
self.SRSQueue:NewTransmission(text,nil,self.SRS,nil,2)
|
||||
end
|
||||
else
|
||||
text = "No active task!"
|
||||
text = self.gettext:GetEntry("NOACTIVETASK",self.locale)
|
||||
end
|
||||
if not self.NoScreenOutput then
|
||||
local m=MESSAGE:New(text,15,"Tasking"):ToGroup(Group)
|
||||
@ -1338,14 +1563,15 @@ function PLAYERTASKCONTROLLER:_FlareTask(Group, Client)
|
||||
if self.TasksPerPlayer:HasUniqueID(playername) then
|
||||
local task = self.TasksPerPlayer:ReadByID(playername) -- Ops.PlayerTask#PLAYERTASK
|
||||
task:FlareTarget()
|
||||
text = string.format("%s, copy pilot %s, task %03d location illuminated!", self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
local textmark = self.gettext:GetEntry("FLARETASK",self.locale)
|
||||
text = string.format(textmark, self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
self:T(self.lid..text)
|
||||
--local m=MESSAGE:New(text,"10","Tasking"):ToAll()
|
||||
if self.UseSRS then
|
||||
self.SRSQueue:NewTransmission(text,nil,self.SRS,nil,2)
|
||||
end
|
||||
else
|
||||
text = "No active task!"
|
||||
text = self.gettext:GetEntry("NOACTIVETASK",self.locale)
|
||||
end
|
||||
if not self.NoScreenOutput then
|
||||
local m=MESSAGE:New(text,15,"Tasking"):ToGroup(Group)
|
||||
@ -1365,14 +1591,15 @@ function PLAYERTASKCONTROLLER:_AbortTask(Group, Client)
|
||||
if self.TasksPerPlayer:HasUniqueID(playername) then
|
||||
local task = self.TasksPerPlayer:PullByID(playername) -- Ops.PlayerTask#PLAYERTASK
|
||||
task:ClientAbort(Client)
|
||||
text = string.format("%s, all stations, pilot %s aborted task %03d", self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
local textmark = self.gettext:GetEntry("ABORTTASK",self.locale)
|
||||
text = string.format(textmark, self.MenuName or self.Name, playername, task.PlayerTaskNr)
|
||||
self:T(self.lid..text)
|
||||
--local m=MESSAGE:New(text,"10","Tasking"):ToAll()
|
||||
if self.UseSRS then
|
||||
self.SRSQueue:NewTransmission(text,nil,self.SRS,nil,2)
|
||||
end
|
||||
else
|
||||
text = "No active task!"
|
||||
text = self.gettext:GetEntry("NOACTIVETASK",self.locale)
|
||||
end
|
||||
if not self.NoScreenOutput then
|
||||
local m=MESSAGE:New(text,15,"Tasking"):ToGroup(Group)
|
||||
@ -1395,12 +1622,14 @@ function PLAYERTASKCONTROLLER:_BuildMenus(Client)
|
||||
if _client then
|
||||
local client = _client -- Wrapper.Client#CLIENT
|
||||
local group = client:GetGroup()
|
||||
local playername = client:GetPlayerName() or "Unknown"
|
||||
local unknown = self.gettext:GetEntry("UNKNOWN",self.locale)
|
||||
local playername = client:GetPlayerName() or unknown
|
||||
if group and client then
|
||||
---
|
||||
-- TOPMENU
|
||||
---
|
||||
local menuname = self.MenuName or self.Name.." Tasking "..self.Type
|
||||
local taskings = self.gettext:GetEntry("MENUTASKING",self.locale)
|
||||
local menuname = self.MenuName or self.Name..taskings..self.Type
|
||||
local topmenu = MENU_GROUP:New(group,menuname,nil)
|
||||
|
||||
if self.PlayerMenu[playername] then
|
||||
@ -1413,23 +1642,31 @@ function PLAYERTASKCONTROLLER:_BuildMenus(Client)
|
||||
-- ACTIVE TASK MENU
|
||||
---
|
||||
if self:_CheckPlayerHasTask(playername) then
|
||||
local active = MENU_GROUP:New(group,"Active Task",topmenu)
|
||||
local info = MENU_GROUP_COMMAND:New(group,"Info",active,self._ActiveTaskInfo,self,group,client)
|
||||
local mark = MENU_GROUP_COMMAND:New(group,"Mark on map",active,self._MarkTask,self,group,client)
|
||||
|
||||
local menuactive = self.gettext:GetEntry("MENUACTIVE",self.locale)
|
||||
local menuinfo = self.gettext:GetEntry("MENUINFO",self.locale)
|
||||
local menumark = self.gettext:GetEntry("MENUMARK",self.locale)
|
||||
local menusmoke = self.gettext:GetEntry("MENUSMOKE",self.locale)
|
||||
local menuflare = self.gettext:GetEntry("MENUFLARE",self.locale)
|
||||
local menuabort = self.gettext:GetEntry("MENUABORT",self.locale)
|
||||
|
||||
local active = MENU_GROUP:New(group,menuactive,topmenu)
|
||||
local info = MENU_GROUP_COMMAND:New(group,menuinfo,active,self._ActiveTaskInfo,self,group,client)
|
||||
local mark = MENU_GROUP_COMMAND:New(group,menumark,active,self._MarkTask,self,group,client)
|
||||
if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then
|
||||
-- no smoking/flaring here if A2A
|
||||
local smoke = MENU_GROUP_COMMAND:New(group,"Smoke",active,self._SmokeTask,self,group,client)
|
||||
local flare = MENU_GROUP_COMMAND:New(group,"Flare",active,self._FlareTask,self,group,client)
|
||||
local smoke = MENU_GROUP_COMMAND:New(group,menusmoke,active,self._SmokeTask,self,group,client)
|
||||
local flare = MENU_GROUP_COMMAND:New(group,menuflare,active,self._FlareTask,self,group,client)
|
||||
end
|
||||
local abort = MENU_GROUP_COMMAND:New(group,"Abort",active,self._AbortTask,self,group,client)
|
||||
local abort = MENU_GROUP_COMMAND:New(group,menuabort,active,self._AbortTask,self,group,client)
|
||||
elseif self.TaskQueue:Count() > 0 then
|
||||
---
|
||||
-- JOIN TASK MENU
|
||||
---
|
||||
local tasktypes = self:_GetAvailableTaskTypes()
|
||||
local taskpertype = self:_GetTasksPerType()
|
||||
|
||||
local joinmenu = MENU_GROUP:New(group,"Join Task",topmenu)
|
||||
local menujoin = self.gettext:GetEntry("MENUJOIN",self.locale)
|
||||
local joinmenu = MENU_GROUP:New(group,menujoin,topmenu)
|
||||
|
||||
local ttypes = {}
|
||||
local taskmenu = {}
|
||||
@ -1445,7 +1682,8 @@ function PLAYERTASKCONTROLLER:_BuildMenus(Client)
|
||||
if tnow - _task.timestamp < 60 then
|
||||
newtext = "*]"
|
||||
end
|
||||
local text = string.format("TaskNo %03d [%d%s",_task.PlayerTaskNr,pilotcount,newtext)
|
||||
local menutaskno = self.gettext:GetEntry("MENUTASKNO",self.locale)
|
||||
local text = string.format("%s %03d [%d%s",menutaskno,_task.PlayerTaskNr,pilotcount,newtext)
|
||||
if self.UseGroupNames then
|
||||
local name = _task.Target:GetName()
|
||||
if name ~= "Unknown" then
|
||||
@ -1461,7 +1699,8 @@ function PLAYERTASKCONTROLLER:_BuildMenus(Client)
|
||||
end
|
||||
else
|
||||
-- no tasks (yet)
|
||||
local joinmenu = MENU_GROUP:New(group,"Currently no tasks available.",topmenu)
|
||||
local menunotasks = self.gettext:GetEntry("MENUNOTASKS",self.locale)
|
||||
local joinmenu = MENU_GROUP:New(group,menunotasks,topmenu)
|
||||
end
|
||||
---
|
||||
-- REFRESH MENU
|
||||
@ -1738,12 +1977,14 @@ end
|
||||
function PLAYERTASKCONTROLLER:onafterTaskCancelled(From, Event, To, Task)
|
||||
self:T({From, Event, To})
|
||||
self:T(self.lid.."TaskCancelled")
|
||||
local taskname = string.format("Task #%03d %s is cancelled!", Task.PlayerTaskNr, tostring(Task.Type))
|
||||
local canceltxt = self.gettext:GetEntry("TASKCANCELLED",self.locale)
|
||||
local canceltxttts = self.gettext:GetEntry("TASKCANCELLEDTTS",self.locale)
|
||||
local taskname = string.format(canceltxt, Task.PlayerTaskNr, tostring(Task.Type))
|
||||
if not self.NoScreenOutput then
|
||||
local m = MESSAGE:New(taskname,15,"Tasking"):ToCoalition(self.Coalition)
|
||||
end
|
||||
if self.UseSRS then
|
||||
taskname = string.format("%s, task %03d %s is cancelled!", self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
taskname = string.format(canceltxttts, self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
self.SRSQueue:NewTransmission(taskname,nil,self.SRS,nil,2)
|
||||
end
|
||||
return self
|
||||
@ -1759,12 +2000,14 @@ end
|
||||
function PLAYERTASKCONTROLLER:onafterTaskSuccess(From, Event, To, Task)
|
||||
self:T({From, Event, To})
|
||||
self:T(self.lid.."TaskSuccess")
|
||||
local taskname = string.format("Task #%03d %s completed successfully!", Task.PlayerTaskNr, tostring(Task.Type))
|
||||
local succtxt = self.gettext:GetEntry("TASKSUCCESS",self.locale)
|
||||
local succtxttts = self.gettext:GetEntry("TASKSUCCESSTTS",self.locale)
|
||||
local taskname = string.format(succtxt, Task.PlayerTaskNr, tostring(Task.Type))
|
||||
if not self.NoScreenOutput then
|
||||
local m = MESSAGE:New(taskname,15,"Tasking"):ToCoalition(self.Coalition)
|
||||
end
|
||||
if self.UseSRS then
|
||||
taskname = string.format("%s, task %03d %s completed successfully!", self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
taskname = string.format(succtxttts, self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
self.SRSQueue:NewTransmission(taskname,nil,self.SRS,nil,2)
|
||||
end
|
||||
return self
|
||||
@ -1780,12 +2023,14 @@ end
|
||||
function PLAYERTASKCONTROLLER:onafterTaskFailed(From, Event, To, Task)
|
||||
self:T({From, Event, To})
|
||||
self:T(self.lid.."TaskFailed")
|
||||
local taskname = string.format("Task #%03d %s was a failure!", Task.PlayerTaskNr, tostring(Task.Type))
|
||||
local failtxt = self.gettext:GetEntry("TASKFAILED",self.locale)
|
||||
local failtxttts = self.gettext:GetEntry("TASKFAILEDTTS",self.locale)
|
||||
local taskname = string.format(failtxt, Task.PlayerTaskNr, tostring(Task.Type))
|
||||
if not self.NoScreenOutput then
|
||||
local m = MESSAGE:New(taskname,15,"Tasking"):ToCoalition(self.Coalition)
|
||||
end
|
||||
if self.UseSRS then
|
||||
taskname = string.format("%s, task %03d %s was a failure!", self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
taskname = string.format(failtxttts, self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
self.SRSQueue:NewTransmission(taskname,nil,self.SRS,nil,2)
|
||||
end
|
||||
return self
|
||||
@ -1801,12 +2046,14 @@ end
|
||||
function PLAYERTASKCONTROLLER:onafterTaskRepeatOnFailed(From, Event, To, Task)
|
||||
self:T({From, Event, To})
|
||||
self:T(self.lid.."RepeatOnFailed")
|
||||
local taskname = string.format("Task #%03d %s was a failure! Replanning!", Task.PlayerTaskNr, tostring(Task.Type))
|
||||
local repfailtxt = self.gettext:GetEntry("TASKFAILEDREPLAN",self.locale)
|
||||
local repfailtxttts = self.gettext:GetEntry("TASKFAILEDREPLANTTS",self.locale)
|
||||
local taskname = string.format(repfailtxt, Task.PlayerTaskNr, tostring(Task.Type))
|
||||
if not self.NoScreenOutput then
|
||||
local m = MESSAGE:New(taskname,15,"Tasking"):ToCoalition(self.Coalition)
|
||||
end
|
||||
if self.UseSRS then
|
||||
taskname = string.format("%s, task %03d %s was a failure! Replanning!", self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
taskname = string.format(repfailtxttts, self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
|
||||
self.SRSQueue:NewTransmission(taskname,nil,self.SRS,nil,2)
|
||||
end
|
||||
return self
|
||||
@ -1822,12 +2069,13 @@ end
|
||||
function PLAYERTASKCONTROLLER:onafterTaskAdded(From, Event, To, Task)
|
||||
self:T({From, Event, To})
|
||||
self:T(self.lid.."TaskAdded")
|
||||
local taskname = string.format("%s has a new task %s", self.MenuName or self.Name, tostring(Task.Type))
|
||||
local addtxt = self.gettext:GetEntry("TASKADDED",self.locale)
|
||||
local taskname = string.format(addtxt, self.MenuName or self.Name, tostring(Task.Type))
|
||||
if not self.NoScreenOutput then
|
||||
local m = MESSAGE:New(taskname,15,"Tasking"):ToCoalition(self.Coalition)
|
||||
end
|
||||
if self.UseSRS then
|
||||
taskname = string.format("%s has a new task %s", self.MenuName or self.Name, tostring(Task.TTSType))
|
||||
taskname = string.format(addtxt, self.MenuName or self.Name, tostring(Task.TTSType))
|
||||
self.SRSQueue:NewTransmission(taskname,nil,self.SRS,nil,2)
|
||||
end
|
||||
return self
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user