Tasks - broma-arma/BromA-A3-Framework-Mark3 GitHub Wiki
Introduction
ArmA is a game, and like all games, the players need objectives, actions you need to perform in order to beat the challenges proposed by you, the mission maker. Now, since it IS a game, setting up those challenges requires some knowledge of scripting, which for some might pose a tough barrier; and since the Framework was build to help these people, a system which allows you to setup those objectives free of any pain or hassle was due in order.
First, let's go to where our file for the tasks is. Open:
mission\objectives\tasks.sqf
As you can see, a lot of lines which may seem a bit mysterious, but we'll work on it.
Calling a new Task takes a single function - BRM_fnc_newTask - which is then combined with the proper arguments to work itself into what the user wants. Let's go over these arguments, followed by examples.
Parameters
1 - Side. This will determine who will the task be assigned to, which can be either an unit or a side.
WEST
side_a_side
mySpecialUnit
2. ID. This is an unique identifier for the Task.
"newTaskBLU01"
3. Display title, as the players will see it.
"Destroy the Anti-Air Vehicle."
4. Description of the Task, usually a more or less complete set of instructions on how to complete the objective.
"In order to destroy the Vehicle, make sure your explosives specialist is alive and has the assigned satchel charges on hand. Around two should be enough to deal significant damage to it."
5. Conditions. These are conditions which will be evaluated by the Framework in order to determine the Task's status. Firstly, we have the Assignment Condition, which will give players the Task whenever triggered. Second comes the Completion Condition, where as you can guess, dictates what needs to happen in order to succeed the Task. Finally we have the Failure Condition, which is pretty self-explanatory.
["(true)", "(not alive myMissionTarget)", "(targetEscaped)"]
In this example, we are assigning the Task immediately (since the Assignment Condition is TRUE by default) - and declaring it completed whenever the myMissionTarget object (can be an unit or anything else) is considered dead by the engine. However if the target escapes and the variable targetEscaped is set to TRUE, the Task is a failure.
Keep in mind that it is also possible to leave the Failure Condition in blank ("") as to avoid any losing condition at all.
6. Priority. Here we can determine how important the Task is to the mission, ranging from:
0 - Optional, meaning failing or completing this is completely irrelevant unless decided by the Mission Maker. 1 - Secondary Tasks which are more important than the optional ones, but won't carry severe consequences to the players upon failure. 2 - Primary objectives must be completed and NOT be failed under any circumstances, or else that will spell mission over for everybody.
0
1
2
7. Conditional Code. These are basically lines of code you can execute whenever a Task is Assigned, Completed or Failed.
["hint 'Task Assigned!'", "hint 'Task completed!'", "hint 'Task failed :('"]
Leave them blank ("") if you don't want to use any events.
Usage
So now that we know what does what, let's add our own Task! Open the aforementioned file, and BEFORE the part where it says [] spawn BRM_fnc_checkTasks;, add the code. Considering our previous example, it would be something like this:
[side_a_side, "newTaskBLU01", ["Destroy the Anti-Air Vehicle.", "In order to destroy the Vehicle, make sure your explosives specialist is alive and has the assigned satchel charges on hand. Around two should be enough to deal significant damage to it."], ["(true)", "(not alive myMissionTarget)", "(targetEscaped)"], 2, ["hint 'Task Assigned!'", "hint 'Task completed!'", "hint 'Task failed :('"]] spawn BRM_fnc_newTask;
And we're done. Preview your mission and your Task is good to go.
Q: My Task isn't working and it's giving me some error with _winCond.
A: You are using an object for your task that doesn't exist or isn't named properly - make sure to double check all of your Tasks are completable!