#textdomain wesnoth-low
[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]
            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]
        side=1
        {KALENZ}
        {PLAYABLE}
        #    no_leader=yes
        type=Elvish Captain
        save_id=Kalenz
        fog=no
        shroud=no
        team_name=Player
        user_team_name= _ "Player"
        recruit=""
#ifndef MULTIPLAYER
        {PLAYER_GOLD_04}
        [unit]
            {LANDAR}
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            x=16
            y=29
        [/unit]
#else
        {MULTIPLAYER_GOLD_04}
#endif
    [/side]

    #Landar's side
    [side]
        side=2
#ifdef MULTIPLAYER
        {LANDAR}
        type=Elvish Ranger
        fog=no
        shroud=no
        #persistent=yes
        save_id=Landar
        {PLAYABLE}
        {MULTIPLAYER_GOLD_04}
        team_name=Player
        user_team_name= _ "Player"
        extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
#else
        no_leader=yes
        hidden=yes
        allow_player=no
        controller=null
#endif
    [/side]

    [side]
        #Cleodil's side
        side=3
        no_leader=yes
#ifdef MULTIPLAYER
        {CLEODIL}
        type=Elvish Shyde
        #persistent=yes
        save_id=Cleodil
        {PLAYABLE}
        fog=no
        shroud=no
        #TODO maybe give Cleodil less money in that scenario?
        {MULTIPLAYER_GOLD_04}
        team_name=Player
        user_team_name= _ "Player"
        extra_recruit=Elvish Shaman, Elvish Scout, Wose
#else
        hidden=yes
        allow_player=no
        controller=null
#endif
    [/side]

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

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

        # 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
        {UNIT 3 (Elvish Ranger) 23 24 (role=liberator)}
#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: 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 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}
[/scenario]
