Task Framework Tutorial – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{SideTOC}}
{{TOC|side}}
== Basics ==
== Basics ==


Tasks are a group's objectives. {{arma3}} introduced the '''[[Arma 3 Task Framework]]''' to work with tasks with ease.<br>
Tasks are a group's objectives. {{arma3}} introduced the '''[[Arma 3: Task Framework]]''' to work with tasks with ease.<br>
The '''Task Framework''' functions have a '''global''' effect.
The '''Task Framework''' functions have a '''global''' effect.




{{Informative | For '''{{arma2}}'''<nowiki/>'s Task Tutorial, see [[Arma 2:Task Tutorial]].}}
{{Feature|informative|For '''{{arma2}}'''<nowiki/>'s Task Tutorial, see [[Arma 2: Task Tutorial]].}}




== How to use a task ==
== How to Use a Task ==


=== 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]];


{{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.}}


=== Assign a task ===
=== Assign a Task ===
 
<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.}}


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskSetCurrent]];
=== Set a Task's Type ===
{{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 ===
<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.}}


[<span style="color: purple; font-weight: bold">"taskID"</span>, "attack"] [[call]] [[BIS_fnc_taskSetType]];
=== Set a Task's Visibility ===


{{Informative | This could have been set in the task creation call as the eighth argument. See [[BIS_fnc_taskCreate]]'s ''type'' parameter.}}
<sqf>["taskID", true] call BIS_fnc_taskSetAlwaysVisible;</sqf>


=== Set a task's visibility ===
=== Update a Task's Description ===


[<span style="color: purple; font-weight: bold">"taskID"</span>, [[true]]] [[call]] [[BIS_fnc_taskSetAlwaysVisible]];
<sqf>
// hardcoded language
_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 description ===
// new description
["taskID", ["STR_TaskDescription2", _title, _waypoint]] call BIS_fnc_taskSetDescription;
</sqf>


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


=== Update a task's waypoint position ===
<sqf>["taskID", [theOfficer, true]] call BIS_fnc_taskSetDestination;</sqf>


[<span style="color: purple; font-weight: bold">"taskID"</span>, [theOfficer, [[true]]]] [[call]] [[BIS_fnc_taskSetDestination]];
=== Update a Task's Status ===


=== Update a task's status ===
<sqf>["taskID", "SUCCEEDED"] call BIS_fnc_taskSetState;</sqf>


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


=== Delete a task ===
<sqf>["taskID"] call BIS_fnc_deleteTask;</sqf>


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


== How to Read a Task's Information ==


== How to read a task's information ==
=== Find if a Task Exists ===


=== Find if a task exists ===
<sqf>["taskID"] call BIS_fnc_taskExists;</sqf>


[<span style="color: purple; font-weight: bold">"taskID"</span>] [[call]] [[BIS_fnc_taskExists]];
=== Find if a Task is Completed ===


=== Find if a task is completed ===
<sqf>"taskID" call BIS_fnc_taskCompleted;</sqf>
{{Feature|informative|"Completed" means that the task is either "SUCCEEDED", "FAILED" or "CANCELED".}}


<span style="color: purple; font-weight: bold">"taskID"</span> [[call]] [[BIS_fnc_taskCompleted]];
==== Multiple Tasks Check ====
{{Informative | "Completed" means that the task is either "SUCCEEDED", "FAILED" or "CANCELED".}}
<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>private _taskIDs = player call BIS_fnc_tasksUnit;</sqf>




== Advanced ==
== Advanced ==


{{Informative | All these details can be found in the [[Description.ext#Tasks|Description.ext's Tasks chapter]].}}
{{Feature|informative|All these details can be found in the [[Description.ext#Tasks|Description.ext's Tasks chapter]].}}


=== Define a task in mission config ===
=== Define a Task in Mission Config ===


You can define a task in [[Description.ext#CfgTaskDescriptions|Description.ext's CfgTaskDescriptions]]:
You can define a task in [[Description.ext#CfgTaskDescriptions|Description.ext's CfgTaskDescriptions]]:
Line 104: Line 114:
class myTask1
class myTask1
{
{
title = "myTaskTitle";
title = "my task title";
description = "myTaskDescription";
description = "my task description";
marker = "myTaskDestinationMarker";
marker = "my task destination marker";
};
};
class myTask2
class myTask2
{
{
title = $STR_myTask2Title;
title = "STR_myTask2Title"; // note the lack of $ sign here!
description = $STR_myTask2Description;
description = "STR_myTask2Description"; // without $, it translates for each client
marker = $STR_myTask2Marker;
marker = "STR_myTask2Marker"; // with $ everyone sees the server's language
};
};
};
};
</syntaxhighlight>
</syntaxhighlight>


 
=== Define a new Task Type ===
=== Define a new task type ===


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
Line 136: Line 145:
</syntaxhighlight>
</syntaxhighlight>


 
=== Define Task Display Behaviour ===
=== Define task display behaviour ===


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
Line 151: Line 159:




== See also ==
== See Also ==


* [[Arma 3 Task Framework]]
* [[Arma 3: Task Framework]]
* [[:Category:Function_Group:_Tasks|Tasks Functions]]
* [[:Category:Function_Group:_Tasks|Tasks Functions]]
* [[:Category:Command Group: Briefing|Briefing Commands]]
* [[:Category:Command Group: Briefing|Briefing Commands]]




[[Category:Scripting Topics]]
[[Category:Arma Scripting Tutorials]]
[[Category:Arma 3: Editing]]
[[Category:Arma 3: Tutorials]]

Latest revision as of 10:03, 11 September 2023

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

// hardcoded language _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; // new description ["taskID", ["STR_TaskDescription2", _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".

Multiple Tasks Check

["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		= "my task title";
		description	= "my task description";
		marker		= "my task destination marker";
	};
	class myTask2
	{
		title		= "STR_myTask2Title";			// note the lack of $ sign here!
		description	= "STR_myTask2Description";		// without $, it translates for each client
		marker		= "STR_myTask2Marker";			// with $ everyone sees the server's language
	};
};

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