#textdomain wesnoth-httt
[scenario]
    id=19b_Swamp_Of_Dread
    name= _ "Swamp Of Dread"
    map_data="{campaigns/Heir_To_The_Throne/maps/19b_Swamp_Of_Dread.map}"
    {SCENARIO_MUSIC "knalgan_theme.ogg"}
    {EXTRA_SCENARIO_MUSIC "underground.ogg"}
    {TURNS 33 30 27}

    next_scenario=20a_North_Elves

    {DEFAULT_SCHEDULE}

    {BIGMAP_SWAMP_OF_DREAD}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat the Lich Lord Aimucasur"
                condition=win
            [/objective]
            [objective]
                description= _ "<255,255,255>Bonus objective:
@Defeat all Death Knights first"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Li'sar"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    {campaigns/Heir_To_The_Throne/utils/deaths.cfg}

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Rebels"
        controller=human
        gold=200
    [/side]

    {STARTING_VILLAGES 1 7}

#define SWAMP_DREAD_AI_PARAMS
    [ai]
        {ATTACK_DEPTH 5 5 6}
    [/ai]
    [ai]
        time_of_day=dusk
        turns=8-100
        caution=0.25
        aggression=0.8
    [/ai]
    [ai]
        time_of_day=first_watch,second_watch
        caution=0.0
        aggression=1.0
    [/ai]
#enddef

    [side]
        type=Death Knight
        id=Clarustus
        name= _ "Clarustus"
        side=2
        controller=ai
        canrecruit=yes
        recruit=Walking Corpse
        {GOLD 140 200 260}
        [ai]
            {NO_SCOUTS}
        [/ai]
        {SWAMP_DREAD_AI_PARAMS}
        team_name=undead
        user_team_name=_"Undead"
    [/side]

    {STARTING_VILLAGES 2 7}

    [side]
        type=Death Knight
        id=Merlunius
        name= _ "Merlunius"
        side=3
        controller=ai
        canrecruit=yes
        recruit=Ghost,Skeleton,Walking Corpse
        {GOLD 140 200 260}
        {SWAMP_DREAD_AI_PARAMS}
        team_name=undead
        user_team_name=_"Undead"
    [/side]

    {STARTING_VILLAGES 3 7}

    [side]
        type=Lich
        id=Aimucasur
        name= _ "Aimucasur"
        side=4
        controller=ai
        canrecruit=yes
        recruit=Wraith,Vampire Bat,Skeleton
        {GOLD 140 200 260}
        team_name=undead
        user_team_name=_"Undead"
        {SWAMP_DREAD_AI_PARAMS}
    [/side]

    {STARTING_VILLAGES 4 7}

    [side]
        type=Death Knight
        id=Secadius
        name= _ "Secadius"
        side=5
        controller=ai
        canrecruit=yes
        recruit=Skeleton,Walking Corpse,Ghoul
        [ai]
            {NO_SCOUTS}
        [/ai]
        {SWAMP_DREAD_AI_PARAMS}
        {GOLD 90 150 210}
        team_name=undead
        user_team_name=_"Undead"
    [/side]

    {STARTING_VILLAGES 5 7}

    [side]
        type=Death Knight
        id=Dafeis
        name= _ "Dafeis"
        side=6
        controller=ai
        canrecruit=yes
        recruit=Skeleton Archer,Walking Corpse,Ghost
        {GOLD 90 150 210}
        team_name=undead
        user_team_name=_"Undead"
        {SWAMP_DREAD_AI_PARAMS}
    [/side]

    {STARTING_VILLAGES 6 7}

    [event]
        name=start

        #For Home of the Northern Elves: where do we come from?
        [set_variable]
            name=A_Choice_Was_Made
            value=b
        [/set_variable]
        [recall]
            id=Delfador
        [/recall]
        [recall]
            id="Li'sar"
        [/recall]
        [recall]
            id=Kalenz
        [/recall]
        [message]
            speaker=Delfador
            message= _ "This land is cursed. Liches have existed here for ages, luring adventurers and soldiers to their deaths and amassing great armies and fortunes."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Look there! The swamp is infested with all manner of skeletons, corpses, and worse. I hope I have made a wise choice in taking this path."
        [/message]
        [message]
            speaker=Delfador
            message= _ "These Death Knights appear to be minions enslaved by the Lich Lord. This one must be particularly powerful, since Death Knights are usually strong-willed spirits on their own."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "I believe we can destroy the master and release the minions. There is much fighting to be done before we can pass through these swamps in peace. May our bones not join these fallen warriors who now oppose us."
        [/message]
    [/event]

#define ENDOWED_KNIGHT ID_STRING
    [event]
        name=die
        [filter]
            id={ID_STRING}
            type=Death Knight
        [/filter]
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "The Death Knight explodes into a cloud of dust as it is eradicated. Its armor, however, drops to the ground and remains intact. The heavy black steel is polished to a mirror shine."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "Delfador... that breastplate... how did it end up here?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Its owner was surely a famous warrior in life. I wonder who it was. That plate must have a powerful enchantment to have resisted centuries of decay. Choose wisely who will bear it."
        [/message]
        {VARIABLE temp_armor_x $x1}
        {VARIABLE temp_armor_y $y1}
        {OBJ_VOID_ARMOR $temp_armor_x $temp_armor_y void_armor}
    [/event]
