SCRIPTING FUNCTIONS

Sort alphabetically | Sort by category

AI | Camera | Game objects | Math | Misc | Player | Quests | SFX & VFX | World |


AttackPlayer

Force an AI ship to attack player.

ship GetByKeyName ship0 AttackPlayer ;


CheckContraband

Check if player has any contraband in inventory.
Contraband status depends on current region, random events and scripted events.
Function returns either 0(false) or 1(true).

int smuggle = 0 ;
player CheckContraband smuggle ;


GetBoardable

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

int boardFlag = 0 ;
ship GetByKeyName ship0 GetBoardable boardFlag ;


GetCloak

Check whether ship has cloak set to ON(1) or OFF(0).

int cloakState ;
ship GetbyKeyName ship0 GetCloaked cloakState ;


GetFriendFoe

Check status of Friend-Foe mechanism.
Function returns either 0(false) or 1(true).

int status = 0 ;
game GetFriendFoe status ;


GetInvulnerable

Get invulnerable flag of a ship.

int state = 0 ;
ship GetByKeyName ship0 GetInvulnerable state ;


GetPTE

Check whether ship has Power to Engines set to ON(1) or OFF(0).

int pteState ;
ship GetbyKeyName ship0 GetPTE pteState ;


GoTo

Instruct a ship to go to a position. The ship can be distracted in which case it will lose its target position and act according to its AI.

float3 targetPos = 0.0 0.0 0.0 ;
ship GetByKeyName ship0 GoTo targetPos ;


GoToScript

Instruct a ship to go to a position and once there, fire off another script. The ship can be distracted in which case it will lose its target position and script and act according to its AI.

float3 targetPos = 0.0 0.0 0.0 ;
ship GetByKeyName ship0 GoToScript targetPos Spg2\Scripts\TargetScript.sal ;


ResetShipEnemyList

Resets (or recalculates) enemy list for every active ship. Use this function (in the same script) after using SetAIQuestStatus or SetFriendFoe functions!

game ResetShipEnemyList 1 ; The [ 1 ] is a standardized parameter and must NEVER change


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 ;


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 ;


SetCloak

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

int cloakState = 1 ;
ship GetbyKeyName ship0 SetCloaked cloakState ;


SetCondition

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

ship GetByKeyName ship0 SetCondition 0 ;


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 ;


SetInvulnerable

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

ship GetByKeyName ship0 SetInvulnerable 1 ;


SetPTE

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

int pteState = 1 ;
ship GetbyKeyName ship0 SetPTE pteState ;