#textdomain wesnoth-did

[scenario]
    id=10_Endless_Night
    name= _ "Endless Night"
    map_file=10_Endless_Night.map
    turns=unlimited
    next_scenario=10_Endless_Night
    victory_when_enemies_defeated=yes

    {UNDERGROUND}
    [time_area]
        x=27-31,26,21-25
        y=0-5,2-4,0-2
        {DEFAULT_SCHEDULE}
    [/time_area]

    [story]
        # a bit of extra text for the first round
        [if]
            {VARIABLE_CONDITIONAL timesForever numerical_equals 0}
            [then]
                [part]
                    music=transience.ogg
                    story= _ "Years pass. Every summer, by the time the mountainous paths and high passes shed their wintry gowns of snow, the lich sends his soldiers to attack the orcs, removing all human, elven, and dwarven patrols that impede them. Every year, the undead inflict some damage before being repelled."
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
                [part]
                    story= _ "The lich sometimes wonders if his endeavors are naught but a fruitless crusade, but then again, so what? Life, unlife, death... nothing has ever given his existence meaning. And yet, he still persists? For what?"
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
                [part]
                    story= _ "Reason and purpose..."
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
                [part]
                    story= _ "He needs none. Philosophy only begets misery. Violence and savagery have always been the essence of his existence, a conviction that he has only embraced more wholly in undeath. Better to simply kill without deliberation, without consideration. He has never been one for regrets."
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
                [part]
                    story= _ "Rumors circulate of a lich who preys on scouting patrols. A hero, gathering his loyal troops to him, decides to put an end to the evil."
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
            [/then]
        [/if]
        # These if statements are before the prestart event, so are off-by-one compared to the other checks of timesForever
        [if]
            {VARIABLE_CONDITIONAL timesForever numerical_equals 1}
            [then]
                [part]
                    music=transience.ogg
                    story= _ "Mal Keshar continues to study the book and re-reads the final entry."
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
                [part]
                    # po: This text comes from the epilogue of Secrets of the Ancients, edited to avoid revealing the name of the campaign or the names of the protagonists
                    story = _"“We prevailed today on the field, but our victory did not please me. I realize now... the world is not ready for our knowledge. They cannot understand that we have conquered that primordial fear: death. Instead, as they look upon us, judgment of our appearance drives them to ignorant terror. I give up on all of them. [...] In some future time, less conservative attitudes may dominate, and our knowledge can be put to good use. I can certainly afford to wait. In the meantime, we are doing what we can to hasten that day.”"
                    {STORYTXT_BACKGROUND book.jpg}
                [/part]
                [part]
                    # po: More text from the epilogue of Secrets of the Ancients
                    story= _ "“As for me, I will make my journal conspicuous on this battlefield. I suspect that most will fear it enough to try to destroy it, but I have placed several wards on my journal to protect it. This way, it should survive long enough to make its way into the hands of someone more open-minded. Tath, in particular, is home to many mages. It only takes one who is willing to learn...”"
                    {STORYTXT_BACKGROUND book.jpg}
                [/part]
            [/then]
        [/if]
        [if]
            {VARIABLE_CONDITIONAL timesForever numerical_equals 2}
            [then]
                [part]
                    # po: This text comes from the epilogue of Secrets of the Ancients, edited to avoid revealing the name of the campaign or the names of the protagonists
                    music=transience.ogg
                    story = _"“We prevailed today on the field, but our victory did not please me. I realize now... the world is not ready for our knowledge. They cannot understand that we have conquered that primordial fear: death. Instead, as they look upon us, judgment of our appearance drives them to ignorant terror. I give up on all of them. [...] In some future time, less conservative attitudes may dominate, and our knowledge can be put to good use. I can certainly afford to wait. In the meantime, we are doing what we can to hasten that day.”"
                    {STORYTXT_BACKGROUND book.jpg}
                [/part]
                [part]
                    # po: More text from the epilogue of Secrets of the Ancients
                    story= _ "“As for me, I will make my journal conspicuous on this battlefield. I suspect that most will fear it enough to try to destroy it, but I have placed several wards on my journal to protect it. This way, it should survive long enough to make its way into the hands of someone more open-minded. Tath, in particular, is home to many mages. It only takes one who is willing to learn...”"
                    {STORYTXT_BACKGROUND book.jpg}
                [/part]
                [part]
                    story= _ "The final entry gnaws at Mal Keshar. While he had been Darken Volk’s pawn, both of them were being used as pawns by the author of the book. Has his whole existence been nothing more than that of a puppet?"
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
                [part]
                    story= _ "Still, despite his misgivings about being manipulated, he feels that he can learn something from the book. Orcs had only ever been half of the story — the other had been his own people being unable to accept his use of dark magic. But, if he allowed a foolish hero to take a copy of the book, would others eventually follow in his footsteps? If enough people began to view necromancy as merely another magical art, could it eventually be accepted in society?"
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
            [/then]
        [/if]
        [if]
            {VARIABLE_CONDITIONAL timesForever greater_than 2}
            [then]
                [part]
                    music=transience.ogg
                    story= _ "The book still sits on a dusty shelf in Mal Keshar’s keep, untended and untouched, but constantly plaguing his mind."
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
                [part]
                    story= _ "If he allowed a foolish hero to take a copy of the book, would others eventually follow in his footsteps? Would the author’s plan actually work, or would people continue to view necromancy as only a corrupting power? One voice tells him that being accepted by society should not be of any concern to him. Another says that it would not hurt to try. He does not come to any conclusions, but a slightly embellished copy of the tome sits there in his lair, waiting to be taken."
                    {STORYTXT_BACKGROUND end.jpg}
                [/part]
            [/then]
        [/if]
    [/story]

    {DID_TRACK {JOURNEY_10_NEW}}

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        save_id=Malin Keshar
        recruit=Walking Corpse,Vampire Bat,Ghost,Ghoul,Skeleton Archer,Skeleton
        {GOLD 220 200 180}
        team_name=good
        village_gold=1
        user_team_name= _ "Mal Keshar"
        {FLAG_VARIANT undead}
        color=darkblue

        # wmllint: recognize Mal Keshar
        {CHARACTER_STATS_MAL_KESHAR}

        facing=ne
    [/side]
    # wmllint: validate-on

    # Foolish Hero
    [side]
        side=2
        controller=ai
        team_name=enemies
        # Place leader, grant gold, income and recruits later
        no_leader=yes
        gold=0
        {NO_INCOME}
        color=brown
        # Set ai values later
    [/side]

    # Too Foolish Hero
    [side]
        side=3
        controller=ai
        team_name=enemies
        # po: not yet decided who the enemy will be, or if there will be any
        user_team_name= _ "teamname^Void"
        # Place leader, grant gold, income and recruits later
        no_leader=yes
        hidden=yes
        gold=0
        {NO_INCOME}
        color=brown
        # Set ai values later
    [/side]

    # Monster
    [side]
        side=4
        team_name=monster
        user_team_name= _ "teamname^Inky"
        gold=0
        controller=ai
        no_leader=yes
        hidden=yes
        {NO_INCOME}
        color=orange
        [ai]
            aggression=0.9
            caution=0.1
            grouping=no
            simple_targeting=yes
            village_value=0
            {MODIFY_AI_DELETE_CANDIDATE_ACTION 4 main_loop villages}
            {MODIFY_AI_DELETE_CANDIDATE_ACTION 4 main_loop retreat_injured}
        [/ai]
    [/side]

    [side]
        side=5
        controller=null
        no_leader=yes
        hidden=yes
        team_name=fake
        # po: fake side for a single unit during a cutscene
        user_team_name= _ "teamname^Illusion"
        gold=0
        {NO_INCOME}
        color=darkblue
        # Using the same flag icon and color as the next side, one can't spot it in the top bar
        flag_icon=flags/undead-flag-icon.png
    [/side]

    {STARTING_VILLAGES 1 15}

    # ability macros
    {DID_SOUL_EATER1}
    {DID_SOUL_EATER2}
    {DID_SOUL_EATER3}

    [event]
        name=prestart

        {CLEAR_CORPSE_HORDE}

        # not as dark as the previous scenario, since that one is more RPG-like and lonelier
        {COLOR_ADJUST -10 -10 -10}

        {VARIABLE_OP timesForever add 1}
        {VARIABLE second_hero_arrived no}

        [objectives]
            side=1
            delayed_variable_substitution=yes #so timesForever note works correctly when using debug
            [objective]
                condition=win
                description= _ "Defeat the foolish hero"
                [show_if]
                    {VARIABLE_CONDITIONAL timesForever less_than_equal_to 1}
                [/show_if]
            [/objective]

            [objective]
                condition=win
                description= _ "Defeat another foolish hero"
                [show_if]
                    {VARIABLE_CONDITIONAL timesForever numerical_equals 2}
                [/show_if]
            [/objective]

            [objective]
                condition=win
                description= _ "Defeat yet another foolish hero"
                [show_if]
                    {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}
                    [and]
                        {VARIABLE_CONDITIONAL second_hero_arrived boolean_equals no}
                    [/and]
                [/show_if]
            [/objective]

            [objective]
                condition=win
                description= _ "Defeat both foolish heroes"
                [show_if]
                    {VARIABLE_CONDITIONAL second_hero_arrived boolean_equals yes}
                [/show_if]
            [/objective]

            [objective]
                condition=lose
                description= _ "Destruction of Mal Keshar"
                [show_if]
                    {VARIABLE_CONDITIONAL timesForever less_than_equal_to 2}
                [/show_if]
            [/objective]

            [objective]
                {ALTERNATIVE_OBJECTIVE_CAPTION}
                condition=win
                description= _ "Allow an enemy unit to take the book"
                [show_if]
                    {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}
                [/show_if]
            [/objective]

            [objective]
                {ALTERNATIVE_OBJECTIVE_CAPTION}
                condition=win
                description= _ "Destruction of Mal Keshar"
                [show_if]
                    {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}
                [/show_if]
            [/objective]

            [gold_carryover]
                carryover_percentage=40
            [/gold_carryover]

            [note]
                description="" + _ "Endless Night $timesForever" + ""
            [/note]

            {HAS_NO_TURN_LIMIT}

            # No {IS_LAST_SCENARIO}, because the player can win and keep on playing
        [/objectives]

        {MODIFY_UNIT (id=Mal Keshar) profile (portraits/malin_lich-ancient.png)}

        [if]
            {VARIABLE_CONDITIONAL timesForever greater_than 1}

            [then]
                {VARIABLE previous_previous_randomHero $previous_randomHero}
                {VARIABLE previous_randomHero $randomHero}
            [/then]

            [else]
                {VARIABLE previous_previous_randomHero -1}
                {VARIABLE previous_randomHero -1}
            [/else]
        [/if]

        # let's pick a random hero type...
        {VARIABLE_OP randomHero rand (human,bandit,elf,dwarf,orc)}

        # and make sure it's not the same as last time
        [while]
            {VARIABLE_CONDITIONAL randomHero equals $previous_randomHero}

            [or]
                {VARIABLE_CONDITIONAL randomHero equals $previous_previous_randomHero}
            [/or]

            [do]
                {VARIABLE_OP randomHero rand (human,bandit,elf,dwarf,orc)}
            [/do]
        [/while]

        [if]
            {VARIABLE_CONDITIONAL timesForever greater_than 4}

            [then]
                [replace_map]
                    map_file=10a_Endless_Night.map
                    expand=yes
                    shrink=yes
                [/replace_map]

                [time_area]
                    x=2
                    y=49
                    radius=3
                    [filter_radius]
                        [not]
                            terrain=X*^*
                        [/not]
                        [not]
                            x,y=5,50
                        [/not]
                    [/filter_radius]
                    {DEFAULT_SCHEDULE}
                [/time_area]

                # now it's truly endless night
                {COLOR_ADJUST -15 -15 -15}

                # don't let the two foolish heroes be from the same faction
                {VARIABLE_OP randomHero2 rand (human,bandit,elf,dwarf,orc)}

                [while]
                    {VARIABLE_CONDITIONAL randomHero2 equals $randomHero}

                    [do]
                        {VARIABLE_OP randomHero2 rand (human,bandit,elf,dwarf,orc)}
                    [/do]
                [/while]

                {VARIABLE_OP flankturn rand 5..10}

                [event]
                    name=new turn
                    [filter_condition]
                        [variable]
                            name=turn_number
                            numerical_equals=$flankturn
                        [/variable]
                    [/filter_condition]

                    # the text here is duplicated from below
                    [switch]
                        variable=randomHero2
                        [case]
                            value=human
                            [modify_side]
                                side=3
                                user_team_name= _ "Humans"
                                {FLAG_VARIANT loyalist}
                                color=gold
                                recruit=Spearman,Swordsman,Pikeman,Bowman,Longbowman,Heavy Infantryman,Shock Trooper,Mage,Red Mage,White Mage,Horseman,Knight,Lancer
                            [/modify_side]

                            [scroll_to]
                                x,y=2,50
                            [/scroll_to]

                            [move_unit_fake]
                                type="Royal Guard"
                                side=3
                                x= 2, 6, 8
                                y=50,49,46
                            [/move_unit_fake]

                            [unit]
                                side=3
                                type=Royal Guard
                                id=Too Foolish Hero
                                name= _ "Too Foolish Hero"
                                x,y=8,46
                                canrecruit=yes
                                animate=no
                                facing=ne
                            [/unit]

                            [terrain]
                                x,y=8,46
                                terrain=Ke
                            [/terrain]
                            [terrain]
                                x=   7,8-9,10
                                y=46-47,47,45-47
                                terrain=Ce
                            [/terrain]
                            [terrain]
                                x= 9, 5,12, 5
                                y=49,45,46,48
                                terrain=Uu^Vct
                            [/terrain]
                            [redraw][/redraw]

                            [capture_village]
                                side=3
                                x= 9, 5,12, 5
                                y=49,45,46,48
                            [/capture_village]

                            [message]
                                speaker=Too Foolish Hero
                                # po: the text that the "Too Foolish Hero" speaks is identical to that in the start event and can probably be copied over
                                message= _ "Your doom is at hand, lich! It is nigh time you answered for your evil crimes!"
                            [/message]

                            {INCIDENTAL_MUSIC loyalists.ogg}
                        [/case]

                        [case]
                            value=bandit
                            [modify_side]
                                side=3
                                user_team_name= _ "Bandits"
                                # default flag
                                flag=
                                flag_icon=
                                color=brown
                                recruit=Thug,Bandit,Footpad,Outlaw,Poacher,Trapper,Thief,Rogue
                            [/modify_side]

                            [scroll_to]
                                x,y=2,50
                            [/scroll_to]

                            [move_unit_fake]
                                type=Highwayman
                                side=3
                                x= 2, 6, 8
                                y=50,49,46
                            [/move_unit_fake]

                            [unit]
                                side=3
                                type=Highwayman
                                id=Too Foolish Hero
                                name= _ "Too Foolish Hero"
                                x,y=8,46
                                canrecruit=yes
                                animate=no
                                facing=ne
                            [/unit]

                            [terrain]
                                x,y=8,46
                                terrain=Ke
                            [/terrain]
                            [terrain]
                                x=   7,8-9,10
                                y=46-47,47,45-47
                                terrain=Ce
                            [/terrain]
                            [terrain]
                                x= 9, 5,12, 5
                                y=49,45,46,48
                                terrain=Uu^Vct
                            [/terrain]
                            [redraw][/redraw]

                            [capture_village]
                                side=3
                                x= 9, 5,12, 5
                                y=49,45,46,48
                            [/capture_village]

                            [message]
                                speaker=Too Foolish Hero
                                message= _ "You have preyed on too many of my men. Our territory will be much more secure without your undead pestering us."
                            [/message]

                            {INCIDENTAL_MUSIC knolls.ogg}
                        [/case]

                        [case]
                            value=elf
                            [modify_side]
                                side=3
                                user_team_name= _ "Elves"
                                {FLAG_VARIANT wood-elvish}
                                color=brown
                                recruit=Elvish Fighter,Elvish Hero,Elvish Captain,Elvish Archer,Elvish Ranger,Elvish Marksman,Elvish Shaman,Elvish Sorceress,Elvish Druid,Elvish Scout,Elvish Rider,Wose
                            [/modify_side]

                            [scroll_to]
                                x,y=2,50
                            [/scroll_to]

                            [move_unit_fake]
                                type="Elvish Marshal"
                                side=3
                                x= 2, 6, 8
                                y=50,49,46
                            [/move_unit_fake]

                            [unit]
                                side=3
                                type=Elvish Marshal
                                id=Too Foolish Hero
                                name= _ "Too Foolish Hero"
                                x,y=8,46
                                canrecruit=yes
                                animate=no
                                facing=ne
                            [/unit]

                            [terrain]
                                x,y=8,46
                                terrain=Ke
                            [/terrain]
                            [terrain]
                                x=   7,8-9,10
                                y=46-47,47,45-47
                                terrain=Ce
                            [/terrain]
                            [terrain]
                                x= 9, 5,12, 5
                                y=49,45,46,48
                                terrain=Uu^Vct
                            [/terrain]
                            [redraw][/redraw]

                            [capture_village]
                                side=3
                                x= 9, 5,12, 5
                                y=49,45,46,48
                            [/capture_village]

                            [message]
                                speaker=Too Foolish Hero
                                message= _ "We have finally found you, lich! Long have we heard of your abominable deeds, ensnaring the living with your dark sorceries and molding them into your slaves. Your wretched unlife ends here!"
                            [/message]

                            {INCIDENTAL_MUSIC elvish-theme.ogg}
                        [/case]

                        [case]
                            value=dwarf
                            [modify_side]
                                side=3
                                user_team_name= _ "Dwarves"
                                {FLAG_VARIANT knalgan}
                                color=brown
                                recruit=Dwarvish Fighter,Dwarvish Steelclad,Dwarvish Thunderer,Dwarvish Thunderguard,Dwarvish Stalwart,Dwarvish Guardsman,Dwarvish Ulfserker,Dwarvish Berserker,Dwarvish Scout,Dwarvish Pathfinder,Gryphon Rider,Gryphon Master
                            [/modify_side]

                            [scroll_to]
                                x,y=2,50
                            [/scroll_to]

                            [move_unit_fake]
                                type="Dwarvish Lord"
                                side=3
                                x= 2, 6, 8
                                y=50,49,46
                            [/move_unit_fake]

                            [unit]
                                side=3
                                type=Dwarvish Lord
                                id=Too Foolish Hero
                                name= _ "Too Foolish Hero"
                                x,y=8,46
                                canrecruit=yes
                                animate=no
                                facing=ne
                            [/unit]

                            [terrain]
                                x,y=8,46
                                terrain=Ke
                            [/terrain]
                            [terrain]
                                x=   7,8-9,10
                                y=46-47,47,45-47
                                terrain=Ce
                            [/terrain]
                            [terrain]
                                x= 9, 5,12, 5
                                y=49,45,46,48
                                terrain=Uu^Vct
                            [/terrain]
                            [redraw][/redraw]

                            [capture_village]
                                side=3
                                x= 9, 5,12, 5
                                y=49,45,46,48
                            [/capture_village]

                            [message]
                                speaker=Too Foolish Hero
                                # po: written with a dwarvish accent - regular english would be "it's been along time since I've smashed some undead. You've got plenty of bones for my hammer to break"
                                message= _ "Been a long time since I’ve smashed me some undead. Ye gots ye plenty o’ bones for me hammer ta break."
                            [/message]

                            {INCIDENTAL_MUSIC knalgan_theme.ogg}
                        [/case]

                        [case]
                            value=orc
                            [modify_side]
                                side=3
                                user_team_name= _ "Orcs"
                                {FLAG_VARIANT6 ragged}
                                color=white
                                recruit=Orcish Warrior,Orcish Slayer,Orcish Crossbowman,Troll,Troll Rocklobber
                            [/modify_side]

                            [scroll_to]
                                x,y=2,50
                            [/scroll_to]

                            [move_unit_fake]
                                type="Orcish Warlord"
                                side=3
                                x= 2, 6, 8
                                y=50,49,46
                            [/move_unit_fake]

                            [unit]
                                side=3
                                type=Orcish Warlord
                                id=Too Foolish Hero
                                name= _ "Too Foolish Hero"
                                x,y=8,46
                                canrecruit=yes
                                animate=no
                                facing=ne
                            [/unit]

                            [terrain]
                                x,y=8,46
                                terrain=Ke
                            [/terrain]
                            [terrain]
                                x=   7,8-9,10
                                y=46-47,47,45-47
                                terrain=Ce
                            [/terrain]
                            [terrain]
                                x= 9, 5,12, 5
                                y=49,45,46,48
                                terrain=Uu^Vct
                            [/terrain]
                            [redraw][/redraw]

                            [capture_village]
                                side=3
                                x= 9, 5,12, 5
                                y=49,45,46,48
                            [/capture_village]

                            {PLACE_IMAGE scenery/whitefang-flag.png 9 46}

                            [message]
                                speaker=Too Foolish Hero
                                message= _ "I’ve finally found your lair, lich! You have attacked my tribe and wreaked havoc on our homes for many years. You slew my father and turned his body into one of your nasty creations. With your death, your annoying minions will pester us no longer!"
                            [/message]

                            {INCIDENTAL_MUSIC northerners.ogg}
                        [/case]
                    [/switch]

                    [message]
                        speaker=Mal Keshar
                        message= _ "I almost feel as if the universe is mocking me by sending me this many imbeciles..."
                    [/message]

                    [modify_side]
                        side=3
                        hidden=no
