#textdomain wesnoth-low
#ifdef MULTIPLAYER
[multiplayer]
    name= _ "3p MC — LoW, Chapter two"
    description= _ "<i>The Legend of Wesmere</i>\nMultiplayer Campaign\nChapter two"
    id=04_The_Elvish_Treasury
    next_scenario=05_The_Saurian_Treasury_NORMAL
    random_start_time=no
    allow_new_game=yes
#else
    [scenario]
        name= _ "The Elvish Treasury"
        id=04_The_Elvish_Treasury
        next_scenario=05_The_Saurian_Treasury
#endif
        experience_modifier=100

        {LOW_MAP 04_The_Elvish_Treasury.map}
        {TURNS 35 30 25}

        {DEFAULT_SCHEDULE}

        {STARTING_VILLAGES_ALL 2}
        {STARTING_VILLAGES 3 14}

        {INTRO_AND_SCENARIO_MUSIC frantic.ogg vengeful.ogg}
        {EXTRA_SCENARIO_MUSIC knalgan_theme.ogg}
        {EXTRA_SCENARIO_MUSIC knolls.ogg}
        {EXTRA_SCENARIO_MUSIC silvan_sanctuary.ogg}

        [story]
#ifdef MULTIPLAYER
            [part]
                delay=4000
                title= _ "<i>The Legend of Wesmere</i>,
Chapter Two"
            [/part]
#endif
            [part]
                title= _ "Chapter Two,
<i>The Treasury</i>"
                #    show_title=yes
            [/part]
            [part]
                story= _ "Kalenz and his forces raced to relieve the siege of the Elvish Treasury..."
                delay=4000
                {TO_ELVISH_TREASURY}
            [/part]
            [part]
                {TO_ELVISH_TREASURY_BATTLE}
                show_title=yes
            [/part]
        [/story]

        [side]
            #{KALENZ}
            {PLAYABLE}
            no_leader=yes
            save_id=Kalenz
            fog=no
            shroud=no
            team_name=Player
            user_team_name= _ "Player"
            recruit=""
            # wmllint: recognize Kalenz
#ifndef MULTIPLAYER
            {PLAYER_GOLD_04}
            [unit]
                {LANDAR}
                extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
                x=16
                y=29
                # wmllint: recognize Landar
            [/unit]
#else
            {MULTIPLAYER_GOLD_04}
#endif
        [/side]

        [side]
            side=2
            allow_player=no
            controller=ai
            type=Saurian Ambusher
            {SAURIAN_SETUP}
            #{FLAG_VARIANT undead}
            id=Shurm
            name= _ "Shurm"
            canrecruit=yes
            {GOLD 190 280 340}
            {INCOME 4 8 12}
            team_name=Lizards
            user_team_name= _ "Enemies"
#ifdef EASY
            recruit=Saurian Skirmisher, Saurian Augur
#else
            recruit=Saurian Skirmisher, Saurian Augur,  Saurian Ambusher
