#textdomain wesnoth-dm

[scenario]
    name=_ "Houses of the Dead"
    id=09_Houses_of_the_Dead
    next_scenario=10_The_Gate_Between_Worlds
    {MEMOIRS_MAP 09_Houses_of_the_Dead.map}
    turns=50

    disallow_recall=yes
    victory_when_enemies_defeated=no
    {LAND_OF_THE_DEAD}

    # Could use "The Deep Path", but monotony is what we want here
    {SCENARIO_MUSIC underground.ogg}

    [side]
        {YOUNG_DELFADOR}
        side=1
        save_id=Player
        persistent=yes
        controller=human
        team_name=allies
        user_team_name= _ "Loyalists"
        shroud=yes
        gold=0
        # Go back to stock flag, since we no longer recruit loyalist units
    [/side]

    [side]
        type=Death Knight
        id=Arakar
        name=_ "Arakar"
        side=2
        canrecruit=yes
        controller=ai
        team_name=enemies
        user_team_name= _ "Undead"
        recruit=Skeleton
        {GOLD 0 0 15}
        {INCOME 0 2 2}
        [ai]
            recruitment_pattern=fighter
            aggression=1.0
            [goal] # they're not interested in killing ghosts
                name=target
                [criteria]
                    id=Delfador
                [/criteria]
                value=50
            [/goal]
            [goal]
                name=target
                [criteria]
                    [not]
                        id=Delfador
                    [/not]
                [/criteria]
                value=0
            [/goal]
        [/ai]
        {FLAG_VARIANT undead}
    [/side]

    [side]
        side=3
        no_leader=yes
        controller=ai
        team_name=allies
        user_team_name= _ "Undead Followers"
        hidden=yes
    [/side]

    [story]
        [part]
            story=_ "It was one of those moments that altered the destiny of the world. The orc warrior held many possibilities in his hand. He could simply have taken Delfador’s head. Had that occurred, the orcs might have overrun the whole of Wesnoth and ruled it for ages. But what he chose, thinking it rare sport to abuse one of the hated human mages, was to strike Delfador with his gauntleted fist."
        [/part]
        [part]
            story=_ "The blow interrupted Delfador’s meditation. He began to topple over to the ground, but before his head reached it he vanished as though he had never been there at all."
        [/part]
    [/story]

    {MEMOIRS_DEATHS}

    [event]
        name=prestart
        {VARIABLE delf_has_staff no}
        {VARIABLE heard_from_ghost no}

        [objectives]
            side=1
            [objective]
                description=_ "Explore the Land of the Dead"
                condition=win
                [show_if]
                    {VARIABLE_CONDITIONAL heard_from_ghost boolean_equals no}
                [/show_if]
            [/objective]
            [objective]
                description=_ "Have Delfador claim the magical artifact, then move him to the signpost"
                condition=win
                [show_if]
                    {VARIABLE_CONDITIONAL heard_from_ghost boolean_equals yes}
                    {VARIABLE_CONDITIONAL delf_has_staff boolean_equals no}
                [/show_if]
            [/objective]
            [objective]
                description=_ "Move Delfador to the signpost"
                condition=win
                [show_if]
                    {VARIABLE_CONDITIONAL heard_from_ghost boolean_equals yes}
                    {VARIABLE_CONDITIONAL delf_has_staff boolean_equals yes}
                [/show_if]
            [/objective]
            [objective]
                description=_ "Death of Delfador"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=80
            [/gold_carryover]

            [note]
                description= _ "Delfador must visit a village himself to find if help is there"
                [show_if]
                    {VARIABLE_CONDITIONAL heard_from_ghost boolean_equals yes}
                [/show_if]
            [/note]
        [/objectives]

        [item]
            x=15
            y=1
            image=scenery/signpost.png
        [/item]

        # Don't let Delfador step on the staff before meeting the guardian
        [terrain]
            x,y=3,7
            terrain=^Xo
            layer=overlay
        [/terrain]
    [/event]

    [event]
        name=start
        [message]
            speaker=narrator
            message=_"Delfador opens his eyes and realizes he is <i>alone</i> in the <i>dark</i>."
            image=wesnoth-icon.png
        [/message]
        [message]
            speaker=Delfador
            message=_"This is surely the land of the dead... and it seems I am still alive. But then, as Leollyn warned, I can never return! I suppose I may as well explore."
        [/message]
        [set_recruit]
            recruit=""
            side=1
        [/set_recruit]
    [/event]

    {STARTING_VILLAGES 2 10}

    {MEMOIRS_SECRET_PASSAGE  32 5  2 8}
    {MEMOIRS_ITEM_STAFF 3 7}

    # Have Rorthin appear before Delfador can reach any of the villages
    [event]
        name=new turn

        [filter_condition]
            [have_location]
                terrain=*^V*

                [filter_vision]
                    visible=yes
                    side=1
                [/filter_vision]
            [/have_location]
        [/filter_condition]

        # Move Rorthin to north of Delfador from the closest shrouded hex

        [store_locations]
            [filter_adjacent_location]
                [filter]
                    id=Delfador
                [/filter]

                adjacent=s
            [/filter_adjacent_location]

            variable=next_to_delf
        [/store_locations]

        [for]
            start,end,step=1,99,1

            [do]
                [store_locations]
                    [filter_vision]
                        visible=no
                        side=1
                    [/filter_vision]

                    [and]
                        x,y=$next_to_delf.x,$next_to_delf.y
                        radius=$i
                    [/and]

                    variable=move_from
                [/store_locations]

                [if]
                    [variable]
                        name=move_from.length
                        greater_than=0
                    [/variable]

                    [then]
                        [break]
                        [/break]
                    [/then]
                [/if]
            [/do]
        [/for]

        [move_unit_fake]
            side=3
            type=Ghost
            x=$move_from[0].x,$next_to_delf.x
            y=$move_from[0].y,$next_to_delf.y
        [/move_unit_fake]

        {NAMED_UNIT 3 (Ghost) $next_to_delf.x $next_to_delf.y Rorthin _"Rorthin" ()}

        [message]
            speaker=Rorthin
            message=_"A living man... so it is as Iliah-Malal says..."
        [/message]
        [message]
            speaker=Delfador
            message=_"Speak again, spirit! Tell me of yourself. Who is this Iliah-Malal?"
        [/message]
        [message]
            speaker=Rorthin
            message=_"My name is Rorthin. I died long ago, in a great battle... I have almost forgotten... Iliah-Malal is a living man, like you, who walks among the dead. He promises life to all those who follow him. Such is against the way of things."
        [/message]
        [message]
            speaker=Delfador
            message=_"I agree. I would very much like to meet Iliah-Malal. Where can I find him?"
        [/message]
        [message]
            speaker=Rorthin
            message=_"Follow the dry river, then the road to the signpost in the north. I will help you. Enter the houses of the dead as you pass, for others here may help you."
        [/message]
        [message]
            speaker=Delfador
            message=_"Speak again, spirit! What else do you know of this place?"
        [/message]
        [message]
            speaker=Rorthin
            message=_"I have heard there is a powerful magical artifact somewhere around here. Any more, I cannot tell you."
        [/message]
        {MODIFY_UNIT (id=Rorthin) side 1}
        [allow_recruit]
            type=Ghost
            side=1
        [/allow_recruit]
        {VARIABLE heard_from_ghost yes}
        [show_objectives]
        [/show_objectives]

        {CLEAR_VARIABLE next_to_delf,move_from}
    [/event]

