#textdomain wesnoth-low
#ifdef MULTIPLAYER
[multiplayer]
    random_start_time=no
#ifndef DEBUG_MODE
    allow_new_game=no
#endif
#else
[scenario]
#endif

    id=05_Saurian_Treasury
    name= _ "The Saurian Treasury"
    next_scenario=06_Acquaintance_in_Need
    {LOW_MAP Saurgrath.map}
    {LOW_MASK 05_Saurian_Treasury.mask 1 1}
    {TURNS 24 20 18}

    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC frantic.ogg the_dangerous_symphony.ogg}
    {EXTRA_SCENARIO_MUSIC knalgan_theme.ogg}
    {EXTRA_SCENARIO_MUSIC the_city_falls.ogg}
    #TODO more music

    {STARTING_VILLAGES_ALL 2}
    {STARTING_VILLAGES 3 20}

    {LOW_PRESTART}

    [story]
        [part]
            story= _ "Elvish scouts found the trail of the Saurian war party without difficulty. The way back to the saurians' treasury was clear..."
            delay=4000
            {TO_SAURIAN_TREASURY}
        [/part]
        [part]
            show_title=yes
            {TO_SAURIAN_TREASURY_BATTLE}
        [/part]
    [/story]

#define PLAYER_GOLD
    {GOLD 300 250 200}
#enddef

    #wmllint: validate-off
    [side]
        {KALENZ}
        {PLAYER_GOLD}
        # wmllint: recognize Kalenz
        recruit={ELVES}
        x=3
        y=19
        fog=no
#ifndef MULTIPLAYER
        [unit]
            {LANDAR}
            placement=leader
            # wmllint: recognize Landar
        [/unit]
#endif
        [unit]
            {CLEODIL}
            placement=leader
            # wmllint: recognize Cleodil
        [/unit]
    [/side]
    #wmllint: validate-on

    [side]
        side=2
        allow_player=no
        controller=ai
        id=Hraurg
        name= _ "Hraurg"
        type=Saurian Ambusher
        canrecruit=yes
        x=22
        y=24
        {GOLD 100 140 160}
        {INCOME 4 8 12}
        team_name=Saurians
        user_team_name= _ "Enemies"
        {FLAG_VARIANT undead}
#ifdef EASY
        recruit=Saurian Skirmisher, Saurian Augur
#else
        recruit=Saurian Skirmisher, Saurian Augur, Saurian Ambusher
#endif
        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_NO_SCOUTS}
            {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}
            [goal]
                [criteria]
                    role=gold_carrier
                [/criteria]
                value=3.0
            [/goal]
        [/ai]
    [/side]

    [side]
        side=3
        allow_player=no
        controller=ai
        type=Saurian Ambusher
        id=Spahr
        name= _ "Spahr"
        canrecruit=yes
        x=26
        y=2
        {GOLD 100 240 320}
        {INCOME 4 8 12}
        team_name=Saurians
        user_team_name= _ "Enemies"
        {FLAG_VARIANT undead}
#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}
            [goal]
                [criteria]
                    role=gold_carrier
                [/criteria]
                value=3.0
            [/goal]
        [/ai]
    [/side]

#ifdef MULTIPLAYER
    #wmllint: validate-off
    [side]
        side=4
        fog=no
        {PLAYER_GOLD}
        recruit={ELVES}
        {LANDAR}
        # wmllint: recognize Landar
        x=3
        y=22
    [/side]
    #wmllint: validate-on
