From bfb11b6f79026607543f811c20dae7c6644c26ec Mon Sep 17 00:00:00 2001 From: FlightControl Date: Sat, 23 Mar 2019 10:45:14 +0100 Subject: [PATCH] Updates on goal logic --- Moose Development/Moose/Tasking/Mission.lua | 15 ++++++++------- Moose Development/Moose/Tasking/Task.lua | 17 +++++++++++++++++ .../Moose/Tasking/Task_Capture_Zone.lua | 4 ++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index 2d6ac4660..f057c9648 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -968,18 +968,19 @@ function MISSION:ReportPlayersProgress( ReportGroup ) -- Determine how many tasks are remaining. for TaskID, Task in pairs( self:GetTasks() ) do local Task = Task -- Tasking.Task#TASK - local TaskGoalTotal = Task:GetGoalTotal() or 0 local TaskName = Task:GetName() + local Goal = Task:GetGoal() PlayerList[TaskName] = PlayerList[TaskName] or {} - if TaskGoalTotal ~= 0 then - local PlayerNames = self:GetPlayerNames() - for PlayerName, PlayerData in pairs( PlayerNames ) do - PlayerList[TaskName][PlayerName] = string.format( 'Player (%s): Task "%s": %d%%', PlayerName, TaskName, Task:GetPlayerProgress( PlayerName ) * 100 / TaskGoalTotal ) + if Goal then + local TotalContributions = Goal:GetTotalContributions() + local PlayerContributions = Goal:GetPlayerContributions() + self:F( { TotalContributions = TotalContributions, PlayerContributions = PlayerContributions } ) + for PlayerName, PlayerContribution in pairs( PlayerContributions ) do + PlayerList[TaskName][PlayerName] = string.format( 'Player (%s): Task "%s": %d%%', PlayerName, TaskName, PlayerContributions[PlayerName] * 100 / TotalContributions ) end else PlayerList[TaskName]["_"] = string.format( 'Player (---): Task "%s": %d%%', TaskName, 0 ) - end - + end end for TaskName, TaskData in pairs( PlayerList ) do diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 797de7d61..68c8a4803 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -1709,6 +1709,23 @@ end do -- Links + --- Set goal of a task + -- @param #TASK self + -- @param Core.Goal#GOAL Goal + -- @return #TASK + function TASK:SetGoal( Goal ) + self.Goal = Goal + end + + + --- Get goal of a task + -- @param #TASK self + -- @return Core.Goal#GOAL The Goal + function TASK:GetGoal() + return self.Goal + end + + --- Set dispatcher of a task -- @param #TASK self -- @param Tasking.DetectionManager#DETECTION_MANAGER Dispatcher diff --git a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua index e39e8b2c9..9ab0f35c7 100644 --- a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua +++ b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua @@ -213,7 +213,7 @@ do -- TASK_CAPTURE_ZONE self:UpdateTaskInfo( true ) - self:SetGoalTotal( 1 ) + self:SetGoal( self.ZoneGoal.Goal ) return self end @@ -232,7 +232,7 @@ do -- TASK_CAPTURE_ZONE self.TaskInfo:AddText( "Zone Coalition", self.ZoneGoal:GetCoalitionName(), 11, "MOD", Persist ) local SetUnit = self.ZoneGoal.Zone:GetScannedSetUnit() local ThreatLevel, ThreatText = SetUnit:CalculateThreatLevelA2G() - self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 20, "MSOD", Persist ) + self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 20, "MOD", Persist ) end