Scripting in Soil enables you to add extra functionality to your maps
or entire gamemodes in your dataset. To add script to your map, simply create
file called "<mapname>.script" inside map folder. You can also create
general purpose script for scenario or multiplayer that will be used if map
doesn't have its own script. To do this, create "scenario.script" or "multiplayer.script"
in "scripts" folder in your dataset. You can start by copying "template.script"
from "common" dataset's "scripts" folder.
Below is documentation of interfaces exposed to scripts. As a final quick note
on scripting language, keep in mind that all arrays and indices start from zero!
Therefore a correct way to check for boundary condition is index < numberOfElements
You can check your script's syntax using "script_validator.exe". Simply drag and drop
your script file on the "script_validator.exe" to open it. This will also create
logs next to your script. Those can be deleted.
Following classes are exposed to the script. vec3 is a simple
3D vector available in script as "value" type. All others are "reference" types
and new instances cannot be created inside script. All except EngineInterface
can be stored as global variables. Following are class hierarchies shown as class
inheritance Base class > Derived class.
There is implicit casting from derived classes to base classes. That means that
if you have reference to class, you can access properties and methods of its
base classes. Remember that inheritance is transitive, so you can access methods
of Targetable through reference to Debris
If you have reference to base class and want to access methods of derived class
you must perform explicit cast. To determine what class object is, you
use Targetable's method getObjectType(). Example:
You have Targetable@ thing; and calling thing.getObjectType() returns
TYPE_SHIP. Now you can cast to Ship like this:
Ship@ thing_as_ship = cast<Ship>(thing);.
In this case, you could also cast to Object@. It is completely vital that
you always check if you can perform cast before doing so. If possible, avoid at all.
Method | Description |
int preinitiateRemoveObject(Object@ object) |
This function is called before even initiate. Return non-zero if object should be removed. This should be used for adjusting difficulty, since script cannot erase objects at will |
int initiate() |
This function is called before first step. Returns number of steps that script wishes to simulate before entering the mission. void step() is called during these as normal, only player doesn't see anything |
void step() |
Called at the end of each game step. Game simulates STEPS_PER_SECOND steps per in-game second |
string onMissionEnd() |
Called after last step when exiting map by script (not player action like returning to main menu or restarting) by calling EngineInterface.endMission(). Returns a name of map that should load after this. Object pools and persistent data will be available in the next map. |
string getObjectives(uint isEscMenu) |
Returns string with writen objectives. Any "\n" will be converted to new line. If isEscMenu is non-zero, message is intended for escape menu. Technically, you don't need to make difference |
bool briefing() |
Returns true if briefing phase should end. If mission doesn't have briefing, just return true. This function is called exactly on step number returned by initiate. Game does not run during this phase, but soil.stepNumber is still increased as normally so you can track time. Once briefing phase is over, soil.stepNumber is reset to number of presimulated frames |
void onObjectCreated(Object@ object, uint warpedIn) |
Executes after step for all objects that were added to map on that step. warpedIn is non-zero if object was added by warping in. If ship warped in, it cannot receive orders or be targeted until it finishes warping. This takes EngineInterface.warpTime (in seconds). |
void onObjectDestroyed(Object@ object) |
Executes after step for all objects that were destroyed on that step. You must remove all references to this object in your script. At this point, objects that were destroyed are no longer accessible through functions EngineInterface.getAll and others. So e.g. you can check if this was last ship destroyed with some tag byt checking if there are 0 ships with that tag left. |
void onObjectWarpout(Ship@ ship) |
Same as above, but for ships that warped out. If ship warped out, onObjectDestroyed is not called |
void onFighterDestroyed(Fighter@ fighter) |
Same as above, but for fighters. Fighters are kept in separate list to all other objects |
void onButtonPressed(Player@ player, string id) |
Called at the end of step some time later after player pressed button added with id by script. player is here because of multiplayer scripts to identify who pressed what button, so games will be synchronized. Button press is using same mechanism as orders, so there will be delay a few frames between actual button press and this callback being executed |
void onTextInput(Player@ player, string id, string value) |
Called at the end of step some time later after player confirms input added with id by script. |
void onScriptEvent(Player@ player, string payload) |
Called at the end of step some time later after script created the event. Same mechanisms as for button presses apply |
bool onKeyPressed(int key, bool ctrl, bool alt, bool shift) |
Called when keyboard key is pressed. As this is local to player, only use this for non-game-altering script, or only emit script events, so the actions happens in script event processing - being recorded in replays and happening for all players in multiplayer. Return true to release the key so it isn't used again in next step, or as any other hotkey |
void logScript(string message) |
Writes a message to script log (and to console) |
string int2str(int value) |
Converts integer value to string |
string int2str(uint value) |
Converts unsigned integer value to string |
string flt2str(float value, int numDecimals, bool fixedDecimals) |
Converts float value to string, with maximum of numDecimals. If fixedDecimals, decimals are always there, e.g "1.000" |
int str2int(string integerAsString) |
Tries to read an integer value from string |
float str2flt(string floatAsString) |
Tries to read a float value from string |
bool str2bool(string boolAsString) |
Tries to read a bool value from string |
uint randomUInt(uint count) |
Generates a random number between 0 and count (not including). E.g. "randomUInt(4)" can generate numbers 0, 1, 2, 3. This generator is same as used for game logic, use this if you want to randomly generate something that will affect game. If you'll use ASYNC version, replays or multiplayer won't work correctly |
uint randomUIntASYNC(uint count) |
Same as above, but uses random number generator independent of game logic. Use this for things that don't affect game, e.g. UI for one of players in multiplayer. If you use this for anything that alters the game in any way, replays won't work correctly and multiplayer will desync. |
| |
Method | Description |
ShipType getShipType() const |
|
const ShipStat@ getStat() const |
|
string getFullDisplayName() const |
Same as function on ShipStat |
OrderType getOrder() const |
Returns current order assigned to this ship. If it has no orders, returns SHIP_ORDER_NONE |
AbilityType getOrderAbility() const |
Returns ability ordered if ship order is SHIP_ORDER_ABILITY_CAST. For non-cast abilities, see Ship.hasActiveAbility |
Object@ getTarget() const |
Returns target related to current order. If ship has no order and it turns itself towards nearby enemy or resource, this method still returns null because it is not target of player's order |
vec3 getDestination() const |
Returns position related to player's order. Has meaningful value only if order is not SHIP_ORDER_NONE |
float getFiringDistance() const |
Same method as on ShipStat |
void setDisarmedStatus(bool disarmed) |
If disarmed is set to true, turrets from this ship are removed |
bool getDisarmedStatus() const |
|
bool canPerformOrder(OrderType order, const Object@ target) |
Returns true if this ship can do order of type order. If target is not null, it is additionally check if given order can be performed on this target (e.g. ship that can perform SHIP_ORDER_ATTACK will still return false if target is friendly) |
bool isInoperable() |
Returns true if ship can operate (not scaffolded or exploding) |
bool isScaffolded() |
Returns true if any object has scaffold on it (being repaired or scrapped) |
bool isUnderConstruction() |
Returns true if ship is currently being built by shipyard |
bool isBeingScrapped() |
Returns true if ship is currently being scrapped by shipyard |
float getRepairCostTotal() |
Returns amount of resources it will take to repair this ship |
float getScrapValue() |
Returns amount of resources that will be refunded by scrapping this ship by shipyard |
uint getConstructionQueueLength() |
Returns number of ships that are in build queue of this ship. It does not include ships already being built |
uint getConstructionNormalQueueLength() |
Returns number of ships that are in build queue of this ship. It does not include ships already being built |
uint getConstructionPriorityQueueLength() |
Returns number of ships that are in priority build queue of this ship. It does not include ships already being built |
bool canBuildShip(const ShipStat@ stat, array<string>@ blockedByResearch = null) |
|
ShipStatus getShipStatus() |
|
float getShieldHitpoints() |
|
float getShieldMaxHitpoints() |
|
void setShieldHitpoints(float) |
|
float getCargoCapacity() const |
|
float getCargoResources() const |
|
float getCargoCrystals() const |
|
float getEnergy() const |
|
float getEnergyCapacity() const |
|
int getMaxPassengers() const |
Returns max number of "crew" in this ships crew quarters. Crew is used to build new ships |
int getPassengers() const |
|
uint getNumFighterGroups() const |
|
uint getRemainingFighterGroupSpace() const |
|
uint getNumSubsystems() |
Returns number of subystems this ship has |
Subsystem@ getSubsystem(uint index) |
Returns subsystem at index, or null if index is out of range |
Subsystem@ getSubsystemByType(SubsystemType type) |
Returns first subsystem of specified type, or null if there isn't one |
bool canCastAbilityOn(AbilityType type, Object@ target) |
Returns true if this ship can cast ability of type, this also includes if ship has activation energy cost. If target is not null it also tests if ability can be cast on that target. If ability is not cast (applied on self), don't provide target |
bool hasActiveAbility(AbilityType type) |
Returns true if ship has active ability of type. For abilities cast on other ships, use Ship.getOrder and Ship.getOrderAbility |
float getShipAutoTargetScore(const Object@ target) |
Returns targeting "score" of target for this ship. Higher score means that ship would prefer to attack this target over objects with lower score. This is only based on this ship's ship type and targets type/ship type |
float getExperienceOffensive() |
Returns offensive experience of this ship. See EC in editor to see what this affects |
float getExperienceDefensive() |
|
void setExperienceOffensive(float experience) |
|
void setExperienceDefensive(float experience) |
|
void setHero(bool heroStatus) |
Sets heroStatus of this ship. Hero ships can use abilities without them being researched. They can also have abilities that their base ship class doesn't have (hero only) |
void isHero() |
|
bool loadCargo(float resources, float crystals) |
Magically loads amount of resources and crystals to this ship. If there is not enough space for this cargo, false is returned and as much cargo as fits is loaded, with crystals being loaded first |
bool unloadCargo(float resources, float crystals) |
Magically unloads amount resources and crystals from this ship. If there is not enough of either cargo on this ship, false is returned and no cargo is removed |
bool loadPassengers(int count) |
Magically loads count of crew into this ship. If there is not enough space, false is returned and as much passengers fit are loaded |
bool unloadPassengers(int count) |
Magically removes count of crew from this ship. If there is not enough crew on this ship, false is returned and no crew is removed |
void cheatRestoreShield() |
|
void cheatRestoreEnergy() |
|
void cheatFillCrewquarters() |
|
void cheatFillCargoholds() |
|
void cheatReloadMissiles() |
|
void cheatServiceFighters() |
|
| |
Method | Description |
uint stepNumber |
Step number of simulation, every mission starts at 0. Script can set how many frames are simulated before first image is show to player (e.g. to wait for some explosions, ships to open fire, etc.). Game simulates STEPS_PER_SECOND steps per second (unless there were some big changes, this should be 20) |
uint orderDelay |
When player gives orders, it takes this many frames until they are applied. Don't use this for anything other then to display it? I have no idea why it is even here |
int screenWidth |
Screen width in pixels. Obviously use this only for UI (0 is left, screenWidth is right) |
int screenHeight |
Screen height in pixels. Obviously use this only for UI (0 is bottom, screenHeight is top) |
float uiScaling |
It should be applied to button sizes, offsets and font sizes. Obviously use this only for UI (default is 1.0f) |
float warpTime |
Time in seconds it takes from when ship starts warping in/out until it is finished. Unless I fixed it, ships cannot receive orders while warping, delay any orders for them from their creation for at least this time. This is constant, it never changes |
float warpWarmup |
Minimum time in seconds it takes from when ship is ordered to warp out until it starts warping. Ship needs to face correct direction, so it might take longer (or never happen). This does not apply for microwarp ability, that is individual for ability. This is constant, it never changes |
bool lastManStanding |
Is true if current multiplayer match victory rule is last man standing (as opposed to based on damage done) |
bool debugDraw |
Is true if user wants script to draw debug information (what that means is up to script). This can be turned on in script debugger (while in game, press SHIFT + F5) |
uint getNumAll() |
Returns number of all objects of all types in map, except for fighters. Fighters are kept in separate list |
Object@ getAll(uint idx) |
Returns object of any type at index idx, or null if out of range |
uint getNumObjects() |
Returns number of generic objects in map (these are objects that are not Ship, Fighter, Debris, or ResourceContainer) |
Object@ getObject(uint idx) |
Returns generic object at index idx, or null if out of range |
uint getNumResourceContainers() |
Returns number of resource containers (generic objects that can have resource to be mined, but can also be empty) in map |
ResourceContainer@ getResourceContainer(uint idx) |
Returns resource container at index idx, or null if out of range |
uint getNumDebris() |
Returns number of debris in map (remnants of destroyed objects that can be mined for resources by salvages, if debris is from ship) |
Debris@ getDebris(uint idx) |
Returns debris at index idx, or null if out of range |
uint getNumShips() |
Returns number of ships in map (this includes stations, everything with subsystem counts as ship) |
Ship@ getShip(uint idx) |
Returns ship at index idx, or null if out of range |
uint getNumFighters() |
Returns number of fighers in map |
Fighter@ getFighter(uint idx) |
Returns fighter at index idx, or null if out of range |
Ship@ getAttacker(Targetable@ object, uint attackerIndex) |
Returns attacker of object with index attackerIndex. You can get number of attackers of object with Targetable.getNumAttackers(). Returns null if index is out of range, attacker is not of type Ship, or attacker no longer exists |
Player@ getPlayerNeutral() |
Returns neutral player. This is a special player not included in in getNumPlayers |
uint getNumPlayers() |
Returns number of players in this map, this does not include neutral player. Players are not added, removed, or reordered during the game |
Player@ getPlayer(uint) |
Returns player by index. If index is out of range, returns neutral player. Players are not added, removed, or reordered during the game |
Player@ getPlayer(string name) |
Returns player by name. This is what is set in editor or what you see on result screen. If there is no player with name, null is returned |
vec3 getPointOfInterest(string name) |
Returns a position with name marked as point of interest in map editor. If there is no position with name, result is invalid position, you can query validity with vec3.isInvalid() |
vec3 getLocationPosition(uint index) |
Returns position of starting location for players |
void issueOrder(Ship@ ship, OrderType order, Object@ target, vec3 position, bool queue, string additionalInfo) |
Issues order of type order to ship. Orders will use target or position depending on type of order (e.g. escort needs target, move needs position). If queue is true, order is placed at the end of order queue, as if player held shift key. If queue is false, current order is cancelled, queue emptied, and this order becomes current order. additionalInfo is used dependent on order type. If it is not empty string, for SHIP_ORDER_WARP_OUT it denotes to what object pool will ship be added when warped out, for MISC_ORDER_OBJECT_DESIGNATION_SET name of this ship, for SHIP_ORDER_ADD_FIGHTERGROUP what type of fighter group to add, for SHIP_ORDER_REMOVE_FIGHTERGROUP index at which remove, for SHIP_ORDER_SCAFFOLD_CONSTRUCT what type of ship to build, and what tags to assign (e.g. "vr_cruiser" for no tags, or "vr_cruiser|tag_defense|tag_ai_made" for multiple tags) |
void issueOrderArray(Ship@ ship, OrderType order, array<Object@>@ target, bool queue) |
issueOrder version with multiple targets. This version creates order group, ship will automatically choose/switch between targets in one group as it sees fit instead of executing them one by one |
void issueOrderMisc(Player@ player, OrderType miscOrderType, string additionalInfo) |
Apply misc orders. (currently only documented one is MISC_ORDER_GIVE_UNITS, which changes desired game speed for player, with possible values of additionalInfo {"1","2","3","4"}) |
void activateAbility(Ship@ ship, AbilityType ability) |
Orders ship to activate ability. Technically could be done with issue order, but target, position, queue, additionalInfo is irrelevant, and you can use enum for type |
void deactivateAbility(Ship@ ship, AbilityType ability) |
Orders ship to deactivate ability. Technically could be done with issue order, but target, position, queue, additionalInfo is irrelevant, and you can use enum for type |
void castAbility(Ship@ ship, AbilityType ability, Object@ target, bool shift) |
Orders ship to cast ability on target. Most abilities can target only ships. Cast abilities work as regular orders when it comes to shift. |
void spawnShip(string statName, uint number, Player@ owner, vec3 position, vec3 lookAtPoint, bool asWarp, string tag, bool positionNotForceVacant = false) |
Creates number of ships of of type statName, assigned to player owner, at position facing towards lookAtPoint. If asWarp is true, spawned ships will warp in at position arriving from direction so they would face lookAtPoint, if false, they magically appear at position. If tag is not empty string, it will be added as tag. To add multiple tags, separate them by '|', e.g. "tag1|tag2|tag3" |
void spawnObject(string statName, uint number, Player@ owner, vec3 position, vec3 lookAtPoint, bool asResource, string tag, bool positionNotForceVacant = false) |
|
void spawnFighterGroup(string statName, uint numberOfFighters, Player@ owner, vec3 position, Ship@ parentShip) |
Creates fighter group of statName type of fighters with numberOfFighters at position. Fighter group is given to player owner. If parentShip is specified, it is attached to that ship if it still has empty slot in fighter bay, and owner must be same as parentShip's owner. parentShip as null is useful when you want to spawn escape pods that will return to owner's station. |
uint getNumObjectsInPool(string poolName) |
Returns number of objects in pool called poolName |
void respawnFromPoolFirst(string poolName, Player@ owner, vec3 position, vec3 lookAtPoint, string addTag, ShipSpawnMethod spawnMethod) |
Respawns first object in pool poolName at position facing towards lookAtPoint. Object is given to player owner and tag addTag is added to it. If object is Ship, spawnMethod dictates how it should spawn, if DEFAULT is selected, ship spawns in the fashion it despawned (disappear, warp out) |
void respawnFromPoolLast(string poolName, Player@ owner, vec3 position, vec3 lookAtPoint, string addTag, ShipSpawnMethod spawnMethod) |
Respawns last object in pool poolName at position facing towards lookAtPoint. Object is given to player owner and tag addTag is added to it. If object is Ship, spawnMethod dictates how it should spawn, if DEFAULT is selected, ship spawns in the fashion it despawned (disappear, warp out) |
void respawnFromPoolAll(string poolName, Player@ owner, vec3 position, vec3 lookAtPoint, string addTag, ShipSpawnMethod spawnMethod) |
Respawns all objects in pool poolName at position facing towards lookAtPoint. Objects are given to player owner and tag addTag is added to them. If object is Ship, spawnMethod dictates how it should spawn, if DEFAULT is selected, ship spawns in the fashion it despawned (disappear, warp out). Only for this method, formation spawn types make any sense |
void storeObjectToPool(Object@ object, string poolName, bool saveSelectionGroup) |
Removes object from map and stores it to pool with name poolName. If saveSelectionGroup is true, number of selection group is remembered so it is in that group when you respawn it, e.g. in next mission. Other way how object can get into pool is by warping out, with pool name as order's additionalInfo NOTE: this function only works when called inside of onMissionEnd() |
void endMission() |
Ends mission, exiting current map after current step is finished (script will still run after this call). When the mission is ended this way, onMissionEnd() will be called, in which you can call EngineInterface.storeObjectToPool(), and indicate next mission if any |
void addUIGroup(string groupID, string config) |
TODO: move stuff here from add button |
void setUIGroupCorners(string groupID, int left, int bottom, int right, int top) |
TODO: move stuff here from add button |
vec3 getUIElementCenter(string groupID, string id) |
TODO: |
vec3 getUIElementSize(string groupID, string id) |
TODO: |
void addButton(string groupID, string id, string text, int x, int y, int width, int height, bool enabled) |
TODO: update this Adds button to user interface, placed in a group with groupID, identified by id, centered at x,y. It is recommended that width and height be even numbers. enabled indicates whether or not button is clickable (it also renders differently, usually darker). config is .buttongroup styling config found in data/textures/gui that should be applied to this button. useScissor tells whether text, lines and polygons associated with this button should be clipped by its bounding box. config is only applied when button is first created, other values are updated if button exists. Button exists for single step only, and must be renewed every step as long as you wish to display this button. Setting all x,y,width,height to 0 will not update them, so values from buttonconfig are used |
void addLabel(string groupID, string id, string text, int x, int y, int width, int height, float alphaOverride = -1.0f) |
adds UI 'label'. Just a text |
void addTextField(string groupID, string id, string text, int x, int y, int width, int height, bool enabled, bool numbersOnly) |
adds text input. If text> is empty string, won't overwrite the value. numbersOnly limits inputs to numbers (only has effect when creating the input, it cannot be changed while the input is still existing) |
void addTextArea(string groupID, string id, string text, int x, int y, int width, int height, bool enabled) |
adds text input. If text> is empty string, won't overwrite the value |
void setUIVisibility(bool visible) |
hides all UI, e.g. for cinematics. Things that are still visible: uses of drawText, drawSensorIcon, drawLine with drawInCinematic set to true, messages from insertTextMessage |
void enableCameraControl() |
returns control of camera to player (end cinematic) |
void disableCameraControl() |
takes control of camera away from player (e.g. for cinematics) |
void emitScriptEvent(string payload) |
Sends script event so all clients (multiplayer/replay) can execute it. This might be useful for reacting to key presses, or using client specific data (e.g. camera position) |
void createMessagebox(string title, string message) |
Creates a message box. Intended to be used for error messages or some such |
void setFontStyleDefault() |
Sets font style to default, without outline |
void setFontStyleDefaultOutline() |
Sets font style to default, with outline |
void setFontStyle(bool outlineEnabled, vec3 outlineColor, float outlineOpacity, float outlineInner, float outlineOuter, vec3 outlineOffset) |
Sets style for font outline. outlineInner is distance from text where outline has full opacity, outlineOuter is distance from text where outline reaches zero opacity. outlineOffset is how much is outline offset from base text, this creates sort of drop-shadow (z is ignored). outlineColor is in range [0.0, 1.0] |
void drawText(string text, int x, int y, vec3 color, float alpha, string font, int height, bool drawInCinematic = false) |
Draws text on screen at coordinates x, y (0,0 is at left bottom). color and alpha is in range [0.0, 1.0]. font is one of file names in data/fonts, without extension. height is approximate in pixels |
uint getTextWidth(string text, string font, int height) |
Returns expected width in pixels of text when rendered in font with height. This does not include outline |
string createColorTag(vec3 color, float alpha) |
Returns string that you can insert into text that you want to render to change color mid-text. color and alpha are in range [0.0, 1.0] |
string createFontTag(string face, uint size) |
Returns string that you can insert into text that you want to render to change font mid-text. |
void insertTextMessage(string message, float displayTime) |
Adds text message that will be display above bottom panel, such as dialog, objective related messages, or to display mission rewards |
void playSound(string soundName, float gain, bool isVoice) |
Plays a sound. soundName is name of file to play in data/sounds/ (without extension). gain is volume multiplier at which sound will play, it is clamped to [0.0, 1.0] interval. If isVoice is true, it is added to queue of voice sounds, these play one at the time. If isVoice is false, sound plays immediately |
void playUISound(string soundName, bool isPriority) |
Plays an UI sound. soundName is name of file to play in data/sounds/ (without extension). If isPriority is true, it is added to queue of voice sounds, these play one at the time. If isVoice is false, sound plays immediately |
void drawSensorIcon(SensorIconType icon, vec3 position, vec3 color, float opacity, bool drawInCinematic = false) |
Draws sensor icon of type icon, placed at position in color. color is in range [0.0, 1.0]. This can be used to e.g. indicate mission objective. |
void drawLine(vec3 position0, vec3 position1, vec3 color0, float alpha0, vec3 color1, float alpha1, bool is3D, bool drawInCinematic = false) |
Draws a line from between two positions. If is3D is true, line will be drawn in world space, if false then in screen space (in pixels). colors and alphas are in range [0.0, 1.0]. |
void drawLineUI(string groupID, vec3 position0, vec3 position1, vec3 color0, float alpha0, vec3 color1, float alpha1) |
Same as above, but line is drawn together with UI created with e.g. addButton. This will draw it to same UI layer as the group with groupID, allowing it to be drawn over other UI. This is always in 2D |
void polygonPointUI(string groupID, vec3 position) |
Adds another point to current polygon. |
void polygonFinishUI(string groupID, vec3 color, float opacity) |
Creates a new polygon from previous points. Only convex polygons will draw correctly. If you want to draw concave polygons, you need to break them into convex parts yourself |
vec3 getProjectedPosition(vec3 worldPosition) |
Returns projected worldPosition to screen space (in pixels) |
void setCameraCenter(vec3 position) |
Sets camera center to position. Center is position around which camera rotates |
void setCameraView(vec3 position, vec3 center, vec3 centerVelocity, bool instantSkip) |
Sets camera to position, looking at center |
vec3 getCameraCenter() |
|
vec3 getCameraPosition() |
|
void setCameraFOV(float fov, bool instantSkip) |
in degrees |
float getCameraFOV() |
in degrees |
void endCinematicCamera() |
ends cinematic camera. This is useful when script is about to take control of camera |
void giveResearch(string name, Player@ player) |
Gives research with name to player. name is file name found in data/stats/research/ without the extension (as always) |
void giveAllResearch(Player@ player) |
Gives all research to player |
void giveAllFreeResearch(Player@ player) |
Gives all research that doesn't cost research crystals to player. This is preferred method when wanting the player to build anything, as it won't give research that would boost production speed, reduce costs, or increase experience of built ships |
void removeResearch(string name, Player@ player) |
If player has already researched name, it will remove it from them. This can be useful to remove obsolete ships from being able to be built, or to temporarily allow building some ships by giving hidden research, then removing it. |
void removeAllResearch(Player@ player) |
Removes all research from player |
void allowResearch(string name, Player@ player) |
Allows player to research name. This can be used by disallowing all research, then allowing more as campaign or mission progresses |
void allowAllResearch(Player@ player) |
Allows all research for player |
void disallowResearch(string name, Player@ player) |
Disallows research name for player |
void disallowAllResearch(Player@ player) |
Disallows all research for player |
bool hasResearch(Player@ player, string name) |
Returns true if player has researched name |
bool hasResearchForShip(Player@ player, string ship) |
Returns true if player has all required research to build ship |
bool hasResearchForFighter(Player@ player, string fighter) |
Returns true if player has all required research to build fighter |
array<string> @getQueuebleResearch(Player@ player) |
Returns all research player can currently enqueue. This is all research that is clickable in UI (not hidden, not disallowed, with prerequisities researched or queued) |
void queueResearch(string name, Player@ player) |
Adds research name to queue for player |
void queueResearchForShip(Player@ player, string ship) |
Adds research for player required to build ship |
void queueResearchForFighter(Player@ player, string fighter) |
Adds research for player required to build fighter |
const ShipStat@ getShipStat(string name) |
Returns ship stat by name. Returns null if no such ship stat exists. If you already have Ship instance, you can use Ship.getStat() to get its stat. This should be used when you don't have instance of ship. |
void setPersistentData(string key, string value) |
Saves value under key to persistent data. This data is carried over to next missions. If you want to save ships that carry over, use object pools |
string getPersistentData(string key) |
Returns persistent data stored under key, or empty string if there is nothing stored under that key |
void logPersistentData() |
Dumps all persistent data to script log. This is for easier debugging of what is stored there. |
void logObjectPools() |
Dumps info about object pools to script log. This prints all saved pool names along with number of objects in them |
string getMissionParameter(string parameter) |
Returns value of parameter for this mission. These are displayed and user can select values when starting mission. Described in .config in the map's folder |
bool isObjectiveHighlighted(int index) |
Returns value of parameter for this mission. These are displayed and user can select values when starting mission. Described in .config in the map's folder |
void awardAchievement(string achievement) |
Awards achievement. These are found in data/stats/achievement/. Awarded achievement will be displayed even if it wasn't shown be showAchievement |
void showAchievement(string) |
Achievements are hidden by default, only displayed as ???. With this you can show it without awarding it, e.g. when mission is finished in which this is awarded |
| |