#define MEMOIRS_DEAD_HOUSE X Y TYPE ID NAME_STRING ACTIONS
    [event]
        name=moveto
        [filter]
            id=Delfador
            x={X}
            y={Y}
        [/filter]
        [unit]
            type={TYPE}
            id={ID}
            name={NAME_STRING}
            side=1
            x={X}
            y={Y}
        [/unit]
        {ACTIONS}
    [/event]
#enddef

    # wmllint: whofield MEMOIRS_DEAD_HOUSE 4
    {MEMOIRS_DEAD_HOUSE 36 18 Ghoul Penella ( _ "Penella") (
        [message]
            speaker=Penella
            message=_"Do not fear me, Delfador. It is my doom to appear as you see me. I was a serf of a cruel lord. He demanded great taxes to fight many wars... then plague came... my family were starving, and we were forced to eat the flesh of those who had died."
        [/message]
        [allow_recruit]
            type=Ghoul
            side=1
        [/allow_recruit]
    )}
    {MEMOIRS_DEAD_HOUSE 16 13 Ghost Roddry ( _ "Roddry") (
        [message]
            speaker=Roddry
            message=_"Have you encountered the skeletons? Their castle lies north of here. It is difficult to attack, but there is a secret entrance in the valley beyond Sythan’s village."
        [/message]
    )}
    {MEMOIRS_DEAD_HOUSE 22 12 Shadow Nameless ( _ "Nameless") (
        [message]
            speaker=Nameless
            message=_"I died a long time ago. I have forgotten my name."
        [/message]
    )}
    {MEMOIRS_DEAD_HOUSE 23 3 Ghost Melinna ( _ "Melinna") (
        [message]
            speaker=Melinna
            message=_"Iliah-Malal says that he can open a portal to the world of the living. Those who follow him will walk the earth as they did in life."
        [/message]
        [message]
            speaker=Delfador
            message=_"Why are the dead so restless? This should be a place of rest and peace for you."
        [/message]
        [message]
            speaker=Melinna
            message=_"Once, I was happy here, but Iliah-Malal made me see this land as the eyes of the living see it... a place of rock and dust."
        [/message]
    )}
    {MEMOIRS_DEAD_HOUSE 34 11 Ghost Sythan ( _ "Sythan") (
        [message]
            speaker=Sythan
            message=_"I was once a great lord... I commanded armies! Iliah-Malal promised I would lead again."
        [/message]
    )}
    {MEMOIRS_DEAD_HOUSE 22 16 Ghost Hereld ( _ "Hereld") (
        [message]
            speaker=Hereld
            message=_"Beware the skeletons! They are not the spirits of dead men, but the creations of evil magic."
        [/message]
        [message]
            speaker=Delfador
            message=_"What else do you know of the skeletons?"
        [/message]
        [message]
            speaker=Hereld
            message=_"It is said that they guard a powerful magical artifact. Roddry knows more than I do; he lives to the west."
        [/message]
        #wmllint: whofield clear MEMOIRS_DEAD_HOUSE
    )}

