#textdomain wesnoth-ei

[scenario]
    id=04c_Mal-Ravanals_Capital
    name= _ "Mal-Ravanal’s Capital"
    map_file=04c_Mal-Ravanals_Capital.map
    turns=unlimited
    next_scenario=05_Northern_Outpost

    {DEFAULT_SCHEDULE_DAWN}

    {SCENARIO_MUSIC knalgan_theme.ogg}

    [story]
        [part]
            story=_ "Gweddry marched his band of soldiers ever eastward, deeper and deeper into the bogs. A great wall of stone loomed before them."
            music=silence.ogg
        [/part]
    [/story]
    {EI_TRACK {JOURNEY_04C_NEW} }

    [side]
        side=1
        controller=human
        {GOLD 200 175 150}
        team_name=good
        user_team_name=_"Wesnothians"
        {FLAG_VARIANT loyalist}
        # wmllint: recognize Gweddry
        {CHARACTER_STATS_GWEDDRY}
    [/side]

#define UNDEAD_SIDE
    controller=ai
    team_name=undead
    user_team_name= _ "Undead"
    {FLAG_VARIANT undead}
    canrecruit=yes
    [ai]
        leader_value=0
    [/ai]
#enddef

    #--------------------
    # DARK SORCERERS (loiter)
    #--------------------
    [side]
        side=2
        type=Dark Sorcerer
        id=Mal-Skraat
        name= _ "Mal-Skraat"
        recruit=Walking Corpse,Soulless,Ghoul,Skeleton Rider,Vampire Bat
        {GOLD 20 60 100}
        {INCOME 1 4 7}
        {UNDEAD_SIDE}
    [/side]
    {STARTING_VILLAGES 2 4}
    {SILENTLY_LIMIT_LEADER_MOVES 2 1}
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2 "Vampire Bat" 1}
    {RECRUIT_UNIT_VARIATIONS 2 "Walking Corpse" none,none,mounted,mounted}
    {RECRUIT_UNIT_VARIATIONS 2 "Soulless" none,none,mounted,mounted}

    [side]
        side=3
        type=Dark Sorcerer
        id=Mal-Rikna
        name= _ "Mal-Rikna"
        gender=female
        recruit=Walking Corpse,Soulless,Ghoul,Skeleton Rider,Vampire Bat
        {GOLD 20 60 100}
        {INCOME 1 4 7}
        {UNDEAD_SIDE}
    [/side]
    {STARTING_VILLAGES 3 8}
    {LIMIT_CONTEMPORANEOUS_RECRUITS 3 "Vampire Bat" 1}
    {SILENTLY_LIMIT_LEADER_MOVES 3 1}
    {RECRUIT_UNIT_VARIATIONS 3 "Walking Corpse" none,none,saurian,saurian}
    {RECRUIT_UNIT_VARIATIONS 3 "Soulless" none,none,saurian,saurian}

    [event] # start off defensive
        name=prestart
        {MODIFY_SIDE_AI (2) ({GOAL_LOCATION 0.1 (x,y,radius=9,6,1)})}
        {MODIFY_SIDE_AI (2) ({GOAL_LOCATION 0.1 (x,y,radius=7,8,1)})}
        {MODIFY_SIDE_AI (3) ({GOAL_LOCATION 0.1 (x,y,radius=14,24,1)})}
        {MODIFY_SIDE_AI (3) ({GOAL_LOCATION 0.1 (x,y,radius=7,22,1)})}
    [/event]

    #--------------------
    # LICH (defend the wall)
    #--------------------
    [side]
        side=4
        color=brown
        type=Lich
        id=Mal-Vakaz
        name= _ "Mal-Vakaz"
        recruit=Skeleton,Revenant,Skeleton Archer,Bone Shooter,Dark Adept
        {GOLD 40 120 200}
        {INCOME 5 12 19}
        facing=sw
        {UNDEAD_SIDE}
    [/side]
    {STARTING_VILLAGES 4 13}
    {SILENTLY_LIMIT_LEADER_MOVES 4 1}

    [event]
        name=prestart
        {MODIFY_SIDE_AI (4) ({GOAL_SEEK_SIDE 5 1 0})}
        {MODIFY_SIDE_AI (4) (grouping=no)}
        {MODIFY_SIDE_AI (4) (aggression=-1)}
        {MODIFY_SIDE_AI (4) (caution=1)}

        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 99 (x,y=38,4)})} # further away goals get higher priority, or else they get ignored
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 77 (x,y=30,6)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 55 (x,y=29,8)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 55 (x,y=28,9)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 55 (x,y=27,12)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 55 (x,y=27,14)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 66 (x,y=28,17)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 77 (x,y=28,19)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 99 (x,y=29,22)})}

        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 44 (x,y=31,10)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 44 (x,y=33,13)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 44 (x,y=33,16)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 44 (x,y=36,8)})}
        {MODIFY_SIDE_AI (4) ({GOAL_LOCATION 44 (x,y=41,17)})}

        {GENERIC_UNIT 4 (Bone Shooter) 39 13}
        {GENERIC_UNIT 4 (Skeleton Archer) 33 16}
        {GENERIC_UNIT 7 (Skeleton) 40 15} # side 7 because this guy gets posessed by Mal-Ravanal

        # give some wall units to Mal-Ravanal so that they attack right away
        {GENERIC_UNIT 4 (Skeleton) 38 4}
        {GENERIC_UNIT 7 (Skeleton) 30 6}
        {GENERIC_UNIT 7 (Skeleton Archer) 28 9}
        {GENERIC_UNIT 4 (Skeleton) 27 14}
        {GENERIC_UNIT 7 (Skeleton Archer) 28 17}
        {GENERIC_UNIT 7 (Skeleton) 28 19}
        {GENERIC_UNIT 4 (Skeleton) 29 26}

        # few units further forward so they trickle in
        {GENERIC_UNIT 7 (Skeleton) 36 8}
        {GENERIC_UNIT 7 (Bone Shooter) 35 6}
        {GENERIC_UNIT 7 (Skeleton Archer) 37 19}
        {GENERIC_UNIT 7 (Revenant) 41 17}
    [/event]

    #--------------------
    # DEATH KNIGHTS (loiter)
    #--------------------
    [side]
        side=5
        color=brown
        type=Death Knight
        id=Rava-Krodaz
        name= _ "Rava-Krodaz"
        recruit=Skeleton,Revenant,Skeleton Archer,Bone Shooter
        gold=120 # these guys are mostly only there for appearance's sake
        {INCOME 5 12 19}
        facing=sw
        {UNDEAD_SIDE}
    [/side]
    {STARTING_VILLAGES 5 5}

    [side]
        side=6
        color=brown
        type=Death Knight
        id=Rava-Krovan
        name= _ "Rava-Krovan"
        recruit=Skeleton,Revenant,Skeleton Archer,Bone Shooter
        gold=120 # these guys are mostly only there for appearance's sake
        {INCOME 5 12 19}
        facing=sw
        {UNDEAD_SIDE}
    [/side]
    {STARTING_VILLAGES 6 5}

    [event] # be defensive at first
        name=prestart
        {MODIFY_SIDE_AI (5) ({GOAL_LOCATION 1 (x,y,radius=44,6,3)})}
        {MODIFY_SIDE_AI (6) ({GOAL_LOCATION 1 (x,y,radius=44,19,3)})}
    [/event]

    #--------------------
    # MAL-RAVANAL (attack immediately, but no recruiting)
    #--------------------
    [side]
        side=7
        {CHARACTER_STATS_RAVANAL} # wmllint: recognize Mal-Ravanal
        recruit=Spectre,Wraith
        gold=-2
        income=-2
        facing=sw
        {UNDEAD_SIDE}
        [ai]
            [leader_goal]
                x,y=58,12
            [/leader_goal]
        [/ai]
        color=black

        # some eastern guards (for appearance's sake)
        {LOYAL_UNIT 7 (Draug)    54 25} {GUARDIAN}
        {LOYAL_UNIT 7 (Revenant) 63 25} {GUARDIAN}
        {LOYAL_UNIT 7 (Banebow)  65 21} {GUARDIAN}

        {LOYAL_UNIT 7 (Chocobone)    65 7} {GUARDIAN}
        {LOYAL_UNIT 7 (Banebow)      64 2} {GUARDIAN}
        {LOYAL_UNIT 7 (Revenant)     61 2} {GUARDIAN}
        {LOYAL_UNIT 7 (Bone Shooter) 54 4} {GUARDIAN}
    [/side]
    #     {STARTING_VILLAGES_AREA 7 51-65 1-26 1}

    [event]
        name=prestart
        {VARIABLE ravanal_no_income yes}
        [modify_unit]
            [filter]
                id=Mal-Ravanal
            [/filter]
            [effect]
                apply_to=remove_ability # remove the "renaimation" ability since it isn't active here, and we don't want to confuse the player
                [abilities]
                    [dummy]
                        id=reanimation
                    [/dummy]
                [/abilities]
            [/effect]
        [/modify_unit]
    [/event]
    [event] # manually set gold to 0
        name=side 7 turn refresh
        first_time_only=no

        [filter_condition]
            {VARIABLE_CONDITIONAL ravanal_no_income equals yes}
        [/filter_condition]

        [modify_side]
            side=7
            gold=0
        [/modify_side]
    [/event]
    [event] # manually set gold to 1000
        name=side 1
        first_time_only=no

        [filter_condition]
            {VARIABLE_CONDITIONAL ravanal_no_income not_equals yes}
        [/filter_condition]

        [modify_side]
            side=7
            gold=9999
        [/modify_side]
    [/event]

    #--------------------
    # PRISONERS
    #--------------------
    [side]
        side=8
        no_leader=yes
        controller=null
        team_name=good,undead
        user_team_name= _ "Wesnothians"
        color=white
        hidden=yes
    [/side]

