#textdomain wesnoth-httt
[scenario]
    id=16_Hasty_Alliance
    name= _ "Hasty Alliance"
    map_data="{campaigns/Heir_To_The_Throne/maps/16_Hasty_Alliance.map}"
    {SCENARIO_MUSIC "underground.ogg"}
    {TURNS 33 30 27}

    {DEEP_UNDERGROUND}

    next_scenario=17_Scepter_of_Fire

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat the enemy leader"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Li’sar"
                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]

    [story]
        [part]
            story= _ "The last dwarvish settlement far behind them, the party descended into the deepest parts of the hewn caverns. Except for disturbances caused by the occasional goblin, the air in the lower passages was still and tomblike."
            #background="maps/wesnoth-httt.jpg"
            show_title=no
        [/part]
        [part]
            story= _ "Stepping through a low corridor, Konrad and Delfador emerged from the maze-like catacombs into icy blackness. Darkness seemed to crush them. Lights flickered and went out. Even the staff of the elder mage struggled to produce enough light to see by."
            #background="maps/wesnoth-httt.jpg"
            show_title=no
        [/part]
        [part]
            story= _ "A cavernous void stretched out ahead, across which no ceiling or walls were visible. Wind howled and whipped over narrow ledges bridging the depths, almost as if animated by powerful nearby magic... and newly awoken evil."
            #background="maps/wesnoth-httt.jpg"
            show_title=no
        [/part]
    [/story]

    {BIGMAP_HASTY_ALLIANCE}

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad.png
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Humans"
        controller=human
        gold=200
        shroud=yes
        {FLAG_VARIANT long}
    [/side]

    [side]
        side=2
        canrecruit=yes
        controller=ai
        type=Princess
        id="Li'sar"
        name= _ "Li’sar"
        profile=portraits/lisar.png
        facing=sw
        [ai]
            recruitment_pattern=fighter,fighter,fighter,fighter,mixed fighter
        [/ai]
        recruit=Swordsman,Heavy Infantryman,Pikeman,Red Mage,Ogre
        gold=400
        team_name=elves
        user_team_name=_"Humans"
        experience=62
        {FLAG_VARIANT loyalist}
    [/side]

    # Ensure that Li'sar can't get herself killed during the first couple of
    # turns when the player can't necessarily yet be able to protect her.
    {FORCE_CHANCE_TO_HIT side=3 id="Li'sar" 0 (
        [variable]
            name=turn_number
            less_than=5
        [/variable]
    )}

    [side]
        type=Troll Warrior
        id=Haaf-Garga
        name= _ "Haaf-Garga"
        side=3
        canrecruit=yes
        controller=ai
#ifdef EASY
        recruit=Troll,Troll Whelp,Vampire Bat,Wolf Rider
#else
        recruit=Troll,Troll Warrior,Blood Bat,Wolf Rider
#endif
        {GOLD 100 160 220}
        {INCOME 4 8 12}
        [ai]
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        team_name=evil
        user_team_name=_"Evil"
    [/side]

    [event]
        name=start

        # {SCATTER_IMAGE (terrain=Uu) 4 scenery/rubble.png}

        #hide Li'sar until she arrives
        [hide_unit]
            x=12
            y=18
        [/hide_unit]

        [recall]
            id=Delfador
        [/recall]
        [recall]
            id=Kalenz
        [/recall]

        [redraw]
        [/redraw]

        [message]
            speaker=Konrad
            message= _ "Where are we? Which way now? I am tired of this darkness!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "I am not sure of the way. Let me think for a moment."
        [/message]

        #Li'sar arrives
        [move_unit_fake]
            type=Princess
            side=2
            x=15,14,13,12
            y=17,18,19,18
        [/move_unit_fake]

        [unhide_unit]
        [/unhide_unit]

        [move_unit_fake]
            type=Royal Guard
            side=2
            x=15,14,13,12,11
            y=18,18,18,17,18
        [/move_unit_fake]

        [unit]
            type=Royal Guard
            generate_name=yes
            side=2
            x=11
            y=18
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [redraw]
        [/redraw]

        [move_unit_fake]
            type=Royal Guard
            side=2
            x=15,14,13,12,11
            y=18,18,19,18,19
        [/move_unit_fake]

        [unit]
            type=Royal Guard
            generate_name=yes
            side=2
            x=11
            y=19
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [redraw]
        [/redraw]

        [message]
            speaker="Li'sar"
            message= _ "En garde!"  # wmllint: no spellcheck
        [/message]
        [message]
            speaker=Konrad
            message= _ "What in the world are you doing here?"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "Tracking you down, of course! You have escaped me for the last time!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Foolish girl! We are in the deepest of caverns, probably surrounded by all manner of creatures, and you still want to fight us? You will bring us all to ruin!"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "Don’t try to trick me! I know why you have come here! But I will put an end to you and your treason here. Then I will get the Sceptre, and return to the daylight again!"
        [/message]

        #change the music to being frantic as lots of orcs arrive
        [music]
            name=the_dangerous_symphony.ogg
            immediate=yes
            play_once=yes
        [/music]
        [music]
            name=the_deep_path.ogg
            append=no
        [/music]
        [music]
            name=heroes_rite.ogg
            append=yes
        [/music]

