SCRIPTING FUNCTIONS

Sort alphabetically | Sort by category

All | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | R | S | T | U | V | Z


Script

Start another script from withing an executing script. Used mostly for cutscenes.

script Spg2\Scripts\scriptName.sal ;


SectorId

Get Id of current sector (hex).

int sectorID ;
sector GetId sectorID ;


SetAcquire

Set quest acquired flag.
It can be either 0(false) or 1(true).

mainquest GetById 1 SetAcquire 1 ;
sidequest GetById 1 SetAcquire 1 ;


SetAIQuestStatus

Flag that sets desired behavior to a ship. Use this function on quest-related ships ONLY! Set appropriate flag for desired behavior.

int aiState_0 = 0 ; [ship is no longer viewed as quest ship]
int aiState_1 = 1 ; [ship's AI is disabled. Ship becomes passive]
int aiState_2 = 2 ; [ship's AI is partially disabled. Ship will ONLY attack other QUEST ships that are his enemies in regards to SetFriendFoe flag]
int aiState_3 = 3 ; [ship's AI is partially disabled. Ship can accept ONLY special script comamnds like GoTo, but will NOT defend itself]
int aiState_4 = 4 ; [ship's AI is partially disabled. Ship can accept ONLY special script commands like GoTo, but WILL fire back on attackers. Defending will NOT break assigned script command.]
ship GetbyKeyName ship0 SetAIQuestStatus aiState_1 ;


SetAIStatus

Can be set either to 0(active) or 1(passive). Passive ships will not act on their own default AI behavior.

ship GetByKeyName ship0 SetAIStatus 0 ;


SetAngularVelocity

Set angular velocity of a mesh in an assembly.

float3 angVel = 0.0 4.5 0.0 ;
float interpolation = 1.0 ;
float delay = 1.5 ;
tgate GetByKeyName korkyraGate GetMesh 1 SetAngularVel angVel interpolation delay ;


SetAvailable

Set quest available flag.
It can be either 0(false) or 1(true).

mainquest GetById 1 SetAvailable 1 ;
sidequest GetById 1 SetAvailable 1 ;


SetBoardable

Set a ship's boardable flag. (o == false, 1 == true)
Ships with flag set to 0 CANNOT be boarded!

int boardFlag = 0 ;
ship GetByKeyName ship0 SetBoardable boardFlag ;


SetCanRepair

Set repairable flag for structures. Repair action can only be done on structures that have this flag set to 1.
Flag can be set either to 0(false) or 1(true).

structure GetByKeyName structure01 SetCanRepair 0 ;


SetCloak

Set ship cloak state to true(1) or false(0).

int cloakState = 1 ;
ship GetbyKeyName ship0 SetCloaked cloakState ;


SetCommoditiesCount

Set an exact quantity of commodities in the player inventory.

int amount = 101 ;
int commodityId = 5 ; [->commodities.wdt]
player SetCommoditiesCount commodityId amount ;


SetCondition

Set specific AI condition of an object.
State can be set to either o(indestructible) or 1(destructible).

ship GetByKeyName ship0 SetCondition 0 ;


SetControlEnabled

Switch player controls OFF (0) or ON (1).

game SetControlEnabled 1 ;


SetCredits

Set player credit count.

int credits = 1500 ;
player SetCredits credits ;


SetCSCamera

Initializes the cutscene camera controls.

camera SetCSCamera 1 ; turn on
camera SetCSCamera 0 ; turn off


SetDefault

Reverts camera setup to the saved parameters (GetDefault).
NEVER activate this function before(!) using GetDefault.

camera SetDefault ;


SetEnabled

Activate or deactivate an object. Ship is used only as example.
Can be set either to 0(disabled) or 1(enabled).

ship GetByKeyName ship0 SetEnabled 1 ;
ship GetByKeyName ship0 SetEnabled 0 ;


SetExp

Set player experience.

int exp = 1000 ;
player SetExp exp ;


SetFloat

Sets the float modding variable in the save file to the wanted value.

int stackVarId = 0 ;
float floatVal = 0.0 ;
modingvar SetFloat stackVarId floatVal ;
modingvar SetFloat 0 floatVal ;


SetFriendFoe

Friend-Foe mechanism. Used during missions to prevent randomly generated AI ships from interfering.
status = 0 [neutral objects will not interfere
status = 1 [friendly objects will assist player by default]
status = 2 [hostile objects will attack player by default]
Specific behaviour must be scripted.

int status = 0 ;

ship GetByKeyName ship0 SetFriendFoe status ;


SetHP

Sets hull of object to a fixed value.

float shipHP = 500.0 ;
ship GetByKeyName ship0 SetHP shipHP ;


SetHPRel

Sets hull of object to its relative percentage, taking into account the object's base Hull value.

int HullPercentage = 100 ; ship hull will be set to its 100%
ship GetByKeyName ship0 SetHPRel HullPercentage ;


SetInt

Sets the integer modding variable in the save file to the wanted value.

int stackVarId = 0 ;
int intVal = 0 ;
modingvar SetInt stackVarId intVal ;
modingvar SetInt 0 intVal ;


SetInvulnerable

Set whether ship is invulnerable (1) or not (0).

ship GetByKeyName ship0 SetInvulnerable 1 ;


SetMark

Mark an object as important. Used for marking quest objects.
0 = clear marker
1 = main mission
2 = side mission
3 = freelance mission

ship GetByKeyName ship0 SetMark 1 ;


SetMeshPosition

Set mesh position in an assembly (offset).

float3 position = 0.0 30.0 0.0 ;
float interpolation = 1.0 ;
float delay = 1.5 ;
tgate GetByKeyName korkyraGate GetMesh 1 SetPosition position interpolation delay ;


SetMeshRotation

Set rotation of a mesh in an assembly.

float3 rotation = 0.0 1.57 0.0 ;
float interpolation = 1.0 ;
float delay = 1.5 ;
tgate GetByKeyName korkyraGate GetMesh 1 SetRotation rotation interpolation delay ;


SetMeshVisibility

Toggle rendering of an object mesh.
State can be set to either 0(invisible) or 1(visible).
Mesh shader MUST support fading!

int state = 1 ;
float delay = 1.5 ;
tgate GetByKeyName korkyraGate GetMesh 1 SetVisible state delay ;


SetParticleVisibility

Toggle rendering of an object particle.
Type can be set to either 1(interpolation) or 2(instant).

int state = 1 ;
int interpolation = 1 ;
float delay = 1.5 ; [deprecated]
tgate GetByKeyName korkyraGate GetParticle 1 SetVisible state interpolation delay ;


SetPTE

Set ship Power to Engines to ON(1) or OFF(0).

int pteState = 1 ;
ship GetbyKeyName ship0 SetPTE pteState ;


SetQuestItemCount

Set an exact quantity of a quest item in the player inventory.

int amount = 4 ;
int itemId = 2 ; [->QuesItems.wdt]
player SetQuestItemCount itemId amount ;


SetQuestMode

Switch Quest mode to OFF (0) or ON (1). QuestMode MUST be set to ON before SetAIQuestStatus is used on ships!

game SetQuestMode 1 ;


SetReputation

Set player's reputation.

int rep = 1200 ;
player SetReputation rep ;


SetRotation

Set object rotation.

float3 rotation = 1.0 0.0 0.0 ;
ship GetByKeyName ship0 SetRotation rotation ;


SetScale

Set scale of a mesh in an assembly. assemblyex object is used only as an example.

int retId = 0 ;
int meshId = 1 ;
float3 scale = 12.0 12.0 12.0 ;
float interpolation = 1.0 ;
float delay = 0.0 ;
assemblyex GetMesh retId meshId SetScale scale interpolation delay ;


SetSolve

Set quest solved flag. It can be set either to 0(false) or 1(true).

mainquest GetById 1 SetSolve 1 ;
sidequest GetById 1 SetSolve 1 ;


SetSpeed

Sets ship speed. Used primarily for the player. AI ships eventually resume their default AI behavior.

float speed = 5.0 ;
ship GetPlayer SetSpeed speed ;


SetTransparent

Set transparency of a mesh in an assembly. assemblyex object is used only as an example.

int retId = 0 ;
int meshId = 1 ;
float transparency = 0.5 ;
float interpolation = 1.0 ;
float delay = 0.0 ;
assemblyex GetMesh retId meshId SetTransparent transparency interpolation delay ;


SetTroopersNo

Set the number of Troopers on a ship.

int trooperCount = 10 ;
ship GetByKeyName ship0 SetTroopersNo trooperCount ;


SetType (camera)

Defines the camera type and its parameters. This function requires the SetCSCamera function to be turned ON before using.

OBJECT TYPES (hard-coded)
player == 0
ship == 1
tgate == 2
wormhole == 3
rift == 4
station == 5
structure == 6
planet == 7
asteroid field == 8
nebula == 9
waypoint == 10
derelict == 11
anomaly == 12
trigger == 13
junkyard == 14
scenery == 15
single asteroid == 16
platform == 17
path == 18

ROTATION CAMERA
int objectType = 1 ; if objectType is 0 (player) this parameter is followed by NONE as keyname
float rotationStart = 2.4 ; camera starting angle in radians (planar)
float rotationSpeed = 0.08 ; camera speed of rotation
float verticalStart = 2.4 ; camera vertical start position
float verticalOffset = 12.0 ; camera vertical offset
float verticalSpeed = 0.06 ; speed at which camera moves on the vertical axis (within allowed offset)
float cameraDistance = 60.0 ; camera distance from focus
camera SetType 5 objectType SHIP_0 rotationStart rotationSpeed verticalStart verticalOffset verticalSpeed cameraDistance ;

camera SetType 5 0 NONE rotationStart rotationSpeed verticalStart verticalOffset verticalSpeed cameraDistance ; if player is camera target

LOCK-ON CAMERA
int objectType = 1 ; if objectType is 0 (player) this parameter is followed by NONE as keyname
float verticalStartA = 5.0 ; camera vertical start position
int focusObjType = 7 ; if objectType is 0 (player) this parameter is NOT followed by a keyname(!)
float verticalStartB = 0.0 ; focus vertical position
float cameraDistance = 2700.0 ; camera distance from focus
camera SetType 6 objectType SHIP_0 verticalStartA focusObjType trinityPLA verticalStartB cameraDistance ;

camera SetType 6 0 NONE verticalStartA focusObjType trinityPLA verticalStartB cameraDistance ; if camera uses player as starting point


SetZoom

Set camera zoom. Needs SetCSCamera to be first set to ON.

float time = 1.0 ;
float zoomAmount = 190.0 ;
camera SetZoom 0 time zoomAmount ; the 0 is a temporary parameter that will be changed at a later date


Shake (screen)

Screen-shake effect.

LOCAL
int sort = 1 ; [1=local]
int shakeType = 0 ;
float power = 0.5 ;
float duration = 0.6 ;
float delay = 0.0 ;
float3 position = 0 0 0 ;
float radius = 400.0 ;
camera Shake sort shakeType power duration delay position radius ;

GLOBAL
int sort = 0 ; [0=local]
int shakeType = 0 ;
float power = 0.5 ;
float duration = 0.6 ;
float delay = 0.0 ;
camera Shake sort shakeType power duration delay ;


Shockwave

Generate a shockwave.

float delay = 0.0 ;
float3 position = 0.0 0.0 0.0 ;
float3 color = 1.0 1.0 1.0 ;
int shapeId = 0 ; [0,1,2,3]
int textureId = 0 ; [->shockwave.wds]
float radiusStart = 0.0 ;
float radiusEnd = 50.0 ;
float lifetime = 2.0 ;
float distortion = 0.2 ;
float refraction = 0.2 ;
float yScale = 1.0 ; [vertical scale; only works if shapeId is NOT 0]
int fadeType = 1 ; [0=linear, 1=graph]
shockwave delay position color shapeId textureId radiusStart radiusEnd lifetime distortion refraction yScale fadeType ;


ShowAllPanels

Turns HUD panels ON(1) or OFF(0).
NEVER turn panels ON if you haven't already shut them down first!

game ShowAllPanels 0 ;


ShowLine

Show horizontal black lines. Used in cutscenes. Can be set to either true(1) or false(0).

screen ShowLine 1 ;


ShowText

Show text on the bottom of the screen.

int miscLine = 0 ; [->Spg2\Texts\misc.txt | line count starts from 0]
float duration = 10.0 ;
screen ShowText miscLine duration ;


ShowWarnings

Show special notification panel with needed title and text.

int titleLine = 1 ;
int textLine1 = 2 ;
int textLine2 = -1 ;[if no text, set as -1]
screen ShowWarnings titleLine textLine1 textLine2 ;


ShowWarningsEx (pass through wormhole)

Show special notification panel. Title and text lines are hard-coded, but parameters can be sent through. If a parameter is set to 0, it is NOT shown on the notification panel.

int troopers = 5 ; //number of Troopers lost
int hull = 100 ; //amount of Hull lost
int wrongLoc = 0 ; //whether or not you've exited the wormhole in the right location (0 == false, 1 == true)
screen ShowWarningsEx 16 troopers hull wrongLoc ; //16 is the special hard-coded ID of the notification panel


Sound

Play global sound.

sound soundName ; [sound.wdt]


Sound3D

Play local sound with distance falloff.

float3 position = 0.0 0.0 0.0 ;
sound3d soundName position ; [sound.wdt]


Spawn ship (shipAdd)

Spawn a ship based on current region parameters(!).
For keyname use either custom literal value OR keyword "GENERIC" which means the game will assign a generic keyname.
Using GENERIC prevents you from manipulating the spawned ship later on via its keyname.
Keyname MUST be used directly in the function as literal value.

int type = 0 ; //0 = region based
float3 position = 0.0 0.0 0.0 ;
int faction = 0 ; //region based(!) where 0 is the first faction in the region file
int shipId = 0 ; //region based(!) where 0 is the first ship in the faction ship list
shipAdd ship0/GENERIC type position faction shipId ;


Storypanel

Force open a special panel. Used specifically for important VO logs during main campaign. The only parameter is the hard-coded ID.

storypanel 0 ;