#textdomain wesnoth-dm
[scenario]
    id=19_Showdown_in_the_Northern_Swamp
    name= _ "Showdown in the Northern Swamp"
    next_scenario=20_Prince_of_Wesnoth
    {MEMOIRS_MAP 19_Showdown_in_the_Northern_Swamp.map}
    {TURNS 24 28 32}
    carryover_percentage=0

    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC northerners.ogg the_deep_path.ogg}
    {EXTRA_SCENARIO_MUSIC revelation.ogg}
    {EXTRA_SCENARIO_MUSIC heroes_rite.ogg}
    {EXTRA_SCENARIO_MUSIC underground.ogg}

    [story]
        [part]
            story= _ "With the portal closed, Iliah-Malal was weakened. He retreated into the Swamp of Dread to recover his strength and attempt another conjuration. Delfador’s troop, hurrying west by secret Dwarvish ways and stealthily crossing the Listra by night, found the necromancer there, on the brink of raising another army amidst the fetid reek."
            delay=4000
        [/part]
        [part]
            story= _ "Using dwarvish and elvish messengers, Delfador was able to communicate the news to the King and ask for help. Mustering all the troops he could find, Lionel marched north to join Delfador for the battle that would decide the fate of Wesnoth."
            delay=4000
        [/part]
    [/story]
    {DM_TRACK {TRIUMPH_STAGE3}}

    ##### Delfador's side #####
    #wmllint: validate-off
    [side]
        {YOUNG_DELFADOR}
        side=1
        save_id=Player
        persistent=yes
        controller=human
        gold=200
        recruit={LOYALISTS},White Mage,Red Mage
        shroud=yes
        team_name=allies
        user_team_name= _ "Loyalists"
        {FLAG_VARIANT long}
    [/side]
    #wmllint: validate-on
    ##### /Delfador's side #####

    [side]
        side=2
        no_leader=yes
        gold=200
        recruit=Spearman,Horseman,Bowman,Cavalryman,Heavy Infantryman
        shroud=yes
        team_name=allies
        user_team_name= _ "Loyalists"
        {FLAG_VARIANT loyalist}
    [/side]

    # The strategic challenge should be getting these to cooperate well
    [side]
        {ILIAH_MALAL (Ancient Lich)}
        facing=se
        side=3
        controller=ai
        team_name=enemies
        user_team_name= _ "Undead"
#ifdef EASY
        recruit=Skeleton, Skeleton Archer, Vampire Bat, Ghost
#endif

#ifdef NORMAL
        recruit=Skeleton, Revenant, Skeleton Archer, Bone Shooter, Ghost, Vampire Bat, Blood Bat, Chocobone, Dark Adept
#endif

#ifdef HARD
        recruit=Skeleton, Skeleton Archer, Revenant, Draug, Banebow, Bone Shooter, Deathblade, Ghost, Wraith, Shadow, Nightgaunt, Chocobone, Dark Adept, Spectre, Blood Bat, Vampire Bat
#endif

        {GOLD 300 375 450}
        {INCOME 10 20 30}
        [ai]
            recruitment_pattern=scout,fighter,archer
            [goal]
                name=target
                [criteria]
                    id=Delfador
                [/criteria]
                value=10
            [/goal]
        [/ai]
        {FLAG_VARIANT undead}
    [/side]

    [side]
        type=Necromancer
        id=Maldun
        name=_ "Maldun"
        facing=sw
        side=4
        canrecruit=yes
        controller=ai
        recruit=Vampire Bat,Dark Adept,Walking Corpse,Ghost,Soulless
        #  [ai]
        #      recruitment_pattern=scout,fighter,archer
        #  [/ai]
        team_name=enemies
        user_team_name= _ "Undead"
        {GOLD 180 300 375}
        {FLAG_VARIANT undead}
    [/side]

    [side]
        type=Death Knight
        id=Alderoth
        name=_ "Alderoth"
        facing=ne
        side=5
        team_name=enemies
        user_team_name= _ "Undead"
        controller=ai

        {GOLD 150 210 330}
        {INCOME 6 8 12}

        canrecruit=yes
        [ai]
            recruitment_pattern=scout,fighter,archer
        [/ai]

#ifdef EASY
        recruit=Skeleton, Skeleton Archer, Vampire Bat
#endif

#ifdef NORMAL
        recruit=Skeleton, Revenant, Skeleton Archer, Bone Shooter, Ghost, Vampire Bat, Blood Bat, Chocobone, Dark Adept
#endif

#ifdef HARD
        recruit=Skeleton, Skeleton Archer, Revenant, Draug, Banebow, Bone Shooter, Deathblade, Ghost, Wraith, Shadow, Nightgaunt, Chocobone, Dark Adept, Spectre, Blood Bat, Vampire Bat