#ifdef EASY
                        income="$(5 + 1 * $timesForever)"
#endif
#ifdef NORMAL
                        income="$(6 + 2 * $timesForever)"
#endif
#ifdef HARD
                        income="$(7 + 3 * $timesForever)"
#endif
                        # see comments on lines 886 and 887 regarding aggression
                        [ai]
                            aggression="$(min( [1.0, (0.3 + 0.1 * $timesForever) ] ) )"
                            villages_per_scout=10
                            village_value=0.5
                        [/ai]
                    [/modify_side]

                    {VARIABLE second_hero_arrived yes}

                    [show_objectives]
                        side=1
                    [/show_objectives]
                [/event]

                # Initial gold is given here at prestart, so that it will
                # be accounted as starting gold in the statistics
                [modify_side]
                    side=3
#ifdef EASY
                    gold="$(140 + 40 * $timesForever)"
#endif
#ifdef NORMAL
                    gold="$(170 + 50 * $timesForever)"
#endif
#ifdef HARD
                    gold="$(200 + 60 * $timesForever)"
#endif
                [/modify_side]
            [/then]
        [/if]

        [switch]
            variable=randomHero
            [case]
                value=human
                [unit]
                    side=2
                    type=Royal Guard
                    id=Foolish Hero
                    name= _ "Foolish Hero"
                    x,y=22,4
                    canrecruit=yes
                    facing=sw
                [/unit]

                [modify_side]
                    side=2
                    user_team_name= _ "Humans"
                    {FLAG_VARIANT loyalist}
                    color=gold
                    recruit=Spearman,Swordsman,Pikeman,Bowman,Longbowman,Heavy Infantryman,Shock Trooper,Mage,Red Mage,White Mage,Horseman,Knight,Lancer
                [/modify_side]

                # Hiding the existence of a second side by making flag and colors,
                # which can be seen in the top bar seen in the top bar,
                # look the same for both sides.
                [modify_side]
                    side=3
                    {FLAG_VARIANT loyalist}
                    color=gold
                [/modify_side]

                {REPLACE_SCENARIO_MUSIC loyalists.ogg}
            [/case]

            [case]
                value=bandit
                [unit]
                    side=2
                    type=Highwayman
                    id=Foolish Hero
                    name= _ "Foolish Hero"
                    x,y=22,4
                    canrecruit=yes
                    facing=sw
                [/unit]

                [modify_side]
                    side=2
                    user_team_name= _ "Bandits"
                    # default flag
                    recruit=Thug,Bandit,Footpad,Outlaw,Poacher,Trapper,Thief,Rogue
                [/modify_side]

                {REPLACE_SCENARIO_MUSIC knolls.ogg}
            [/case]

            [case]
                value=elf
                [unit]
                    side=2
                    type=Elvish Marshal
                    id=Foolish Hero
                    name= _ "Foolish Hero"
                    x,y=22,4
                    canrecruit=yes
                    facing=sw
                [/unit]

                [modify_side]
                    side=2
                    user_team_name= _ "Elves"
                    {FLAG_VARIANT wood-elvish}
                    recruit=Elvish Fighter,Elvish Hero,Elvish Captain,Elvish Archer,Elvish Ranger,Elvish Marksman,Elvish Shaman,Elvish Sorceress,Elvish Druid,Elvish Scout,Elvish Rider,Wose
                [/modify_side]

                [modify_side]
                    side=3
                    {FLAG_VARIANT wood-elvish}
                [/modify_side]

                {REPLACE_SCENARIO_MUSIC elvish-theme.ogg}
            [/case]

            [case]
                value=dwarf
                [unit]
                    side=2
                    type=Dwarvish Lord
                    id=Foolish Hero
                    name= _ "Foolish Hero"
                    x,y=22,4
                    canrecruit=yes
                    facing=sw
                [/unit]

                [modify_side]
                    side=2
                    user_team_name= _ "Dwarves"
                    {FLAG_VARIANT knalgan}
                    recruit=Dwarvish Fighter,Dwarvish Steelclad,Dwarvish Thunderer,Dwarvish Thunderguard,Dwarvish Stalwart,Dwarvish Guardsman,Dwarvish Ulfserker,Dwarvish Berserker,Dwarvish Scout,Dwarvish Pathfinder,Gryphon Rider,Gryphon Master
                [/modify_side]

                [modify_side]
                    side=3
                    {FLAG_VARIANT knalgan}
                [/modify_side]

                {REPLACE_SCENARIO_MUSIC knalgan_theme.ogg}
            [/case]

            [case]
                value=orc
                [unit]
                    side=2
                    type=Orcish Warlord
                    id=Foolish Hero
                    name= _ "Foolish Hero"
                    x,y=22,4
                    canrecruit=yes
                    facing=sw
                [/unit]

                [modify_side]
                    side=2
                    user_team_name= _ "Orcs"
                    {FLAG_VARIANT6 ragged}
                    color=white
                    recruit=Orcish Warrior,Orcish Slayer,Orcish Crossbowman,Troll,Troll Rocklobber
                [/modify_side]

                [modify_side]
                    side=3
                    {FLAG_VARIANT6 ragged}
                    color=white
                [/modify_side]

                {REPLACE_SCENARIO_MUSIC northerners.ogg}
            [/case]
        [/switch]

        [capture_village]
            side=2
            x=21,19,25,24
            y= 2, 5, 4, 6
        [/capture_village]

        # Give the foolish hero gold & income based on timesForever
        # Set ai aggression, it hits 1.0 at 7 timesForever, ensuring the enemy will attack.
        [modify_side]
            side=2