#define HASTY_TROLL X Y
    {LOYAL_UNIT 3 Troll {X} {Y}}
    [redraw]
    [/redraw]
#enddef
#define HASTY_GOBLIN_KNIGHT X Y
    {LOYAL_UNIT 3 (Goblin Knight) {X} {Y}}
    [redraw]
    [/redraw]
#enddef

        #alot of enemies arrive
        [move_unit_fake]
            type=Troll
            side=3
            x=13,12,11
            y=16,16,16
        [/move_unit_fake]

        {HASTY_TROLL 11 16}

        [move_unit_fake]
            type=Troll
            side=3
            x=13,13
            y=16,17
        [/move_unit_fake]

        {HASTY_TROLL 13 17}

        [move_unit_fake]
            type=Troll
            side=3
            x=15,14
            y=18,18
        [/move_unit_fake]

        {HASTY_TROLL 14 18}

        [move_unit_fake]
            type=Goblin Knight
            side=3
            x=4,5,6
            y=13,14,14
        [/move_unit_fake]

        {HASTY_GOBLIN_KNIGHT 6 14}

        [move_unit_fake]
            type=Goblin Knight
            side=3
            x=3,4,5
            y=16,16,16
        [/move_unit_fake]

        {HASTY_GOBLIN_KNIGHT 5 16}

        [move_unit_fake]
            type=Goblin Knight
            side=3
            x=7,8
            y=20,20
        [/move_unit_fake]

        {HASTY_GOBLIN_KNIGHT 8 20}

        [move_unit_fake]
            type=Troll
            side=3
            x=3,4,5
            y=14,14,15
        [/move_unit_fake]

        {HASTY_TROLL 5 15}

        [move_unit_fake]
            type=Troll
            side=3
            x=5,5,6
            y=14,15,15
        [/move_unit_fake]

        {HASTY_TROLL 6 15}

        #some more trolls that are behind in the caves
        {HASTY_TROLL 3 13}
        {HASTY_TROLL 4 9}
        {HASTY_TROLL 15 13}
        {HASTY_TROLL 17 14}
        {HASTY_TROLL 13 10}

        [message]
            type=Goblin Knight
            message= _ "Surprise! Die, you sun-lovers!"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Now we are surrounded! Do you still want to fight us, Princess? Surely that would lead to doom for us all!"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "I see we have little choice but to help each other. Let us fight together until we return to the surface. Agreed?"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Very well, I promise that you will reach the surface again, or we shall all perish together, Princess."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "But once we escape from this hole, I have a score to settle with you!"
        [/message]
    [/event] #end of start event

    [event]
        name=enemies defeated

        [message]
            speaker=Konrad
            message= _ "Well, we have helped each other survive so far, Princess. Now let’s continue together. What do you say?"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "Yes. We agreed to help each other get out of these pits alive, did we not? Let us continue to pool our resources. I pledge to you my gold."
        [/message]

        [message]
            speaker=Konrad
            message= _ "Thank you, Princess. Come, men. Let us find the Sceptre!"
        [/message]

        [store_unit]
            [filter]
                id="Li'sar"
            [/filter]

            kill=yes
            variable=stored_Lisar
        [/store_unit]

        [unit]
            side=1
            id="Li'sar"
            name= _ "Li’sar"
            unrenamable=yes
            profile=portraits/lisar.png
            type=$stored_Lisar.type
            experience=$stored_Lisar.experience
            {IS_HERO}
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]

        {CLEAR_VARIABLE stored_Lisar}

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

    #deaths.cfg only handles death of Li'sar is she’s on side '1', so handle
    #it explicitly here.
    [event]
        name=last breath
        [filter]
            id="Li'sar"
        [/filter]
        [message]
            speaker=unit
            message= _ "I can’t believe it should end like this!"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

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