#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}"
    {TURNS 64 60 54}

    {UNDERGROUND}

    next_scenario=16_Hasty_Alliance

    {SCENARIO_MUSIC "the_deep_path.ogg"}
    {EXTRA_SCENARIO_MUSIC "underground.ogg"}
    {EXTRA_SCENARIO_MUSIC "knalgan_theme.ogg"}
    {EXTRA_SCENARIO_MUSIC "into_the_shadows.ogg"}
    {EXTRA_SCENARIO_MUSIC "heroes_rite.ogg"}

    {HTTT_TRACK {JOURNEY_15_NEW} }

    [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-human.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=prestart
        {NEED_DELFADOR placement=leader}
        {NEED_KALENZ placement=leader}
        [allow_recruit]
            side=1
            type=Dwarvish Fighter,Dwarvish Thunderer
        [/allow_recruit]
        [disallow_recruit]
            side=1
            type=Dwarvish Guardsman
        [/disallow_recruit]
    [/event]

    [event]
        name=start
        [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]
    [/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 23 (Burlin) ( _ "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

            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [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
            # po: Comic relief
            male_message= _ "I am a merman, 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."
            # po: Comic relief
            female_message= _ "I am a mermaid, 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
            [show_if]
                [have_unit]
                    x,y=6,23
                    gender=male
                [/have_unit]
            [/show_if]
            # 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]
            speaker=Ulfdain
            [show_if]
                [have_unit]
                    x,y=6,23
                    gender=female
                [/have_unit]
            [/show_if]
            # wmllint: directory spelling mer-mead
            message= _ "(sniffs) A mer-mead. 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]
                id=$unit.id
            [/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
            [show_if]
                [have_unit]
                    id=$unit.id
                    gender=male
                [/have_unit]
            [/show_if]
            message= _ "Well, mer-mahn, we made it. I will fight for yer lord. He sounds like a brave fellow."
        [/message]
        [message]
            speaker=Ulfdain
            [show_if]
                [have_unit]
                    id=$unit.id
                    gender=female
                [/have_unit]
            [/show_if]
            message= _ "Well, mer-mead, 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]

        [sound]
            name=thunderstick.ogg
        [/sound]
        [delay]
            time=200
        [/delay]

        # This dialog has several purposes:
        # 1. Clue to the player that he's exploring in the right direction
        # 2. Clue to the player to hurry up, in order to save Geldar
        # 3. An excuse to play the thunderstick sound :)
        [message]
            speaker=Konrad
            # We don't use {WHISPER} since it adds parentheses and two pairs of parentheses would be confusing.
            message=_ "<i>(motions for silence)</i>

<small>What was that raucous noise?</small>"
        [/message]
        [message]
            speaker=Delfador
            {DELFADOR_MENTORING}
            message=_ "That can only have been a Dwarven thunderstick, Konrad. Our Knalgan allies must be in the thick of battle."
        [/message]
        # Let $unit speak too, so it's clear where the battle is.
        [if]
            [have_unit]
                id=$unit.id
                race=dwarf
            [/have_unit]
            [then]
                [message]
                    speaker=unit
                    # po: speaker is a dwarf
                    message=_ "That’ll be Lord Geldar’s clan, my lords. Their scouting patrols should’ve found us by now."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=unit
                    # po: The unit is saying that a battle between the player's dwarven allies and their enemies is not far, but still under the shroud. Translate freely.
                    male_message=_ "We must hurry to assist them, my lords."
                    # po: The unit is saying that a battle between the player's dwarven allies and their enemies is not far, but still under the shroud. Translate freely.
                    female_message=_ "female^We must hurry to assist them, my lords."
                [/message]
            [/else]
        [/if]
        [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]
        [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
            # TODO: mention some sounds coming from the cave-in? (Ostensibly,
            # the sounds of the skeletons working to open the passage.)
            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_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_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
    [/event]

    [event]
        name=sighted
        [filter]
            side=2
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [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]
#ifdef EASY
        {NARRATOR_MESSAGE (_ "The dwarves are your allies in this scenario. If you help their leader survive the battle, he may provide you with useful information.")}
#endif
    [/event]

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

    [event]
        name=sighted
        [filter]
            side=4
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [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]
        [filter_second]
            side=1
        [/filter_second]
        [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_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_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.

        #

        [if]
            [have_unit]
                id=Geldar
            [/have_unit]
            [then]
                [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= _ "We have fared little better ourselves, friend. We have fled the Aethenwood last spring and come to these caves to seek the Sceptre of Fire. With the Sceptre, we hope to put the war to an end."
                [/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
                    # po: Relgorn is the dwarvish leader from the previous scenario
                    message= _ "Lord Relgorn’s troops are fighting at our side, sir."
                [/message]

                [message]
                    speaker=Geldar
                    message= _ "And fine troops they are, Prince, but no dwarf can match a guardsman’s resolute defense. Please accept the service o’ my clan’s defenders, to protect you and your quest."
                [/message]

                [message]
                    speaker=Konrad
                    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]

                [message]
                    speaker=Geldar
                    message= _ "Northeast o’ my keep, Delfador, the tunnels converge towards the deepest reaches o’ the underground kingdom. The Sceptre can only be there."
                [/message]
            [/then]
            [else]
                [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=Konrad
                    message= _ "How will we make it?"
                [/message]

                [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]

#undef MORE_UNITS
