Task Framework Tutorial – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
Line 13: Line 13:
=== Create a task ===
=== Create a task ===


[[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";
[[private]] _myTask = [groupOfPlayers, <span style="color: purple; font-weight: bold">"taskID"</span>, [_description, _title, _waypoint], objDocuments, [[true]]] [[call]] [[BIS_fnc_taskCreate]];


{{Feature | Informative | The <span style{{=}}"color: purple; font-weight: bold">"taskID"</span> argument is the task's ID used for later references.<!--
private _myTask = [groupOfPlayers, "taskID", [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate;
</sqf>
 
{{Feature | Informative | The '''"taskID"''' argument is the task's ID used for later references.<!--
--> This string gets defined here on creation and must be unique for each task.<!--
--> This string gets defined here on creation and must be unique for each task.<!--
--> It should be kept short for network economy.}}
--> It should be kept short for network economy.}}
Line 25: Line 27:
=== Assign a task ===
=== Assign a task ===


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskSetCurrent]];
<sqf>"taskID" call BIS_fnc_taskSetCurrent;</sqf>
{{Feature | Informative | This step is optional here as we used [[true]] as the fifth argument of  the [[BIS_fnc_taskCreate]] call, making it the current task.}}
{{Feature | Informative | This step is optional here as we used [[true]] as the fifth argument of  the [[BIS_fnc_taskCreate]] call, making it the current task.}}


=== Set a task's type ===
=== Set a task's type ===


[<span style="color: purple; font-weight: bold">"taskID"</span>, "attack"] [[call]] [[BIS_fnc_taskSetType]];
<sqf>["taskID", "attack"] call BIS_fnc_taskSetType;</sqf>
 
{{Feature | Informative | This could have been set in the task creation call as the eighth argument. See [[BIS_fnc_taskCreate]]'s ''type'' parameter.}}
{{Feature | Informative | This could have been set in the task creation call as the eighth argument. See [[BIS_fnc_taskCreate]]'s ''type'' parameter.}}


=== Set a task's visibility ===
=== Set a task's visibility ===


[<span style="color: purple; font-weight: bold">"taskID"</span>, [[true]]] [[call]] [[BIS_fnc_taskSetAlwaysVisible]];
<sqf>["taskID", true] call BIS_fnc_taskSetAlwaysVisible;</sqf>


=== Update a task's description ===
=== Update a task's description ===


_description = _description + "<nowiki><br/><br/></nowiki>UPDATE: an officer stole the documents; we got the GPS tracking, follow your HUD.";
<sqf>
[<span style="color: purple; font-weight: bold">"taskID"</span>, [_description, _title, _waypoint]] [[call]] [[BIS_fnc_taskSetDescription]];
_description = _description + "<br/><br/>UPDATE: an officer stole the documents; we got the GPS tracking, follow your HUD.";
["taskID", [_description, _title, _waypoint]] call BIS_fnc_taskSetDescription;
</sqf>


=== Update a task's waypoint position ===
=== Update a task's waypoint position ===


[<span style="color: purple; font-weight: bold">"taskID"</span>, [theOfficer, [[true]]]] [[call]] [[BIS_fnc_taskSetDestination]];
<sqf>["taskID", [theOfficer, true]] call BIS_fnc_taskSetDestination;</sqf>


=== Update a task's status ===
=== Update a task's status ===


[<span style="color: purple; font-weight: bold">"taskID"</span>, "SUCCEEDED"] [[call]] [[BIS_fnc_taskSetState]];
<sqf>["taskID", "SUCCEEDED"] call BIS_fnc_taskSetState;</sqf>


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


[<span style="color: purple; font-weight: bold">"taskID"</span>] [[call]] [[BIS_fnc_deleteTask]];
<sqf>["taskID"] call BIS_fnc_deleteTask;</sqf>




Line 60: Line 63:
=== Find if a task exists ===
=== Find if a task exists ===


[<span style="color: purple; font-weight: bold">"taskID"</span>] [[call]] [[BIS_fnc_taskExists]];
<sqf>["taskID"] call BIS_fnc_taskExists;</sqf>


=== Find if a task is completed ===
=== Find if a task is completed ===


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskCompleted]];
<sqf>"taskID" call BIS_fnc_taskCompleted;</sqf>
{{Feature | Informative | "Completed" means that the task is either "SUCCEEDED", "FAILED" or "CANCELED".}}
{{Feature | Informative | "Completed" means that the task is either "SUCCEEDED", "FAILED" or "CANCELED".}}


==== Check if multiple tasks are completed ====
==== Check if multiple tasks are all completed ====


[ <span style="color: purple; font-weight: bold">"taskID_0"</span>, <span style="color: purple; font-weight: bold">"taskID_1"</span>, <span style="color: purple; font-weight: bold">"taskID_2"</span>] [[findIf]] {!(_x [[call]] [[BIS_fnc_taskCompleted]])} == -1
<sqf>["taskID_0", "taskID_1", "taskID_2"] findIf {!(_x call BIS_fnc_taskCompleted)} == -1</sqf>


=== Get a task's status ===
=== Get a task's status ===


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskState]];
<sqf>"taskID" call BIS_fnc_taskState;</sqf>


=== Get a task's type ===
=== Get a task's type ===


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskType]];
<sqf>"taskID" call BIS_fnc_taskType;</sqf>


