Meteor 2 Scripting Functions
Effects
int getGraphicsQualityLevel()
Get the graphics quality level from the local options.

Example
if(getGraphicsQualityLevel() < GQ_HIGH)
{
    print("Graphics quality level is below high quality");
}

Comments
The quality level should be from 0 to 3 with the following constants defined.
GQ_LOW = 0
GQ_MEDIUM = 1
GQ_HIGH = 2 (default)
GQ_ULTRA = 3

void createExplosion(vector2 pos, float height, float radius, float damage, float armourPenetration, int ownerID)
Create an in-game explosion.

Example 1
// create exlosion at ground level height
createExplosion(getPos(PLAYER_OBJECT), 0, 20, 100, 50, PLAYER_OBJECT);


Example 2
// create exlosion at in the air.
createExplosion(getPos(PLAYER_OBJECT), getAirHeight(), 20, 100, 50, PLAYER_OBJECT);

Comments
armourPenetration is 0 to 100.
Can be called from server or client.

void fade(string text, float fadeOutSeconds, float fadedSeconds, float fadeInSeconds)
Fades out the screen, displays a message and fades back in.

Example 1
// fade out over 1 seconds, show text for 3 seconds, fade in over 1 second
fade("Later that day...", 1, 3, 1);

Example 2
// instantly turn screen black, wait 2 seconds, fade in over 2 seconds
fade("", 0, 2, 2);

Comments
Only affects the local computer.
Player controls are disabled while fading and while faded.

See also
getCinematicBarsEnabled setCinematicBarsEnabled

void flash(float lifetime, string colour)
Light up the world for a short time.

Example
// light up night sky for 1 second
flash(1, "#FFFFFF");

Comments
Only affects the local computer.
colour is specified in HTML style ("#RRGGBB" hex values), colours may also contain 2 additional optional characters for alpha (e.g. "#FFFFFF80" is transparent white).
Lifetime is in seconds.

bool getCinematicBarsEnabled()
Gets whether the cinematic bars are enabled.

Example
if(getCinematicBarsEnabled())
{
    print("Cinematic bars are enabled.");
}
else
{
    print("Cinematic bars are disabled.");
}

See also
setCinematicBarsEnabled fade

void setCinematicBarsEnabled(bool enabled)
Sets whether the cinematic bars are enabled.

Example
// enable cinematic bars
setCinematicBarsEnabled(true);

Comments
Only affects the local player.
Player controls are disabled while cinematic bars are enabled.

See also
getCinematicBarsEnabled fade

bool getMaxWildlifeDistance()
Get the maximum wildlife particle distance.

Example
print(getMaxWildlifeDistance());

Comments
Wildlife particles further than this distance from the game window centre will be culled automatically.

See also
addWildlifeParticle

void addWildlifeParticle(vector2 spawnPos, uint filenameHash)
Spawn a wildlife particle (e.g. insect or bird).

Example
unsigned birdHash = createStringHashLowerCase("Wildlife_Bird01.ini");
vector2 playerPos = getPos(PLAYER_OBJECT);
for(int i=0; i<10; i++)
{
    addWildlifeParticle(playerPos, birdHash);
}

Comments
The particle filename is required as a hash for better performance. Use createStringHashLowerCase() to generate a filename hash once before any loops.

See also
getMaxWildlifeDistance createStringHashLowerCase getWildlifeParticleInstanceCount

int getWildlifeParticleInstanceCount(uint filenameHash)
Get the current particles instance count of a willife particle type.

Example
unsigned birdHash = createStringHashLowerCase("Wildlife_Bird01.ini");
int birdsCount = getWildlifeParticleInstanceCount(birdHash);
print("Birds count: " + birdsCount);

See also
addWildlifeParticle createStringHashLowerCase

void addPlantParticle(vector2 spawnPos, uint filenameHash)
Spawn a plant particle (e.g. grass or flower).

Example
unsigned grassHash = createStringHashLowerCase("Plant_Grass01.ini");
vector2 playerPos = getPos(PLAYER_OBJECT);
for(int i=0; i<10; i++)
{
    addPlantParticle(playerPos, grassHash);
}

Comments
The particle filename is required as a hash for better performance. Use createStringHashLowerCase() to generate a filename hash once before any loops.

See also
createStringHashLowerCase getPlantParticleInstanceCount

int getPlantParticleInstanceCount(uint filenameHash)
Get the current particles instance count of a plant particle type.

Example
unsigned grassHash = createStringHashLowerCase("Plant_Grass01.ini");
int grassHash = getPlantParticleInstanceCount(grassHash);
print("Grass count: " + birdsCount);

See also
addWildlifeParticle createStringHashLowerCase

bool isAddFireFrame()
Determine if fire particles should be added this frame.

Comments
Fire particles can be added during any frame but this function provides a convenient way of timing them consistently.

See also
addFireParticle

void addFireParticle(vector2 pos, float maxSize, float height=0, float lightLifetime=-1)
Add a fire particle.

Example
void onUpdate(float deltaTime)
{
    if(isAddFireFrame())
    {
        addFireParticle(getPos(PLAYER_OBJECT), 10);
    }
}

See also
isAddFireFrame addSmokeParticle

bool isAddSmokeFrame()
Determine if smoke particles should be added this frame.

Comments
Smoke particles can be added during any frame but this function provides a convenient way of timing them consistently.

See also
addSmokeParticle

void addSmokeParticle(vector2 pos, float size, string smokeColour, float growRate=0.95, float decayRate=0.5, vector2 smokeVelocity=vector2(0,0))
Add a fire particle.

Example
void onUpdate(float deltaTime)
{
    if(isAddSmokeFrame())
    {
        addSmokeParticle(getPos(PLAYER_OBJECT), 10, "#A0A0A0");
    }
}

Comments
smokeColour is specified in HTML style ("#RRGGBB" hex values), colours may also contain 2 additional optional characters for alpha (e.g. "#FFFFFF80" is transparent white).

See also
isAddSmokeFrame addFireParticle

void addSpriteParticle(int spriteNumber, vector2 pos, float height, float angle, float scale, float speed, float growRate, float lifetime)
Add a particle from a sprite.

Example
int particleSpriteNumber = 0;

void onStart()
{
    particleSpriteNumber = spriteTypeNameToNumber("effects\\shrapnel.spr");
}

void onUpdate(float deltaTime)
{
    vector2 pos = vector2(100, 100);
    float angle = randomDir();
    float height = 10;
    float scale = 0.5;
    float speed = 2;
    float growRate = 1.5; // growth during whole lifetime
    float lifetime = 3;

    addParticle(particleSpriteNumber, pos, angle, height, scale, speed, growRate, lifetime);
}

Comments
Currently only supports visual particles (no physics or collision).

See also
spriteTypeNameToNumber

void drawLight(vector2 pos, float angle, vector2 size, string colour, bool effectLight)
Draw a basic ellipse light.

Example
void onUpdate(float deltaTime)
{
    drawLight(getPos(PLAYER_OBJECT), getDir(PLAYER_OBJECT), vector2(30, 100), "#FF0000", true);
}

Comments
colour is specified in HTML style ("#RRGGBB" hex values), colours may also contain 2 additional optional characters for alpha (e.g. "#FFFFFF80" is transparent white).
Set effectLight to true to show the light in the daytime and brigter during the night.


Index