Task Tutorial – Arma 2

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[ *Armed Assault *\]\]" to "{{arma1}}")
m (Text replacement - "{{arma2}}" to "{{GameCategory|arma2|link= y}}")
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:
== Basics ==
== Basics ==


Tasks were introduced in [[{{arma2}}]] and improved in [[Arma 3: Task Framework|Arma 3]]. They replaced the [[Briefing.html|old objective system]] used in [[:Category:ArmA: Armed Assault|{{arma1}}]] and [[:Category:Operation Flashpoint|{{ofp}}]].
Tasks were introduced in {{GameCategory|arma2|link= y}} and improved in [[Arma 3: Task Framework|Arma 3]]. They replaced the [[Briefing.html|old objective system]] used in [[:Category:ArmA: Armed Assault|{{arma1}}]] and [[:Category:Operation Flashpoint|{{ofp}}]].




Line 23: Line 23:
| "Assigned"
| "Assigned"
| ''grey'' - The task is the current one
| ''grey'' - The task is the current one
| rowspan="6" | [[Image:Taskstates.png|Task States]]
| rowspan="6" | [[File:Taskstates.png|Task States]]
|-
|-
| "Canceled"
| "Canceled"
Line 57: Line 57:
=== Create a task ===
=== Create a task ===


[[private]] <span style="color: purple; font-weight: bold">_myTask</span> = [[player]] [[createSimpleTask]] ["taskName1"];
<sqf>private _myTask = player createSimpleTask ["taskName1"];</sqf>


=== Set a task's description ===
=== Set a task's description ===


[[private]] _title = "Get the documents";
<sqf>
[[private]] _description = "Enter the house to find the documents. Hurry, as the enemy is on its way.";
private _title = "Get the documents";
[[private]] _waypoint = "House";
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];
 
_myTask setSimpleTaskDescription [_description, _title, _waypoint];
</sqf>


=== Assign a task ===
=== Assign a task ===


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


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


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


=== Set a task's state ===
=== Set a task's state ===


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


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


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




Line 91: Line 97:
=== Get a task's state ===
=== Get a task's state ===


[[taskState]] <span style="color: purple; font-weight: bold">_myTask</span>;
<sqf>taskState _myTask;</sqf>


=== Get a task's description ===
=== Get a task's description ===


[[taskDescription]] <span style="color: purple; font-weight: bold">_myTask</span>;
<sqf>taskDescription _myTask;</sqf>


=== Get a task's destination ===
=== Get a task's destination ===


[[taskDestination]] <span style="color: purple; font-weight: bold">_myTask</span>;
<sqf>taskDestination _myTask;</sqf>





Latest revision as of 13:01, 19 March 2024

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


How to read a task's information

Get a task's state

taskState _myTask;

Get a task's description

Get a task's destination


See also