#textdomain wesnoth-low
#ifdef MULTIPLAYER
[multiplayer]
    random_start_time=no
#ifndef DEBUG_MODE
    allow_new_game=no
#endif
#else
[scenario]    
#endif

    id="09_Bounty_hunters"
    name= _ "Bounty Hunters"
    {LOW_MAP 09_Bounty_Hunters.map}
    {TURNS 32 28 24}

    victory_when_enemies_defeated=no

    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC northerners.ogg traveling_minstrels.ogg}
    {EXTRA_SCENARIO_MUSIC breaking_the_chains.ogg}
    {EXTRA_SCENARIO_MUSIC battle.ogg}

    {LOW_PRESTART}

    next_scenario=10_Cliffs_of_Thoria
    [story]
        [part]
            delay=4000
            story= _ "Believing that Wesmere's seeming safety might prove a costly illusion, Kalenz and Olurf left enough troops and resources to guard it strongly before starting off on the long and dangerous trip to the great mage of Thoria. They would soon find that peril was closer than they had reckoned."
        [/part]

        [part]
            show_title=yes
            {TO_BOUNTY_HUNTERS}
        [/part]
    [/story]

#define PLAYER_GOLD
    {GOLD 287 260 230}
#enddef

    #wmllint: validate-off
    [side]
        {KALENZ}
        {PLAYER_GOLD}
        fog=no
        # wmllint: recognize Kalenz
#ifndef MULTIPLAYER
        recruit={ELVES},{DWARVES}
        [unit]
            {LANDAR}
            # wmllint: recognize Landar
            placement=leader
        [/unit]
        [unit]
            {OLURF}
            # wmllint: recognize Olurf
            placement=leader
        [/unit]
#else
        recruit={ELVES}
#endif
        [unit]
            {CLEODIL}
            # wmllint: recognize Cleodil
            placement=leader
        [/unit]
    [/side]
    #wmllint: validate-on
    [event]
        name=prestart

        # wmllint: recognize Arkildur
        # wmllint: recognize Tameril-Isimeril
        # wmllint: recognize Laril
        # wmllint: recognize Anduilas

        # these have been left behind to guard the Ka'lian
        [store_unit]
            variable=l3_store_kalenz
            kill=yes
            [filter]
                side=1
                [not]
                    id=Kalenz
                [/not]
                [not]
                    id=Anduilas
                [/not]
                [not]
                    id=Landar
                [/not]
                [not]
                    id=Cleodil
                [/not]
                [and]
                    type=Elvish Marshal,Elvish Champion,Elvish Avenger,Elvish Sharpshooter
                    [or]
                        {FILTER_LOYALS}
                    [/or]
                [/and]
            [/filter]
        [/store_unit]

#ifdef MULTIPLAYER
        [store_unit]
            variable=l3_store_landar
            kill=yes
            [filter]
                side=5
                [not]
                    id=Landar
                [/not]
                [not]
                    #wmllint: recognize Landulias
                    id=Landulias
                [/not]
                [and]
                    type=Elvish Marshal,Elvish Champion,Elvish Avenger,Elvish Sharpshooter
                    [or]
                        {FILTER_LOYALS}
                    [/or]
                [/and]
            [/filter]
        [/store_unit]
#endif

        [recall]
            id=Anduilas
        [/recall]
        #
        #        {RECALL_LOYALS}

        [switch]
            variable=l3_store.length
            [case]
                value=0
                [set_variable]
                    name=left_behind
                    value= _ "some experienced warriors"	# wmllint: ignore
                [/set_variable]
            [/case]
            [case]
                value=1
                [set_variable]
                    name=left_behind
                    format=$l3_store[0].name
                [/set_variable]
            [/case]
            [else]
                {VARIABLE l3_length $l3_store.length}
                {VARIABLE_OP l3_length add -1}
                {FOREACH l3_store i}
                    # for-case, what a great anti-pattern
                    [switch]
                        variable=i
                        [case]
                            value=0
                            [set_variable]
                                name=left_behind
                                format=$l3_store[$i].name
                            [/set_variable]
                        [/case]
                        #TODO is unit.name the translated name?
                        [case]
                            value=$l3_length
                            [set_variable]
                                name=left_behind
                                format= _ "$left_behind and $l3_store[$i].name"	# wmllint: ignore
                            [/set_variable]
                        [/case]
                        [else]
                            [set_variable]
                                name=left_behind
                                format= _ "$left_behind|, $l3_store[$i].name"	# wmllint: ignore
                            [/set_variable]
                        [/else]
                    [/switch]
                {NEXT i}
                {CLEAR_VARIABLE l3_length}
            [/else]
        [/switch]
    [/event]

    [side]
        side=2
        allow_player=no
        controller=ai
        type=Saurian Flanker
        id=Huurgh
        name=_ "Huurgh"

        canrecruit=yes
        {GOLD 200 240 290}
        {INCOME 4 8 12}
        team_name=Liz
        user_team_name= _ "Enemies"
