Unilt filter for different healing

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
pkz
Posts: 30
Joined: April 14th, 2009, 1:11 am

Unilt filter for different healing

Post by pkz »

I am trying to filter out units with the heals +4 and heals +8 separately. this one works :
[filter]
[filter_wml]
[abilities]
[heals]
value=4
[/heals]
[/abilities]
[/filter_wml]
[/filter]

gives me only units with healing +4

this one though does not :
[filter]
[filter_wml]
[abilities]
[heals]
value=8
[/heals]
[/abilities]
[/filter_wml]
[/filter]

It gives me units with heals +4 or Heals +8

i also tried this:
[filter]
[filter_wml]
[abilities]
[heals]
value=4
[/heals]
[/abilities]
[/filter_wml]
[not]
[filter_wml]
[abilities]
[heals]
value=8
[/heals]
[/abilities]
[/filter_wml]
[/not]
[/filter]

Any ideas?

User avatar
Speedbrain
Posts: 137
Joined: August 10th, 2009, 9:51 pm
Location: Utah, USA

Re: Unilt filter for different healing

Post by Speedbrain »

Did it store an empty set from your last example?
I'm no master of coding or WML, but it seems the 4 and the 8 should be switched in your last example. You want all the 8's, NOT the 4's, right?

User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Unilt filter for different healing

Post by Dixie »

Look at how they are defined in the core macros of the game:
Spoiler:
If you want to filter the mainline Cures, maybe you could use the invisible UNPOISON ability?

Code: Select all

[filter]
  ability=curing
[/filter]
If you have made some costum healing abilities/have a unit with the EXTRA_HEAL but not UNPOISON... I dunno, create a costum ability instead of using the mainline ones and just give it a different id?

Also: ninja's but speedbrain's comment makes sense.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth

Anonymissimus
Inactive Developer
Posts: 2460
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Unilt filter for different healing

Post by Anonymissimus »

Why do HEAL and EXTRA_HEAL have the same id in mainline ? It doesn't make much sense. Then you could filter easily with ability=...
It looks like filter_wml cares for the [heals] tag but not for value=, would explain the experienced behaviour.
You could do (in your custom abilities):

Code: Select all

#undef ABILITY_EXTRA_HEAL
#define ABILITY_EXTRA_HEAL
    [heals]
        value=8
        id=extra_healing
...
So mainline and custom units with this ability are using your custom extra_heal which matches the core one except for the id.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign

pkz
Posts: 30
Joined: April 14th, 2009, 1:11 am

Re: Unilt filter for different healing

Post by pkz »

Dixie, that type of filter works, and is simples, but does not differentiate between a heal +4 and a heal +8.. i need a way of filtering them seperatly, for two different actions.

Speedbrain, not it catches the unit. the filter for +8 works fine, as it should. but the filter for +4 picks up the +8 units also. its as if its reading it as all units with that number or greater.

Anonymissimus, not sure how i could apply your idea. how can i get the script to change the id for one (+4) but not the other (+8). I would still need to filter the units apart. and if i can do that i'm laughing.

Anonymissimus
Inactive Developer
Posts: 2460
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Unilt filter for different healing

Post by Anonymissimus »

pkz wrote:Anonymissimus, not sure how i could apply your idea. how can i get the script to change the id for one (+4) but not the other (+8). I would still need to filter the units apart. and if i can do that i'm laughing.
Put that among your utils/abilities.cfg - the core definition except for the #undef and the changed id, to substitute core's ABILITY_EXTRA_HEALING:
Spoiler:
Then in any SUF do

Code: Select all

		[filter]
			ability=healing
		[/filter]
		[filter]
			ability=extra_healing
		[/filter]
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign

User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Unilt filter for different healing

Post by Dixie »

pkz wrote:Dixie, that type of filter works, and is simples, but does not differentiate between a heal +4 and a heal +8.. i need a way of filtering them seperatly, for two different actions.
Are you sure? Have you tried it? As I understand it, all mainline units who have heal +8 (id=healing) also have unpoison (id=curing), and none of those that have haling +4 (id=healing) have unpoison.

Thus, you could filter heal+4 like this:

Code: Select all

[filter]
  ability=healing
 [not]
  ability=curing
 [/not]
[/filter]
and heal+8 like this:

Code: Select all

[filter]
  ability=curing
[/filter]
Note that even if it requires a few lines of additionnal code, I think Anonymissimus's way of doing it is pretty valid too.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth

silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: Unilt filter for different healing

Post by silene »

Anonymissimus wrote:It looks like filter_wml cares for the [heals] tag but not for value=, would explain the experienced behaviour.
No, the code in 1.8 looks sensible, and it really should be looking at value. By the way, I haven't been able to reproduce the issue: units without value=8 are not matched for me.

At the very least, it helped me notice that [filter_wml] never worked in trunk. (If the unit had more attributes than the ones in the filter, it would fail.)

Post Reply