#textdomain wesnoth-httt
[scenario]
    id=09_The_Valley_of_Death
    name= _ "The Valley of Death — The Princess’s Revenge"
    map_data="{campaigns/Heir_To_The_Throne/maps/09_The_Valley_of_Death.map}"
    turns=12

    {DEFAULT_SCHEDULE}

    next_scenario=10_Gryphon_Mountain

    {SCENARIO_MUSIC "the_dangerous_symphony.ogg"}
    {EXTRA_SCENARIO_MUSIC "northerners.ogg"}
    {EXTRA_SCENARIO_MUSIC "knalgan_theme.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Survive for two days"
                condition=win
                show_turn_counter=yes
            [/objective]
            {ALTERNATIVE_OBJECTIVE_BONUS ( _ "Eradicate the liches")}
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]

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

    {HTTT_TRACK {JOURNEY_09_NEW} }

    [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 300 200 200}
        {FLAG_VARIANT long}
    [/side]

#define VOD_AI_PARMS
    [ai]
        grouping=no
        simple_targeting=yes
        aggression=1.0
        caution=-5.0
        {ATTACK_DEPTH 1 3 5}
    [/ai]
#enddef

    [side]
        type=Lich
        id=Galga
        name= _ "Galga"
        side=2
        canrecruit=yes
        team_name=undead
        user_team_name=_"Undead"

        {VOD_AI_PARMS}
        {GOLD 200 320 440}

#ifdef EASY
        recruit=Skeleton,Revenant,Blood Bat,Ghost,Bone Shooter
#endif
#ifdef NORMAL
        recruit=Skeleton,Revenant,Chocobone,Blood Bat,Wraith,Bone Shooter,Dark Adept
#endif
#ifdef HARD
        recruit=Skeleton,Revenant,Chocobone,Wraith,Bone Shooter,Dark Adept
#endif

        [ai]
#ifdef EASY
            recruitment_pattern=fighter,fighter,archer,scout
#endif
#ifdef NORMAL
            recruitment_pattern=fighter,fighter,archer,scout
#endif
#ifdef HARD
            recruitment_pattern=fighter,fighter,archer,scout
#endif
        [/ai]

        [ai]
            aggression=1.0
            village_value=0.0
            leader_value=50.0
        [/ai]
        {FLAG_VARIANT undead}
    [/side]

    {STARTING_VILLAGES 2 6}

    [side]
        type=Lich
        id=Na-alga
        name= _ "Na-alga"
        side=3
        team_name=undead
        user_team_name=_"Undead"
        canrecruit=yes
        recruit=Wraith,Walking Corpse
        {VOD_AI_PARMS}
        {GOLD 200 400 600}
        [ai]
#ifdef EASY
            recruitment_pattern=scout,fighter
#endif
#ifdef NORMAL
            recruitment_pattern=fighter,scout
#endif
#ifdef HARD
            recruitment_pattern=fighter,fighter,fighter,scout
#endif
        [/ai]

        [ai]
            aggression=1.0
            village_value=0.0
            leader_value=50.0
            villages_per_scout=0
        [/ai]
        {FLAG_VARIANT undead}
    [/side]

    {STARTING_VILLAGES 3 6}

    [side]
        type=Lich
        id=Selda-Mana
        name= _ "Selda-Mana"
        side=4
        canrecruit=yes
        {VOD_AI_PARMS}
        {GOLD 160 280 400}

#ifdef EASY
        recruit=Walking Corpse,Wraith,Bone Shooter,Revenant,Skeleton
#endif
#ifdef NORMAL
        recruit=Walking Corpse,Wraith,Bone Shooter,Revenant,Skeleton,Dark Adept
#endif
#ifdef HARD
        recruit=Wraith,Chocobone,Bone Shooter,Revenant,Skeleton,Dark Adept
#endif

        [ai]
#ifdef EASY
            recruitment_pattern=fighter,fighter,archer,scout
#endif
#ifdef NORMAL
            recruitment_pattern=fighter,fighter,archer,scout
#endif
#ifdef HARD
            recruitment_pattern=fighter,fighter,archer,scout,scout
