This commit is contained in:
FlightControl_Master
2017-10-05 18:31:39 +02:00
parent cd83a0b488
commit ffc1c5d6ad
10 changed files with 335 additions and 380 deletions

View File

@@ -878,42 +878,20 @@ function TASK:MenuMarkToGroup( TaskGroup )
-- List the name of the Task.
local Name = self:GetName()
Report:Add( Name .. ": " .. self:GetTaskBriefing() )
Report:Add( "Task " .. Name .. ": " .. self:GetTaskBriefing() .. "\n" )
for TaskInfoID, TaskInfo in pairs( self.TaskInfo, function( t, a, b ) return t[a].TaskInfoOrder < t[b].TaskInfoOrder end ) do
local TaskInfoIDText = "" --string.format( "%s: ", TaskInfoID )
if type( TaskInfo.TaskInfoText ) == "string" then
if TaskInfoID == "Targets" then
else
Report:Add( TaskInfoIDText .. TaskInfo.TaskInfoText )
end
elseif type( TaskInfo ) == "table" then
if TaskInfoID == "Coordinates" then
--local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
--Report:Add( TaskInfoIDText .. ToCoordinate:ToString() )
else
end
local ReportText = self:GetMarkInfo( TaskInfoID, TaskInfo )
if ReportText then
Report:Add( ReportText )
end
end
local Coordinate = self:GetInfo( "Coordinates" ) -- Core.Point#COORDINATE
local Velocity = self.TargetSetUnit:GetVelocity()
local Heading = self.TargetSetUnit:GetHeading()
Coordinate:SetHeading( Heading )
Coordinate:SetVelocity( Velocity )
Report:Add( "Targets are" .. Coordinate:GetMovingText() .. "." )
local TargetCoordinate = self:GetInfo( "Coordinate" ) -- Core.Point#COORDINATE
local MarkText = Report:Text( ", " )
self:F( { Coordinate = Coordinate, MarkText = MarkText } )
Coordinate:MarkToGroup( MarkText, TaskGroup )
self:F( { Coordinate = TargetCoordinate, MarkText = MarkText } )
TargetCoordinate:MarkToGroup( MarkText, TaskGroup )
--Coordinate:MarkToAll( Briefing )
end
@@ -1449,14 +1427,14 @@ function TASK:ReportSummary( ReportGroup )
local Report = REPORT:New()
-- List the name of the Task.
Report:Add( self:GetName() )
Report:Add( "Task " .. self:GetName() )
-- Determine the status of the Task.
Report:Add( "State: <" .. self:GetState() .. ">" )
if self.TaskInfo["Coordinates"] then
if self.TaskInfo["Coordinate"] then
local TaskInfoIDText = string.format( "%s: ", "Coordinate" )
local TaskCoord = self.TaskInfo["Coordinates"].TaskInfoText -- Core.Point#COORDINATE
local TaskCoord = self.TaskInfo["Coordinate"].TaskInfoText -- Core.Point#COORDINATE
Report:Add( TaskInfoIDText .. TaskCoord:ToString( ReportGroup, nil, self ) )
end
@@ -1486,7 +1464,7 @@ function TASK:ReportOverview( ReportGroup )
if Line ~= 0 then
Report:AddIndent( LineReport:Text( ", " ) )
else
Report:Add( TaskName .. ", " .. LineReport:Text( ", " ) )
Report:Add( "Task " .. TaskName .. ", " .. LineReport:Text( ", " ) )
end
LineReport = REPORT:New()
Line = math.floor( TaskInfo.TaskInfoOrder / 10 )
@@ -1497,7 +1475,7 @@ function TASK:ReportOverview( ReportGroup )
if type( TaskInfo.TaskInfoText ) == "string" then
LineReport:Add( TaskInfoIDText .. TaskInfo.TaskInfoText )
elseif type(TaskInfo) == "table" then
if TaskInfoID == "Coordinates" then
if TaskInfoID == "Coordinate" then
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
--Report:Add( TaskInfoIDText )
LineReport:Add( TaskInfoIDText .. ToCoordinate:ToString( ReportGroup, nil, self ) )
@@ -1571,7 +1549,7 @@ function TASK:ReportDetails( ReportGroup )
-- Determine the status of the Task.
local Status = "<" .. self:GetState() .. ">"
Report:Add( "Task: " .. Name .. " - " .. Status .. " - Detailed Report" )
Report:Add( "Task " .. Name .. " - " .. Status .. " - Detailed Report" )
-- Loop each Unit active in the Task, and find Player Names.
local PlayerNames = self:GetPlayerNames()
@@ -1589,31 +1567,13 @@ function TASK:ReportDetails( ReportGroup )
for TaskInfoID, TaskInfo in pairs( self.TaskInfo, function( t, a, b ) return t[a].TaskInfoOrder < t[b].TaskInfoOrder end ) do
local TaskInfoIDText = string.format( " - %s: ", TaskInfoID )
if type( TaskInfo.TaskInfoText ) == "string" then
Report:Add( TaskInfoIDText .. TaskInfo.TaskInfoText )
elseif type(TaskInfo) == "table" then
if TaskInfoID == "Coordinates" then
local FromCoordinate = ReportGroup:GetUnit(1):GetCoordinate()
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
Report:Add( TaskInfoIDText .. ToCoordinate:ToString( ReportGroup:GetUnit(1), nil, self ) )
else
end
local ReportText = self:GetReportDetail( ReportGroup, TaskInfoID, TaskInfo )
if ReportText then
Report:Add( ReportText )
end
end
local Coordinate = self:GetInfo( "Coordinates" ) -- Core.Point#COORDINATE
local Velocity = self.TargetSetUnit:GetVelocity()
local Heading = self.TargetSetUnit:GetHeading()
Coordinate:SetHeading( Heading )
Coordinate:SetVelocity( Velocity )
Report:Add( "Targets are" .. Coordinate:GetMovingText() .. "." )
return Report:Text()
end

