How to apply [terrain_graphics] to a part of the map?

The place to post your WML questions and answers.

Moderator: Forum Moderators

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
Mechanical
Posts: 388
Joined: June 29th, 2015, 4:11 pm
Location: Russia

How to apply [terrain_graphics] to a part of the map?

Post by Mechanical »

Hi. One of my scenarios is a winter map that has a cave on it. I wanted to add a falling snow effect to all map tiles except the cave area.

I tried different options, but in the end the snow either appeared on all the tiles at all or not at all.

My last attempt looked like this:

Code: Select all

[terrain_graphics]
x="0,1,2,3,4,5,6,7,8,9,10,11,11,12,13,14,15,16,16,17,17,18,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42"
y="0-42,0-42,0-42,0-42,0-42,0-42,0-42,0-42,0-42,0-42,1-42,0,2-42,3-42,5-42,6-42,9-42,7,10-42,11-16,18-42,11-15,17-42,18-42,18-42,19-42,19-42,20-42,20-42,21-42,19-42,19-42,18-42,18-42,17-42,17-42,17-42,19-42,18-42,19-42,19-42,20-42,20-42,22-42,22-42,23-42,24-42"
        [tile]
            x,y=0,0
        [/tile]
        [image]
            layer=1
            name=snow/SnowSlowR_[0~199].png~FL()~O(0.35):25
            random_start=yes
        [/image]
[/terrain_graphics]
Coordinates are all map tiles except for the cave tiles.

I also tried filtering the tiles by terrain, like:

Code: Select all

[tile]
type=Rb
[/tile]
but that had no effect.

I read the [terrain_graphics] documentation, but apparently I couldn't understand it completely, that's why I'm asking for help.
User avatar
Saizo-Luz
Posts: 83
Joined: June 14th, 2024, 12:50 pm
Location: High Heavens

Re: How to apply [terrain_graphics] to a part of the map?

Post by Saizo-Luz »

I'll put everything here!

I suppose you have the snowfall images... so...

Code: Select all

#define SNOWFALL
    [terrain_graphics]
        map="
1

*"
        [tile]
            pos=1
            set_flag=snowfall
            no_flag=snowfall
        [/tile]

        [image]
            position=horizontal
            layer=1000
            name=weather/blank.png
            [variant]
                tod=snowy_dawn,snowy_morning,snowy_afternoon,snowy_dusk,snowy_first_watch,snowy_second_watch
                name=weather/snow/snow-[1~6].png:80
            [/variant]
        [/image]
    [/terrain_graphics]
#enddef
You can create this macro and define at the top of the scenario.

Code: Select all

[scenario]
    {SNOWFALL}
[/scenario]
Or put everything! Just erase the #define and #enddef

Now... the important thing: the TOD
It's the schedule! If you're using the normal schedule, put their id in the TOD

Code: Select all

tod=dawn,morning,afternoon,dusk,first_watch,second_watch
Then you just need to create a time area to the cave. It's easier to use the type of the terrain, so it'll be underground only on the cave terrains

Code: Select all

[time_area]
        id=cave
        {UNDERGROUND}
        terrain=Xu,Ur,Uu,Uh,Tb^Tf
[/time_area]
It's just an example: Xu,Ur,Uu,Uh,Tb^Tf are cave terrains.

It won't snow in the cave, because you put the schedules when it should snow in the TOD. Don't forget to put the right path to the snowfall image files.
Attachments
Like This!
Like This!
A lot of add-ons has these images - it's 6
A lot of add-ons has these images - it's 6
snow-1.png (437 Bytes) Viewed 2159 times
User avatar
Mechanical
Posts: 388
Joined: June 29th, 2015, 4:11 pm
Location: Russia

Re: How to apply [terrain_graphics] to a part of the map?

Post by Mechanical »

Saizo-Luz wrote: December 29th, 2024, 2:18 pm I'll put everything here!

I suppose you have the snowfall images... so...

Code: Select all

#define SNOWFALL
    [terrain_graphics]
        map="
1

*"
        [tile]
            pos=1
            set_flag=snowfall
            no_flag=snowfall
        [/tile]

        [image]
            position=horizontal
            layer=1000
            name=weather/blank.png
            [variant]
                tod=snowy_dawn,snowy_morning,snowy_afternoon,snowy_dusk,snowy_first_watch,snowy_second_watch
                name=weather/snow/snow-[1~6].png:80
            [/variant]
        [/image]
    [/terrain_graphics]
#enddef
You can create this macro and define at the top of the scenario.

Code: Select all

[scenario]
    {SNOWFALL}
[/scenario]
Or put everything! Just erase the #define and #enddef

Now... the important thing: the TOD
It's the schedule! If you're using the normal schedule, put their id in the TOD

Code: Select all

tod=dawn,morning,afternoon,dusk,first_watch,second_watch
Then you just need to create a time area to the cave. It's easier to use the type of the terrain, so it'll be underground only on the cave terrains

Code: Select all

[time_area]
        id=cave
        {UNDERGROUND}
        terrain=Xu,Ur,Uu,Uh,Tb^Tf
[/time_area]
It's just an example: Xu,Ur,Uu,Uh,Tb^Tf are cave terrains.

It won't snow in the cave, because you put the schedules when it should snow in the TOD. Don't forget to put the right path to the snowfall image files.
Your method works, thank you much for such detailed explanation! :)
User avatar
Saizo-Luz
Posts: 83
Joined: June 14th, 2024, 12:50 pm
Location: High Heavens

Re: How to apply [terrain_graphics] to a part of the map?

Post by Saizo-Luz »

Mechanical wrote: December 30th, 2024, 1:31 pm Your method works, thank you much for such detailed explanation! :)
Nice! :)

The name=weather/blank.png it's just the blank hex: core/images/misc/blank-hex.png
Because I had that gray image of the heavy rain, so when there was no weather effect activated, it was that dark gray screen - very weird! :?
This would heappen because the weather effect would start at some point in the middle of the scenario, and not from the beginning - and until that happened, this image remained on the screen. So the blank hex is to avoid any interference.
Attachments
noweather.png
noweather.png (110 Bytes) Viewed 2093 times
Post Reply