Immovables can have programs that will be executed by the game engine. Each immovable has a program named ''program'', which will be started automatically when the immovable is created in the game, and then repeated until the immovable is destroyed. If that program is not explicitly defined, it is created automatically and will contain a single command that will run the ''idle'' animation forever. Each program must be declared with program=''<name>'' in the [''global''] section of the immovable's definition. A program is defined in the section that has the same name as the program (the order of program definitions does not matter). A worker can call an immovable program. A program consists of a sequence of commands. A command is written as ''<type>=<parameters>''. The different command types and the parameters that they take are explained below.</parameters></type></name>
Runs an animation.
- parameters ::= ''animation'' [''duration'']
- ''animation'': The name of an animation (defined in the immovable).
- ''duration'': A positive integer. If omitted, the duration is infinite.
Starts the specified animation for the immovable. The actual duration is a random number from 1 to ''duration'' * 2 - 1, with [http://en.wikipedia.org/wiki/Binomial_distribution binominal distribution].
Blocks the execution of the program for the calculated duration. (The animation will not be stopped by this command. It will run until another animation is started.)
Plays a soundFX.
- parameters ::= ''soundFX'' [''priority'']
- ''soundFX'': The filename of an soundFX (relative to the immovable's directory).
- ''priority'': An integer. If omitted, 127 is used.
Plays the specified soundFX with the specified priority. Whether the soundFX is actually played is determined by the sound handler.
Removes the immovable and replaces it with a new immovable of another type.
- parameters ::= ''typename'' [''probability'']
''typename'': The name of the type of the new immovable. For a tribe immovable, the name refers to an immovable type defined in that tribe. If the name includes the prefix "world:", the name refers to an immovable type defined in the world. The name may not refer to the immovable type that the command is defined for.
''probability'': A positive integer in the range 1 .. 254. The probability that the transformation will be done. If omitted, the transformation is unconditional.
Like transform but takes into account how well the immovable thrives.
- parameters ::= ''typename''
- ''typename: (see transform)
The probability that the transform will be done is determined by how well the immovable thrives. This is currently only influenced by the terrain types of the surrounding triangles. See the section about terrain affinity.
Like transform but does not create a new immovable.
- parameters ::= [''probability'']
- ''probability'': (see transform)
Creates a new immovable at a random location near the immovable.
- parameters ::= ''typename'' [''probability'']
''typename'': The name of the type of the new immovable. For a tribe immovable, the name refers to an immovable type defined in that tribe. If the name includes the prefix "world:", the name refers to an immovable type defined in the world.
''probability'': A positive integer in the range 1 .. 254. The probability that the seed will travel one distance step further away.
Like for grow, the probability that a command of this type will do anything at all is determined by how well the immovable thrives (see grow). If the command will do anything, it will do it as follows.
First, the distance is set to 0. Then, a random number in the range 0 .. 255 is generated. If this number is less the parameter ''probability'', the distance is increased and a new number is generated and used in the same way. Otherwise the distance calculation is finished. This will give the distance a geometric distribution.
When the distance has been chosen, a location with that distance from the immovable is chosen randomly.
Then it is calculated how well the immovable thrives at the chosen location (see grow). This determines the probability that the seed will germinate there. If so, a new immovable of the specified type is created there.
Each immovable type can define a terrain affinity. It determines how well immovables of this type thrive on different terrain types. This influences the probabilities that immovables of this type will grow and seed.
The immovable type can have the section [terrain affinity] with key=value pairs. Each key is the name of a terrain type and the value is a natural number in the range 0 .. 255. The value 0 is used for terrain types that are not assigned an affinity value.
To calculate how suitable a node is for the immovable type, the affinity values of the terrain types of the 6 surrounding triangles are added. This gives a value in the range 0 .. 6 * 255.