#textdomain wesnoth-utbs
# add the events for Kaleh abilities

# the stun attack
[event]
    name=attacker_hits
    first_time_only=no

    [filter_attack]
        special=stun
    [/filter_attack]

    [filter_second]
        [not]
            level=0
            [or]
                [filter_wml]
                    [status]
                        stunned=yes
                    [/status]
                [/filter_wml]
            [/or]
        [/not]
    [/filter_second]

    {VARIABLE second_unit.status.stunned yes}

    [if]
        [variable]
            name=second_unit.gender
            equals=female
        [/variable]

        [then]
            [set_variable]
                name=tmp_stunned_text
                value= _ "female^stunned"
            [/set_variable]
        [/then]

        [else]
            [set_variable]
                name=tmp_stunned_text
                value= _ "stunned"
            [/set_variable]
        [/else]
    [/if]

    [unstore_unit]
        variable=second_unit
        find_vacant=no
        text=$tmp_stunned_text
        red,green,blue=196,196,128
    [/unstore_unit]

    [object]
        silent=yes
        duration=turn

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

        [effect]
            apply_to=image_mod
            replace="CS(50,50,0)"
        [/effect]

        [effect]
            apply_to=zoc
            value=no
        [/effect]
    [/object]

    [clear_variable]
        name=tmp_stunned_text
    [/clear_variable]
[/event]

[event]
    name=turn refresh
    first_time_only=no

    [store_unit]
        [filter]
            side=$side_number
            [filter_wml]
                [status]
                    stunned=yes
                [/status]
            [/filter_wml]
        [/filter]
        variable=stunned
    [/store_unit]

    {FOREACH stunned i}
        {CLEAR_VARIABLE stunned[$i].status.stunned}

        [unstore_unit]
            variable=stunned[$i]
        [/unstore_unit]
    {NEXT i}

    {CLEAR_VARIABLE stunned}
[/event]