#define IMPRISON ID X Y MESSAGE
    {TEAM_COLOR_OVERRIDE (id={ID}) white}
    {MODIFY_UNIT id={ID} halo items/horse-cage.png}
    {MODIFY_UNIT id={ID} status.slowed yes}
    {NAMED_LOYAL_UNIT 4 (Deathblade) {X} {Y} (Jailer_{X}_{Y}) _"Jailer"}
    [+unit]
        max_moves=0
    [/unit]

    [event]
        name=last breath #deliberate, so this triggers before ravanal_gets_serious

        [filter]
            id=Jailer_{X}_{Y}
        [/filter]

        {MODIFY_UNIT id={ID} halo ""}
        {MODIFY_UNIT id={ID} side 1}
        [fire_event]
            name=rescued_{ID}
        [/fire_event]
        [message]
            speaker={ID}
            message={MESSAGE}
        [/message]
        [if]
            [variable]
                name=first_prisoner_freed
                not_equals=yes
            [/variable]
            [then]
                [message]
                    speaker=Gweddry
                    #po: to a single captive
                    message= _ "How did these undead come to imprison you?"
                [/message]
                [message]
                    speaker={ID}
                    message= _ "It is a sad tale. My allies and I were questing when we were ambushed and captured by ghostly warriors. Their leader has been toying with us, forcing us to fight for their amusement."
                [/message]
                [message]
                    speaker=Gweddry
                    message= _ "No soldier deserves such treatment. We will try to free as many of you as possible."
                [/message]
                [message]
                    speaker={ID}
                    message= _ "Five of my comrades are still imprisoned. We will gladly enter your service in appreciation for our freedom."
                [/message]
            [/then]
        [/if]
        {VARIABLE first_prisoner_freed yes}
    [/event]
