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

    name= _ "Vengeance"
    next_scenario=10a_Elf_Epilogue

    {SCENARIO_MUSIC nunc_dimittis.ogg}

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

#define SG_DEATHS_LAST_LEVEL
#enddef
    {campaigns/The_South_Guard/utils/sg_deaths.cfg}

    {DEFAULT_SCHEDULE_MORNING}

    {TURNS 10 12 14}
    victory_when_enemies_defeated=no

    {TSG_BIGMAP {JOURNEY_09A_NEW} }

    # The South Guard

    [side]
        side=1
        type=Horseman Commander
        id=Deoran
        name= _ "Deoran"
        profile=portraits/deoran.png
        unrenamable=yes

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

        {GOLD 175 150 125}
        {INCOME 4 2 0}

        fog=no
        shroud=no

        canrecruit=yes
        recruit=Bowman, Spearman, Cavalryman
#ifdef EASY
        {NAMED_GENERIC_UNIT 1 (Javelineer)        14 13 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 14 14 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 15 12 () (_"Westin Guard")}

        {NAMED_GENERIC_UNIT 1 (Spearman)          21 14 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Spearman)          19 10 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Longbowman)        19 12 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Shock Trooper)     19 11 () (_"Westin Guard")}

        {NAMED_GENERIC_UNIT 1 (Spearman)          21 9  () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Lieutenant)        20 11 () (_"Westin Guard")}
#endif
#ifdef NORMAL
        {NAMED_GENERIC_UNIT 1 (Javelineer)        14 13 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 14 14 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 15 12 () (_"Westin Guard")}

        {NAMED_GENERIC_UNIT 1 (Spearman)          21 14 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Spearman)          19 10 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Bowman)            19 12 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 19 11 () (_"Westin Guard")}

        {NAMED_GENERIC_UNIT 1 (Spearman)          21 9  () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Lieutenant)        20 11 () (_"Westin Guard")}
#endif
#ifdef HARD
        {NAMED_GENERIC_UNIT 1 (Javelineer)        14 13 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Spearman)          14 14 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Heavy Infantryman) 15 12 () (_"Westin Guard")}

        {NAMED_GENERIC_UNIT 1 (Spearman)          21 14 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Spearman)          19 10 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Bowman)            19 12 () (_"Westin Guard")}
        {NAMED_GENERIC_UNIT 1 (Lieutenant)        19 11 () (_"Westin Guard")}