#ifdef EASY
            gold="$(200 + 40 * $timesForever)"
            income="$(5 + 5 * $timesForever)"
#endif
#ifdef NORMAL
            gold="$(230 + 50 * $timesForever)"
            income="$(6 + 6 * $timesForever)"
#endif
#ifdef HARD
            gold="$(260 + 60 * $timesForever)"
            income="$(7 + 7 * $timesForever)"
#endif
            [ai]
                aggression="$(min( [1.0, (0.3 + 0.1 * $timesForever) ] ) )"
                villages_per_scout=10
                village_value=0.5
            [/ai]
        [/modify_side]

        # play only sad music after a few repetitions
        [if]
            {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}
            [then]
                [music]
                    name=the_king_is_dead.ogg
                    append=yes
                [/music]
                [music]
                    name=weight_of_revenge.ogg
                    append=yes
                [/music]
                [music]
                    name=nunc_dimittis.ogg
                    append=yes
                [/music]

                # also give the reflection pool version 3 easter egg
                {PLACE_IMAGE items/ball-dark.png 20 43}
            [/then]
            [else]
                [music]
                    name=battle.ogg
                    append=yes
                [/music]
                [music]
                    name=casualties_of_war.ogg
                    append=yes
                [/music]
            [/else]
        [/if]

        [recall]
            type=Skeletal Dragon
            x,y=28,19
        [/recall]

        {PLACE_IMAGE scenery/black-monolith.png 21 27}
        {PLACE_IMAGE scenery/whirlpool.png 5 5}
    [/event]

    [event]
        name=start

        # Additional dialog depending on how many times the scenario has been played
        [switch]
            variable=timesForever
            [case]
                value=1
                # no additional dialog
            [/case]
            [case]
                value=2
                [message]
                    speaker=Mal Keshar
                    message= _ "I will destroy you like the last foolish hero who challenged me."
                [/message]
            [/case]
            [case]
                value=3
                [message]
                    speaker=Mal Keshar
                    message= _ "Another foolish hero? Seriously?"
                [/message]
            [/case]
            [case]
                value=4
                [message]
                    speaker=Mal Keshar
                    message= _ "Is there an endless supply of foolish heroes with death wishes? Honestly, where do you all come from?"
                [/message]
            [/case]
            [else]
                # 5 and up
                {RANDOM 1..4}
                [switch]
                    variable=random
                    [case]
                        value=1
                        [message]
                            speaker=Mal Keshar
                            message= _ "Am I doomed to fight foolish heroes forever?"
                        [/message]
                    [/case]
                    [case]
                        value=2
                        [message]
                            speaker=Mal Keshar
                            message= _ "How long is this going to keep happening?"
                        [/message]
                    [/case]
                    [case]
                        value=3
                        [message]
                            speaker=Mal Keshar
                            message= _ "..."
                        [/message]
                    [/case]
                    [else]
                        [message]
                            speaker=Mal Keshar
                            message= _ "At this point, I would be more surprised if these foolish heroes stopped showing up."
                        [/message]
                    [/else]
                [/switch]
                {CLEAR_VARIABLE random}
            [/else]
        [/switch]

        [switch]
            variable=randomHero
            [case]
                value=human
                [message]
                    speaker=Foolish Hero
                    message= _ "Your doom is at hand, lich! It is nigh time you answered for your crimes against humanity!"
                [/message]

                [message]
                    speaker=Mal Keshar
                    # po: cityfolk - just a person from the city, e.g. Weldyn
                    message= _ "Narrow-minded and obtuse, as one would expect of cityfolk. Go back to your manors and taverns before I decide to kill you."
                [/message]
            [/case]

            [case]
                value=bandit
                [message]
                    speaker=Foolish Hero
                    message= _ "You have preyed on too many of my men. Our territory will be much more secure without your undead pestering us."
                [/message]

                [message]
                    speaker=Mal Keshar
                    message= _ "Not even real soldiers. How meaningless."
                [/message]
            [/case]

            [case]
                value=elf
                [message]
                    speaker=Foolish Hero
                    message= _ "We have finally found you, lich! Long have we heard of your abominable deeds, ensnaring the living with your dark sorceries and molding them into your slaves. Your wretched unlife ends here!"
                [/message]

                [message]
                    speaker=Mal Keshar
                    message= _ "Life or death, it is all the same. There are always those who try to kill me. Ever do they fail."
                [/message]
            [/case]

            [case]
                value=dwarf
                [message]
                    speaker=Foolish Hero
                    # po: written with a dwarvish accent - regular english would be "it's been along time since I've smashed some undead. You've got plenty of bones for my hammer to break"
                    message= _ "Been a long time since I’ve smashed me some undead. Ye gots ye plenty o’ bones for me hammer ta break."
                [/message]

                [message]
                    speaker=Mal Keshar
                    message= _ "And it has been some time since I’ve had a supply of dwarven corpses to work with. I suppose I can put your hammers to good use in the mines."
                [/message]
            [/case]

            [case]
                value=orc

                {PLACE_IMAGE scenery/whitefang-flag.png 20 4}

                [message]
                    speaker=Foolish Hero
                    message= _ "I’ve finally found your lair, lich! You have attacked my tribe and wreaked havoc on our homes for many years. You slew my father and turned his body into one of your nasty creations. With your death, your annoying minions will pester us no longer!"
                [/message]

                [message]
                    speaker=Mal Keshar
                    message= _ "The Whitefang Orcs! It is you who despoiled my motherland and razed my home. It is you who forced me to resort to necromancy to protect myself. It is you who ended my mortal life and forced me to become a lich. And you desire vengeance? Hah! The irony of this would be hysterical if I could still feel such an emotion."
                [/message]
            [/case]
        [/switch]

        # Place the book, and add a victory event if the foolish hero's army
        # takes it. Should the unit have to make its way back to the enemy
        # keep? Probably not, Mal Keshar is going to let it go anyway; maybe
        # he should have to kill the first unit that picks it up and let a
        # second enemy pick it up, to make it more convincing for the foolish
        # hero.
        #
        # The dialog would be wrong if the hero picked up the book themselves,
        # but that's unlikely to happen, the hero is likely to stay on the keep
        # to recruit.
        [if]
            {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}
            [then]
                {PLACE_IMAGE (items/book5.png) 17 27}

                [event]
                    name=moveto
                    first_time_only=yes
                    [filter]
                        x,y=17,27
                        side=2,3
                    [/filter]

                    [remove_item]
                        x,y=$x1,$y1
                        image="items/book5.png"
                    [/remove_item]

                    [if]
                        [have_unit]
                            x,y=$x1,$y1
                            side=2
                        [/have_unit]
                        [then]
                            [role]
                                id=Foolish Hero
                                role=speakinghero
                            [/role]
                            {VARIABLE hero_type $randomHero}
                        [/then]
                        [else]
                            [role]
                                id=Too Foolish Hero
                                role=speakinghero
                            [/role]
                            {VARIABLE hero_type $randomHero2}
                        [/else]
                    [/if]
                    [switch]
                        variable=hero_type
                        [case]
                            value=human
                            [message]
                                speaker=unit
                                message= _ "That’s an evil grimoire!"
                            [/message]

                            [message]
                                role=speakinghero
                                message= _ "It might be linked to the lich’s power! Try burning it."
                            [/message]

                            [message]
                                speaker=Mal Keshar
                                message= _ "(faking pain) Aaargh!"
                            [/message]

                            [message]
                                role=unit
                                message= _ "It’s not catching fire!"
                            [/message]

                            [message]
                                role=speakinghero
                                message= _ "Still, it seems to be hurting the lich. Let us retreat and bring it with us. The mages may be able to destroy this and put an end to this lich."
                            [/message]
                        [/case]

                        [case]
                            value=bandit
                            [message]
                                speaker=unit
                                message= _ "That’s an evil grimoire!"
                            [/message]

                            [message]
                                role=speakinghero
                                message= _ "It might be linked to the lich’s power! Try burning it."
                            [/message]

                            [message]
                                speaker=Mal Keshar
                                message= _ "(faking pain) Aaargh!"
                            [/message]

                            [message]
                                role=unit
                                message= _ "It’s not catching fire!"
                            [/message]

                            [message]
                                role=speakinghero
                                message= _ "Still, it seems to be hurting the lich. Let us retreat and bring it with us. We may yet find another way to destroy it and put an end to this lich."
                            [/message]
                        [/case]

                        [case]
                            value=elf
                            [message]
                                speaker=unit
                                message= _ "That’s an evil grimoire!"
                            [/message]

                            [message]
                                role=speakinghero
                                # po: "faerie fire" as in the elvish sylph's attack
                                message= _ "It must be connected to the lich’s power. Perhaps if we burn it with faerie fire, the lich will be destroyed. Let us take it and retreat."
                            [/message]
                        [/case]

                        [case]
                            value=dwarf
                            [message]
                                speaker=unit
                                # po: regular english: That's an evil grimoire!
                                message= _ "That be an evil grimoire!"
                            [/message]

                            [message]
                                role=speakinghero
                                # po: regular english: Try destroying the darned thing.
                                message= _ "Try destroyin’ the blasted thing."
                            [/message]

                            [message]
                                speaker=Mal Keshar
                                message= _ "(faking pain) Aaargh!"
                            [/message]

                            [message]
                                speaker=unit
                                # po: regular english: My axe can't cut the paper. It's protected by magic!
                                message= _ "Me axe kinna cut tha paper. It be protected by magic!"
                            [/message]

                            [message]
                                role=speakinghero
                                # po: regular english: Yes, but the lich still seems to be hurt. Let's take it and retreat. Maybe the forge can destroy it.
                                message= _ "Aye, but the lich still seems ta be hurtin’. Let’s take it ’n retreat. Maybe tha forge ken destroy it."
                            [/message]
                        [/case]

                        [case]
                            value=orc
                            [message]
                                speaker=unit
                                # po: this orc has bad grammar on purpose
                                message= _ "Me like skull on book. It look good."
                            [/message]

                            [message]
                                role=speakinghero
                                message= _ "Idiot."
                            [/message]

                            [message]
                                speaker=Mal Keshar
                                message= _ "(faking pain) Aaargh!"
                            [/message]

                            [message]
                                speaker=unit
                                # po: still the same orc, still has bad grammar. Uuuuuh is a whine-like sound, indicating disappointment.
                                message= _ "Uuuuuh, I can’t pull skull off book, but lich scream."
                            [/message]

                            [message]
                                speaker=Mal Keshar
                                message= _ "Defend the book, my minions! Aaargh!"
                            [/message]

                            [message]
                                role=speakinghero
                                message= _ "The book must be connected to the lich’s power! Take it and retreat. Once we smash that book, the lich should be destroyed."
                            [/message]
                        [/case]
                    [/switch]

                    [story]
                        title= _ "Epilogue"
                        [part]
                            story= _ "The foolish hero was tricked, and left believing both that the book could be destroyed, and that the lich might be weakened by doing so."
                            {STORYTXT_BACKGROUND end.jpg}
                        [/part]
                        [part]
                            story= _ "Retreating outside the cave, the foolish hero tried to destroy the book. None of the attempts left so much as a single dent or char, yet each one caused another scream to echo from the cave mouth. Eventually, the cave entrance collapsed, and everything was still. Satisfied, the foolish hero left the ruined lair behind, book stowed away safely — and secretly — in his pack."
                            {STORYTXT_BACKGROUND end.jpg}
                        [/part]
                        [part]
                            story= _ "Years pass. Every summer, by the time the mountainous paths and high passes shed their wintry gowns of snow, humans, elves and dwarves patrol to resist orcish raiders. Undead no longer trouble the watches and memories of the lich fade to mere legend."
                            {STORYTXT_BACKGROUND end.jpg}
                        [/part]
                        [part]
                            story= _ "Rumors circulate about a spirit of good fortune that protects these guards. It is said that when attacked by orcs at night, the darkness itself descends to repel the assailants."
                            {STORYTXT_BACKGROUND end.jpg}
                        [/part]
                    [/story]

                    [endlevel]
                        next_scenario=null
                        carryover_report=no
                        save=no
                        linger_mode=no
                    [/endlevel]
                [/event]
            [/then]
        [/if]
    [/event]

    # monolith
    [event]
        name=moveto
        [filter]
            x,y=21,27
            id=Mal Keshar
        [/filter]
        [if]
            {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}
            [then]
                [message]
                    speaker=narrator
                    message= _ "A monolith of black stone, a dark surface reflecting deep shadow infinitely into the night."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=narrator
                    message= _ "A monolith of black stone, cold and brittle to the touch."
                [/message]
            [/else]
        [/if]
    [/event]

    # whirlpool
    # let's give Mal Keshar at least a bit of character
    # he's not allllll doom and gloom, is he?
    [event]
        name=moveto
        [filter]
            x,y=5,5
        [/filter]
        [unit]
            x,y=5,5
            type=Cuttle Fish
            id=Inky
            name= _ "female^Inky"
            gender=female
            side=4
            animate=yes
            [status]
                # Will escape upon defeat, won't be eaten
                unplagueable=yes
            [/status]
        [/unit]
        [message]
            speaker=Inky
            # po: this is just some kind of squishy sound that a squid might make
            message= _ "Gllllbbbg!"
        [/message]
        [if]
            {VARIABLE_CONDITIONAL metInky numerical_equals 0}
            [then]
                [message]
                    speaker=Mal Keshar
                    message= _ "A cuttlefish! Perhaps I shall make it my pet."
                [/message]
                {VARIABLE metInky 1}
            [/then]
            [else]
                # po: squiddy means "squid-like" in this sentence
                [message]
                    speaker=Mal Keshar
                    message= _ "We meet again, squiddy one."
                [/message]
            [/else]
        [/if]
    [/event]
    [event]
        name=die
        [filter]
            id=Inky
        [/filter]

        [if]
            [not]
                {VARIABLE_CONDITIONAL second_unit.side numerical_equals 1}
            [/not]
            [then]
                [message]
                    # wmllint: deathcheck off
                    speaker=Inky
                    # wmllint: deathcheck on
                    message= _ "Bloub°°°"
                [/message]
            [/then]
            [elseif]
                {VARIABLE_CONDITIONAL metInky numerical_equals 1}
                [then]
                    # yes, Inky is a she
                    [message]
                        speaker=Mal Keshar
                        message= _ "Curses. She got away."
                    [/message]
                    {VARIABLE metInky 2}
                [/then]
            [/elseif]
            [else]
                # This scenario (Endless_Night) repeats itself. To trigger this branch the player has to kill Inky two times.
                [message]
                    speaker=Mal Keshar
                    message= _ "It appears that she has evaded me once again."
                [/message]
            [/else]
        [/if]
    [/event]

    # reflection pool 3
    [event]
        name=moveto
        [filter]
            x,y=20,43
            id=Mal Keshar
        [/filter]
        [filter_condition]
            {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}
        [/filter_condition]
        [switch]
            variable=reflectionPool
            [case]
                value=0
                [message]
                    speaker=Mal Keshar
                    message= _ "I remember this place. It swirls with strange energy, like a pool of memories."
                [/message]

                [unit]
                    id=Drogan
                    name= _ "Drogan"
                    type=Lieutenant
                    side=5
                    x,y=21,44
                    profile=portraits/drogan.png
                    canrecruit=yes
                    unrenamable=yes
                    facing=nw
                    animate=yes
                [/unit]

                [message]
                    speaker=Drogan
                    #wmllint: local spelling ol'
                    # po: the first sentence in plain english is: Do you still remember the good old days? In the rest of the text, ’n means "and"
                    message= _ "D’ya still ’member tha good ol’ days? When you were little, ’n yer father had no time fer ya, we used ta train together in tha fields. Just you ’n me fer hours on end, practicin’ with our swords ’n havin’ fun."
                [/message]

                [message]
                    speaker=Drogan
                    message= _ "It were so much simpler back then, without yer complicated magic ’n yer crazy education ta mess things up. Don’t ya think so, Malin?"
                [/message]

                [delay]
                    time=1500
                [/delay]

                [message]
                    speaker=Mal Keshar
                    message= _ "That name is no longer mine."
                [/message]

                [kill]
                    id=Drogan
                [/kill]
                {VARIABLE_OP reflectionPool add 1}
            [/case]
            [case]
                value=1
                [message]
                    speaker=Mal Keshar
                    message= _ "What does the darkness have in store for me this time?"
                [/message]

                [unit]
                    type=Frontier Baroness
                    id=Dela Keshar
                    name= _ "Dela Keshar"
                    profile=portraits/dela.png
                    canrecruit=yes
                    unrenamable=yes
                    side=5
                    x,y=21,44
                    animate=yes
                    facing=nw
                [/unit]

                [message]
                    speaker=Dela Keshar
                    message= _ "I guess we were never that close, but you were still my brother. When you went to Alduin fer those eight years, I was so lonely, ya know? Bein’ the daughter of a baron, it was real hard to make any real friends. It was always just people tryin’ to be nice and friendly just to get something out of me. People didn’t care about me. They only cared about my title."
                [/message]

                [message]
                    speaker=Dela Keshar
                    message= _ "When you first came back from Alduin, I was so, so happy to see ya. I thought you and me and pa could finally be a family again and I’d finally have someone I could talk to as just, you know, a friend. And then ya went and screwed it all up by turnin’ to that dark magic of yours. You don’t know how much that hurt me. You really don’t, Malin."
                [/message]

                [delay]
                    time=1500
                [/delay]

                [message]
                    speaker=Mal Keshar
                    message= _ "That is not my name."
                [/message]

                [kill]
                    id=Dela Keshar
                [/kill]
                {VARIABLE_OP reflectionPool add 1}
            [/case]
            [case]
                value=2
                [unit]
                    type=Necromancer
                    id=Darken Volk
                    name= _ "Darken Volk"
                    profile=portraits/darken_volk.png
                    canrecruit=yes
                    unrenamable=yes
                    side=5
                    x,y=21,44
                    animate=yes
                    facing=nw
                [/unit]

                [message]
                    speaker=Darken Volk
                    message= _ "A necromancer’s existence is a solitary one. Though we may be surrounded by hordes of the undead, it is a scarce occasion that we interact with another truly sentient being. In all my years of travels, you were my first and only apprentice."
                [/message]

                [message]
                    speaker=Darken Volk
                    message= _ "I taught you everything I knew. I imparted you with all the power you needed to accomplish your goals. I thought that in return, you would afford me a single, small favor, and that I would not ask more of you. How did you repay me? By betraying me using the very skills I taught you! You are a cursed soul, Mal Keshar the Damned!"
                [/message]

                [kill]
                    id=Darken Volk
                [/kill]

                [delay]
                    time=1500
                [/delay]

                # he's losing it...
                [message]
                    speaker=Mal Keshar
                    message= _ "Hah."
                [/message]

                [message]
                    speaker=Mal Keshar
                    message= _ "Hahahahaha."
                [/message]

                [message]
                    speaker=Mal Keshar
                    message= _ "HAHAHAHAHAHAHAHAHA."
                [/message]

                [delay]
                    time=1500
                [/delay]

                [message]
                    speaker=Mal Keshar
                    message= _ "That is indeed my name."
                [/message]

                {VARIABLE_OP reflectionPool add 1}
            [/case]
            [else]
                [message]
                    speaker=narrator
                    message= _ "Mal Keshar stares into the abyss, oddly at ease alone amongst the darkness."
                [/message]
            [/else]
        [/switch]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Mal Keshar
        [/filter]

        [if]
            {VARIABLE_CONDITIONAL timesForever greater_than_equal_to 3}

            # after a few repetitions, we'll let the campaign really end
            # when Malin dies
            [then]
                [if]
                    [have_unit]
                        x,y=$x2,$y2
                        side=2
                    [/have_unit]
                    [then]
                        [role]
                            id=Foolish Hero
                            role=speakinghero
                        [/role]
                        [role]
                            side=2
                            [not]
                                canrecruit=yes
                            [/not]
                            role=second
                        [/role]
                        {VARIABLE hero_type $randomHero}
                    [/then]
                    [else]
                        [role]
                            id=Too Foolish Hero
                            role=speakinghero
                        [/role]
                        [role]
                            side=3
                            [not]
                                canrecruit=yes
                            [/not]
                            role=second
                        [/role]
                        {VARIABLE hero_type $randomHero2}
                    [/else]
                [/if]

                [music]
                    name=journeys_end.ogg
                    immediate=yes
                    append=no
                [/music]

                [switch]
                    variable=hero_type
                    [case]
                        value=human
                        [message]
                            speaker=Mal Keshar
                            message= _ "Slain by those who were once my countrymen..."
                        [/message]

                        [kill]
                            id=Mal Keshar
                            animate=yes
                        [/kill]

                        [message]
                            role=speakinghero
                            message= _ "His evil deeds have come to an end."
                        [/message]

                        [message]
                            role=second
                            message= _ "Who do you think he was before he was corrupted by the darkness?"
                        [/message]

                        [message]
                            role=speakinghero
                            message= _ "It matters not. He embraced death over life, and thus relinquished his right to mercy. Let us return home; the town will need us to defend against the orcish raids."
                        [/message]

                        [message]
                            role=second
                            message= _ "Yes, sir."
                        [/message]
                    [/case]

                    [case]
                        value=bandit
                        [message]
                            speaker=Mal Keshar
                            message= _ "Darkness descends... and I..."
                        [/message]

                        [kill]
                            id=Mal Keshar
                            animate=yes
                        [/kill]

                        [message]
                            role=speakinghero
                            message= _ "It’s done. He’ll trouble us no more."
                        [/message]

                        [message]
                            role=second
                            message= _ "Who do you think he was before becoming a lich?"
                        [/message]

                        [message]
                            role=speakinghero
                            message= _ "Likely one of those arrogant mages who think themselves superior to everyone else. He probably learned necromancy just to subjugate people like us."
                        [/message]

                        [message]
                            role=second
                            message= _ "So he was an evil tyrant. How dreadful."
                        [/message]

                        [message]
                            role=speakinghero
                            message= _ "Probably. Anyway, there’s no use in dwelling upon one so wicked. Let’s go."
                        [/message]
                    [/case]

                    [case]
                        value=elf
                        [message]
                            speaker=Mal Keshar
                            message= _ "Darkness descends... and I..."
                        [/message]

                        [kill]
                            id=Mal Keshar
                            animate=yes
                        [/kill]

                        [message]
                            role=speakinghero
                            message= _ "Well, that is the end of his evil ways."
                        [/message]

                        [message]
                            role=second
                            message= _ "I wonder who this lich was in life before he turned to the evil that is undeath."
                        [/message]

                        [message]
                            role=speakinghero
                            message= _ "A selfish human, only greedy for power while utterly indifferent to anything but himself. A necromancer’s only purpose is to work for their own gain, nothing else."
                        [/message]

                        [message]
                            role=second
                            message= _ "Pure evil, that is what they are."
                        [/message]

                        [message]
                            role=speakinghero
                            message= _ "Indeed. We need not afford this one any compassion. Let us leave this miserable place."
                        [/message]
                    [/case]

                    [case]
                        value=dwarf
                        [message]
                            speaker=Mal Keshar
                            message= _ "Darkness descends... and I..."
                        [/message]

                        [kill]
                            id=Mal Keshar
                            animate=yes
                        [/kill]

                        [message]
                            role=speakinghero
                            # po: regular english - the lich is nothing but a pile of bones now
                            message= _ "Tha lich be nae but a pile o’ bones now."
                        [/message]

                        [message]
                            role=second
                            # po: regular english - I wonder what kind of human he was in life
                            message= _ "I wonder what kind o’ human he did be in life."
                        [/message]

                        [message]
                            role=speakinghero
                            # po: regular english - I guess he was some crazy mage who wanted to make other humans his slaves. Why else do you think he would turn to dark magic?
                            message= _ "Me guess be that he be some loonie mage who wanted ta make other humans inta ’is slaves. Why else d’ye think tha lad woul’ turn ta dark magic?"
                        [/message]

                        [message]
                            role=second
                            # po: regular english - I don't know. You think the lich's castle can be useful
                            message= _ "I dinna know. Ye think tha lich’s castle ken be useful?"
                        [/message]

                        [message]
                            role=speakinghero
                            # po: regular english - Yes. Let's get to work.
                            message= _ "Aye. Let’s git to workin’."
                        [/message]
                    [/case]

                    [case]
                        value=orc
                        [message]
                            speaker=Mal Keshar
                            message= _ "Felled by an orc... so it ends... like this..."
                        [/message]

                        [kill]
                            id=Mal Keshar
                            animate=yes
                        [/kill]

                        [message]
                            role=speakinghero
                            message= _ "The lich is dead! I have finally avenged my father."
                        [/message]

                        [message]
                            role=second
                            message= _ "Who you think he was, boss?"
                        [/message]

                        [message]
                            role=speakinghero
                            message= _ "Just some angst-ridden mage who turned to dark magic when he swore some stupid quest for revenge upon us. Amusing that he was more bothersome in death than in life. Annoying that it took so long to kill him."
                        [/message]

                        # easter egg text
                        [if]
                            [variable]
                                name=x1
                                numerical_equals=17
                            [/variable]
                            [and]
                                [variable]
                                    name=y1
                                    numerical_equals=27
                                [/variable]
                            [/and]
                            [and]
                                [variable]
                                    name=timesForever
                                    greater_than=5
                                [/variable]
                            [/and]
                            [then]
                                [message]
                                    role=second
                                    message= _ "Boss, look! The lich dropped a shiny book!"
                                [/message]

                                [message]
                                    role=speakinghero
                                    message= _ "Well, what is it?"
                                [/message]

                                [message]
                                    role=second
                                    message= _ "I don’t know, but it looks like someone wrote something inside! It says:"
                                [/message]

                                [message]
                                    speaker=narrator
                                    image=items/book2.png
                                    # po: hahaha is Zephrin laughing
                                    # po: this line sounds very "modern-day" but that's intentional because it's an easter egg, not meant to be taken strictly at face value
                                    message= _ "That stupid memory came back to bother me again today. It was that time at the Academy when Zephrin and I were arguing about orcs. I still remember that hoarse voice of his telling me, ‘Fun story, Malin, but you really should put a disclaimer. You know, to make sure everyone understands no orcs were harmed in the making of this story, hahaha.’

