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

#ifdef HARD
    id=05_The_Saurian_Treasury_HARD
    next_scenario=06_Acquaintance_in_Need_HARD
#endif
#ifdef EASY
    id=05_The_Saurian_Treasury_EASY
    next_scenario=06_Acquaintance_in_Need_EASY
#endif
#ifdef NORMAL
    id=05_The_Saurian_Treasury_NORMAL
    next_scenario=06_Acquaintance_in_Need_NORMAL
#endif

#else
    [scenario]
        id=05_The_Saurian_Treasury
        next_scenario=06_Acquaintance_in_Need
#endif

        experience_modifier=100

#define TREASURY_LOCATION
        20,21#enddef

        [label]
            text= _ "Saurian Treasury"
            x,y={TREASURY_LOCATION}
        [/label]

        name= _ "The Saurian Treasury"
        {LOW_MAP Saurgrath.map}
        {LOW_MASK 05_The_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}
        {EXTRA_SCENARIO_MUSIC knolls.ogg}

        {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
#define MULTIPLAYER_GOLD
    {GOLD 100 80 65}
#enddef

        [side]
            {KALENZ}
            # wmllint: recognize Kalenz
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            x=3
            y=19
            fog=no
#ifndef MULTIPLAYER
            {PLAYER_GOLD}
            [unit]
                {LANDAR}
                extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
                x=4
                y=11
                # wmllint: recognize Landar
            [/unit]
            [unit]
                {CLEODIL}
                extra_recruit=Elvish Shaman, Elvish Scout, Wose
                x=1
                y=15
                # wmllint: recognize Cleodil
            [/unit]
#else
            {MULTIPLAYER_GOLD}
#endif
        [/side]

#define SAURIAN_AI
    {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]
            name=protect_unit
            [criteria]
                role=guardian
            [/criteria]
            value=10.0
            protect_radius=6
        [/goal]
        [goal]
            [criteria]
                type=Elvish Scout, Elvish Rider, Elvish Outrider
            [/criteria]
            value=5.0
        [/goal]
        [goal]
            [criteria]
                role=gold_carrier
            [/criteria]
            value=10.0
        [/goal]
    [/ai]
#enddef

        [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"
            [unit]
                type=Saurian Flanker
                x,y={TREASURY_LOCATION}
                role=guardian
                max_moves=0
            [/unit]
            {SAURIAN_SETUP}
            {SAURIAN_AI}
#ifdef EASY
            recruit=Saurian Skirmisher, Saurian Augur
#else
            recruit=Saurian Skirmisher, Saurian Augur, Saurian Ambusher
#endif
        [/side]

        [side]
            side=3
            allow_player=no
            controller=ai
            type=Saurian Ambusher
            id=Spahr
            name= _ "Spahr"
            canrecruit=yes
            x=26
            y=2
            {GOLD 180 240 320}
            {INCOME 4 8 12}
            team_name=Saurians
            user_team_name= _ "Enemies"
            {SAURIAN_SETUP}
            {SAURIAN_AI}
#ifdef EASY
            recruit=Saurian Skirmisher, Saurian Augur
#else
            recruit=Saurian Skirmisher, Saurian Augur, Saurian Ambusher
#endif
        [/side]

#undef SAURIAN_AI

#ifdef MULTIPLAYER
        [side]
            side=4
            fog=no
            {MULTIPLAYER_GOLD}
            recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            {LANDAR}
            # wmllint: recognize Landar
            x=4
            y=11
        [/side]
        [side]
            side=5
            fog=no
            {MULTIPLAYER_GOLD}
            recruit=Elvish Shaman, Elvish Scout, Wose
            {CLEODIL}
            x=1
            y=15
        [/side]
#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]

                {TURNS_RUN_OUT}

                [gold_carryover]
                    bonus=yes
                    carryover_percentage=80
                [/gold_carryover]
            [/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]
            #TODO get rid of magic number
            {HIGHLIGHT_IMAGE 20 21 items/chest.png ()}
        [/event]

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

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

        [object]
            image=items/chest.png
            name= _ "Treasure Chest"
            description= _ "The bearer of this chest is slowed in movement and attack by the same effect as the slow weapon special. Slow halves the damage caused by attacks and the movement cost for a slowed unit is doubled. A unit that is slowed will feature a snail icon in its sidebar information when it is selected."
            [effect]
                apply_to=status
                add=slowed
                unit_type=Elvish Scout, Elvish Outrider, Elvish Rider
            [/effect]
            duration=level
            [filter]
                x,y={POSITION}
            [/filter]
            [then]
                [remove_item]
                    image=items/chest.png
                    x,y=$x1,$y1
                [/remove_item]
                [role]
                    x,y={POSITION}
                    role=gold_carrier
                [/role]
                [unit_overlay]
                    x,y={POSITION}
                    image=items/gold-coins-small.png
                [/unit_overlay]
            [/then]
        [/object]
    [/event]
#enddef

        #Slow down the gold carrier every turn.
        [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={TREASURY_LOCATION}
            [/filter]

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

            [message]
                speaker=unit
                message= _ "We have reached the treasury. Guard me while I bring the pillage home."
            [/message]

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

                {TURNS_RUN_OUT}

                [gold_carryover]
                    bonus=yes
                    carryover_percentage=80
                [/gold_carryover]
            [/objectives]

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

        {TREASURE_CHEST {TREASURY_LOCATION}}

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

        [event]
            name=victory
            [store_unit]
                [filter]
                    role=gold_carrier
                [/filter]
                variable=gold_carrier
                kill=no
            [/store_unit]
            [remove_unit_overlay]
                x=$gold_carrier.x
                y=$gold_carrier.y
                image=items/gold-coins-small.png
            [/remove_unit_overlay]
            {CLEAR_VARIABLE gold_carrier}
            [message]
                id=Kalenz
                message= _ "We have recovered our gold; it is well."
            [/message]
            [if]
                [not]
                    [have_unit]
                        role=gold_carrier
                    [/have_unit]
                [/not]
                [then]
                    [if]
                        [have_unit]
                            #wmllint: recognize Huraldur
                            id=Huraldur
                        [/have_unit]
                        [then]
                            [role]
                                id=Huraldur
                                role=gold_carrier
                            [/role]
                        [/then]
                        [else]
                            [role]
                                id=Landar
                                role=gold_carrier
                            [/role]
                        [/else]
                    [/if]
                [/then]
            [/if]
            [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 and bring the gold back as Cleodil wishes. The Saurians will likely be infesting the direct route, so we will detour to the north."
            [/message]
            [message]
                id=Landar
                message= _ "But Kalenz, this is a boon unlooked for! With the surplus gold we could take the war immediately to the Orcs. We could come down upon them like thunder while they believe us still reeling from their invasion!"
            [/message]
            [message]
                id=Cleodil
                message= _ "But the Ka’lian’s gold is the Ka’lian’s. Would you have us divide our forces, some to return it to them while others attempt your thunder-stroke?"
            [/message]
            [message]
                id=Kalenz
                message= _ "Cleodil’s doubt is wise. Only a foolish commander divides his forces in the presence of superior numbers; to do so is to invite defeat in detail."
            [/message]
            [message]
                id=Cleodil
                message= _ "Landar, thoughts that brew in hot blood are seldom well-found."
            [/message]
            [message]
                id=Landar
                message= _ "It... is so. Again you speak wisdom. Very well; to the Ka’lian!"
            [/message]
#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
#undef MULTIPLAYER_GOLD
