Terrain Graphics

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Terrain Graphics

Post by GForce0 »

Hi, I have some questions on how to correctly use [terrain_graphics]

Let's start with a simple example:

Code: Select all

[terrain_graphics]
	x=1-3
	y=9
        [tile]
		x,y=0,0
		type = Hh^Fds
		[image]
			layer=1
			name="forest/forested-deciduous-summer-hills-tile.png"
		[/image]
        [/tile]
[/terrain_graphics]
When I use something like this, I expect that only on hex (1,9) (2,9) (3,9) the image will be placed. Because according to the wiki the x,y under [terrain_graphics] constrains the rule to these absolute coordinates.
However, what happens is that it will put the image on ALL Hh^Fds hexes of the entire map. Even if I change it to just x,y = 1,9, it also does the entire map. This I don't understand. How can I make the rule apply to the hexes I want?

User avatar
doofus-01
Art Director
Posts: 3897
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Terrain Graphics

Post by doofus-01 »

I'm a bit rusty on this, and don't know what's going on under the hood, so I don't want to speculate too much, but I have two thoughts:

1. There is a working example of x,y constrained graphics in mainline UtBS first scenario

Code: Select all


    [terrain_graphics]
        map="
.,  *,  .
, *,  *,
*,  1,  *
, *,  *,
.,  *,  ."
        [tile]
            pos=1
        [/tile]
        x,y=23,27
        [image]
            name=great-tree-smashed.png
            layer=0
            base=108,108
            center=144,108
        [/image]
    [/terrain_graphics]
2. Are you sure it's not working? I didn't test it, but the specified image looks close to what the normal graphics would be and the random image variation selection is often very unfortunate, you can get clumps of identical images.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Re: Terrain Graphics

Post by GForce0 »

The example does work to put a single hex image onto a specified hex. Although I feel this method is more intended for multi-hex images.
For example I can put the image on x,y = 2,10 like this:
Spoiler:
However, I cannot use this method to put the same single hex image on multiple hexes. (My goal being to fill x,y = 1-9,10 with the image)

Also I tried the example from https://wiki.wesnoth.org/MultiHexTutorial with the single mountain tile.
I can add an x,y constraint there to limit the placement to that specific hex:
Spoiler:
However, providing a range or comma-separated list does not work, only the first coordinate is used.
Either I am missing something, or the wiki is wrong and you cannot constrain to coordinateS, which would be very disappointing.

For now the only thing that worked is using a whole lot of [tile] tags with [image] inside them, using relative coordinates for all the tiles I want the image on. But this is a very ugly and inefficient way of doing.

User avatar
beetlenaut
Developer
Posts: 2481
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Terrain Graphics

Post by beetlenaut »

This map should make a horizontal line of five tiles if you use pos=1: *, 1, 1, 1, 1, 1, *. Are you saying you tried this? It's been a long time since I did any graphics, but if I remember right, it does work.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Re: Terrain Graphics

Post by GForce0 »

If I do:

Code: Select all

[terrain_graphics]
	map="*, 1, 1, 1, 1, 1, *"
	x = 2
	y = 10
	[tile]
		pos=1
	[/tile]

	[image]
		name="forest/forested-deciduous-summer-hills-tile.png"
		layer=0
	[/image]
[/terrain_graphics]
Then the single hex image will be on (2,10)

If I leave out

Code: Select all

x,y = 2,10
, then it fills the entire left half of the map with the tile. x=0-15 will be filled, and x=16-26 left untouched.

User avatar
beetlenaut
Developer
Posts: 2481
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Terrain Graphics

Post by beetlenaut »

Now I'm a little bit confused about what you are doing. You don't have a type key any more, so it looks like this [terrain_graphics] tag isn't connected to a [terrain_type] tag. It is [terrain_type] that allows you to use your custom terrain in the editor and makes it visible to the game. The [terrain_graphics] tag just tells what it should look like to the user, and is not even required.

In case that is news to you, here is an example from SotA:
Spoiler:
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Re: Terrain Graphics

Post by GForce0 »

To be honest I am also a bit confused what I am doing because I don't fully get how this should be functioning :doh:
But the reason I didn't bother with type here is because my reasoning was:
It doesn't matter which type of terrain is really present here, I just want the tiles in this area to look like this, and so I will do it by specifying the area it should affect.

