#textdomain wesnoth-dw
[unit_type]
    id=Merman Brawler
    name= _ "Merman Brawler"
    profile="portraits/brawler.png"
    race=merman
    image="units/merfolk/brawler.png"
    ellipse="misc/ellipse"
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=38
    movement_type=swimmer
    movement=6
    level=1
    experience=50
    {AMLA_DEFAULT}
    alignment=lawful
    cost=19
    usage=fighter
    description= _ "Exceptionally large and strong mermen are sometimes more comfortable with their own fists and tails than with other weapons."+{SPECIAL_NOTES}+{SPECIAL_NOTES_STUN}
    die_sound=mermen-die.ogg
    {DEFENSE_ANIM "units/merfolk/brawler-defend.png" "units/merfolk/brawler-defend.png" mermen-hit.wav }
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/transparent/brawler.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/transparent/brawler.png"
    [/portrait]
    [attack]
        name=fist-merman
        description=_"fist"
        type=impact
        range=melee
        damage=5
        number=4
    [/attack]
    [attack]
        name=tail-merman
        description=_"tail"
        type=impact
        range=melee
        damage=9
        number=2
        [specials]
            {WEAPON_SPECIAL_STUN}
        [/specials]
    [/attack]

    [attack_anim]
        [filter_attack]
            name=fist-merman
        [/filter_attack]
        [frame]
            begin=-250
            end=-200
            image="units/merfolk/brawler.png"
        [/frame]
        [frame]
            begin=-200
            end=0
            image="units/merfolk/brawler-fist-1.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=0
                end=100
                image="units/merfolk/brawler-fist-2.png"
                sound=fist.ogg
            [/frame]
            [frame]
                begin=100
                end=200
                image="units/merfolk/brawler-fist-3.png"
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=0
                end=150
                image="units/merfolk/brawler-fist-2.png"
                sound=dagger-swish.wav
            [/frame]
            [frame]
                begin=100
                end=200
                image="units/merfolk/brawler-fist-3.png"
            [/frame]
        [/else]
        [frame]
            begin=200
            end=250
            image="units/merfolk/brawler.png"
        [/frame]
    [/attack_anim]

    [attack_anim]
        [filter_attack]
            name=tail-merman
        [/filter_attack]
        start_time=-100
        [if]
            hits=yes
            [frame]
                duration=30
                image="units/merfolk/brawler-tail-land-1.png"
            [/frame]
            [frame]
                duration=30
                image="units/merfolk/brawler-tail-land-3.png"
            [/frame]
            [frame]
                duration=30
                image="units/merfolk/brawler-tail-land-5.png"
                sound=tail.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=30
                image="units/merfolk/brawler-tail-land-1.png"
            [/frame]
            [frame]
                duration=30
                image="units/merfolk/brawler-tail-land-3.png"
            [/frame]
            [frame]
                duration=30
                image="units/merfolk/brawler-tail-land-5.png"
                sound=miss-1.ogg
            [/frame]
        [/else]
        [frame]
            duration=50
            image="units/merfolk/brawler-tail-land-5.png"
        [/frame]
        [frame]
            duration=30
            image="units/merfolk/brawler-tail-land-4.png"
        [/frame]
        [frame]
            duration=80
            image="units/merfolk/brawler-tail-land-3.png"
        [/frame]
        [frame]
            duration=80
            image="units/merfolk/brawler-tail-land-2.png"
        [/frame]
        [frame]
            duration=80
            image="units/merfolk/brawler-tail-land-1.png"
        [/frame]
        [frame]
            duration=80
            image="units/merfolk/brawler.png"
        [/frame]
    [/attack_anim]

    [event]
        name=attacker_hits
        first_time_only=no

        [filter_attack]
            name=tail-merman
        [/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]
[/unit_type]
