How do I specify a unit that is adjacent to a specific hex?

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
ialdabaoth
Posts: 9
Joined: November 22nd, 2013, 5:57 pm

How do I specify a unit that is adjacent to a specific hex?

Post by ialdabaoth »

Here's my code:

Code: Select all

            [animate_unit]
              [filter]
                side=$side_number
                type=Elvish Shaman,Elvish Druid,Elvish Shyde,Ancient Wose
                 #only the one that's adjacent
                [filter_adjacent_location]
                   x,y=$x1,$y1
                [/filter_adjacent_location]
              [/filter]
              flag=healing
              facing=$x1,$y1
            [/animate_unit]

            [unit]
              type=Wose Sapling
              side=$side_number
              x,y=$x1,$y1
              animate=yes
            [/unit]

            [modify_unit]
              [filter]
                 side=$side_number
                 type=Elvish Shaman,Elvish Druid,Elvish Shyde,Ancient Wose
                 #only the one that's adjacent
                 [filter_adjacent_location]
                    x,y=$x1,$y1
                 [/filter_adjacent_location]
              [/filter]
              attacks_left=0
              moves=0
            [/modify_unit]
The trouble is, both filter_adjacent_location blocks seem to be ignored. EVERY Elvish Shaman on the field has their attacks and moves dropped to 0, and ONE Elvish Shaman at random plays its "heal" animation. Help?
User avatar
Iris
Site Administrator
Posts: 6798
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: How do I specify a unit that is adjacent to a specific h

Post by Iris »

Wrap the [filter_adjacent_location] tags under [filter_location] tags under [filter] instead. The reason is that [filter_adjacent_location] (as opposed to just [filter_adjacent]) is part of a StandardLocationFilter, which a StandardUnitFilter (which the [animate_unit] and [modify_unit] actions expect under [filter]) accepts only under the [filter_location] tag.

Also, the [animate_unit] action expects a [facing] tag, not attribute, containing a SLF.

Code: Select all

                [animate_unit]
                  [filter]
                    side=$side_number
                    type=Elvish Shaman,Elvish Druid,Elvish Shyde,Ancient Wose
                     #only the one that's adjacent
                     [filter_location]
                       [filter_adjacent_location]
                          x,y=$x1,$y1
                       [/filter_adjacent_location]
                     [/filter_location]
                  [/filter]
                  flag=healing
                  [facing]
                    x,y=$x1,$y1
                  [/facing]
                [/animate_unit]

                [unit]
                  type=Wose Sapling
                  side=$side_number
                  x,y=$x1,$y1
                  animate=yes
                [/unit]

                [modify_unit]
                  [filter]
                     side=$side_number
                     type=Elvish Shaman,Elvish Druid,Elvish Shyde,Ancient Wose
                     #only the one that's adjacent
                     [filter_location]
                       [filter_adjacent_location]
                          x,y=$x1,$y1
                       [/filter_adjacent_location]
                     [/filter_location]
                  [/filter]
                  attacks_left=0
                  moves=0
                [/modify_unit]
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
ialdabaoth
Posts: 9
Joined: November 22nd, 2013, 5:57 pm

Re: How do I specify a unit that is adjacent to a specific h

Post by ialdabaoth »

Excellent! Everything seems to work, except for one thing:

The Elvish Shaman changes direction, but doesn't show the healing animation unless I put it AFTER the creation of the Wose Sapling. Is there something specific to healing animations, that they don't show if there isn't an adjacent unit to heal?
User avatar
Iris
Site Administrator
Posts: 6798
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: How do I specify a unit that is adjacent to a specific h

Post by Iris »

ialdabaoth wrote:Is there something specific to healing animations, that they don't show if there isn't an adjacent unit to heal?
Potentially. Normally, the ‘healing’ animation is played for the healer at the same time as the target’s ‘healed’ animation; the specifics of how these concurrent animations (i.e. most animation types) are handled when requested stand-alone elude me.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Post Reply