#textdomain wesnoth-httt
[scenario]
    id=15_The_Lost_General
    name= _ "The Lost General"
    map_data="{campaigns/Heir_To_The_Throne/maps/15_The_Lost_General.map}"
    {SCENARIO_MUSIC "the_deep_path.ogg"}
    {EXTRA_SCENARIO_MUSIC "knalgan_theme.ogg"}
    {TURNS 64 60 54}

    {UNDERGROUND}

    next_scenario=16_Hasty_Alliance

    {BIGMAP_THE_LOST_GENERAL}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
    [/event]

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad.png
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Rebels"
        controller=human
        {GOLD 350 250 100}
        shroud=yes
        {FLAG_VARIANT long}
    [/side]

    [side]
        id=Geldar
        name= _ "Geldar"
        type=Dwarvish Lord
        side=2
        canrecruit=yes
        recruit=Dwarvish Fighter
        gold=150
        team_name=elves
        user_team_name=_"Rebels"
        {FLAG_VARIANT knalgan}
    [/side]

    [side]
        id=Brugg
        name= _ "Brugg"
        type=Troll Warrior
        side=3
        canrecruit=yes
        recruit=Orcish Warrior,Wolf Rider,Troll,Troll Whelp,Troll Rocklobber,Goblin Pillager,Orcish Assassin,Orcish Crossbowman
        {GOLD 290 350 410}
        [ai]
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        team_name=evil
        user_team_name=_"Evil"
    [/side]

    [side]
        id=Lionel
        name= _ "Lionel"
        type=Death Knight
        side=4
        canrecruit=yes
        recruit=Skeleton,Ghost,Revenant,Skeleton Archer,Bone Shooter
        {GOLD 240 300 360}
        [ai]
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        team_name=evil
        user_team_name=_"Evil"
        {FLAG_VARIANT undead}
    [/side]

    {PLACE_IMAGE scenery/signpost.png 27 22}
    {PLACE_IMAGE scenery/rubble.png 28 25}
    {PLACE_IMAGE scenery/rubble.png 26 24}
    {PLACE_IMAGE scenery/rubble.png 27 24}

    {PLACE_IMAGE scenery/whirlpool.png 13 22}
    {PLACE_IMAGE scenery/whirlpool.png 7 23}

    [event]
        name=start
        [recall]
            id=Delfador
        [/recall]
        [recall]
            id=Kalenz
        [/recall]
        [message]
            speaker=Delfador
            message= _ "We are now in the main dwarvish caverns."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Underground roads once led to the different parts of the complex, but now everything lies in ruins."
        [/message]
        [allow_recruit]
            side=1
            type=Dwarvish Fighter,Dwarvish Thunderer
        [/allow_recruit]
    [/event]

    [event]
        name=moveto
        [filter]
            x=27
            y=22
            side=1
        [/filter]
        [message]
            speaker=narrator
            image="scenery/signpost.png"
            message= _ "The sign says ‘Guest quarters’."
        [/message]
        [allow_undo][/allow_undo]
    [/event]

    [event]
        name=moveto
        [filter]
            x=17
            y=24
            side=1
        [/filter]

        {NAMED_LOYAL_UNIT 2 (Dwarvish Fighter) 17 24 (Burlin) ( _ "Burlin")}
        # wmllint: recognize Burlin

        [message]
            speaker=Burlin
            message= _ "My uncle’s family drowned after the orcs flooded that cavern..."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            x=13
            y=22
            side=1
            race=merman
        [/filter]
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "A hidden whirlpool sucks you down into a subterranean current!"
        [/message]
        {PLACE_IMAGE items/bones.png 2 22}
        {PLACE_IMAGE items/bones.png 4 21}
        [unit]
            id=Ulfdain
            name= _ "Ulfdain"
            type=Dwarvish Ulfserker
            side=2
            x,y=2,21
            random_traits=no
            unrenamable=yes

            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        # wmllint: recognize Ulfdain
        [teleport]
            [filter]
                x,y=$x1,$y1
            [/filter]
            x,y=6,23
        [/teleport]
        [scroll_to]
            x,y=6,23
        [/scroll_to]
        [remove_shroud]
            side=1
            x=2-4
            y=21-24
        [/remove_shroud]
        [redraw]
            side=1
        [/redraw]
        [message]
            speaker=Ulfdain
            message= _ "What’s this, more trolls? Aye, come to papa, little whelps."
        [/message]
        [message]
            x,y=6,23
            message= _ "Hello? Who is here?"
        [/message]
        [message]
            speaker=Ulfdain
            message= _ "What in the world are you? Some sort o’ monster’s appendage set tae lure me down to be yer watery meal, eh?"
        [/message]
        [message]
            x,y=6,23
            message= _ "I am of the merfolk, dweller of the vast oceans! Do not ask me what I am doing in a cave. My lord can be somewhat eccentric. We are fighting at the side of your fellow cave-dwellers to drive back the orcs and trolls."
        [/message]
        [message]
            speaker=Ulfdain
            # wmllint: directory spelling mer-mahn
            message= _ "(sniffs) A mer-mahn. Never heard of it. I doubt yer as tasty as my friends here."
        [/message]
        [message]
            x,y=6,23
            message= _ "Why are you down here? Are those... troll carcasses?"
        [/message]
        [message]
            speaker=Ulfdain
            message= _ "I was brawlin’ with these wee pups here defending my outpost. We got a little carried away, fell in the water, and were sucked down intae this grotto."
        [/message]
        [message]
            x,y=6,23
            message= _ "How long have you been here?"
        [/message]
        [message]
            speaker=Ulfdain
            message= _ "Och, several days at least. The troll meat is starting to stink, and I’m a little ravenous, if ye catch my drift. Canna’ swim past that current, and no’ for lack o’ tryin’."
        [/message]
        [message]
            x,y=6,23
            message= _ "I will rescue you. Hold onto my shoulders, sir dwarf."
        [/message]
        [message]
            speaker=Ulfdain
            message= _ "Thanks. Nae need to wait around here. Let’s go."
        [/message]
        [store_unit]
            [filter]
                id=Ulfdain
            [/filter]

            kill=yes
            variable=stored_Ulfdain
        [/store_unit]
    [/event]

    [event]
        name=moveto
        [filter]
            x=7
            y=23
            side=1
            race=merman
        [/filter]
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "Better prepared this time to fight the current, you eventually manage to emerge from the whirlpool."
        [/message]
        [teleport]
            [filter]
                x,y=$x1,$y1
            [/filter]
            x,y=13,22
        [/teleport]
        {VARIABLE stored_Ulfdain.x 14}
        {VARIABLE stored_Ulfdain.y 22}
        {VARIABLE stored_Ulfdain.side 1}
        [unstore_unit]
            variable=stored_Ulfdain
            find_vacant=yes
        [/unstore_unit]
        [place_shroud]
            side=1
            x= 2-7 , 7-8
            y=21-24,22-24
        [/place_shroud]
        [message]
            speaker=Ulfdain
            message= _ "Well, mer-mahn, we made it. I will fight for yer lord. He sounds like a brave fellow."
        [/message]
        {CLEAR_VARIABLE stored_Ulfdain}
    [/event]

    [event]
        name=moveto
        [filter]
            x=22-25
            y=1-23
            side=1
        [/filter]
        [message]
            speaker=unit
            message= _ "These passages seem to have been used recently."
        [/message]
        [allow_undo][/allow_undo]
    [/event]

    [event]
        name=moveto
        [filter]
            x=11-19
            y=10-16
            side=1
        [/filter]
        [remove_shroud]
            side=1
            x=14-16,12-18,10-19,12-18
            y=10,   11,   12-14,15
        [/remove_shroud]
        [redraw]
        [/redraw]

        #
        # For some reason, the scroll_to tag isn't working.
        # If anyone can fix it, please do.
        #

        [scroll_to]
            x,y=15,13
        [/scroll_to]
        [delay]
            time=1500
        [/delay]
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "You emerge into a vast natural cathedral, the walls arching higher than you can see in the darkness. Stretching across the gallery is a great chasm, around which the cave floor appears to have been completely worn smooth. This was once the center of a bustling dwarvish empire, the remnants of which have since been driven into the upper caves of Knalga by the forces of darkness."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            x=20-30
            y=18-30
            side=1
        [/filter]
        [message]
            speaker=unit
            message= _ "There is a big cave-in south of here."
        [/message]
    [/event]
    [event]
        name=moveto
        [filter]
            x=20-30
            y=24-25
            side=1
        [/filter]
        {QUAKE "cave-in.ogg"}
        [message]
            speaker=unit
            message= _ "The rocks are moving!"
        [/message]
        [terrain]
            x=28
            y=26
            terrain=Uu
        [/terrain]

        {PLACE_IMAGE scenery/rubble.png 28 26}

        [terrain]
            x=26
            y=25
            terrain=Uu
        [/terrain]

        {PLACE_IMAGE scenery/rubble.png 26 25}

        #just in case that the player waits until the other end is
        # open to catch him alone
        [unit]
