#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
        [/not]
    [/filter_second]

    [if]
        [variable]
            name=second_unit.variables.stunned
            boolean_equals=no
        [/variable]
        [then]
            {VARIABLE second_unit.variables.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=level

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

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

                [effect]
                    apply_to=ellipse
                    ellipse="misc/ellipse-nozoc"
                [/effect]

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

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

[event]
    name=turn refresh
    first_time_only=no

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

    {FOREACH stunned i}
        {VARIABLE stunned[$i].variables.stunned no}

        [unstore_unit]
            variable=stunned[$i]
        [/unstore_unit]

        [object]
            silent=yes
            duration=level

            [filter]
                x,y=$stunned[$i].x,$stunned[$i].y
            [/filter]

            [effect]
                apply_to=image_mod
                replace="NOP()"
            [/effect]

            [effect]
                apply_to=ellipse
                ellipse="misc/ellipse"
            [/effect]

            [effect]
                apply_to=zoc
                value=yes
            [/effect]
        [/object]
    {NEXT i}

    {CLEAR_VARIABLE stunned}
[/event]