#endif
        {FLAG_VARIANT undead}
    [/side]

    [event]
        name=prestart
        {KALENZ_REJOINS_DELFADOR 26 22}
        [unit]
            {ULREK}
            # wmllint: unwho ULREK
            placement=leader
        [/unit]
        {UNDEAD_REJOIN_DELFADOR}
        {MODIFY_UNIT (side=1) facing nw}

        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Lionel"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description=_ "Death of Ulrek"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=no # next scenario is 26 years later
                carryover_percentage=0
            [/gold_carryover]

            [note]
                description= _ "The killing blow against Iliah-Malal can only be struck by one of your Undead veterans or by Delfador"
                [show_if]
                    [have_unit]
                        race=undead
                        side=1
                        search_recall_list=yes
                    [/have_unit]
                [/show_if]
            [/note]
            [note]
                description= _ "The killing blow against Iliah-Malal can only be struck by Delfador"
                [show_if]
                    [not]
                        [have_unit]
                            race=undead
                            side=1
                            search_recall_list=yes
                        [/have_unit]
                    [/not]
                [/show_if]
            [/note]
        [/objectives]

        {OBJ_POTION_HOLY 26 19 showdown_holywater1}
        {OBJ_POTION_HOLY 30 20 showdown_holywater2}
        {OBJ_POTION_HOLY 29 20 showdown_holywater3}

        [remove_shroud]
            side=1,2
        [/remove_shroud]

        [store_starting_location]
            side=2
            variable=start_loc
        [/store_starting_location]
        {CLEAR_VARIABLE Lionel.overlays}
        {CLEAR_VARIABLE Lionel.ellipse}
        {VARIABLE Lionel.canrecruit yes}
        {VARIABLE Lionel.side 2}
        {VARIABLE Lionel.facing nw}
        [unstore_unit]
            variable=Lionel
            x=$start_loc.x
            y=$start_loc.y
        [/unstore_unit]
        {CLEAR_VARIABLE start_loc,Lionel}
        # wmllint: recognize Lionel
    [/event]

    [event]
        name=start

        [message]
            speaker=Iliah-Malal
            message= _ "So we meet again, Delfador. You were a fool to turn down my offer. None of your allies will save you now."
        [/message]
        [message]
            speaker=Delfador
            message= _ "You have ravaged your own soul with your corrupt arts, and your words are empty wind; I fear them not."
        [/message]
        [message]
            speaker=Iliah-Malal
            message= _ "Is he not amusing, my creatures? He puffs himself up as though he were Delfador the Mighty, Delfador the Powerful, Delfador the Great... rather than a jumped-up hedge wizard I shall shortly crush beneath my heel."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Delfador the Great, eh? And so it comes to pass as the four Oracles foretold. I accept your name-gift, Iliah-Malal."
        [/message]
        [message]
            speaker=Iliah-Malal
            message= _ "Oracles? What nonsense you babble... After you die, I will raise your corpse and compel you to tell me how to reopen my portal!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "One of us will find a final death here. I do not think it will be me."
        [/message]
        [if]
            [have_unit]
                race=undead
                side=1
                search_recall_list=yes
            [/have_unit]
            [then]
                [message]
                    speaker=narrator
                    message= _ "In this scenario only, you may recall your veterans from the Land of the Dead. The killing blow against Iliah-Malal can only be struck by one of them or by Delfador."
                    image=wesnoth-icon.png
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=recall
        first_time_only=yes
        [filter]
            race=undead
        [/filter]

        # Most likely facings for this dialog, as recall of undead will probably happen turn 1 or 2
        {MODIFY_UNIT (id=Lionel) facing nw}
        [message]
            speaker=Lionel
            message= _ "Delfador... You raise undead?!"
        [/message]
        {MODIFY_UNIT (id=Delfador) facing se}
        [message]
            speaker=Delfador
            message= _ "No. I did not raise them from our dead; I offered some who fought beside me in the otherworld a way here, and they come to us of their own will. Today they fight for the living."
        [/message]
    [/event]

    [event]
        name=turn 2
        [message]
            speaker=Delfador
            message= _ "I have prepared some holy water. Sprinkle it on your weapons and smash those foul creatures into dust!"
        [/message]

        [message]
            speaker=Iliah-Malal
            message= _ "Powers of darkness, enshroud this field!"
        [/message]

        [place_shroud]
            side=1,2
        [/place_shroud]
        [redraw]
            side=1,2
            clear_shroud=yes
        [/redraw]
    [/event]
    [event]
        name=turn 3
        {MODIFY_UNIT (id=Delfador) facing nw}
        [message]
            speaker=Delfador
            message= _ "Darkness shall be dispelled!"
        [/message]

        [remove_shroud]
            side=1,2
        [/remove_shroud]
        {MODIFY_UNIT (id=Iliah-Malal) facing se}
        [message]
            speaker=Iliah-Malal
            message= _ "No!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Let the light shine forth!"
        [/message]
        [message]
            speaker=Iliah-Malal
            message= _ "Your sorcery matters little. Your army will fall like wheat to the sickle before my undead legions."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Your mindless minions will be no match for the spirit and fire of the living."
        [/message]

        {MODIFY_UNIT (id=Lionel) facing nw}
        [message]
            speaker=Lionel
            message= _ "Delfador, as the King ordered I place all troops under your command. They will follow you to death, if necessary, and so will I!"
        [/message]

        {MODIFY_UNIT (id=Delfador) facing se}
        [message]
            speaker=Delfador
            message= _ "Lionel, it is an honor to go into battle beside you. Now let us fight for life over death!"
        [/message]

        [if]
            [have_unit]
                race=undead
                side=1
                search_recall_list=yes
            [/have_unit]
            #wmllint: local spelling un-life
            [then]
                [message]
                    speaker=Delfador
                    message= _ "Remember that one of our undead or I must strike the final blow, for Iliah-Malal’s un-life can only be ended by the touch of un-life or by the power of the Book of Crelanu."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Delfador
                    message= _ "Remember that I must strike the final blow, for Iliah-Malal’s un-life can only be ended by the power of the Book of Crelanu."
                [/message]
            [/else]
        [/if]
        {SUBSUME_SIDE_AND_VILLAGES 2}
        {MAKE_HERO Lionel}
    [/event]

    # last breath events for Iliah-Malal
    # An undead can kill him
    [event]
        name=last breath
        [filter]
            id=Iliah-Malal
        [/filter]
        [filter_second]
            race=undead
        [/filter_second]

        [message]
            speaker=Delfador
            message= _ "Now your days are ended!"
        [/message]
        [message]
            speaker="Iliah-Malal"
            message=_ "The power of death is mine! When you strike me down I arise stronger than before!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Not this time. For I have gazed upon the dark heart of necromancy in the Book of Crelanu, and found there your final doom at the hands of the dead themselves."
        [/message]
        {DELFADOR_LIGHTNING}

        # We're counting on the lich-scream as Ihiah-Malal
        # dies to end the scene.
    [/event]

    # Delfador can kill him
    [event]
        name=last breath
        [filter]
            id=Iliah-Malal
        [/filter]
        [filter_second]
            id=Delfador
        [/filter_second]

        [message]
            speaker=Delfador
            message= _ "Now your days are ended!"
        [/message]
        [message]
            speaker="Iliah-Malal"
            message=_ "The power of death is mine! When you strike me down I arise stronger than before!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Not this time. For I have gazed upon the dark heart of necromancy in the Book of Crelanu, AND I REMAIN OF THE LIGHT!"
        [/message]
        {DELFADOR_LIGHTNING}

        # We're counting on the lich-scream as Ihiah-Malal
        # dies to end the scene.
    [/event]

    # But nobody else can.
    [event]
        name=last breath
        first_time_only=no
        [filter]
            id=Iliah-Malal
        [/filter]
        [filter_second]
            [not]
                id=Delfador
            [/not]
            [not]
                race=undead
            [/not]
        [/filter_second]

        [message]
            speaker="Iliah-Malal"
            message=_ "The power of death is mine! When you strike me down I arise stronger than before!"
        [/message]

        # He gets the standard +3 hitpoints and full heal.
        {ADVANCE_UNIT (id="Iliah-Malal") ()}
    [/event]

    [event]
        name=enemies defeated

        [endlevel]
            result=victory
            bonus=no
            carryover_percentage=0
        [/endlevel]
    [/event]

    # wmllint: recognize Kalenz
    [event]
        name=victory

        [message]
            speaker=Delfador
            message= _ "Evil has been vanquished on this day. May this victory bring lasting peace."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "You have earned the name the accursed one gave you... Delfador the Great."
        [/message]
        [message]
            speaker=Ulrek
            message=_"Indeed. This will be quite a tale to tell."
        [/message]
        [if]
            [have_unit]
                side=1
                race=undead
                search_recall_list=yes
            [/have_unit]
            [then]
                [while]
                    [have_unit]
                        side=1
                        race=undead
                        x,y=recall,recall
                        search_recall_list=yes
                    [/have_unit]
                    [do]
                        [recall]
                            side=1
                            race=undead
                            show=yes
                        [/recall]
                    [/do]
                [/while]
                [message]
                    speaker=Delfador
                    message= _ "You who fought beside me in the Land of the Dead and chose the side of the living on this day, return now to your peace and rest."
                [/message]

                [kill]
                    side=1
                    race=undead
                    animate=yes
                [/kill]
            [/then]
        [/if]
        [message]
            speaker=Lionel
            message=_"And the portal, it is sealed for good?"
        [/message]
        [message]
            speaker=Delfador
            message=_"Yes, it is. But it was too great a work of magic to be entirely undone; there is a flaw still remaining, a trace of Iliah-Malal’s way between worlds. Raising undead will be a little easier in the future than it has been before. Those who come after us will have to be vigilant against the corruption of the dark arts, and show themselves worthy of the land they live in."
        [/message]

        # This is set-up for the next scenario, where Kalenz leads side 1 again
        {DELFADOR_DEPARTS_AGAIN}
    [/event]
    {MEMOIRS_DEATHS}
[/scenario]
