#textdomain wesnoth-utbs
# add the events for Kaleh abilities
[event]
    # charisma ability
    name=moveto
    first_time_only=no
    [filter]
        side=1
        [filter_adjacent]
        [/filter_adjacent]
        [or]
            side=1
        [/or]
        [or]
            side=1
            [wml_filter]
					    morale="loyalized"
				    [/wml_filter]
        [/or]
    [/filter]
    [store_unit]
        variable=player_unit
        kill=no
        [filter]
            side=1
        [/filter]
    [/store_unit]
    {FOREACH player_unit i}
    {VARIABLE player_unit[$i].upkeep "full"}
    {VARIABLE player_unit[$i].morale ""}
    [unstore_unit]
        variable=player_unit[$i]
    [/unstore_unit]
    {NEXT i}
    [store_unit]
        variable=player_unit
        kill=no
        [filter]
            side=1
            canrecruit=no
            [filter_adjacent]
            [/filter_adjacent]
        [/filter]
    [/store_unit]
    {FOREACH player_unit i}
    {VARIABLE player_unit[$i].upkeep "loyal"}
    {VARIABLE player_unit[$i].morale "loyalized"}
    [unstore_unit]
        variable=player_unit[$i]
    [/unstore_unit]
    {NEXT i}
    [allow_undo]
    [/allow_undo]
[/event]

# the stun attack
[event]
    name=attacker_hits
    first_time_only=no
    [special_filter]
        weapon=sword_rush
    [/special_filter]
    [filter_second]
        [not]
            level=0
        [/not]
        [not]
            role="zoc_off"
        [/not]
    [/filter_second]
    {VARIABLE second_unit.role "zoc_off"}
    [unstore_unit]
        variable=second_unit
        text="stunned"
        red,green,blue=150,120,250
    [/unstore_unit]
    {VARIABLE unit.status.slowed "on"}
    [unstore_unit]
        variable=unit
        text="slowed"
        red,green,blue=200,55,55
    [/unstore_unit]
    [object]
        silent=yes
        id=stun
        [filter]
            x,y=$x2,$y2
        [/filter]
        [effect]
            apply_to=zoc
            value=0
        [/effect]
    [/object]
[/event]
[event]
    name=new turn
    first_time_only=no
    [store_unit]
        variable=zoc_unit
        kill=no
        [filter]
            role="zoc_off"
        [/filter]
    [/store_unit]
    {FOREACH zoc_unit i}
    {VARIABLE zoc_unit[$i].role ""}
    [unstore_unit]
        variable=zoc_unit[$i]
    [/unstore_unit]
    [object]
        silent=yes
        [filter]
            x=$zoc_unit[$i].x
            y=$zoc_unit[$i].y
        [/filter]
        [effect]
            apply_to=zoc
            value=1
        [/effect]
    [/object]
    {NEXT i}
[/event]
# upgrade leadership event
[event]
    name=post_advance
    first_time_only=yes
    [filter]
        side=1
        canrecruit=yes
        [wml_filter]
            variation=Marshal
        [/wml_filter]
    [/filter]
    [object]
        silent=yes
        x=$unit.x
        y=$unit.y
        [effect]
            apply_to=remove_ability
            [abilities]
                id=leadership
            [/abilities]
        [/effect]
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_LEADERSHIP_LEVEL_3}
            [/abilities]
        [/effect]
    [/object]
[/event]
