I‘d recommend you to have some programming background – otherwise you might find it hard to understand some aspects of this article. I must mention something concerning this article: some content could be used to create hacking tools and bots. I am aware of this fact, but it is like with all tools: they can be used for good and for bad things. With a hammer you can either build a house or kill your neighbour, then please:
do something good for the community and don’t misuse your knowledge!
Another side note: the entire code you will see in here is written in Delphi XE2. It shouldn’t be hard to port it though.
In this article I will give you a detailed explanation of the Tibia map format (C++ client).
You can find the map data at “%AppData%/Tibia/Automap” for Windows or “~/.tibia/automap” for Linux.
You will find a hell lot of files inside that folder – this is your automap. The automap is broken down into 256×256 big pieces.
The file name consists of: “xxxyyyzz.map” where x is the x coordinate, y the y coordinate and z the height of the map piece (7 is the regular ground level, 0 stands for deepest underground and 15 for the topmost floor). These numbers are filled up with zeros. They range from “000000000.map” to “25525515.map”.
If an area has not been explored yet, the file does not exist. As soon as you visit even a tiniest part of it, the file gets created.
III. Map Format
It is actually a really easy system, just the details get a bit tricky:
-65536 bytes: 256×256 bytes, each byte representing 1 visible pixel of the map
-65536 bytes: 256×256 bytes, each byte representing the walking speed on a specific tile
-4 bytes: the amount of markers on the map
The following section appears once for each marker on the map, if there are no markers the file ends here.
-1 byte: x position
-1 byte: map tile the marker is on on the x axis
-2 bytes: blank, they are always zero
-1 byte: y position
-1 byte: map tile the marker is on on the y axis
-2 bytes: blank, they are always zero
-4 bytes: the image ID of the marker
-2 bytes: length of the description that follows
-n bytes: the description of the marker, each byte representing 1 ANSI character, not zero terminated
Well – this seems easy! Let’s go into more details:
IV. Graphical map colors
If you play around a little with the map files you will find out that Tibia doesn’t use all of the 256 possible colors – actually ONLY the following 15 (maybe 16):
type TTibiaMapColor = record colorID: byte; r,g,b: byte; end; var TibiaMapColorList: array[0..15] of TTibiaMapColor = ( (colorID:000;r:000;g:000;b:000), // tar, void, inner cave walls, undiscovered area (colorID:012;r:000;g:102;b:000), // trees or bushes, (colorID:024;r:000;g:204;b:000), // grass or stone ground, (colorID:030;r:000;g:255;b:000), // swamp (colorID:040;r:051;g:000;b:204), // water (colorID:086;r:102;g:102;b:102), // mountain or rock (colorID:114;r:153;g:051;b:000), // cave wall (colorID:121;r:153;g:102;b:051), // cave mud (colorID:129;r:153;g:153;b:153), // normal floor or road (colorID:179;r:204;g:255;b:255), // ice walls (colorID:186;r:255;g:051;b:000), // wall (colorID:192;r:255;g:102;b:000), // lava (colorID:207;r:255;g:204;b:153), // sand (colorID:210;r:255;g:255;b:000), // ladder, hole, rope point, stairs or a teleporter (means of transporting without the use of NPCs) (colorID:215;r:255;g:255;b:255), // snow (colorID:255;r:150;g:000;b:255));// unknown
colorID is the byte written in the file, r, g and b are just the regular RGB colors used by the client to display the automap.
Please note that I have only found the id 255 at a single pixel and when I went there to check it, Tibia client removed it and replaced it with 0, so it was probably just a bug. But you can never know for sure – after all, 16 colors would make more sense than 15.
This one is quite easy:
1-250: the lower the value is, the higher is your movement speed on that tile
251-254: not used
Please note that stairs/teleporters etc. are marked as non-walkable too, so you’d need to check if this tile is marked as stairs/tp in the graphical map to be sure it is non-walkable.
If you combine those two maps you can do a very nice pathfinding, even (for example) calculate what’s the fastest way from Thais to Ab’Dendriel. (google for “A* Pathfinding”)
If i find a way to post them in a better way i will do so.
Thank you for reading my article! If you liked it, please leave your comment at the bottom of this page.
If you didn’t like the article, please write a comment as well and tell me what do you think it lacked or what you disliked.
See you soon (or a little bit later) in a article on the network connections of Tibia.
Have fun playing!