#textdomain wesnoth-low
[scenario]
    name= _ "Bounty Hunters"
    id=09_Bounty_Hunters
    next_scenario=10_Cliffs_of_Thoria

    random_start_time=no
    allow_new_game=yes
    new_game_title= _ "Chapter Three: The Book of Crelanu"
    force_lock_settings=yes

    experience_modifier=100

    {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}
    #TODO redo music playlist

    [story]
#ifdef MULTIPLAYER
        [part]
            delay=4000
            title= _ "<i>The Legend of Wesmere</i>
Chapter Three"
            #  show_title=yes
        [/part]
#endif
        [part]
            delay=4000
            title= _ "Chapter Three
<i>The Book of Crelanu</i>"
            show_title=yes
        [/part]
        [part]
            delay=4000
            story= _ "Believing that Wesmere’s seeming safety might prove a costly illusion, Kalenz, Landar 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]
    [/story]
    {LOW_TRACK ( {FLIGHT_COMPLETE} {TREASURY_COMPLETE} {BOOK_STAGE2} ) }

#define PLAYER_GOLD
    {GOLD 360 340 320}
#enddef
#define MULTIPLAYER_GOLD
    {GOLD 120 110 100}
#enddef

    [side]
        side=1
        save_id=Kalenz
        disallow_shuffle=yes
        {PLAYABLE}
        {KALENZ}
#ifndef MULTIPLAYER
        {PLAYER_GOLD}
        [unit]
            {LANDAR}
            x=14
            y=33
        [/unit]
        [unit]
            {OLURF}
            x=18
            y=31
        [/unit]
        [unit]
            {CLEODIL}
            x=18
            y=33
        [/unit]
#else
        {MULTIPLAYER_GOLD}
        recruit=Elvish Fighter, Elvish Archer, Elvish Scout
