.project |U/ callChopper.sqf G1Y description.ext ŔWF functions\fhq_tasktracker.hpp fW~ functions\fhq_tasktracker\fhq_tasktracker\fn_ttAddBriefing.sqf Vw functions\fhq_tasktracker\fhq_tasktracker\fn_ttAddTasks.sqf VV functions\fhq_tasktracker\fhq_tasktracker\fn_ttAreTasksCompleted.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttAreTasksSuccessful.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttGetAllTasksWithState.sqf VG functions\fhq_tasktracker\fhq_tasktracker\fn_ttGetTaskState.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttiAddBriefingEntry.sqf hW9 functions\fhq_tasktracker\fhq_tasktracker\fn_ttiCreateOrUpdateTask.sqf MW functions\fhq_tasktracker\fhq_tasktracker\fn_ttiFilterUnits.sqf V% functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskDesc.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskId.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskName.sqf Vm functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskState.sqf V. functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskTarget.sqf FV functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskTitle.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskType.sqf +VC functions\fhq_tasktracker\fhq_tasktracker\fn_ttiGetTaskWp.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttiHasBriefingEntry.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttiInit.sqf a~W functions\fhq_tasktracker\fhq_tasktracker\fn_ttiIsFilter.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttiIsTaskState.sqf gV functions\fhq_tasktracker\fhq_tasktracker\fn_ttiMissionBriefing.sqf V) functions\fhq_tasktracker\fhq_tasktracker\fn_ttiMissionTasks.sqf V, functions\fhq_tasktracker\fhq_tasktracker\fn_ttiPostInit.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttIsTaskCompleted.sqf V functions\fhq_tasktracker\fhq_tasktracker\fn_ttIsTaskSuccessful.sqf VL functions\fhq_tasktracker\fhq_tasktracker\fn_ttiTaskExists.sqf VQ functions\fhq_tasktracker\fhq_tasktracker\fn_ttiUnitBriefing.sqf Vg functions\fhq_tasktracker\fhq_tasktracker\fn_ttiUnitTasks.sqf V^ functions\fhq_tasktracker\fhq_tasktracker\fn_ttiUpdateBriefingList.sqf hW functions\fhq_tasktracker\fhq_tasktracker\fn_ttiUpdateTaskList.sqf Vx functions\fhq_tasktracker\fhq_tasktracker\fn_ttSetTaskState.sqf Vx functions\fhq_tasktracker\fhq_tasktracker\fn_ttSetTaskStateAndNext.sqf V$ functions\fhq_tasktracker\fhq_tasktracker\fn_ttTaskHint.sqf V functions\fhq_tasktracker\fn_ttAddBriefing.sqf Vw functions\fhq_tasktracker\fn_ttAddTasks.sqf VV functions\fhq_tasktracker\fn_ttAreTasksCompleted.sqf V functions\fhq_tasktracker\fn_ttAreTasksSuccessful.sqf V functions\fhq_tasktracker\fn_ttGetAllTasksWithState.sqf VG functions\fhq_tasktracker\fn_ttGetTaskState.sqf V functions\fhq_tasktracker\fn_ttiAddBriefingEntry.sqf hW9 functions\fhq_tasktracker\fn_ttiCreateOrUpdateTask.sqf MW functions\fhq_tasktracker\fn_ttiFilterUnits.sqf V% functions\fhq_tasktracker\fn_ttiGetTaskDesc.sqf V functions\fhq_tasktracker\fn_ttiGetTaskId.sqf V functions\fhq_tasktracker\fn_ttiGetTaskName.sqf Vm functions\fhq_tasktracker\fn_ttiGetTaskState.sqf V. functions\fhq_tasktracker\fn_ttiGetTaskTarget.sqf FV functions\fhq_tasktracker\fn_ttiGetTaskTitle.sqf V functions\fhq_tasktracker\fn_ttiGetTaskType.sqf +VC functions\fhq_tasktracker\fn_ttiGetTaskWp.sqf V functions\fhq_tasktracker\fn_ttiHasBriefingEntry.sqf V functions\fhq_tasktracker\fn_ttiInit.sqf a~W functions\fhq_tasktracker\fn_ttiIsFilter.sqf V functions\fhq_tasktracker\fn_ttiIsTaskState.sqf gV functions\fhq_tasktracker\fn_ttiMissionBriefing.sqf V) functions\fhq_tasktracker\fn_ttiMissionTasks.sqf V, functions\fhq_tasktracker\fn_ttiPostInit.sqf V functions\fhq_tasktracker\fn_ttIsTaskCompleted.sqf V functions\fhq_tasktracker\fn_ttIsTaskSuccessful.sqf VL functions\fhq_tasktracker\fn_ttiTaskExists.sqf VQ functions\fhq_tasktracker\fn_ttiUnitBriefing.sqf Vg functions\fhq_tasktracker\fn_ttiUnitTasks.sqf V^ functions\fhq_tasktracker\fn_ttiUpdateBriefingList.sqf hW functions\fhq_tasktracker\fn_ttiUpdateTaskList.sqf Vx functions\fhq_tasktracker\fn_ttSetTaskState.sqf Vx functions\fhq_tasktracker\fn_ttSetTaskStateAndNext.sqf V$ functions\fhq_tasktracker\fn_ttTaskHint.sqf V init.sqf U library\createExtraction.sqf ꝨS] mission.sqm 8Y
[FHQ] Helo Extraction (COOP 04, Example)
org.friedenhq.armascript.projectNature
if (isServer) then
{
/* I define this as a function here so I don't need to cram
* all that stuff into the parameter list. This is not strictly
* needed, but usually a good idea */
FHQ_EndMission =
{
hint 'All in, go go go';
sleep 10;
"WON" call BIS_fnc_EndMissionServer;
};
/* This code should only run on the server */
[units FHQ_playerGroup, /* The units to extract... multiple groups can be extracted
* with, for example (units group1 + units group2) */
"B_Heli_Transport_03_F", /* Class name of the extraction vehicle */
getMarkerPos "markChopperSpawn",/* Position the extraction vehicle is created at */
getMarkerPos "markExtract", /* Pickup position */
true, /* true if the chopper should touch down, false for hover */
"hint 'Chopper on the way';", /* Code that is executed when the extraction vehicle is spawned */
"hint 'Chopper has arrived';", /* Code that is run when the vehicle reaches the extraction zone */
"[] spawn FHQ_EndMission;" /* Code that is run when units are loaded. Usually also used to
* end the mission */
] execvm "library\createExtraction.sqf";
};class CfgFunctions
{
#include "functions\fhq_tasktracker.hpp"
};
/* FHQ Task Tracker
* Copyright 2016 by Thomas Frieden (Varanon). All rights reserved. Use of this software
* is at your own risk. The copyright holder is in no way responsible for damages
* resulting from the use of this software.
* Distribution of the software is only allowed within a mission. In addition, no
* changes are allowed to the software without the permission of the authors.
* Distribution as a standalone package is prohibited.
* Attribution (getting a mention in the credits section of your mission) is appreciated,
* but not a requirement
*/
#define INTERNAL_FUNCTION(x) \
class x \
{ \
description = "Internal Function"; \
};
#define EXPORTED_FUNCTION(x,y) \
class x \
{ \
description = y; \
};
class FHQ {
class TaskTrackerInternal {
tag="FHQ";
file="functions\fhq_tasktracker";
class ttiInit
{
description = "Internal function, called automatically";
preInit = 1;
};
class ttiPostInit
{
description = "Internal function, called automatically";
postInit = 1;
};
INTERNAL_FUNCTION(ttifilterUnits)
INTERNAL_FUNCTION(ttiAddBriefingEntry)
INTERNAL_FUNCTION(ttiHasBriefingEntry)
INTERNAL_FUNCTION(ttiUpdateBriefingList)
INTERNAL_FUNCTION(ttiGetTaskId)
INTERNAL_FUNCTION(ttiGetTaskDesc)
INTERNAL_FUNCTION(ttiGetTaskTitle)
INTERNAL_FUNCTION(ttiGetTaskWp)
INTERNAL_FUNCTION(ttiGetTaskTarget)
INTERNAL_FUNCTION(ttiGetTaskState)
INTERNAL_FUNCTION(ttiGetTaskName)
INTERNAL_FUNCTION(ttiGetTaskType)
INTERNAL_FUNCTION(ttiTaskExists)
INTERNAL_FUNCTION(ttiCreateOrUpdateTask)
INTERNAL_FUNCTION(ttiUpdateTaskList)
INTERNAL_FUNCTION(ttiMissionTasks)
INTERNAL_FUNCTION(ttiMissionBriefing)
INTERNAL_FUNCTION(ttiUnitTasks)
INTERNAL_FUNCTION(ttiUnitBriefing)
INTERNAL_FUNCTION(ttiIsFilter)
INTERNAL_FUNCTION(ttiIsTaskState)
};
class TaskTracker {
tag="FHQ";
file="functions\fhq_tasktracker";
EXPORTED_FUNCTION(ttTaskHint, "This function is called for every task hint to be displayed.")
EXPORTED_FUNCTION(ttAddBriefing, "Adds a briefing to the missing.")
EXPORTED_FUNCTION(ttAddTasks, "Adds tasks to the mission.")
EXPORTED_FUNCTION(ttGetTaskState, "Return the state of a task.")
EXPORTED_FUNCTION(ttSetTaskState, "Set the new state of a task.")
EXPORTED_FUNCTION(ttIsTaskCompleted, "Check whether a given task is completed")
EXPORTED_FUNCTION(ttAreTasksCompleted, "Check whether a list of tasks is completed")
EXPORTED_FUNCTION(ttIsTaskSuccessful, "Check whether a given task is successfully completed")
EXPORTED_FUNCTION(ttAreTasksSuccessful, "Check whether a list of tasks is successfully completed")
EXPORTED_FUNCTION(ttGetAllTasksWithState, "Return an array of all tasks with a given state")
EXPORTED_FUNCTION(ttSetTaskStateAndNext, "Set a task's state, and select the next one")
};
};
/* FHQ_fnc_ttAddBriefing: Add a full briefing
*
* This functions receives an array as input. The elements of the input array
* are interpreted as follows:
* If the element is a two-element array consisting of two strings, the entry is
* interpreted as a new briefing topic. If the array has three strings, it's interpreted
* as a new briefing entry, with the first one being the general subject ("Diary" by default),
* and the two subsequent strings title and description.
* If the element is anything else, the following topics will only be presented to
* the units matching the element. For example, if the element is a group, the following
* entries are added to this group only.
*
* NOTE: The old hierarchical filtering is no longer supported. It wasn't that useful for
* real-world application and was posing severe problems with respawn missions.
*
* Example:
*
* [
* west,
* ["Mission", "Get some!"],
* ["Enemy Forces", "There's lots of ruskies around"],
* east,
* ["Mission", "Get those imperialistic americans"],
* ["Current Supply of Vodka", "Low"],
* {true},
* ["Credits", "Mission by", "Some Dude"],
* ["Credits", "Uses scripts by", "Some other dude
Yet another dude"]
* ] call FHQ_fnc_ttAddBriefing.
*
* The first two lines (Mission, Enemy Forces), are added under "Briefing" for west
* troops only, the second two lines (Mission, Current Supply of Vodka) only for east.
* The last two lines add two new entries "Mission by" and "Uses scripts by" into a new
* subject "Credits".
*
* NOTE: Do not over-use the additional subject feature. Briefing and all associated information
* should go to the default subject.
*
* Calling FHQ_TT_addBriefing with an already existing subject/title will add a new log entry
* if the text differs from the previous one.
*
* Notifications are shown after the initial briefing has been donwloaded by the clients, i.e.
* not at mission start, only when new briefing entries are added.
*/
private ["_currentFilter", "_i", "_current", "_x"];
_currentFilter = {true};
if (isServer) then {
/* Note: Server only code. Briefing entries must be added on the server, not on an
* individual client
*/
for [{_i = 0}, {_i < count _this}, {_i = _i + 1}] do {
_current = _this select _i;
if (_current call FHQ_fnc_ttiIsFilter) then {
_currentFilter = nil;
_currentFilter = _current;
} else {
/* It's a briefing entry. */
[_currentFilter, _current] call FHQ_fnc_ttiAddBriefingEntry;
};
};
publicVariable "FHQ_TTI_BriefingList";
if (!isDedicated) then {
FHQ_TTI_BriefingList call FHQ_fnc_ttiUpdateBriefingList;
};
FHQ_TTI_briefing = true;
publicVariable "FHQ_TTI_briefing";
};
/* FHQ_fnc_ttAddTasks: Add tasks to the mission
*
* Task are defined similar to briefing entries. The function accepts an array as input.
* Each entry is either a filter (see FHQ_TT_addBriefing), or a task description.
*
* A task description itself is an array and can be one of the following format:
* [_taskName, _longDescription, _shortDescription, _waypointDescription, _target, _initialState]
* [[_taskName, _parentTask], _longDescription, _shortDescription, _waypointDescription, _target, _initialState]
*
* Both _target and _initialState are optional and can be left out.
*
* o _taskName is a symbolic name that is invisible to the player.
* o _longDescription is a text describing the task.
* o _shortDescription is used as a headline for the task in the task list and on task hints
* o _waypointDescription is displayed on the waypoint on the map and in the 3d view (if enabled).
* o _target can be a position (three-element array) or an object. If either is given, the
* task waypoint is shown on the map an the 3d view. Objects that move also move
* the waypoint marker.
* o _initialState is the initial state of the task ("succeeded", "failed", "canceled",
* "created", or "assigned"). By default, if _initialState is ommited, the state is set
* to "created". If set to "assigned", the task is also automatically assigned to everyone
* that knows about it.
*
* Example:
*
* [
* west,
* ["taskBoard1", "Board your chopper", "Board your chopper", "BOARD", westHelo1, "assigned"],
* ["taskCAS", "Fly around", "Fly around", "CAS"],
* ["taskRetreat1", "Return to LZ", "Return to LZ", "RETREAT", getMarkerPos "markLZ"],
* "BLU_G_F",
* ["taskSecret", "Secret: Betray NATO for whatever reason", "Secret: Betray NATO", ""],
* [["taskSecret1", "taskSecret"], "Because they are idiots", "Idiots", ""],
* [["taskSecret2", "taskSecret"], "Because I am evil", "Evil", ""]
* ] call FHQ_fnc_ttAddTasks;
*
* The first three tasks are assigned at all playable west units. The second bunch of three tasks is
* only assigned to FIA units. The latter two, taskSecret1 and taskSecret2 are created as subtasks
* of the task "taskSecret" and will be displayed immediately below their respective parent.
*
* NOTE: This function can only be called on the server. Calling it anywhere else will have no effect.
*/
private _currentFilter = {true};
if (isServer) then {
/* Note: Server only code. Briefing entries must be added on the server, not on an
* individual client
*/
private _i = 0;
for [{_i = 0}, {_i < count _this}, {_i = _i + 1}] do {
private _current = _this select _i;
if (_current call FHQ_fnc_ttiIsFilter) then {
/* Must be a filter */
_currentFilter = nil;
_currentFilter = _current;
} else {
/* Task entry.
* Check if the task already exists. If not, construct a full
* task entry with all redundant information filled in for easier
* access later on
*/
private _name = _current call FHQ_fnc_ttiGetTaskName;
if (([FHQ_TTI_TaskList, _name] call FHQ_fnc_ttiTaskExists) == -1) then {
private _newTask =
[_current call FHQ_fnc_ttiGetTaskId,
_current call FHQ_fnc_ttiGetTaskDesc,
_current call FHQ_fnc_ttiGetTaskTitle,
_current call FHQ_fnc_ttiGetTaskWp,
_current call FHQ_fnc_ttiGetTaskTarget,
_current call FHQ_fnc_ttiGetTaskState,
_current call FHQ_fnc_ttiGetTaskType];
FHQ_TTI_TaskList = FHQ_TTI_TaskList + [[_currentFilter, _newTask]];
};
};
};
publicVariable "FHQ_TTI_TaskList";
if (!isDedicated) then {
FHQ_TTI_TaskList call FHQ_fnc_ttiUpdateTaskList;
};
FHQ_TTI_tasks = true;
publicVariable "FHQ_TTI_tasks";
};
/* FHQ_fnc_ttAreTasksCompleted
*
* Check for all tasks given whether they are considered completed. This function can
* be called on the client as well as the server.
*
* Usage
* _result = [_taskName1, _taskName2, ...] call FHQ_fnc_ttAreTasksCompleted
*
* _taskName1 and following: Task names that are tested for being completed. If any of them is not
* completed, the function returns false, else true.
*/
private ["_result", "_x"];
_result = true;
{
if (!(tolower ([_x] call FHQ_fnc_ttGetTaskState) in ["succeeded", "canceled", "failed"])) exitWith
{
_result = false;
};
} forEach _this;
_result;
/* FHQ_fnc_ttAreTasksSuccessful
*
* Check success for all tasks given. This function can be called on the client as well as
* the server.
*
* _result = [_taskName1, _taskName2, ...] call FHQ_fnc_ttAreTasksSuccessful
*/
private ["_result", "_x"];
_result = true;
{
if (tolower ([_x] call FHQ_fnc_ttGetTaskState) != "succeeded") exitWith
{
_result = false;
};
} forEach _this;
_result;
/* FHQ_fnc_ttGetAllTasksWithState
*
* Get all tasks with a given state. This function can be called on the client as well as
* the server.
*
* _taskList = [_state] call FHQ_fnc_ttGetAllTasksWithState;
*/
#define FHQ_TTIF_TASKSTATE 5
private ["_result", "_taskState"];
_result = [];
_taskState = [_this, 0, "", [""]] call BIS_fnc_param;
{
if (((_x select 1) select FHQ_TTIF_TASKSTATE) == _taskState) then
{
_result = _result + [(_x select 1) call FHQ_fnc_ttiGetTaskName];
};
} forEach FHQ_TTI_TaskList;
_result;
/* FHQ_fnc_ttGetTaskState
*
* Get the state of a given task. This function can be called on the client as well as
* the server.
*
* Usage:
* _state = [_task] call FHQ_fnc_ttGetTaskState;
*
* _task: The name of a task defined via FHQ_fnc_ttAddTask
*
* Returns the state of the task ("succeeded", "failed", "canceled", "created", "assigned"), or an empty
* string if the task does not exist
*/
#define FHQ_TTIF_TASKSTATE 5
private ["_res", "_name", "_idx", "_entry"];
_res = "";
_name = [_this, 0, "", [""]] call BIS_fnc_param;
_idx = [FHQ_TTI_TaskList, _name] call FHQ_fnc_ttiTaskExists;
if (_idx != -1) then {
_entry = FHQ_TTI_TaskList select _idx;
_res = (_entry select 1) select FHQ_TTIF_TASKSTATE;
};
_res;
/* Internal: Add a briefing record on the server
* parameters:
* select 0: Filter
* select 1: [_section, _subject, _text]
*/
private _record = [_this, 1] call BIS_fnc_param;
private _filter = [_this, 0] call BIS_fnc_param;
private _subject = "Diary";
private _topic = _record select 0;
private _text = _record select 1;
if (count _record == 3) then {
_subject = _record select 0;
_topic = _record select 1;
_text = _record select 2;
};
FHQ_TTI_BriefingList = FHQ_TTI_BriefingList + [[_filter, [_subject, _topic, _text]]];
private ["_current", "_existing", "_unit", "_name", "_state", "_idx", "_record", "_object", "_taskID",
"_parented"];
_current = [_this, 0] call BIS_fnc_param;
_existing = [_this, 1] call BIS_fnc_param;
_unit = [_this, 2] call BIS_fnc_param;
_name = _current call FHQ_fnc_ttiGetTaskName;
_state = _current call FHQ_fnc_ttiGetTaskState;
_parented = false;
_idx = [_existing, _name] call FHQ_fnc_ttiTaskExists;
if (_idx != -1) then {
_record = _existing select _idx;
if ((_record select 0) != _state) then {
/* Need to set new state */
_record set [0, _state];
if (_state == "assigned") then {
_unit setCurrentTask (_record select 1);
};
(_record select 1) setTaskState _state;
if (_unit == player && !FHQ_TTI_supressTaskHints) then
{
[_current call FHQ_fnc_ttiGetTaskTitle, _state] call FHQ_fnc_ttTaskHint;
};
/* Update the list */
_existing set [_idx, _record];
};
} else {
_taskID = _current call FHQ_fnc_ttiGetTaskId;
if (typename _taskID == "STRING") then {
_object = _unit createSimpleTask [_name];
} else {
_object = _unit createSimpleTask [_name, _unit getVariable format["FHQ_TT_taskname_%1", _taskID select 1]];
_parented = true;
};
if (!FHQ_TTI_is_arma3 && _parented) then {
_object setSimpleTaskDescription [_current call FHQ_fnc_ttiGetTaskDesc,
format ["%2%1", _current call FHQ_fnc_ttiGetTaskTitle, FHQ_TT_subtaskPrefix],
_current call FHQ_fnc_ttiGetTaskWp];
} else {
_object setSimpleTaskDescription [_current call FHQ_fnc_ttiGetTaskDesc,
_current call FHQ_fnc_ttiGetTaskTitle,
_current call FHQ_fnc_ttiGetTaskWp];
};
_target = _current call FHQ_fnc_ttiGetTaskTarget;
switch (typename _target) do
{
case "ARRAY": {
_object setSimpleTaskDestination _target;
};
case "OBJECT": {
_object setSimpleTaskTarget [_target, true];
};
};
private _taskType = _current call FHQ_fnc_ttiGetTaskType;
if (_taskType != "" && FHQ_TTI_version > 156) then {
[_object, _taskType] call compile "(_this select 0) setSimpleTaskType (_this select 1);"
};
_target = nil;
_object setTaskState _state;
if (tolower(_state) == "assigned") then
{
_unit setCurrentTask _object;
};
_unit setVariable [format["FHQ_TT_taskname_%1", _name], _object]; // FIXME: propagate through network ?
if (_unit == player && !FHQ_TTI_supressTaskHints) then
{
[_current call FHQ_fnc_ttiGetTaskTitle, _state] call FHQ_fnc_ttTaskHint;
};
_existing = _existing + [ [_state, _object, _name] ];
};
_existing;/* Internal function */
private ["_unitsArray", "_outputArray"];
_filter = [_this, 0] call BIS_fnc_param;
_unitsArray = [_this, 1, (if (isMultiplayer) then {playableUnits} else {switchableUnits})] call BIS_fnc_param;
_outputArray = [];
switch (typename _filter) do
{
case "CODE":
{
// Filter all playable units by comparing them with the code
{if (_x call _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "GROUP":
{
// Filter out all objects not in group
{if (_x in units _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "OBJECT":
{
// Result is only the array containing the object
_outputArray = [_filter];
};
case "SIDE":
{
// Filter out all objects not belonging to side
{if (side _x == _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "STRING":
{
// Filer out all objects not belonging to the faction
{if (faction _x == _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "ARRAY":
{
// Result is the input
_outputArray = _filter;
}
};
_outputArray;
#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKDESC;
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKNAME;
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
private _name = "";
private _task = _this select FHQ_TTIF_TASKNAME;
if (typename _task == "ARRAY") then
{
_name = _task select 0;
}
else
{
_name = _task;
};
_name;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
/* Might not be present */
private _res = "created";
if (count _this > FHQ_TTIF_TASKSTATE) then {
_res = _this select FHQ_TTIF_TASKSTATE;
} else {
if (count _this > FHQ_TTIF_TASKTARGET) then {
if (typename (_this select FHQ_TTIF_TASKTARGET) == "STRING") then {
_res = _this select FHQ_TTIF_TASKTARGET;
};
};
};
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
/* Might not be present */
private _res = "";
if (count _this > FHQ_TTIF_TASKTARGET) then {
_thing = _this select FHQ_TTIF_TASKTARGET;
/* A string means it's the initial state (unless starting with # or @), so if it's not, it's either
* a position (array) or target (object)
*/
switch (typename _thing) do {
case "ARRAY": {
_res = nil;
_res = _thing;
};
case "OBJECT": {
_res = nil;
_res = _thing;
};
case "CODE": {
_res = nil;
_res = call _thing;
};
case "STRING": {
_res = nil;
if (_thing find "#" == 0) exitWith {
private _parts = _thing select [1];
_res = call compile _parts ;
};
if (_thing find "@" == 0) exitWith {
private _parts = _thing select [1];
_res = getMarkerPos _parts;
};
_res = "";
};
};
};
_res;
#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKTITLE;
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
#define FHQ_TTIF_TASKTYPE 6
/* Might not be present */
private _res = "";
private _num = count _this;
/* It must be a string, and it must be the last one, so we're just checking if there's more than 4
* and the last one is a string that is not a target or a state
*/
if (_num > 4) then {
private _type = _this select (_num - 1);
if (typename _type == "STRING") then {
if (!(_type call FHQ_fnc_ttiIsTaskState) and (_type find "#" != 0) and (_type find "@" != 0)) then {
/* Last element is a string, but no position, and no state, so it must be a type */
_res = _type;
};
};
};
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKWP;
_res;private ["_x", "_res", "_test", "_inArray"];
_res = false;
_inArray = [_this, 1, []] call BIS_fnc_param;
_test = [_this, 0, []] call BIS_fnc_param;
{
if (_x select 0 == _inArray select 0 && ((_x select 1) select 0) == ((_inArray select 1) select 0)
&& ((_x select 1) select 1) == ((_inArray select 1) select 1)) exitWith {
_res = true;
};
} foreach _test;
_res; /* Internal function, called automatically */
FHQ_TT_subtaskPrefix = " > ";
FHQ_TTI_supressTaskHints = true;
FHQ_TTI_is_arma3 = true;
FHQ_TTI_version = productVersion select 2;
if (isClass (configfile >> "CfgAddons" >> "PreloadAddons" >> "A3")) then {
FHQ_TTI_is_arma3 = true;
};
if (isServer) then
{
FHQ_TTI_BriefingList = [];
FHQ_TTI_TaskList = [];
};
if (!isDedicated) then
{
FHQ_TTI_ClientTaskList = [];
if (isNil {player} || isNull player) then
{
FHQ_TTI_isJIPPlayer = true;
};
[] spawn
{
// Wait for join in progress
waitUntil {!isNil {player}};
waitUntil {!isNull player};
/* Wait until briefing is ready (on server).
* Note that we spawn this code, to cope with the possibility of having no briefing at all
*/
[] spawn {
waitUntil {!isNil "FHQ_TTI_briefing"};
FHQ_TTI_BriefingList call FHQ_fnc_ttiUpdateBriefingList;
"FHQ_TTI_BriefingList" addPublicVariableEventHandler {(_this select 1) call FHQ_fnc_ttiUpdateBriefingList};
};
// Wait until the task list is ready (on server)
waitUntil {!isNil "FHQ_TTI_tasks"};
FHQ_TTI_TaskList call FHQ_fnc_ttiUpdateTaskList;
"FHQ_TTI_TaskList" addPublicVariableEventHandler {(_this select 1) call FHQ_fnc_ttiUpdateTaskList};
FHQ_TTI_supressTaskHints = false;
};
};
/* Internal function */
private "_x";
private _filter = _this;
private _res = false;
switch (typename _filter) do
{
case "CODE":
{
_res = true;
};
case "GROUP":
{
_res = true;
};
case "OBJECT":
{
_res = true;
};
case "SIDE":
{
_res = true;
};
case "STRING":
{
_res = true;
};
case "ARRAY":
{
/* The complex case: If all elements are objects, then it's a filter */
private _nonObjects = 0;
{
if (typename _x != "OBJECT") then {
_nonObjects = _nonObjects + 1;
};
} foreach _filter;
if (_nonObjects == 0) then {
_res = true;
};
};
};
_res;/* Internal Function */
private _state = toLower _this;
private _res = false;
if (_state in ["succeeded", "failed", "canceled", "created", "assigned"]) then {
_res = true;
};
_res;/* Eden compatible mission briefing
* This function is called like
* [_value] call FHQ_fnc_ttiMissionBriefing;
*
* _value is an array of briefing blocks. Each block is an array in itself,
* with the following format:
* ["identifier", [ [FHQ_TT briefing entry],... ]]
*
* "identifier" is a string identifying a "block" of entries. Units can receive one
* such block, i.e. all briefing entries listed under the identifier will be given to
* the unit.
*/
missionNamespace setVariable ["FHQ_tt_MissionBriefing", param [0, []]]; /* Eden compatible mission tasks
* This function is called like
* [_value] call FHQ_fnc_ttiMissionTasks;
*
* _value is an array of tasks. Each entry is an identifier followed by
* a full FHQ TT task entry
*
*/
missionNamespace setVariable ["FHQ_tt_MissionTasks", param [0, []]]; /* PostInit function
* This function walks through all playable/switchable units and assigns tasks and briefings to them
*/
/* Briefings:
* FHQ_tt_MissionBriefing is a global variable that contains an array of briefing blocks.
* Each block has a unique ID and a list of entries.
*
* We process this by going through the briefing blocks first: For each entry, the units
* referencing the briefing are collected in an array, and
*/
if (!isServer) exitWith {};
private _briefings = missionNamespace getVariable ["FHQ_tt_MissionBriefing", []];
private _tasks = missionNamespace getVariable ["FHQ_tt_MissionTasks", []];
private _playable = (if (isMultiplayer) then {playableUnits} else {switchableUnits});
private _i = 0;
for [{_i = 0}, {_i < count _briefings}, {_i = _i + 1}] do
{
private _briefing = _briefings select _i;
private _id = _briefing select 0;
private _entry = _briefing select 1;
private _units = [];
{
if (tolower(_id) == tolower(_x getVariable ["FHQ_tt_UnitBriefing", ""])) then {
_units = _units + [_x];
};
} foreach _playable;
if (count _units != 0) then {
([_units] + _entry) call FHQ_fnc_ttAddBriefing;
};
};
for [{_i = 0}, {_i < count _tasks}, {_i = _i + 1}] do
{
private _task = _tasks select _i;
private _id = _task select 0;
private _entry = _task select 1;
private _units = [];
{
if (tolower(_id) in (_x getVariable ["FHQ_tt_UnitTasks", []])) then {
_units = _units + [_x];
};
} foreach _playable;
if (count _units != 0) then {
([_units] + [_entry]) call FHQ_fnc_ttAddTasks;
};
};
/* FHQ_fnc_ttIsTaskCompleted
*
* Check whether a task is canceled, successful or failed. Like all query functions, this can be called
* on any client as well as the server.
*
* _result = [_task] call FHQ_fnc_ttIsTaskCompleted;
*
* _task: Name of the task.
*
* Returns true or false if the task's state is considered a "completed" state, i.e.
* succeeded, canceled, or failed
*
*/
private "_result";
_result = (tolower(_this call FHQ_fnc_ttGetTaskState) in ["succeeded", "canceled", "failed"]);
_result;
/* FHQ_fnc_ttIsTaskSuccessful
*
* Check whether a task is ended successfully. This function can be called on the client as well as
* the server.
*
* _result = [_taskName] call FHQ_fnc_ttIsTaskSuccessful;
*/
private "_result";
_result = (tolower(_this call FHQ_fnc_ttGetTaskState) == "succeeded");
_result;
private ["_unitTaskList", "_name", "_res", "_current", "_i", "_checkName"];
_unitTaskList = [_this, 0] call BIS_fnc_param;
_name = [_this, 1] call BIS_fnc_param;
_res = -1;
for "_i" from 0 to count _unitTaskList - 1 do
{
_current = _unitTaskList select _i;
if (count _current == 2) then {
_checkName = (_current select 1) call FHQ_fnc_ttiGetTaskName; // Server list
} else {
_checkName = (_current select 2); // Client list
};
if (_checkName == _name) exitWith {
_res = _i;
};
} foreach _unitTaskList;
_res;/* Eden compatible mission briefing
* This function is called like
* [_unit, _value] call FHQ_fnc_ttiUnitBriefing;
*
* _unit is the unit that should receive the briefing, and _value
* denotes the briefing itself.
*/
private _unit = param [0, objNull];
private _value = param [1, ""];
_unit setVariable ["FHQ_tt_UnitBriefing", _value];/* Eden compatible mission tasks
* This function is called like
* [_unit, _value] call FHQ_fnc_ttiUnitTasks;
*
* _unit is the unit that should receive the briefing, and _value
* denotes the briefing itself.
*/
private _unit = param [0, objNull];
private _value = param [1, ""];
_unit setVariable ["FHQ_tt_UnitTasks", _value];private ["_i", "_idx", "_current", "_record", "_filter", "_units", "_x", "_briefing", "_list", "_existing", "_notify"];
_briefing = _this;
_notify = false;
{
_list = [];
for [{_i = 0}, {_i < count _briefing}, {_i = _i + 1}] do {
_current = _briefing select _i; // [_filter, [_section, _subject, _text]]
_filter = _current select 0;
_units = [_filter] call FHQ_fnc_ttiFilterUnits;
if (_x in _units) then {
_record = _current select 1;
_list = _list + [[_record select 0, [_record select 1, _record select 2]]];
};
};
/* Now add them in reverse order */
_existing = _x getVariable ["FHQ_TTI_ClientBriefingList", []];
for [{_i = count _list - 1}, {_i >= 0}, {_i = _i - 1}] do {
_current = _list select _i;
if (!([_existing, _current] call FHQ_fnc_ttiHasBriefingEntry)) then {
/* Check if the section exists and create it if necessary, then add the record */
if (!(_x diarySubjectExists (_current select 0))) then {
_x createDiarySubject [_current select 0, _current select 0];
};
_x createDiaryRecord [_current select 0, [(_current select 1) select 0, (_current select 1) select 1]];
if (player == _x && !FHQ_TTI_supressTaskHints) then
{
private "_title";
_title = _current select 0;
if (_title == "Diary") then {
if (FHQ_TTI_is_arma3) then {
_title = "Briefing";
} else {
_title = "Notes";
};
};
[format ["%1/%2", _title, (_current select 1) select 0], "newbriefing"] call FHQ_fnc_ttTaskHint;
};
};
};
_x setVariable ["FHQ_TTI_ClientBriefingList", _list]; // FIXME ?
} foreach (if (isMultiplayer) then {playableUnits} else {switchableUnits});private _tasks = _this;
private _i = 0;
{
private _list = [];
for [{_i = 0}, {_i < count _tasks}, {_i = _i + 1}] do {
private _current = _tasks select _i; // [_filter, [_section, _subject, _text]]
private _filter = _current select 0;
private _units = [_filter] call FHQ_fnc_ttiFilterUnits;
if (_x in _units) then {
_list = _list + [_current select 1];
};
};
/* Now add them in reverse order */
private _existing = _x getVariable ["FHQ_TTI_ClientTaskList", []];
if (FHQ_TTI_is_arma3) then {
for [{_i = 0}, {_i < count _list}, {_i = _i + 1}] do {
private _current = _list select _i;
_existing = [_current, _existing, _x] call FHQ_fnc_ttiCreateOrUpdateTask;
};
} else {
for [{_i = count _list - 1}, {_i >= 0}, {_i = _i - 1}] do {
private ["_current", "_task", "_name"];
private _current = _list select _i;
/* Check for a parent task. Since we add them reversed in Arma 2, we need
* to check if a parent task is "below" us
*/
private _task = _current call FHQ_fnc_ttiGetTaskId;
if (typename _task == "ARRAY") then {
/* It's a task with parent */
private _name = _task select 1;
private _idx = [_existing, _name] call FHQ_fnc_ttiTaskExists;
if (_idx == -1) then {
/* Doesn't exist... so go through it and create the task now */
private ["_j"];
for "_j" from 0 to count _list - 1 do {
private ["_entry", "_checkName"];
_entry = _list select _j;
_checkName = _entry call FHQ_fnc_ttiGetTaskName;
if (_checkName == _name) exitWith {
_existing = [_entry, _existing, _x] call FHQ_fnc_ttiCreateOrUpdateTask;
};
};
};
};
_existing = [_current, _existing, _x] call FHQ_fnc_ttiCreateOrUpdateTask;
};
};
_x setVariable ["FHQ_TTI_ClientTaskList", _existing];
} foreach (if (isMultiplayer) then {playableUnits} else {switchableUnits});/* FHQ_fnc_ttSetTaskState
*
* Set the state of the specified task to the specified state, and alert the player
* if necessary.
*
* NOTE: Server callable only. Calling this on a client does not have an effect
*
* Usage:
* [_task, _state] call FHQ_fnc_ttSetTaskState;
* _task: the task name defined with FHQ_fnc_ttAddTasks
* _state: One of "succeeded", "failed", "canceled", "created", "assigned"
*
*/
#define FHQ_TTIF_TASKSTATE 5
private ["_name", "_state", "_idx", "_record", "_entry"];
if (isServer) then {
_name = [_this, 0, "", [""]] call BIS_fnc_param;
_state = [_this, 1, "", [""]] call BIS_fnc_param;
_idx = [FHQ_TTI_TaskList, _name] call FHQ_fnc_ttiTaskExists;
if (_idx != -1) then {
_entry = FHQ_TTI_TaskList select _idx;
_record = _entry select 1;
_record set [FHQ_TTIF_TASKSTATE, _state];
_entry set [1, _record];
FHQ_TTI_TaskList set [_idx, _entry];
publicVariable "FHQ_TTI_TaskList";
if (!isDedicated) then {
FHQ_TTI_TaskList call FHQ_fnc_ttiUpdateTaskList;
};
};
};
/* FHQ_fnc_ttSetTaskStateAndNext
*
* Set the state of a given task to the given state, and select another task from a list of
* tasks which is not finished yet. The first task found will be set to assigned and a message will
* be shown to the player, if enabled.
*
* NOTE: Can only be called on the server
*
* Usage:
* [_task1, _state, _task2, ...] call FHQ_fnc_ttSetTaskStateAndNext;
*
* _task1: The task to set to _state
* _state: The state for _task1
* _task2 and following: The tasks are checked in turn for completion, and the first one not
* completed will be assigned.
*
* Example:
*
* ["taskGetVodka", "succeeded", "taskDrink", "taskBeMerry"] call FHQ_fnc_ttSetTaskStateAndNext;
*/
private "_i";
[_this select 0, _this select 1] call FHQ_fnc_ttSetTaskState;
for [ {_i = 2}, {_i < count _this}, {_i = _i + 1} ] do
{
if (!([_this select _i] call FHQ_fnc_ttIsTaskCompleted)) exitWith
{
[_this select _i, "assigned"] call FHQ_fnc_ttSetTaskState;
};
};
if (!FHQ_TTI_is_arma3) then
{
/* Arma 2 */
private ["_desc", "_state", "_color", "_icon", "_text"];
_desc = _this select 0;
_state = _this select 1;
_color = [1, 1, 1, 1];
_icon = "taskNew";
_text = "New Task";
switch (tolower(_state)) do
{
case "created":
{
_color = [1, 1, 1, 1];
_icon = "taskNew";
_text = localize "str_taskNew";
};
case "assigned":
{
_color = [1, 1, 1, 1];
_icon = "taskCurrent";
_text = localize "str_taskSetCurrent";
};
case "succeeded":
{
_color = [0.600000,0.839215,0.466666,1];
_icon = "taskDone";
_text = localize "str_taskAccomplished";
};
case "canceled":
{
_color = [0.75,0.75,0.75,1];
_icon = "taskFailed";
_text = localize "str_taskCancelled";
};
case "cancelled":
{
_color = [0.75,0.75,0.75,1];
_icon = "taskFailed";
_text = localize "str_taskCancelled";
};
case "failed":
{
_color = [0.972549,0.121568,0,1];
_icon = "taskFailed";
_text = localize "str_taskFailed";
};
case "newbriefing":
{
_color = [1, 1, 1, 1];
_icon = "taskCurrent";
_text = "Briefing updated";//localize "str_taskSetCurrent";
};
};
taskHint [format ["%1\n%2", _text, _desc], _color, _icon];
} else {
/* Arma 3 */
private ["_notifyTemplate", "_desc", "_state"];
_desc = [_this, 0, ""] call BIS_fnc_param;
_state = [_this, 1, "created"] call BIS_fnc_param;
_notifyTemplate = "TaskCreated";
switch (tolower _state) do
{
case "created":
{
_notifyTemplate = "TaskCreated";
};
case "assigned":
{
_notifyTemplate = "TaskAssigned";
};
case "succeeded":
{
_notifyTemplate = "TaskSucceeded";
};
case "canceled":
{
_notifyTemplate = "TaskCanceled";
};
case "cancelled":
{
_notifyTemplate = "TaskCanceled";
};
case "failed":
{
_notifyTemplate = "TaskFailed";
};
case "newbriefing":
{
_notifyTemplate = "TaskAssigned";
if (isClass (missionConfigFile >> "CfgNotifications" >> "NewBriefing")) then {
_notifyTemplate = "NewBriefing";
};
};
};
[_notifyTemplate, ["", _desc]] call BIS_fnc_showNotification;
};
/* FHQ_fnc_ttAddBriefing: Add a full briefing
*
* This functions receives an array as input. The elements of the input array
* are interpreted as follows:
* If the element is a two-element array consisting of two strings, the entry is
* interpreted as a new briefing topic. If the array has three strings, it's interpreted
* as a new briefing entry, with the first one being the general subject ("Diary" by default),
* and the two subsequent strings title and description.
* If the element is anything else, the following topics will only be presented to
* the units matching the element. For example, if the element is a group, the following
* entries are added to this group only.
*
* NOTE: The old hierarchical filtering is no longer supported. It wasn't that useful for
* real-world application and was posing severe problems with respawn missions.
*
* Example:
*
* [
* west,
* ["Mission", "Get some!"],
* ["Enemy Forces", "There's lots of ruskies around"],
* east,
* ["Mission", "Get those imperialistic americans"],
* ["Current Supply of Vodka", "Low"],
* {true},
* ["Credits", "Mission by", "Some Dude"],
* ["Credits", "Uses scripts by", "Some other dude
Yet another dude"]
* ] call FHQ_fnc_ttAddBriefing.
*
* The first two lines (Mission, Enemy Forces), are added under "Briefing" for west
* troops only, the second two lines (Mission, Current Supply of Vodka) only for east.
* The last two lines add two new entries "Mission by" and "Uses scripts by" into a new
* subject "Credits".
*
* NOTE: Do not over-use the additional subject feature. Briefing and all associated information
* should go to the default subject.
*
* Calling FHQ_TT_addBriefing with an already existing subject/title will add a new log entry
* if the text differs from the previous one.
*
* Notifications are shown after the initial briefing has been donwloaded by the clients, i.e.
* not at mission start, only when new briefing entries are added.
*/
private ["_currentFilter", "_i", "_current", "_x"];
_currentFilter = {true};
if (isServer) then {
/* Note: Server only code. Briefing entries must be added on the server, not on an
* individual client
*/
for [{_i = 0}, {_i < count _this}, {_i = _i + 1}] do {
_current = _this select _i;
if (_current call FHQ_fnc_ttiIsFilter) then {
_currentFilter = nil;
_currentFilter = _current;
} else {
/* It's a briefing entry. */
[_currentFilter, _current] call FHQ_fnc_ttiAddBriefingEntry;
};
};
publicVariable "FHQ_TTI_BriefingList";
if (!isDedicated) then {
FHQ_TTI_BriefingList call FHQ_fnc_ttiUpdateBriefingList;
};
FHQ_TTI_briefing = true;
publicVariable "FHQ_TTI_briefing";
};
/* FHQ_fnc_ttAddTasks: Add tasks to the mission
*
* Task are defined similar to briefing entries. The function accepts an array as input.
* Each entry is either a filter (see FHQ_TT_addBriefing), or a task description.
*
* A task description itself is an array and can be one of the following format:
* [_taskName, _longDescription, _shortDescription, _waypointDescription, _target, _initialState]
* [[_taskName, _parentTask], _longDescription, _shortDescription, _waypointDescription, _target, _initialState]
*
* Both _target and _initialState are optional and can be left out.
*
* o _taskName is a symbolic name that is invisible to the player.
* o _longDescription is a text describing the task.
* o _shortDescription is used as a headline for the task in the task list and on task hints
* o _waypointDescription is displayed on the waypoint on the map and in the 3d view (if enabled).
* o _target can be a position (three-element array) or an object. If either is given, the
* task waypoint is shown on the map an the 3d view. Objects that move also move
* the waypoint marker.
* o _initialState is the initial state of the task ("succeeded", "failed", "canceled",
* "created", or "assigned"). By default, if _initialState is ommited, the state is set
* to "created". If set to "assigned", the task is also automatically assigned to everyone
* that knows about it.
*
* Example:
*
* [
* west,
* ["taskBoard1", "Board your chopper", "Board your chopper", "BOARD", westHelo1, "assigned"],
* ["taskCAS", "Fly around", "Fly around", "CAS"],
* ["taskRetreat1", "Return to LZ", "Return to LZ", "RETREAT", getMarkerPos "markLZ"],
* "BLU_G_F",
* ["taskSecret", "Secret: Betray NATO for whatever reason", "Secret: Betray NATO", ""],
* [["taskSecret1", "taskSecret"], "Because they are idiots", "Idiots", ""],
* [["taskSecret2", "taskSecret"], "Because I am evil", "Evil", ""]
* ] call FHQ_fnc_ttAddTasks;
*
* The first three tasks are assigned at all playable west units. The second bunch of three tasks is
* only assigned to FIA units. The latter two, taskSecret1 and taskSecret2 are created as subtasks
* of the task "taskSecret" and will be displayed immediately below their respective parent.
*
* NOTE: This function can only be called on the server. Calling it anywhere else will have no effect.
*/
private _currentFilter = {true};
if (isServer) then {
/* Note: Server only code. Briefing entries must be added on the server, not on an
* individual client
*/
private _i = 0;
for [{_i = 0}, {_i < count _this}, {_i = _i + 1}] do {
private _current = _this select _i;
if (_current call FHQ_fnc_ttiIsFilter) then {
/* Must be a filter */
_currentFilter = nil;
_currentFilter = _current;
} else {
/* Task entry.
* Check if the task already exists. If not, construct a full
* task entry with all redundant information filled in for easier
* access later on
*/
private _name = _current call FHQ_fnc_ttiGetTaskName;
if (([FHQ_TTI_TaskList, _name] call FHQ_fnc_ttiTaskExists) == -1) then {
private _newTask =
[_current call FHQ_fnc_ttiGetTaskId,
_current call FHQ_fnc_ttiGetTaskDesc,
_current call FHQ_fnc_ttiGetTaskTitle,
_current call FHQ_fnc_ttiGetTaskWp,
_current call FHQ_fnc_ttiGetTaskTarget,
_current call FHQ_fnc_ttiGetTaskState,
_current call FHQ_fnc_ttiGetTaskType];
FHQ_TTI_TaskList = FHQ_TTI_TaskList + [[_currentFilter, _newTask]];
};
};
};
publicVariable "FHQ_TTI_TaskList";
if (!isDedicated) then {
FHQ_TTI_TaskList call FHQ_fnc_ttiUpdateTaskList;
};
FHQ_TTI_tasks = true;
publicVariable "FHQ_TTI_tasks";
};
/* FHQ_fnc_ttAreTasksCompleted
*
* Check for all tasks given whether they are considered completed. This function can
* be called on the client as well as the server.
*
* Usage
* _result = [_taskName1, _taskName2, ...] call FHQ_fnc_ttAreTasksCompleted
*
* _taskName1 and following: Task names that are tested for being completed. If any of them is not
* completed, the function returns false, else true.
*/
private ["_result", "_x"];
_result = true;
{
if (!(tolower ([_x] call FHQ_fnc_ttGetTaskState) in ["succeeded", "canceled", "failed"])) exitWith
{
_result = false;
};
} forEach _this;
_result;
/* FHQ_fnc_ttAreTasksSuccessful
*
* Check success for all tasks given. This function can be called on the client as well as
* the server.
*
* _result = [_taskName1, _taskName2, ...] call FHQ_fnc_ttAreTasksSuccessful
*/
private ["_result", "_x"];
_result = true;
{
if (tolower ([_x] call FHQ_fnc_ttGetTaskState) != "succeeded") exitWith
{
_result = false;
};
} forEach _this;
_result;
/* FHQ_fnc_ttGetAllTasksWithState
*
* Get all tasks with a given state. This function can be called on the client as well as
* the server.
*
* _taskList = [_state] call FHQ_fnc_ttGetAllTasksWithState;
*/
#define FHQ_TTIF_TASKSTATE 5
private ["_result", "_taskState"];
_result = [];
_taskState = [_this, 0, "", [""]] call BIS_fnc_param;
{
if (((_x select 1) select FHQ_TTIF_TASKSTATE) == _taskState) then
{
_result = _result + [(_x select 1) call FHQ_fnc_ttiGetTaskName];
};
} forEach FHQ_TTI_TaskList;
_result;
/* FHQ_fnc_ttGetTaskState
*
* Get the state of a given task. This function can be called on the client as well as
* the server.
*
* Usage:
* _state = [_task] call FHQ_fnc_ttGetTaskState;
*
* _task: The name of a task defined via FHQ_fnc_ttAddTask
*
* Returns the state of the task ("succeeded", "failed", "canceled", "created", "assigned"), or an empty
* string if the task does not exist
*/
#define FHQ_TTIF_TASKSTATE 5
private ["_res", "_name", "_idx", "_entry"];
_res = "";
_name = [_this, 0, "", [""]] call BIS_fnc_param;
_idx = [FHQ_TTI_TaskList, _name] call FHQ_fnc_ttiTaskExists;
if (_idx != -1) then {
_entry = FHQ_TTI_TaskList select _idx;
_res = (_entry select 1) select FHQ_TTIF_TASKSTATE;
};
_res;
/* Internal: Add a briefing record on the server
* parameters:
* select 0: Filter
* select 1: [_section, _subject, _text]
*/
private _record = [_this, 1] call BIS_fnc_param;
private _filter = [_this, 0] call BIS_fnc_param;
private _subject = "Diary";
private _topic = _record select 0;
private _text = _record select 1;
if (count _record == 3) then {
_subject = _record select 0;
_topic = _record select 1;
_text = _record select 2;
};
FHQ_TTI_BriefingList = FHQ_TTI_BriefingList + [[_filter, [_subject, _topic, _text]]];
private ["_current", "_existing", "_unit", "_name", "_state", "_idx", "_record", "_object", "_taskID",
"_parented"];
_current = [_this, 0] call BIS_fnc_param;
_existing = [_this, 1] call BIS_fnc_param;
_unit = [_this, 2] call BIS_fnc_param;
_name = _current call FHQ_fnc_ttiGetTaskName;
_state = _current call FHQ_fnc_ttiGetTaskState;
_parented = false;
_idx = [_existing, _name] call FHQ_fnc_ttiTaskExists;
if (_idx != -1) then {
_record = _existing select _idx;
if ((_record select 0) != _state) then {
/* Need to set new state */
_record set [0, _state];
if (_state == "assigned") then {
_unit setCurrentTask (_record select 1);
};
(_record select 1) setTaskState _state;
if (_unit == player && !FHQ_TTI_supressTaskHints) then
{
[_current call FHQ_fnc_ttiGetTaskTitle, _state] call FHQ_fnc_ttTaskHint;
};
/* Update the list */
_existing set [_idx, _record];
};
} else {
_taskID = _current call FHQ_fnc_ttiGetTaskId;
if (typename _taskID == "STRING") then {
_object = _unit createSimpleTask [_name];
} else {
_object = _unit createSimpleTask [_name, _unit getVariable format["FHQ_TT_taskname_%1", _taskID select 1]];
_parented = true;
};
if (!FHQ_TTI_is_arma3 && _parented) then {
_object setSimpleTaskDescription [_current call FHQ_fnc_ttiGetTaskDesc,
format ["%2%1", _current call FHQ_fnc_ttiGetTaskTitle, FHQ_TT_subtaskPrefix],
_current call FHQ_fnc_ttiGetTaskWp];
} else {
_object setSimpleTaskDescription [_current call FHQ_fnc_ttiGetTaskDesc,
_current call FHQ_fnc_ttiGetTaskTitle,
_current call FHQ_fnc_ttiGetTaskWp];
};
_target = _current call FHQ_fnc_ttiGetTaskTarget;
switch (typename _target) do
{
case "ARRAY": {
_object setSimpleTaskDestination _target;
};
case "OBJECT": {
_object setSimpleTaskTarget [_target, true];
};
};
private _taskType = _current call FHQ_fnc_ttiGetTaskType;
if (_taskType != "" && FHQ_TTI_version > 156) then {
[_object, _taskType] call compile "(_this select 0) setSimpleTaskType (_this select 1);"
};
_target = nil;
_object setTaskState _state;
if (tolower(_state) == "assigned") then
{
_unit setCurrentTask _object;
};
_unit setVariable [format["FHQ_TT_taskname_%1", _name], _object]; // FIXME: propagate through network ?
if (_unit == player && !FHQ_TTI_supressTaskHints) then
{
[_current call FHQ_fnc_ttiGetTaskTitle, _state] call FHQ_fnc_ttTaskHint;
};
_existing = _existing + [ [_state, _object, _name] ];
};
_existing;/* Internal function */
private ["_unitsArray", "_outputArray"];
_filter = [_this, 0] call BIS_fnc_param;
_unitsArray = [_this, 1, (if (isMultiplayer) then {playableUnits} else {switchableUnits})] call BIS_fnc_param;
_outputArray = [];
switch (typename _filter) do
{
case "CODE":
{
// Filter all playable units by comparing them with the code
{if (_x call _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "GROUP":
{
// Filter out all objects not in group
{if (_x in units _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "OBJECT":
{
// Result is only the array containing the object
_outputArray = [_filter];
};
case "SIDE":
{
// Filter out all objects not belonging to side
{if (side _x == _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "STRING":
{
// Filer out all objects not belonging to the faction
{if (faction _x == _filter) then {_outputArray = _outputArray + [_x];};} forEach _unitsArray;
};
case "ARRAY":
{
// Result is the input
_outputArray = _filter;
}
};
_outputArray;
#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKDESC;
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKNAME;
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
private _name = "";
private _task = _this select FHQ_TTIF_TASKNAME;
if (typename _task == "ARRAY") then
{
_name = _task select 0;
}
else
{
_name = _task;
};
_name;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
/* Might not be present */
private _res = "created";
if (count _this > FHQ_TTIF_TASKSTATE) then {
_res = _this select FHQ_TTIF_TASKSTATE;
} else {
if (count _this > FHQ_TTIF_TASKTARGET) then {
if (typename (_this select FHQ_TTIF_TASKTARGET) == "STRING") then {
_res = _this select FHQ_TTIF_TASKTARGET;
};
};
};
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
/* Might not be present */
private _res = "";
if (count _this > FHQ_TTIF_TASKTARGET) then {
_thing = _this select FHQ_TTIF_TASKTARGET;
/* A string means it's the initial state (unless starting with # or @), so if it's not, it's either
* a position (array) or target (object)
*/
switch (typename _thing) do {
case "ARRAY": {
_res = nil;
_res = _thing;
};
case "OBJECT": {
_res = nil;
_res = _thing;
};
case "CODE": {
_res = nil;
_res = call _thing;
};
case "STRING": {
_res = nil;
if (_thing find "#" == 0) exitWith {
private _parts = _thing select [1];
_res = call compile _parts ;
};
if (_thing find "@" == 0) exitWith {
private _parts = _thing select [1];
_res = getMarkerPos _parts;
};
_res = "";
};
};
};
_res;
#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKTITLE;
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
#define FHQ_TTIF_TASKTYPE 6
/* Might not be present */
private _res = "";
private _num = count _this;
/* It must be a string, and it must be the last one, so we're just checking if there's more than 4
* and the last one is a string that is not a target or a state
*/
if (_num > 4) then {
private _type = _this select (_num - 1);
if (typename _type == "STRING") then {
if (!(_type call FHQ_fnc_ttiIsTaskState) and (_type find "#" != 0) and (_type find "@" != 0)) then {
/* Last element is a string, but no position, and no state, so it must be a type */
_res = _type;
};
};
};
_res;#define FHQ_TTIF_TASKNAME 0
#define FHQ_TTIF_TASKDESC 1
#define FHQ_TTIF_TASKTITLE 2
#define FHQ_TTIF_TASKWP 3
#define FHQ_TTIF_TASKTARGET 4
#define FHQ_TTIF_TASKSTATE 5
_res = _this select FHQ_TTIF_TASKWP;
_res;private ["_x", "_res", "_test", "_inArray"];
_res = false;
_inArray = [_this, 1, []] call BIS_fnc_param;
_test = [_this, 0, []] call BIS_fnc_param;
{
if (_x select 0 == _inArray select 0 && ((_x select 1) select 0) == ((_inArray select 1) select 0)
&& ((_x select 1) select 1) == ((_inArray select 1) select 1)) exitWith {
_res = true;
};
} foreach _test;
_res; /* Internal function, called automatically */
FHQ_TT_subtaskPrefix = " > ";
FHQ_TTI_supressTaskHints = true;
FHQ_TTI_is_arma3 = true;
FHQ_TTI_version = productVersion select 2;
if (isClass (configfile >> "CfgAddons" >> "PreloadAddons" >> "A3")) then {
FHQ_TTI_is_arma3 = true;
};
if (isServer) then
{
FHQ_TTI_BriefingList = [];
FHQ_TTI_TaskList = [];
};
if (!isDedicated) then
{
FHQ_TTI_ClientTaskList = [];
if (isNil {player} || isNull player) then
{
FHQ_TTI_isJIPPlayer = true;
};
[] spawn
{
// Wait for join in progress
waitUntil {!isNil {player}};
waitUntil {!isNull player};
/* Wait until briefing is ready (on server).
* Note that we spawn this code, to cope with the possibility of having no briefing at all
*/
[] spawn {
waitUntil {!isNil "FHQ_TTI_briefing"};
FHQ_TTI_BriefingList call FHQ_fnc_ttiUpdateBriefingList;
"FHQ_TTI_BriefingList" addPublicVariableEventHandler {(_this select 1) call FHQ_fnc_ttiUpdateBriefingList};
};
// Wait until the task list is ready (on server)
waitUntil {!isNil "FHQ_TTI_tasks"};
FHQ_TTI_TaskList call FHQ_fnc_ttiUpdateTaskList;
"FHQ_TTI_TaskList" addPublicVariableEventHandler {(_this select 1) call FHQ_fnc_ttiUpdateTaskList};
FHQ_TTI_supressTaskHints = false;
};
};
/* Internal function */
private "_x";
private _filter = _this;
private _res = false;
switch (typename _filter) do
{
case "CODE":
{
_res = true;
};
case "GROUP":
{
_res = true;
};
case "OBJECT":
{
_res = true;
};
case "SIDE":
{
_res = true;
};
case "STRING":
{
_res = true;
};
case "ARRAY":
{
/* The complex case: If all elements are objects, then it's a filter */
private _nonObjects = 0;
{
if (typename _x != "OBJECT") then {
_nonObjects = _nonObjects + 1;
};
} foreach _filter;
if (_nonObjects == 0) then {
_res = true;
};
};
};
_res;/* Internal Function */
private _state = toLower _this;
private _res = false;
if (_state in ["succeeded", "failed", "canceled", "created", "assigned"]) then {
_res = true;
};
_res;/* Eden compatible mission briefing
* This function is called like
* [_value] call FHQ_fnc_ttiMissionBriefing;
*
* _value is an array of briefing blocks. Each block is an array in itself,
* with the following format:
* ["identifier", [ [FHQ_TT briefing entry],... ]]
*
* "identifier" is a string identifying a "block" of entries. Units can receive one
* such block, i.e. all briefing entries listed under the identifier will be given to
* the unit.
*/
missionNamespace setVariable ["FHQ_tt_MissionBriefing", param [0, []]]; /* Eden compatible mission tasks
* This function is called like
* [_value] call FHQ_fnc_ttiMissionTasks;
*
* _value is an array of tasks. Each entry is an identifier followed by
* a full FHQ TT task entry
*
*/
missionNamespace setVariable ["FHQ_tt_MissionTasks", param [0, []]]; /* PostInit function
* This function walks through all playable/switchable units and assigns tasks and briefings to them
*/
/* Briefings:
* FHQ_tt_MissionBriefing is a global variable that contains an array of briefing blocks.
* Each block has a unique ID and a list of entries.
*
* We process this by going through the briefing blocks first: For each entry, the units
* referencing the briefing are collected in an array, and
*/
if (!isServer) exitWith {};
private _briefings = missionNamespace getVariable ["FHQ_tt_MissionBriefing", []];
private _tasks = missionNamespace getVariable ["FHQ_tt_MissionTasks", []];
private _playable = (if (isMultiplayer) then {playableUnits} else {switchableUnits});
private _i = 0;
for [{_i = 0}, {_i < count _briefings}, {_i = _i + 1}] do
{
private _briefing = _briefings select _i;
private _id = _briefing select 0;
private _entry = _briefing select 1;
private _units = [];
{
if (tolower(_id) == tolower(_x getVariable ["FHQ_tt_UnitBriefing", ""])) then {
_units = _units + [_x];
};
} foreach _playable;
if (count _units != 0) then {
([_units] + _entry) call FHQ_fnc_ttAddBriefing;
};
};
for [{_i = 0}, {_i < count _tasks}, {_i = _i + 1}] do
{
private _task = _tasks select _i;
private _id = _task select 0;
private _entry = _task select 1;
private _units = [];
{
if (tolower(_id) in (_x getVariable ["FHQ_tt_UnitTasks", []])) then {
_units = _units + [_x];
};
} foreach _playable;
if (count _units != 0) then {
([_units] + [_entry]) call FHQ_fnc_ttAddTasks;
};
};
/* FHQ_fnc_ttIsTaskCompleted
*
* Check whether a task is canceled, successful or failed. Like all query functions, this can be called
* on any client as well as the server.
*
* _result = [_task] call FHQ_fnc_ttIsTaskCompleted;
*
* _task: Name of the task.
*
* Returns true or false if the task's state is considered a "completed" state, i.e.
* succeeded, canceled, or failed
*
*/
private "_result";
_result = (tolower(_this call FHQ_fnc_ttGetTaskState) in ["succeeded", "canceled", "failed"]);
_result;
/* FHQ_fnc_ttIsTaskSuccessful
*
* Check whether a task is ended successfully. This function can be called on the client as well as
* the server.
*
* _result = [_taskName] call FHQ_fnc_ttIsTaskSuccessful;
*/
private "_result";
_result = (tolower(_this call FHQ_fnc_ttGetTaskState) == "succeeded");
_result;
private ["_unitTaskList", "_name", "_res", "_current", "_i", "_checkName"];
_unitTaskList = [_this, 0] call BIS_fnc_param;
_name = [_this, 1] call BIS_fnc_param;
_res = -1;
for "_i" from 0 to count _unitTaskList - 1 do
{
_current = _unitTaskList select _i;
if (count _current == 2) then {
_checkName = (_current select 1) call FHQ_fnc_ttiGetTaskName; // Server list
} else {
_checkName = (_current select 2); // Client list
};
if (_checkName == _name) exitWith {
_res = _i;
};
} foreach _unitTaskList;
_res;/* Eden compatible mission briefing
* This function is called like
* [_unit, _value] call FHQ_fnc_ttiUnitBriefing;
*
* _unit is the unit that should receive the briefing, and _value
* denotes the briefing itself.
*/
private _unit = param [0, objNull];
private _value = param [1, ""];
_unit setVariable ["FHQ_tt_UnitBriefing", _value];/* Eden compatible mission tasks
* This function is called like
* [_unit, _value] call FHQ_fnc_ttiUnitTasks;
*
* _unit is the unit that should receive the briefing, and _value
* denotes the briefing itself.
*/
private _unit = param [0, objNull];
private _value = param [1, ""];
_unit setVariable ["FHQ_tt_UnitTasks", _value];private ["_i", "_idx", "_current", "_record", "_filter", "_units", "_x", "_briefing", "_list", "_existing", "_notify"];
_briefing = _this;
_notify = false;
{
_list = [];
for [{_i = 0}, {_i < count _briefing}, {_i = _i + 1}] do {
_current = _briefing select _i; // [_filter, [_section, _subject, _text]]
_filter = _current select 0;
_units = [_filter] call FHQ_fnc_ttiFilterUnits;
if (_x in _units) then {
_record = _current select 1;
_list = _list + [[_record select 0, [_record select 1, _record select 2]]];
};
};
/* Now add them in reverse order */
_existing = _x getVariable ["FHQ_TTI_ClientBriefingList", []];
for [{_i = count _list - 1}, {_i >= 0}, {_i = _i - 1}] do {
_current = _list select _i;
if (!([_existing, _current] call FHQ_fnc_ttiHasBriefingEntry)) then {
/* Check if the section exists and create it if necessary, then add the record */
if (!(_x diarySubjectExists (_current select 0))) then {
_x createDiarySubject [_current select 0, _current select 0];
};
_x createDiaryRecord [_current select 0, [(_current select 1) select 0, (_current select 1) select 1]];
if (player == _x && !FHQ_TTI_supressTaskHints) then
{
private "_title";
_title = _current select 0;
if (_title == "Diary") then {
if (FHQ_TTI_is_arma3) then {
_title = "Briefing";
} else {
_title = "Notes";
};
};
[format ["%1/%2", _title, (_current select 1) select 0], "newbriefing"] call FHQ_fnc_ttTaskHint;
};
};
};
_x setVariable ["FHQ_TTI_ClientBriefingList", _list]; // FIXME ?
} foreach (if (isMultiplayer) then {playableUnits} else {switchableUnits});private _tasks = _this;
private _i = 0;
{
private _list = [];
for [{_i = 0}, {_i < count _tasks}, {_i = _i + 1}] do {
private _current = _tasks select _i; // [_filter, [_section, _subject, _text]]
private _filter = _current select 0;
private _units = [_filter] call FHQ_fnc_ttiFilterUnits;
if (_x in _units) then {
_list = _list + [_current select 1];
};
};
/* Now add them in reverse order */
private _existing = _x getVariable ["FHQ_TTI_ClientTaskList", []];
if (FHQ_TTI_is_arma3) then {
for [{_i = 0}, {_i < count _list}, {_i = _i + 1}] do {
private _current = _list select _i;
_existing = [_current, _existing, _x] call FHQ_fnc_ttiCreateOrUpdateTask;
};
} else {
for [{_i = count _list - 1}, {_i >= 0}, {_i = _i - 1}] do {
private ["_current", "_task", "_name"];
private _current = _list select _i;
/* Check for a parent task. Since we add them reversed in Arma 2, we need
* to check if a parent task is "below" us
*/
private _task = _current call FHQ_fnc_ttiGetTaskId;
if (typename _task == "ARRAY") then {
/* It's a task with parent */
private _name = _task select 1;
private _idx = [_existing, _name] call FHQ_fnc_ttiTaskExists;
if (_idx == -1) then {
/* Doesn't exist... so go through it and create the task now */
private ["_j"];
for "_j" from 0 to count _list - 1 do {
private ["_entry", "_checkName"];
_entry = _list select _j;
_checkName = _entry call FHQ_fnc_ttiGetTaskName;
if (_checkName == _name) exitWith {
_existing = [_entry, _existing, _x] call FHQ_fnc_ttiCreateOrUpdateTask;
};
};
};
};
_existing = [_current, _existing, _x] call FHQ_fnc_ttiCreateOrUpdateTask;
};
};
_x setVariable ["FHQ_TTI_ClientTaskList", _existing];
} foreach (if (isMultiplayer) then {playableUnits} else {switchableUnits});/* FHQ_fnc_ttSetTaskState
*
* Set the state of the specified task to the specified state, and alert the player
* if necessary.
*
* NOTE: Server callable only. Calling this on a client does not have an effect
*
* Usage:
* [_task, _state] call FHQ_fnc_ttSetTaskState;
* _task: the task name defined with FHQ_fnc_ttAddTasks
* _state: One of "succeeded", "failed", "canceled", "created", "assigned"
*
*/
#define FHQ_TTIF_TASKSTATE 5
private ["_name", "_state", "_idx", "_record", "_entry"];
if (isServer) then {
_name = [_this, 0, "", [""]] call BIS_fnc_param;
_state = [_this, 1, "", [""]] call BIS_fnc_param;
_idx = [FHQ_TTI_TaskList, _name] call FHQ_fnc_ttiTaskExists;
if (_idx != -1) then {
_entry = FHQ_TTI_TaskList select _idx;
_record = _entry select 1;
_record set [FHQ_TTIF_TASKSTATE, _state];
_entry set [1, _record];
FHQ_TTI_TaskList set [_idx, _entry];
publicVariable "FHQ_TTI_TaskList";
if (!isDedicated) then {
FHQ_TTI_TaskList call FHQ_fnc_ttiUpdateTaskList;
};
};
};
/* FHQ_fnc_ttSetTaskStateAndNext
*
* Set the state of a given task to the given state, and select another task from a list of
* tasks which is not finished yet. The first task found will be set to assigned and a message will
* be shown to the player, if enabled.
*
* NOTE: Can only be called on the server
*
* Usage:
* [_task1, _state, _task2, ...] call FHQ_fnc_ttSetTaskStateAndNext;
*
* _task1: The task to set to _state
* _state: The state for _task1
* _task2 and following: The tasks are checked in turn for completion, and the first one not
* completed will be assigned.
*
* Example:
*
* ["taskGetVodka", "succeeded", "taskDrink", "taskBeMerry"] call FHQ_fnc_ttSetTaskStateAndNext;
*/
private "_i";
[_this select 0, _this select 1] call FHQ_fnc_ttSetTaskState;
for [ {_i = 2}, {_i < count _this}, {_i = _i + 1} ] do
{
if (!([_this select _i] call FHQ_fnc_ttIsTaskCompleted)) exitWith
{
[_this select _i, "assigned"] call FHQ_fnc_ttSetTaskState;
};
};
if (!FHQ_TTI_is_arma3) then
{
/* Arma 2 */
private ["_desc", "_state", "_color", "_icon", "_text"];
_desc = _this select 0;
_state = _this select 1;
_color = [1, 1, 1, 1];
_icon = "taskNew";
_text = "New Task";
switch (tolower(_state)) do
{
case "created":
{
_color = [1, 1, 1, 1];
_icon = "taskNew";
_text = localize "str_taskNew";
};
case "assigned":
{
_color = [1, 1, 1, 1];
_icon = "taskCurrent";
_text = localize "str_taskSetCurrent";
};
case "succeeded":
{
_color = [0.600000,0.839215,0.466666,1];
_icon = "taskDone";
_text = localize "str_taskAccomplished";
};
case "canceled":
{
_color = [0.75,0.75,0.75,1];
_icon = "taskFailed";
_text = localize "str_taskCancelled";
};
case "cancelled":
{
_color = [0.75,0.75,0.75,1];
_icon = "taskFailed";
_text = localize "str_taskCancelled";
};
case "failed":
{
_color = [0.972549,0.121568,0,1];
_icon = "taskFailed";
_text = localize "str_taskFailed";
};
case "newbriefing":
{
_color = [1, 1, 1, 1];
_icon = "taskCurrent";
_text = "Briefing updated";//localize "str_taskSetCurrent";
};
};
taskHint [format ["%1\n%2", _text, _desc], _color, _icon];
} else {
/* Arma 3 */
private ["_notifyTemplate", "_desc", "_state"];
_desc = [_this, 0, ""] call BIS_fnc_param;
_state = [_this, 1, "created"] call BIS_fnc_param;
_notifyTemplate = "TaskCreated";
switch (tolower _state) do
{
case "created":
{
_notifyTemplate = "TaskCreated";
};
case "assigned":
{
_notifyTemplate = "TaskAssigned";
};
case "succeeded":
{
_notifyTemplate = "TaskSucceeded";
};
case "canceled":
{
_notifyTemplate = "TaskCanceled";
};
case "cancelled":
{
_notifyTemplate = "TaskCanceled";
};
case "failed":
{
_notifyTemplate = "TaskFailed";
};
case "newbriefing":
{
_notifyTemplate = "TaskAssigned";
if (isClass (missionConfigFile >> "CfgNotifications" >> "NewBriefing")) then {
_notifyTemplate = "NewBriefing";
};
};
};
[_notifyTemplate, ["", _desc]] call BIS_fnc_showNotification;
};/* Create an extraction for the given group, spawning a vehicle at one position and pick up the group at another.
* Parameters:
* _this select 0: Group to extract, or array of units
* _this select 1: Class name of extraction vehicle
* _this select 2: Position to spawn at
* _this select 3: Position to pick up at
* _this select 4: Touch down ?
* _this select 5: (optional string) Code to run after spawning the vehicle
* _this select 6: (optional string) Code to run when chopper has reached the extraction wp
* _this select 7: (optional string) Code to run when group is in chopper
*/
if (!isServer) exitWith {/* Server only */};
private ["_group", "_vehicle", "_spawnPos", "_pickupPos", "_afterSpawn",
"_wpReach", "_inChopper", "_spawnVec", "_type", "_az", "_tmpName",
"_extGrp", "_wp", "_touchDown", "_heliH", "_cnt", "_side", "_units"];
_group = _this select 0;
_vehicle = _this select 1;
_spawnPos = _this select 2;
_pickupPos = _this select 3;
_touchDown = _this select 4;
_side = west;
if (tolower (typeName _group) == "array") then
{
_side = side (_group select 0);
_units = _group;
} else {
_side = side leader _group;
_units = units _group;
};
_afterSpawn = {};
_wpReach = "";
_inChopper = {};
if ((count _this) > 4) then {
_afterSpawn = compile (_this select 5);
};
if ((count _this) > 5) then {
_wpReach = _this select 6;
};
if ((count _this) > 6) then {
_inChopper = compile (_this select 7);
};
/* Make sure we start in the air when we're a flyer */
_type = getText(configFile >> "CfgVehicles" >> _vehicle >> "simulation");
if (_type in ["airplane", "helicopter"]) then {
if ((count _spawnPos) == 2 || (_spawnPos select 2) < 10) then {
_spawnPos set [2, 50];
};
};
_az = [_spawnPos, _pickupPos] call BIS_fnc_dirTo;
_spawnVec = [_spawnPos, _az, _vehicle, _side] call BIS_fnc_spawnVehicle;
_extGrp = _spawnVec select 2;
_extGrp call _afterSpawn;
_heliH = "HeliHEmpty" createVehicle _pickupPos;
if (!_touchDown) then {
deleteVehicle _heliH;
};
/* Create a temporary name that is used as a global variable to allow multiple extractions */
_tmpName = format["FHQ_Extract_%1", floor (time*1000)];
missionNamespace setVariable [_tmpName, _spawnVec select 0];
_wp = _extGrp addWaypoint [_pickupPos, 0];
_wp setWaypointType "LOAD";
_wp setWaypointStatements ["true", format["(missionNamespace getVariable ""%1"") land ""GET IN""; %2", _tmpName, _wpReach]];
_cnt = {alive _x} count _units;
while {_cnt != ({_x in (_spawnVec select 0)} count _units)} do {
{
waitUntil {(vehicle _x) == _spawnVec select 0};
} forEach _units;
};
(_spawnVec select 0) call _inChopper;
if (_touchDown) then {
deleteVehicle _heliH;
};
_wp = _extGrp addWaypoint [_spawnPos, 0];
_wp setWaypointType "MOVE"; raP version 5 EditorData addons K CUP_Creatures_Military_USMC CUP_Weapons_AmmoBoxes CUP_WarfareBuildings CUP_StandaloneTerrains_Core_Faction A3_Structures_F_Mil_Helipads A3_Structures_F_Heli_Items_Airport CUP_AirVehciles_UH1Y CUP_Vehicles_ACE_compat CUP_AirVehicles_MH60S CUP_AirVehicles_CH53E CUP_Creatures_People_Civil_Russia A3_Weapons_F CUP_Creatures_People_Civil_Chernarus A3_Weapons_F_Items ace_medical A3_Characters_F ace_goggles ace_common ace_flashsuppressors ace_huntir ace_mx2a ace_parachute A3_Structures_F_Exp_Military_ContainerBases A3_Structures_F_Exp_Military_Barracks_01 rhs_c_a2port_air A3_Air_F_Heli_Light_01 CUP_WheeledVehicles_Ural CUP_WheeledVehicles_UAZ A3_Structures_F_Exp_Military_Fortifications CUP_WheeledVehicles_Datsun A3_Soft_F_Quadbike_01 A3_Characters_F_Exp_Civil cba_modules A3_Weapons_F_Ammoboxes ace_rearm ace_dragging A3_Structures_F_EPA_Civ_Constructions CUP_CAStructures_Misc_Powerlines CUP_TrackedVehicles_T72 CUP_TrackedVehicles_T55 A3_Structures_F_Furniture A3_Structures_F_Civ_InfoBoards CUP_Misc_e_Config CUP_Editor_Buildings_Config CUP_Editor_Structures_Config CUP_CAStructures_E_Misc_Misc_Interier CUP_CAMisc A3_Characters_F_Exp A3_Weapons_F_Exp_Rifles_CTAR ace_realisticnames A3_Weapons_F_Exp CUP_Weapons_West_Attachments ace_ballistics A3_Weapons_F_Pistols_Rook40 ace_smallarms ace_optics A3_Characters_F_Exp_Headgear A3_Characters_F_Exp_Vests ace_attach ace_chemlights A3_Weapons_F_Exp_Rifles_CTARS A3_Weapons_F_Acc ace_scopes A3_Weapons_F_Exp_Launchers_RPG32 CUP_AirVehicles_UH1H A3_Soft_F_Exp_LSV_02 CUP_Creatures_Military_Taki A3_Modules_F_Intel A3_Ui_F A3_Modules_F_Supports CUP_AirVehicles_C130J ace_interaction ace_cargo A3_Modules_F_Curator_Curator A3_Data_F_Curator_Virtual AddonsMetaData DynamicSimulation 3# randomSeed ='e ScenarioData # CustomAttributes # Mission % moveGridStep ?angleGridStep
>scaleGridStep ?autoGroupingDist Atoggles ItemIDProvider 5 MarkerIDProvider H Camera [ nextID b H nextID [ pos JO
ECOMFdir 5>
y>up (>?l>!8 ?aside ɲ$? U D List 3# =items <