Map documentation

Discuss the future of Warzone 2100 with us.
Post Reply
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

Map documentation

Post by Prot »

Someone has documentation on the format of map files?
I need to parse game map, but i not understand of the some files like game.map and ttypes.ttp, and also is coordinates format, in game JS API act like map tiles, but in map files, coordinates very long, like pixels of the map.
Example of feature.ini:

Code: Select all

[feature_0026]
id = 26
position = 3648, 13376, 20
rotation = 0, 0, 0
name = OilResource
I would like to know the ratio between the tiles and the pixels. And just want to parse the map tiles, having received information about the water and cliffs for making better bot AI.
And i need specification of map binary files, to parse it byte by byte.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Map documentation

Post by aubergine »

ttypes.ttp is something to do with terrain IIRC, but never worked out exactly what or how it works.

Co-ordinates format is based in pixels, where 128 pixels = 1 map tile. So the position you show above is x=28.5 tiles, y=104.5 tiles (so the middle of tile at 28,104).

As for the Z index, I have no idea how that works - IIRC in the JS API it's often a negative number -- the higher the altitude, the more negative the number!

Anyway, I don't think there's any docs for any of this stuff yet - want to create some as you find out what things are? Would be huge help for many people!

Some links that might be of use in our quest:

* http://developer.wz2100.net/wiki/MapFormat
* http://developer.wz2100.net/wiki/ConvertingOldMaps
* http://developer.wz2100.net/wiki/ModdingTilesets
* https://warzone.atlassian.net/wiki/page ... Id=5406726
* http://warzone2100.org.uk/
* https://github.com/Emdek/wz-map-editor
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Map documentation

Post by Per »

I think the easiest way to understand the map format is to read the code I wrote for loading these files from command line utilities -
https://github.com/Warzone2100/warzone2 ... apload.cpp - but that may just be bias since I wrote them :)

ttypes.ttp contain which terrain textures have which terrain basic types.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Map documentation

Post by NoQ »

And just want to parse the map tiles, having received information about the water and cliffs for making better bot AI.
And i need specification of map binary files, to parse it byte by byte.
You just won't be able to do it inside an AI script. API isn't given access to physfs.

What you may consider doing is calling propulsionCanReach() on adjacent tiles, this gives you complete passability information. No faster method exists, i think.
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

Re: Map documentation

Post by Prot »

I finally found the time to figure this out looking into game.cpp and map.cpp from gamesource. Wrote a bash/php script for parsing maps files "game.map" and "ttypes.ttp", hail map templates for AI !! :D
Now i can pass to my bot the info about cliffs(Yellow), water(blue), Weight of terrain from height(gray scale) and gateways(red) :3

Image
Image
Image
Image
Image
Image
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Map documentation

Post by NoQ »

I think i committed terrainType(x, y) (5.50 in the docs at the moment) since then (3.2+).

There are no functions for retrieving height, but it's easy to add if have a good use for it.

Note that height is not a property of a tile, but of a vertex between four tiles.
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

Re: Map documentation

Post by Prot »

NoQ wrote:I think i committed terrainType(x, y) (5.50 in the docs at the moment) since then (3.2+).

There are no functions for retrieving height, but it's easy to add if have a good use for it.
cool, but i use 3.1.5 or at least for both versions. And i do precalculate distanses with a* then use templates for maps. In JS calculate in realtime it's too much expencive for bot script.
NoQ wrote:Note that height is not a property of a tile, but of a vertex between four tiles.
Yeah. It top left corner, i to much learn from code, even i do not need it anymore :lol2:
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Map documentation

Post by NoQ »

Prot wrote:
NoQ wrote:I think i committed terrainType(x, y) (5.50 in the docs at the moment) since then (3.2+).

There are no functions for retrieving height, but it's easy to add if have a good use for it.
cool, but i use 3.1.5 or at least for both versions. And i do precalculate distanses with a* then use templates for maps. In JS calculate in realtime it's too much expencive for bot script.
You can do something like "if version is 3.2+, pre-calculate whatever you like in eventGameInit()". If it's about a few seconds (note that javascript is relatively fast by itself), users won't notice (the game doesn't start instantly anyway). Unfortunately, it'd need to be done for all players independently (so multiply time estimates by 9).

Squeezing pre-computed data into the AI would, on the other hand, quickly increase mod size when more and more maps are thrown into it, and supporting all future maps is also great.

Alternatively, you can pre-compute your stuff in background, taking at, say at most 10-20 milliseconds of each game frame in the early game (different scripts can be easily taught to take non-overlapping game frames, and also other CPU stress is much lower in early game).
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

Re: Map documentation

Post by Prot »

Maybe it's necroposting.
But at the beginning of 2018 I started to write the documentation of the maps data.
https://wz2100.euphobos.ru/docs/map.html
At the moment it is completely finished for versions 3.2+ and 3.3+
I never completed the description of maps and objects (bjo) to version before 3.1 branch, but in this last version of the game, they are no longer relevant, because maps store everything in JSON.
The only drawback is thats need to be translated from Russian into English.

I also wrote a library that works with maps, can read them, make previews in a color scheme similar to the game, convert json->bjo and Vice versa bjo->json, automatically on the fly add spectators to the map, and even made a preliminary map generator.
This library already works on my website: https://wz2100.euphobos.ru/maps/
If someone need this, perhaps later I will publish on github, after I bring the code in order.
Post Reply