#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
#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 4}
    {STARTING_VILLAGES 5 20}

    [story]
        [part]
            story= _ "Elvish scouts found the trail of the saurian war party without difficulty. The way back to the saurians’ treasury was clear..."
            {LOW_BIGMAP}
            {FLIGHT_COMPLETE}
            {TREASURY_STAGE2}
        [/part]
    [/story]
    {LOW_TRACK ( {FLIGHT_COMPLETE} {TREASURY_STAGE2_END} ) }

#define PLAYER_GOLD
#ifdef MULTIPLAYER
    {GOLD 140 120 100}
    {INCOME -2 -2 -2}
    village_gold=1
#else
    {GOLD 300 260 240}
    {INCOME -2 -2 -2}
    village_gold=1
#endif
#enddef

    [side]
        side=1
        {PLAYABLE}
        save_id=Kalenz
        disallow_shuffle=yes

        no_leader=yes
        [unit]
            {KALENZ}
            x=3
            y=19
        [/unit]
        {PLAYER_GOLD}

#ifndef MULTIPLAYER
        [unit]
            {LANDAR}
            x=4
            y=11
        [/unit]
        [unit]
            {CLEODIL}
            x=1
            y=15
        [/unit]
#endif
    [/side]

    # wmllint: skip-side
    {MP_SIDE 2 (
        no_leader=yes
        {PLAYABLE}
        save_id=Landar
        disallow_shuffle=yes
        {PLAYER_GOLD}
        [unit]
            {LANDAR}
            x=4
            y=11
        [/unit]
    )}

    # wmllint: skip-side
    {MP_SIDE 3 (
        no_leader=yes
        {PLAYABLE}
        save_id=Cleodil
        disallow_shuffle=yes
        {PLAYER_GOLD}
        [unit]
            {CLEODIL}
            x=1
            y=15
        [/unit]
    )}

#define SAURIAN_AI
    [ai]
        {AI_NO_SCOUTS}
        {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 with a horse 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=40
            [/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
                    duration=scenario
                    object_id="gold_icon"
                [/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=40
            [/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_object]
            role=gold_carrier
            object_id="gold_icon"
        [/remove_object]

        [endlevel]
            result=victory
#ifdef MULTIPLAYER
            bonus=0.4
#else
            bonus=yes
#endif
        [/endlevel]
    [/event]

    [event]
        name=scenario_end
        [filter_condition]
            [proceed_to_next_scenario]
            [/proceed_to_next_scenario]
        [/filter_condition]
        [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]

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

#undef PLAYER_GOLD
#undef MULTIPLAYER_GOLD
#undef ELVISH_MOUNTED_UNITS
