Help with filtering inside weapon specials

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
User avatar
Sir Iwein
Posts: 13
Joined: February 13th, 2008, 8:09 am

Help with filtering inside weapon specials

Post by Sir Iwein »

For my project im trying to make a new weapon special for magic attacks

This attack should be more powerful when friendly magic units are standing around the attacker

Somehow the filter seems not to work

Code: Select all

#define WEAPON_SPECIAL_CHANNELING

 [damage]
     id=channeling-n
     name= _ "channeling"
     description= _ "Channeling: This unit inflicts additional damage for every friendly magical unit standing next to this unit."
     [filter_adjacent]
                adjacent=n
		[filter_weapon]
			special=magical
		[/filter_weapon]
      [/filter_adjacent]
      add=1
      apply_to=self
      active_on=offense
      cumulative=yes
 [/damage]
#[damage]
   #  id=channeling-nw
#repeating this four all 6 directions
   # [/damage]

#enddef

The ability shows up properly if the filter is commented out.

Thank you Sir Iwein
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: Help with filtering inside weapon specials

Post by Exasperation »

Your filter is a bit mucked up:

Code: Select all

[filter]
    [filter_adjacent]
        count=1
        adjacent=n
        is_enemy=no
        type=<put list of units that trigger this power here>
    [/filter_adjacent]
[/filter]
You can only use certain types of filter in certain places - [filter_adjacent] isn't accepted directly by [ability] (which is why it needs to be inside [filter]), and [filter_weapon] can't be used inside a standard unit filter, which is why I suggest providing a list of unit types that trigger the power (alternately, you could change the condition to something easier to check for, like possession of the channeling special ability).

Also, if you want the ability to be visible on the unit when there are no adjacent units triggering it, you have to add name_inactive= and description_inactive= lines to the ability (these can just contain the same values as name_inactive and description_inactive, in which case they will appear the same whether you're receiving the bonus or not).
User avatar
Sir Iwein
Posts: 13
Joined: February 13th, 2008, 8:09 am

Re: Help with filtering inside weapon specials

Post by Sir Iwein »

I tried your filter, but it seems not to work, the special is active the whole time.
I was a bit unprecice in the first post, the code is inside a [specials] tag, and not and [ability] tag, this is possibly why the filter does not work.
In the wikiarticle about Abilities it says filters should work inside special tags, but i have nowhere seen an example of someone actually using these filters.
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: Help with filtering inside weapon specials

Post by Exasperation »

Sorry, I didn't realize it was a weapon special (I guess I just read through it too quickly).

[filter_adjacent] is valid inside of a weapon special, but it still won't accept [filter_weapon] inside of a standard unit filter (such as [filter_adjacent]).

And the point about name_inactive and description_inactive still holds - name and description are only used when the conditions in the filters are met.
User avatar
Sir Iwein
Posts: 13
Joined: February 13th, 2008, 8:09 am

Re: Help with filtering inside weapon specials

Post by Sir Iwein »

Thank you for your reponses, it works now.
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: Help with filtering inside weapon specials

Post by Exasperation »

Glad I could help, and sorry about the initial confusion.
Post Reply