Topic: [MAPPING] How to set up your own rules for automapper [OUTDATED]
Refreshed images. // Dune
Hey lil Teeworlds community,
cuz I got kind of bored I decided to write down a little tutorial about how to get that stuff about the automapper running.
As far as I got to know out of the base rules of the automapper I will try to explain in the best possible way.
First of all you guys will get to know the basic of how think when writing down such rules.
The following picture will discribe how it works in teeworlds, as you may see, the y-axis is kind of different, so keep that always in mind while writing your "rules".
As you may already see, you begin to count the "Index" at 0 0.
At the beginning you have to decide which tile will become the basetile of the whole map.As you already know the basetile from grass_main.png is the "dirt" tile.
Index 1
BaseTile
At first you have to decide which "tiles" or as other people may call it "mapres" you wanna set.
For example we want to get a normal ground tile with the "Index 16" as you may see on the upper picture.
The ground tile with the Index 16 needs some special conditions to get set on the right place.
for this Tile it is kind of easy:
- you need nothing to be above it
This would be the easiest way to set some easy conditions but as of complexity of maps as you may know there will be always errors if you write down way too easy rules.
- you need the basetile to be under the ground tile (16)
As of the easy example given by the devs you can see, that there are no Basetiles defined below the "top" or just ground tiles.
#top
Index 16
Pos 0 -1 EMPTY
This rule defines that there has to be one empty tile above the tile with the Index 16 for it to be placed.
Meaning: If there is no empty tile above, this ground or top tile won't be set by the automapper.
I would prefer a little bit different function for this rule.
as shown here:
#top
Index 16
Pos 0 -1 EMPTY
Pos 0 1 FULL
I adds the requirement 'to have ONE tile under it' to be set by the automapper
You may have noticed, if you read the rule files, that there are most likely before each of this "Index rules"
headers like
#top
I am not shure whether it is there to divide the rules from each other but i think commenting the rules in your fule files wouldn't be bad. So don't be lazy and get your rules a header.
Now I am going to explain will the rules I have found in the base *.rule files made by the devs.
[Grass]
......
[Cave]
Here I am taking the grass_main.rule file as an example.
In one rule file you are able to have more than one block of rules.
Reasons could be:
- you ave got more than only one BaseTile
Here it would be the gras main BaseTile and also the Cave one's BaseTile, which explains why there are two catigories of rules in this file.
#Header of any kind of rule
..already explained
Now i think the following "command" or rather "requirement" for tiles to be set by the automapper is:
Pos
If you want a tile to be set, you need to have a "Position" to have a given kind of properties like:
You want Index "x" only to be set if there are at least four tiles next to it, also one above, one beneath, one left and one right from it, so you define the rule like this:
#Header of your rule
Index "x"
Pos 1 0 <-- one right from it
Pos -1 0 <-- one left from it
Pos 0 1 <-- one beneath
Pos 0 -1 <-- and one above Index "x"
Please do not forget that your defined Index "x" has the Pos(ition) 0 0, so you begin to count from 0 0 to get your needed positions to be filled by any kind of tiles
The next step is to define what tiles have to be on that positions that defines the position of your Index "x" tile.
So you have your Index "x" and you just want to have any kind of tile next to it, so you define it like shown:
#Header of your rule
Index "x"
Pos 1 0 FULL
Pos -1 0 FULL
Pos 0 1 FULL
Pos 0 -1 FULL
The property "FULL" expresses that the given position just hast to have any kind of tile.
Because the whole rules script is case sensitive, you have to write ALL of the commands as shown in the dev's base rule files. And please do not forget to set one space between the y-coordinate and the property of the position.
Next property of the Pos command is:
EMPTY
It is the same as FULL but as you may already know the given position has to be EMPTY for the Index "x" tile to be set.
Index "whatever"
Index "..." can also be a property of the Pos command.
It would be written like this:
Index "x"
Pos 1 0 Index "whatever" <-- Pos: one to the right has to be Index "whatever"
for this tile to be set by the automapper.
It's kind of bad for complex maps WITHOUT the following properties of Pos, cuz they do not exist there are some functions missing.
DO NOT COPY CUZ THEY DO NOT EXIST:
Pos 1 1 Index "y" XFLIP
Pos 1 1 Index "y" YFLIP
Pos 1 1 Index "y" XYFLIP
This ideas could be some improvements for the automapper.
As well as the Pos command the Index command has some special properies:
Index "x" XFLIP
With this property the tile "x" is set after one horizontal flip.
There is also the property:
Index "x" YFLIP
With this property the tile "x" is set after one vertical flip.
As far as I read the rule files, the following command should be the last one.
It's called:
Random "***"
As you may know the meaning of the word "random" you can already say what kind of command this is.
As far as I know and as far as I experienced it sets the Index "x" tile after the "***" count of BaseTiles onto a random spot.
For example you want to set the bones randomly on the map:
#random bones
Index 2
Pos 0 1 FULL
Pos 0 -1 FULL
Pos 1 0 FULL
Pos -1 0 FULL
Random 150
I think this would mean, that the Bones (Index 2) are set by the automapper after 150 positions that comply with the given requirements of the rule(Pos x y .....)
One little rule as a highlight of this tutorial
#random tee-skeletons
Index 64
Pos 1 0 FULL
Pos 2 0 FULL
Pos -1 0 FULL
Pos 2 2 FULL
Pos 2 -1 FULL
Pos -1 2 FULL
Random 100
#---------
Index 65
Pos -1 0 INDEX 64
#---------
Index 80
Pos 0 -1 INDEX 64
#---------
Index 81
Pos -1 -1 INDEX 64
#---------
Hope you liked it and understood it quite well.
If there are any questions or complaints about this tutorial, please feel free to post them so I can improve this tutorial.