I can still hear his infernal cackling ringing in my head. Sure thing, Zephrin, right... like my whole life was some sort of work of fiction!"
                                [/message]

                                [message]
                                    role=speakinghero
                                    # po: Bah is an exclamation of disgust or irritation
                                    message= _ "Bah! Do these people believe that we are fools? They must think we are all actors in a poorly written drama! I’ve had enough of this. I’m going home."
                                [/message]
                            [/then]
                            [else]
                                [message]
                                    role=speakinghero
                                    message= _ "Anyway, round up the wolves. I’m going home."
                                [/message]
                            [/else]
                        [/if]
                    [/case]
                [/switch]

                [endlevel]
                    next_scenario=null
                    carryover_report=no
                    save=no
                    linger_mode=no
                [/endlevel]
            [/then]

            # Normal defeat condition before sufficient repetitions
            # putting the HERODEATH_MALIN_LICH macro here doesn't seem to work
            [else]
                [message]
                    speaker=unit
                    message= _ "... Then my battle against the orcs is lost!"
                [/message]

                [endlevel]
                    result=defeat
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=enemies defeated

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


#textdomain wesnoth-did
[unit_type]
    id=Apprentice Mage
    name=_ "Apprentice Mage"
    race=human
    gender=male
    image="units/apprentice-mage.png"
    hitpoints=38
    movement_type=smallfoot
    movement=6
    experience=60
    level=1
    alignment=neutral
    advances_to=Apprentice Necromancer
    cost=15
    usage=mixed fighter
    description=_ "Trained in swordsmanship as a boy and the magical arts as a young man, Malin Keshar is talented at both but an expert in neither. Although not as powerful as other fighters in direct combat, Malin’s sharp wit often allows him to outsmart his foes without putting himself in much danger."
    {DEFENSE_ANIM "units/apprentice-mage-defend.png" "units/apprentice-mage-sword.png" {SOUND_LIST:HUMAN_HIT} }
    die_sound={SOUND_LIST:HUMAN_DIE}
    [attack]
        name=short sword
        #textdomain wesnoth-units
        description=_ "short sword"
        #textdomain wesnoth-did
        icon=attacks/sword-human-short.png
        type=blade
        range=melee
        damage=4
        number=3
    [/attack]
    [attack]
        name=magic blast
        description=_ "magic blast"
        icon="attacks/mud-glob.png" # dark missile is next level up
        type=impact
        range=ranged
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage=6
        number=2
    [/attack]
    [attack_anim]
        [filter_attack]
            name=magic blast
        [/filter_attack]

        start_time=-350
        missile_start_time=-100
        halo_start_time=-250

        [missile_frame]
            duration=200
            image="projectiles/darkmissile-n.png"
            image_diagonal="projectiles/darkmissile-ne.png"
        [/missile_frame]

        [frame]
            image="units/apprentice-mage-magic-[1~2].png:[75,300]"
        [/frame]

        [halo_frame]
            halo="halo/undead/dark-magic-[1~6].png~O(35%):50"
            halo_y=10
            halo_x=5
            auto_vflip=no
        [/halo_frame]

        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -100}
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=short sword
        [/filter_attack]

        start_time=-175

        [frame]
            image="units/apprentice-mage-sword.png:25"
        [/frame]
        [frame]
            image="units/apprentice-mage-sword-[1~3].png:[75,150,75]"
        [/frame]
        [frame]
            image="units/apprentice-mage.png:50"
        [/frame]

        {SOUND:HIT_AND_MISS {SOUND_LIST:SWORD_SWISH} {SOUND_LIST:MISS} -75}
    [/attack_anim]
    [recruiting_anim]
        [filter_second]
            race=undead
        [/filter_second]

        start_time=-375
        sound_start_time=-40

        [frame]
            image="units/apprentice-mage-magic-1.png:75"
        [/frame]
        [frame]
            image="units/apprentice-mage-magic-2.png"
            halo=halo/undead/dark-magic-[1~6].png:50
            halo_x,halo_y=12,-6
        [/frame]
        [frame]
            image="units/apprentice-mage-magic-2.png:50"
        [/frame]
        [frame]
            image="units/apprentice-mage.png:10"
        [/frame]

        [sound_frame]
            sound=magic-dark.ogg
        [/sound_frame]
    [/recruiting_anim]
