Cabal Common Library Doc MissionHandling

From Elite Wiki
Revision as of 22:49, 29 May 2012 by Svengali (talk | contribs) (Overview)

Overview

Part of the Cabal_Common_Library.

The script handles incoming data from worldScripts to coordinate mission offerings based on tokens in system descriptions. OXPs can register on startUp and the script calls back whenever the conditions are matched.

var a = ["boring",{chance:0.1,gov:[1],name:"myOXP",func:"callback"}];

worldScripts.Cabal_Common_MissionHandling.mPool.push(a);

If OXPs have inserted data, the checks are done on shipWillExitWitchspace (early flag), shipExitedWitchspace, shipWillLaunchFromStation (early flag) and shipLaunchedFromStation.

Inserted object

The array must hold two entries.

token
String. Main condition to start further checks.
actions
Object. Contains the conditions and handling functionality.


Required actions properties:

name
String. Script name.
func
String. Functionname for callback.

Optional actions properties:

chance
Number. Compared against Math.random(), so should be in range 0...1.
early
Boolean. Process on shipWillLaunchFromStation and shipWillExitWitchspace. Otherwise on shipLaunchedFromStation and shipExitedWitchspace.
exToken
String. Don't handle if token found. E.g. "Navy".
gal
Array. galaxyNumber. E.g. [1,4].
gov
Array. system.government. E.g. [2,3,4].
ID
Array. system.ID. E.g. [2,45,127,234].
incOXP
Array. List of incompatible OXP names. If detected, object will be skipped.
mutalEx
Number. Mute group. Default 0.
seeds
Array. Scrambled IDs.


Callback

If the conditions are matched the script calls the specified function with the token as argument. The OXP can do further checks there and should return true or false. If it returns true and mutalEx was specified no callback for a OXP with the same group is processed.

Additionally the script sets a property runningMission to true to give other OXPs a clue about it. If this property gets set to true by other OXPs no further checks are processed.


Properties

runningMission
Boolean. If set no further checks are processed. Reset on startUp and shipWillExitWitchspace.
binSearch
Object. Search tree that holds the inserted data.