#ifdef HARD
            type=Revenant
#else
            type=Skeleton
#endif
            side=4
            x=24
            y=28
            [modifications]
                {TRAIT_UNDEAD}
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
#ifdef EASY
            type=Walking Corpse
#endif
#ifdef NORMAL
            type=Skeleton
#endif
#ifdef HARD
            type=Revenant
#endif
            side=4
            x=24
            y=28
            [modifications]
                {TRAIT_UNDEAD}
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
    [/event]

    [event]
        name=sighted
        [filter]
            side=2
        [/filter]
        [message]
            speaker=second_unit
            message= _ "Who goes there? Friend or foe?"
        [/message]
        [message]
            speaker=unit
            message= _ "We are desperately trying to rid these tunnels of orcs and trolls! Please help us in our quest."
        [/message]
    [/event]

    [event]
        name=sighted
        [filter]
            side=3
        [/filter]
        [message]
            speaker=second_unit
            message= _ "Vile creature! Let us rid these tunnels of its kind!"
        [/message]
    [/event]

    [event]
        name=sighted
        [filter]
            side=4
        [/filter]
        [message]
            speaker=second_unit
            message= _ "I did not know that the undead were in these pits!"
        [/message]
    [/event]

    [event]
        name=sighted
        [filter]
            id=Lionel
        [/filter]
        [message]
            speaker=second_unit
            message= _ "Who is this foul enemy that we fight?"
        [/message]
        [message]
            speaker=Lionel
            message= _ "I am Lionel. I am the Lost General. I will avenge myself upon you all!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Avenge? What have we done to you that you must avenge?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Lionel? A General? I remember that name..."
        [/message]
        [message]
            speaker=Lionel
            message= _ "Remember me, do you? Aye. I was the king’s finest general, sent down to these pits to retrieve the Sceptre. But the orcs trapped me and my men in this cavern, to starve to death. The dwarves were no help, leaving me to die. Now I will get revenge on you all!"
        [/message]