#enddef

    #
    # 1.1.7 PROBLEMS: if you kill the endowed knight last, the lich event doesn't fire.
    #

    [event]
        name=prestart
        {VARIABLE_OP armored_knight random (Clarustus,Merlunius,Secadius,Dafeis)}
        {ENDOWED_KNIGHT ($armored_knight)}
    [/event]

    #
    # Reward the player for killing all 4 Death Knights - the Lich is weaker
    #
    [event]
        name=prestart
        {VARIABLE dk_kill_count 0}
    [/event]
    [event]
        name=die
        first_time_only=no
        [filter]
            type=Death Knight
        [/filter]
        {VARIABLE_OP dk_kill_count add 1}

        [if]
            [variable]
                name=dk_kill_count
                numerical_equals=4
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "As the last Death Knight falls, an ear-splitting screech escapes from the Lich. It is clear that controlling such powerful spirits has drained it significantly, and it is seething in anger towards you."
                [/message]
                [store_unit]
                    variable=Lich_store
                    [filter]
                        type=Lich
                    [/filter]
                [/store_unit]
                {VARIABLE_OP Lich_store.hitpoints multiply 0.4}
                [unstore_unit]
                    variable=Lich_store
                [/unstore_unit]
                {CLEAR_VARIABLE Lich_store}
            [/then]
        [/if]
    [/event]

    [event]
        name=die
        [filter]
            type=Lich
        [/filter]
        [kill]
            type=Death Knight
        [/kill]
        [if]
            [variable]
                name=dk_kill_count
                numerical_equals=4
            [/variable]
            [else]
                [if]
                    [variable]
                        name=dk_kill_count
                        numerical_equals=3
                    [/variable]
                    [then]
                        [message]
                            speaker=narrator
                            image="wesnoth-icon.png"
                            message= _ "A final blow destroys the lich, releasing a small shock-wave of energy outwards. The last Death Knight silently falls to the ground, inanimate. A giant cloud of dust bellows out as the remnants of the Lich's once-mortal skin and centuries of grime and gristle are dislodged for the last time."
                        [/message]
                    [/then]
                    [else]
                        [message]
                            speaker=narrator
                            image="wesnoth-icon.png"
                            message= _ "A final blow destroys the lich, releasing a small shock-wave of energy outwards. The Death Knights silently fall to the ground, inanimate. A giant cloud of dust bellows out as the remnants of the lich's once-mortal skin and centuries of grime and gristle are dislodged for the last time."
                        [/message]
                    [/else]
                [/if]
            [/else]
            [then]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "A final blow destroys the lich, releasing a small shock-wave of energy outwards. A giant cloud of dust bellows out as the remnants of the Lich's once-mortal skin and centuries of grime and and gristle are dislodged for the last time."
                [/message]
            [/then]
        [/if]
        [message]
            speaker=Delfador
            message= _ "Aimucasur's lordship over this cursed ground is broken."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Aimucasur? So you know of this Lich Lord? Did you know him? He was a powerful mage?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Yes, very powerful. I was not certain of his identity at first, but it is certain now. He lived centuries ago... he appears in our histories, a former headmaster on Alduin. He was reported to have disappeared, and now we know what happened to him."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "He was just someone who couldn't handle the power given to him."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "You would do well to learn the lesson he did not."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "Move along, Elf, unless you enjoy making camp in this slimy bog. I, for one, do not!"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Indeed..."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "Listen, you whose eyes are fair but hide a vacuum, do you not think I know what power does to one's soul? What evils a person is capable of when truth and righteousness are but scrolls that can be rewritten when a queen grows tired of them?"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "I spent my entire childhood listening to my mother give orders and commanding armies around. I hid in the throne room as a little girl as she met with her generals. I now know she was having people killed... entire towns of people killed!"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "I became my mother's most trusted aide-de-camp. I was sent to quiet the worst of the rebellion. Of course they fought back. I never knew who these people were or why they fought my mother. Konrad, you are lucky. You do not know what Wesnoth has been like these past many years. There is no peace. I have never known peace."
        [/message]
        [message]
            speaker=Delfador
            message= _ "I do know the cup of bitterness poured out on Wesnoth by your mother, child. The land has been torn apart. The elves know this. The orcs know this. Undead can feel it. Large armies of men march across the plains hunting each other, and when no men remain, outsiders will claim Wesnoth as their home."
        [/message]
        [message]
            speaker=Konrad
            image=portraits/konrad-angry.png
            message= _ "Enough! I can listen to no more of this. Princess, you may want to end your mother's rule, but I will end her life as she ended the life of my father and my brothers. Asheviere's masterwork of treachery will end, and it will end by my blade!"
        [/message]
        {CLEAR_VARIABLE temp_armor_x}
        {CLEAR_VARIABLE temp_armor_y}
        {CLEAR_VARIABLE armor_taken}
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
[/scenario]
