how to filter terrain groups? (all flat, all deep water etc)

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
lea
Posts: 301
Joined: October 1st, 2016, 7:25 pm

how to filter terrain groups? (all flat, all deep water etc)

Post by lea »

StandardLocationFilter allows filtering terrain types by terrain code, including wildcards
but that's pretty much it

is there any way to filter terrains by defense/movement category, as they are listed in unit type descriptions?

namely these 15 categories as listed in movetypes:
deep_water, shallow_water, reef, swamp_water, flat, sand, forest, hills, mountains, village, castle, cave, frozen, unwalkable, fungus, impassable

they seem to correspond 1-to-1 to values in "alias of" column of TerrainCodeTableWML table but could not find a way to filter by these either
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
User avatar
beetlenaut
Developer
Posts: 2832
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: how to filter terrain groups? (all flat, all deep water etc)

Post by beetlenaut »

It doesn't seem to be possible. It might be too late to make a feature request for 1.18, but I'm not sure. However, using terrain codes probably wouldn't be that hard. I think I would just make macros for each type like this:

Code: Select all

#define T_VILLAGE
	*^V*
#enddef

#define T_FLAT
	G*,R*,I*,Ur*,*^B*
#enddef

...
I used the terrain code list and Ctrl^F to highlight all instances of the word "village" or "flat" on the web page.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
lea
Posts: 301
Joined: October 1st, 2016, 7:25 pm

Re: how to filter terrain groups? (all flat, all deep water etc)

Post by lea »

beetlenaut wrote: November 5th, 2023, 10:47 pmI think I would just make macros for each type like this:
... ... ...
apparently that's how it is done in mainline

the problem is that it may fail on maps with custom terrains unless makers of such maps strictly adhere to mainline's style of terrain codes

also consider terrain categories like shallow water and coastal reef - they use same terrain code style while being different (and mutually exclusive) terrain categories for the purposes of determining unit's base defense and movement cost
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
User avatar
Celtic_Minstrel
Developer
Posts: 2290
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: how to filter terrain groups? (all flat, all deep water etc)

Post by Celtic_Minstrel »

There isn't any general way for arbitrary terrain categories, but you can detect the key mechanical terrain categories with a formula:

Code: Select all

formula=keep
formula=castle
formula=village
Maybe filtering by terrain alias would be a reasonable feature request – something like a new "alias" key that means "match terrains that alias to these terrains".
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply