Useful Functions¶
Custom Ejection Messages¶
How ejection messages are chosen¶
When ejecting the game selects a random number between 0 and 1, if this number is greater than 0.15 then a random common eject message is returned, if it is less than 0.15 then a rare ejection message is returned.
Adding new messages¶
Using AddCommonEjectMessage( String message )
and AddRareEjectMessage( String message )
in script additional messages can be added to the pool of potential ejection messages
Localisation¶
Like most things custom ejection messages can be localised through keyvalues
There are no functions to remove ejection messages, however existing ones can be altered by modifying localisation files
Below are a list of useful functions added by Northstar.
Player functions¶
Check for different weapon types on a player¶
bool function HasWeapon( entity ent, string weaponClassName, array
bool function HasOrdnance( entity ent, string weaponClassName, array
bool function HasCoreAbility( entity ent, string weaponClassName, array
bool function HasSpecial( entity ent, string weaponClassName, array
bool function HasAntiRodeo( entity ent, string weaponClassName, array
bool function HasMelee( entity ent, string weaponClassName, array
bool function HasOffhandForSlot( entity ent, int slot, string weaponClassName, array
bool function WeaponHasSameMods( entity weapon, array
bool function HasOffhandWeapon( entity ent, string weaponClassName )
bool function PilotHasSniperWeapon( entity player )
bool function PilotActiveWeaponIsSniper( entity player )
Get weapon from entity¶
string function GetActiveWeaponClass( entity player )
entity function GetPilotAntiPersonnelWeapon( entity player )
entity function GetPilotSideArmWeapon( entity player )
entity function GetPilotAntiTitanWeapon( entity player )
Take weapon from Entity¶
bool function TakePrimaryWeapon( entity player )
bool function TakeSecondaryWeapon( entity player )
bool function TakeSidearmWeapon( entity player )
void function EnableOffhandWeapons( entity player )
void function DisableOffhandWeapons( entity player )
void function EnableOffhandWeapons( entity player )
void function TakeAllWeapons( entity ent )
void function TakeWeaponsForArray( entity ent, array
Validity checks for player¶
bool function PlayerCanTeleportHere( entity player, vector testOrg, entity ignoreEnt = null )
Note
Respawn comment next to the function:
TODO: This is a copy of SP's PlayerPosInSolid(). Not changing it to avoid patching SP. Merge into one function next game
bool function PlayerSpawnpointIsValid( entity ent )
bool function EntityInSolid( entity ent, entity ignoreEnt = null, int buffer = 0 )
Note
Respawn comment next to the function:
TODO: This function returns true for a player standing inside a friendly grunt. It also returns true if you are right up against a ceiling.Needs fixing for next game
bool function EntityInSpecifiedEnt( entity ent, entity specifiedEnt, int buffer = 0 )
Change a players invincibility¶
void function MakeInvincible( entity ent )
void function ClearInvincible( entity ent )
bool function IsInvincible( entity ent )
bool function IsFacingEnemy( entity guy, entity enemy, int viewAngle = 75 )
bool function PlayerHasTitan( entity player )
void function ScaleHealth( entity ent, float scale )
Entity functions¶
float function GetEntHeight( entity ent )
float function GetEntWidth( entity ent )
float function GetEntDepth( entity ent )
void function PushEntWithVelocity( entity ent, vector velocity )
vector function GetCenter( array
Turret functions¶
void function TurretChangeTeam( entity turret, int team )
void function MakeTurretInvulnerable( entity turret )
void function MakeTurretVulnerable( entity turret )
void function UpdateTurretClientSideParticleEffects( entity turret )
Rest so far to be sorted¶
array
entity function GetLocalClientPlayer()
Note
this function only exists on clients
array
Note
A cleaner way to get a player:
entity function GetPlayerByIndex( int index )
array
void function DropWeapon( entity npc )
Note
this function only works on NPCs and not on players
void function ClearDroppedWeapons( float delayTime = 0.0 )
void function ClearActiveProjectilesForTeam( int team, vector searchOrigin = <0,0,0>, float searchDist = -1 )
void function ClearChildren( entity parentEnt )
Titans¶
bool function TitanHasRegenningShield( entity soul )
void function DelayShieldDecayTime( entity soul, float delay )
void function GiveAllTitans()
float ornull function GetTitanCoreTimeRemaining( entity player )
Gamemode functions¶
int function GetCurrentWinner( int defaultWinner = TEAM_MILITIA )
Note
Does not work for FFA modes
string NSGetLocalPlayerUID()
Returns the local player's UID, else null
.
Available on CLIENT, UI and SERVER VM.
bool function IsMultiplayer()
bool function IsSingleplayer()
string function GetMapName()
Threaded conditonals¶
void function WaitTillLookingAt( entity player, entity ent, bool doTrace, float degrees, float minDist = 0, float timeOut = 0, entity trigger = null, string failsafeFlag = "" )
void function WaitUntilShieldFades( entity player, entity titan, entity bubbleShield, float failTime )
entity function WaitUntilPlayerPicksUp( entity ent )
void function WaitForHotdropToEnd( entity titan )
var function WaittillGameStateOrHigher( state )
void function WaitTillCraneUsed( entity craneModel )
void function WaitTillHotDropComplete( entity titan )
var function WaitForNPCsDeployed( npcArray )
var function WaittillPlayDeployAnims( ref )
Random functions¶
bool function IsPlayerMalePilot( entity player )
bool function IsPlayerFemalePilot( entity player )
void function RandomizeHead( entity model )
Randomize head across all available heads
void function RandomizeHeadByTeam( entity model, int headIndex, int numOfHeads )
Randomize head across heads available to a particular team. Assumes for a model all imc heads are first, then all militia heads are later.
void function CreateZipline( vector startPos, vector endPos )
bool function HasTeamSkin( entity model )
void function DropToGround( entity ent )
void function DropTitanToGround( entity titan, array
Type Utilities¶
Table¶
void function TableRemoveInvalid( table
void function TableRemoveInvalidByValue( table
void function TableRemoveDeadByKey( table
array TableKeysToArray( table Table )
Arrays¶
int function array.find(var value)
this returns -1
if the item was not found in the array
array.fastremove(var)
Removes a variable by value instead of index.
array.randomize()
Reorders the array randomly.
array.getrandom()
returns a random element from array
array.resize(int newSize, var fillValue = 0)
changes the size of the array to the first int, new slots will be filled with the 2nd argument.
array.sort( compare_func = null )
Note
A few built-in functions you can give as arguments to sort an array.
Array Sort Functions
int function SortLowest( var a, var b )
int function SortHighest( var a, var b )
int function SortItemsAlphabetically(var a, var b )
int function SortAlphabetize( var a, var b )
int function SortStringAlphabetize( string a, string b )
int function SortStringAsset( asset a, asset b )
int function SortBySpawnTime( entity a, entity b )
Functions for score comparison
int function CompareKills( entity a, entity b )
int function CompareAssaultScore( entity a, entity b )
int function CompareScore( entity a, entity b )
int function CompareAssault( entity a, entity b )
int function CompareDefense( entity a, entity b )
int function CompareLTS( entity a, entity b )
int function CompareCP( entity a, entity b )
int function CompareCTF( entity a, entity b )
int function CompareSpeedball( entity a, entity b )
int function CompareMFD( entity a, entity b )
int function CompareScavenger( entity a, entity b )
int function CompareFW( entity a, entity b )
int function CompareHunter( entity a, entity b )
int function CompareATCOOP( entity a, entity b )
int function CompareFD( entity a, entity b )
int function CompareTitanKills( entity a, entity b )
array.reverse()
reverse the array in place
array.slice(int start, int end = null)
Note
Returns a section of the array as new array. Copies from start to the end (not included). If start is negative the index is calculated as length + start, if end is negative the index is calculated as length + end. If end is omitted end is equal to the array length.
String¶
var function UniqueString( titleString = "" )
returns a unique string
string function StringReplace(string original, string toReplace, string replacement)
Note
Returns the new string with the first occurance of the toReplace string."
string function format( string template, ... )
Returns a formatted template
string function Localize( string token )
Note
replaces text that should be localized on the client
string localized = Localize( token )
int ornull function string.find( string s )
Warning
returns null
if the string is not found.
You can eliminate the possibility of the returned index being null by casting like this:
int ornull index = GetMapName().find( "mp" )
if( !index )
return
int( index )
int n = index + 1 //now we do not need the ornull anymore
string function string.slice( int start, int end = null )
Float¶
float function RandomFloatRange( float min, float max)
Integer¶
int function RandomIntRange( int min, int max )
int function RandomIntRangeInclusive( int min, int max )
Vectors¶
vector function RandomVec( float range )