#textdomain wesnoth-low
#ifndef MULTIPLAYER
#define PLAYER_GOLD
    {GOLD 320 260 240}
    {INCOME -2 -2 -2}
#enddef
#else
#define PLAYER_GOLD
    {GOLD 120 105 90}
    {INCOME -2 -2 -2}
#enddef
#endif
[scenario]
    name= _ "The Elvish Treasury"
    id=04_The_Elvish_Treasury
    next_scenario=05_The_Saurian_Treasury

    allow_new_game=yes
    new_game_title= _ "Chapter Two: The Treasury"
    force_lock_settings=yes

    experience_modifier=100

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

    {DEFAULT_SCHEDULE}
    random_start_time=no

    {STARTING_VILLAGES_ALL 4}
    {STARTING_VILLAGES 5 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]
            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..."
            {LOW_BIGMAP}
            {FLIGHT_COMPLETE}
            {TREASURY_STAGE1}
        [/part]
    [/story]
    {LOW_TRACK ( {FLIGHT_COMPLETE} {TREASURY_STAGE1_END} ) }

    # wmllint: validate-off
    [side]
        side=1
        # wmllint: who KALENZ is Kalenz
        {KALENZ}
        {PLAYABLE}
        save_id=Kalenz
        disallow_shuffle=yes
        {PLAYER_GOLD}
#ifndef MULTIPLAYER
        [unit]
            # wmllint: who LANDAR is Landar
            {LANDAR}
            x=16
            y=29
        [/unit]
#else
#endif
    [/side]
    # wmllint: validate-on

    #Landar's side

    # wmllint: skip-side
    {MP_SIDE 2 (
        {LANDAR}
        save_id=Landar
        disallow_shuffle=yes
        {PLAYABLE}
        {PLAYER_GOLD}
    )}

    # wmllint: skip-side
    {MP_SIDE 3 (
        no_leader=yes
        save_id=Cleodil
        disallow_shuffle=yes
        {PLAYABLE}
        {PLAYER_GOLD}
    )}

    [side]
        side=4
        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]
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout, scout, healer"}
            {AI_SIMPLE_ALWAYS_ASPECT aggression 0.75}
        [/ai]
    [/side]

    [side]
        side=5
        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]
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout, scout, healer"}
        [/ai]
    [/side]

    [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=40
    [/gold_carryover]
#enddef

    [event]
        name=start
        [objectives]
            {OBJECTIVES}
        [/objectives]

#ifdef MULTIPLAYER
        [persistent_carryover_unstore]
            scenario_id = LoW_Chapter_One
        [/persistent_carryover_unstore]
#endif
        # wmllint: who RECALL_LOYALS is Huraldur
        #{RECALL_LOYALS}
        # Kalenz's pals
        [recall]
            id=Huraldur
            x=7
            y=28
        [/recall]

        [recall]
            id=Anduilas
            x=6
            y=28
        [/recall]

        # Landar's pals
        [recall]
            id=Arkildur
            x=17
            y=29
        [/recall]

        [recall]
            id=scout
            x=16
            y=28
        [/recall]

#ifdef MULTIPLAYER
        # TODO: this is the only unit that player3 controls until
        # Cleodil is freed by the other players. We should make this
        # scenario more intesting for player 3 during this time.
        # Maybe give him some units that managed to escape and want to help?
        {UNIT 3 (Elvish Ranger) 23 24 (role=liberator)}
#endif
        [allow_extra_recruit]
            id=Kalenz,Landar
            extra_recruit=Elvish Scout
        [/allow_extra_recruit]

        [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: who CLEODIL is Cleodil
            {CLEODIL}
#ifdef MULTIPLAYER
            side=3
#else
            side=1
#endif
            x,y=11,11
        [/unit]

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

        [unit]
            {LARIL}
#ifdef MULTIPLAYER
            side=3
#else
            side=1
#endif
            x,y=11,11
        [/unit]
        [unit]
            {TAMERIL_ISIMERIL}
#ifdef MULTIPLAYER
            side=3
#else
            side=1
#endif
            x,y=11,11
        [/unit]

        [message]
            id=Cleodil
            message= _ "We are free! My lord Kalenz, from this day forward I and my kin 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,2,3
            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=scenario_end
        [filter_condition]
            [proceed_to_next_scenario]
            [/proceed_to_next_scenario]
        [/filter_condition]

        [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]
    {DEFAULT_VICTORY 0.4}

    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}
[/scenario]
#undef PLAYER_GOLD