View File

@@ -103,7 +103,7 @@ do -- TASK_ZONE_GOAL
self:__RouteTo( 0.1 )
end
end
return self
end
@@ -156,6 +156,33 @@ do -- TASK_ZONE_GOAL
return self.GoalTotal
end
function TASK_ZONE_GOAL:GetMarkInfo( TaskInfoID, TaskInfo )
if type( TaskInfo.TaskInfoText ) == "string" then
return string.format( "%s: %s", TaskInfoID, TaskInfo.TaskInfoText )
elseif type( TaskInfo ) == "table" then
if TaskInfoID == "Coordinate" then
end
end
return nil
end
function TASK_ZONE_GOAL:GetReportDetail( ReportGroup, TaskInfoID, TaskInfo )
if type( TaskInfo.TaskInfoText ) == "string" then
return string.format( " - %s: %s", TaskInfoID, TaskInfo.TaskInfoText )
elseif type(TaskInfo) == "table" then
if TaskInfoID == "Coordinate" then
local FromCoordinate = ReportGroup:GetUnit(1):GetCoordinate()
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
return string.format( " - %s: %s", TaskInfoID, ToCoordinate:ToString( ReportGroup:GetUnit(1), nil, self ) )
else
end
end
end
end
@@ -163,7 +190,7 @@ do -- TASK_ZONE_CAPTURE
--- The TASK_ZONE_CAPTURE class
-- @type TASK_ZONE_CAPTURE
-- @field Set#SET_UNIT TargetSetUnit
-- @field Core.ZoneGoalCoalition#ZONE_GOAL_COALITION ZoneGoal
-- @extends #TASK_ZONE_GOAL
--- # TASK_ZONE_CAPTURE class, extends @{TaskZoneGoal#TASK_ZONE_GOAL}
@@ -201,7 +228,7 @@ do -- TASK_ZONE_CAPTURE
self:SetBriefing(
TaskBriefing or
"Capture zone " .. self.TaskZoneName .. "."
"Capture Zone " .. self.TaskZoneName
)
self:UpdateTaskInfo()
@@ -215,13 +242,13 @@ do -- TASK_ZONE_CAPTURE
local ZoneCoordinate = self.ZoneGoal:GetZone():GetCoordinate()
self:SetInfo( "Coordinates", ZoneCoordinate, 0 )
self:SetInfo( "Zone Name", self.TaskZoneName, 10 )
self:SetInfo( "Zone Coalition", self.TaskCoalitionName, 11 )
self:SetInfo( "Coordinate", ZoneCoordinate, 0 )
self:SetInfo( "Zone Name", self.ZoneGoal:GetZoneName(), 10 )
self:SetInfo( "Zone Coalition", self.ZoneGoal:GetCoalitionName(), 11 )
end
function TASK_ZONE_CAPTURE:ReportOrder( ReportGroup )
local Coordinate = self:GetInfo( "Coordinates" )
local Coordinate = self:GetInfo( "Coordinate" )
--local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )

View File