#ifdef EASY
        recruit=Saurian Augur,Saurian Skirmisher,Saurian Ambusher
#else
        recruit=Saurian Augur,Saurian Skirmisher, Saurian Oracle, Saurian Soothsayer, Saurian Flanker
#endif
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_ignore_bad_combat=yes
#ifdef EASY
            recruitment_pattern=scout,scout,healer,scout
#else
            recruitment_pattern=scout,scout,healer,archer,archer,scout
#endif
            grouping=offensive
            aggression=0.75
        [/ai]
    [/side]
    [side]
        side=3
        allow_player=no
        controller=ai
        type=Saurian Oracle
        id=Shhar
        name=_ "Shhar"

        canrecruit=yes
        {GOLD 300 340 400}
        {INCOME 4 8 12}
        team_name=Liz
        user_team_name= _ "Enemies"
#ifdef EASY
        recruit=Saurian Augur,Saurian Skirmisher,Saurian Ambusher
#else
        recruit=Saurian Augur,Saurian Skirmisher, Saurian Oracle, Saurian Soothsayer, Saurian Flanker
#endif
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_ignore_bad_combat=yes
#ifdef EASY
            recruitment_pattern=scout,scout,healer,scout
#else
            recruitment_pattern=scout,scout,healer,archer,archer,scout
#endif
            grouping=offensive
            aggression=0.75
        [/ai]
    [/side]

    [side]
        side=4
        allow_player=no
        controller=ai
        hidden=yes
        no_leader=yes
        team_name=creatures
        user_team_name= _ "Creatures"
        [ai]
            #TODO these values seem wrong
            aggression=200.0
            caution=-100.0
            grouping=no
            [avoid]
                x=1-37,1-17,21-37, 1-5,23-37,1-3,28-37,34-37
                y= 1-2,   3,    3,   4,    4,  5,    5,    6
            [/avoid]
            [avoid]
                x=1-37
                y=12-32
            [/avoid]
            [avoid]
                x=1-4,13-17,26-37
                y= 11,   11,   11
            [/avoid]
            [avoid]
                x=9-10, 8-13,10-13,9-12,21-24,22-23,22-24
                y=   5,    6,    7,   8,    8,    9,    7
            [/avoid]
            village_value=0
        [/ai]
    [/side]

#ifdef MULTIPLAYER
    [side]
        side=5
        fog=no
        {PLAYER_GOLD}
        {LANDAR}
        recruit={ELVES}
    [/side]

    [side]
        side=6
        #TODO give olurf more gold?
        {PLAYER_GOLD}
        team_name=player
        user_team_name= _ "Player"
        {OLURF}
        {PLAYABLE}
        controller=human
        allow_player=yes
        recruit={DWARVES}
    [/side]
#endif

    [event]
        name=prestart
        [objectives]
            side=0
            [objective]
                description= _ "Kalenz crosses the river"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Landar"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Cleodil"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Olurf"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
            note={EARLY_FINISH_BONUS_NOTE}
        [/objectives]
    [/event]

    [event]
        name=start

        [message]
            id=Huurgh
            # wmllint: local spelling Yesss
            message= _ "Yesss! It's the elves who stole our gold! The bounty is mine!"
        [/message]
        [message]
            id=Shhar
            message= _ "I saw them first, fool! The bounty is all mine."
        [/message]
        [message]
            id=Olurf
            message= _ "What are they talking about?"
        [/message]
        [message]
            id=Landar
            message= _ "It would seem the saurians put a bounty on our heads for having the effrontery to take our gold back after they stole it. Are you interested?"
        [/message]
        [message]
            id=Olurf
            message= _ "No, but my axe is interested in some saurian heads! They ha' been too friendly with the orcs for my liking!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Remember, we are here on a mission. We will fight these saurians if we must, but our mission is to get to Thoria."
        [/message]
        [message]
            id=Olurf
            message= _ "Crossing the river without a bridge? We dwarves know water is a very dangerous thing!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Indeed, this river is, I believe, Arkan-Thoria. There are fell legends about it. May be they are but children's tales...still, be very careful when you cross it."
        [/message]