#endif
    [/side]

    {STARTING_VILLAGES 1 15}

    # The Enraged Elves

    [side]
        side=2
        type=Elvish Avenger
        id=Eltenmir
        name= _ "Eltenmir"

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

        [status]
            uncovered=yes
        [/status]

        gold=0
        income=0

        canrecruit=no
        [ai]
            passive_leader=yes
            aggression=0.0
            caution=1.0
            [goal]
                name=target
                [criteria]
                    id=Ethiliel
                [/criteria]
                value=2
            [/goal]
        [/ai]
        [ai]
            passive_leader=yes
            time_of_day=dusk,first_watch,second_watch
            aggression=0.9
            caution=0
            grouping=no
        [/ai]
        {FLAG_VARIANT wood-elvish}
    [/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=Deoran
            message= _ "Finally, we have returned home! The undead and bandits are both defeated and it seems that the townsfolk have already begun to rebuild. Perhaps now there will be peace in Westin. You have our thanks, Lady Ethiliel. We could not have accomplished this feat without you."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Yes... you have done a great deed in destroying the undead, but it was others of your kind that brought about this evil to begin with. Nevertheless, I see now that not all humans are alike and that you, too, are capable of courage and loyalty. About the trouble with my people, I will see what I can do—"
        [/message]
        [message]
            speaker=narrator
            message= _ "Help!"
            image=none
        [/message]

        [scroll_to_unit]
            id=Eltenmir
        [/scroll_to_unit]

        [message]
            speaker=narrator
            message= _ "Help!"
            image=none
        [/message]
        [move_unit_fake]
            type=Peasant
            side=1
            x=11,12,13,14,15,16
            y=9,8,9,8,9,8
        [/move_unit_fake]
        [unit]
            type=Peasant
            id=Poor Farmer
            name= _ "Poor Farmer"
            side=1
            x=16
            y=8
        [/unit]
        [move_unit]
            id=Eltenmir
            to_x,to_y=15,9
        [/move_unit]
        [message]
            speaker=Eltenmir
            message= _ "You will pay for Mebrin’s death!"
        [/message]
        [message]
            speaker=Poor Farmer
            message= _ "I am just a farmer! I never killed anyone!"
        [/message]
        [message]
            speaker=Eltenmir
            message= _ "You lie! All humans are the same! Your people kidnapped and murdered our wisest sage! Now you will pay!"
        [/message]
        [color_adjust]
            red=255
            green=0
            blue=0
        [/color_adjust]
        [delay]
            time=250
        [/delay]
        [kill]
            id=Poor Farmer
            fire_event=no
            animate=yes
        [/kill]
        [color_adjust]
            red=0
            green=0
            blue=0
        [/color_adjust]
        [message]
            speaker=Sir Gerrick
            message= _ "He just killed that innocent farmer! We must stop him!"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Stop, Eltenmir! These humans are not the ones who harmed Mebrin. They have helped me obtain vengeance on the ones responsible for the horrible deed and have thus absolved themselves of any wrongdoing. No more innocent blood needs to be shed."
        [/message]
        [message]
            speaker=Eltenmir
            message= _ "I can hardly believe my ears. You have always been too soft, Ethiliel, but to side with the humans? All humans are scum and vermin! Just as they have felled our trees in the past, they have destroyed our homes, murdered our people, and killed Mebrin!"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Mebrin was my master, Eltenmir! It is <i>I</i> who grieves the most! I have spent countless, sleepless nights thinking about his death and missing him so dearly that my heart never ceases to ache. You know how I must feel about losing one that I cherished so. Still... still, even I recognize that these humans are not the ones to blame."
        [/message]
        [message]
            speaker=Eltenmir
            message= _ "It matters not. The humans have spilled the blood of our people, and so theirs will be spilled in turn. If you stand against us, Ethiliel, we will attack you too. You had best stay out of this."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "And what do you think Ithelden will have to say about that?"
        [/message]

        [delay]
            time=1000
        [/delay]

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

        [message]
            speaker=Ethiliel
            message= _ "Eltenmir, answer me! You know you do not have the authority to be attacking the humans like this, much less me! Eltenmir!"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "..."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Ever the stubborn one. Deoran, we will not be able to fight them for very long. I will send a messenger to Ithelden and hope he gets here in time before the city is overrun."
        [/message]
        [message]
            speaker=Deoran
            message= _ "Are you sure that they’ll listen to Ithelden? Or that he’ll even try to stop them?"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Perhaps not, but we have no other hope right now. We must survive until Ithelden arrives!"
        [/message]

        [move_unit_fake]
            type=Elvish Scout
            side=1
            x=22,21,20,19,18,17,16,15,14,13,12,11,10,9
            y=8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,7 ,7 ,6 ,6
        [/move_unit_fake]

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

#ifdef EASY
        {LOYAL_UNIT 2 (Elvish Fighter) 7 12}
        {LOYAL_UNIT 2 (Elvish Archer)  8 9}
        {LOYAL_UNIT 2 (Elvish Ranger)  6 8}
        {LOYAL_UNIT 2 (Elvish Shaman)   4 7}
        {LOYAL_UNIT 2 (Elvish Hero)    9 9}
        {LOYAL_UNIT 2 (Elvish Scout)  2 8}
#endif
#ifdef NORMAL
        {LOYAL_UNIT 2 (Elvish Fighter) 9 8}
        {LOYAL_UNIT 2 (Elvish Captain) 7 12}
        {LOYAL_UNIT 2 (Elvish Archer)  8 9}
        {LOYAL_UNIT 2 (Elvish Ranger)  6 8}
        {LOYAL_UNIT 2 (Elvish Druid)   4 7}
        {LOYAL_UNIT 2 (Elvish Hero)    9 9}
        {LOYAL_UNIT 2 (Elvish Rider)  2 8}
#endif
#ifdef HARD
        {LOYAL_UNIT 2 (Elvish Fighter) 11 11}
        {LOYAL_UNIT 2 (Elvish Fighter) 9 8}
        {LOYAL_UNIT 2 (Elvish Captain) 7 12}
        {LOYAL_UNIT 2 (Elvish Druid)   3 11}
        {LOYAL_UNIT 2 (Elvish Marksman)  8 9}
        {LOYAL_UNIT 2 (Elvish Ranger)  6 8}
        {LOYAL_UNIT 2 (Elvish Hero)    9 9}
        {LOYAL_UNIT 2 (Elvish Rider)  2 8}
#endif

        [objectives]
            side=1
            [objective]
                description= _ "Survive until end of turns"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Deoran"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Ethiliel"
                condition=lose
            [/objective]

            {IS_LAST_SCENARIO}
        [/objectives]
    [/event]

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

#ifdef EASY
        [set_variable]
            name=how_many_elves
            rand=1..18
        [/set_variable]
#endif
#ifdef NORMAL
        [set_variable]
            name=how_many_elves
            rand=1..21
        [/set_variable]
#endif
#ifdef HARD
        [set_variable]
            name=how_many_elves
            rand=1..24
        [/set_variable]
#endif

        [repeat]
            times=$(max((round($how_many_elves/10)),1))
            [do]
#ifdef EASY
                [set_variable]
                    name=unit_type
                    rand=Elvish Fighter,Elvish Archer,Elvish Ranger,Elvish Shaman,Elvish Druid,Elvish Hero,Elvish Marksman,Elvish Rider,Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Fighter,Elvish Archer,Elvish Shaman
                [/set_variable]
#endif
#ifdef NORMAL
                [set_variable]
                    name=unit_type
                    rand=Elvish Fighter,Elvish Archer,Elvish Ranger,Elvish Shaman,Elvish Druid,Elvish Hero,Elvish Marksman,Elvish Rider,Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Fighter,Elvish Archer,Elvish Shaman
                [/set_variable]
#endif
#ifdef HARD
                [set_variable]
                    name=unit_type
                    rand=Elvish Fighter,Elvish Archer,Elvish Ranger,Elvish Shaman,Elvish Druid,Elvish Hero,Elvish Marksman,Elvish Rider,Elvish Fighter,Elvish Archer,Elvish Shaman
                [/set_variable]
#endif
                {GENERIC_UNIT 2 $unit_type 2 9}
            [/do]
        [/repeat]

        [fire_event]
            name=elf_rise
        [/fire_event]

        {CLEAR_VARIABLE how_many_elves,unit_type}
    [/event]

    [event]
        name=elf_rise
        first_time_only=yes

        [message]
            side=2
            [not]
                x,y=$x1,$y1
            [/not]
            message= _ "For every one of us you strike down, more will rise!"
        [/message]
    [/event]

    [event]
        name=time over

        [scroll_to]
            x,y=2,7
        [/scroll_to]

        [unit]
            side=1
            type=Elvish Scout
            x,y=2,7
            animate=yes
        [/unit]
        [unit]
            side=1
            type=Elvish Marshal
            id=Ithelden
            name= _ "Ithelden"
            x,y=3,7
            canrecruit=yes
            animate=yes
        [/unit]

        [message]
            speaker=Ithelden
            message= _ "Eltenmir! What in the world is going on here?"
        [/message]

        [unit]
            side=2
            type=Elvish Avenger
            id=Eltenmir
            name= _ "Eltenmir"
            x,y=5,8
            canrecruit=yes
            animate=yes
            [status]
                uncovered=yes
            [/status]
        [/unit]

        [message]
            speaker=Eltenmir
            message= _ "We are merely giving these human pigs what they deserve. If they wish to shed the blood of our people, we will do the same to them."
        [/message]
        [message]
            speaker=Ithelden
            message= _ "I know you must be grieving over Mebrin’s death as well, but surely you see that nothing good can come of doing this. Especially not from attacking Ethiliel!"
        [/message]
        [message]
            speaker=Eltenmir
            message= _ "Then suggest something, for we must have some form of retribution!"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "The ones who <i>effectively</i> killed Mebrin are dead. I saw to that personally. We should have no more qualms with the remaining humans here."
        [/message]
        [message]
            speaker=Eltenmir
            message= _ "As if we would be satisfied by something like that! Even if what you say is true, the death of a few bugs in the woods is hardly an equal trade for one of our greatest leaders!"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "But the answer cannot be more death and destruction..."
        [/message]
        [message]
            speaker=Ithelden
            message= _ "No, it might not be, but Eltenmir is right. We cannot sit idly by and forget this atrocity either. If you wish to prevent a slaughter here, we will have to come up with some other form of resolution. Regardless, you should come and discuss the issue with us, Ethiliel. You no longer belong with the humans."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "I... I suppose you are right. I will come."
        [/message]
        {MOVE_UNIT id=Ethiliel 6 8}
        [delay]
            time=1500
        [/delay]
        [sound]
            name=magic-faeriefire.ogg
        [/sound]
        [delay]
            time=1500
        [/delay]
        [kill]
            id=Ethiliel,Ithelden,Eltenmir
            animate=no
            fire_event=no
        [/kill]

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

    [event]
        name=attack end
        [filter]
            side=1
        [/filter]

        [message]
            speaker=Ethiliel
            message= _ "Be careful, Deoran. The more blood you spill, the more my people will be enraged. More will surely come to attack."
        [/message]
    [/event]
[/scenario]
