Out-of-game Map generation and Tiled Map Editor

Discussion of all aspects of the game engine, including development of new and existing features.

Moderators: Forum Moderators, Developers

Post Reply
User avatar
nyov
Posts: 20
Joined: July 7th, 2019, 1:45 pm

Out-of-game Map generation and Tiled Map Editor

Post by nyov » July 14th, 2019, 10:27 am

Heya, I'm interested if anyone ever tried to clone the map-rendering logic of BfW and make it "standalone", or, more widely accessible.

That probably sounds ridiculous; why take the mapeditor out of the game only create another mapeditor then?
Well, there is this really decent, generic, tile-oriented map-editor called Tiled. Most, who have worked on tile-based games, have probably heard about it.
It has gained a pretty rich feature-set (in common features, which would apply to most tile-maps).
And it can now handle hex-based tile-grids (of pretty much any possible configuration - which is awesome).

So usually, to make it work with <random> game, you just need to write a parser for <random>'s map-format; perhaps another one to cut <random>'s spritemaps into single images for Tiled tilesets, and you're done and can create <random> maps in Tiled.

tiled1.png

Obviously, not so with BfW :lol: The amount of customization w.r.t. adjacency/tile composition is pretty amazing (not to say hardcore) in BfW. I probably haven't yet dug to the bottom of those capabilities, but from the info on the Wiki (building castle tiles - concave and convex sprite sets) and the map-editor (where I see hexes composed of thirteen bitmaps), I can see how that requires some specialized capabilities in layout- and rendering code.

But Tiled comes with a C++ plugin functionality. So perhaps the rules of BfW's "adjacency" tile-rendering could be codified as such a plugin.
Tiled supports map layers, so ultimately it should be able to manually render this system already, if one were to blit every sprite of a hex onto another map layer (e.g. base tile on "layer 1", any north-east corners on "layer 3", south-east corners on "layer 4", south on "layer 5" and so on).

tiled2.png

So, yeah, has anyone done something in that direction, or would be interested in doing so? Would there be reasons against doing so (BfW's too specialized / hacky or suboptimal, with better solutions of doing the same out there, so no reason to proliferate it)?

User avatar
Pentarctagon
Forum Administrator
Posts: 4057
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Out-of-game Map generation and Tiled Map Editor

Post by Pentarctagon » July 14th, 2019, 9:17 pm

Terrain and how to handle the transitions between hexes is definitely one of the more obscure and opaque aspects of Wesnoth's functionality. The 2.0 overhaul is the only attempt I recall to re-write that logic entirely, and there's been some trouble getting that to work well.

As far as reasons to potentially not do this:
* The current editor also has some basic functionality for creating scenarios, such as placing units on the map.
* The terrain transition logic would still be needed when playing, so if the map editor were moved out as a plugin to this program it would mean this logic would exist in two places instead of one.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

User avatar
josteph
Developer
Posts: 738
Joined: August 19th, 2017, 6:58 pm

Re: Out-of-game Map generation and Tiled Map Editor

Post by josteph » July 15th, 2019, 1:07 pm

If you want to make Tiled support Wesnoth, the simplest answer is not to bother reimplementing terrain transitions in Tiled at all. Just use the base sprites of each terrain type. Showing the terrain statistics (base terrain types, defense cap, healing/illumination, etc) is much more important.

User avatar
nyov
Posts: 20
Joined: July 7th, 2019, 1:45 pm

Re: Out-of-game Map generation and Tiled Map Editor

Post by nyov » July 17th, 2019, 3:31 pm

Pentarctagon wrote:
July 14th, 2019, 9:17 pm
* The current editor also has some basic functionality for creating scenarios, such as placing units on the map.
* The terrain transition logic would still be needed when playing, so if the map editor were moved out as a plugin to this program it would mean this logic would exist in two places instead of one.
Yeah, the idea definitely isn't to remove the ingame editor. That is a neat integration which doesn't require the user to have some dev-environment to build maps or scenarios. I would rather think it an alternative option, to support projects such as
viewtopic.php?t=44416 or
https://github.com/ancestral/Wesnoth-Canvas
The second one is pretty much my own interest in this: rendering maps outside the game.

josteph wrote:
July 15th, 2019, 1:07 pm
If you want to make Tiled support Wesnoth, the simplest answer is not to bother reimplementing terrain transitions in Tiled at all. Just use the base sprites of each terrain type. Showing the terrain statistics (base terrain types, defense cap, healing/illumination, etc) is much more important.
I'm not sure game-specific stats like defense cap and healing would be the job of Tiled engine? But it should be possible to implement as additional layers/overlays to flip on and off.
And I guess it would be possible to map without transitions. The map format doesn't include those after all, so theoretically they're just added fluff, by some computing algorithm. But without those transitions, maps will look like this, and as a visual type it's quite hard for me to envision the final product from this (Of course it would be a first step):
http://mproud.com/wesnoth/canvas/
http://mproud.com/wesnoth/canvas/
Comparison: ingame editor
Comparison: ingame editor
I did some testing with Python Tiled plugins, but ultimately found it might be easier to write a BfW-map converter to Tiled's TMX (map) and TSX (sprites) formats, outside Tiled, because the map doesn't include the sprites or references them. I'll shelve this, though, at the moment, as I don't have that much time for side-projects.

User avatar
josteph
Developer
Posts: 738
Joined: August 19th, 2017, 6:58 pm

Re: Out-of-game Map generation and Tiled Map Editor

Post by josteph » July 17th, 2019, 4:43 pm

nyov wrote:
July 17th, 2019, 3:31 pm
But without those transitions, maps will look like this, and as a visual type it's quite hard for me to envision the final product from this (Of course it would be a first step):

canvas.jpgingame.jpg
Yes, a first step is what I meant. I see it can be hard to adjust to this sort of map if you're used to the in-game map, but I think you might get used to this sort of map after using it for a while. Even if we implemented a terminal interface to wesnoth, some people would get used to that.

I think this kind of simplified view might even be useful. Were I to balance a map, I'd love to have a view where all flat hexes used the same sprite, all forest-on-mountains hexes used the same sprite, all forest-on-hills hexes used the same sprite, etc., eliminating the visual distinctions between grass and farmland, elvish village and dwarvish village, and so on, which have no effect on gameplay. A view with full terrain transitions would be useful too, of course, but we have the in-game editor for that :)

User avatar
nyov
Posts: 20
Joined: July 7th, 2019, 1:45 pm

Re: Out-of-game Map generation and Tiled Map Editor

Post by nyov » July 18th, 2019, 12:20 am

Seeing both shots side-by-side makes it easier. Before I loaded it in the ingame editor, I wasn't even aware it was Hamlets I was looking at. :lol:
But I can see there might be times it would make sense to look at it like that. And it would be easy to disable transitions once they're implemented (wherever), because they're just this render-algorithm on top of the base sprites (which is nice).

Post Reply