From feef4c148ec030d73eabae953daabd946e095563 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Wed, 4 Oct 2017 17:12:05 +0200 Subject: [PATCH] Progress --- .../Moose/Actions/Act_Account.lua | 21 -- Moose Development/Moose/Core/Goal.lua | 180 ++++-------------- Moose Development/Moose/Core/ZoneGoal.lua | 172 ++++------------- .../Moose/Core/ZoneGoalCoalition.lua | 123 +++++++++++- .../Moose/Functional/Scoring.lua | 33 ++++ ...sk_ZoneCapture.lua => TaskZoneCapture.lua} | 87 ++------- Moose Mission Setup/Moose.files | 2 +- 7 files changed, 244 insertions(+), 374 deletions(-) rename Moose Development/Moose/Tasking/{Task_ZoneCapture.lua => TaskZoneCapture.lua} (75%) diff --git a/Moose Development/Moose/Actions/Act_Account.lua b/Moose Development/Moose/Actions/Act_Account.lua index 0cc641623..c8412b1d9 100644 --- a/Moose Development/Moose/Actions/Act_Account.lua +++ b/Moose Development/Moose/Actions/Act_Account.lua @@ -285,26 +285,5 @@ do -- ACT_ACCOUNT_DEADS end end - --- @param #ACT_ACCOUNT_DEADS self - -- @param Event#EVENTDATA EventData - function ACT_ACCOUNT_DEADS:onfuncEventDead( EventData ) - self:T( { "EventDead", EventData } ) - - if EventData.IniDCSUnit then - self:Event( EventData ) - end - end - - --- DCS Events - - --- @param #ACT_ACCOUNT_DEADS self - -- @param Event#EVENTDATA EventData - function ACT_ACCOUNT_DEADS:onfuncEventCrash( EventData ) - self:T( { "EventDead", EventData } ) - - if EventData.IniDCSUnit then - self:Event( EventData ) - end - end end -- ACT_ACCOUNT DEADS diff --git a/Moose Development/Moose/Core/Goal.lua b/Moose Development/Moose/Core/Goal.lua index d6f4d405b..e423cdde0 100644 --- a/Moose Development/Moose/Core/Goal.lua +++ b/Moose Development/Moose/Core/Goal.lua @@ -45,8 +45,11 @@ do -- Goal ClassName = "GOAL", } - --- @field #table GOAL.States - GOAL.States = {} + --- @field #table GOAL.Players + GOAL.Players = {} + + --- @field #number GOAL.TotalContributions + GOAL.TotalContributions = 0 --- GOAL Constructor. -- @param #GOAL self @@ -56,51 +59,6 @@ do -- Goal local self = BASE:Inherit( self, FSM:New() ) -- #GOAL self:F( {} ) - - do - - --- On State for GOAL - -- @field GOAL.On - - --- On State Handler OnLeave for GOAL - -- @function [parent=#GOAL] OnLeaveOn - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- On State Handler OnEnter for GOAL - -- @function [parent=#GOAL] OnEnterOn - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - end - - do - - --- Off State for GOAL - -- @field GOAL.Off - - --- Off State Handler OnLeave for GOAL - -- @function [parent=#GOAL] OnLeaveOff - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- Off State Handler OnEnter for GOAL - -- @function [parent=#GOAL] OnEnterOff - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - end - --- Achieved State for GOAL -- @field GOAL.Achieved @@ -120,86 +78,7 @@ do -- Goal -- @param #string To - self:SetStartState( "Idle" ) - self:AddTransition( "Idle", "Start", "On" ) - - --- Start Handler OnBefore for GOAL - -- @function [parent=#GOAL] OnBeforeStart - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- Start Handler OnAfter for GOAL - -- @function [parent=#GOAL] OnAfterStart - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - --- Start Trigger for GOAL - -- @function [parent=#GOAL] Start - -- @param #GOAL self - - --- Start Asynchronous Trigger for GOAL - -- @function [parent=#GOAL] __Start - -- @param #GOAL self - -- @param #number Delay - - self:AddTransition( "On", "Stop", "Idle" ) - - --- Stop Handler OnBefore for GOAL - -- @function [parent=#GOAL] OnBeforeStop - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- Stop Handler OnAfter for GOAL - -- @function [parent=#GOAL] OnAfterStop - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - --- Stop Trigger for GOAL - -- @function [parent=#GOAL] Stop - -- @param #GOAL self - - --- Stop Asynchronous Trigger for GOAL - -- @function [parent=#GOAL] __Stop - -- @param #GOAL self - -- @param #number Delay - - - self:AddTransition( "On", "IsAchieved", "On" ) - - --- IsAchieved Handler OnBefore for GOAL - -- @function [parent=#GOAL] OnBeforeIsAchieved - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- IsAchieved Handler OnAfter for GOAL - -- @function [parent=#GOAL] OnAfterIsAchieved - -- @param #GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - --- IsAchieved Trigger for GOAL - -- @function [parent=#GOAL] IsAchieved - -- @param #GOAL self - - --- IsAchieved Asynchronous Trigger for GOAL - -- @function [parent=#GOAL] __IsAchieved - -- @param #GOAL self - -- @param #number Delay - + self:SetStartState( "Pending" ) self:AddTransition( "*", "Achieved", "Achieved" ) --- Achieved Handler OnBefore for GOAL @@ -226,9 +105,6 @@ do -- Goal -- @param #GOAL self -- @param #number Delay - - self.AchievedScheduler = nil - self:SetEventPriority( 5 ) return self @@ -236,30 +112,38 @@ do -- Goal --- @param #GOAL self - -- @param From - -- @param Event - -- @param To - function GOAL:onafterOn( From, Event, To ) - if not self.AchievedScheduler then - self.AchievedScheduler = self:ScheduleRepeat( 15, 15, 0, nil, self.CheckAchieved, self ) - end + -- @param #string PlayerName + function GOAL:AddPlayerContribution( PlayerName ) + self.Players[PlayerName] = self.Players[PlayerName] or 0 + self.Players[PlayerName] = self.Players[PlayerName] + 1 + self.TotalContributions = self.TotalContributions + 1 + end + + + --- @param #GOAL self + -- @param #number Player contribution. + function GOAL:GetPlayerContribution( PlayerName ) + return self.Players[PlayerName] or 0 end + --- @param #GOAL self - -- @param From - -- @param Event - -- @param To - function GOAL:onafterOff( From, Event, To ) - self:ScheduleStop( self.CheckAchieved ) - self.ArchievedScheduler = nil + function GOAL:GetPlayerContributions() + return self.Players or {} end + --- @param #GOAL self - -- @param From - -- @param Event - -- @param To - function GOAL:CheckAchieved( From, Event, To ) - self:IsAchieved() + function GOAL:GetTotalContributions() + return self.TotalContributions or 0 + end + + + + --- @param #GOAL self + -- @return #boolean true if the goal is Achieved + function GOAL:IsAchieved() + return self:Is( "Achieved" ) end end \ No newline at end of file diff --git a/Moose Development/Moose/Core/ZoneGoal.lua b/Moose Development/Moose/Core/ZoneGoal.lua index d5f7b9dda..794c7611d 100644 --- a/Moose Development/Moose/Core/ZoneGoal.lua +++ b/Moose Development/Moose/Core/ZoneGoal.lua @@ -43,9 +43,6 @@ do -- Zone ClassName = "ZONE_GOAL", } - --- @field #table ZONE_GOAL.States - ZONE_GOAL.States = {} - --- ZONE_GOAL Constructor. -- @param #ZONE_GOAL self -- @param Core.Zone#ZONE_BASE Zone A @{Zone} object with the goal to be achieved. @@ -58,101 +55,20 @@ do -- Zone self.Zone = Zone -- Core.Zone#ZONE_BASE self.Goal = GOAL:New() - do - - --- Guarded State Handler OnLeave for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnLeaveGuarded - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- Guarded State Handler OnEnter for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnEnterGuarded - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - end - - - do - - --- Empty State Handler OnLeave for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnLeaveEmpty - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- Empty State Handler OnEnter for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnEnterEmpty - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - end - - - self:AddTransition( "*", "Guard", "Guarded" ) - - --- Guard Handler OnBefore for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnBeforeGuard - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- Guard Handler OnAfter for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnAfterGuard - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - --- Guard Trigger for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] Guard - -- @param #ZONE_GOAL self - - --- Guard Asynchronous Trigger for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] __Guard - -- @param #ZONE_GOAL self - -- @param #number Delay - - self:AddTransition( "*", "Empty", "Empty" ) - - --- Empty Handler OnBefore for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnBeforeEmpty - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - -- @return #boolean - - --- Empty Handler OnAfter for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] OnAfterEmpty - -- @param #ZONE_GOAL self - -- @param #string From - -- @param #string Event - -- @param #string To - - --- Empty Trigger for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] Empty - -- @param #ZONE_GOAL self - - --- Empty Asynchronous Trigger for ZONE_GOAL - -- @function [parent=#ZONE_GOAL] __Empty - -- @param #ZONE_GOAL self - -- @param #number Delay - - self.SmokeTime = nil + + self:AddTransition( "*", "DestroyedUnit", "*" ) + + --- DestroyedUnit Handler OnAfter for ZONE_GOAL + -- @function [parent=#ZONE_GOAL] OnAfterDestroyedUnit + -- @param #ZONE_GOAL self + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param Wrapper.Unit#UNIT DestroyedUnit The destroyed unit. + -- @param #string PlayerName The name of the player. + return self end @@ -171,6 +87,7 @@ do -- Zone return self.Zone:GetName() end + --- Smoke the center of theh zone. -- @param #ZONE_GOAL self -- @param #SMOKECOLOR.Color SmokeColor @@ -204,41 +121,7 @@ do -- Zone end end - function ZONE_GOAL:IsGuarded() - - local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition ) - self:E( { IsGuarded = IsGuarded } ) - return IsGuarded - end - - function ZONE_GOAL:IsEmpty() - - local IsEmpty = self.Zone:IsNoneInZone() - self:E( { IsEmpty = IsEmpty } ) - return IsEmpty - end - - - --- Check status Zone. - -- @param #ZONE_GOAL self - function ZONE_GOAL:StatusZone() - - local State = self:GetState() - self:E( { State = self:GetState() } ) - - self.Zone:Scan() - - if State ~= "Guarded" and self:IsGuarded() then - self:Guard() - end - - if State ~= "Empty" and self:IsEmpty() then - self:Empty() - end - - end - --- Check status Smoke. -- @param #ZONE_GOAL self function ZONE_GOAL:StatusSmoke() @@ -255,5 +138,34 @@ do -- Zone end end end + + + --- @param #ZONE_GOAL self + -- @param Event#EVENTDATA EventData + function ZONE_GOAL:__Destroyed( EventData ) + self:T( { "EventDead", EventData } ) + + if EventData.IniDCSUnit then + if EventData.IniUnit:IsInZone( self:GetZone() ) then + local PlayerHits = _DATABASE.HITS[EventData.IniUnitName] + if PlayerHits then + for PlayerName, PlayerHit in pairs( PlayerHits ) do + self.Goal:AddPlayerContribution( PlayerName ) + self:DestroyedUnit( EventData.IniUnitName, PlayerName ) + end + end + end + end + end + + + --- Activate the event UnitDestroyed to be fired when a unit is destroyed in the zone. + -- @param #ZONE_GOAL self + function ZONE_GOAL:MonitorDestroyedUnits() + + self:HandleEvent( EVENTS.Dead, self.__Destroyed ) + self:HandleEvent( EVENTS.Crash, self.__Destroyed ) + + end end diff --git a/Moose Development/Moose/Core/ZoneGoalCoalition.lua b/Moose Development/Moose/Core/ZoneGoalCoalition.lua index e0437433b..6ef2890ed 100644 --- a/Moose Development/Moose/Core/ZoneGoalCoalition.lua +++ b/Moose Development/Moose/Core/ZoneGoalCoalition.lua @@ -16,10 +16,10 @@ do -- ZoneGoal --- @type ZONE_GOAL_COALITION - -- @extends Core.ZoneGoal#ZONE_GOAL + -- @extends Core.ZoneGoal#ZONE_GOAL_COALITION - --- # ZONE_GOAL_COALITION class, extends @{ZoneGoal#ZONE_GOAL} + --- # ZONE_GOAL_COALITION class, extends @{ZoneGoal#ZONE_GOAL_COALITION} -- -- ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition. -- Derived classes implement the ways how the achievements can be realized. @@ -67,7 +67,7 @@ do -- ZoneGoal -- @return #ZONE_GOAL_COALITION function ZONE_GOAL_COALITION:New( Zone, Coalition ) - local self = BASE:Inherit( self, ZONE_GOAL:New( Zone ) ) -- #ZONE_GOAL_COALITION + local self = BASE:Inherit( self, ZONE_GOAL_COALITION:New( Zone ) ) -- #ZONE_GOAL_COALITION self:F( { Zone = Zone, Coalition = Coalition } ) self:SetCoalition( Coalition ) @@ -110,10 +110,98 @@ do -- ZoneGoal -- @param #string To end + + do - self:E( { Guarded = "Guarded" } ) + --- Guarded State Handler OnLeave for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnLeaveGuarded + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + -- @return #boolean + --- Guarded State Handler OnEnter for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnEnterGuarded + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + end + + + do + + --- Empty State Handler OnLeave for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnLeaveEmpty + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + -- @return #boolean + + --- Empty State Handler OnEnter for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnEnterEmpty + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + + end + + self:AddTransition( "*", "Guard", "Guarded" ) + + --- Guard Handler OnBefore for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnBeforeGuard + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + -- @return #boolean + + --- Guard Handler OnAfter for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnAfterGuard + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + + --- Guard Trigger for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] Guard + -- @param #ZONE_GOAL_COALITION self + + --- Guard Asynchronous Trigger for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] __Guard + -- @param #ZONE_GOAL_COALITION self + -- @param #number Delay + + self:AddTransition( "*", "Empty", "Empty" ) + + --- Empty Handler OnBefore for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnBeforeEmpty + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + -- @return #boolean + + --- Empty Handler OnAfter for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] OnAfterEmpty + -- @param #ZONE_GOAL_COALITION self + -- @param #string From + -- @param #string Event + -- @param #string To + + --- Empty Trigger for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] Empty + -- @param #ZONE_GOAL_COALITION self + + --- Empty Asynchronous Trigger for ZONE_GOAL_COALITION + -- @function [parent=#ZONE_GOAL_COALITION] __Empty + -- @param #ZONE_GOAL_COALITION self + -- @param #number Delay + self:AddTransition( { "Guarded", "Empty" }, "Attack", "Attacked" ) @@ -214,7 +302,16 @@ do -- ZoneGoal self:E( { IsGuarded = IsGuarded } ) return IsGuarded end + + + function ZONE_GOAL_COALITION:IsEmpty() + local IsEmpty = self.Zone:IsNoneInZone() + self:E( { IsEmpty = IsEmpty } ) + return IsEmpty + end + + function ZONE_GOAL_COALITION:IsCaptured() local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition ) @@ -300,7 +397,7 @@ do -- ZoneGoal --- When started, check the Coalition status. - -- @param #ZONE_GOAL self + -- @param #ZONE_GOAL_COALITION self function ZONE_GOAL_COALITION:onafterGuard() --self:E({BASE:GetParent( self )}) @@ -334,11 +431,21 @@ do -- ZoneGoal -- @param #ZONE_GOAL_COALITION self function ZONE_GOAL_COALITION:StatusZone() - local State = self:GetState() - self:E( { State = self:GetState() } ) - self:GetParent( self, ZONE_GOAL_COALITION ).StatusZone( self ) + local State = self:GetState() + self:E( { State = self:GetState() } ) + + self.Zone:Scan() + + if State ~= "Guarded" and self:IsGuarded() then + self:Guard() + end + + if State ~= "Empty" and self:IsEmpty() then + self:Empty() + end + if State ~= "Attacked" and self:IsAttacked() then self:Attack() end diff --git a/Moose Development/Moose/Functional/Scoring.lua b/Moose Development/Moose/Functional/Scoring.lua index 40c434f33..35dc1b2fd 100644 --- a/Moose Development/Moose/Functional/Scoring.lua +++ b/Moose Development/Moose/Functional/Scoring.lua @@ -710,6 +710,39 @@ function SCORING:_AddMissionTaskScore( Mission, PlayerUnit, Text, Score ) end end +--- Registers Scores the players completing a Mission Task. +-- @param #SCORING self +-- @param Tasking.Mission#MISSION Mission +-- @param #string PlayerName +-- @param #string Text +-- @param #number Score +function SCORING:_AddMissionGoalScore( Mission, PlayerName, Text, Score ) + + local MissionName = Mission:GetName() + + self:E( { Mission:GetName(), PlayerName, Text, Score } ) + + -- PlayerName can be nil, if the Unit with the player crashed or due to another reason. + if PlayerName then + local PlayerData = self.Players[PlayerName] + + if not PlayerData.Mission[MissionName] then + PlayerData.Mission[MissionName] = {} + PlayerData.Mission[MissionName].ScoreTask = 0 + PlayerData.Mission[MissionName].ScoreMission = 0 + end + + self:T( PlayerName ) + self:T( PlayerData.Mission[MissionName] ) + + PlayerData.Score = self.Players[PlayerName].Score + Score + PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score + + MESSAGE:NewType( self.DisplayMessagePrefix .. MissionName .. " : " .. Text .. " Score: " .. Score, MESSAGE.Type.Information ):ToAll() + + self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score ) + end +end --- Registers Mission Scores for possible multiple players that contributed in the Mission. -- @param #SCORING self diff --git a/Moose Development/Moose/Tasking/Task_ZoneCapture.lua b/Moose Development/Moose/Tasking/TaskZoneCapture.lua similarity index 75% rename from Moose Development/Moose/Tasking/Task_ZoneCapture.lua rename to Moose Development/Moose/Tasking/TaskZoneCapture.lua index 5ee4e8c43..fc5d34359 100644 --- a/Moose Development/Moose/Tasking/Task_ZoneCapture.lua +++ b/Moose Development/Moose/Tasking/TaskZoneCapture.lua @@ -8,7 +8,7 @@ -- -- ==== -- --- @module Task_Protect +-- @module TaskZoneCapture do -- TASK_ZONE_GOAL @@ -78,7 +78,7 @@ do -- TASK_ZONE_GOAL -- @param Tasking.Task#TASK_ZONE_GOAL Task function Fsm:onafterStartMonitoring( TaskUnit, Task ) self:E( { self } ) - self:__Protect( 0.1 ) + self:__Monitor( 0.1 ) self:__RouteToTarget( 0.1 ) end @@ -88,7 +88,7 @@ do -- TASK_ZONE_GOAL -- @param Tasking.Task#TASK_ZONE_GOAL Task function Fsm:onafterMonitor( TaskUnit, Task ) self:E( { self } ) - self:__Protect( 15 ) + self:__Monitor( 15 ) end --- Test @@ -146,9 +146,9 @@ do -- TASK_ZONE_GOAL return ActRouteZone:GetZone() end - function TASK_ZONE_GOAL:SetGoalTotal() + function TASK_ZONE_GOAL:SetGoalTotal( GoalTotal ) - self.GoalTotal = 1 + self.GoalTotal = GoalTotal end function TASK_ZONE_GOAL:GetGoalTotal() @@ -164,7 +164,7 @@ do -- TASK_CAPTURE_ZONE --- The TASK_CAPTURE_ZONE class -- @type TASK_CAPTURE_ZONE -- @field Set#SET_UNIT TargetSetUnit - -- @extends Tasking.TaskZoneGoal#TASK_ZONE_GOAL + -- @extends #TASK_ZONE_GOAL --- # TASK_CAPTURE_ZONE class, extends @{TaskZoneGoal#TASK_ZONE_GOAL} -- @@ -184,18 +184,18 @@ do -- TASK_CAPTURE_ZONE -- @param Tasking.Mission#MISSION Mission -- @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 Core.ZoneGoal#ZONE_GOAL ZoneGoal + -- @param Core.ZoneGoalCoalition#ZONE_GOAL_COALITION ZoneGoalCoalition -- @param #string TaskBriefing The briefing of the task. -- @return #TASK_CAPTURE_ZONE self - function TASK_CAPTURE_ZONE:New( Mission, SetGroup, TaskName, ZoneGoal, TaskBriefing) - local self = BASE:Inherit( self, TASK_ZONE_GOAL:New( Mission, SetGroup, TaskName, ZoneGoal, "CAPTURE", TaskBriefing ) ) -- #TASK_CAPTURE_ZONE + function TASK_CAPTURE_ZONE:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, TaskBriefing) + local self = BASE:Inherit( self, TASK_ZONE_GOAL:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, "CAPTURE", TaskBriefing ) ) -- #TASK_CAPTURE_ZONE self:F() Mission:AddTask( self ) - self.TaskCoalition = ZoneGoal:GetCoalition() - self.TaskCoalitionName = ZoneGoal:GetCoalitionName() - self.TaskZoneName = self.ZoneGoal:GetZoneName() + self.TaskCoalition = ZoneGoalCoalition:GetCoalition() + self.TaskCoalitionName = ZoneGoalCoalition:GetCoalitionName() + self.TaskZoneName = ZoneGoalCoalition:GetZoneName() self:SetBriefing( TaskBriefing or @@ -234,66 +234,21 @@ do -- TASK_CAPTURE_ZONE self:E( { PlayerUnit = PlayerUnit } ) if self.ZoneGoal then - local ProtectCoalition = self.ZoneGoal:GetCoalition() - local TaskCoalition = self.Coalition - - self:E( { ProtectCoalition = ProtectCoalition, TaskCoalition = TaskCoalition } ) - - if ProtectCoalition ~= TaskCoalition then + if self.ZoneGoal.Goal:IsAchieved() then self:Success() + local TotalContributions = self.ZoneGoal.Goal:GetTotalContributions() + for PlayerName, PlayerContribution in pairs( self.ZoneGoal.Goal:GetPlayerContributions() ) do + local Task = self.Task + local Scoring = Task:GetScoring() + if Scoring then + Scoring:_AddMissionGoalScore( Task.Mission, PlayerName, "Captured Zone", PlayerContribution * 200 / TotalContributions ) + end + end end end self:__Goal( -10, PlayerUnit, PlayerName ) end - --- Set a score when a target in scope of the A2G attack, has been destroyed . - -- @param #TASK_CAPTURE_ZONE self - -- @param #string PlayerName The name of the player. - -- @param #number Score The score in points to be granted when task process has been achieved. - -- @param Wrapper.Unit#UNIT TaskUnit - -- @return #TASK_CAPTURE_ZONE - function TASK_CAPTURE_ZONE:SetScoreOnProgress( PlayerName, Score, TaskUnit ) - self:F( { PlayerName, Score, TaskUnit } ) - - local ProcessUnit = self:GetUnitProcess( TaskUnit ) - - --ProcessUnit:AddScoreProcess( "Protecting", "ZoneGoal", "Captured", "Player " .. PlayerName .. " has SEADed a target.", Score ) - - return self - end - - --- Set a score when all the targets in scope of the A2G attack, have been destroyed. - -- @param #TASK_CAPTURE_ZONE self - -- @param #string PlayerName The name of the player. - -- @param #number Score The score in points. - -- @param Wrapper.Unit#UNIT TaskUnit - -- @return #TASK_CAPTURE_ZONE - function TASK_CAPTURE_ZONE:SetScoreOnSuccess( PlayerName, Score, TaskUnit ) - self:F( { PlayerName, Score, TaskUnit } ) - - local ProcessUnit = self:GetUnitProcess( TaskUnit ) - - ProcessUnit:AddScore( "Success", "The zone has been captured!", Score ) - - return self - end - - --- Set a penalty when the A2G attack has failed. - -- @param #TASK_CAPTURE_ZONE self - -- @param #string PlayerName The name of the player. - -- @param #number Penalty The penalty in points, must be a negative value! - -- @param Wrapper.Unit#UNIT TaskUnit - -- @return #TASK_CAPTURE_ZONE - function TASK_CAPTURE_ZONE:SetScoreOnFail( PlayerName, Penalty, TaskUnit ) - self:F( { PlayerName, Penalty, TaskUnit } ) - - local ProcessUnit = self:GetUnitProcess( TaskUnit ) - - ProcessUnit:AddScore( "Failed", "The zone has been lost!", Penalty ) - - return self - end - end diff --git a/Moose Mission Setup/Moose.files b/Moose Mission Setup/Moose.files index 09d931114..7bc7a8f0e 100644 --- a/Moose Mission Setup/Moose.files +++ b/Moose Mission Setup/Moose.files @@ -72,6 +72,6 @@ Tasking/Task_A2G.lua Tasking/Task_A2A_Dispatcher.lua Tasking/Task_A2A.lua Tasking/Task_Cargo.lua -Tasking/Task_Protect.lua +Tasking/TaskZoneCapture.lua Moose.lua