Task Framework Objective

From Arma Projects
Jump to: navigation, search

As with every task, there is an objective to complete. This section of the config allows a mission maker to set the conditions that are monitored to check if a task has been completed. There are many pre-configured variables that are available and when the condition returns true, the objective will be updated. Once complete, the framework can initiate a subsequent task(s) so a mission can be daisy chained into a story or larger operation.

The task objective check is trigger based. There is no monitoring loop taking up and wasting processor time while checking the same variables over and over again coming to the same conclusion.

Setting an Objective

Setting the state and condition criteria of the task will allow the framework to assess the necessary features required and determine if a task is completed. This is done in two steps.

Setting the new Task Status

A task complete state can be any of the following: state = <number:state>;

ID State Description
1 Succeeded The task will be displayed as successful
2 Failed The task will be displayed as a failure
3 Canceled The task will be displayed as canceled

Check a tasks Conditions

The condition for each task state is a string that is compiled and called to assess variables and return either a True for False on the condition for a task state. The string is text mined to identify any pre-configured variables and will only assess those conditions if found. As this is compiled into code, a mission maker can make any condition they want to process a task state, even an external function.

condition = <string:condition>;

These variables when added to the condition will be process the below outcomes if identified in the condition string.

Variable Type Description
_unitskilled BOOL When all units spawned are not alive
_targetskilled BOOL When all units spawned that are configured as "Target = 1" are not alive or cannot move
_targetsdestroyed BOOL When all objects in the compositions spawned that are configured in "Target Class Types" are not alive or cannot move
_targetsreturned BOOL When all units spawned that are configured as "Target = 1" are alive, can move and present at a return point
_targetDelivered BOOL When all units spawned that are configured as "Target = 1" are alive, can move and present at a objective
_targetDeployed BOOL When onDeployedObject triggered event indicates task object deployed at objective area
_cachedestroyed BOOL When all objects spawned that are configured as weapons cache in CfgMission and are configured "Target = 1"
_inteldownloaded BOOL When an onIntelDownloaded triggered event indicates task intel has been downloaded
_intelpickedup BOOL When an onIntelPickedUp triggered event indicates task intel has been picked up
_intelrecieved BOOL When an onIntelRecieved triggered event indicates task intel has recieved from NPC conversation
_sectorscleared BOOL When an areas sectors are all clear of alive spawned units
_areadefended BOOL When all attacking units are not alive or not in the defend area
_playerskilled BOOL When all players assigned to the task have been killed at least once since task creation
_playersleft Number The amount of players assigned to the task that have not been killed since task creation
_childtaskscomplete BOOL Parent Specific - When all child tasks configured have been completed
Code Note
Unlimited Conditions
The objective can have as many different outcomes as required for a mission maker, i.e you can have three successful objective conditions each with its own condition leading to a different outcome. There is no limit to the number of conditions that can be processed however do take server performance into consideration..

Basic Example with single outcome

class My_Task_1 {
	class Objective {
		class ObjectiveCondition_1 {
			state = <number> // i.e. 1:Succeeded, 2:Failed, 3:Canceled
			condition = <string>; // i.e. "_targetsKilled"
		};
	};
};

Example of multiple possible outcomes

class My_Task_1 {
	class Objective {
		class ObjectiveCondition_1 {
			state = <number> // i.e. 1:Succeeded, 2:Failed, 3:Canceled
			condition = <string>; // i.e. "_targetsKilled"
		};
		class ObjectiveCondition_2 {
			state = <number> // i.e. 1:Succeeded, 2:Failed, 3:Canceled
			condition = <string>; // i.e. "_targetsReturned"
		};
		class ObjectiveCondition_3 {
			state = <number> // i.e. 1:Succeeded, 2:Failed, 3:Canceled
			condition = <string>; // i.e. "_intelPickedUp"
		};
	};
};

Triggering a task sequence

Mission makers also have the ability to trigger the creating of new tasks on the completion of the current one. This is done in two primary ways.

  • Next Task - An array of task ids that one will be randomly selected and created after completion
nextTask[] = <array:taskIDs>;
  • Next Tasks - An array of task ids that will all be created after completion
nextTasks[] = <array:taskIds>;

Triggering the Mission End

To end the mission on a condition requires one simple line in the objective that is finite (false or true). Once triggered, the mission outro sequence will begin and all clients will have their mission end. The server however hangs for a little and when all players disconnect, it will attempt to run the OCAP output before completing the mission. OCAP is optional and if not present, will not affect or cause an error in the mission.

endMission = <number:boolean>

Additional Objective Features

  • Condition External Functions - Mission makers also can trigger the execution of a custom function when a task reaches a certain state.
    Variables passed are the [<string:taskID>,<string:state>]
function = <string:function>;
  • Return Points - Mission makers can create a return point near the objective automatically for missions requiring objects, vehicles or targets to be recovered. The return point is between 2-3km from the objective and allows for a better player experience.
nearbyReturnPoint = <number:0-1>;
  • Global Respawn Disabling - Mission makers can prevent respawn for players assigned to the task while a task is active with a simple command **(Requires RespawnMP Framework)
    Only when the task is complete will they be enabled to respawn again.
disableRespawn = <number:0-1>;

Full Example of Task Objective

class My_Task_1 {
	//... append to existing task
	class Objective {
		disableRespawn = 1; // Disable respawn while assigned to this active task
		nearbyReturnPoint = 0; // Creates nearby return point
		class Succeeded {
			state = 1; // 1: Succeeded
			condition = "_unitsKilled && _intelPickedup";
			nextTask[] = {"My_Task_2","My_Task_3"}; // Create another task from randomly selecting one of the array
			function = "MY_fnc_testFunction"; // Execute an external function
		};
		class Failed {
			state = 2; // 2: Failed
			condition = "_playerskilled"; // When assigned players killed
			endMission = 1;
		};
		class Canceled {
			state = 3; // 3: Failed
			condition = "_intelrecieved"; // Cancel Task
			nextTasks[] = {"Task_4_A","Task_4_B"}; // Create both tasks from the array
		};
	};
};