Difference between revisions of "WML Abilities"

From The Battle for Wesnoth Wiki
m
 
(Added knockback)
Line 1: Line 1:
 +
== WML Abilities ==
 +
 
Remember that you must include the WML ability code in every scenario where you intend them to work.
 
Remember that you must include the WML ability code in every scenario where you intend them to work.
  

Revision as of 10:40, 16 February 2006

WML Abilities

Remember that you must include the WML ability code in every scenario where you intend them to work.

Knockback Template:DevFeature

When a unit is hit with a knockback attack, it is immediately pushed one hex away from the attacker, at which point the combat ends. Exception: units in villages can't be knocked out of them.

Examples that give knockback for every Drake Glider on their slam attack, and for the Shock Trooper named Jane:

{KNOCKBACK (type=Drake Glider) slam}
{KNOCKBACK description=Jane mace}


#define KNOCKBACK FILTER WEAPON
    [event]
        name=attacker_hits
        first_time_only=no

        [filter]
            {FILTER}
        [/filter]

        [special_filter]
            weapon={WEAPON}
        [/special_filter]

        [sound]
            name=ghoul-hit.wav
        [/sound]

        {OPPOSITE_SIDE $x2 $y2 $x1 $y1 target_hex}

        [store_locations]
            x,y=$x2,$y2
            terrain=AaBbDeLptUVvYZ
            variable=defender_in_village
        [/store_locations]

        {IF_HAVE_UNIT x,y=$target_hex.x,$target_hex.y (
            [else]
                {IF defender_in_village.length not_equals 1 (
                    [then]
                        {STORE_UNIT_VAR x,y=$x2,$y2 side side_of_defender}

                        [teleport]
                            [filter]
                                x,y=$x2,$y2
                            [/filter]

                            x,y=$target_hex.x,$target_hex.y
                        [/teleport]

                        [capture_village]
                            side=$side_of_defender
                            x,y=$target_hex.x,$target_hex.y
                        [/capture_village]

                        {CLEAR_VARIABLE side_of_defender}
                    [/then]
                )}
            [/else]
        )}

        {CLEAR_VARIABLE target_hex}
        {CLEAR_VARIABLE defender_in_village}
    [/event]
#enddef