Multihex+overlay terrain guidance please!

Discussion and development of scenarios and campaigns for the game.

Moderator: Forum Moderators

Post Reply
User avatar
Spannerbag
Posts: 763
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Multihex+overlay terrain guidance please!

Post by Spannerbag »

Hi,

I'm working on initial ideas for a single player campaign and have a basic (very basic!) idea about terrain but I'm struggling here.
I have created custom villages but what I'm attempting here is much more complex and so I thought I'd ask here before I end up throwing my PC out the window...

What I want to do
Create a 2x2 custom terrain overlay (I'm using ^YSt as the terrain code).
I have created 4 separate hexes (in 72x72 pixel images) that I want to bolt together using map= and [tile].

I have stolen the map from mountains.cfg in the hope that it will work for me (the layout of the terrain I'm working on has the same arrangement).
I.e.

Code: Select all

#Macro for 4-Hex mountains
#define MOUNTAINS_2x2 TERRAIN PROB FLAG IMAGESTEM
    [terrain_graphics]
        map="
.,  *,  .
, *,  *
*,  1,  *
, 1,  1
*,  1,  *
, *,  *
.,  *,   .
, .,  ."

The layout of the 4 hexes (A,B,C and D) in my terrain are arranged thus (just like the 2x2 mountains):

Code: Select all

 B
A D
 C
If A x-coordinate is even: A,B,D have same y-coordinate and C's is +1.
If A x-coordinate is odd: A,C,D have same y-coordinate and B's is -1.

I understand I can apply an [image] to each [tile].
I also want tile D (only) to act like a village for healing but not to generate income.
So in [terrain_type] have

Code: Select all

  heals=8
  gives_income=no
but for tile "D" only - if possible?

However, before I get too bogged down I have a few queries:

1. Is the above possible?
That is, have 1 tile of multi-hex terrain heal/cure units whilst others do not.
If so, how would I do this (I can see a way using 2 separate terrains adjacent to each other but I'd rather not go there).

2. Lots of terrain [images] have variations= (I left them in my custom village terrain as they were in the original .cfg but I have no idea what they do or are for!).
Questions:
What do these do/are they for?
Are they the same as [variant]?
(I can live with the terrain not changing with time of day.)

3. Does the clause heals=8 in [terrain_type] above also cure units?

4. Are the actual flag values set/tested in set_flag / has_flag / no_flag / set_no_flag documented anywhere?

Ideally if you could PM me (so I get an email alert) that would be perfect.

Thanks in advance for your time and trouble, much appreciated!

Cheers,
Spannerbag.
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.18, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
tsunami_
Posts: 23
Joined: June 22nd, 2024, 2:07 am
Location: Pacific

Re: Multihex+overlay terrain guidance please!

Post by tsunami_ »

Hello!
I know this post is a few years old, but multihex terrain is pain, so I will try to make a nice tutorial with images. It will surely be helpful to somebody.

Quick answers:
1. Yes, using image overflow and a healing overlay. I will explain this one.
2. I do not know what you are referring to exactly.
3. Yes - Oasis overlay has this. In fact any amount of heals will also cures.
4. As far as I understand, you can make up any flag you want and it will only check for one if you ask it.



First of all, I will explain your mountain map.
., *, .
, *, *
*, 1, *
, 1, 1
*, 1, *
, *, *
., *, .
, ., ."

The "1" are hexes that have the correct terrain type. the "*" are overflow hexes. The "." are unaffected hexes (these are used to line up the others correctly). "," divides the hexes.
Like this:
1-mountain-label.png
Now, I assume you want to create an overlay something like this:
2-house-want.png
You said you have separated tiles. However, if they always go together, I suggest glueing them together into one image. This will make life simpler. I will use this method.

Step 1: Create image at the correct size.
Step 2: Determine which hexes are overflow.
Now, you don't want your southern tile to have the overlay, because you want to add a heals+8 overlay after. So it will be an overflow hex.
Like so:
3-house-layout-1.png
3-house-layout-1.png (217.09 KiB) Viewed 1071 times
In fact, you can make all but one hex overflow if you want:
4-house-layout-2.png
4-house-layout-2.png (217.07 KiB) Viewed 1071 times
Step 3: Crop image
Now this is important: The game will line up the top-left corner of your image with the top-left corner of a square that contains all affected hexes. So if you make a square that exactly surrounds your hexes, you won't have to worry about "centre= x,y" or anything like that.
In this example, the image is cropped to size 234x216 (3 1/4 hexes wide, 3 hexes tall).
5-crop-suggestion.png
5-crop-suggestion.png (210.36 KiB) Viewed 1071 times
house-overlay.png
house-overlay.png (4.48 KiB) Viewed 1071 times
(continued)
Last edited by tsunami_ on March 10th, 2025, 6:42 am, edited 1 time in total.
User avatar
tsunami_
Posts: 23
Joined: June 22nd, 2024, 2:07 am
Location: Pacific

Re: Multihex+overlay terrain guidance please!

Post by tsunami_ »

(continuation)

Step 4: Move your image into the terrain folder.

Step 5: Code
Now, you just need to write your image in map-notation.
Hopefully, this picture makes it clear:
6-map-code-1.png
Here is the terrain code for this particular image. (You need to change the editor group to use it of course).

Code: Select all

[terrain_type]
    symbol_image=house-overlay
    id=housebig
    name= _ "house overlay"
    editor_name= _ "house overlay"
    string=^Yh2
    aliasof=_bas # This code gives it the mov/def of the base terrain.
    editor_group=HBX
[/terrain_type]


[terrain_graphics]
	map="
. , * ,
, * , * ,
* , 1 ,
, 1 , 1 ,
. , * ,"

    [tile]
	pos=1
	type=*^Yh2
	set_no_flag=overlay
    [/tile]
        probability=100
    [image]
        name = house-overlay.png
        layer=0
	base=144, 144 # measured from the top-left corner of the image
    [/image]
[/terrain_graphics]
Now you can add your overlay in the editor. The image will only appear if you draw the pattern that matches your "map=". In this case three "*^Yh2" tiles in a row.
As you can see, the southern tile has no overlay. So you can add a different one, in your case an invisible village or heals+8 one.
7-house-in-editor.png
Now, maybe you want to make sure that there is always a village-overlay (^Vov) in the south. In this case, you can use multiple tiles. pos=1 for the house tiles, pos=2 for the village overlay.
Here is the new map and code.
8-map-code-2.png

Code: Select all

[terrain_graphics]
	map="
. , * ,
, * , * ,
* , 1 ,
, 1 , 1 ,
. , 2 ,"

    [tile]
	pos=1
	type=*^Yh2
	set_no_flag=overlay
    [/tile]
    [tile]
	pos=2
	type=*^Vov
	set_no_flag=overlay
    [/tile]
        probability=100
    [image]
        name = house-overlay.png
        layer=0
	base=144, 144
    [/image]
[/terrain_graphics]
Now, the house will only appear if you have both the three house tiles and the village overlay.
9-correct-map.png

(End)

I hope it makes sense! :D
User avatar
Spannerbag
Posts: 763
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Multihex+overlay terrain guidance please!

Post by Spannerbag »

Wow, many thanks for your post, it must have taken some time so I really appreciate your efforts!
tsunami_ wrote: March 10th, 2025, 6:24 am ...
1. Yes, using image overflow and a healing overlay. I will explain this one.
2. I do not know what you are referring to exactly.
3. Yes - Oasis overlay has this. In fact any amount of heals will also cures.
Thanks for the clarification/confirmation.
4. As far as I understand, you can make up any flag you want and it will only check for one if you ask it.
...
  1. Thanks! Good work. 8)
  2. I think I understand that now: if I'm right it refers to different graphics for a single terrain (e.g. villages).
    Presumably which actual graphic appears is determined by the terrain rules (based on location, time of day etc.) but I'm unclear on the detail of this logic.
    Below: same terrain code, different appearance.
    vvar.jpg
    vvar.jpg (18.37 KiB) Viewed 940 times
  3. Oh, I didn't know heals always cures also.
  4. I'd kinda realised that since posting but always helpful to have confirmation. :)
I've only skimmed your post so haven't digested the details yet - as ever I'm pushed for time, but wanted to say thanks.
My own understanding of terrain has moved on somewhat and I managed to work around the particular problem that gave rise to my post... however I can certainly find a use for multihex terrain, as workarounds are tedious and often mandate significant map and code changes.

Another terrain related subject for your tutorial, if you are feeling generous, would be to summarise how (assuming this is possible) to have multiple overlays on a single hex by specifying different layers so you could have, for (trivial) example, a wooden bridge over a railway track.

Sheesh, amazing how time goes by... can't believe I posted that over 5 years ago! :shock:

The post arose from 2 separate requirements in different campaigns.
One was for my campaign Leafsea Burning (published, currently undergoing major surgery as a result of feedback and my "good ideas").
I've not had much chance to work on the other campaign since then, it's been languishing at around 50-60% complete for ages. :(

I will certainly give your posts a thorough perusal when I have the headspace (and time to experiment), probably next weekend.
Thanks again for taking the trouble to reply, much appreciated.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.18, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
tsunami_
Posts: 23
Joined: June 22nd, 2024, 2:07 am
Location: Pacific

Re: Multihex+overlay terrain guidance please!

Post by tsunami_ »

Spannerbag wrote: March 10th, 2025, 12:26 pm Wow, many thanks for your post, it must have taken some time so I really appreciate your efforts!
You are welcome! It took less time to write the post than to figure all this out in the first place. So if it helps someone else skip the frustration, then it was worth it, you know?
Spannerbag wrote: March 10th, 2025, 12:26 pm Another terrain related subject for your tutorial, if you are feeling generous, would be to summarise how (assuming this is possible) to have multiple overlays on a single hex by specifying different layers so you could have, for (trivial) example, a wooden bridge over a railway track.
Actually, I was looking for help with layering when I found your post :lol:. If you think it will be useful to people, I can make a tutorial once I figure it out. In fact I think I will try to implement your example, since it is a lot simpler than what I was trying (over-ambition - always the problem).
Spannerbag wrote: March 10th, 2025, 12:26 pm I will certainly give your posts a thorough perusal when I have the headspace (and time to experiment), probably next weekend.
Please tell me about anything unclear in my tutorial, once you've tried it, so I can make it better.
Thank you! :)
User avatar
Spannerbag
Posts: 763
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Multihex+overlay terrain guidance please!

Post by Spannerbag »

tsunami_ wrote: March 11th, 2025, 8:19 am ... if it helps someone else skip the frustration, then it was worth it, you know?
Well that's a :D from me!

tsunami_ wrote: March 11th, 2025, 8:19 am ...I think I will try to implement your example, since it is a lot simpler than what I was trying (over-ambition - always the problem).
I have exactly the same tendency when designing campaigns... I'll create a short, concise one some day... perhaps... nah, probably not. :)
tsunami_ wrote: March 11th, 2025, 8:19 am Please tell me about anything unclear in my tutorial, once you've tried it, so I can make it better.
Roger wilco!
Look forward to reading it. :D
Thanks again.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.18, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
Post Reply