How to apply [terrain_graphics] to a part of the map?
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.
- Mechanical
- Posts: 388
- Joined: June 29th, 2015, 4:11 pm
- Location: Russia
How to apply [terrain_graphics] to a part of the map?
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:
Coordinates are all map tiles except for the cave tiles.
I also tried filtering the tiles by terrain, like:
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.
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]
I also tried filtering the tiles by terrain, like:
Code: Select all
[tile]
type=Rb
[/tile]
I read the [terrain_graphics] documentation, but apparently I couldn't understand it completely, that's why I'm asking for help.
Re: How to apply [terrain_graphics] to a part of the map?
I'll put everything here!
I suppose you have the snowfall images... so...
You can create this macro and define at the top of the 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
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
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.
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
Code: Select all
[scenario]
{SNOWFALL}
[/scenario]
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
Code: Select all
[time_area]
id=cave
{UNDERGROUND}
terrain=Xu,Ur,Uu,Uh,Tb^Tf
[/time_area]
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.
- Mechanical
- Posts: 388
- Joined: June 29th, 2015, 4:11 pm
- Location: Russia
Re: How to apply [terrain_graphics] to a part of the map?
Your method works, thank you much for such detailed explanation!Saizo-Luz wrote: ↑December 29th, 2024, 2:18 pm I'll put everything here!
I suppose you have the snowfall images... so...
You can create this macro and define at the top of the scenario.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
Or put everything! Just erase the #define and #enddefCode: Select all
[scenario] {SNOWFALL} [/scenario]
Now... the important thing: the TOD
It's the schedule! If you're using the normal schedule, put their id in the TOD
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 terrainsCode: Select all
tod=dawn,morning,afternoon,dusk,first_watch,second_watch
It's just an example: Xu,Ur,Uu,Uh,Tb^Tf are cave terrains.Code: Select all
[time_area] id=cave {UNDERGROUND} terrain=Xu,Ur,Uu,Uh,Tb^Tf [/time_area]
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.

Re: How to apply [terrain_graphics] to a part of the map?
Nice!Mechanical wrote: ↑December 30th, 2024, 1:31 pm Your method works, thank you much for such detailed explanation!![]()

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 (110 Bytes) Viewed 2093 times