But perhaps it's easier for everyone if I take a step back and explain what I am trying to do. The image shows a part of the map. I am trying to make the illusion of two height levels by placing a row of cave walls. Then I want to hide the upper transition from cave walls to forest hills by putting images of forest hills on the transition. Then you only see the lower transition, and it should look as if there is a plateau above the cliff, and lowlands below the cliff. (I hope) But I also do not want to place the forest hills image on all of the actual forest hills tiles, because that would cover the items I placed on some of them using [item]. This is the reason I want to use [terrain_graphics] on specified areas
image.png

User avatar
beetlenaut
Developer
Posts: 2481
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Terrain Graphics

Post by beetlenaut »

The two terrain tags are for making a terrain available in the map editor. It's possible to hack the [terrain_graphics] rules so a terrain shows up on certain tiles, as you have found, but it's not actually made to be used that way. That's why you are having problems doing it like that.

You need a custom forest terrain that is always drawn on top of what is physically below it on the map. (Or a cave terrain that works the opposite way.) Follow my example above and make a new forest terrain that specifies a low negative layer in the [terrain_graphics][image] tag. Layer 0 is where most units are drawn IIRC. Positive numbers are drawn in front of units, and higher negative numbers go farther back into the screen. You might want -1. Give it whatever code you want, but make it aliasof=^Fds. That's the code for Summer Deciduous Forest, so your terrain will be a direct copy of that one. You can find that code in the map editor with a button on the top right or with the :show_terrain_codes command during the game. (The codes are also online.) That new terrain will be available in the editor, and you can paint it wherever you need it on the map.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Re: Terrain Graphics

Post by GForce0 »

Hmm ok, thanks! It seems I completely misunderstood the idea behind it. I will try to play around with this in mind

User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Re: Terrain Graphics

Post by GForce0 »

This works very well to change the graphics on specific tiles!
However, if I put them on layer 1 or higher, troops will be behind the images. But if I use layer 0, the images will be behind the transition that I want to cover. Apparently that is drawn later. Is there a way to make troops be drawn on a higher layer? Or otherwise to change within layer 0 which is drawn last?

User avatar
beetlenaut
Developer
Posts: 2481
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Terrain Graphics

Post by beetlenaut »

GForce0 wrote:
July 19th, 2020, 6:26 pm
Is there a way to make troops be drawn on a higher layer?
I had a similar problem with the bats in SotA. The only way I found to change what layer the troops are drawn in is to make a copy of each unit with a different drawing layer specified in the animation. I only had three units to worry about though. If you have more than that, it's kind of an ugly solution.

I'm surprised there is no layer between the terrain and the units. That's annoying. Maybe you need to do it the other way, with a custom cave terrain that is drawn farther back instead of a forest that is drawn farther forward. Have you tried that?
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Re: Terrain Graphics

Post by GForce0 »

Players are supposed to be able to use any units, so that won't work :doh:

I don't think using a custom cave terrain will work, because by doing that I am not controlling the transition graphics that is drawn on the hexes adjacent to the cave tiles.

Now I am trying something else instead: Just removing the cave altogether and putting an impassable overlay there. Then use [item] to draw the lower transition that I wanted.
Only problem, the images become a bit bluish. I read in another thread this is just how it is handled, but can be solved with wml. How can I do that, to keep the same appearance as the image has originally?

User avatar
beetlenaut
Developer
Posts: 2481
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Terrain Graphics

Post by beetlenaut »

Each time (dusk, morning, first watch, etc.) has a color change associated with it that is applied to terrain images. An image placed with [item] also gets that color change applied. (You can avoid this by using halo=yes, but then the image also goes in front of units.) So, if you clip an image out of the editor or the game and then use it as an [item] image, it will get the time coloration applied twice. I'm assuming that's what you did and why it's turning bluish. If you get the images you need out of the original images from the terrain directory, that should fix the problem.

Some people have gotten around similar problems by duplicating everything for a terrain type along with its transitions and macros, but that might be too much work for a few tiles.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
GForce0
Posts: 20
Joined: May 17th, 2020, 5:58 pm

Re: Terrain Graphics

Post by GForce0 »

Ah, I see indeed what has happened. Then I know what to do, thanks!

Post Reply