#define MORE_UNITS
    {LOYAL_UNDEAD_UNIT 4 (Revenant) 23 28}
#enddef

        {MORE_UNITS}
        {MORE_UNITS}
        {MORE_UNITS}
    [/event]

    [event]
        name=last breath
        [filter]
            id=Lionel
        [/filter]
        [message]
            speaker=Lionel
            message= _ "Argh! I am vanquished! But at least by worthy foes, instead of those disgusting orcs."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Rest in peace, Lionel. The poor, lost general."
        [/message]
        [message]
            speaker=Lionel
            message= _ "I am destroyed, but my mission must be completed. Though you are foes, you are at least worthy ones, so I will tell you that the Sceptre is east from here, the way you have come from, deep in the caverns. I made the mistake of not asking for directions when I became lost. May you have better fortune in your quest than I did!"
        [/message]
    [/event]

    [event]
        name=turn 20

        {QUAKE "rumble.ogg"}
        {QUAKE "rumble.ogg"}
        {QUAKE "rumble.ogg"}
        {QUAKE "rumble.ogg"}
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "The earth shakes."
        [/message]
        # just to open another exit to the undeads
        [terrain]
            x=15
            y=26
            terrain=Uu
        [/terrain]

        {PLACE_IMAGE scenery/rubble.png 15 26}

        [terrain]
            x=16
            y=26
            terrain=Uu
        [/terrain]

        {PLACE_IMAGE scenery/rubble.png 16 26}

        {LOYAL_UNDEAD_UNIT 4 (Skeleton) 23 28}
    [/event]

    [event]
        name=enemies defeated

        #

        # We don't know if Geldar will be alive at this point,
        # but if he is, then he gives you guardsmen. The message
        # tags outside the if statement will form a coherent
        # conversation either way, and leaving them out avoids
        # some duplication.

        #
        [message]
            speaker=Geldar
            message= _ "Tall ones, I thank ye. Life has been nothing but a struggle recently. We are the last outpost o’ civilization in these caves."
        [/message]
        [message]
            speaker=Delfador
            message= _ "These caves are vast. If we are to find the Sceptre of Fire we must hurry. We are not alone, and now that our foes have smelled our blood it will be worse."
        [/message]
        [message]
            speaker=Geldar
            message= _ "The Sceptre? Ah, the Sceptre ye seek. You surface dwellers are ambitious. Beyond my citadel the spawn of the darkness hold complete sway. You’ll no’ survive without assistance."
        [/message]
        [message]
            speaker=Konrad
            message= _ "How will we make it?"
        [/message]
        [message]
            speaker=Geldar
            message= _ "Northeast o’ my keep, young human, the tunnels converge towards the deepest reaches of the underground kingdom. The Sceptre can only be there. Please accept the service of my guardsmen. These elite warriors will protect you."
        [/message]

        [if]
            [have_unit]
                id=Geldar
            [/have_unit]
            [then]
                [message]
                    speaker=Delfador
                    message= _ "Your boon is most welcome, sir dwarf. Keeping the Sceptre out of the hands of evil beasts is a common goal for us, and we will prevail with your help."
                [/message]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "You may now recruit the legendary dwarvish guardsmen!"
                [/message]
                [allow_recruit]
                    side=1
                    type=Dwarvish Guardsman
                [/allow_recruit]
            [/then]
            [else]
                [message]
                    speaker=Delfador
                    message= _ "I do not know, Konrad, but I can sense our path only leads us downward. We will continue to the northeast, to the deepest depths of these caverns."
                [/message]
            [/else]
        [/if]

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

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