#TODO change for multiplayer
        [message]
            side_for=1
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "Before Kalenz left the Ka'lian he had ordered $left_behind to stay and guard it. Kalenz is from now on able to recruit Dwarves."
        [/message]

        {CLEAR_VARIABLE left_behind}
    [/event]

    [event]
        name=moveto
        [filter]
            x=1-37,1-17,21-37, 1-5,23-37,1-3,28-37,35-37
            y= 1-2,   3,    3,   4,    4,  5,    5,    6
            [and]
                id=Kalenz
#ifdef MULTIPLAYER
                [or]
                    id=Landar
                [/or]
                [or]
                    id=Olurf
                [/or]
#endif
            [/and]
        [/filter]
        [message]
            speaker=unit
            message= _ "We made it. Onwards to Thoria!"
        [/message]
        [message]
            id=Olurf
            message= _ "At last!"
        [/message]
        [message]
            id=Landar
            message= _ "We'll need to settle things with these saurians once and for all!"
        [/message]

        [endlevel]
            result=victory
            bonus=yes
        [/endlevel]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1,5,6
            x=1-37
            y=6-9
        [/filter]

        {RANDOM_PLACEMENT 32 7 1 (
            [unit]
                type=Water Serpent
                id=Sealurr
                name= _ "Sealurr"
                side=4
                [modifications]
                    {TRAIT_RESILIENT}
                    {TRAIT_STRONG}
                [/modifications]
            [/unit]
        ) }

        [message]
            speaker=unit
            message= _ "The legends are true! Sea creatures are upon us!"
        [/message]

        [scroll_to_unit]
            id=Sealurr
        [/scroll_to_unit]

        {RANDOM_PLACEMENT 3 8 2 (
            [unit]
                type=Cuttle Fish
                id=Kallub
                name= _ "Kallub"
                side=4
                [modifications]
                    {TRAIT_RESILIENT}
                    {TRAIT_STRONG}
                [/modifications]
            [/unit]
        ) }

        [message]
            speaker=unit
            message= _ "They are coming at us from all sides!"
        [/message]

        [scroll_to_unit]
            id=Kallub
        [/scroll_to_unit]

#ifndef EASY
        {RANDOM_PLACEMENT 3 9 2 (
            [unit]
                type=Water Serpent
                id=Scardeep
                name= _ "Scardeep"
                side=4
                [modifications]
                    {TRAIT_RESILIENT}
                    {TRAIT_STRONG}
                [/modifications]
            [/unit]
        ) }

        [message]
            speaker=unit
            message= _ "Watch for the Serpent!"
        [/message]

        [scroll_to_unit]
            id=Scardeep
        [/scroll_to_unit]

        {RANDOM_PLACEMENT 16 6 2 (
            [unit]
                type=Cuttle Fish
                id=Kalimar
                name= _ "Kalimar"
                side=4
                [modifications]
                    {TRAIT_RESILIENT}
                    {TRAIT_STRONG}
                [/modifications]
            [/unit]
        ) }

        [scroll_to_unit]
            id=Kalimar
        [/scroll_to_unit]
#endif

#ifdef HARD
        {RANDOM_PLACEMENT 34 8 1 (
            [unit]
                type=Cuttle Fish
                id=Alkamar
                name= _ "Alkamar"
                side=4
                [modifications]
                    {TRAIT_RESILIENT}
                    {TRAIT_STRONG}
                [/modifications]
            [/unit]
        ) }

        [scroll_to_unit]
            id=Alkamar
        [/scroll_to_unit]
#endif
    [/event]

    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}
#ifndef MULTIPLAYER
[/scenario]
#else
[/multiplayer]
#endif

#undef PLAYER_GOLD