#endif

    [event]
        name=prestart
        [objectives]
            side=0

            #TODO maybe switch the both win objectivs
            [objective]
                description= _ "Enter the Saurian Treasury and leave with the gold"
                condition=win
            [/objective]
            {ALTERNATIVE_OBJECTIVE (_ "Defeat all enemy leaders")}
            [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= _ "Turns run out"
                condition=lose
            [/objective]
            note={EARLY_FINISH_BONUS_NOTE}
        [/objectives]

        {RECALL_LOYALS}
    [/event]

    [event]
        name=start

        [message]
            id=Kalenz
            message= _ "There they are. They have dumped our gold in their own treasury. We must strike quickly and leave with the gold before they can summon their full host."
        [/message]
        [message]
            id=Cleodil
            message= _ "Moving so much gold is no light matter. We will need horses to bear it back home."
        [/message]
        [message]
            id=Hraurg
            # wmllint: local spelling ussss
            #po: Saurians often hiss their sibilants; do this in your language.
            message= _ "The elves have followed ussss! We must hold the gold until reinforcements arrive."
        [/message]
    [/event]

#define BLINK
    {TEAM_COLOR_OVERRIDE (role=gold_carrier) white}
    [redraw]
    [/redraw]
    [delay]
        time=500
    [/delay]
    {TEAM_COLOR_OVERRIDE (role=gold_carrier) purple}
    [redraw]
    [/redraw]
    [delay]
        time=500
    [/delay]
#enddef

#define TREASURE_CHEST X Y
    [item]
        image=items/chest.png
        x={X}
        y={Y}
    [/item]

    [event]
        name=moveto
        delayed_variable_substitution=no
        [filter]
            x={X}
            y={Y}
            type=Elvish Scout, Elvish Outrider, Elvish Rider
        [/filter]

        [object]
            image=items/chest.png
            name= _ "Treasure Chest"
            [effect]
                apply_to=status
                add=slowed
                unit_type=Elvish Scout, Elvish Outrider, Elvish Rider
            [/effect]
            duration=level
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    image=items/chest.png
                [/removeitem]
                [role]
                    x={X}
                    y={Y}
                    role=gold_carrier
                [/role]
                [unit_overlay]
                    x={X}
                    y={Y}
                    image=items/gold-coins-small.png
                [/unit_overlay]
            [/then]
        [/object]
    [/event]
#enddef

    [event]
        name=side turn
        first_time_only=no
        {MODIFY_UNIT role=gold_carrier status.slowed yes }
    [/event]

    [event]
        name=moveto
        [filter]
            race=elf
            x,y=20,21
        [/filter]

        [music]
            name=northerners.ogg
            play_once=yes
        [/music]

        [message]
            id=unit
            message= _ "We got to the treasury. It was much easier than we thought...What's this?"
        [/message]

        #TODO modify ai to kill the rider.
        [unit]
            id=Swirh
            name= _ "Swirh"
            side=2
            type=Saurian Ambusher
            x=20
            y=21
            role=treasure_guard
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
        [unit]
            id=Cfir
            name= _ "Cfir"
            side=2
            type=Saurian Skirmisher
            x=20
            y=21
            role=treasure_guard
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
        [unit]
            id=Kfir
            name= _ "Kfir"
            side=2
            type=Saurian Augur
            x=20
            y=21
            role=treasure_guard
            [modifications]
                {TRAIT_DEXTROUS}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
#ifdef HARD
        [unit]
            id=Hrish
            name= _ "Hrish"
            side=2
            type=Saurian Ambusher
            x=20
            y=21
            role=treasure_guard
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
#endif
        [message]
            id=Swirh
            # wmllint: local spelling sssstupid
            message= _ "Sssstupid elves thought the treasury would be unguarded! Guards, slay these intruders!"
        [/message]

        [objectives]
            side=0
            [objective]
                description= _ "New Objective: Transport the treasure with a rider to the signpost"
                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= _ "Turns run out"
                condition=lose
            [/objective]
        [/objectives]

        {HIGHLIGHT_IMAGE 1 22 scenery/signpost.png ()}
        [scroll_to_unit]
            id=Kalenz
        [/scroll_to_unit]
    [/event]

    {TREASURE_CHEST 20 21}

    [event]
        name=last breath
        [filter]
            id=Spahr
        [/filter]
        [message]
            speaker=unit
            message= _ "Aargh! I shall never see the bright moon's face again!"
        [/message]
    [/event]

    [event]
        name=last breath
        first_time_only=no
        [filter]
            role=gold_carrier
        [/filter]
        {TREASURE_CHEST $x1 $y1}
    [/event]

    [event]
        name=moveto
        [filter]
            role=gold_carrier
            x=1
            y=22
        [/filter]

        [remove_unit_overlay]
            x=1
            y=22
            image=items/gold-coins-small.png
        [/remove_unit_overlay]

        [endlevel]
            result=victory
            bonus=yes
        [/endlevel]
    [/event]

    # In case the players wins by defeating both enemy leaders, remove the gold overlay if it's there.
    [event]
        name=enemies defeated
        [store_unit]
            variable=gold_carrier
            [filter]
                role=gold_carrier
            [/filter]
        [/store_unit]
        [if]
            [variable]
                name=gold_carrier.length
                greater_than=0
            [/variable]
            [then]
                [remove_unit_overlay]
                    x=$gold_carrier.x
                    y=$gold_carrier.y
                    image=items/gold-coins-small.png
                [/remove_unit_overlay]
            [/then]
        [/if]
        {CLEAR_VARIABLE gold_carrier}
    [/event]

    [event]
        name=victory
        [message]
            id=Kalenz
            message= _ "We have recovered our gold; it is well."
        [/message]
        [message]
            role=gold_carrier
            message= _ "We have recovered much more than our own treasure. These saurians would seem to have taken up robbery as a vocation!"
        [/message]
        [message]
            id=Spahr
            message= _ "They took all our treasure! Quickly, place ambushers on all trails from here to Wesmere. I will give 500 gold to whoever kills their leader. They must not escape."
        [/message]
        [message]
            id=Kalenz
            #po: "fare" is an archaic English verb meaning to travel or move.
            message= _ "Turnabout is fair play. Now that we've retrieved the gold, let us fare swiftly back to Wesmere. The Saurians will likely be infesting the direct route, so we will detour to the north. "
        [/message]
        #TODO add speech about the returning of the money.
#ifdef MULTIPLAYER
        {LOOT 900 1}
        {LOOT 900 4}
#else
        {LOOT 1800 1}
#endif
    [/event]

    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}

#ifndef MULTIPLAYER
[/scenario]
#else
[/multiplayer]
#endif

#undef PLAYER_GOLD
