Module Task

This module contains the TASK_BASE class.

1) #TASK_BASE class, extends Base#BASE

1.1) The #TASK_BASE class implements the methods for task orchestration within MOOSE.

The class provides a couple of methods to:

1.2) Set and enquire task status (beyond the task state machine processing).

A task needs to implement as a minimum the following task states:

  • Success: Expresses the successful execution and finalization of the task.
  • Failed: Expresses the failure of a task.
  • Planned: Expresses that the task is created, but not yet in execution and is not assigned yet.
  • Assigned: Expresses that the task is assigned to a Group of players, and that the task is in execution mode.

A task may also implement the following task states:

  • Rejected: Expresses that the task is rejected by a player, who was requested to accept the task.
  • Cancelled: Expresses that the task is cancelled by HQ or through a logical situation where a cancellation of the task is required.

A task can implement more statusses than the ones outlined above. Please consult the documentation of the specific tasks to understand the different status modelled.

The status of tasks can be set by the methods State followed by the task status. An example is StateAssigned(). The status of tasks can be enquired by the methods IsState followed by the task status name. An example is if IsStateAssigned() then.

1.3) Add scoring when reaching a certain task status:

Upon reaching a certain task status in a task, additional scoring can be given. If the Mission has a scoring system attached, the scores will be added to the mission scoring. Use the method TASK_BASE.AddScore() to add scores when a status is reached.

1.4) Task briefing:

A task briefing can be given that is shown to the player when he is assigned to the task.


Authors: FlightControl - Design and Programming

Global(s)

TASK_BASE

Type TASK_BASE

TASK_BASE:AddProcess(TaskUnit, Process)

Add Process to Task with key Unit.

TASK_BASE:AddScore(TaskStatus, ScoreText, Score)

Adds a score for the TASK to be achieved.

TASK_BASE:AddStateMachine(TaskUnit, Fsm)

Add a FiniteStateMachine to Task with key Unit

TASK_BASE:AssignToGroup(TaskGroup)

Assign the Taskto a Group.

TASK_BASE:AssignToUnit(TaskUnit)

Assign the Taskto an alive Unit.

TASK_BASE.ClassName
TASK_BASE:CleanUp()

Cleans all references of a TASK_BASE.

TASK_BASE:FailProcesses(TaskUnitName)

Fail processes from Task with key Unit

TASK_BASE.Fsm
TASK_BASE:GetCategory()

Gets the Category of the Task

TASK_BASE:GetID()

Gets the ID of the Task

TASK_BASE:GetName()

Gets the Name of the Task

TASK_BASE:GetScoring()

Gets the Scoring of the task

TASK_BASE:GetStateString()

Gets the Task status.

TASK_BASE:GetTaskIndex()

Gets the Task Index, which is a combination of the Task category, the Task type, the Task name.

TASK_BASE:GetTaskName()

Returns the Task name.

TASK_BASE:GetType()

Gets the Type of the Task

TASK_BASE:HasStateMachine(TaskUnitName)

Checks if there is a FiniteStateMachine assigned to Unit for Task

TASK_BASE:IsAssignedToGroup(TaskGroup)

Returns if the Task is assigned to the Group.

TASK_BASE:IsStateAssigned()

Is the Task status Assigned.

TASK_BASE:IsStateFailed()

Is the Task status Failed.

TASK_BASE:IsStateHold()

Is the Task status Hold.

TASK_BASE:IsStatePlanned()

Is the Task status Planned.

TASK_BASE:IsStateReplanned()

Is the Task status Replanned.

TASK_BASE:IsStateSuccess()

Is the Task status Success.

TASK_BASE.Menu
TASK_BASE.MenuAbort
TASK_BASE.MenuAssignToGroup(MenuParam)
TASK_BASE.MenuStatus
TASK_BASE.MenuTaskAbort(MenuParam)
TASK_BASE.MenuTaskStatus(MenuParam)
TASK_BASE.Mission
TASK_BASE:New(The, SetGroup, TaskName, TaskType, TaskCategory, Mission)

