Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

API for managing missions and their 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 =  

Mission

.status – true = mission successful, false = mission failed, undefined/null = in progress

...

.onCompleted() // triggered when mission is completed

...

(default)

.timeLimit – get/set time limit, null = no time limit

.onTimeout() – triggered when mission timer runs out

.onSuccess() – triggered when all mandatory objectives achieved

.onFailure() – 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

...

.objective(obj) 

.objectives[]

.<number> = objectiveIDs

.<objectiveID> = objective object

.id – string

.title – string

.status – true = objective achieved, false = objective failed, undefined/null = in progress (default)

.tasks – total number of tasks

.done – number of tasks completed

.optional – objective optional? true/false (default: false)

.hidden – objective hidden? true/false (default: false)

.enabled – objective enabled? true/false (default: true)

.requires – array of prerequisite objectives

.enables – array of objectives to enable when on success

.onProgress() – triggered when done changes

.onSuccess()

.onFailure()

.onEnable()