From 2fadd949a6f841e7bf5bd2aea781d75f023bb894 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Sun, 7 May 2017 15:37:27 +0200 Subject: [PATCH] Fixes --- .../Moose/Actions/Act_Assign.lua | 2 - Moose Development/Moose/Core/Cargo.lua | 8 ++ Moose Development/Moose/Core/Set.lua | 5 + .../Moose/Tasking/CommandCenter.lua | 44 +++++-- Moose Development/Moose/Tasking/Mission.lua | 117 +++++++++++++++++- Moose Development/Moose/Tasking/Task.lua | 50 +++++--- Moose Development/Moose/Tasking/Task_A2G.lua | 71 ++++++++--- .../Moose/Tasking/Task_CARGO.lua | 36 ++++-- .../Moose/Wrapper/Positionable.lua | 13 +- 9 files changed, 280 insertions(+), 66 deletions(-) diff --git a/Moose Development/Moose/Actions/Act_Assign.lua b/Moose Development/Moose/Actions/Act_Assign.lua index 7d45ad21a..e04139698 100644 --- a/Moose Development/Moose/Actions/Act_Assign.lua +++ b/Moose Development/Moose/Actions/Act_Assign.lua @@ -173,8 +173,6 @@ do -- ACT_ASSIGN_ACCEPT local ProcessGroup = ProcessUnit:GetGroup() - self:Message( "You are assigned to the task " .. self.Task:GetName() ) - self.Task:Assign( ProcessUnit, ProcessUnit:GetPlayerName() ) end diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 65414e1f8..f984fe542 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -280,6 +280,14 @@ function CARGO:GetType() return self.Type end +--- Get the current coordinates of the Cargo. +-- @param #CARGO self +-- @return Core.Point#COORDINATE The coordinates of the Cargo. +function CARGO:GetCoordinate() + return self.CargoObject:GetCoordinate() +end + + --- Check if cargo is loaded. -- @param #CARGO self -- @return #boolean true if loaded diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index aaa06e3a8..6ca7f6d5d 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -1336,6 +1336,11 @@ SET_UNIT = { } +--- Get the first unit from the set. +-- @function [parent=#SET_UNIT] GetFirst +-- @param #SET_UNIT self +-- @return Wrapper.Unit#UNIT The UNIT object. + --- Creates a new SET_UNIT object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names. -- @param #SET_UNIT self -- @return #SET_UNIT diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 248f5fd00..93fd01162 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -112,9 +112,9 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) if EventData.IniObjectCategory == 1 then local EventGroup = GROUP:Find( EventData.IniDCSGroup ) if EventGroup and self:HasGroup( EventGroup ) then - local MenuReporting = MENU_GROUP:New( EventGroup, "Reporting", self.CommandCenterMenu ) - local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Summary Report", MenuReporting, self.ReportSummary, self, EventGroup ) - local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Details Report", MenuReporting, self.ReportDetails, self, EventGroup ) + local MenuReporting = MENU_GROUP:New( EventGroup, "Missions Reports", self.CommandCenterMenu ) + local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Status Report", MenuReporting, self.ReportMissionsStatus, self, EventGroup ) + local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Players Report", MenuReporting, self.ReportMissionsPlayers, self, EventGroup ) self:ReportSummary( EventGroup ) end local PlayerUnit = EventData.IniUnit @@ -307,11 +307,9 @@ end -- @param #string Message -- @param Wrapper.Group#GROUP TaskGroup -- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown. -function COMMANDCENTER:MessageToGroup( Message, TaskGroup, Name ) +function COMMANDCENTER:MessageToGroup( Message, TaskGroup ) - local Prefix = Name and "@ " .. Name .. ": " or "@ " .. TaskGroup:GetCallsign() .. ": " - Message = Prefix .. Message - self:GetPositionable():MessageToGroup( Message , 20, TaskGroup, self:GetName() ) + self:GetPositionable():MessageToGroup( Message , 15, TaskGroup, self:GetName() ) end @@ -321,7 +319,8 @@ function COMMANDCENTER:MessageToCoalition( Message ) local CCCoalition = self:GetPositionable():GetCoalition() --TODO: Fix coalition bug! - self:GetPositionable():MessageToCoalition( Message, 20, CCCoalition, self:GetName() ) + + self:GetPositionable():MessageToCoalition( Message, 15, CCCoalition ) end @@ -329,18 +328,37 @@ end --- Report the status of all MISSIONs to a GROUP. -- Each Mission is listed, with an indication how many Tasks are still to be completed. -- @param #COMMANDCENTER self -function COMMANDCENTER:ReportSummary( ReportGroup ) +function COMMANDCENTER:ReportMissionsStatus( ReportGroup ) + self:E( ReportGroup ) + + local Report = REPORT:New() + + Report:Add( "Status report of all missions." ) + + for MissionID, Mission in pairs( self.Missions ) do + local Mission = Mission -- Tasking.Mission#MISSION + Report:Add( " - " .. Mission:ReportStatus() ) + end + + self:MessageToGroup( Report:Text(), ReportGroup ) +end + +--- Report the players of all MISSIONs to a GROUP. +-- Each Mission is listed, with an indication how many Tasks are still to be completed. +-- @param #COMMANDCENTER self +function COMMANDCENTER:ReportMissionsPlayers( ReportGroup ) self:E( ReportGroup ) local Report = REPORT:New() + Report:Add( "Players active in all missions." ) + for MissionID, Mission in pairs( self.Missions ) do local Mission = Mission -- Tasking.Mission#MISSION - Report:Add( " - " .. Mission:ReportOverview() ) + Report:Add( " - " .. Mission:ReportPlayers() ) end - self:GetPositionable():MessageToGroup( Report:Text(), 30, ReportGroup ) - + self:MessageToGroup( Report:Text(), ReportGroup ) end --- Report the status of a Task to a Group. @@ -356,6 +374,6 @@ function COMMANDCENTER:ReportDetails( ReportGroup, Task ) Report:Add( " - " .. Mission:ReportDetails() ) end - self:GetPositionable():MessageToGroup( Report:Text(), 30, ReportGroup ) + self:MessageToGroup( Report:Text(), ReportGroup ) end diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index 73d7a84fa..47563623e 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -258,7 +258,7 @@ end -- @param #MISSION self -- @return #MISSION self function MISSION:GetName() - return string.format( "Mission %s (%s)", self.Name, self.MissionPriority ) + return string.format( 'Mission "%s (%s)"', self.Name, self.MissionPriority ) end --- Add a Unit to join the Mission. @@ -606,6 +606,117 @@ function MISSION:GetTasksRemaining() return TasksRemaining end +--- @param #MISSION self +-- @return #number +function MISSION:GetTaskTypes() + -- Determine how many tasks are remaining. + local TaskTypeList = {} + local TasksRemaining = 0 + for TaskID, Task in pairs( self:GetTasks() ) do + local Task = Task -- Tasking.Task#TASK + local TaskType = Task:GetType() + TaskTypeList[TaskType] = TaskType + end + return TaskTypeList +end + + +--- Create a status report of the Mission. +-- This reports provides a one liner of the mission status. It indicates how many players and how many Tasks. +-- +-- Mission "" - Status "" +-- - Task Types: , +-- - Planned Tasks (xp) +-- - Assigned Tasks(xp) +-- - Success Tasks (xp) +-- - Hold Tasks (xp) +-- - Cancelled Tasks (xp) +-- - Aborted Tasks (xp) +-- - Failed Tasks (xp) +-- +-- @param #MISSION self +-- @return #string +function MISSION:ReportStatus() + + local Report = REPORT:New() + + -- List the name of the mission. + local Name = self:GetName() + + -- Determine the status of the mission. + local Status = self:GetState() + local TasksRemaining = self:GetTasksRemaining() + + Report:Add( string.format( '%s - Status "%s"', Name, Status ) ) + + local TaskTypes = self:GetTaskTypes() + + Report:Add( string.format( " - Task Types: %s", table.concat(TaskTypes, ", " ) ) ) + + local TaskStatusList = { "Planned", "Assigned", "Success", "Hold", "Cancelled", "Aborted", "Failed" } + + for TaskStatusID, TaskStatus in pairs( TaskStatusList ) do + local TaskCount = 0 + local TaskPlayerCount = 0 + -- Determine how many tasks are remaining. + for TaskID, Task in pairs( self:GetTasks() ) do + local Task = Task -- Tasking.Task#TASK + if Task:Is( TaskStatus ) then + TaskCount = TaskCount + 1 + TaskPlayerCount = TaskPlayerCount + Task:GetPlayerCount() + end + end + if TaskCount > 0 then + Report:Add( string.format( " - %02d %s Tasks (%dp)", TaskCount, TaskStatus, TaskPlayerCount ) ) + end + end + + return Report:Text() +end + +--- Create a player report of the Mission. +-- This reports provides a one liner of the mission status. It indicates how many players and how many Tasks. +-- +-- Mission "" - Status "" +-- - Player ": Task , Task +-- - Player : Task , Task +-- - .. +-- +-- @param #MISSION self +-- @return #string +function MISSION:ReportPlayers() + + local Report = REPORT:New() + + -- List the name of the mission. + local Name = self:GetName() + + -- Determine the status of the mission. + local Status = self:GetState() + local TasksRemaining = self:GetTasksRemaining() + + Report:Add( string.format( '%s - Status "%s"', Name, Status ) ) + + local PlayerList = {} + + -- Determine how many tasks are remaining. + for TaskID, Task in pairs( self:GetTasks() ) do + local Task = Task -- Tasking.Task#TASK + local PlayerNames = Task:GetPlayerNames() + for PlayerID, PlayerName in pairs( PlayerNames ) do + PlayerList[PlayerName] = Task:GetName() + end + + end + + for PlayerName, TaskName in pairs( PlayerList ) do + Report:Add( string.format( ' - Player (%s): Task "%s"', PlayerName, TaskName ) ) + end + + return Report:Text() +end + + --- Create a summary report of the Mission (one line). -- @param #MISSION self -- @return #string @@ -645,7 +756,7 @@ function MISSION:ReportOverview( TaskStatus ) local Status = self:GetState() local TasksRemaining = self:GetTasksRemaining() - Report:Add( "Mission " .. Name .. " - " .. Status .. " Task Report ") + Report:Add( string.format( '%s - Status "%s"', Name, Status ) ) -- Determine how many tasks are remaining. local TasksRemaining = 0 @@ -672,7 +783,7 @@ function MISSION:ReportDetails() -- Determine the status of the mission. local Status = self:GetState() - Report:Add( "Mission " .. Name .. " - " .. Status ) + Report:Add( string.format( '%s - Status "%s"', Name, Status ) ) -- Determine how many tasks are remaining. local TasksRemaining = 0 diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index f006c584f..e2ae85c64 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -157,9 +157,9 @@ TASK = { -- @param #string TaskName The name of the Task -- @param #string TaskType The type of the Task -- @return #TASK self -function TASK:New( Mission, SetGroupAssign, TaskName, TaskType ) +function TASK:New( Mission, SetGroupAssign, TaskName, TaskType, TaskBriefing ) - local self = BASE:Inherit( self, FSM_TASK:New() ) -- Core.Fsm#FSM_TASK + local self = BASE:Inherit( self, FSM_TASK:New() ) -- Tasking.Task#TASK self:SetStartState( "Planned" ) self:AddTransition( "Planned", "Assign", "Assigned" ) @@ -189,7 +189,7 @@ function TASK:New( Mission, SetGroupAssign, TaskName, TaskType ) self:SetName( TaskName ) self:SetID( Mission:GetNextTaskID( self ) ) -- The Mission orchestrates the task sequences .. - self.TaskBriefing = "You are invited for the task: " .. self.TaskName .. "." + self:SetBriefing( TaskBriefing ) self.FsmTemplate = self.FsmTemplate or FSM_PROCESS:New() @@ -413,15 +413,15 @@ do -- Group Assignment local SetAssignedGroups = self:GetGroups() - SetAssignedGroups:ForEachGroup( - function( AssignedGroup ) - if self:IsGroupAssigned(AssignedGroup) then - self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is assigned to group %s.", TaskName, TaskGroupName ), AssignedGroup ) - else - self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is assigned to your group.", TaskName ), AssignedGroup ) - end - end - ) +-- SetAssignedGroups:ForEachGroup( +-- function( AssignedGroup ) +-- if self:IsGroupAssigned(AssignedGroup) then +-- self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is assigned to group %s.", TaskName, TaskGroupName ), AssignedGroup ) +-- else +-- self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is assigned to your group.", TaskName ), AssignedGroup ) +-- end +-- end +-- ) return self end @@ -468,6 +468,8 @@ do -- Group Assignment self:F( TaskGroup:GetName() ) local TaskGroupName = TaskGroup:GetName() + local Mission = self:GetMission() + local CommandCenter = Mission:GetCommandCenter() self:SetGroupAssigned( TaskGroup ) @@ -478,11 +480,16 @@ do -- Group Assignment self:E(PlayerName) if PlayerName ~= nil or PlayerName ~= "" then self:AssignToUnit( TaskUnit ) + CommandCenter:MessageToGroup( + string.format( 'Task "%s": Briefing for player (%s):\n%s', + self:GetName(), + PlayerName, + self:GetBriefing() + ), TaskGroup + ) end end - local Mission = self:GetMission() - local CommandCenter = Mission:GetCommandCenter() CommandCenter:SetMenu() return self @@ -848,6 +855,13 @@ function TASK:GetTaskName() return self.TaskName end +--- Returns the @{Task} briefing. +-- @param #TASK self +-- @return #string Task briefing. +function TASK:GetTaskBriefing() + return self.TaskBriefing +end + @@ -1117,10 +1131,18 @@ end -- @param #string TaskBriefing -- @return #TASK self function TASK:SetBriefing( TaskBriefing ) + self:E(TaskBriefing) self.TaskBriefing = TaskBriefing return self end +--- Gets the @{Task} briefing. +-- @param #TASK self +-- @return #string The briefing text. +function TASK:GetBriefing() + return self.TaskBriefing +end + diff --git a/Moose Development/Moose/Tasking/Task_A2G.lua b/Moose Development/Moose/Tasking/Task_A2G.lua index 17162ca7f..8c99d85f1 100644 --- a/Moose Development/Moose/Tasking/Task_A2G.lua +++ b/Moose Development/Moose/Tasking/Task_A2G.lua @@ -86,8 +86,8 @@ do -- TASK_A2G -- @param Core.Zone#ZONE_BASE TargetZone The target zone, if known. -- If the TargetZone parameter is specified, the player will be routed to the center of the zone where all the targets are assumed to be. -- @return #TASK_A2G self - function TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskType ) - local self = BASE:Inherit( self, TASK:New( Mission, SetGroup, TaskName, TaskType ) ) -- Tasking.Task#TASK_A2G + function TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskType, TaskBriefing ) + local self = BASE:Inherit( self, TASK:New( Mission, SetGroup, TaskName, TaskType, TaskBriefing ) ) -- Tasking.Task#TASK_A2G self:F() self.TargetSetUnit = TargetSetUnit @@ -364,16 +364,28 @@ do -- TASK_SEAD --- Instantiates a new TASK_SEAD. -- @param #TASK_SEAD self -- @param Tasking.Mission#MISSION Mission - -- @param Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. + -- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. -- @param #string TaskName The name of the Task. - -- @param Set#SET_UNIT TargetSetUnit + -- @param Core.Set#SET_UNIT TargetSetUnit + -- @param #string TaskBriefing The briefing of the task. -- @return #TASK_SEAD self - function TASK_SEAD:New( Mission, SetGroup, TaskName, TargetSetUnit ) - local self = BASE:Inherit( self, TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, "SEAD" ) ) -- #TASK_SEAD + function TASK_SEAD:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskBriefing ) + local self = BASE:Inherit( self, TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, "SEAD", TaskBriefing ) ) -- #TASK_SEAD self:F() Mission:AddTask( self ) + local TargetCoord = TargetSetUnit:GetFirst():GetCoordinate() + local TargetPositionText = TargetCoord:ToString() + local TargetThreatLevel = TargetSetUnit:CalculateThreatLevelA2G() + + self:SetBriefing( + TaskBriefing or + "Execute a Suppression of Enemy Air Defenses.\n" .. + "Initial Coordinates: " .. TargetPositionText .. "\n" .. + "Threat Level: [" .. string.rep( "■", TargetThreatLevel ) .. "]" + ) + return self end @@ -392,19 +404,28 @@ do -- TASK_BAI --- Instantiates a new TASK_BAI. -- @param #TASK_BAI self -- @param Tasking.Mission#MISSION Mission - -- @param Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. + -- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. -- @param #string TaskName The name of the Task. - -- @param Set#SET_UNIT UnitSetTargets - -- @param #number TargetDistance The distance to Target when the Player is considered to have "arrived" at the engagement range. - -- @param Core.Zone#ZONE_BASE TargetZone The target zone, if known. - -- If the TargetZone parameter is specified, the player will be routed to the center of the zone where all the targets are assumed to be. + -- @param Core.Set#SET_UNIT TargetSetUnit + -- @param #string TaskBriefing The briefing of the task. -- @return #TASK_BAI self - function TASK_BAI:New( Mission, SetGroup, TaskName, TargetSetUnit ) - local self = BASE:Inherit( self, TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, "BAI" ) ) -- #TASK_BAI + function TASK_BAI:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskBriefing ) + local self = BASE:Inherit( self, TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, "BAI", TaskBriefing ) ) -- #TASK_BAI self:F() Mission:AddTask( self ) + local TargetCoord = TargetSetUnit:GetFirst():GetCoordinate() + local TargetPositionText = TargetCoord:ToString() + local TargetThreatLevel = TargetSetUnit:CalculateThreatLevelA2G() + + self:SetBriefing( + TaskBriefing or + "Execute a Battleground Air Interdiction of a group of enemy targets.\n" .. + "Initial Coordinates: " .. TargetPositionText .. "\n" .. + "Threat Level: [" .. string.rep( "■", TargetThreatLevel ) .. "]" + ) + return self end @@ -423,19 +444,29 @@ do -- TASK_CAS --- Instantiates a new TASK_CAS. -- @param #TASK_CAS self -- @param Tasking.Mission#MISSION Mission - -- @param Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. + -- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. -- @param #string TaskName The name of the Task. - -- @param Set#SET_UNIT UnitSetTargets - -- @param #number TargetDistance The distance to Target when the Player is considered to have "arrived" at the engagement range. - -- @param Core.Zone#ZONE_BASE TargetZone The target zone, if known. - -- If the TargetZone parameter is specified, the player will be routed to the center of the zone where all the targets are assumed to be. + -- @param Core.Set#SET_UNIT TargetSetUnit + -- @param #string TaskBriefing The briefing of the task. -- @return #TASK_CAS self - function TASK_CAS:New( Mission, SetGroup, TaskName, TargetSetUnit ) - local self = BASE:Inherit( self, TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, "CAS" ) ) -- #TASK_CAS + function TASK_CAS:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskBriefing ) + local self = BASE:Inherit( self, TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, "CAS", TaskBriefing ) ) -- #TASK_CAS self:F() Mission:AddTask( self ) + local TargetCoord = TargetSetUnit:GetFirst():GetCoordinate() + local TargetPositionText = TargetCoord:ToString() + local TargetThreatLevel = TargetSetUnit:CalculateThreatLevelA2G() + + self:SetBriefing( + TaskBriefing or + "Execute a Close Air Support for a group of enemy targets.\n" .. + "Beware of friendlies at the vicinity!\n" .. + "Initial Coordinates: " .. TargetPositionText .. "\n" .. + "Threat Level: [" .. string.rep( "■", TargetThreatLevel ) .. "]" + ) + return self end diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index d80324af6..38d5c2316 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -153,7 +153,7 @@ do -- TASK_CARGO -- -- === -- - -- @field #TASK_CARGO TASK_CARGO + -- @field #TASK_CARGO -- TASK_CARGO = { ClassName = "TASK_CARGO", @@ -166,9 +166,10 @@ do -- TASK_CARGO -- @param #string TaskName The name of the Task. -- @param Core.Set#SET_CARGO SetCargo The scope of the cargo to be transported. -- @param #string TaskType The type of Cargo task. + -- @param #string TaskBriefing The Cargo Task briefing. -- @return #TASK_CARGO self - function TASK_CARGO:New( Mission, SetGroup, TaskName, SetCargo, TaskType ) - local self = BASE:Inherit( self, TASK:New( Mission, SetGroup, TaskName, TaskType ) ) -- #TASK_CARGO + function TASK_CARGO:New( Mission, SetGroup, TaskName, SetCargo, TaskType, TaskBriefing ) + local self = BASE:Inherit( self, TASK:New( Mission, SetGroup, TaskName, TaskType, TaskBriefing ) ) -- #TASK_CARGO self:F( {Mission, SetGroup, TaskName, SetCargo, TaskType}) self.SetCargo = SetCargo @@ -696,9 +697,10 @@ do -- TASK_CARGO_TRANSPORT -- @param Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. -- @param #string TaskName The name of the Task. -- @param Core.Set#SET_CARGO SetCargo The scope of the cargo to be transported. + -- @param #string TaskBriefing The Cargo Task briefing. -- @return #TASK_CARGO_TRANSPORT self - function TASK_CARGO_TRANSPORT:New( Mission, SetGroup, TaskName, SetCargo ) - local self = BASE:Inherit( self, TASK_CARGO:New( Mission, SetGroup, TaskName, SetCargo, "Transport" ) ) -- #TASK_CARGO_TRANSPORT + function TASK_CARGO_TRANSPORT:New( Mission, SetGroup, TaskName, SetCargo, TaskBriefing ) + local self = BASE:Inherit( self, TASK_CARGO:New( Mission, SetGroup, TaskName, SetCargo, "Transport", TaskBriefing ) ) -- #TASK_CARGO_TRANSPORT self:F() Mission:AddTask( self ) @@ -709,8 +711,6 @@ do -- TASK_CARGO_TRANSPORT self:AddTransition( "*", "CargoPickedUp", "*" ) self:AddTransition( "*", "CargoDeployed", "*" ) - do - --- OnBefore Transition Handler for Event CargoPickedUp. -- @function [parent=#TASK_CARGO_TRANSPORT] OnBeforeCargoPickedUp -- @param #TASK_CARGO_TRANSPORT self @@ -742,9 +742,7 @@ do -- TASK_CARGO_TRANSPORT -- @param #number Delay The delay in seconds. -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that PickedUp the cargo. You can use this to retrieve the PlayerName etc. -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - end - do --- OnBefore Transition Handler for Event CargoDeployed. -- @function [parent=#TASK_CARGO_TRANSPORT] OnBeforeCargoDeployed -- @param #TASK_CARGO_TRANSPORT self @@ -780,10 +778,26 @@ do -- TASK_CARGO_TRANSPORT -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that Deployed the cargo. You can use this to retrieve the PlayerName etc. -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. -- @param Core.Zone#ZONE DeployZone The zone where the Cargo got Deployed or UnBoarded. - end local Fsm = self:GetUnitProcess() + local CargoReport = REPORT:New( "Transport Cargo. The following cargo needs to be transported including initial positions:") + + SetCargo:ForEachCargo( + --- @param Core.Cargo#CARGO Cargo + function( Cargo ) + local CargoType = Cargo:GetType() + local CargoName = Cargo:GetName() + local CargoCoordinate = Cargo:GetCoordinate() + CargoReport:Add( string.format( '- "%s" (%s) at %s', CargoName, CargoType, CargoCoordinate:ToString() ) ) + end + ) + + self:SetBriefing( + TaskBriefing or + CargoReport:Text() + ) + return self end @@ -815,7 +829,7 @@ do -- TASK_CARGO_TRANSPORT end end end - + return CargoDeployed end diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 7a192ba64..c815b7bfb 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -334,7 +334,7 @@ function POSITIONABLE:GetMessageText( Message, Name ) --R2.1 added local DCSObject = self:GetDCSObject() if DCSObject then Name = Name and ( " (" .. Name .. ")" ) or "" - local Callsign = self:GetCallsign() ~= "" and self:GetCallsign() or self:GetName() + local Callsign = string.format( "[%s]", self:GetCallsign() ~= "" and self:GetCallsign() or self:GetName() ) local MessageText = Callsign .. Name .. ": " .. Message return MessageText end @@ -383,12 +383,19 @@ end -- @param #string Message The message text -- @param Dcs.DCSTYpes#Duration Duration The duration of the message. -- @param Dcs.DCScoalition#coalition MessageCoalition The Coalition receiving the message. --- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable. -function POSITIONABLE:MessageToCoalition( Message, Duration, MessageCoalition, Name ) +function POSITIONABLE:MessageToCoalition( Message, Duration, MessageCoalition ) self:F2( { Message, Duration } ) + local Name = "" + local DCSObject = self:GetDCSObject() if DCSObject then + if MessageCoalition == coalition.side.BLUE then + Name = "Blue coalition" + end + if MessageCoalition == coalition.side.RED then + Name = "Red coalition" + end self:GetMessage( Message, Duration, Name ):ToCoalition( MessageCoalition ) end