[/unit_type]


#textdomain wesnoth-did
[unit_type]
    id=Apprentice Necromancer
    name=_ "Apprentice Necromancer"
    race=human
    image="units/apprentice-necromancer.png"
    hitpoints=52
    movement_type=smallfoot
    movement=6
    experience=90
    level=2
    alignment=neutral
    advances_to=Dark Mage
    gender=male
    usage=mixed fighter
    description=_ "Under Darken Volk’s tutelage, Malin has become adept at wielding necromancy both as a tool to raise an army of undead, and as a means to increase his own, personal power. Malin’s focus on improving his magical prowess has left little time for him to improve his swordsmanship, but he still holds on to his short sword as his melee weapon of choice."
    {DEFENSE_ANIM "units/apprentice-necromancer-defend.png" "units/apprentice-necromancer.png" {SOUND_LIST:HUMAN_HIT} }
    die_sound={SOUND_LIST:HUMAN_DIE}
    [attack]
        name=short sword
        #textdomain wesnoth-units
        description=_ "short sword"
        icon=attacks/sword-human-short.png
        type=blade
        range=melee
        damage=6
        number=3
    [/attack]
    [attack]
        name=chill wave
        description=_"chill wave"
        type=cold
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=13
        number=2
        icon=attacks/iceball.png
    [/attack]
    [attack]
        name=shadow wave
        description=_"shadow wave"
        #textdomain wesnoth-did
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=9
        number=2
        icon=attacks/dark-missile.png
    [/attack]
    [attack_anim]
        [filter_attack]
            name=chill wave
        [/filter_attack]

        {MISSILE_FRAME_CHILL_WAVE 0 -5}

        start_time=-355
        [frame]
            image="units/apprentice-necromancer-magic-[1~2].png:75"
        [/frame]
        [frame]
            image="units/apprentice-necromancer-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -120}
        [frame]
            image="units/apprentice-necromancer-magic-[2~1].png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=shadow wave
        [/filter_attack]

        {MISSILE_FRAME_SHADOW_WAVE}

        start_time=-675
        [frame]
            image="units/apprentice-necromancer-magic-[1~2].png:75"
        [/frame]
        [frame]
            image="units/apprentice-necromancer-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        [frame]
            image="units/apprentice-necromancer-magic-3.png:200"
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -120}
        [frame]
            image="units/apprentice-necromancer-magic-[2~1].png:50"
        [/frame]
        [frame]
            image="units/apprentice-necromancer.png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=corpse launch
        [/filter_attack]

        {MISSILE_FRAME_SHADOW_WAVE}

        start_time=-675
        [frame]
            image="units/apprentice-necromancer-magic-[1~2].png:75"
        [/frame]
        [frame]
            image="units/apprentice-necromancer-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        [frame]
            image="units/apprentice-necromancer-magic-3.png:200"
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -120}
        [frame]
            image="units/apprentice-necromancer-magic-[2~1].png:50"
        [/frame]
        [frame]
            image="units/apprentice-necromancer.png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=short sword
        [/filter_attack]

        start_time=-225

        [frame]
            image="units/apprentice-necromancer-magic-1.png:50"
        [/frame]
        [frame]
            image="units/apprentice-necromancer-sword-[1~2].png:[100,275]"
        [/frame]
        [frame]
            image="units/apprentice-necromancer.png:75"
        [/frame]

        {SOUND:HIT_AND_MISS {SOUND_LIST:SWORD_SWISH} {SOUND_LIST:MISS} -75}
    [/attack_anim]
    [recruiting_anim]
        [filter_second]
            race=undead
        [/filter_second]

        start_time=-300
        sound_start_time=-75

        [frame]
            image="units/apprentice-necromancer-magic-[1,2].png:75"
        [/frame]
        [frame]
            image="units/apprentice-necromancer-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        [frame]
            image="units/apprentice-necromancer-magic-[2,1].png:50"
        [/frame]
        [frame]
            image="units/apprentice-necromancer.png:1"
        [/frame]

        [sound_frame]
            sound=magic-dark.ogg
        [/sound_frame]
    [/recruiting_anim]
