API for managing missions and their objectives.
properties
.
addObjectiveMission(objectDescriptorObj)
.enableObjective(objectiveID) // enable objective
.disableObective(objectiveID) // disable objective
.achieveObjective(objectiveID) // force an objective to be achieved
.isObjectiveAchieved(objectiveID) // true =
.isComplete() // checks if all mandatory objectives are done. false = settings) – optionally use settings obj to set one or more top-level properties (causes objectives to be cleared)
.name – name of mission (string)
.date – date on which the mission starts (date object)
.id – mission id (string)
.labels – a list of labels that the mission relies on (each one must exist in labels.ini)
.status – true = mission successful, false = mission failed, undefined/null = in progress
...
.onCompleted() // triggered when mission is completed
.onFailed() // triggered when mission failed
objective descriptor object
...
number of tasks required to complete the objective
must be >= 1
default: 1
...
is this objective optional?
- true – it's optional
- false – it's mandatory, you can't win the mission without completing it
default: false
...
is this objective hidden?
- true – yes, it's hidden
- false – no, it's visible to users
default: false
when hidden, it will only be listed in status reports if the game is in cheat mode
...
is the objective enabled?
- true – yes, it's enabled and can be achieved
- false – no, it's disabled and cannot be achieved
default: if requires specified, defaults to false, if requires not specified defaults to true
note: to change value call Mission.enableObjective(id)
...
Array of String
Null
...
optionally specify a list of other objectives (by their ids) that must be completed before this objective is enabled
default: null (don't require anything)
...
Array of String
Null
...
optionally specify a list of objectives to enable when this objective is achieved
default: null (don't enable anything)
...
a function to call whenever the objective progress is updated, except when the object is achieved in which case onDone() gets called (see below)
parameters: id, config (the objective descriptor object), data (passed in from updating script)
...
a function to call when the objective is achieved (all tasks done)
same params as onUpdate
...
a function to call when the objective is enabled or disabled
params: id, config, enabled (true or false), data
...
(default: undefined)
.timeLimit – get/set time limit, 0 = timed out, any other falsey = no time limit
.countDown – object with numeric refs (times in seconds until 0) and string values (audio files to play)
.onTimeout() – triggered when mission timer runs out
.start() – start the mission
.onStart() – triggered when mission starts
.successful() – finish the mission successfully
.failed() – finish the mission as failed
.onFinish(success) – triggered when mission successful
.objective(obj) – add an objective
.progress – number of mandatory objectives completed
.objectives[]
.<number> = objectiveIDs
.<objectiveID> = objective object
.title – string
.type – see constants
.id – string
.status – true = objective achieved, false = objective failed, undefined/null = in progress (default)
.struct – array of structures required to complete objective (auto-sets .tasks to num structures)
.tasks – total number of tasks
.progress – number of tasks completed
.inc([data]) – increment progress, optionally pass in data for event handler
.required – mandatory objective? true/false (default: true)
.hidden – objective hidden? true/false (default: false)
.enabled – objective enabled? true/false (default: true) – cannot progress objective while disbled
.requires – array of prerequisite objectives
.enables – array of objectives to enable when on success
.onProgress() – triggered when done changes
.onCompleted() – triggered when the objective is completed
.onFailed() – triggered when the objective is failed
.onEnabled() – triggered when the objective is enabled
.onDisabled() – triggered when the objective is disabled
Constants
Mission.PRIMARY_OBJECTIVE
Mission.SECONDARY_OBJECTIVE
Mission.TERTIARY_OBJECTIVE – defaults required:false
Mission.SECRET_OBJECTIVE – defaults required:false, hidden:true