API for managing missions and objectives.
properties
.addObjective(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 = failed, undefined/null = in progress, true = completed
.onCompleted() // triggered when mission is completed
.onFailed() // triggered when mission failed
objective descriptor object
Property | Type | Mandatory | Notes | API Ver |
---|---|---|---|---|
id | String | id of the task, used when updating task, etc. | ||
title | String | used when displaying objectives to user via console | ||
tasks | Number | number of tasks required to complete the objective must be >= 1 default: 1 | ||
optional | Boolean | is this objective optional?
default: false | ||
hidden | Boolean | is this objective hidden?
default: false when hidden, it will only be listed in status reports if the game is in cheat mode | ||
enabled | Boolean | is the objective enabled?
default: if requires specified, defaults to false, if requires not specified defaults to true note: to change value call Mission.enableObjective(id) | ||
requires | 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) | ||
enables | Array of String Null | optionally specify a list of objectives to enable when this objective is achieved default: null (don't enable anything) | ||
onUpdate | Function | 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) | ||
onDone | Function | a function to call when the objective is achieved (all tasks done) same params as onUpdate | ||
onEnable | Function | a function to call when the objective is enabled or disabled params: id, config, enabled (true or false), data |