[/unit_type]


#textdomain wesnoth-did
[unit_type]
    id=Dark Mage
    name= _ "Dark Mage"
    race=human
    image="units/dark-mage.png"
    hitpoints=67
    movement_type=smallfoot
    movement=6
    experience=150
    level=3
    alignment=chaotic
    advances_to=null
    {AMLA_DEFAULT}
    cost=50
    usage=mixed fighter
    description= _ "Although Malin’s sword has grown rusty from lack of proper care, he continues to use it for melee combat, perhaps more as a keepsake than an effective weapon. His increasing skill with magic, however, is more than enough to compensate."
    die_sound={SOUND_LIST:HUMAN_DIE}
    {DEFENSE_ANIM "units/dark-mage-defend.png" "units/dark-mage.png" {SOUND_LIST:HUMAN_HIT} }
    [attack]
        name=short sword
        #textdomain wesnoth-units
        description=_ "short sword"
        icon=attacks/sword-human-short.png
        type=blade
        range=melee
        damage=5
        number=3
    [/attack]
    [attack]
        name=chill wave
        description=_"chill wave"
        type=cold
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=15
        number=2
        icon=attacks/iceball.png
    [/attack]
    [attack]
        name=shadow wave
        description=_"shadow wave"
        #textdomain wesnoth-did
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=10
        number=2
        icon=attacks/dark-missile.png
    [/attack]
    [attack_anim]
        [filter_attack]
            name=chill wave
        [/filter_attack]

        {MISSILE_FRAME_CHILL_WAVE 0 -5}

        start_time=-355
        [frame]
            image="units/dark-mage-magic-[1~2].png:75"
        [/frame]
        [frame]
            image="units/dark-mage-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -120}
        [frame]
            image="units/dark-mage-magic-[2~1].png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=shadow wave
        [/filter_attack]

        {MISSILE_FRAME_SHADOW_WAVE}

        start_time=-675
        [frame]
            image="units/dark-mage-magic-[1~2].png:75"
        [/frame]
        [frame]
            image="units/dark-mage-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        [frame]
            image="units/dark-mage-magic-3.png:250"
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -50}
        [frame]
            image="units/dark-mage-magic-[2~1].png:50"
        [/frame]
        [frame]
            image="units/dark-mage.png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=corpse launch
        [/filter_attack]

        {MISSILE_FRAME_SHADOW_WAVE}

        start_time=-675
        [frame]
            image="units/dark-mage-magic-[1~2].png:75"
        [/frame]
        [frame]
            image="units/dark-mage-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        [frame]
            image="units/dark-mage-magic-3.png:250"
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -50}
        [frame]
            image="units/dark-mage-magic-[2~1].png:50"
        [/frame]
        [frame]
            image="units/dark-mage.png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=short sword
        [/filter_attack]

        start_time=-225

        [frame]
            image="units/dark-mage-magic-1.png:50"
        [/frame]
        [frame]
            image="units/dark-mage-sword-[1~2].png:[100,275]"
        [/frame]
        [frame]
            image="units/dark-mage.png:75"
        [/frame]

        {SOUND:HIT_AND_MISS {SOUND_LIST:SWORD_SWISH} {SOUND_LIST:MISS} -75}
    [/attack_anim]
    [recruiting_anim]
        [filter_second]
            race=undead
        [/filter_second]

        start_time=-300
        sound_start_time=-75

        [frame]
            image="units/dark-mage-magic-[1,2].png:75"
        [/frame]
        [frame]
            image="units/dark-mage-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        [frame]
            image="units/dark-mage-magic-[2,1].png:50"
        [/frame]
        [frame]
            image="units/dark-mage.png:1"
        [/frame]

        [sound_frame]
            sound=magic-dark.ogg
        [/sound_frame]
    [/recruiting_anim]
