#textdomain wesnoth-anl

#define COMPLETE_ACTION GOLD_NUMBER
    {VARIABLE finished yes}
    {VARIABLE unit.status.worked_this_turn yes}
    {VARIABLE unit.moves 0}
    [unstore_unit]
        variable=unit
    [/unstore_unit]
    [gold]
        amount={GOLD_NUMBER}
        side=$side_number
    [/gold]
#enddef

#define ANL_SHOW_IF TYPE TERRAIN_PATTERN
    [show_if]
        [have_unit]
            side=$side_number
            x,y=$x1,$y1
            type={TYPE}
            [filter_location]
                terrain={TERRAIN_PATTERN}
            [/filter_location]
        [/have_unit]
    [/show_if]
#enddef

#define SET_NAMES SIDE
    [if]
        [have_unit]
            side={SIDE}
            canrecruit=yes
        [/have_unit]
        [then]
            [store_unit]
                [filter]
                    side={SIDE}
                    canrecruit=yes
                [/filter]
                variable=leader
            [/store_unit]
            {VARIABLE player_{SIDE}.name $leader.name}
            [unstore_unit]
                variable=leader
            [/unstore_unit]
        [/then]
    [/if]
#enddef

#define SET_SIDE_VARIABLES SIDE
    [set_variables]
        name=player_{SIDE}

        [value]
            [farming]
                progress=0
                target=4
                gold=3
            [/farming]

            [mining]
                progress=0
                target=5
                gold=4
            [/mining]

            [warfare]
                progress=0
                target=4
                troop_available=0
            [/warfare]

            troop_1=no
            troop_2=no
            troop_3=no
            troop_4=no
            troop_5=no
            troop_6=no
            troop_7=no

            [research]
                current_target=agriculture
            [/research]

            [leader_option_1]
                progress=0
                target=4
            [/leader_option_1]

            ally_1=no
            ally_2=no
            ally_3=no
            ally_4=no

            [leader_option_2]
                progress=0
                target=4
            [/leader_option_2]

            ally_5=no
            ally_6=no
            ally_7=no
            ally_8=no
        [/value]
    [/set_variables]
#enddef

#define PICK_RECRUIT_OPTION UNIT_IMAGE UNIT_TYPE_STRING UNIT_TYPE_NAME_STRING VAR
    [option]
        message={MENU_IMG_TXT {UNIT_IMAGE} {UNIT_TYPE_NAME_STRING}}
        [show_if]
            {CONDITION player_$side_number|.{VAR} equals no}
        [/show_if]
        [command]
            {VARIABLE player_$side_number|.{VAR} yes}
            [allow_recruit]
                type={UNIT_TYPE_STRING}
                side=$side_number
            [/allow_recruit]
        [/command]
    [/option]
#enddef

#define ADDING_TO_CURRENT_RESEARCH_FIELD SIDE NUMBER
    [if]
        {CONDITION player_{SIDE}.research.current_target equals _"agriculture"}
        [then]
            {VARIABLE_OP player_{SIDE}.farming.progress add {NUMBER}}
        [/then]
    [/if]
    [if]
        {CONDITION player_{SIDE}.research.current_target equals _"mining"}
        [then]
            {VARIABLE_OP player_{SIDE}.mining.progress add {NUMBER}}
        [/then]
    [/if]
    [if]
        {CONDITION player_{SIDE}.research.current_target equals _"warfare"}
        [then]
            {VARIABLE_OP player_{SIDE}.warfare.progress add {NUMBER}}
        [/then]
    [/if]
#enddef

#define ANL_RESCUE_TRAPPED_UNIT MOVETO_X MOVETO_Y UNIT_X UNIT_Y
    [event]
        name=moveto
        [filter]
            side=1,2,3,4
            x={MOVETO_X}
            y={MOVETO_Y}
        [/filter]

        [message]
            speaker=unit
            message= _ "Let's cut you free!"
        [/message]
        [message]
            speaker=narrator
            message= _ "You release the creature from the web and it agrees to help you."
            image=wesnoth-icon.png
        [/message]

        [store_unit]
            [filter]
                x={UNIT_X}
                y={UNIT_Y}
            [/filter]
            variable=critter
            kill=no
        [/store_unit]
        {VARIABLE critter.side $side_number}
        {CLEAR_VARIABLE critter.overlays}
        [unstore_unit]
            variable=critter
        [/unstore_unit]
    [/event]
#enddef

#define ANL_PLACE_UNIT SIDE TYPE X Y
    [unit]
        side={SIDE}
        type={TYPE}
        generate_name=yes
        ai_special=guardian
        random_traits=no
        x={X}
        y={Y}
    [/unit]
#enddef

#define ANL_PLACE_GUARDIAN SIDE TYPE X Y
    [unit]
        side={SIDE}
        type={TYPE}
        generate_name=yes
        ai_special=guardian
        random_traits=no
        role=guardian
        x={X}
        y={Y}
    [/unit]
#enddef

#define ANL_PLACE_WOUNDED_UNIT SIDE TYPE X Y HITPOINTS_AMOUNT
    [unit]
        side={SIDE}
        type={TYPE}
        generate_name=yes
        hitpoints={HITPOINTS_AMOUNT}
        ai_special=guardian
        random_traits=no
        x={X}
        y={Y}
    [/unit]
#enddef

#define ANL_PLACE_TRAPPED_UNIT SIDE TYPE X Y
    [unit]
        side={SIDE}
        type={TYPE}
        generate_name=yes
        ai_special=guardian
        random_traits=no
        overlays=projectiles/web.png
        x={X}
        y={Y}
    [/unit]
#enddef

#define BUILD_SOUND_1
    {PLAY_SOUND ("miss-1.ogg")}
    {DELAY 120}
    {PLAY_SOUND ("bite.ogg")}
    {DELAY 220}
    {PLAY_SOUND ("dart.wav")}
    {DELAY 180}
    {PLAY_SOUND ("dart.wav")}
#enddef

#define BUILD_SOUND_2
    {PLAY_SOUND ("staff.wav")}
    {DELAY 100}
    {PLAY_SOUND ("pincers.ogg")}
    {DELAY 160}
    {PLAY_SOUND ("sling.ogg")}
#enddef

#define BUILD_SOUND_3
    {PLAY_SOUND ("bite.ogg")}
    {DELAY 280}
    {PLAY_SOUND ("staff.wav")}
    {DELAY 100}
    {PLAY_SOUND ("dart.wav")}
    {DELAY 180}
    {PLAY_SOUND ("dart.wav")}
#enddef
