#textdomain wesnoth-low
[scenario]
    id=05_The_Saurian_Treasury
    next_scenario=06_Acquaintance_in_Need

    random_start_time=no
    allow_new_game=no
    force_lock_settings=yes

    experience_modifier=100

#define TREASURY_LOCATION
    20,21#enddef

#define ELVISH_MOUNTED_UNITS
    Elvish Scout,Elvish Rider,Elvish Outrider,Elvish Horse Archer
#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
#ifdef MULTIPLAYER
    {GOLD 100 80 65}
    {INCOME -2 -2 -2}
    village_gold=1
#else
    {GOLD 300 240 195}
    {INCOME -2 -2 -2}
    village_gold=1
#endif
#enddef

    [side]
        side=1
        fog=no
        {PLAYABLE}
        save_id=Kalenz

        no_leader=yes
        [unit]
            {KALENZ}
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            x=3
            y=19
        [/unit]
        {PLAYER_GOLD}

#ifndef MULTIPLAYER
        [unit]
            {LANDAR}
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            x=4
            y=11
        [/unit]
        [unit]
            {CLEODIL}
            extra_recruit=Elvish Shaman, Elvish Scout, Wose
            x=1
            y=15
        [/unit]
#endif
    [/side]

    [side]
        side=2
        no_leader=yes
#ifdef MULTIPLAYER
        {PLAYABLE}
        save_id=Landar
        {PLAYER_GOLD}
        fog=no
        [unit]
            {LANDAR}
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            x=4
            y=11
        [/unit]
#else
        hidden=yes
        controller=null
        allow_player=no
#endif
    [/side]

    [side]
        side=3
        no_leader=yes
#ifdef MULTIPLAYER
        {PLAYABLE}
        save_id=Cleodil
        fog=no
        {PLAYER_GOLD}
        [unit]
            {CLEODIL}
            extra_recruit=Elvish Shaman, Elvish Scout, Wose
            x=1
            y=15
        [/unit]
#else
        hidden=yes
        controller=null
        allow_player=no
#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_MOUNTED_UNITS}
            [/criteria]
            value=5.0
        [/goal]
        [goal]
            [criteria]
                role=gold_carrier
            [/criteria]
            value=10.0
        [/goal]
    [/ai]
#enddef

    [side]
        side=4
        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=5
        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

    [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]
            id=Arkildur
            x=5
            y=11
        [/recall]

        [recall]
            id=scout
            x=4
            y=10
        [/recall]

        [recall]
            id=Tameril-Isimeril
            x=2
            y=14
        [/recall]

        [recall]
            id=Laril
            x=2
            y=15
        [/recall]

        [recall]
            id=Huraldur
            x=4
            y=19
        [/recall]

        [recall]
            id=Anduilas
            x=4
            y=18
        [/recall]
    [/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_MOUNTED_UNITS}
        [/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
                [filter]
                    type={ELVISH_MOUNTED_UNITS}
                [/filter]
            [/effect]
            duration=scenario
            [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}
            type={ELVISH_MOUNTED_UNITS}
        [/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]
            role=gold_carrier
            image=items/gold-coins-small.png
        [/remove_unit_overlay]

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

    [event]
        name=victory
        [remove_unit_overlay]
            role=gold_carrier
            image=items/gold-coins-small.png
        [/remove_unit_overlay]
        [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]
                        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 600 1}
        {LOOT 600 2}
        {LOOT 600 3}
#else
        {LOOT 1800 1}
#endif
    [/event]

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

#undef PLAYER_GOLD
#undef MULTIPLAYER_GOLD
#undef ELVISH_MOUNTED_UNITS
