# Difference between revisions of "Effect file"

Line 50: | Line 50: | ||

====Functions==== | ====Functions==== | ||

− | |||

− | cos | + | {| class="wikitable" |

+ | |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) | ||

+ | |- | ||

+ | |sqrt | ||

+ | |Square root | ||

+ | |- | ||

+ | |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 | ||

+ | |} | ||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

[[Category:File type]] | [[Category:File type]] |

## Revision as of 21:58, 17 April 2017

.effect

## Contents

### File format

#### Sprite

#### Light

#### Trail

#### Param

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" />

#### Variation

#### Data

### Expression language

#### Parameters

There are four built in parameters for effects,

t | time | 0-1 |

l | loop | 0+ |

u | unit | Not 0 |

i | index | 0+ |

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.

#### Functions

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) |

sqrt | Square root |

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 |