Difference between revisions of "Effect file"
|Line 1:||Line 1:|
Latest revision as of 23:45, 17 April 2017
These are values that can be sent to the effect and used in the effect expressions, for example these are used to send in an angle to most projectiles and rotate their sprites accordingly.
<param name="angle" default="0" />
This is a simple language for creating dynamic values that can change over time for the effect components, for example if you want a sprite to fade out during the effect you might do something like
color-a="1 - t"
or if you want it to pulse during the effect you could do
color-a="sin(t) / 2 + 0.5"
There are four built in parameters for effects,
The time parameter says where in the effect "timeline" you are, so it goes from 0 to 1 over the length of the effect, if the effect is looping then when time hits 1 it will reset to 0 and loop will increase by 1. So an expression like,
t + l
will simply start at 0 and go up forever until the effect is stopped.
The unit parameter simply contains the unit id for the unit that is currently playing the effect, this is fairly unique but can be reused for future effects getting played.
And the index parameter only exists inside a trail effect component and simply contains the id of the current segment in the trail.
More parameters can be added to an effect using the <param> tag and has to be filled with values by scripts.
|sin||Simple sine function, takes radians|
|cos||Simple cosine function, takes radians|
|abs||The absolute value, basically just turns negative values in to positive ones|
|ceil||Rounds a value up to the next or current integer|
|floor||Rounds a value down to the previous or current integer|
|exp||Returns e raised to the specified power|
|log||Returns the natural (base e) logarithm of a specified number|
|saturate||Clamps a number to 0-1|
|sign||The sign of the number (-1, 0 or 1)|
|clamp||clamp(v, min, max) - Clamps v so it is not lower than min or higher than max|
|lerp||lerp(t, a, b) - Linearly interpolates from a to b using t (0-1)|
|smoothstep||smoothstep(t, a, b) - Smoothly interpolates from a to b using t (0-1)|
|min||Returns the smallest of two values|
|max||Returns the largest of two values|
|pow||pow(a, b) - Returns a to the power of b|
|rand||Returns a random value based on an input value, for example rand(t) returns a new value every frame while rand(l) returns a new value every time the effect loops|
|wposx||wposx(n) - Returns the x coordinate of where this unit was n frames ago relative to their current position|
|wposy||wposy(n) - Returns the y coordinate of where this unit was n frames ago relative to their current position|