#textdomain wesnoth-low
#ifdef MULTIPLAYER
[multiplayer]
    name= _ "4p MC — LoW, Normal Mode, Chapter three"
    description= _ "<i>The Legend of Wesmere</i>\nMultiplayer Campaign\nChapter three\n Normal difficulty"
    id=09_Bounty_Hunters
    next_scenario=10_Cliffs_of_Thoria
    random_start_time=no
    allow_new_game=yes
#else
    [scenario]
        name= _ "Bounty Hunters"
        id=09_Bounty_Hunters
        next_scenario=10_Cliffs_of_Thoria
#endif
        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

        #        {LOW_PRESTART}

        [story]
#ifdef MULTIPLAYER
            [part]
                delay=4000
                title= _ "<i>The Legend of Wesmere</i>,
Chapter Three"
                #  show_title=yes
                story= _ "This multiplayer campaign is best be played after finishing chapter one, since the recall lists of that scenario will be reloaded."
            [/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]

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

#define PLAYER_GOLD
    {GOLD 287 260 230}
#enddef
#define MULTIPLAYER_GOLD
    {GOLD 70 65 55}
#enddef

        [side]
            side=1
            save_id=Kalenz
            persistent=yes
            no_leader=yes
            controller=human
            {PLAYABLE}
            fog=no
            shroud=no
            team_name=player
            user_team_name= _ "Player"
            # wmllint: recognize Kalenz
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
#ifndef MULTIPLAYER
            {PLAYER_GOLD}
            {KALENZ}
            [unit]
                {LANDAR}
                extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
                # wmllint: recognize Landar
                x=14
                y=31
            [/unit]
            [unit]
                {OLURF}
                extra_recruit=Dwarvish Fighter, Dwarvish Thunderer, Dwarvish Scout, Dwarvish Stalwart
                x=18
                y=29
                # wmllint: recognize Olurf
            [/unit]
            [unit]
                {CLEODIL}
                extra_recruit=Elvish Shaman, Wose, Elvish Scout
                x=18
                y=31
                # wmllint: recognize Cleodil
            [/unit]
#else
            {MULTIPLAYER_GOLD}
            recruit=Elvish Fighter, Elvish Archer, Elvish Scout
#endif
        [/side]

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

            canrecruit=yes
            #            {GOLD 200 240 290}
            {GOLD 400 480 580}
            {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}
                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
            {SAURIAN_SETUP}
            allow_player=no
            controller=ai
            type=Saurian Oracle
            id=Shhar
            name=_ "Shhar"

            canrecruit=yes
            #            {GOLD 300 340 400}
            {GOLD 400 480 580}
            {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}
                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]

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

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

#ifdef MULTIPLAYER
            {GET_PERSISTENT_RECALLS_FROM4 1 5 6 7 LoW_Chapter_Two kalenz}
            {GET_PERSISTENT_RECALLS_FROM4 5 1 6 7 LoW_Chapter_Two landar}
            {GET_PERSISTENT_RECALLS_FROM4 6 1 5 7 LoW_Chapter_Two olurf}
            {GET_PERSISTENT_RECALLS_FROM4 7 1 5 6 LoW_Chapter_Two cleodil}
#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}
            [not]
                id=Kalenz
            [/not]
            [not]
                id=Anduilas
            [/not]
            [not]
                #wmllint: recognize Landulias
                id=Landulias
            [/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]
    [switch]
        variable=l3_store_{NAME}.length
        [case]
            value=0
            [set_variable]
                name=left_behind_{NAME}
                value= _ "some experienced warriors" # wmllint: ignore
            [/set_variable]
        [/case]
        [case]
            value=1
            [set_variable]
                name=left_behind_{NAME}
                value=$l3_store_{NAME}[0].name
            [/set_variable]
        [/case]
        [else]
            {VARIABLE l3_length $l3_store_{NAME}.length}
            {VARIABLE_OP l3_length sub 1}
            {FOREACH l3_store_{NAME} i}
                # for-case, what a great anti-pattern
                [switch]
                    variable=i
                    [case]
                        value=0
                        [set_variable]
                            name=left_behind_{NAME}
                            value=$l3_store_{NAME}[$i].name
                        [/set_variable]
                    [/case]
                    [case]
                        value=$l3_length
                        [set_variable]
                            name=left_behind_{NAME}
                            value= _ "$left_behind_{NAME} and $l3_store_{NAME}[$i].name" # wmllint: ignore
                        [/set_variable]
                    [/case]
                    [else]
                        [set_variable]
                            name=left_behind_{NAME}
                            value= _ "$left_behind_{NAME}|, $l3_store_{NAME}[$i].name" # wmllint: ignore
                        [/set_variable]
                    [/else]
                [/switch]
            {NEXT i}
            {CLEAR_VARIABLE l3_length}
        [/else]
    [/switch]