#undef MEMOIRS_DEAD_HOUSE

    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Delfador
            x=15
            y=1
        [/filter]
        [if]
            [variable]
                name=delf_has_staff
                boolean_equals=yes
            [/variable]
            [then]
                [endlevel]
                    result=victory
                    bonus=yes
                [/endlevel]
            [/then]
            [else]
                [message]
                    id=Delfador
                    message=_ "I must find that artifact of which the ghost spoke; it sounds too powerful a thing to be left in Iliah-Malal’s hands."
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto

        [filter]
            side=1
        [/filter]

        [filter_condition]
            [have_location]
                x=8,10
                y=4,3

                [filter_vision]
                    visible=yes
                    side=1
                [/filter_vision]
            [/have_location]
        [/filter_condition]

        [message]
            speaker=Delfador
            message=_"Something does not feel right about those villages..."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=8,4
        [/filter]
        {NAMED_UNIT 2 (Skeleton) $x1 $y1 Rattles _"Rattles" ()}
        {UNIT 2 (Skeleton) $x1 $y1 ()}
        [if]
            [have_unit]
                id=Delfador
                x,y=8,4
            [/have_unit]
            [then]
                [message]
                    speaker=Rattles
                    message=_"Do you serve Iliah-Malal, living man?"
                    [option]
                        label=_"Yes, I serve him."
                        [command]
                            [message]
                                speaker=Rattles
                                message=_"Then you will not mind if we kill you! Hahahahah!"
                            [/message]
                        [/command]
                    [/option]
                    [option]
                        label=_"No, I do not."
                        [command]
                            [message]
                                speaker=Rattles
                                message=_"Then you will die forever!"
                            [/message]
                        [/command]
                    [/option]
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Rattles
                    message=_"Do you serve Iliah-Malal?"
                    [option]
                        label=_"Yes, I serve him."
                        [command]
                            [message]
                                speaker=Rattles
                                message=_"Then you will not mind if we destroy you! Hahahahah!"
                            [/message]
                        [/command]
                    [/option]
                    [option]
                        label=_"No, I do not."
                        [command]
                            [message]
                                speaker=Rattles
                                message=_"Then you will perish forever!"
                            [/message]
                        [/command]
                    [/option]
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=10,3
        [/filter]
        {NAMED_UNIT 2 (Skeleton) $x1 $y1 Bones _"Bones" ()}
        {UNIT 2 (Skeleton) $x1 $y1 ()}
        [if]
            [have_unit]
                id=Delfador
                x,y=10,3
            [/have_unit]
            [then]
                [message]
                    speaker=Bones
                    message=_"Iliah-Malal commands your death!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Bones
                    message=_"Iliah-Malal commands your destruction!"
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Delfador
            x=2-4,2-3
            y=6-7,8
        [/filter]

        # wmllint: local spelling An-Usrukhar eyeblink
        [message]
            #po: The Tomb Guardian's dialogue should sound especially archaic
            #po: and imperious. If your language has special forms for superior
            #po: addressing inferior, use them here.
            speaker=narrator
            message=_"WHO ENTERS THE TOMB OF AN-USRUKHAR?"
            image="portraits/tomb-guardian.png"
        [/message]
        [message]
            speaker=Delfador
            message=_"I... I am Delfador, a mage of Wesnoth."
        [/message]
        [message]
            speaker=narrator
            #po: "bestrode" = past tense of archaic verb "bestride", literally
            #po: meaning to straddle but with a secondary sense of "to
            #po: dominate", and connotations of gigantism.
            message=_"I am the will of An-Usrukhar, greatest of mages, he who bestrode Irdya in the morning of time, who sleeps now in a death beyond death until the unmaking of the world."
            image="portraits/tomb-guardian.png"
        [/message]
        [message]
            speaker=Delfador
            message=_"I am only a man, a living man seeking a way home from the house of the dead."
        [/message]
        [message]
            speaker=narrator
            message=_"Living...? I see that it is so. Your breath stirs dust that has lain untouched since the Primal Aeon. And it was foretold that one like you would come."
            image="portraits/tomb-guardian.png"
        [/message]
        [message]
            speaker=Delfador
            message=_"Foretold?"
        [/message]
        [message]
            speaker=narrator
            #po: "Aeon" is a variant form of the word English word "eon", used
            #po: for a long and indefinite span of time. The variant has
            #po: mystical connotations.
            message=_"Foretold in the Primal Aeon, years past beyond your counting. An-Usrukhar the Great, he of whom I am but the tiniest shade and fragment, foresaw in the Mirror of Evanescent Time that a living man would come here to be tested. AND I AM THE TEST!"
            image="portraits/tomb-guardian.png"
        [/message]
        [message]
            speaker=Delfador
            #po: "coil" is an archaism. In the English of around 1600, it was
            #po: used to refer to a difficulty or entanglement. Translate
            #po: freely.
            message=_"I have felt the coils of prophecy on me before. I am beginning to dislike them."
        [/message]
        [message]
            speaker=narrator
            message=_"It is only given to the small not to feel the hand of fate on their shoulder; the great must suffer its weight whether they will or no. Delfador, mage of Wesnoth, ARE YOU A SERVANT OF THE LIGHT?"
            image="portraits/tomb-guardian.png"
        [/message]
        [message]
            speaker=Delfador
            message=_"I serve my king and my kingdom."
        [/message]
        [message]
            speaker=narrator
            #po: The Tomb Guardian speaks closer to literal truth here than
            #po: Delfador can possibly know. It is now 470YW; in 501YW,
            #po: Garard II will be murdered by his wife and son, and the
            #po: usurpation of Asheviere will begin.
            message=_"Your king will die in an eyeblink and your kingdom in the drawing of a breath. Delfador, I ask you again, ARE YOU A SERVANT OF THE LIGHT?"
            image="portraits/tomb-guardian.png"
        [/message]
        [message]
            speaker=Delfador
            message=_"I serve my people and my land."
        [/message]
        [message]
            speaker=narrator
            #po: "matter" is used here with an archaic meaning, roughly
            #po: that of "ground" or "essence".  This sense survives in
            #po: modern English in constructions like "It matters a lot."
            message=_"Peoples vanish and lands wither under the pitiless gaze of eternity; the true matter of the world is deeper. Delfador, I ask you a third time, and on your answer hangs your life: ARE YOU A SERVANT OF THE LIGHT?"
            image="portraits/tomb-guardian.png"
        [/message]
        [message]
            speaker=Delfador
            message=_"I... I serve life against death. Love against fear. Light against darkness."
        [/message]
        [delay]
            time=1250
        [/delay]
        {FLASH_WHITE ()}
        [message]
            speaker=narrator
            message=_"IT IS WELL. Take up, O servant of light, the Staff of An-Usrukhar. The trials before you will be great. So is its power."
            image="portraits/tomb-guardian.png"
        [/message]

        # Let the staff be taken
        [terrain]
            x,y=3,7
            terrain=^
            layer=overlay
        [/terrain]
    [/event]

    [event]
        name=victory
        {CLEAR_VARIABLE delf_has_staff,heard_from_ghost}
    [/event]
[/scenario]