[/unit_type]


#textdomain wesnoth-did
[unit_type]
    # Malin’s older sister, an Outlaw Princess with altered description.
    # Pictures taken from The Rise of Wesnoth.
    id=Frontier Baroness
    name= _ "female^Frontier Baroness"
    race=human
    gender=female
    image="units/neutral-outlaw-princess.png"
    hitpoints=46
    movement_type=elusivefoot
    movement=7
    experience=100
    level=2
    alignment=neutral
    advances_to=null
    {AMLA_DEFAULT}
    cost=50
    [abilities]
        {ABILITY_SKIRMISHER}
    [/abilities]
    usage=mixed fighter
    description= _ "At Wesnoth’s frontiers, all able-bodied men and women must be able to defend their homes in times of need. Men are most often trained in the use of sword or bow and are used as soldiers who withstand the brunt of orcish assaults to hold the raiders at bay. Women, instead, learn to use the staff and sling and are most effective as scouts and ambushers. The most proficient are powerful skirmishers and are highly adept at reconnaissance, allowing them to often outmaneuver and entrap orcish raiders."
    die_sound={SOUND_LIST:HUMAN_FEMALE_DIE}
    [defend]
        hits=miss

        [frame]
            image="units/neutral-outlaw-princess.png:1"
        [/frame]
        [frame]
            image="units/neutral-outlaw-princess-defend-1-[1,2,1].png:[83*2,84]"
        [/frame]
        [frame]
            image="units/neutral-outlaw-princess.png:100"
        [/frame]
    [/defend]
    [defend]
        hits=hit

        start_time=-126
        sound_start_time=-25

        [frame]
            image="units/neutral-outlaw-princess.png:1,units/neutral-outlaw-princess-defend.png:250,units/neutral-outlaw-princess.png:1"
        [/frame]

        [sound_frame]
            sound={SOUND_LIST:HUMAN_FEMALE_HIT}
        [/sound_frame]
    [/defend]
    [defend]
        hits=kill

        start_time=-126

        [frame]
            image="units/neutral-outlaw-princess.png:1,units/neutral-outlaw-princess-defend.png:250,units/neutral-outlaw-princess.png:1"
        [/frame]
    [/defend]
    [attack]
        name=staff
        #textdomain wesnoth-units
        description= _"staff"
        type=impact
        range=melee
        damage=7
        number=2
        icon=attacks/quarterstaff.png
    [/attack]
    [attack]
        name=sling
        description= _"sling"
        #textdomain wesnoth-did
        type=impact
        range=ranged
        damage=6
        number=3
        icon=attacks/sling.png
    [/attack]
    [attack_anim]
        [filter_attack]
            name=sling
        [/filter_attack]

        start_time=-400
        sound_start_time=-400
        offset=0.0

        [if]
            hits=yes
            {MISSILE_FRAME_STONE_HIT 8 -8}
            [sound_frame]
                sound=sling.ogg
            [/sound_frame]
        [/if]
        [else]
            hits=no
            {MISSILE_FRAME_STONE_MISS 8 -8}
            [sound_frame]
                sound=sling-miss.ogg
            [/sound_frame]
        [/else]
        [frame]
            image="units/neutral-outlaw-princess-attack-sling[1~2].png:[250,200]"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=staff
        [/filter_attack]

        start_time=-225

        [frame]
            image="units/neutral-outlaw-princess.png:75"
        [/frame]
        [frame]
            image="units/neutral-outlaw-princess-attack-staff[1~2].png:[75,175]"
        [/frame]
        [frame]
            image="units/neutral-outlaw-princess-defend-1-2.png:50"
        [/frame]
        [frame]
            image="units/neutral-outlaw-princess.png:25"
        [/frame]

        {SOUND:HIT_AND_MISS staff.ogg staff-miss.ogg -125}
    [/attack_anim]
[/unit_type]


#textdomain wesnoth-did

[unit_type]
    id=Ghast DiD
    [base_unit]
        id=Ghast
    [/base_unit]
    advances_to=null
    experience=90
    hide_help=yes
    do_not_list=yes

    {AMLA_OPTION_GHOUL_MELEE}
    {AMLA_OPTION_GHOUL_RESIST}
    {AMLA_OPTION_CANNIBALIZE1}
    {AMLA_OPTION_CANNIBALIZE2}
    {AMLA_OPTION_DEATH_CLOUD}
    {AMLA_DEFAULT}

    {DID_DEATH_CLOUD}
[/unit_type]


#textdomain wesnoth-did
# Same as normal, except advances to Necrophage DiD
[unit_type]
    id=Ghoul DiD
    [base_unit]
        id=Ghoul
    [/base_unit]
    advances_to=Necrophage DiD
    hide_help=yes
    do_not_list=yes
[/unit_type]