filter_adjacent in resistance tag not working

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.
CookieLord
Posts: 20
Joined: June 22nd, 2022, 8:57 pm

filter_adjacent in resistance tag not working

Post by CookieLord »

After adding the filter_adjacent the ability remains permanently disabled.

Code: Select all

[effect]
	apply_to=new_ability
	[abilities]
		mode=append
		[resistance]
 			id=shields_up
			name= _ "Shields Up"
			description= _ "By grouping up with 2 other allies, this unit’s resistances are increased by 10, up to a maximum of 50%, when defending against ranged attacks."
			affect_self=yes
			active_on=defense
				
			[filter_adjacent]
				count=2-6
				is_enemy=no
			[/filter_adjacent]
			[filter_second_weapon]
				range=ranged
			[/filter_second_weapon]
			[filter_base_value]
				less_than=50
			[/filter_base_value]
				
			add=10
			max_value=50
		[/resistance]
	[/abilities]
[/effect]
User avatar
Ravana
Forum Moderator
Posts: 3313
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: filter_adjacent in resistance tag not working

Post by Ravana »

mode=append looks made up, but this example should work anyways.
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

What version of Wesnoth are you using? Before 1.19.10 you must use [filter_adjacent] in a [filter] tag for this to work.
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

You should use that:

Code: Select all

[effect]
	apply_to=new_ability
	[abilities]
		[resistance]
 			id=shields_up
			name= _ "Shields Up"
			description= _ "By grouping up with 2 other allies, this unit’s resistances are increased by 10, up to a maximum of 50%, when defending against ranged attacks."
			affect_self=yes
			active_on=defense
			[filter]	
				[filter_adjacent]
					count=2-6
					is_enemy=no
				[/filter_adjacent]
			[/filter]
			[filter_second_weapon]
				range=ranged
			[/filter_second_weapon]
			[filter_base_value]
				less_than=50
			[/filter_base_value]
				
			add=10
			max_value=50
		[/resistance]
	[/abilities]
[/effect]
gnombat
Posts: 892
Joined: June 10th, 2010, 8:49 pm

Re: filter_adjacent in resistance tag not working

Post by gnombat »

newfrenchy83 wrote: June 9th, 2025, 12:57 pm you must use [filter_adjacent] in a [filter] tag for this to work.
Is that really true? The documentation for [filter_adjacent] says specifically not to do that.
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

gnombat wrote: June 9th, 2025, 1:20 pm
newfrenchy83 wrote: June 9th, 2025, 12:57 pm you must use [filter_adjacent] in a [filter] tag for this to work.
Is that really true? The documentation for [filter_adjacent] says specifically not to do that.
Yes I'm sure, try it and you'll see.
gnombat
Posts: 892
Joined: June 10th, 2010, 8:49 pm

Re: filter_adjacent in resistance tag not working

Post by gnombat »

newfrenchy83 wrote: June 9th, 2025, 1:31 pm Yes I'm sure, try it and you'll see.
Surely the wiki needs to be fixed then? Isn't it telling people to do the exact opposite of that?
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

i will fix the wiki
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

wiki fixed
User avatar
Ravana
Forum Moderator
Posts: 3313
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: filter_adjacent in resistance tag not working

Post by Ravana »

That does not make sense. You said to use [filter] in standard unit filter, which is not allowed still, we have open issue https://github.com/wesnoth/wesnoth/issues/4316

And https://wiki.wesnoth.org/AbilitiesWML still does not say anything about version 1.19.10
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

i corrected the wiki
User avatar
Ravana
Forum Moderator
Posts: 3313
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: filter_adjacent in resistance tag not working

Post by Ravana »

Wiki was still not good enough, I removed your change from SUF and added devfeature in abilities instead. It does not make much sense though since abilities have supported [filter_adjacent] since 2006 https://wiki.wesnoth.org/index.php?titl ... ldid=11553
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

Ravana wrote: June 9th, 2025, 6:50 pm Wiki was still not good enough, I removed your change from SUF and added devfeature in abilities instead. It does not make much sense though since abilities have supported [filter_adjacent] since 2006 https://wiki.wesnoth.org/index.php?titl ... ldid=11553
I think you misunderstood, it was before version 1.19.10 that the fact that the first unit checked did not match caused the ability to be inactive even if others matched, after that, this fault was fixed so that the verification continues and that only if no unit checked matches the standard filter or the condition of number or direction, then we have a false return, and this prevents the verification of a second [adjacent_filter]
newfrenchy83
Code Contributor
Posts: 202
Joined: October 6th, 2017, 12:57 pm

Re: filter_adjacent in resistance tag not working

Post by newfrenchy83 »

I changed the wiki to interger the repair in 1.19.10, and I have a question, is it normal for you that all the [filter_adjacent] must match for the ability to be active, would it not be more logical for the ability to activate a single [filter_adjacent] match
User avatar
Ravana
Forum Moderator
Posts: 3313
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: filter_adjacent in resistance tag not working

Post by Ravana »

Count determines how many adjacent units must match.
Post Reply