The Mission API contains all the code to manage, initialize, and complete missions.
A mission is a shared object
A mission is a shared and persistent data structure (using the dictionary API)
that has a type
(e.g. kill_officer
), a status
(e.g. available
), and other properties.
When a mission starts (fnc_execute
), a spawn is initialized.
The actual states of the missions are defined in spawns
, and the spawn follows these states.
Every outcome (success or fail) of a mission is defined in fnc__getFailData
and
fnc__getSuccessData
.
Each mission is defined by a set of states (e.g. "initialize"
, "wait_to_deliver"
)
and functions that execute those states.
To start the mission "kill_officer"
in city _cityName
, use
// create and save it persistently
["kill_officer", _cityName] call AS_mission_fnc_add;
// spawn it
"kill_officer" call AS_mission_fnc_activate;
The mission is deleted automatically once the it completed (successfully or not).
Follow the following steps:
-
decide on a unique name for the mission type (
name
). -
Create a file in
spawns
calledfnc_[name].sqf
, which declares 2 global arrays,AS_mission_[name]_states
andAS_mission_[name]_state_functions
and populate it with functions. Make sure the functions store the state of the mission in the end. Check existing examples for inspiration. -
Add the outcomes of the mission in
fnc__getFailData
andfnc__getSuccessData
. -
Add the mission to the
fnc_spawn_states
as the others. -
Add conditions for the mission to be available to
fnc_updateAvailable
-
Add the
fnc_[name].sqf
to thecfgFunctions.hpp
as the others.