#endif
            {ai/aliases/stable_singleplayer.cfg}
            [ai]
                {AI_SIMPLE_ALWAYS_ASPECT recruitment_ignore_bad_movement yes}
                {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout, scout, healer"}
                {AI_SIMPLE_ALWAYS_ASPECT aggression 0.75}
            [/ai]
        [/side]

        [side]
            side=3
            allow_player=no
            controller=ai
            type=Saurian Ambusher
            {SAURIAN_SETUP}
            {FLAG_VARIANT undead}
            id=Trigr
            name= _ "Trigr"
            canrecruit=yes
            {GOLD 190 280 350}
            {INCOME 4 8 12}
            team_name=Lizards
            user_team_name= _ "Enemies"
#ifdef EASY
            recruit=Saurian Skirmisher, Saurian Augur
#else
            recruit=Saurian Skirmisher, Saurian Augur, Saurian Ambusher
#endif
            {ai/aliases/stable_singleplayer.cfg}
            [ai]
                {AI_SIMPLE_ALWAYS_ASPECT recruitment_ignore_bad_movement yes}
                {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout, scout, healer"}
            [/ai]
        [/side]

#ifdef MULTIPLAYER
        [side]
            #Landar's side
            side=4
            fog=no
            shroud=no
            no_leader=yes
            #persistent=yes
            save_id=Landar
            {PLAYABLE}
            {MULTIPLAYER_GOLD_04}
            team_name=Player
            user_team_name= _ "Player"
            # wmllint: recognize Landar
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
        [/side]

        [side]
            #Cleodil's side
            side=5
            fog=no
            shroud=no
            no_leader=yes
            #persistent=yes
            save_id=Cleodil
            {PLAYABLE}
            #TODO maybe give Cleodil less money in that scenario?
            {MULTIPLAYER_GOLD_04}
            team_name=Player
            user_team_name= _ "Player"
            # wmllint: recognize Cleodil
            extra_recruit=Elvish Shaman, Elvish Scout, Wose
        [/side]

#endif

        [item]
            x=13
            y=11
            image=scenery/temple1.png
        [/item]
        [item]
            x=11
            y=11
            image=units/elves-wood/shyde.png~RC(magenta>red)
        [/item]
        [item]
            x=11
            y=11
            image=items/cage.png
        [/item]

#define OBJECTIVES
    side=0
    [objective]
        description= _ "Defeat all enemy leaders"
        condition=win
    [/objective]
    [objective]
        description= _ "Death of Kalenz"
        condition=lose
    [/objective]
    [objective]
        description= _ "Death of Landar"
        condition=lose
    [/objective]

    {TURNS_RUN_OUT}

    [gold_carryover]
        bonus=yes
        carryover_percentage=80
    [/gold_carryover]
#enddef

        [event]
            #Used this instead of prestart since global variables aren't synced before
            name=side 1 turn 1
            [objectives]
                {OBJECTIVES}
            [/objectives]

#ifdef MULTIPLAYER
            {GET_PERSISTENT_RECALLS_FROM2 1 4 LoW_Chapter_One kalenz}
            {GET_PERSISTENT_GOLD_FROM2 1 4 LoW_Chapter_One kalenz_gold}
            {GET_PERSISTENT_RECALLS_FROM2 4 1 LoW_Chapter_One landar}
            {GET_PERSISTENT_GOLD_FROM2 4 1 LoW_Chapter_One landar_gold}
#endif

            [recall]
                id=Kalenz
                x=7
                y=29
            [/recall]
            [if]
                [not]
                    [have_unit]
                        id=Kalenz
                    [/have_unit]
                [/not]
                [then]
                    [unit]
                        {KALENZ}
                        extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
                        type=Elvish Captain
                        x=7
                        y=29
                    [/unit]
                [/then]
            [/if]

            [recall]
                id=Landar
                x=16
                y=29
            [/recall]
            [if]
                [not]
                    [have_unit]
                        id=Landar
                    [/have_unit]
                [/not]
                [then]
                    [unit]
                        {LANDAR}
                        extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
                        side=4
                        type=Elvish Ranger
                        x=16
                        y=29
                    [/unit]
                [/then]
            [/if]

            {RECALL_LOYALS}
            # wmllint: recognize Huraldur
            #{CHECK_LANDAR}

#ifdef MULTIPLAYER
            [recall]
                type=Elvish Ranger, Elvish Avenger
                role=liberator
                x=23
                y=24
            [/recall]
            [if]
                [not]
                    [have_unit]
                        role=liberator
                    [/have_unit]
                [/not]
                [then]
                    {UNIT 1 (Elvish Ranger) 23 24 (role=liberator)}
                [/then]
            [/if]
#else
            [allow_extra_recruit]
                id=Kalenz,Landar
                extra_recruit=Elvish Scout
            [/allow_extra_recruit]

#endif

            [redraw]
            [/redraw]

            [message]
                id=Kalenz
                message= _ "It seems that we are too late. The Treasury has fallen to the Saurians..."
            [/message]
            [message]
                id=Huraldur
                message= _ "And I see the remains of the garrison has been taken prisoner."
            [/message]

            {HIGHLIGHT_IMAGE 11 11 items/cage.png ("units/elves-wood/shyde.png~RC(magenta>red)")}
            [scroll_to_unit]
                id=Kalenz
            [/scroll_to_unit]

            [message]
                id=Kalenz
                message= _ "We must free them and make these saurians pay. Attack and leave no one alive!"
            [/message]

#ifdef MULTIPLAYER
            [message]
                role=liberator
                message= _ "I will do as you say, sneak in and free them. Wish me good fortune and no discovery!"
            [/message]
            [message]
                id=Kalenz
                message= _ "Go swiftly and silently."
            [/message]
            [move_unit]
                role=liberator
                to_x=11
                to_y=11
                fire_event=yes
            [/move_unit]
#endif

            [message]
                id=Shurm
                message= _ "More elves are coming! Too late, we’ve taken all your gold and we’ll get more gold from the orcs for helping them out!"
            [/message]
            [message]
                id=Kalenz
                message= _ "You will not live to enjoy it!"
            [/message]
        [/event]

        [event]
            name=free cleodil

            {INCIDENTAL_MUSIC love_theme.ogg}

            [unit]
                # wmllint: recognize Cleodil
                {CLEODIL}
#ifdef MULTIPLAYER
                side=5
#else
                side=1
#endif
                x,y=11,11
            [/unit]

            [remove_item]
                x,y=11,11
            [/remove_item]

            [unit]
                id=Arkildur
                name= _ "Arkildur"
#ifdef MULTIPLAYER
                side=5
#else
                side=1
#endif
                type=Elvish Fighter
                x,y=11,11
                [modifications]
                    {TRAIT_STRONG}
                    {TRAIT_INTELLIGENT}
                    {TRAIT_LOYAL}
                [/modifications]
                {IS_LOYAL}
            [/unit]
            [unit]
                id=Tameril-Isimeril
                name= _ "Tameril-Isimeril"
#ifdef MULTIPLAYER
                side=5
#else
                side=1
#endif
                type=Elvish Archer
                x,y=11,11
                random_gender=yes
                [modifications]
                    {TRAIT_DEXTROUS}
                    {TRAIT_RESILIENT}
                    {TRAIT_LOYAL}
                [/modifications]
                {IS_LOYAL}
            [/unit]
#ifdef EASY
            [unit]
                id=Laril
                name= _ "Laril"
#ifdef MULTIPLAYER
                side=5
#else
                side=1
#endif
                type=Elvish Archer
                x,y=11,11
                [modifications]
                    {TRAIT_DEXTROUS}
                    {TRAIT_QUICK}
                    {TRAIT_LOYAL}
                [/modifications]
                {IS_LOYAL}
            [/unit]
#endif

            [message]
                id=Cleodil
                message= _ "We are free! My lord Kalenz, from this day forward I and my men are your sworn followers. And there is that which you should know about the treasure the orcs seek..."
            [/message]
            [message]
                id=Kalenz
                message= _ "I accept your service gratefully, for I will need every sword and bow and spell with which to defeat these invaders. There will be time for talk later; now, we must fight."
            [/message]
        [/event]

        [event]
            name=moveto
            [filter]
                side=1,4
                x=11
                y=11
            [/filter]

            [fire_event]
                name=free cleodil
            [/fire_event]

            [objectives]
                {OBJECTIVES}
                [objective]
                    description= _ "Death of Cleodil"
                    condition=lose
                [/objective]
            [/objectives]
        [/event]
#undef OBJECTIVES
        [event]
            name=victory

            [if]
                [not]
                    [have_unit]
                        id=Cleodil
                    [/have_unit]
                [/not]

                [then]
                    [message]
                        id=Kalenz
                        message= _ "Without their leaders, the saurians flee in panic. Let us free the treasury’s garrison before they can find it in them to rally and return."
                    [/message]

                    [fire_event]
                        name=free cleodil
                    [/fire_event]
                [/then]
            [/if]

            [message]
                id=Kalenz
                message= _ "We have defeated the saurians and freed the garrison, and that is no small thing... but our gold is gone."
            [/message]
            [message]
                id=Cleodil
                # wmllint: directory spelling dastone
                message= _ "The saurians happily carried away the treasury gold, but they had come here looking for something more specific... some individual object they called ‘dastone’. I am sorry, my lord Kalenz, I could not understand their distorted speech very well."
            [/message]
            [message]
                race=elf
                message= _ "The war with the Orcs goes poorly. The Ka’lian will need that gold back to buy arms and food, to hire artisans, to support its armies."
            [/message]
            [message]
                id=Kalenz
                message= _ "We will hunt down those saurians and retrieve our gold. More, we must teach them that it is lethal folly to raid us, else they will plague us like rats."
            [/message]
        [/event]

        [event]
            name=last breath
            [filter]
                id=Shurm
            [/filter]
            [message]
                speaker=unit
                message= _ "I am ashamed to die at the hands of tree-shaggers!"
            [/message]
            [message]
                speaker=second_unit
                message= _ "When you meet your kin in the dry hells, tell them you perished at the hands of Kalenz’s elves!"
            [/message]
        [/event]

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