mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
#PLAYERTASKCONTROLLER
* Show Freetext as Briefing in all tasks when available * TARGET - added Average coordinate option from GROUP
This commit is contained in:
parent
cefb5d98f0
commit
7dd46ec24f
@ -95,7 +95,7 @@ PLAYERTASK = {
|
|||||||
|
|
||||||
--- PLAYERTASK class version.
|
--- PLAYERTASK class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
PLAYERTASK.version="0.1.8"
|
PLAYERTASK.version="0.1.9"
|
||||||
|
|
||||||
--- Generic task condition.
|
--- Generic task condition.
|
||||||
-- @type PLAYERTASK.Condition
|
-- @type PLAYERTASK.Condition
|
||||||
@ -294,6 +294,22 @@ function PLAYERTASK:AddFreetext(Text)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [USER] Query if a task has free text description.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:HasFreetext()
|
||||||
|
self:T(self.lid.."HasFreetext")
|
||||||
|
return self.Freetext ~= nil and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Query if a task has free text TTS description.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:HasFreetextTTS()
|
||||||
|
self:T(self.lid.."HasFreetextTTS")
|
||||||
|
return self.FreetextTTS ~= nil and true or false
|
||||||
|
end
|
||||||
|
|
||||||
--- [USER] Set a task sub type description to this task.
|
--- [USER] Set a task sub type description to this task.
|
||||||
-- @param #PLAYERTASK self
|
-- @param #PLAYERTASK self
|
||||||
-- @param #string Type
|
-- @param #string Type
|
||||||
@ -514,7 +530,7 @@ function PLAYERTASK:SmokeTarget(Color)
|
|||||||
if not self.lastsmoketime then self.lastsmoketime = 0 end
|
if not self.lastsmoketime then self.lastsmoketime = 0 end
|
||||||
local TDiff = timer.getAbsTime() - self.lastsmoketime
|
local TDiff = timer.getAbsTime() - self.lastsmoketime
|
||||||
if self.Target and TDiff > 299 then
|
if self.Target and TDiff > 299 then
|
||||||
local coordinate = self.Target:GetCoordinate()
|
local coordinate = self.Target:GetAverageCoordinate()
|
||||||
if coordinate then
|
if coordinate then
|
||||||
coordinate:Smoke(color)
|
coordinate:Smoke(color)
|
||||||
self.lastsmoketime = timer.getAbsTime()
|
self.lastsmoketime = timer.getAbsTime()
|
||||||
@ -531,7 +547,7 @@ function PLAYERTASK:FlareTarget(Color)
|
|||||||
self:T(self.lid.."SmokeTarget")
|
self:T(self.lid.."SmokeTarget")
|
||||||
local color = Color or FLARECOLOR.Red
|
local color = Color or FLARECOLOR.Red
|
||||||
if self.Target then
|
if self.Target then
|
||||||
local coordinate = self.Target:GetCoordinate()
|
local coordinate = self.Target:GetAverageCoordinate()
|
||||||
if coordinate then
|
if coordinate then
|
||||||
coordinate:Flare(color,0)
|
coordinate:Flare(color,0)
|
||||||
end
|
end
|
||||||
@ -549,7 +565,7 @@ function PLAYERTASK:IlluminateTarget(Power,Height)
|
|||||||
local Power = Power or 1000
|
local Power = Power or 1000
|
||||||
local Height = Height or 150
|
local Height = Height or 150
|
||||||
if self.Target then
|
if self.Target then
|
||||||
local coordinate = self.Target:GetCoordinate()
|
local coordinate = self.Target:GetAverageCoordinate()
|
||||||
if coordinate then
|
if coordinate then
|
||||||
local bcoord = COORDINATE:NewFromVec2( coordinate:GetVec2(), Height )
|
local bcoord = COORDINATE:NewFromVec2( coordinate:GetVec2(), Height )
|
||||||
bcoord:IlluminationBomb(Power)
|
bcoord:IlluminationBomb(Power)
|
||||||
@ -1371,7 +1387,7 @@ PLAYERTASKCONTROLLER.Messages = {
|
|||||||
|
|
||||||
--- PLAYERTASK class version.
|
--- PLAYERTASK class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
PLAYERTASKCONTROLLER.version="0.1.41"
|
PLAYERTASKCONTROLLER.version="0.1.42"
|
||||||
|
|
||||||
--- Constructor
|
--- Constructor
|
||||||
-- @param #PLAYERTASKCONTROLLER self
|
-- @param #PLAYERTASKCONTROLLER self
|
||||||
@ -2650,7 +2666,8 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
local text = ""
|
local text = ""
|
||||||
local textTTS = ""
|
local textTTS = ""
|
||||||
if self.TasksPerPlayer:HasUniqueID(playername) or Task then
|
if self.TasksPerPlayer:HasUniqueID(playername) or Task then
|
||||||
-- TODO: Show multiple?
|
-- NODO: Show multiple?
|
||||||
|
-- Details
|
||||||
local task = Task or self.TasksPerPlayer:ReadByID(playername) -- Ops.PlayerTask#PLAYERTASK
|
local task = Task or self.TasksPerPlayer:ReadByID(playername) -- Ops.PlayerTask#PLAYERTASK
|
||||||
local tname = self.gettext:GetEntry("TASKNAME",self.locale)
|
local tname = self.gettext:GetEntry("TASKNAME",self.locale)
|
||||||
local ttsname = self.gettext:GetEntry("TASKNAMETTS",self.locale)
|
local ttsname = self.gettext:GetEntry("TASKNAMETTS",self.locale)
|
||||||
@ -2663,6 +2680,7 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
else
|
else
|
||||||
CoordText = Coordinate:ToStringA2A(Client)
|
CoordText = Coordinate:ToStringA2A(Client)
|
||||||
end
|
end
|
||||||
|
-- Threat Level
|
||||||
local ThreatLevel = task.Target:GetThreatLevelMax()
|
local ThreatLevel = task.Target:GetThreatLevelMax()
|
||||||
--local ThreatLevelText = "high"
|
--local ThreatLevelText = "high"
|
||||||
local ThreatLevelText = self.gettext:GetEntry("THREATHIGH",self.locale)
|
local ThreatLevelText = self.gettext:GetEntry("THREATHIGH",self.locale)
|
||||||
@ -2673,11 +2691,13 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
--ThreatLevelText = "low"
|
--ThreatLevelText = "low"
|
||||||
ThreatLevelText = self.gettext:GetEntry("THREATLOW",self.locale)
|
ThreatLevelText = self.gettext:GetEntry("THREATLOW",self.locale)
|
||||||
end
|
end
|
||||||
|
-- Targetno and Threat
|
||||||
local targets = task.Target:CountTargets() or 0
|
local targets = task.Target:CountTargets() or 0
|
||||||
local clientlist, clientcount = task:GetClients()
|
local clientlist, clientcount = task:GetClients()
|
||||||
local ThreatGraph = "[" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]: "..ThreatLevel
|
local ThreatGraph = "[" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]: "..ThreatLevel
|
||||||
local ThreatLocaleText = self.gettext:GetEntry("THREATTEXT",self.locale)
|
local ThreatLocaleText = self.gettext:GetEntry("THREATTEXT",self.locale)
|
||||||
text = string.format(ThreatLocaleText, taskname, ThreatGraph, targets, CoordText)
|
text = string.format(ThreatLocaleText, taskname, ThreatGraph, targets, CoordText)
|
||||||
|
-- Prec bombing
|
||||||
if task.Type == AUFTRAG.Type.PRECISIONBOMBING and self.precisionbombing then
|
if task.Type == AUFTRAG.Type.PRECISIONBOMBING and self.precisionbombing then
|
||||||
if self.LasingDrone and self.LasingDrone.playertask then
|
if self.LasingDrone and self.LasingDrone.playertask then
|
||||||
local yes = self.gettext:GetEntry("YES",self.locale)
|
local yes = self.gettext:GetEntry("YES",self.locale)
|
||||||
@ -2689,6 +2709,7 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
text = text .. prectext
|
text = text .. prectext
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Buddylasing
|
||||||
if task.Type == AUFTRAG.Type.PRECISIONBOMBING and self.buddylasing then
|
if task.Type == AUFTRAG.Type.PRECISIONBOMBING and self.buddylasing then
|
||||||
if self.PlayerRecce then
|
if self.PlayerRecce then
|
||||||
local yes = self.gettext:GetEntry("YES",self.locale)
|
local yes = self.gettext:GetEntry("YES",self.locale)
|
||||||
@ -2718,6 +2739,7 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Transport
|
||||||
elseif task.Type == AUFTRAG.Type.CTLD or task.Type == AUFTRAG.Type.CSAR then
|
elseif task.Type == AUFTRAG.Type.CTLD or task.Type == AUFTRAG.Type.CSAR then
|
||||||
-- THREATTEXT = "%s\nThreat: %s\nTargets left: %d\nCoord: %s",
|
-- 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.",
|
-- THREATTEXTTTS = "%s, %s. Target information for %s. Threat level %s. Targets left %d. Target location %s.",
|
||||||
@ -2725,15 +2747,15 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
textTTS = taskname
|
textTTS = taskname
|
||||||
local detail = task:GetFreetext()
|
local detail = task:GetFreetext()
|
||||||
local detailTTS = task:GetFreetextTTS()
|
local detailTTS = task:GetFreetextTTS()
|
||||||
text = text .. "\nDetail: "..detail.."\nTarget location "..CoordText
|
text = text .. "\nBriefing: "..detail.."\nTarget location "..CoordText
|
||||||
textTTS = textTTS .. "; Detail: "..detailTTS.."\nTarget location "..CoordText
|
textTTS = textTTS .. "; Briefing: "..detailTTS.."\nTarget location "..CoordText
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Pilots
|
||||||
local clienttxt = self.gettext:GetEntry("PILOTS",self.locale)
|
local clienttxt = self.gettext:GetEntry("PILOTS",self.locale)
|
||||||
if clientcount > 0 then
|
if clientcount > 0 then
|
||||||
for _,_name in pairs(clientlist) do
|
for _,_name in pairs(clientlist) do
|
||||||
if self.customcallsigns[_name] then
|
if self.customcallsigns[_name] then
|
||||||
-- personalized flight name in player naming
|
|
||||||
--_name = string.match(_name,"| ([%a]+)")
|
|
||||||
_name = self.customcallsigns[_name]
|
_name = self.customcallsigns[_name]
|
||||||
end
|
end
|
||||||
clienttxt = clienttxt .. _name .. ", "
|
clienttxt = clienttxt .. _name .. ", "
|
||||||
@ -2743,6 +2765,8 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
local keine = self.gettext:GetEntry("NONE",self.locale)
|
local keine = self.gettext:GetEntry("NONE",self.locale)
|
||||||
clienttxt = clienttxt .. keine
|
clienttxt = clienttxt .. keine
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Task Report
|
||||||
text = text .. clienttxt
|
text = text .. clienttxt
|
||||||
textTTS = textTTS .. clienttxt
|
textTTS = textTTS .. clienttxt
|
||||||
if self.UseSRS then
|
if self.UseSRS then
|
||||||
@ -2762,6 +2786,10 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task)
|
|||||||
if string.find(ttstext," BR, ") then
|
if string.find(ttstext," BR, ") then
|
||||||
CoordText = string.gsub(ttstext," BR, "," Bee, Arr, ")
|
CoordText = string.gsub(ttstext," BR, "," Bee, Arr, ")
|
||||||
end
|
end
|
||||||
|
elseif task:HasFreetext() then
|
||||||
|
-- add freetext
|
||||||
|
text = text .. "\nBriefing: "..task:GetFreetext()
|
||||||
|
ttstext = ttstext .. "; Briefing: "..task:GetFreetextTTS()
|
||||||
end
|
end
|
||||||
self.SRSQueue:NewTransmission(ttstext,nil,self.SRS,nil,2)
|
self.SRSQueue:NewTransmission(ttstext,nil,self.SRS,nil,2)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1133,15 +1133,19 @@ end
|
|||||||
--- Get target 3D position vector.
|
--- Get target 3D position vector.
|
||||||
-- @param #TARGET self
|
-- @param #TARGET self
|
||||||
-- @param #TARGET.Object Target Target object.
|
-- @param #TARGET.Object Target Target object.
|
||||||
|
-- @param #boolean Average
|
||||||
-- @return DCS#Vec3 Vector with x,y,z components.
|
-- @return DCS#Vec3 Vector with x,y,z components.
|
||||||
function TARGET:GetTargetVec3(Target)
|
function TARGET:GetTargetVec3(Target, Average)
|
||||||
|
|
||||||
if Target.Type==TARGET.ObjectType.GROUP then
|
if Target.Type==TARGET.ObjectType.GROUP then
|
||||||
|
|
||||||
local object=Target.Object --Wrapper.Group#GROUP
|
local object=Target.Object --Wrapper.Group#GROUP
|
||||||
|
|
||||||
if object and object:IsAlive() then
|
if object and object:IsAlive() then
|
||||||
local vec3=object:GetAverageVec3()
|
local vec3=object:GetVec3()
|
||||||
|
if Average then
|
||||||
|
vec3=object:GetAverageVec3()
|
||||||
|
end
|
||||||
|
|
||||||
if vec3 then
|
if vec3 then
|
||||||
return vec3
|
return vec3
|
||||||
@ -1220,8 +1224,9 @@ end
|
|||||||
--- Get target coordinate.
|
--- Get target coordinate.
|
||||||
-- @param #TARGET self
|
-- @param #TARGET self
|
||||||
-- @param #TARGET.Object Target Target object.
|
-- @param #TARGET.Object Target Target object.
|
||||||
|
-- @param #boolean Average
|
||||||
-- @return Core.Point#COORDINATE Coordinate of the target.
|
-- @return Core.Point#COORDINATE Coordinate of the target.
|
||||||
function TARGET:GetTargetCoordinate(Target)
|
function TARGET:GetTargetCoordinate(Target, Average)
|
||||||
|
|
||||||
if Target.Type==TARGET.ObjectType.COORDINATE then
|
if Target.Type==TARGET.ObjectType.COORDINATE then
|
||||||
|
|
||||||
@ -1231,7 +1236,7 @@ function TARGET:GetTargetCoordinate(Target)
|
|||||||
else
|
else
|
||||||
|
|
||||||
-- Get updated position vector.
|
-- Get updated position vector.
|
||||||
local vec3=self:GetTargetVec3(Target)
|
local vec3=self:GetTargetVec3(Target, Average)
|
||||||
|
|
||||||
-- Update position. This saves us to create a new COORDINATE object each time.
|
-- Update position. This saves us to create a new COORDINATE object each time.
|
||||||
if vec3 then
|
if vec3 then
|
||||||
@ -1364,6 +1369,26 @@ function TARGET:GetCoordinate()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get average coordinate.
|
||||||
|
-- @param #TARGET self
|
||||||
|
-- @return Core.Point#COORDINATE Coordinate of the target.
|
||||||
|
function TARGET:GetAverageCoordinate()
|
||||||
|
|
||||||
|
for _,_target in pairs(self.targets) do
|
||||||
|
local Target=_target --#TARGET.Object
|
||||||
|
|
||||||
|
local coordinate=self:GetTargetCoordinate(Target,true)
|
||||||
|
|
||||||
|
if coordinate then
|
||||||
|
return coordinate
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E(self.lid..string.format("ERROR: Cannot get average coordinate of target %s", tostring(self.name)))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Get category.
|
--- Get category.
|
||||||
-- @param #TARGET self
|
-- @param #TARGET self
|
||||||
-- @return #string Target category. See `TARGET.Category.X`, where `X=AIRCRAFT, GROUND`.
|
-- @return #string Target category. See `TARGET.Category.X`, where `X=AIRCRAFT, GROUND`.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user