#endif
    [/side]

    #Landar's side
    # wmllint: skip-side
    {MP_SIDE 2 (
        {PLAYABLE}
        save_id=Landar
        disallow_shuffle=yes
        {MULTIPLAYER_GOLD}
        no_leader=yes
        [unit]
            {LANDAR}
            x=14
            y=33
        [/unit]
    )}

    #Olurf's side
    # wmllint: skip-side
    {MP_SIDE 3 (
        {PLAYABLE}
        save_id=Olurf
        disallow_shuffle=yes
        #TODO give Olurf more gold?
        {MULTIPLAYER_GOLD}
        no_leader=yes
        {DWARF_SETUP}
        [unit]
            {OLURF}
            x=18
            y=31
        [/unit]
    )}

    #Cleodil's side
    # wmllint: skip-side
    {MP_SIDE 4 (
        {PLAYABLE}
        save_id=Cleodil
        disallow_shuffle=yes
        {MULTIPLAYER_GOLD}
        no_leader=yes
        [unit]
            {CLEODIL}
            x=18
            y=33
        [/unit]
    )}

    [side]
        side=5
        {SAURIAN_SETUP}
        allow_player=no
        controller=ai
        type=Saurian Flanker
        id=Huurgh
        name=_ "Huurgh"

        canrecruit=yes
        {GOLD 360 440 500}
        {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 Ambusher, Saurian Oracle, Saurian Soothsayer, Saurian Flanker
#endif
        [ai]
            {NO_SCOUTS}
#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=6
        {SAURIAN_SETUP}
        allow_player=no
        controller=ai
        type=Saurian Oracle
        id=Shhar
        name=_ "Shhar"

        canrecruit=yes
        {GOLD 360 460 540}
        {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 Ambusher, Saurian Oracle, Saurian Soothsayer, Saurian Flanker
#endif
        [ai]
            {NO_SCOUTS}
#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=7
        allow_player=no
        controller=ai
        hidden=yes
        no_leader=yes
        team_name=creatures
        user_team_name= _ "Creatures"
        faction=Custom
        [ai]
            aggression=1.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-4,   5,    5,   6,    6,  7,    7,    8
            [/avoid]
            [avoid]
                x=1-37
                y=14-34
            [/avoid]
            [avoid]
                x=1-4,13-17,26-37
                y= 13,   13,   13
            [/avoid]
            [avoid]
                x=9-10, 8-13,10-13,9-12,21-24,22-23,22-24
                y=   7,    8,    9,  10,   10,   11,    9
            [/avoid]
            village_value=0
        [/ai]
    [/side]

    #### Concentrated every wml related to the game setup into this single event ####
    [event]
        name=start

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

        [command]
#ifdef MULTIPLAYER
            [persistent_carryover_unstore]
                scenario_id = LoW_Chapter_Two
            [/persistent_carryover_unstore]
#endif

#define LEAVE_BEHIND_L3 NAME SIDE
    # these have been left behind to guard the Ka'lian
    [store_unit]
        variable=l3_store_{NAME}
        kill=yes
        [filter]
            side={SIDE}
            type=Elvish Marshal,Elvish Champion,Elvish Avenger,Elvish Sharpshooter
            [not]
                id=Kalenz
            [/not]
            [not]
                id=Anduilas
            [/not]
            [not]
                id=Arkildur
            [/not]
            [not]
                id=Landar
            [/not]
            [not]
                id=Cleodil
            [/not]
            [not]
                {FILTER_LOYALS}
            [/not]
        [/filter]
    [/store_unit]
    [lua]
        code=<<
            local args = (...)
            local units = wml.child_array(args, "units")
            local empty_str = args.empty
            local var = args.variable

            for i = 1, #units do
                units[i] = units[i].name
            end
            wml.variables[var] = wesnoth.format_conjunct_list(empty_str, units)
        >>
        [args]
            empty= _ "some experienced warriors" # wmllint: ignore
            variable=left_behind_{NAME}
            [insert_tag]
                name=units
                variable=l3_store_{NAME}
            [/insert_tag]
        [/args]
    [/lua]
#enddef

            {LEAVE_BEHIND_L3 kalenz 1}
#ifdef MULTIPLAYER
            {LEAVE_BEHIND_L3 landar 2}
#endif
            {RECALL_LOYALS}

            [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]

                {TURNS_RUN_OUT}

                [gold_carryover]
                    bonus=yes
                    carryover_percentage=40
                [/gold_carryover]
            [/objectives]

            [message]
                id=Huurgh
                # wmllint: local spelling Yess
                message= _ "Yess! 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=Landar
                message= _ "They are far too numerous to risk battle with. Let’s cross the river!"
            [/message]
            [message]
                id=Olurf
                message= _ "We can outrun them in the woods and mountains beyond the north shore. But crossing the river without a bridge? We dwarves know water is a very dangerous thing!"
            [/message]
            [message]
                id=Cleodil
                message= _ "Indeed, this river is, I believe, Arkan-Thoria. There are fell legends about it. Maybe they are but children’s tales... Still, be very careful when you cross it."
            [/message]
            [message]
                id=Kalenz
                message= _ "You speak my thought, Cleodil. Close in behind me; I’ll guard you from harm myself. Look to your weapons as we cross, all! And be wary."
            [/message]

            [message]
                side_for=1
                speaker=narrator
                image=wesnoth-icon.png
                message= _ "Before Kalenz left the Ka’lian he had ordered $left_behind_kalenz to stay and guard it."
            [/message]
            {CLEAR_VARIABLE left_behind_kalenz}
#ifdef MULTIPLAYER
            [message]
                side_for=2
                speaker=narrator
                image=wesnoth-icon.png
                message= _ "Before Landar left the Ka’lian he had ordered $left_behind_landar to stay and guard it."
            [/message]
            {CLEAR_VARIABLE left_behind_landar}
#endif
        [/command]
    [/event]

    [event]
        name=moveto
        [filter]
            x=1-37,1-17,21-37, 1-5,23-37,1-3,28-37,35-37
            y= 1-4,   5,    5,   6,    6,  7,    7,    8
            [and]
                id=Kalenz
#ifdef MULTIPLAYER
                [or]
                    id=Landar
                [/or]
                [or]
                    id=Olurf
                [/or]
#endif
            [/and]
        [/filter]

        [command]
            [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]
            [message]
                id=Cleodil
                message= _ "Hasn’t enough blood been shed? I think we can compose matters with them after the threat of the orcs has been met."
            [/message]

            [endlevel]
                result=victory
#ifdef MULTIPLAYER
                bonus=0.3
#else
                bonus=yes
#endif
            [/endlevel]
        [/command]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1,2,3,4
            x=1-37
            y=8-11
        [/filter]

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

        [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 10 2 (
            type=Cuttle Fish
            id=Kallub
            name= _ "Kallub"
            side=7
            [modifications]
                {TRAIT_RESILIENT}
                {TRAIT_STRONG}
            [/modifications]
        ) }

        [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 11 2 (
            type=Water Serpent
            id=Scardeep
            name= _ "Scardeep"
            side=7
            [modifications]
                {TRAIT_RESILIENT}
                {TRAIT_STRONG}
            [/modifications]
        ) }

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

        [scroll_to_unit]
            id=Scardeep
        [/scroll_to_unit]

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

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

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

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

    {DEFAULT_VICTORY 0.3}
    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}
[/scenario]

#undef PLAYER_GOLD
#undef MULTIPLAYER_GOLD
