Filter by terrain?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
MadMax
Posts: 1792
Joined: June 6th, 2004, 3:29 pm
Location: Weldyn, Wesnoth

Filter by terrain?

Post by MadMax » August 15th, 2004, 9:42 pm

Could it be possible to add an option in the Standard Unit Filter to filter by terrain ie:

Code: Select all

[event]
name=moveto
[filter]
terrain=g
[/filter]
...
[/event]
?
"ILLEGITIMIS NON CARBORUNDUM"

Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom

Dave
Founding Developer
Posts: 7067
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave » August 16th, 2004, 12:35 am

It'd certainly be possible.

What would the purpose of this feature be though?

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn » August 16th, 2004, 1:21 am

Dave wrote:What would the purpose of this feature be though?
Easier and more flexible WML
But it doesn't really add anything that WML can't do already...

Dave
Founding Developer
Posts: 7067
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave » August 16th, 2004, 1:26 am

Dacyn wrote:
Dave wrote:What would the purpose of this feature be though?
Easier and more flexible WML
But it doesn't really add anything that WML can't do already...
Sure, but I mean, what is a motivating example for this feature?

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

MadMax
Posts: 1792
Joined: June 6th, 2004, 3:29 pm
Location: Weldyn, Wesnoth

Post by MadMax » August 16th, 2004, 2:16 am

perhaps if you wanted to make lava do damage to units that are on it without needing to specify the coordinates:

Code: Select all

[event]
name=new turn
first_time_only=no
[store_unit]
[filter]
terrain=l
[/filter]
variable=victims
[/store_unit]
{FOREACH victims i}
{VARIABLE_OP victims[$i].hitpoints add -10}
[unstore_unit]
variable=victims[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE victims}
[/event]
I'm not sure about of the syntax, but... you get the idea.

EDIT: syntax corrected
Last edited by MadMax on August 16th, 2004, 3:28 pm, edited 1 time in total.
"ILLEGITIMIS NON CARBORUNDUM"

Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom

Invisible Philosopher
Posts: 873
Joined: July 4th, 2004, 9:14 pm
Location: My imagination
Contact:

Post by Invisible Philosopher » August 16th, 2004, 2:12 pm

Dacyn wrote:
Dave wrote:What would the purpose of this feature be though?
Easier and more flexible WML
But it doesn't really add anything that WML can't do already...
It allows the player to undo more of the time.
Play a Silver Mage in the Wesvoid campaign.

MadMax
Posts: 1792
Joined: June 6th, 2004, 3:29 pm
Location: Weldyn, Wesnoth

Post by MadMax » August 16th, 2004, 3:25 pm

The idea is that if lava terrain were ever added, you could dump that into a global file in a campaign and every scenario would have that without specifying coordinates. Also, didn't EP propose a 'pillage' ability? This would make it possible.
"ILLEGITIMIS NON CARBORUNDUM"

Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom

quartex
Inactive Developer
Posts: 2258
Joined: December 22nd, 2003, 4:17 am
Location: Boston, MA

Post by quartex » October 15th, 2004, 3:38 am

Did filtering by terrain get implemented?

Suppose I have a map that is half caves and half surface world. I want to set a filter to make the cave floor and cave wall terrains "underground" according to the clock. I could do this manually, listing every hex I want to make underground, or it would be much faster to be able to filter by terrain type. I might still have to go in and list the castle hexes of an underground base, but I wouldn't have to list all the normal underground cave floors and walls.

User avatar
Elvish_Pillager
Posts: 8129
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager » October 15th, 2004, 10:16 am

MadMax wrote:Also, didn't EP propose a 'pillage' ability? This would make it possible.
No.

I didn't propose it.

It isn't impossible.

This feature would be useful.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.

Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn » October 15th, 2004, 10:48 am

Also many mainline scenarios could use it.
With this, you wouldn't have to change as much when you change the map of a scenario.

Boucman
Inactive Developer
Posts: 2119
Joined: March 31st, 2004, 1:04 pm

Post by Boucman » October 15th, 2004, 6:19 pm

I had a look at the code, and it isn't that easy to add, unfortunately...

someone more able than me with the unit/terrain filters might be able to do it though
Fight key loggers: write some perl using vim

User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin » December 28th, 2004, 8:27 pm

This seriously would be a useful feature. From my scenario Weldyn Under Attack, in EI:

Code: Select all

#define TERRAIN_Y
#argh!!! terrain= should be a filter! (or is it? this might have all been pointless... :( )
x=10-13,23,24,25,26,27,28-31,32,39,40,39,38,34,33,32,31,30,29-28,10,11-12,12,13,13-14,15-16,4,5
y=6,6,5,6,5,6,5,4,8-11,11-16,17-18,18,25,26-28,28-29,30-31,31-33,34,27-29,30,31,32,33,34,11-16,17-20
#enddef

Code: Select all

	[event]
	name=moveto
		[filter]
		{TERRAIN_Y}
		side=5,6,7
		[/filter]
		[message]
		description=Gweddry
		message= _ "Look, the undead are tearing down our defences!"
		[/message]
	[/event]

	[event]
	name=moveto
	first_time_only=no
		[filter]
		{TERRAIN_Y}
		side=5,6,7
		[/filter]
		[terrain]
		x,y=$x1,$y1
		letter=h
		[/terrain]
	[/event]
If i ever want to change that map, i will have to go through it again, listing each and every mountain tile. A filter by terrain would solve this problem.

I encounter similar problems in other scenarios i design for SE.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm

olf359
Posts: 3
Joined: December 10th, 2004, 5:42 pm

Post by olf359 » January 4th, 2005, 9:28 am

Hi,
turin wrote:This seriously would be a useful feature. From my scenario Weldyn Under Attack, in EI:
maybe you could use something like this perl-script as a workaround:

Code: Select all

#!/usr/bin/perl

use strict;
use warnings;

my $content = join("", <>);
my ($map) = ($content =~ /map_data="([^"]*)"/sg);
my @lines = split /\n/, $map;
my %terrain = ();
foreach my $y ( 0..$#lines ) {
  my @chars = split //, $lines[$y];
  foreach my $x ( 0..$#chars ) {
    push @{$terrain{$chars[$x]}{x}}, $x;
    push @{$terrain{$chars[$x]}{y}}, $y;
  }
}

foreach my $terrain ( sort keys %terrain ) {
  print '#define TERRAIN_' . "$terrain\n";
  print "x=" . join(",", @{$terrain{$terrain}{x}}) . "\n";
  print "y=" . join(",", @{$terrain{$terrain}{y}}) . "\n";
  print '#enddef ' . "\n";
}
... sorry, the code is not tested but it should work... :wink:

CU, Olf

LienRag
Posts: 26
Joined: September 24th, 2018, 4:03 pm

Re: Filter by terrain?

Post by LienRag » November 8th, 2018, 10:45 pm

Has it been implemented ?
I would need it for a scenario I'm working on...

josteph
Developer
Posts: 126
Joined: August 19th, 2017, 6:58 pm

Re: Filter by terrain?

Post by josteph » November 8th, 2018, 10:48 pm

This thread is from 2005 (!). Yes, this has been implemented, see [filter_location] in https://wiki.wesnoth.org/StandardUnitFilter.

Post Reply