ArmA 3 Alpha: Scripting tasks for single player missions that must be completed in order

Overview

In this scenario, the player spawns with Task 1 as their current task and it is displayed on their HUD. A secondary task, called Task 2, is not displayed on the player’s HUD or when viewing all tasks.

To complete Task 1, the player must move to Task 1’s location. Once the player has reached Task 1’s location, a success message displays and indicates the player should now complete Task 2. Task 1 is hidden from the HUD and marked completed. Task 2 is then displayed on the HUD and when viewing all tasks.

Code structure

In this example, I am calling the FNC_task_1_completed function when a trigger activates. This could be changed and called, for example, when an OPFOR unit dies.

If you have a lot of code that executes when Task 1 completes, you could create a new file calledtask1Completed.sqf and use execVM “task1Completed.sqf” on the trigger instead of call FNC_task_1_completed.

The structure depends on how complicated your mission is and how you want code to be organized. With something this simple, keeping it in a single file works.

In the Editor

  1. Create a single BLUFOR spawn.
  2. Create 2 markers named Task_Marker_1 and Task_Marker_2.
  3. Create a trigger named Task_1_Trigger_Completed near Task_Marker_1 that activates when BLUFOR is present. Activation field contains: “call FNC_task_1_completed”;

Mission Files

Create or extract the files to your mission folder.
Read more on where to find mission files in the biki.

init.sqf

// Setup our briefing
execVM "briefing.sqf";

briefing.sqf

// FUNCTION: Called when
// Task_1_Trigger_Completed activates.
// Creates task 2.
FNC_task_1_completed =
{
    // Player has completed task 1.
    // Mark it complete.
    task_1 setTaskState "Succeeded";

    // Create task 2
    task_2 = player createSimpleTask ["Task 2 Message"];
    task_2 setSimpleTaskDescription [
        "Task 2 Message",
        "Task 2 Title",
        "Task 2 HUD Title"
    ];
    task_2 setSimpleTaskDestination (getMarkerPos "Task_Marker_2");

    // Update player's current task to task 2
    player setCurrentTask task_2;

    // Let player know they've completed task 1
    // and now need to complete task 2
    hint "Task 1 Completed!\nComplete task 2!"; 
};

// Create task 1
task_1 = player createSimpleTask ["Task 1 Message"];
task_1 setSimpleTaskDescription [
    "Task 1 Message", 
    "Task 1 Title", 
    "Task 1 HUD Title"
];
task_1 setSimpleTaskDestination (getMarkerPos "Task_Marker_1");

// Set task 1 as player's current task
player setCurrentTask task_1;

// Let player know they need to complete task 1
hint "Complete task 1";