Instantiates a new TASK_BASE.

TASK_BASE:OnAssigned(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

TASK_BASE:OnFailed(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

TASK_BASE:OnStateChange(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

TASK_BASE:OnSuccess(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

TASK_BASE.Players
TASK_BASE.Processes
TASK_BASE:RemoveMenu()

Remove the menu options of the Task to all the groups in the SetGroup.

TASK_BASE:RemoveMenuForGroup(TaskGroup)

Remove the menu option of the Task for a Group.

TASK_BASE:RemoveProcesses(TaskUnitName)

Remove Processes from Task with key Unit

TASK_BASE:RemoveStateMachines(TaskUnitName)

Remove FiniteStateMachines from Task with key Unit

TASK_BASE.Scores
TASK_BASE:SendBriefingToAssignedGroups()

Send the briefng message of the Task to the assigned Groups.

TASK_BASE:SetAssignedMenu()

Set the menu options of the Task to all the groups in the SetGroup.

TASK_BASE:SetAssignedMenuForGroup(TaskGroup)

Set the assigned menu options of the Task.

TASK_BASE:SetBriefing(TaskBriefing)

Sets a Task briefing.

TASK_BASE:SetCategory(TaskCategory)

Sets the Category of the Task

TASK_BASE.SetGroup

The Set of Groups assigned to the Task

TASK_BASE:SetID(TaskID)

Sets the ID of the Task

TASK_BASE:SetName(TaskName)

Sets the Name of the Task

TASK_BASE:SetPlannedMenu()

Set the menu options of the Task to all the groups in the SetGroup.

TASK_BASE:SetPlannedMenuForGroup(TaskGroup, MenuText)

Set the planned menu option of the Task.

TASK_BASE:SetType(TaskType)

Sets the Type of the Task

TASK_BASE:StateAssigned()

Sets a Task to status Assigned.

TASK_BASE:StateFailed()

Sets a Task to status Failed.

TASK_BASE:StateHold()

Sets a Task to status Hold.

TASK_BASE:StatePlanned()

Sets a Task to status Planned.

TASK_BASE:StateReplanned()

Sets a Task to status Replanned.

TASK_BASE:StateSuccess()

Sets a Task to status Success.

TASK_BASE.TaskBriefing
TASK_BASE.TaskCategory
TASK_BASE.TaskID
TASK_BASE.TaskName
TASK_BASE.TaskScheduler
TASK_BASE.TaskType
TASK_BASE:UnAssignFromGroups()

Assign the Task from the Groups.

TASK_BASE:UnAssignFromUnit(TaskUnit, TaskUnitName)

UnAssign the Task from an alive Unit.

TASK_BASE:_EventAssignUnit(Event)

Register a potential new assignment for a new spawned Unit.

TASK_BASE:_EventDead(Event)

UnAssigns a Unit that is left by a player, crashed, dead, ....

TASK_BASE:_EventPlayerLeaveUnit(Event)

Catches the "player leave unit" event for a Unit ....

TASK_BASE:_Schedule()
TASK_BASE:_Scheduler()

Global(s)

#TASK_BASE TASK_BASE

Type Task

Type TASK_BASE

The TASK_BASE class

Field(s)

TASK_BASE:AddProcess(TaskUnit, Process)

Add Process to Task with key Unit.

Parameters

Return value

#TASK_BASE: self

TASK_BASE:AddScore(TaskStatus, ScoreText, Score)

Adds a score for the TASK to be achieved.

Parameters

  • #string TaskStatus : is the status of the TASK when the score needs to be given.

  • #string ScoreText : is a text describing the score that is given according the status.

  • #number Score : is a number providing the score of the status.

Return value

#TASK_BASE: self

TASK_BASE:AddStateMachine(TaskUnit, Fsm)

Add a FiniteStateMachine to Task with key Unit

Parameters

Return value

#TASK_BASE: self

TASK_BASE:AssignToGroup(TaskGroup)

Assign the Taskto a Group.

Parameter

TASK_BASE:AssignToUnit(TaskUnit)

Assign the Taskto an alive Unit.

Parameter

Return value

#TASK_BASE: self

#string TASK_BASE.ClassName
TASK_BASE:CleanUp()

Cleans all references of a TASK_BASE.

Return value

#nil:

TASK_BASE:FailProcesses(TaskUnitName)

Fail processes from Task with key Unit

Parameter

  • #string TaskUnitName :

Return value

#TASK_BASE: self

StateMachine#STATEMACHINE TASK_BASE.Fsm
TASK_BASE:GetCategory()

Gets the Category of the Task

Return value

#string: TaskCategory

TASK_BASE:GetID()

Gets the ID of the Task

Return value

#string: TaskID

TASK_BASE:GetName()

Gets the Name of the Task

Return value

#string: The Task Name

TASK_BASE:GetScoring()

Gets the Scoring of the task

Return value

Scoring#SCORING: Scoring

TASK_BASE:GetStateString()

Gets the Task status.

TASK_BASE:GetTaskIndex()

Gets the Task Index, which is a combination of the Task category, the Task type, the Task name.

Return value

#string: The Task ID

TASK_BASE:GetTaskName()

Returns the Task name.

Return value

#string: TaskName

TASK_BASE:GetType()

Gets the Type of the Task

Return value

#string: TaskType

TASK_BASE:HasStateMachine(TaskUnitName)

Checks if there is a FiniteStateMachine assigned to Unit for Task

Parameter

  • #string TaskUnitName :

Return value

#TASK_BASE: self

TASK_BASE:IsAssignedToGroup(TaskGroup)

Returns if the Task is assigned to the Group.

Parameter

Return value

#boolean:

TASK_BASE:IsStateAssigned()

Is the Task status Assigned.

TASK_BASE:IsStateFailed()

Is the Task status Failed.

TASK_BASE:IsStateHold()

Is the Task status Hold.

TASK_BASE:IsStatePlanned()

Is the Task status Planned.

TASK_BASE:IsStateReplanned()

Is the Task status Replanned.

TASK_BASE:IsStateSuccess()

Is the Task status Success.

TASK_BASE.Menu
TASK_BASE.MenuAbort
TASK_BASE.MenuAssignToGroup(MenuParam)

Parameter

  • MenuParam :

TASK_BASE.MenuStatus
TASK_BASE.MenuTaskAbort(MenuParam)

Parameter

  • MenuParam :

TASK_BASE.MenuTaskStatus(MenuParam)

Parameter

  • MenuParam :

Mission#MISSION TASK_BASE.Mission
TASK_BASE:New(The, SetGroup, TaskName, TaskType, TaskCategory, Mission)

Instantiates a new TASK_BASE.

Should never be used. Interface Class.

Parameters

  • Mission#MISSION The : mission wherein the Task is registered.

  • Set#SET_GROUP SetGroup : The set of groups for which the Task can be assigned.

  • #string TaskName : The name of the Task

  • #string TaskType : The type of the Task

  • #string TaskCategory : The category of the Task (A2G, A2A, Transport, ... )

  • Mission :

Return value

#TASK_BASE: self

TASK_BASE:OnAssigned(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

Parameters

TASK_BASE:OnFailed(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

Parameters

TASK_BASE:OnStateChange(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

Parameters

TASK_BASE:OnSuccess(TaskUnit, Fsm, Event, From, To, Event)

StateMachine callback function for a TASK

Parameters

TASK_BASE.Players
TASK_BASE.Processes
TASK_BASE:RemoveMenu()

Remove the menu options of the Task to all the groups in the SetGroup.

Return value

#TASK_BASE: self

TASK_BASE:RemoveMenuForGroup(TaskGroup)

Remove the menu option of the Task for a Group.

Parameter

Return value

#TASK_BASE: self

TASK_BASE:RemoveProcesses(TaskUnitName)

Remove Processes from Task with key Unit

Parameter

  • #string TaskUnitName :

Return value

#TASK_BASE: self

TASK_BASE:RemoveStateMachines(TaskUnitName)

Remove FiniteStateMachines from Task with key Unit

Parameter

  • #string TaskUnitName :

Return value

#TASK_BASE: self

TASK_BASE.Scores
TASK_BASE:SendBriefingToAssignedGroups()

Send the briefng message of the Task to the assigned Groups.

TASK_BASE:SetAssignedMenu()

Set the menu options of the Task to all the groups in the SetGroup.

Return value

#TASK_BASE: self

TASK_BASE:SetAssignedMenuForGroup(TaskGroup)

Set the assigned menu options of the Task.

Parameter

Return value

#TASK_BASE: self

TASK_BASE:SetBriefing(TaskBriefing)

Sets a Task briefing.

Parameter

  • #string TaskBriefing :

Return value

#TASK_BASE: self

TASK_BASE:SetCategory(TaskCategory)

Sets the Category of the Task

Parameter

  • #string TaskCategory :

Set#SET_GROUP TASK_BASE.SetGroup

The Set of Groups assigned to the Task

TASK_BASE:SetID(TaskID)

Sets the ID of the Task

Parameter

  • #string TaskID :

TASK_BASE:SetName(TaskName)

Sets the Name of the Task

Parameter

  • #string TaskName :

TASK_BASE:SetPlannedMenu()

Set the menu options of the Task to all the groups in the SetGroup.

Return value

#TASK_BASE: self

TASK_BASE:SetPlannedMenuForGroup(TaskGroup, MenuText)

Set the planned menu option of the Task.

Parameters

  • Group#GROUP TaskGroup :

  • #string MenuText : The menu text.

Return value

#TASK_BASE: self

TASK_BASE:SetType(TaskType)

Sets the Type of the Task

Parameter

  • #string TaskType :

TASK_BASE:StateAssigned()

Sets a Task to status Assigned.

TASK_BASE:StateFailed()

Sets a Task to status Failed.

TASK_BASE:StateHold()

Sets a Task to status Hold.

TASK_BASE:StatePlanned()

Sets a Task to status Planned.

TASK_BASE:StateReplanned()

Sets a Task to status Replanned.

TASK_BASE:StateSuccess()

Sets a Task to status Success.

TASK_BASE.TaskBriefing
TASK_BASE.TaskCategory
TASK_BASE.TaskID
TASK_BASE.TaskName
Scheduler#SCHEDULER TASK_BASE.TaskScheduler
TASK_BASE.TaskType
TASK_BASE:UnAssignFromGroups()

Assign the Task from the Groups.

TASK_BASE:UnAssignFromUnit(TaskUnit, TaskUnitName)

UnAssign the Task from an alive Unit.

Parameters

Return value

#TASK_BASE: self

TASK_BASE:_EventAssignUnit(Event)

Register a potential new assignment for a new spawned Unit.

Tasks only get assigned if there are players in it.

Parameter

Return value

#TASK_BASE: self

TASK_BASE:_EventDead(Event)

UnAssigns a Unit that is left by a player, crashed, dead, ....

There are only assignments if there are players in it.

Parameter

Return value

#TASK_BASE: self

TASK_BASE:_EventPlayerLeaveUnit(Event)

Catches the "player leave unit" event for a Unit ....

When a player is an air unit, and leaves the unit:

  • and he is not at an airbase runway on the ground, he will fail its task.
  • and he is on an airbase and on the ground, the process for him will just continue to work, he can switch airplanes, and take-off again. This is important to model the change from plane types for a player during mission assignment.

Parameter

Return value

#TASK_BASE: self

TASK_BASE:_Schedule()
TASK_BASE:_Scheduler()