Task Tutorial – Arma 2

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Lou Montana moved page Tasks to Arma 2:Task Tutorial: I wanted to)
(Page refresh)
Line 1: Line 1:
{{Feature arma3|In Arma 3 version 1.58 task system was greatly enhanced. To name few improvements:
{{SideTOC}}
* improved 2D & 3D visualization
== Basics ==
* improved UX (user experience)
* new features - e.g. shared objectives, task overview, always visible tasks, task types, ...


Check [[Arma 3 Tasks Overhaul]] page for more information.}}
Tasks were introduced in [[ArmA 2]] and improved in [[Arma 3 Task Framework|Arma 3]]. They replaced the [[Briefing.html|old objective system]] used in [[Armed Assault]] and [[Operation Flashpoint]].


{{Important|Using the '''[[Arma 3 Task Framework]]''' instead is recommended}}
<div style="float: right;">__TOC__</div>


== Description ==
{{Feature arma3 | For '''{{arma3}}'''<nowiki/>'s Task Tutorial, see [[Arma 3 Task Framework Tutorial]].}}
Tasks were introduced in [[ArmA 2]] and improved in [[Arma 3 Tasks Overhaul|Arma 3]]. They replaced the [[Briefing.html|old objective system]] used in [[Armed Assault]] and [[Operation Flashpoint]].


== Basics ==


=== Creation ===
As opposed to the previous system:
Tasks can be created at any time from anywhere (trigger, script, etc). They do not need to be created in an external file.
* Tasks can be created at any time from anywhere (trigger, script, etc). They do not need to be created in an external file.
* Tasks are created "on the fly" as they are required and not "hidden/shown" anymore.


=== Hiding ===
=== States ===
As opposite to the old method of showing and hiding objectives, tasks are instead created "on the fly" as they are required.


=== State ===
Task states are in [[String]] format.
Task state is in [[String]] format.
The possible state of a task is one of these:
* "Assigned"
* "Canceled"
* "Created"
* "Failed"
* "Succeeded"


=== Icon / Color ===
{| class="bikitable"
'''Arma 2'''
! Value
[[Image:Taskstates.png|left|Task States]]
! Description
* Assigned: gray
! Display
* Canceled: one gray diagonal line
|-
* Created: black (empty)
| "Assigned"
* Failed: red X
| ''grey'' - The task is the current one
* Succeeded: green
| rowspan="6" | [[Image:Taskstates.png|Task States]]
|-
| "Canceled"
| ''grey diagonal line'' - The task has been cancelled
|-
| "Created"
| ''black empty'' - The task exists, is available but isn't the current one
|-
| "Failed"
| ''red crossed'' - The task was failed
|-
| "Succeeded"
| ''green'' - The task was succeeded
|-
| "None"
| ''?''
|}




== Good To Know ==
== Good To Know ==


=== Creation ===
Tasks are unit-specific. They are created to a ''unit'' and not to a ''client'' (computer).
Tasks are unit ([[object]]) specific. They are created to a unit and not to a client (human player). The effect is local and should be executed on every client.
For example if you create a task for the [[player]] unit then [[teamSwitch]] to another unit, this new unit won't have any task.
If you switch back to the original unit, it will have this created task.
 
{{Important | Task creation is '''local''' and should be executed on every client that needs it, such as every client that ''could'' access the unit.}}
 
The value returned by [[createSimpleTask]] is a unique handle to the unit's task, returns a handle (variable which refers to the created task). Each task has a unique handle. Even using same line of code on different client will result in a different handle for the "same" task.
 
 
== How to use a task ==
 
=== Create a task ===


For example:
[[private]] <span style="color: purple; font-weight: bold">_myTask</span> = [[player]] [[createSimpleTask]] ["taskName1"];
You start mission in a unit which is named "unit1". The briefing creates following task:
task1 = unit1 [[createSimpleTask]] ["taskName1"];


Now, if you [[teamSwitch]] to another unit, he will not have the task. This is common with the usual "task = player createsimpletask" type of creation as the task will only be created to the unit [[player]] is referring to.
=== Set a task's description ===


=== Return Variable / Handle ===
[[private]] _title = "Get the documents";
Command [[createSimpleTask]] returns a handle (variable which refers to the created task). Each task has a unique handle. Even using same line of code on different client will result in a different handle for the "same" task.
[[private]] _description = "Enter the house to find the documents. Hurry, as the enemy is on its way.";
[[private]] _waypoint = "House";
<span style="color: purple; font-weight: bold">_myTask</span> [[setSimpleTaskDescription]] [_description, _title, _waypoint];


=== Assign a task ===


== Examples ==
<span style="color: purple; font-weight: bold">_myTask</span> [[setTaskState]] "Assigned";
[[player]] [[setCurrentTask]] <span style="color: purple; font-weight: bold">_myTask</span>;


=== Creation ===
=== Set a task's destination ===


==== Simplest ====
<span style="color: purple; font-weight: bold">_myTask</span> [[setSimpleTaskDestination]] [[getPosATL]] objDocuments; {{cc|a position}}
  task1 = [[player]] [[createSimpleTask]] ["taskName1"];
{{cc|or}}
  <span style="color: purple; font-weight: bold">_myTask</span> [[setSimpleTaskTarget]] [objDocuments, [[true]]]; {{cc|an object - Arma 2 OA v 1.55}}


==== Common ====
=== Set a task's state ===
task1 = [[player]] [[createSimpleTask]] ["taskName1"];
task1 [[setSimpleTaskDescription]] ["To be successful in this example task you need to...","Example Task",""];


==== Advanced ====
  <span style="color: purple; font-weight: bold">_myTask</span> [[setTaskState]] "Succeeded";
  task1 = [[player]] [[createSimpleTask]] ["taskName1"];
task1 [[setSimpleTaskDescription]] ["To be successful in this example task you need to...","Example Task",""];
task1 [[setTaskState]] "Assigned";
player [[setCurrentTask]] task1;


=== Update ===
=== Delete a task ===


==== Simplest ====
  [[player]] [[removeSimpleTask]] <span style="color: purple; font-weight: bold">_myTask</span>;
  task1 [[setTaskState]] "Succeeded";


==== Common ====
task1 [[setTaskState]] "Succeeded";
task2 [[setTaskState]] "Assigned";
player [[setCurrentTask]] task2;


==== Advanced ====
== How to read a task's information ==
  task1 [[setTaskState]] "Succeeded";
 
  task2 = [[player]] [[createSimpleTask]] ["taskName2"];
=== Get a task's state ===
task2 [[setSimpleTaskDescription]] ["Another task has been issued...","Another Example Task",""];
 
  task2 [[setTaskState]] "Assigned";
  [[taskState]] <span style="color: purple; font-weight: bold">_myTask</span>;
player [[setCurrentTask]] task2;
 
=== Get a task's description ===
 
  [[taskDescription]] <span style="color: purple; font-weight: bold">_myTask</span>;
 
=== Get a task's destination ===
 
  [[taskDestination]] <span style="color: purple; font-weight: bold">_myTask</span>;




== See also ==
== See also ==
[[briefing]], [[Arma 3 Tasks Overhaul]]


[[Category: Arma 2: Editing]]
* [[Arma 3 Task Framework]]
* [[Arma 3 Task Framework Tutorial]]
* [[:Category:Function_Group:_Tasks|Tasks Functions]]
* [[:Category:Command Group: Briefing|Briefing Commands]]
* [[briefing]]
 
 
[[Category: Scripting Topics]]
[[Category: ArmA 2: Editing]]

Revision as of 21:58, 9 September 2019

Template:SideTOC

Basics

Tasks were introduced in ArmA 2 and improved in Arma 3. They replaced the old objective system used in Armed Assault and Operation Flashpoint.


Arma 3
For Arma 3's Task Tutorial, see Arma 3 Task Framework Tutorial.


As opposed to the previous system:

  • Tasks can be created at any time from anywhere (trigger, script, etc). They do not need to be created in an external file.
  • Tasks are created "on the fly" as they are required and not "hidden/shown" anymore.

States

Task states are in String format.

Value Description Display
"Assigned" grey - The task is the current one Task States
"Canceled" grey diagonal line - The task has been cancelled
"Created" black empty - The task exists, is available but isn't the current one
"Failed" red crossed - The task was failed
"Succeeded" green - The task was succeeded
"None" ?


Good To Know

Tasks are unit-specific. They are created to a unit and not to a client (computer). For example if you create a task for the player unit then teamSwitch to another unit, this new unit won't have any task. If you switch back to the original unit, it will have this created task.

Task creation is local and should be executed on every client that needs it, such as every client that could access the unit.

The value returned by createSimpleTask is a unique handle to the unit's task, returns a handle (variable which refers to the created task). Each task has a unique handle. Even using same line of code on different client will result in a different handle for the "same" task.


How to use a task

Create a task

private _myTask = player createSimpleTask ["taskName1"];

Set a task's description

private _title = "Get the documents";
private _description = "Enter the house to find the documents. Hurry, as the enemy is on its way.";
private _waypoint = "House";

_myTask setSimpleTaskDescription [_description, _title, _waypoint];

Assign a task

_myTask setTaskState "Assigned";
player setCurrentTask _myTask;

Set a task's destination

_myTask setSimpleTaskDestination getPosATL objDocuments;	// a position
// or
_myTask setSimpleTaskTarget [objDocuments, true];			// an object - Arma 2 OA v 1.55

Set a task's state

_myTask setTaskState "Succeeded";

Delete a task

player removeSimpleTask _myTask;


How to read a task's information

Get a task's state

taskState _myTask;

Get a task's description

taskDescription _myTask;

Get a task's destination

taskDestination _myTask;


See also