#enddef
    [event] # this is a really ugly way to have an additional line for Terraent
        name=rescued_Terraent # fired with rescued_{ID}
        [message]
            speaker=Gweddry
            message=_ "A sun paladin! I had no idea there were any of your order still in Wesnoth."
        [/message]
    [/event]
    [event]
        name=prestart
        {NAMED_NOTRAIT_UNIT 8 (Knight) 22 3 Aeraery (_"Aeraery")}
        [+unit]
            [modifications]
                {TRAIT_SURVIVOR}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]
        {IMPRISON Aeraery     21 3 (_ "Thank you! My poor horse could barely breathe trapped among these reeds!")}

        {NAMED_NOTRAIT_UNIT 8 (Knight) 34 2 Teoryn (_"Teoryn")}
        [+unit]
            [modifications]
                {TRAIT_SURVIVOR}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]
        {IMPRISON Teoryn      33 2 (_ "Bah, I didn’t need your help! Sooner or later, I would have gotten out of this cage on my own.")}

        {NAMED_NOTRAIT_UNIT 8 (Knight) 7 15 Yrthynaenc (_"Yrthynaenc")}
        [+unit]
            [modifications]
                {TRAIT_SURVIVOR}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        {IMPRISON Yrthynaenc  7 16 (_ "My thanks, friends. I had despaired of ever again riding free amongst the living.")}
        {NAMED_NOTRAIT_UNIT 8 (Knight) 24 21 Inyc (_"Inyc")}
        [+unit]
            [modifications]
                {TRAIT_SURVIVOR}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
        {IMPRISON Inyc        25 22 (_ "Vengeance upon the undead! I will make them pay for the abuse they’ve inflicted upon us!")}

        {NAMED_NOTRAIT_UNIT 8 (Knight) 42 21 Vobreddaent (_"Vobreddaent")}
        [+unit]
            [modifications]
                {TRAIT_SURVIVOR}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]
        {IMPRISON Vobreddaent 41 21 (_ "Truly you are heroes of legend to have fought so deep past the undead! I am forever in your debt.")}
    [/event]

    [event]
        name=prestart
        {RECALL Dacyn}

        {PLACE_IMAGE scenery/trash.png 31 3}
        {PLACE_IMAGE scenery/village-human-burned1.png 43 8}
        {PLACE_IMAGE scenery/trash.png 39 5}
        {PLACE_IMAGE scenery/village-human-burned3.png 37 7}
        {PLACE_IMAGE scenery/trash.png 47 3}

        {PLACE_IMAGE scenery/trash.png 38 13}
        {PLACE_IMAGE scenery/village-human-burned4.png 42 15}

        {PLACE_IMAGE scenery/village-human-burned1.png 31 21}
        {PLACE_IMAGE scenery/village-human-burned3.png 33 22}

        {PLACE_IMAGE scenery/village-human-burned2.png 45 21}
        {PLACE_IMAGE scenery/trash.png 44 20}
        {PLACE_IMAGE scenery/village-human-burned3.png 51 21}
        {PLACE_IMAGE scenery/trash.png 50 19}

        {PLACE_IMAGE scenery/village-human-burned4.png 25 12}
        {PLACE_IMAGE scenery/trash.png 22 12}
        {PLACE_IMAGE scenery/village-human-burned2.png 25 23}
        {PLACE_IMAGE scenery/trash.png 24 23}
        {PLACE_IMAGE scenery/trash.png 21 20}

        {PLACE_IMAGE items/ball-green.png 58 11}
        {PLACE_IMAGE items/ball-green.png 58 13}

        [objectives]
            side=1
            [objective]
                description= _ "Escape by defeating one of the dark sorcerers"
                condition=win
            [/objective]
            [objective]
                {BONUS_OBJECTIVE_CAPTION}
                #po: when initially shown there are 6 imprisoned knights, the text doesn't change as they're freed
                description= _ "Rescue the imprisoned knights"
                condition=win
                [show_if]
                    [have_unit]
                        side=8
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Gweddry or Dacyn"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=no
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]

        {MODIFY_UNIT (id=Mal-Ravanal) hitpoints 13}
        [unit]
            side=8
            type=Terraent
            id=Terraent
            #po: the unique unit type is a Paladin variantion
            name= _ "Terraent"
            profile=portraits/terraent.webp
            unrenamable=yes
            x,y=36,15
            random_traits=no
            facing=ne
            hitpoints=9
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_SURVIVOR}
            [/modifications]
        [/unit]
    [/event]

    [event]
        name=start
        [message]
            speaker=Gweddry
            message= _ "The Bitter Swamp’s ill reputation is, it seems, well merited. Mal-Ravanal’s fortress lies before us."
        [/message]
        [message]
            speaker=Dacyn
            message= _ "Yes, and behind us undead forces are closing in, including that pest Mal-Skraat. What exactly is your plan? We have no means for victory with the scant tools we have available to us right now. Even if we were to destroy Mal-Ravanal’s skeletal body, their spirit would remain and simply possess another."
        [/message]
        [message]
            speaker=Gweddry
            message= _ "To retreat, we need to kill one of these dark sorcerers that follow us. But we are already in the enemy capital and I believe we have a duty to hamper the undead however we can. And look, we are not the only ones fighting here!"
        [/message]

        [delay]
            time=500
        [/delay]

        {SCROLL_TO 37 15}

        [message]
            speaker=Terraent
            message= _ "In the name of all that is holy, Lich, I will strike you down!"
        [/message]
        [message]
            speaker=Mal-Ravanal
            message= _ "Try it, fleshbag."
        [/message]

        [sound]
            name=magic-holy-2.ogg
        [/sound]

        [animate_unit]
            flag=attack
            [filter]
                id=Terraent
            [/filter]
            [primary_attack]
                name=lance
            [/primary_attack]
            hits=kill
            [facing]
                x,y=99,0
            [/facing]
        [/animate_unit]
        [harm_unit]
            [filter]
                id=Mal-Ravanal
            [/filter]
            amount=17
            kill=no
        [/harm_unit]

        [sound]
            name=lightning.ogg
        [/sound]

        {COLOR_ADJUST  127   64  127}
        [delay]
            time=150
        [/delay]

        {COLOR_ADJUST -127 -191 -127}
        [delay]
            time=150
        [/delay]

        {COLOR_ADJUST  255  100  100}
        [delay]
            time=150
        [/delay]

        {COLOR_ADJUST -255 -255 -255}
        [delay]
            time=150
        [/delay]

        {COLOR_ADJUST  255    0    0}
        [delay]
            time=150
        [/delay]

        {COLOR_ADJUST 0 0 0}
        [sound]
            name=melee-fire.ogg
        [/sound]

        [fire_event]
            name=terror_despawn
            [primary_unit]
                id=Mal-Ravanal
            [/primary_unit]
        [/fire_event]
        {KILL id=Mal-Ravanal ANIMATE=yes}
        [remove_item]
            image=terror_aura
        [/remove_item]
        [remove_object]
            object_id=terrified
        [/remove_object]

        [delay]
            time=2000
        [/delay]

        [sound]
            name=wail.wav
        [/sound]

        {NAMED_UNIT 5 (Dark Shape) 37 15 Mal-Ravanal (_ "Mal-Ravanal") ()} {FACING sw} {ANIMATE}
        [message]
            speaker=Mal-Ravanal
            message= _ "That tickled a bit!"
        [/message]
        {KILL (type=Dark Shape)}
        {RAVANAL_POSSESS 37 15 (x,y=40,15) (sw)}
        [message]
            speaker=Mal-Ravanal
            message= _ "Well paladin, this has been amusing, but apparently we have a new group of guests to entertain. Back into the cage with you."
        [/message]
        [move_unit]
            id=Mal-Ravanal
            to_x,to_y=47,14
            fire_event=yes # for the terror aura
        [/move_unit]
        {IMPRISON Terraent 35 16 (_ "Gratitude to you and yours, pious warriors! Now let us join forces to free my companions and cleanse this place in holy fire!")}
        # if I change Terraent's jail location, also change the Jailer_35_16 Terraent freed trigger for ravanal_gets_serious

        {SCROLL_TO 17 14}
        {MODIFY_UNIT id=Terraent hitpoints 66}
    [/event]
    [event]
        name=moveto
        [filter]
            x,y=58,12
            id=Mal-Ravanal
        [/filter]
        {MODIFY_UNIT id=Mal-Ravanal facing sw}
    [/event]

    #--------------------
    # MAL-RAVANAL TAUNT
    #--------------------
    [event]
        name=die
        [filter]
            side=1
        [/filter]
        [message]
            speaker=Mal-Ravanal
            message= _ "Silly fleshbags, did you come just to nourish our swamp?"
        [/message]
    [/event]

    #--------------------
    # MAL-RAVANAL "KILLED"
    #--------------------
    [event]
        name=last breath
        first_time_only=no
        [filter]
            id=Mal-Ravanal
        [/filter]
        [store_unit]
            [filter]
                id=Mal-Ravanal
            [/filter]
            variable=dead_ravanal
            kill=yes
        [/store_unit]

        # find (or spawn) a host for mal-ravanal
        {FIND_NEARBY (type=Skeleton,Skeleton Archer,Revenant,Deathblade,Bone Shooter,Draug,Banebow,Death Knight) $dead_ravanal.x $dead_ravanal.y 25}
        {SPAWN_IF_UNFOUND 5 (Revenant) 32..64, 0..26}

        {RAVANAL_POSSESS $dead_ravanal.x $dead_ravanal.y (x,y=$found_unit.x,$found_unit.y) (sw)}
        {CLEANUP_SEARCH}

        {GENERIC_UNIT 5 ({ON_DIFFICULTY Wraith Wraith Spectre}) $possessee.x $possessee.y} {ANIMATE}
        {GENERIC_UNIT 5 ({ON_DIFFICULTY Wraith Spectre Spectre}) $possessee.x $possessee.y} {ANIMATE}
        {GENERIC_UNIT 5 ({ON_DIFFICULTY Wraith Wraith Spectre}) $possessee.x $possessee.y} {ANIMATE}
        {GENERIC_UNIT 5 ({ON_DIFFICULTY Wraith Spectre Spectre}) $possessee.x $possessee.y} {ANIMATE}
        {GENERIC_UNIT 5 ({ON_DIFFICULTY Wraith Wraith Spectre}) $possessee.x $possessee.y} {ANIMATE}
        {GENERIC_UNIT 5 ({ON_DIFFICULTY Wraith Spectre Spectre}) $possessee.x $possessee.y} {ANIMATE}

        [message]
            speaker=Mal-Ravanal
            message= _ "Did you really think that your crude weapons would work?"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "Mal-Ravanal cannot be defeated right now. We must flee!"
        [/message]
    [/event]

    #--------------------
    # RAVANAL GETS SERIOUS
    #--------------------
    [event]
        name=turn 8
        [gold]
            side=4
            amount={ON_DIFFICULTY 15 45 75} # otherwise his armies start to feel a little thin around now
        [/gold]
        [message]
            speaker=Dacyn
            message= _ "Gweddry, we should not be here. They are merely toying with us right now, but all will be lost if Mal-Ravanal finds me amongst you!"
        [/message]
    [/event]
    [event]
        name=turn 10 # dusk, so the player can see all the shadows
        [fire_event]
            name=ravanal_gets_serious
        [/fire_event]
    [/event]
    [event]
        name=die
        [filter]
            id=Rava-Krodaz,Rava-Krovan,Mal-Vakaz #not Jailer_35_16, or else players are rewarded for waiting until the last moment to rescue Terraent
        [/filter]
        [fire_event]
            name=ravanal_gets_serious
        [/fire_event]
    [/event]
    [event]
        name=ravanal_gets_serious

        {REPLACE_SCENARIO_MUSIC silence.ogg}
        [message]  # if you change this, also change 06b_Soradoc
            speaker=Mal-Ravanal
            #po: Ravanal and Dacyn perk up a bit when talking to or referring to each other
            message= _ "Wait a moment! That nauseating holier-than-thou aura..."
        [/message]
        [message]
            speaker=Mal-Ravanal
            message= _ "... ah, Dacyn, what an unexpected surprise! Last time we spoke, you blasted me before I could even finish telling you about my research."
        [/message]
        [message]
            speaker=Dacyn
            message= _ "If only it had ended back then. Stop this madness. Let this torment come to an end."
        [/message]

        {REPLACE_SCENARIO_MUSIC the_dangerous_symphony.ogg}
        {APPEND_MUSIC the_city_falls.ogg}
        [message]
            speaker=Mal-Ravanal
            message= _ "Torment? What torment? You’re the one who seems to be miserable. But don’t worry, if your goal was to become one of these mindless thralls, you came to the right place. You know what they say. No brain, no pain!"
        [/message]
        {MODIFY_UNIT id=Mal-Ravanal facing nw}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  50 11} {ANIMATE}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  53 9 } {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing ne}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  64 9 } {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing se}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  62 16} {ANIMATE}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  58 18} {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing sw}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  54 17} {ANIMATE}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  50 17} {ANIMATE}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Ghost  51 14} {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing nw}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Shadow 56 9 } {ANIMATE}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Shadow 58 8 } {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing se}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Shadow 62 13} {ANIMATE}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Shadow 59 16} {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing sw}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Shadow 56 15} {ANIMATE}

        {MODIFY_UNIT id=Mal-Ravanal facing nw}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Spectre 57 12} {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing ne}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Wraith  59 12} {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing se}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Spectre 59 13} {ANIMATE}
        {MODIFY_UNIT id=Mal-Ravanal facing sw}
        {RAVANAL_ATTACK}
        [sound]
            name=wail.wav
        [/sound]
        {GENERIC_UNIT 7 Wraith  57 13} {ANIMATE}
        [message]
            speaker=Mal-Ravanal
            message= _ "Don’t worry, old friend, these ghosts will take good care of you. Just stay still for a bit..."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Gweddry
            message= _ "You were <b>friends</b> with this lich?!?"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "Yes... We studied together many years ago. Ravan’s power was already most potent back then, but I fear it has become far greater now. None of you stand a chance; we must escape immediately!"
        [/message]

        {CLEAR_VARIABLE ravanal_no_income}
        [modify_side]
            side=5,6
            gold=100
        [/modify_side]
        {RESET_SIDE_AI 2,3,4,5,6 offensive 0.9 0}
    [/event]

    #--------------------
    # VICTORY
    #--------------------
    [event]
        name=last breath
        [filter]
            id=Mal-Skraat
        [/filter]
        [message]
            speaker=Mal-Skraat
            message=_ "No, it can’t end like this! My sister has died unavenged..."
        [/message]
    [/event]
    [event]
        name=die
        [filter]
            id=Mal-Skraat
        [/filter]

        {VARIABLE skraat_dead yes}
        [endlevel]
            result=victory
            bonus=no
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Mal-Rikna
        [/filter]
        [message]
            speaker=Mal-Rikna
            message=_ "Help, please, I never even liked that lich!"
        [/message]
        [message]
            speaker=Mal-Skraat
            message=_ "Useless mage, stop dying and start avenging my sister!"
        [/message]
    [/event]
    [event]
        name=die
        [filter]
            id=Mal-Rikna
        [/filter]
        [endlevel]
            result=victory
            bonus=no
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=victory
        {CLEAR_VARIABLE first_prisoner_freed}

        [message]
            speaker=Gweddry
            message=_ "Quickly, make for the western edge of the swamp! We have to get out of here!"
        [/message]
        [message]
            speaker=Dacyn
            message=_ "Did I not warn you? Coming here was a fool’s errand! We have been very lucky to escape with our lives. We must make with all haste to whatever remains of Owaec’s northern outpost and hope we are not pursued."
        [/message]

        [if]
            [have_unit]
                side=8
            [/have_unit]

            [then]
                [if]
                    [have_unit]
                        type=Terraent
                        side=1
                    [/have_unit]

                    [then]
                        {FIND_NEARBY (type,side=Terraent,1) 36 15 99}
                    [/then]

                    [else]
                        {FIND_NEARBY (type,side=Knight,1) 36 15 99}
                    [/else]
                [/if]
                [message]
                    speaker=$found_unit.id
                    message=_ "We cannot leave my companions behind! They have suffered grievously already and will surely be slain."
                [/message]

                {FIND_NEARBY (
                    type=Knight,Terraent
                    side=8
                ) 36 15 99}
                [message]
                    speaker=$found_unit.id
                    message=_ "Save yourselves and do not despair! As long as there are those who resist the darkness, hope will always remain."
                    image_pos=right
                    mirror=yes
                [/message]
            [/then]
        [/if]

        [if]
            [have_unit]
                side=1
                trait=survivor
                count=6-999
            [/have_unit]
            [then]
                [set_achievement]
                    content_for=eastern_invasion
                    id=ei_S04c
                [/set_achievement]
            [/then]
        [/if]
    [/event]

    {FOREIGN_DEFEAT}

    {HERODEATH_GWEDDRY}
    {HERODEATH_DACYN}
    {HERODEATH_OWAEC}
    {HERODEATH_TERRAENT}
    {HERODEATH_DOLBURRAS}
    {HERODEATH_GRUG}
[/scenario]
