#textdomain wesnoth-tsg
[scenario]
    id=9a_Vengeance

    name= _ "Vengeance"
    next_scenario=10a_Elf_Epilogue

    {SCENARIO_MUSIC nunc_dimittis.ogg}
    {EXTRA_SCENARIO_MUSIC suspense.ogg}

    map_data="{campaigns/The_South_Guard/maps/9a_Vengeance.map}"

    {MORNING}
    {AFTERNOON}
    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}
    {DAWN}

    turns=-1
    victory_when_enemies_defeated=no

    # The South Guard

    [side]
        side=1
        type=Horseman Commander
        id=Deoran
        name= _ "Deoran"
        unrenamable=yes

        team_name=South_Guard
        user_team_name=_"South Guard"
        controller=human
        {CUSTOM_SG_FLAG}

        {GOLD 125 100 80}
        {INCOME 4 2 0}

        fog=no
        shroud=no

        canrecruit=yes
        recruit=Bowman, Spearman, Cavalryman

        {NAMED_GENERIC_UNIT 1 (Javelineer)        22 12 () (_"Westin Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 19 14 () (_"Westin Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 17 15 () (_"Westin Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 17 17 () (_"Westin Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 1 (Spearman)          16 19 () (_"Westin Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 1 (Spearman)          15 21 () (_"Westin Guard")} {GUARDIAN}
    [/side]

    {STARTING_VILLAGES 1 15}

    # The Enraged Elves

    [side]
        side=2
        type=Elvish Marshal
        id=Ithelden
        name= _ "Ithelden"

        team_name=The_Enraged Elves
        user_team_name=_"Enraged Elves"
        controller=ai

        {GOLD 125 100 80}
        {INCOME 4 2 0}

        canrecruit=no
        [ai]
            passive_leader=yes
            aggression=0.0
            caution=1.0
            [target]
                id=Ethiliel
                value=2.0
            [/target]
        [/ai]
        [ai]
            passive_leader=yes
            time_of_day=dusk,first_watch,second_watch
            aggression=1.0
            caution=0
            grouping=no
        [/ai]
    [/side]

    [event]
        name=prestart

        [disallow_recruit]
            side=1
            type=Elvish Fighter, Elvish Shaman
        [/disallow_recruit]
    [/event]

    [event]
        name=start

        [recall]
            id=Sir Gerrick
        [/recall]
        [recall]
            id=Ethiliel
        [/recall]
        [recall]
            id=Minister Hylas
        [/recall]

        [message]
            speaker=Sir Gerrick
            message= _ "Commander! I took your message to the council, and your deeds have pleased them. Are the undead finally gone from our lands?"
        [/message]
        [message]
            speaker=Deoran
            message= _ "The undead are gone! Perhaps now there will be peace for a time in Westin. You have our thanks Lady Ethiliel."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Though the undead are vanquished, they have brought us much sorrow. Deoran, your people have restored their honor. Let us part in peace."
        [/message]
        [message]
            speaker=Deoran
            message= _ "Indeed. Neither the bandits nor the undead will trouble us for some time. We will tend our wounds and you yours."
        [/message]
        [message]
            speaker=narrator
            message= _ "Help!"
            image=wesnoth-icon.png
        [/message]

        [scroll_to_unit]
            id=Ithelden
        [/scroll_to_unit]

        [message]
            speaker=narrator
            message= _ "Help!"
            image=wesnoth-icon.png
        [/message]
        [move_unit_fake]
            type=Peasant
            side=1
            x= 1, 2, 2, 2, 3, 4
            y=11,11,12,13,14, 14
        [/move_unit_fake]
        [unit]
            type=Peasant
            id=Poor Farmer
            name= _ "Poor Farmer"
            side=1
            x=4
            y=14
        [/unit]
        [message]
            speaker=Ithelden
            message= _ "You must pay for killing Mebrin!"
        [/message]
        [message]
            speaker=Poor Farmer
            message= _ "I am just a farmer! What did I do?!"
        [/message]
        [message]
            speaker=Ithelden
            message= _ "What did you do?! Your people kidnapped and murdered our greatest leader! And now you will pay!"
        [/message]
        [colour_adjust]
            red=255
            green=0
            blue=0
        [/colour_adjust]
        [sound]
            name=human-die-1.ogg
        [/sound]
        [colour_adjust]
            red=0
            green=0
            blue=0
        [/colour_adjust]
        [kill]
            id=Poor Farmer
            fire_event=no
        [/kill]
        [message]
            speaker=Sir Gerrick
            message= _ "He just killed that innocent farmer! We must stop him!"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Stop, Ithelden! I have traveled with these humans, and they are not the ones who harmed Mebrin. They are our allies!"
        [/message]
        [message]
            speaker=Ithelden
            message= _ "You too, Ethiliel? All these humans are the same! They fell trees to till the earth; now they have felled our leader! We cannot brook such deeds! You will die with them!"
        [/message]

        [music]
            name=the_dangerous_symphony.ogg
            immediate=yes
            append=no
        [/music]
        [music]
            name=the_city_falls.ogg
            append=yes
        [/music]
        [music]
            name=vengeful.ogg
            append=yes
        [/music]

        {NAMED_LOYAL_UNIT 2 (Elvish Fighter) 3 17 () (_"Disciple of Mebrin")}
        {NAMED_LOYAL_UNIT 2 (Elvish Fighter) 7 15 ()  (_"Disciple of Mebrin")}
        {NAMED_LOYAL_UNIT 2 (Elvish Druid)   6 19 () (_"Disciple of Mebrin")}
        {NAMED_LOYAL_UNIT 2 (Elvish Ranger)  8 15 () (_"Disciple of Mebrin")}
        {NAMED_LOYAL_UNIT 2 (Elvish Druid)   4 22 () (_"Disciple of Mebrin")}
        {NAMED_LOYAL_UNIT 2 (Elvish Hero)    6 23 () (_"Disciple of Mebrin")}
        {NAMED_LOYAL_UNIT 2 (Elvish Rider)  11 13 () (_"Disciple of Mebrin")}

        [kill]
            id=Ithelden
            animate=no
            fire_event=no
        [/kill]

        [message]
            speaker=Ethiliel
            message= _ "We won't be able to hold them off for long. I should go reason with them!"
        [/message]
        [message]
            speaker=Deoran
            message= _ "Are you sure that the elves will greet you any more kindly than they have met us? After all, you did lead us into the forests..."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Perhaps not, but it is your only hope. I must reach Ithelden!"
        [/message]

        {SET_LABEL 6 15 _"Ithelden's base"}
        {HIGHLIGHT_IMAGE 6 15 items/gohere.png ()}

        [objectives]
            side=1
            [objective]
                description= _ "Send Ethiliel to the Great Tree and parley with Ithelden"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Deoran"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Ethiliel"
                condition=lose
            [/objective]
        [/objectives]
    [/event]

    [event]
        name=die
        [filter]
            side=2
        [/filter]
        first_time_only=no

        [set_variable]
            name=how_many_elves
            random=1..6
        [/set_variable]
        [set_variable]
            name=number_of_elves
            value=1
        [/set_variable]

        [while]
            [variable]
                name=number_of_elves
                less_than=$how_many_elves
            [/variable]
            [do]
                [set_variable]
                    name=unit_type
                    random=Elvish Fighter,Elvish Archer,Elvish Ranger,Elvish Shaman,Elvish Druid,Elvish Hero,Elvish Marksman,Elvish Rider,Elvish Fighter,Elvish Archer,Elvish Shaman
                [/set_variable]
                [unit]
                    type=$unit_type
                    name= _ "Disciple of Mebrin"
                    side=2
                    x,y=1,12
                [/unit]
                [set_variable]
                    name=number_of_elves
                    add=1
                [/set_variable]
            [/do]
        [/while]

        [message]
            name= _ "Disciple of Mebrin"
            message= _ "For every one of us you strike down, more will rise!"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Deoran
        [/filter]
        [message]
            speaker=unit
            image=portraits/deoran-sad.png
            message= _ "I have failed my kingdom and duty..."
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Sir Gerrick
        [/filter]
        [message]
            speaker=unit
            message= _ "I have given my all for my kingdom! Avenge me, Deoran!"
        [/message]
    [/event]

    [event]
        name=die

        [filter]
            id=Ethiliel
        [/filter]

        [message]
            speaker=Minister Hylas
            message= _ "Ithelden's elves have killed Ethiliel! Now we have no chance to come to an agreement with them. A war with the Elves is imminent."
        [/message]
        [message]
            speaker=Deoran
            message= _ "We are far away from Weldyn. We'll surely all be killed long before any reinforcements arrive."
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=moveto

        [filter]
            id=Ethiliel
            x=6
            y=15
        [/filter]

        [endlevel]
            result=victory
            carryover_report=no
            save=no
            linger_mode=no
        [/endlevel]
    [/event]
[/scenario]