#enddef

            {LEAVE_BEHIND_L3 kalenz 1}
#ifdef MULTIPLAYER
            {LEAVE_BEHIND_L3 landar 5}
#endif

            [recall]
                id=Kalenz
                x=22
                y=31
            [/recall]

            [recall]
                id=Cleodil
                x=18
                y=31
            [/recall]

            [recall]
                id=Olurf
                x=18
                y=29
            [/recall]

            [recall]
                id=Landar
                x=14
                y=31
            [/recall]

            [recall]
                id=Anduilas
                x=21
                y=31
            [/recall]

            [if]
                [not]
                    [have_unit]
                        id=Kalenz
                    [/have_unit]
                [/not]
                [then]
                    [unit]
                        {KALENZ}
                        type=Elvish Captain
                        x=22
                        y=31
                    [/unit]
                    # wmlscope: start ignoring
                    {UNIT 1 (Elvish Marksman) recall recall ()}
                    # wmlscope: stop ignoring
                [/then]
            [/if]
            [if]
                [not]
                    [have_unit]
                        id=Landar
                    [/have_unit]
                [/not]
                [then]
                    [unit]
                        {LANDAR}
                        side=5
                        type=Elvish Ranger
                        x=14
                        y=31
                        # wmllint: recognize Landar
                    [/unit]
                [/then]
            [/if]
            [if]
                [not]
                    [have_unit]
                        id=Olurf
                    [/have_unit]
                [/not]
                [then]
                    [unit]
                        {OLURF}
                        side=6
                        x=18
                        y=29
                        # wmllint: recognize Olurf
                    [/unit]
                [/then]
            [/if]
            [if]
                [not]
                    [have_unit]
                        id=Cleodil
                    [/have_unit]
                [/not]
                [then]
                    [unit]
                        {CLEODIL}
                        side=7
                        x=18
                        y=31
                        # wmllint: recognize Cleodil
                    [/unit]
                [/then]
            [/if]

            [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=80
                [/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. May be 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
#ifndef MULTIPLAYER
                message= _ "Before Kalenz left the Ka’lian he had ordered $left_behind_kalenz to stay and guard it." + _" Kalenz is able to recruit dwarves from now on."
#else
                message= _ "Before Kalenz left the Ka’lian he had ordered $left_behind_kalenz to stay and guard it."
#endif
            [/message]
            {CLEAR_VARIABLE left_behind_kalenz}
#ifdef MULTIPLAYER
            [message]
                side_for=5
                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
        [/event]

        [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]
            #Landar's side
            save_id=Landar
            side=5
            fog=no
            shroud=no
            {MULTIPLAYER_GOLD}
            no_leader=yes
            {PLAYABLE}
            team_name=player
            user_team_name= _ "Player"
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
        [/side]

        [side]
            #Olurf's side
            save_id=Olurf
            side=6
            fog=no
            shroud=no
            #TODO give Olurf more gold?
            {MULTIPLAYER_GOLD}
            team_name=player
            user_team_name= _ "Player"
            no_leader=yes
            {PLAYABLE}
            {DWARF_SETUP}
            controller=human
            allow_player=yes
            extra_recruit=Dwarvish Fighter, Dwarvish Scout, Dwarvish Guardsman, Dwarvish Thunderer
        [/side]

        [side]
            #Cleodil's side
            save_id=Cleodil
            side=7
            fog=no
            shroud=no
            {MULTIPLAYER_GOLD}
            team_name=player
            user_team_name= _ "Player"
            no_leader=yes
            {PLAYABLE}
            controller=human
            allow_player=yes
            recruit=Elvish Shaman, Wose, Elvish Scout
        [/side]
#endif

        [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]
            [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
                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
#undef MULTIPLAYER_GOLD
