#textdomain wesnoth-httt
[scenario]
    id=19b_Swamp_Of_Dread
    name= _ "Swamp Of Dread"
    map_file=19b_Swamp_Of_Dread.map
    {TURNS 33 30 27}

    next_scenario=20a_North_Elves

    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC "knalgan_theme.ogg"}
    {EXTRA_SCENARIO_MUSIC "underground.ogg"}
    {EXTRA_SCENARIO_MUSIC "siege_of_laurelmor.ogg"}
    {EXTRA_SCENARIO_MUSIC "suspense.ogg"}

    {HTTT_TRACK {JOURNEY_19B_NEW} }

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat the Lich-Lord Aimucasur"
                condition=win
            [/objective]
            [objective]
                {BONUS_OBJECTIVE_CAPTION}
                description= _ "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]

            {TURNS_RUN_OUT}

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

    {campaigns/Heir_To_The_Throne/utils/deaths.cfg}

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad-human.webp
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Rebels"
        controller=human
        {GOLD 230 200 170}
        {FLAG_VARIANT long}
    [/side]

#define SWAMP_DREAD_AI_PARAMS
    [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 60 80 100}
        {INCOME 6 8 10}
        [ai]
            {NO_SCOUTS}
        [/ai]
        {SWAMP_DREAD_AI_PARAMS}
        team_name=undead
        user_team_name=_"Undead"
        {FLAG_VARIANT 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 80 100 120}
        {INCOME 6 8 10}
        {SWAMP_DREAD_AI_PARAMS}
        team_name=undead
        user_team_name=_"Undead"
        {FLAG_VARIANT 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 100 140 180}
        {INCOME 6 9 12}
        team_name=undead
        user_team_name=_"Undead"
        {SWAMP_DREAD_AI_PARAMS}
        {FLAG_VARIANT undead}
    [/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 60 80 100}
        {INCOME 6 8 10}
        team_name=undead
        user_team_name=_"Undead"
        {FLAG_VARIANT 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 80 100 120}
        {INCOME 6 8 10}
        team_name=undead
        user_team_name=_"Undead"
        {SWAMP_DREAD_AI_PARAMS}
        {FLAG_VARIANT undead}
    [/side]

    {STARTING_VILLAGES 6 7}

    [event]
        name=prestart

        #For Home of the Northern Elves: where do we come from?
        [set_variable]
            name=A_Choice_Was_Made
            value=b
        [/set_variable]
        {NEED_DELFADOR placement=leader}
        {NEED_LISAR placement=leader}
        {NEED_KALENZ placement=leader}
    [/event]

    [event]
        name=start

        [message]
            speaker=Delfador
            {DELFADOR_MENTORING}
            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
            {KONRAD_VARIATION concerned}
            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 rand (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 of its generals 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}
                [objectives]
                    side=1
                    [objective]
                        description= _ "Defeat the Lich-Lord Aimucasur"
                        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]

                    {TURNS_RUN_OUT}

                    [gold_carryover]
                        bonus=yes
                        carryover_percentage=40
                    [/gold_carryover]
                [/objectives]
            [/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]
            [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 billows out as the remnants of the lich’s once-mortal body disintegrate for the last time."
                [/message]
            [/then]
            [elseif]
                [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 of his minions silently falls like a puppet with its strings cut. A cloud of dust billows outwards as the remnants of the lich’s once-mortal body disintegrate for the last time."
                    [/message]
                [/then]
            [/elseif]
            [else]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "A final blow destroys the lich, releasing a small shock wave of energy outwards. His minions fall like puppets with their strings cut. A cloud of dust billows out as the remnants of the lich’s once-mortal body disintegrate for the last time."
                [/message]
            [/else]
        [/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? Was he a powerful mage?"
        [/message]
        [message]
            speaker=Delfador
            {DELFADOR_MENTORING}
            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 command 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
            {KONRAD_VARIATION mad}
            message= _ "Enough! I can listen to no more of this. Li’sar, 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]
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE temp_armor_x}
        {CLEAR_VARIABLE temp_armor_y}
        {CLEAR_VARIABLE armor_taken}
        {CLEAR_VARIABLE armored_knight,dk_kill_count}
    [/event]
[/scenario]

#undef SWAMP_DREAD_AI_PARAMS
#undef ENDOWED_KNIGHT
