Random terrain modification
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.
Random terrain modification
So I got a macro that should randomly make one part of the map desert. Which happens - theoretically - by giving that part's coordinates to the macro shown below.
Unfortunately the macro doesn't work - it seems the first part with foreach loop will make almost the complete map desert while the rest does nothing if I remove the first part. In case I give the impression of being dumb: It's been a year, I think, that I wrote this and I have absolutely no idea how I came to write this code.
Maybe someone else can give some insight on the problem. Any help is appreciated.
Code: Select all
#define DESERT X1 Y1 X2 Y2
[store_locations]
[filter_location]
x={X1}-{X2}
y={Y1}-{Y2}
terrain=Ss
[filter_adjacent_location]
[not]
terrain=Uu
[/not]
[/filter_adjacent_location]
[/filter_location]
variable=locs_for_desert
[/store_locations]
[foreach]
array=locs_for_desert
[do]
[terrain]
x,y=$this_item.x,$this_item.y
terrain=Dd
[/terrain]
[/do]
[/foreach]
{CLEAR_VARIABLE locs_for_desert}
[terrain]
x={X1}-{X2}
y={Y1}-{Y2}
[and]
terrain=Gs^Fds,Gg,Gs^Fms
[/and]
terrain=Dd
[/terrain]
[terrain]
x={X1}-{X2}
y={Y1}-{Y2}
[and]
terrain=Hh
[/and]
terrain=Hd
[/terrain]
[terrain]
x={X1}-{X2}
y={Y1}-{Y2}
[and]
terrain=Gg^Fet
[/and]
terrain=Dd^Do
[/terrain]
#enddef
Maybe someone else can give some insight on the problem. Any help is appreciated.
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
- skeptical_troll
- Posts: 498
- Joined: August 31st, 2015, 11:06 pm
Re: Random terrain modification
I guess this should be moved to the WML workshop section.
Anyway, I think your problem is that you don't need the
Anyway, I think your problem is that you don't need the
[filter_location]
tag inside the [store_location]
, so it's taking the whole map by default. Just put the filter without tag. Once the map is all desert you don't find appropriate terrain for the replacements below.-
- Inactive Developer
- Posts: 503
- Joined: April 24th, 2016, 4:18 pm
Re: Random terrain modification
I had problems with both performance and clarity doing random snow, so did it using in-line Lua in HttT S13
I forked real life and now I'm getting merge conflicts.
Re: Random terrain modification
You can use the [random_placement] wml tag , it also has an explicit option for only doing the change for a fraction of randomly chosen tiles.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: Random terrain modification
I fixed it; there were two mistakes: The first one was the one suggested by skeptical_troll, the other was that I accidentally swapped X and Y in the macro call.
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)