@@ -277,6 +277,35 @@ do -- TASK_A2A
return self.GoalTotal
end
function TASK_A2A:GetMarkInfo( TaskInfoID, TaskInfo )
if type( TaskInfo.TaskInfoText ) == "string" then
if TaskInfoID == "Targets" then
else
return string.format( "%s: %s", TaskInfoID, TaskInfo.TaskInfoText )
end
elseif type( TaskInfo ) == "table" then
if TaskInfoID == "Coordinate" then
end
end
return nil
end
function TASK_A2A:GetReportDetail( ReportGroup, TaskInfoID, TaskInfo )
if type( TaskInfo.TaskInfoText ) == "string" then
return string.format( "%s: %s", TaskInfoID, TaskInfo.TaskInfoText )
elseif type(TaskInfo) == "table" then
if TaskInfoID == "Coordinate" then
local FromCoordinate = ReportGroup:GetUnit(1):GetCoordinate()
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
return string.format( " - %s: %s", TaskInfoID, ToCoordinate:ToString( ReportGroup:GetUnit(1), nil, self ) )
else
end
end
end
end
@@ -336,7 +365,7 @@ do -- TASK_A2A_INTERCEPT
function TASK_A2A_INTERCEPT:UpdateTaskInfo()
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
self:SetInfo( "Coordinate", TargetCoordinate, 0 )
self:SetInfo( "Threat", "[" .. string.rep( "", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
@@ -492,7 +521,7 @@ do -- TASK_A2A_SWEEP
function TASK_A2A_SWEEP:UpdateTaskInfo()
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
self:SetInfo( "Coordinate", TargetCoordinate, 0 )
self:SetInfo( "Assumed Threat", "[" .. string.rep( "", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
@@ -641,7 +670,7 @@ do -- TASK_A2A_ENGAGE
function TASK_A2A_ENGAGE:UpdateTaskInfo()
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
self:SetInfo( "Coordinate", TargetCoordinate, 0 )
self:SetInfo( "Threat", "[" .. string.rep( "", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )

View File

@@ -285,6 +285,36 @@ do -- TASK_A2G
return self.GoalTotal
end
function TASK_A2G:GetMarkInfo( TaskInfoID, TaskInfo )
if type( TaskInfo.TaskInfoText ) == "string" then
if TaskInfoID == "Targets" then
else
return string.format( "%s: %s", TaskInfoID, TaskInfo.TaskInfoText )
end
elseif type( TaskInfo ) == "table" then
if TaskInfoID == "Coordinate" then
end
end
return nil
end
function TASK_A2G:GetReportDetail( ReportGroup, TaskInfoID, TaskInfo )
if type( TaskInfo.TaskInfoText ) == "string" then
return string.format( "%s: %s", TaskInfoID, TaskInfo.TaskInfoText )
elseif type(TaskInfo) == "table" then
if TaskInfoID == "Coordinate" then
local FromCoordinate = ReportGroup:GetUnit(1):GetCoordinate()
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
return string.format( " - %s: %s", TaskInfoID, ToCoordinate:ToString( ReportGroup:GetUnit(1), nil, self ) )
else
end
end
end
end
@@ -335,7 +365,7 @@ do -- TASK_A2G_SEAD
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
self:SetInfo( "Coordinate", TargetCoordinate, 0 )
local ThreatLevel, ThreatText
if self.Detection then
@@ -366,7 +396,7 @@ do -- TASK_A2G_SEAD
end
function TASK_A2G_SEAD:ReportOrder( ReportGroup )
local Coordinate = self:GetInfo( "Coordinates" )
local Coordinate = self:GetInfo( "Coordinate" )
--local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
@@ -484,7 +514,7 @@ do -- TASK_A2G_BAI
self:E({self.Detection, self.DetectedItemIndex})
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
self:SetInfo( "Coordinate", TargetCoordinate, 0 )
local ThreatLevel, ThreatText
if self.Detection then
@@ -512,11 +542,21 @@ do -- TASK_A2G_BAI
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
end
local TargetCoordinate = self:GetInfo( "Coordinate" ) -- Core.Point#COORDINATE
local Velocity = self.TargetSetUnit:GetVelocity()
local Heading = self.TargetSetUnit:GetHeading()
TargetCoordinate:SetHeading( Heading )
TargetCoordinate:SetVelocity( Velocity )
self:SetInfo( "Position", "Targets are" .. TargetCoordinate:GetMovingText() .. ".", 12 )
end
function TASK_A2G_BAI:ReportOrder( ReportGroup )
local Coordinate = self:GetInfo( "Coordinates" )
local Coordinate = self:GetInfo( "Coordinate" )
--local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
@@ -633,7 +673,7 @@ do -- TASK_A2G_CAS
function TASK_A2G_CAS:UpdateTaskInfo()
local TargetCoordinate = ( self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) ) or self.TargetSetUnit:GetFirst():GetCoordinate()
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
self:SetInfo( "Coordinate", TargetCoordinate, 0 )
local ThreatLevel, ThreatText
if self.Detection then
@@ -666,7 +706,7 @@ do -- TASK_A2G_CAS
--- @param #TASK_A2G_CAS self
function TASK_A2G_CAS:ReportOrder( ReportGroup )
local Coordinate = self:GetInfo( "Coordinates" )
local Coordinate = self:GetInfo( "Coordinate" )
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
return Distance

View File

@@ -1,299 +0,0 @@
--- **Tasking** - The TASK_Protect models tasks for players to protect or capture specific zones.
--
-- ====
--
-- ### Author: **Sven Van de Velde (FlightControl)**
--
-- ### Contributions: MillerTime
--
-- ====
--
-- @module Task_Protect
do -- TASK_PROTECT
--- The TASK_PROTECT class
-- @type TASK_PROTECT
-- @field Functional.Protect#PROTECT Protect
-- @extends Tasking.Task#TASK
--- # TASK_PROTECT class, extends @{Task#TASK}
--
-- The TASK_PROTECT class defines the task to protect or capture a protection zone.
-- The TASK_PROTECT is implemented using a @{Fsm#FSM_TASK}, and has the following statuses:
--
-- * **None**: Start of the process
-- * **Planned**: The A2G task is planned.
-- * **Assigned**: The A2G task is assigned to a @{Group#GROUP}.
-- * **Success**: The A2G task is successfully completed.
-- * **Failed**: The A2G task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
--
-- ## Set the scoring of achievements in an A2G attack.
--
-- Scoring or penalties can be given in the following circumstances:
--
-- * @{#TASK_PROTECT.SetScoreOnDestroy}(): Set a score when a target in scope of the A2G attack, has been destroyed.
-- * @{#TASK_PROTECT.SetScoreOnSuccess}(): Set a score when all the targets in scope of the A2G attack, have been destroyed.
-- * @{#TASK_PROTECT.SetPenaltyOnFailed}(): Set a penalty when the A2G attack has failed.
--
-- @field #TASK_PROTECT
TASK_PROTECT = {
ClassName = "TASK_PROTECT",
}
--- Instantiates a new TASK_PROTECT.
-- @param #TASK_PROTECT self
-- @param Tasking.Mission#MISSION Mission
-- @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 Functional.Protect#PROTECT Protect
-- @return #TASK_PROTECT self
function TASK_PROTECT:New( Mission, SetGroup, TaskName, Protect, TaskType, TaskBriefing )
local self = BASE:Inherit( self, TASK:New( Mission, SetGroup, TaskName, TaskType, TaskBriefing ) ) -- #TASK_PROTECT
self:F()
self.Protect = Protect
self.TaskType = TaskType
local Fsm = self:GetUnitProcess()
Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "ProtectZone", Rejected = "Reject" } )
Fsm:AddTransition( "Assigned", "ProtectZone", "Protecting" )
Fsm:AddTransition( "Protecting", "Protect", "Protecting", {} )
Fsm:AddTransition( "Protecting", "RouteToTarget", "Protecting" )
Fsm:AddProcess( "Protecting", "RouteToTargetZone", ACT_ROUTE_ZONE:New(), {} )
--Fsm:AddTransition( "Accounted", "DestroyedAll", "Accounted" )
--Fsm:AddTransition( "Accounted", "Success", "Success" )
Fsm:AddTransition( "Rejected", "Reject", "Aborted" )
Fsm:AddTransition( "Failed", "Fail", "Failed" )
self:SetTargetZone( self.Protect:GetProtectZone() )
--- Test
-- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task#TASK_PROTECT Task
function Fsm:onafterProtectZone( TaskUnit, Task )
self:E( { self } )
self:__Protect( 0.1 )
self:__RouteToTarget( 0.1 )
end
--- Protect Loop
-- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task#TASK_PROTECT Task
function Fsm:onafterProtect( TaskUnit, Task )
self:E( { self } )
self:__Protect( 15 )
end
--- Test
-- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_A2G#TASK_PROTECT Task
function Fsm:onafterRouteToTarget( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
-- Determine the first Unit from the self.TargetSetUnit
if Task:GetTargetZone( TaskUnit ) then
self:__RouteToTargetZone( 0.1 )
end
end
return self
end
--- @param #TASK_PROTECT self
-- @param Functional.Protect#PROTECT Protect The Protect Engine.
function TASK_PROTECT:SetProtect( Protect )
self.Protect = Protect -- Functional.Protect#PROTECT
end
--- @param #TASK_PROTECT self
function TASK_PROTECT:GetPlannedMenuText()
return self:GetStateString() .. " - " .. self:GetTaskName() .. " ( " .. self.Protect:GetProtectZoneName() .. " )"
end
--- @param #TASK_PROTECT self
-- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map.
-- @param Wrapper.Unit#UNIT TaskUnit
function TASK_PROTECT:SetTargetZone( TargetZone, TaskUnit )
local ProcessUnit = self:GetUnitProcess( TaskUnit )
local ActRouteProtectZone = ProcessUnit:GetProcess( "Protecting", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE
ActRouteProtectZone:SetZone( TargetZone )
end
--- @param #TASK_PROTECT self
-- @param Wrapper.Unit#UNIT TaskUnit
-- @return Core.Zone#ZONE_BASE The Zone object where the Target is located on the map.
function TASK_PROTECT:GetTargetZone( TaskUnit )
local ProcessUnit = self:GetUnitProcess( TaskUnit )
local ActRouteProtectZone = ProcessUnit:GetProcess( "Protecting", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE
return ActRouteProtectZone:GetZone()
end
function TASK_PROTECT:SetGoalTotal()
self.GoalTotal = 1
end
function TASK_PROTECT:GetGoalTotal()
return self.GoalTotal
end
end
do -- TASK_CAPTURE_ZONE
--- The TASK_CAPTURE_ZONE class
-- @type TASK_CAPTURE_ZONE
-- @field Set#SET_UNIT TargetSetUnit
-- @extends Tasking.Task_Protect#TASK_PROTECT
--- # TASK_CAPTURE_ZONE class, extends @{Task_A2G#TASK_PROTECT}
--
-- The TASK_CAPTURE_ZONE class defines an Suppression or Extermination of Air Defenses task for a human player to be executed.
-- These tasks are important to be executed as they will help to achieve air superiority at the vicinity.
--
-- The TASK_CAPTURE_ZONE is used by the @{Task_A2G_Dispatcher#TASK_A2G_DISPATCHER} to automatically create SEAD tasks
-- based on detected enemy ground targets.
--
-- @field #TASK_CAPTURE_ZONE
TASK_CAPTURE_ZONE = {
ClassName = "TASK_CAPTURE_ZONE",
}
--- Instantiates a new TASK_CAPTURE_ZONE.
-- @param #TASK_CAPTURE_ZONE self
-- @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 Functional.Protect#PROTECT Protect
-- @param #string TaskBriefing The briefing of the task.
-- @return #TASK_CAPTURE_ZONE self
function TASK_CAPTURE_ZONE:New( Mission, SetGroup, TaskName, Protect, TaskBriefing)
local self = BASE:Inherit( self, TASK_PROTECT:New( Mission, SetGroup, TaskName, Protect, "CAPTURE", TaskBriefing ) ) -- #TASK_CAPTURE_ZONE
self:F()
Mission:AddTask( self )
self.TaskCoalition = Protect:GetCoalition()
self.TaskCoalitionName = Protect:GetCoalitionName()
self.TaskZoneName = self.Protect:GetProtectZoneName()
self:SetBriefing(
TaskBriefing or
"Capture zone " .. self.TaskZoneName .. "."
)
self:UpdateTaskInfo()
return self
end
--- Instantiates a new TASK_CAPTURE_ZONE.
-- @param #TASK_CAPTURE_ZONE self
function TASK_CAPTURE_ZONE:UpdateTaskInfo()
local ZoneCoordinate = self.Protect:GetProtectZone():GetCoordinate()
self:SetInfo( "Coordinates", ZoneCoordinate, 0 )
self:SetInfo( "Zone Name", self.TaskZoneName, 10 )
self:SetInfo( "Zone Coalition", self.TaskCoalitionName, 11 )
end
function TASK_CAPTURE_ZONE:ReportOrder( ReportGroup )
local Coordinate = self:GetInfo( "Coordinates" )
--local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
return Distance
end
--- @param #TASK_CAPTURE_ZONE self
-- @param Wrapper.Unit#UNIT TaskUnit
function TASK_CAPTURE_ZONE:OnAfterGoal( From, Event, To, PlayerUnit, PlayerName )
self:E( { PlayerUnit = PlayerUnit } )
if self.Protect then
local ProtectCoalition = self.Protect:GetCoalition()
local TaskCoalition = self.Coalition
self:E( { ProtectCoalition = ProtectCoalition, TaskCoalition = TaskCoalition } )
if ProtectCoalition ~= TaskCoalition then
self:Success()
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", "Protect", "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