#endif
        [/ai]

        [ai]
            aggression=1.0
            village_value=0.0
            leader_value=50.0
        [/ai]

        team_name=undead
        user_team_name=_"Undead"
        {FLAG_VARIANT undead}
    [/side]

    {STARTING_VILLAGES 4 6}

    {OBJ_POTION_HOLY 5 23 object7_holywater}
    {OBJ_POTION_HOLY 31 43 object7_holywater2}

    [event]
        name=prestart

        {PLACE_IMAGE scenery/rock1.png 20 14}
        {PLACE_IMAGE scenery/rock2.png  8 31}
        {PLACE_IMAGE scenery/rock3.png 30 34}
        {PLACE_IMAGE scenery/rock4.png 37 39}

        {NEED_DELFADOR placement=leader}
        {NEED_KALENZ placement=leader}
        [recall]
            id=Moremirmu
        [/recall]
    [/event]

    [event]
        name=start
        [message]
            speaker=Kalenz
            message= _ "My lord! This road does not seem as safe as we had hoped. Look around us at the hills — there are undead about!"
        [/message]
        [message]
            speaker=Selda-Mana
            message= _ "Who are these who approach? Let us kill them all!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "To arms, men! The undead hordes approach!"
        [/message]
        [message]
            speaker=Moremirmu
            message= _ "There can be no surrender to these foul beasts of the pit! We fight until victory, or until every one of us is slain!"
        [/message]
    [/event]

    [event]
        name=turn 3
        [message]
            speaker=Konrad
            {KONRAD_VARIATION concerned}
            message= _ "There are just so many! What shall we do?"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "My people douse our weapons with holy water when fighting undead. It usually lasts until the end of the battle, and they shrink in utter fear of our blades... if that is possible for an undead minion."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Let us hold them off as long as we can!"
        [/message]
    [/event]

    [event]
        name=turn 7
        [if]
            [variable]
                name=moremirmu
                numerical_equals=1
            [/variable]
            [then]
                [unit]
                    id=Moremirmu
                    name= _ "Moremirmu"
                    type=Mage of Light
                    side=1
                    x=20
                    y=48
                    random_traits=no
                    profile=portraits/moremirmu.png
                    [modifications]
                        [object]
                            [effect]
                                apply_to=attack
                                range=melee
                                set_name=holy sword
                                set_description=_ "holy sword"
                                set_icon=attacks/sword-holy.png
                                set_type=arcane
                                increase_damage=1
                                increase_attacks=2
                            [/effect]
                        [/object]
                        {TRAIT_LOYAL}
                    [/modifications]
                    {IS_LOYAL}
                [/unit]

                {LOYAL_UNIT 1 (White Mage) 20 48}
                [+unit]
                    role=moremirmumage
                [/unit]
                {LOYAL_UNIT 1 (White Mage) 20 48}
                [+unit]
                    role=moremirmumage
                [/unit]
                {LOYAL_UNIT 1 (White Mage) 20 48}
                [+unit]
                    role=moremirmumage
                [/unit]

                [message]
                    speaker=Moremirmu
                    message= _ "I have come once again to aid you, friends!"
                [/message]
                [message]
                    speaker=Delfador
                    message= _ "White magi? Come to help us? But what are they doing here?"
                [/message]
                [message]
                    speaker=Konrad
                    message= _ "That is Moremirmu! He helped us fight the undead in the Isles of the Damned, let us hope he can help us once more!"
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=time over

        [message]
            speaker=Delfador
            message= _ "The sun rises in the east. Surely the undead do not have the power to continue their onslaught through another day!"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Indeed not! I feel we have survived this battle."
        [/message]
        [message]
            speaker=Konrad
            {KONRAD_VARIATION concerned}
            message= _ "Whew! That was a difficult battle, but they are retreating at last!"
        [/message]

        [fire_event]
            name=victory dance
        [/fire_event]
        [endlevel]
            result=victory
            bonus=no
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=die
        [filter]
            id=Moremirmu
        [/filter]
        [set_variable]
            name=moremirmu
            value=3
        [/set_variable]
    [/event]

    [event]
        name=enemies defeated

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

    [event]
        name=victory dance
        [message]
            speaker=Delfador
            message= _ "Yes! We have fought them off!"
        [/message]

        #if Moremirmu survived the battle, then this dialog
        #takes place
        [if]
            [variable]
                name=moremirmu
                numerical_equals=1
            [/variable]

            [have_unit]
                id=Moremirmu
            [/have_unit]
            [then]
                [message]
                    speaker=Konrad
                    {KONRAD_VARIATION glad}
                    message= _ "Thank you for returning to help us, Moremirmu."
                [/message]
                [message]
                    speaker=Moremirmu
                    message= _ "It is both my duty and pleasure, my lord! We were dining with some royal guards of the Princess, taking a rest from our pilgrimage, when they spoke of how you were tricked into traveling these dangerous lands. We could do nothing but help you!"
                [/message]
                [message]
                    speaker=Konrad
                    message= _ "So, she tricked us into coming this way! Where may we go now? Which way will be safe for us?"
                [/message]
                [message]
                    speaker=Moremirmu
                    message= _ "You must escape the clutches of that vile Queen, my lord. If you take a course bearing north-east, on past the mountain of gryphons, you will be able to ford the Great River at Abez. Make haste though, for you will not be able to ford the river in winter!"
                [/message]
                [message]
                    speaker=Konrad
                    message= _ "Thank you for your counsel, good friend! May our paths meet again in happier times!"
                [/message]
            [/then]

            [else]
                [if]
                    #if Moremirmu died in this battle, the
                    #player laments his death
                    [variable]
                        name=moremirmu
                        numerical_equals=3
                    [/variable]
                    [then]
                        [message]
                            speaker=Konrad
                            {KONRAD_VARIATION concerned}
                            message= _ "It greatly saddens me that Moremirmu was slain on the field, after he helped us."
                        [/message]
                        [message]
                            type=White Mage,Mage of Light
                            message= _ "May he rest peacefully!"
                        [/message]
                        [message]
                            speaker=Kalenz
                            message= _ "He died fighting for you, Prince, just as any of us would be willing to die for you."
                        [/message]
                    [/then]
                [/if]
                [message]
                    speaker=Konrad
                    message= _ "This place makes me feel uneasy, even with the undead retreating. Where may we go now?"
                [/message]
                [message]
                    speaker=Kalenz
                    message= _ "The land of Wesnoth is not safe for us. The Queen’s forces reach every corner. We must make haste to the north lands, across the Great River. Let us go quickly!"
                [/message]
                [message]
                    speaker=Delfador
                    message= _ "Indeed! Let us go from here!"
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory

        [if]
            [variable]
                name=moremirmu
                numerical_equals=1
            [/variable]
            [or]
                [variable]
                    name=moremirmu
                    numerical_equals=3
                [/variable]
            [/or]

            [then]
                [kill]
                    id=Moremirmu
                [/kill]
                [kill]
                    role=moremirmumage
                [/kill]
            [/then]
        [/if]
        {CLEAR_VARIABLE moremirmu}
    [/event]

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

#undef VOD_AI_PARMS