=== Get a task's visibility ===
=== Get a task's visibility ===


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskAlwaysVisible]];
<sqf>"taskID" call BIS_fnc_taskAlwaysVisible;</sqf>


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


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskDescription]];
<sqf>"taskID" call BIS_fnc_taskDescription;</sqf>


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


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskDestination]];
<sqf>"taskID" call BIS_fnc_taskDestination;</sqf>


=== Get a unit's tasks ===
=== Get a unit's tasks ===


[[player]] [[call]] [[BIS_fnc_tasksUnit]];
<sqf>player call BIS_fnc_tasksUnit;</sqf>





Revision as of 17:28, 22 July 2022

Basics

Tasks are a group's objectives. Arma 3 introduced the Arma 3: Task Framework to work with tasks with ease.
The Task Framework functions have a global effect.


For Arma 2's Task Tutorial, see Arma 2: Task Tutorial.


How to use a task

Create a task

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"; private _myTask = [groupOfPlayers, "taskID", [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate;

The "taskID" argument is the task's ID used for later references. This string gets defined here on creation and must be unique for each task. It should be kept short for network economy.

Assign a task

This step is optional here as we used true as the fifth argument of the BIS_fnc_taskCreate call, making it the current task.

Set a task's type

["taskID", "attack"] call BIS_fnc_taskSetType;

This could have been set in the task creation call as the eighth argument. See BIS_fnc_taskCreate's type parameter.

Set a task's visibility

Update a task's description

_description = _description + "<br/><br/>UPDATE: an officer stole the documents; we got the GPS tracking, follow your HUD."; ["taskID", [_description, _title, _waypoint]] call BIS_fnc_taskSetDescription;

Update a task's waypoint position

["taskID", [theOfficer, true]] call BIS_fnc_taskSetDestination;

Update a task's status

["taskID", "SUCCEEDED"] call BIS_fnc_taskSetState;

Delete a task


How to read a task's information

Find if a task exists

Find if a task is completed

"Completed" means that the task is either "SUCCEEDED", "FAILED" or "CANCELED".

Check if multiple tasks are all completed

["taskID_0", "taskID_1", "taskID_2"] findIf {!(_x call BIS_fnc_taskCompleted)} == -1

Get a task's status

Get a task's type

Get a task's visibility

Get a task's description

Get a task's destination

Get a unit's tasks


Advanced

All these details can be found in the Description.ext's Tasks chapter.

Define a task in mission config

You can define a task in Description.ext's CfgTaskDescriptions:

class CfgTaskDescriptions
{
	class myTask1
	{
		title		= "myTaskTitle";
		description	= "myTaskDescription";
		marker		= "myTaskDestinationMarker";
	};
	class myTask2
	{
		title		= $STR_myTask2Title;
		description	= $STR_myTask2Description;
		marker		= $STR_myTask2Marker;
	};
};


Define a new task type

class CfgTaskTypes
{
	class Attack
	{
		icon	= "\A3\UI_F_MP_Mark\Data\Tasks\Types\Attack_ca.paa";
		icon3D	= "\A3\UI_F_MP_Mark\Data\Tasks\Types3D\Attack_ca.paa";
	};
	class Defend
	{
		icon	= "\A3\UI_F_MP_Mark\Data\Tasks\Types\Defend_ca.paa";
		icon3D	= "\A3\UI_F_MP_Mark\Data\Tasks\Types3D\Defend_ca.paa";
	};
};


Define task display behaviour

class CfgTaskEnhancements
{
	enable       = 1; // 0: disable new task features (default), 1: enable new task features & add new task markers and task widgets into the map
	3d           = 1; // 0: do not use new 3D markers (default), 1: replace task waypoints with new 3D markers
	3dDrawDist   = 0; // 3d marker draw distance (default: 2000)
	share        = 1; // 0: do not count assigned players (default), 1: count how many players have the task assigned
	propagate    = 1; // 0: do not propagate (default), 1: propagate shared tasks to subordinates
};


See also