#textdomain wesnoth-utbs

[scenario]
    id=09_Blood_is_Thicker_Than_Water
    name= _ "Blood is Thicker than Water"
    next_scenario=10_Speaking_with_the_Fishes
    {UTBS_MAP 09_Blood_is_Thicker_Than_Water.map}
    victory_when_enemies_defeated=no
    {TURNS 58 54 50}

    [music]
        name=loyalists.ogg
    [/music]

    {STORY_BLOOD_IS_THICKER_THAN_WATER}

    {TWO_SUNS_DEFAULT_SCHEDULE}

    # side 1: elves
    [side]
        side=1
        id=Kaleh
        type=Quenoth Youth
        canrecruit=yes
        gold=200
        {INCOME 2 0 0}
        controller=human
        shroud=yes
        fog=no
        {FLAG_VARIANT long}
        user_team_name= _ "team_name^Quenoth Elves"
    [/side]

    # Side 2: Darius, leader of Human forces (blue)
    [side]
        side=2
        type=Human Commander
        id=Darius
        name= _ "Darius"
        canrecruit=yes
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_RESILIENT}
        [/modifications]
        {GOLD 100 125 150}
        {INCOME 7 9 11}
        controller=ai
        shroud=no
        fog=no
        team_name=human_ally
        user_team_name=_"Human Allies"
        {FLAG_VARIANT undead}
#ifdef EASY
        recruit=Spearman, Pikeman, Swordsman, Javelineer, Cavalryman, Bowman, Longbowman, Heavy Infantryman
#endif
#ifdef NORMAL
        recruit=Pikeman, Swordsman, Javelineer, Dragoon, Bowman, Longbowman, Heavy Infantryman, Shock Trooper
#endif
#ifdef HARD
        recruit=Pikeman, Swordsman, Javelineer, Dragoon, Longbowman, Shock Trooper
#endif
        [ai]
            recruitment_pattern=scout, fighter, archer
            aggression=0.75
            caution=0.1

            passive_leader=yes
        [/ai]
    [/side]

    # Side=3 traitorous elves (green)
    [side]
        side=3
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=human_ally
        user_team_name=_"Human Allies"
        recruit=Quenoth Fighter,Tauroch Rider,Quenoth Scout,Quenoth Warrior,Quenoth Flanker,Tauroch Vanguard,Quenoth Archer,Quenoth Pathfinder
        [ai]
            recruitment_pattern=fighter, archer, fighter, mixed fighter, scout
            aggression=0.75
            caution=0.25
            passive_leader=yes
        [/ai]
        {FLAG_VARIANT long}
    [/side]

    # Side=4 Iron Council (yellow)

    [side]
        side=4
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=human_ally
        user_team_name=_"Iron Council"
        {FLAG_VARIANT undead}
#ifdef EASY
        recruit=Pikeman, Swordsman, Javelineer, Longbowman, Heavy Infantryman, Necromancer, Skeleton, Skeleton Archer, Bone Shooter
#endif
#ifdef NORMAL
        recruit=Pikeman, Swordsman, Javelineer, Dragoon, Longbowman, Shock Trooper, Necromancer, Revenant, Bone Shooter
#endif
#ifdef HARD
        recruit=Pikeman, Swordsman, Javelineer, Dragoon, Longbowman, Shock Trooper, Necromancer, Revenant, Bone Shooter
#endif
        [ai]
#ifdef EASY
            recruitment_pattern=fighter, archer, mixed fighter
#else
            recruitment_pattern=scout, fighter, archer, mixed fighter
#endif
            aggression=0.8
            caution=0.1
            passive_leader=yes
        [/ai]
    [/side]

    # Side=5 Zelgant Human Lieutenant
    [side]
        side=5
        type=Shock Trooper
        id=Zelgant
        name= _ "Zelgant"
        canrecruit=yes
        [modifications]
            {TRAIT_STRONG}
        [/modifications]
        {GOLD 75 100 125}
        {INCOME 5 6 7}
        controller=ai
        shroud=no
        fog=no
        team_name=human_ally
        user_team_name=_"Human Allies"
        {FLAG_VARIANT undead}
#ifdef EASY
        recruit=Spearman, Pikeman, Swordsman, Javelineer, Cavalryman, Bowman, Longbowman, Heavy Infantryman
#endif
#ifdef NORMAL
        recruit=Spearman, Pikeman, Swordsman, Javelineer, Cavalryman, Dragoon, Bowman, Longbowman, Shock Trooper
#endif
#ifdef HARD
        recruit=Spearman, Pikeman, Swordsman, Javelineer, Cavalryman, Dragoon, Bowman, Longbowman, Shock Trooper
#endif
        [ai]
            recruitment_pattern=scout, fighter, archer
            aggression=0.6
            caution=0.25
            passive_leader=yes
        [/ai]
    [/side]

    # Side=6 Alastra Human Lieutenant
    [side]
        side=6
        type=Javelineer
        id=Alastra
        name= _ "Alastra"
        canrecruit=yes
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_INTELLIGENT}
        [/modifications]
        {GOLD 75 100 125}
        {INCOME 5 6 7}
        controller=ai
        shroud=no
        fog=no
        team_name=human_ally
        user_team_name=_"Human Allies"
        {FLAG_VARIANT undead}
#ifdef EASY
        recruit=Spearman, Pikeman, Swordsman, Javelineer, Cavalryman, Bowman, Longbowman, Heavy Infantryman
#endif
#ifdef NORMAL
        recruit=Spearman, Pikeman, Swordsman, Javelineer, Cavalryman, Dragoon, Bowman, Longbowman, Shock Trooper
#endif
#ifdef HARD
        recruit=Spearman, Pikeman, Swordsman, Javelineer, Cavalryman, Dragoon, Bowman, Longbowman, Shock Trooper
#endif
        [ai]
#ifdef EASY
            recruitment_pattern=scout, fighter, archer
#endif

#ifdef NORMAL
            recruitment_pattern=scout, fighter, archer
#endif

#ifdef HARD
            recruitment_pattern=scout, fighter, archer
#endif

            aggression=0.6
            caution=0.25
            passive_leader=yes
        [/ai]
    [/side]

    # Side=7 Crab Man's side
    [side]
        side=7
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
    [/side]

    # Side=8 Eloh’s side
    [side]
        side=8
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=human_ally
        user_team_name=_"Human Allies"
    [/side]

    {LOYALIST_COLOR_SHIFT}

    # Prestart functions:
    # increase cost of all units by 1
    # insert items onto map
    # increase cost of recruiting units
    # place item images on map
    # recall main heroes
    # initialize starting variables
    # remove shroud surrounding starting position
    # set starting scenario objectives
    # capture elves' starting villages

    [event]
        name=prestart

        {INCREASE_RECRUIT_COSTS 1}

        # add items to map

        # merfolk trapped in cages
        {PLACE_IMAGE "units/merfolk/warrior.png~RC(magenta>red)" 25 36}
        {PLACE_IMAGE items/cage.png 25 36}

        {PLACE_IMAGE "units/merfolk/warrior.png~RC(magenta>red)" 34 31}
        {PLACE_IMAGE items/cage.png 34 31}

        {PLACE_IMAGE "units/merfolk/spearman.png~RC(magenta>red)" 18 32}
        {PLACE_IMAGE items/cage.png 18 32}

        {PLACE_IMAGE "units/merfolk/priestess.png~RC(magenta>red)" 31 25}
        {PLACE_IMAGE items/cage.png 31 25}

        {PLACE_IMAGE "units/merfolk/enchantress.png~RC(magenta>red)" 27 19}
        {PLACE_IMAGE items/cage.png 27 19}

        # human ships
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>purple)" 12 10}
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>purple)" 9 12}
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>purple)" 15 14}
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>purple)" 10 15}

        # recall heroes

        [recall]
            id=Nym
        [/recall]

        [recall]
            id=Zhul
        [/recall]

        # recall dwarf/troll
        [recall]
            id=$ally_name
        [/recall]
        # wmllint: recognize Grog
        # wmllint: recognize Nog
        # wmllint: recognize Rogrimir
        # wmllint: recognize Jarl
        [recall]
            id=Esanoo
            x,y=46,42
        [/recall]
        [recall]
            id=Kromph
        [/recall]

        #initialize starting variables

        [set_variable]
            name=number_merfolk_caged
            value=5
        [/set_variable]
        [set_variable]
            name=number_merfolk_deaths
            value=0
        [/set_variable]

        #remove shroud surrounding starting position
        [remove_shroud]
            x=37-55
            y=41-51
            side=1
        [/remove_shroud]

        # set starting scenario objectives

        [objectives]
            [objective]
                description= _ "Rescue at least two merfolk by turn 16"
                condition=win
                [show_if]
                    {VARIABLE_CONDITIONAL number_merfolk_caged greater_than 0}
                [/show_if]
            [/objective]
            [objective]
                description= _ "Defeat Tanstafaal and Eloh"
                condition=win
                [show_if]
                    [have_unit]
                        id=Tanstafaal,Eloh
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Capture all 4 human ships"
                condition=win
                [show_if]
                    {VARIABLE_CONDITIONAL capture_ships boolean_equals yes}
                [/show_if]
            [/objective]
            [objective]
                description= _ "Three merfolk must survive"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kaleh"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Nym"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Zhul"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

        #create starting elves
        [unit]
            type=Quenoth Fighter
            id=Ulothanir
            name= _ "Ulothanir"
            x=47
            y=48
            side=1
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        [unit]
            type=Quenoth Scout
            id=Elonea
            name= _ "Elonea"
            x=44
            y=48
            side=1
            [modifications]
                {TRAIT_DEXTROUS}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        # capture elves' starting villages
        [capture_village]
            x=42-49
            y=45-47
            side=1
        [/capture_village]
    [/event]

    # Event 1: Starting dialogue & humans jump out of forest and attack Esanoo

    [event]
        name=start
        [message]
            speaker=Kaleh
            message= _ "Now that we’re down off the hills, you can’t even see all that water, it’s hidden by the trees. I never thought I would see so many trees in one place."
        [/message]
        [message]
            speaker=Zhul
            message= _ "Compared to the desert it seems almost like a paradise. All this growth and vegetation, I can feel it pulsing with life."
        [/message]
        [message]
            speaker=Nym
            message= _ "And yet these trees seem different, the forest seems darker, somehow. I prefer to stay out in the open where I can see my enemies coming."
        [/message]

        {MESSAGE_DEPEND_ON_ALLY
        (
            [message]
                speaker=Grog
                message= _ "Trees look big and strong, like trolls. Dark, too. Grog tired of walking under hot sun."
            [/message]
        )
        (
            [message]
                speaker=Nog
                message= _ "Trees look big and strong, like trolls. Dark, too. Nog tired of walking under hot sun."
            [/message]
        )
        (
            [message]
                speaker=Rogrimir
                message= _ "It looks nice and dark under the trees, less exposed to that blazing sun. I’m exhausted after walking across all that harsh sand."
            [/message]
        )
        (
            [message]
                speaker=Jarl
                message= _ "It looks nice and dark under the trees, less exposed to that blazing sun. I’m exhausted after walking across all that harsh sand."
            [/message]
        )}

        [message]
            speaker=Esanoo
            message= _ "This is where the human encampments lie, to the northwest. They have settled a chain of islands along the coast of the water. If you break through these trees you will soon see them. I think that’s where they are holding the rest of my group."
        [/message]
        [message]
            speaker=Esanoo
            message= _ "My master wanted to make sure that if one of us was captured, we couldn’t betray her location. So she didn’t tell us where she was, but she taught us a simple spell to divine her hiding place. But it requires three merfolk to cast. So in order to find her, we must rescue at least two of my people. Though I hope we can save all of them."
        [/message]
        [message]
            speaker=Zhul
            message= _ "And you said that there are only five others in your group left?"
        [/message]
        [message]
            speaker=Esanoo
            message= _ "We originally numbered much more, but we were ambushed by a band of naga on the way here. Half of our force held off the naga while the rest of us fled. By the time we got to these shores, only six of us were left. But for the grace of the Sea God I managed to hide when the rest of my group was ambushed and captured. I doubt that they have been broken yet, but I do not know how long they can last. Remember, without three of us, you will not be able to find my master."
        [/message]
        [message]
            speaker=Nym
            message= _ "Wait, did you hear that?"
            image=portraits/nym_moody.png
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Someone’s coming. Quick, hide!"
        [/message]
        [message]
            speaker=Esanoo
            message= _ "What? Huh?"
        [/message]
        [scroll_to]
            x=46
            y=39
        [/scroll_to]

        {NAMED_UNIT 2 "Spearman"   45 42 (scout1) ( _ "Human Scout") (animate=yes)}
        {NAMED_UNIT 2 "Javelineer" 47 42 (scout2) ( _ "Human Scout") (animate=yes)}

        [redraw]
        [/redraw]

        [message]
            id=scout1
            message= _ "Hey, what do we have here?"
        [/message]
        [message]
            speaker=Esanoo
            message= _ "Uh... Uh..."
        [/message]
        [message]
            id=scout2
            message= _ "It’s another one of those fish creatures. It must have come back to try to rescue its friends."
        [/message]
        [message]
            id=scout1
            message= _ "Ha, stupid creature. But we’re in luck, the council was looking for the last of these spies."
        [/message]
        [message]
            id=scout2
            message= _ "We’d better get him back to the base. They’re going to sacrifice them all in some big holy ceremony at dawn just two days from now."
        [/message]
        [message]
            id=scout1
            message= _ "Yeah, we’ll be heroes!"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Not if we gut you first. Attack!"
        [/message]
        [message]
            id=scout1
            message= _ "The Dark Lady protect us, they’re elves!"
        [/message]
        [message]
            id=scout2
            message= _ "There’s tons of them! Flee, we must warn the others!"
        [/message]
        [move_unit]
            id=scout1
            to_x=44
            to_y=38
        [/move_unit]
        [move_unit]
            id=scout2
            to_x=46
            to_y=38
        [/move_unit]
        [kill]
            id=scout1,scout2
            animate=no
        [/kill]
        [message]
            speaker=Nym
            message= _ "Well, so much for the element of surprise."
        [/message]
        [message]
            speaker=Esanoo
            message= _ "Thank you. I’m sorry, I don’t know what came over me. They just jumped out of nowhere."
        [/message]
        [message]
            speaker=Nym
            message= _ "It’s fine, you’re not used to being on dry ground, and you’ve been through a lot. Even if the humans know we’re coming, we can still take them. Just be careful and stay in the back until we reach the water again."
        [/message]
        [message]
            speaker=Esanoo
            message= _ "I sure will look forward to that. I’m afraid my scales have all dried out again. It itches something terrible."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Well if we’re going to save those merfolk, then we don’t have any time to lose. The humans said they would be sacrificed in just two days. We’d better set up camp here and push on north west as soon as possible. I just hope we can make it in time."
        [/message]
        [terrain]
            x,y=45, 46
            terrain=Ke
        [/terrain]
        [terrain]
            x=44, 45, 46, 44, 45, 46
            y=45, 45, 45, 46, 47, 46
            terrain=Ce
        [/terrain]

        #add human scouts to jungle

        #western peninsula
        {NAMED_GENERIC_UNIT 6 (Swordsman) 28 43 () ( _ "Human Scout")}

        #central peninsula

        {NAMED_GENERIC_UNIT 2 (Javelineer) 34 40 () ( _ "Human Scout")}
        {NAMED_GENERIC_UNIT 2 (Bowman) 26 38 () ( _ "Human Scout")}

#ifndef EASY
        {NAMED_GENERIC_UNIT 2 (Spearman) 32 37 () ( _ "Human Scout")}
#endif
        #north eastern peninsula
        {NAMED_GENERIC_UNIT 5 (Cavalryman) 42 34 () ( _ "Human Scout")}

#ifndef EASY
        {NAMED_GENERIC_UNIT 5 (Heavy Infantryman) 42 37 () ( _ "Human Scout")}
#endif

        {NAMED_GENERIC_UNIT 5 (Spearman) 46 36 () ( _ "Human Scout")}

        #add a few human soldiers to islands

        #two southern islands with caged merfolk
        #{NAMED_GENERIC_UNIT 6 (Spearman) 25 34 () ( _ "Human Soldier")}
        {NAMED_GENERIC_UNIT 5 (Bowman) 34 30 () ( _ "Human Soldier")}

        #western island with base
        {NAMED_GENERIC_UNIT 6 (Heavy Infantryman) 20 33 () ( _ "Human Soldier")}

        #north eastern island with base
        {NAMED_GENERIC_UNIT 5 (Pikeman) 33 26 () ( _ "Human Soldier")}

        #central island
        {NAMED_GENERIC_UNIT 2 (Cavalryman) 23 30 () ( _ "Human Soldier")}

        #capture villages

        [capture_village]
            x,y=16-44, 22-45
            side=2
        [/capture_village]
        [capture_village]
            x=30, 35, 16
            y=45, 42, 35
            side=6
        [/capture_village]
        [capture_village]
            x=44, 42, 32
            y=37, 34, 31
            side=5
        [/capture_village]
    [/event]

    # (event 3): check if all merfolk have been freed

    # if number_merfolk_caged = 0
    # have humans retreat, go to eloh event

    # I need to put this before events 2 (rescuing of merfolk) because this
    # is actually a macro that gets called by events 2

#define CHECK_IF_FREED_ALL_MERFOLK
    [set_variable]
        name=number_merfolk_caged
        sub=1
    [/set_variable]
    [fire_event]
        name=merfolk_all_freed
    [/fire_event]
#enddef

    [event]
        name=merfolk_all_freed

        [filter_condition]
            [variable]
                name=number_merfolk_caged
                numerical_equals=0
            [/variable]
        [/filter_condition]

        [if]
            [have_unit]
                id=Esanoo
            [/have_unit]
            [then]
                [message]
                    speaker=Esanoo
                    message= _ "Wonderful! We have rescued all of my band from the humans. I cannot thank you enough."
                [/message]
                [message]
                    race=merman
                    [not]
                        id=Esanoo
                    [/not]
                    message= _ "Indeed, we owe you a great debt. You have done well Esanoo, better than I could have hoped."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Nym
                    message= _ "Esanoo said there were five merfolk left in his band. I think we have rescued them all!"
                [/message]
                [message]
                    race=merman
                    message= _ "Indeed, I think you have now freed all of us. We owe you a great debt. We are sorry that Esanoo has fallen, but we will honor him and tell everyone the story of his great deeds. Glad are we that he found you and brought you to us. Even the smallest fish can change the course of the sea."
                [/message]
            [/else]
        [/if]

        # have humans retreat
        [if]
            [have_unit]
                id=Darius
            [/have_unit]
            [then]
                [remove_shroud]
                    x=20-24
                    y=21-25
                    side=1
                [/remove_shroud]
                [message]
                    speaker=Darius
                    message= _ "Curse them! The elves have freed the merfolk. We will be have our vengeance. Keep fighting, and execute plan C!"
                [/message]
                [fire_event]
                    name=retreat_darius_alive
                [/fire_event]
            [/then]
            [else]
                [fire_event]
                    name=retreat_darius_dead
                [/fire_event]
            [/else]
        [/if]

        [fire_event]
            name=eloh_appears
        [/fire_event]
    [/event]

    # Event 2: Freeing Merfolk

    # locations of first 4 merfolk
    # x=25, 34, 18, 31
    # y=36, 31, 32, 25
    # 1 Merman Warrior  Urruga (1st NW island) - quick
    # 2 Merman Warrior  Nuvassa (1st NE island) - strong
    # 3 Merman Spearman Yantili (2nd NW sandy island) - resilient
    # 4 Mermaid Priestess  Il-tian (2nd NE grass island) - quick

    # 5 Mermaid Enchantress is in NE cave 9 - intelliegt

    [event]
        name=first_rescue_response_male

        [if]
            [have_unit]
                id=Esanoo
            [/have_unit]
            [then]
                [message]
                    speaker=Esanoo
                    message= _ "I have returned with the elves we sought. They have agreed to help me rescue the rest of our group from the foul humans."
                [/message]
                [message]
                    speaker=unit
                    message= _ "Indeed you have done well, far better than I could have hoped. We shall talk more later, but for now we have to free the rest of our brethren."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Kaleh
                    message= _ "Greetings. Esanoo told us that you were looking for us, and he bravely led us here. Though he has fallen in combat, we have come to rescue the rest of your kind."
                [/message]
                [message]
                    speaker=unit
                    message= _ "Yes, I recognize your face, young elf. We will remember Esanoo’s sacrifice. But for now we must rescue the rest of my brethren before they too are slain by the foul humans."
                [/message]
                [message]
                    speaker=Nym
                    message= _ "How could he recognize your face? We’ve never seen him before."
                [/message]
                [message]
                    speaker=Kaleh
                    message= _ "We’ll ask later, for now we’ve got to keep fighting."
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=first_rescue_response_female

        [if]
            [have_unit]
                id=Esanoo
            [/have_unit]
            [then]
                [message]
                    speaker=Esanoo
                    message= _ "I have returned with the elves we sought. They have agreed to help me rescue the rest of our group from the foul humans."
                [/message]
                [message]
                    speaker=unit
                    # wmllint: local spelling female_speaker
                    message= _ "female_speaker^Indeed you have done well, far better than I could have hoped. We shall talk more later, but for now we have to free the rest of our brethren."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Kaleh
                    # wmllint: local spelling female_addressed
                    message= _ "female_addressed^Greetings. Esanoo told us that you were looking for us, and he bravely led us here. Though he has fallen in combat, we have come to rescue the rest of your kind."
                [/message]
                [message]
                    speaker=unit
                    message= _ "female_speaker^Yes, I recognize your face, young elf. We will remember Esanoo’s sacrifice. But for now we must rescue the rest of my brethren before they too are slain by the foul humans."
                [/message]
                [message]
                    speaker=Nym
                    message= _ "How could she recognize your face? We’ve never seen her before."
                [/message]
                [message]
                    speaker=Kaleh
                    message= _ "We’ll ask later, for now we’ve got to keep fighting."
                [/message]
            [/else]
        [/if]
    [/event]

    # Merman Warrior Urruga (1st NW island)

    [event]
        name=moveto
        id=rescue_urruga

        [filter]
            x,y=25, 36
            side=1
        [/filter]

        [remove_item]
            x,y=25, 36
        [/remove_item]
        [unit]
            type=Merman Warrior
            id=Urruga
            name= _ "Urruga"
            side=1
            x=25
            y=36
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [if]
            [variable]
                name=number_merfolk_caged
                numerical_equals=5
            [/variable]
            [then]
                [message]
                    speaker=Urruga
                    message= _ "Free at last! Thanks be to the Sea God. But wait a minute, you’re elves?!"
                [/message]
                [fire_event]
                    name=first_rescue_response_male
                    [primary_unit]
                        id=Urruga
                    [/primary_unit]
                [/fire_event]
            [/then]
            [else]
                [message]
                    speaker=Urruga
                    message= _ "Thank you for rescuing me. We’ll show those humans the true fury of the merfolk!"
                [/message]
            [/else]
        [/if]
        {CHECK_IF_FREED_ALL_MERFOLK}
    [/event]

    # Merman Warrior Nuvassa (1st NE island)

    [event]
        name=moveto
        id=rescue_nuvassa
        [filter]
            x,y=34, 31
            side=1
        [/filter]

        [remove_item]
            x,y=34, 31
        [/remove_item]
        [unit]
            type=Merman Warrior
            id=Nuvassa
            name= _ "Nuvassa"
            side=1
            x=34
            y=31
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [if]
            [variable]
                name=number_merfolk_caged
                numerical_equals=5
            [/variable]
            [then]
                [fire_event]
                    name=first_rescue_response_male
                    [primary_unit]
                        id=Nuvassa
                    [/primary_unit]
                [/fire_event]
            [/then]
            [else]
                [message]
                    speaker=Nuvassa
                    message= _ "Thank you for rescuing me. You elves are very skilled at fighting on the dry land. I envy you."
                [/message]
                [message]
                    speaker=$unit.id
                    race=elf
                    message= _ "As I envy your kind’s prowess when fighting in the water."
                [/message]
            [/else]
        [/if]
        {CHECK_IF_FREED_ALL_MERFOLK}
    [/event]

    # Merman Spearman Yantili (2nd NW sandy island)

    [event]
        name=moveto
        id=rescue_yantili
        [filter]
            x,y=18, 32
            side=1
        [/filter]

        [remove_item]
            x,y=18, 32
        [/remove_item]
        [unit]
            type=Merman Spearman
            id=Yantili
            name= _ "Yantili"
            side=1
            x=18
            y=32
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [if]
            [variable]
                name=number_merfolk_caged
                numerical_equals=5
            [/variable]
            [then]
                [fire_event]
                    name=first_rescue_response_male
                    [primary_unit]
                        id=Yantili
                    [/primary_unit]
                [/fire_event]
            [/then]
            [else]
                [message]
                    speaker=Yantili
                    message= _ "Thank you for rescuing me. I never imagined that we would actually be able to find you elves. Our master was right after all. But more of that later..."
                [/message]
            [/else]
        [/if]
        {CHECK_IF_FREED_ALL_MERFOLK}
    [/event]

    # Mermaid Priestess  Il-tian (2nd NE grass island)

    [event]
        name=moveto
        id=rescue_iltian
        [filter]
            x,y=31, 25
            side=1
        [/filter]

        [remove_item]
            x,y=31, 25
        [/remove_item]
        [unit]
            type=Mermaid Priestess
            id=Il-tian
            name= _ "Il-tian"
            side=1
            x=31
            y=25
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [if]
            [variable]
                name=number_merfolk_caged
                numerical_equals=5
            [/variable]
            [then]
                [fire_event]
                    name=first_rescue_response_female
                    [primary_unit]
                        id=Il-tian
                    [/primary_unit]
                [/fire_event]
            [/then]
            [else]
                [message]
                    speaker=Il-tian
                    message= _ "Thank you for rescuing me. May the Sea God’s bounty bless you and protect you. If you have any wounded I can help heal them. The blades of the vile humans are terrible indeed."
                [/message]
            [/else]
        [/if]
        {CHECK_IF_FREED_ALL_MERFOLK}
    [/event]

    # We-jial Mermaid Enchantress, trapped in cave

    # when unit enters cave

    [event]
        name=moveto
        [filter]
            x=27-32
            y=17-20
            side=1
        [/filter]

        [message]
            speaker=unit
            message= _ "What a dark nasty place. Something smells horrible."
        [/message]
#ifdef EASY
        {NAMED_UNIT 4 (Walking Corpse) 27 18 () ( _ "Undead Warden") (upkeep=free)}
        {NAMED_UNIT 4 (Walking Corpse) 28 19 () ( _ "Undead Warden") (upkeep=free)}
#else
        {NAMED_UNIT 4 (Soulless) 27 18 () ( _ "Undead Warden") (upkeep=free)}
        {NAMED_UNIT 4 (Walking Corpse) 28 19 () ( _ "Undead Warden") (upkeep=free)}
#endif
    [/event]

    # freeing mermaid enhcantress trapped in cave

    [event]
        name=moveto
        id=rescue_wejial
        [filter]
            x,y=27, 19
            side=1
        [/filter]

        [remove_item]
            x,y=27, 19
        [/remove_item]
        [unit]
            type=Mermaid Enchantress
            id=We-jial
            name= _ "We-jial"
            side=1
            x=29
            y=19
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [message]
            speaker=We-jial
            message= _ "Thank you for rescuing me. How did you manage to escape?"
        [/message]
        {CHECK_EXPLORER}
        [if]
            [variable]
                name=explorer.id
                equals=Esanoo
            [/variable]
            [then]
                [message]
                    speaker=$explorer.id
                    message= _ "One of the elves we were searching for helped me get away before I was caught. I can’t believe the humans imprisoned you in such a horrible place. To be stuck in the darkness with those undead. We will make them pay for what they have done!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=$explorer.id
                    message= _ "Esanoo found the elves that we were searching for. He brought them back and they helped free us. I can’t believe the humans imprisoned you in such a horrible place. To be stuck in the darkness with those undead. We will make them pay for what they have done!"
                [/message]
            [/else]
        [/if]
        [message]
            speaker=We-jial
            message= _ "Do not worry yourself, now that I am free all will be set to rights. It is not our mission to defeat all the evil in this world. Protecting the elves is most important. We must bring them to our master; all else is secondary."
        [/message]
        [message]
            speaker=$explorer.id
            message= _ "Yes, you are right, of course. Pardon me."
        [/message]
        {CLEAR_VARIABLE explorer}
        {CHECK_IF_FREED_ALL_MERFOLK}
    [/event]

    # Event 2.1: Merfolk death counter

    # Each time a merfolk dies after caged merfolk have been killed,
    # increment death count
    # if death count = 4, then the number of merfolk alive (in cages and free) < 3 -> defeat

    [event]
        name=die
        first_time_only=no

        [filter]
            race=merman
            side=1
        [/filter]

        [set_variable]
            name=number_merfolk_deaths
            add=1
        [/set_variable]

        [if]
            [variable]
                name=number_merfolk_deaths
                greater_than_equal_to=4
            [/variable]
            [then]
                [if]
                    [variable]
                        name=number_merfolk_caged
                        equals=0
                    [/variable]
                    [then]
                        # no merfolk left in cages
                        [message]
                            speaker=Kaleh
                            message= _ "No, too many merfolk have died! There are not enough of them left to divine the location of their master. We should have protected the merfolk more carefully. Now our search is hopeless."
                        [/message]
                    [/then]
                    [else]
                        # still some in cages
                        [message]
                            speaker=Kaleh
                            message= _ "Too many merfolk have died! Even if we save the rest, there will not be enough for them to divine the location of their master. We should have protected the merfolk more carefully. Now our search is hopeless."
                        [/message]
                    [/else]
                [/if]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]
        [/if]
    [/event]

    # Event 2.2 Elves discover salt water

    [event]
        name=moveto

        [filter]
            side=1
            race=elf
            [filter_location]
                terrain=W*
            [/filter_location]
        [/filter]

        [message]
            speaker=unit
            message= _ "Whoa, this water is warm. Imagine if we had this back home, more water than I could drink in a lifetime! Hey... wait a minute. Faugh! This water is salty! It tastes terrible, I can’t drink this! What use is all this water if you can’t drink it?"
        [/message]
        [allow_undo]
        [/allow_undo]
    [/event]

    # Event 2.3 Easter egg message
    # If an elf or merfolk goes out to the end of the island chain

    # if unit is an elf

    [event]
        name=moveto

        [filter]
            x,y=6, 38
            side=1
            race=elf
        [/filter]

        [if]
            [have_unit]
                # wmllint: recognize Eloh
                id=Eloh
            [/have_unit]
            [then]
                [message]
                    speaker=unit
                    message= _ "It really is beautiful out here, looking out over the sparkling water. If I didn’t have vile humans and traitorous elves at my back I could spend all day just sitting out here. But I really should get back to the battle. Ah, it’s a hard knock life."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=unit
                    message= _ "It really is beautiful out here, looking out over the sparkling water. If I didn’t have vile humans and Eloh knows what else at my back I could spend all day just sitting out here. But I really should get back to the battle. Ah, it’s a hard knock life."
                [/message]
            [/else]
        [/if]
    [/event]

    # if unit is a merfolk

    [event]
        name=moveto
        [filter]
            x,y=6, 38
            side=1
            race=merman
        [/filter]
        [message]
            speaker=unit
            message= _ "If I were a landwalker, I might think the view from this sandbar to be amazing. But I am a creature of the sea and I see views like this every day."
        [/message]
    [/event]

    # Event 2.5 Elves encounter human leaders

    [event]
        name=moveto
        id=approach_zelgant
        [filter]
            x=27-35
            y=23-28
            side=1
        [/filter]
        [filter_condition]
            [have_unit]
                id=Zelgant
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Zelgant
            message= _ "You trespass upon our land at your own peril. All who oppose the will of the Iron Council shall be crushed!"
        [/message]
    [/event]
    [event]
        name=moveto
        id=approach_alastra
        [filter]
            x=15-21
            y=31-36
            side=1
        [/filter]
        [filter_condition]
            [have_unit]
                id=Alastra
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Alastra
            message= _ "Foolish elves. We have heard of your pitiful kind. You are but worms compared to the might of the Dark Lady. Coming here shall be your undoing."
        [/message]
    [/event]
    [event]
        name=moveto
        id=approach_darius
        [filter]
            x=19-26
            y=22-26
            side=1
        [/filter]
        [filter_condition]
            [have_unit]
                id=Darius
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Darius
            message= _ "She said you would come. You may be able to defeat us, but none can defy her. You will bow down in the end. It is your destiny."
        [/message]
    [/event]

    # Event 4: Time runs out

    # turn = 16 and number_merfolk_caged > 0
    # kill all captured merfolk
    # (if all merfolk have been freed except hidden mermaid enchantress
    # then change the message that gets displayed, because player will not
    # see mermaid die)
    # then set merfolk_freed to 5
    # if number_merfolk_deaths is >= 4, defeat
    # else, have humans retreat, go to eloh event

    [event]
        name=turn 16

        [filter_condition]
            [variable]
                name=number_merfolk_caged
                greater_than=0
            [/variable]
        [/filter_condition]

        # Remove any remaining rescue events
        [remove_event]
            id=rescue_urruga
        [/remove_event]
        [remove_event]
            id=rescue_nuvassa
        [/remove_event]
        [remove_event]
            id=rescue_yantili
        [/remove_event]
        [remove_event]
            id=rescue_iltian
        [/remove_event]
        [remove_event]
            id=rescue_wejial
        [/remove_event]

        # To do: add dialogue when merfolk die

        # remove shroud around human leader

        [if]
            [have_unit]
                id=Darius
            [/have_unit]
            [then]
                [remove_shroud]
                    x=20-24
                    y=21-25
                    side=1
                [/remove_shroud]
                [message]
                    speaker=Darius
                    message= _ "The time has come. On this most holy day, let us sacrifice these infidels unto the Dark Lady. Their suffering shall be a testament to her power and glory!"
                [/message]
            [/then]
            [else]
                # introduce new necromancer triad member

                [remove_shroud]
                    x=13-17
                    y=26-30
                    side=1
                [/remove_shroud]
                {NAMED_NOTRAIT_UNIT 4 (Necromancer) 15 28 (Hekuba) ( _ "Hekuba")}
                [+unit]
                    random_gender=no
                [/unit]
                [message]
                    speaker=Hekuba
                    message= _ "The time has come, my brethren. On this most holy day, let us sacrifice these infidels unto The Dark Lady. Their suffering shall be a testament to her power and glory!"
                [/message]

                # Hekuba disappears again
                [kill]
                    id=Hekuba
                    animate=no
                    fire_event=no
                [/kill]
            [/else]
        [/if]

        #have screen flash red

        [color_adjust]
            red,green,blue=255, 0, 0
        [/color_adjust]
        [redraw]
        [/redraw]
        [delay]
            time=100
        [/delay]
        [color_adjust]
            red,green,blue=0, 0, 0
        [/color_adjust]
        [redraw]
        [/redraw]

        [if]
            [have_location]
                x,y=27,19
                [filter_vision]
                    side=1
                    visible=no
                    respect_fog=no
                [/filter_vision]
            [/have_location]

            [variable]
                name=number_merfolk_caged
                numerical_equals=1
            [/variable]
            [then]
                [if]
                    [have_unit]
                        id=Esanoo
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Esanoo
                            message= _ "Oh no! Our enchantress, We-jial. Where did they hide her? What horrible fate has befallen her? If only we could have saved her in time."
                        [/message]
                        [message]
                            race=merman
                            message= _ "The Sea God will carry her soul out to sea and bear it to the deeps. May he watch over her until the day we are all together again."
                        [/message]
                    [/then]
                    [else]
                        [message]
                            speaker=Zhul
                            message= _ "Esanoo said there were five merfolk captured. We only found four. Where did they hide the last one? What horrible acts have these humans committed?"
                        [/message]

                        [message]
                            race=merman
                            message= _ "They took We-jial, our enchantress, away from us. But she is at peace now. The Sea God will carry her soul out to sea and bear it to the deeps. May he watch over her until the day we are all together again."
                        [/message]
                    [/else]
                [/if]
            [/then]
            [else]
                [message]
                    speaker=Kaleh
                    message= _ "The bars of the cages are smoking and glowing red hot!"
                [/message]
                [if]
                    [have_unit]
                        id=Esanoo
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Esanoo
                            message= _ "May the Sea God protect us. They are being burnt alive! It’s terrible, I can’t bear to watch."
                        [/message]
                        [message]
                            race=merman
                            message= _ "The Sea God will carry their souls out to sea and bear them to the deeps. May he watch over them until the day we are all together again."
                        [/message]
                    [/then]
                    [else]
                        [message]
                            speaker=Zhul
                            message= _ "Eloh protect us. They are being burnt alive! I do not know what the purpose of the unholy sacrifice is, but it is sickening to watch."
                        [/message]
                        [message]
                            race=merman
                            message= _ "The Sea God will carry their souls out to sea and bear them to the deeps. May he watch over them until the day we are all together again."
                        [/message]
                    [/else]
                [/if]
            [/else]
        [/if]

        # destroy images of captured merfolk
        [remove_item]
            x=25,34,18,31,27
            y=36,31,32,25,19
        [/remove_item]

        [set_variable]
            name=number_merfolk_deaths
            add=$number_merfolk_caged
        [/set_variable]
        [set_variable]
            name=number_merfolk_caged
            value=0
        [/set_variable]

        # if player hasn't kept 3 merfolk alive then defeat
        [if]
            [variable]
                name=number_merfolk_deaths
                greater_than_equal_to=4
            [/variable]
            [then]
                [message]
                    speaker=Esanoo
                    message= _ "They are all dead. We were too late. Forgive me, master!"
                [/message]
                [message]
                    speaker=Kaleh
                    message= _ "We couldn’t save enough of the merfolk. We have failed. Now we shall never be able to meet the merfolk’s leader!"
                [/message]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]

            # Else Esanoo laments those who died
            # Assume that at least some merfolk have died because
            # if all 5 merfolk were saved this event would never have fired

            [else]
                [message]
                    speaker=Esanoo
                    message= _ "Oh Master, forgive me. I could not save them all in time. Vile humans, you shall pay twice over for what you have done!"
                [/message]

                # have humans retreat

                [if]
                    [have_unit]
                        id=Darius
                    [/have_unit]
                    [then]
                        [remove_shroud]
                            x=20-24
                            y=21-25
                            side=1
                        [/remove_shroud]
                        [message]
                            speaker=Darius
                            # wmllint: local spelling stinkin'
                            message= _ "The stinkin’ elves have freed some of the merfolk. And still they fight on. Execute plan B. And kill those merfolk!"
                        [/message]

                        [fire_event]
                            name=retreat_darius_alive
                        [/fire_event]
                    [/then]
                    [else]
                        [fire_event]
                            name=retreat_darius_dead
                        [/fire_event]
                    [/else]
                [/if]

                [fire_event]
                    name=eloh_appears
                [/fire_event]
            [/else]
        [/if]
    [/event]

    [event]
        name=retreat_darius_alive

        [message]
            speaker=Darius
            message= _ "I must go report to the Iron Council. Keep fighting!"
        [/message]
        [store_unit]
            [filter]
                id=Darius
            [/filter]

            kill=yes
            variable=stored_Darius
        [/store_unit]
        [if]
            [have_unit]
                id=Zelgant
            [/have_unit]
            [then]
                [message]
                    speaker=Zelgant
                    message= _ "I go to marshal reinforcements. Do not lose heart, we will crush these puny elves."
                [/message]
                [store_unit]
                    [filter]
                        id=Zelgant
                    [/filter]

                    kill=yes
                    variable=stored_Zelgant
                [/store_unit]
            [/then]
        [/if]
        [if]
            [have_unit]
                id=Alastra
            [/have_unit]
            [then]
                [message]
                    speaker=Alastra
                    message= _ "I must leave for now, fight on in my stead."
                [/message]
                [store_unit]
                    [filter]
                        id=Alastra
                    [/filter]

                    kill=yes
                    variable=stored_Alastra
                [/store_unit]
            [/then]
        [/if]
    [/event]

    [event]
        name=retreat_darius_dead

        # introduce new necromancer triad member

        [remove_shroud]
            x=13-17
            y=26-30
            side=1
        [/remove_shroud]

        {NAMED_NOTRAIT_UNIT 4 (Necromancer) 15 28 (Hekuba) ( _ "Hekuba")}
        [+unit]
            random_gender=no
        [/unit]

        [message]
            speaker=Hekuba
            message= _ "Curse them! The elves have stolen our offering to the Lady. We will have our vengeance. Keep fighting and execute plan C!"
        [/message]
        [kill]
            id=Hekuba
            animate=no
            fire_event=no
        [/kill]
        [message]
            speaker=Nym
            message= _ "Who was that?"
        [/message]
        [message]
            race=merman
            message= _ "That was one of the Iron Triad. Rarely do they leave their sanctuary. They prefer to let their minions do the dirty work."
        [/message]

        [if]
            [have_unit]
                id=Zelgant
            [/have_unit]
            [then]
                [message]
                    speaker=Zelgant
                    message= _ "I go to marshal reinforcements. Do not lose heart, we will crush these puny elves."
                [/message]
                [store_unit]
                    [filter]
                        id=Zelgant
                    [/filter]

                    kill=yes
                    variable=stored_Zelgant
                [/store_unit]
            [/then]
        [/if]
        [if]
            [have_unit]
                id=Alastra
            [/have_unit]
            [then]
                [message]
                    speaker=Alastra
                    message= _ "I must go report to the Iron Council. Keep fighting!"
                [/message]
                [store_unit]
                    [filter]
                        id=Alastra
                    [/filter]

                    kill=yes
                    variable=stored_Alastra
                [/store_unit]
            [/then]
        [/if]
    [/event]

    # Event 4.5:
    # Appearance of Eloh and Tanstafaal
    # Kaleh can no longer recruit elves
    # Merfolk offer to help Kaleh cross the water

    # Event 5 (nested): One turn after Eloh appears Zhul leaves Kaleh and is imprisoned

    # Event 6 (nested): If Flesh Golem is alive, 6 turns after eloh appears
    # he turns against the elves

    [event]
        name=eloh_appears

        #cut income for side 2, 5, 6
        [modify_side]
            [filter_side]
                side=2,5,6
            [/filter_side]
            income=0
            gold=0
        [/modify_side]

        [remove_shroud]
            x=51-55
            y=14-17
            side=1
        [/remove_shroud]
        [unit]
            type=Quenoth Champion
            id=Tanstafaal
            name= _ "Tanstafaal"
            side=3
            x=52
            y=15
            canrecruit=yes
            facing=sw
            [modifications]
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        # conversation between Tanstafaal, Eloh and Elves

        [message]
            # wmllint: directory spelling Tanstafaal
            speaker=Tanstafaal
            message= _ "Hail, my brothers, I have returned!"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Tanstafaal, where have you been? We have been looking for you."
        [/message]
        [message]
            speaker=Tanstafaal
            message= _ "I have gone on a journey and I have seen the light. No longer will I blindly follow in your footsteps, Kaleh. I have come back to lead our people on the true path. She has spoken to me, and I am but an implement of her divine will."
        [/message]
        [message]
            speaker=Nym
            message= _ "Who has spoken to you?"
        [/message]
        [unit]
            type=Divine Avatar
            id=Eloh
            name= _ "Eloh"
            side=8
            x,y=53, 16
            ai_special=guardian
            random_traits=no
            facing=sw
        [/unit]
        [scroll_to_unit]
            id=Eloh
        [/scroll_to_unit]
        [message]
            speaker=Tanstafaal
            message= _ "Behold, our goddess has returned to us. All bow down to Eloh, our savior!"
        [/message]

        [role]
            type_adv_tree=Quenoth Mystic
            side=1
            [not]
                id=Zhul
            [/not]
            role=mystic_speaker
        [/role]
        [role]
            type_adv_tree=Quenoth Fighter
            side=1
            role=fighter_speaker
        [/role]
        [role]
            type_adv_tree=Quenoth Scout
            side=1
            role=scout_speaker
        [/role]
        [role]
            type_adv_tree=Tauroch Rider
            side=1
            role=rider_speaker
        [/role]

        [message]
            role=mystic_speaker
            message= _ "The Goddess!"
        [/message]
        [message]
            role=fighter_speaker
            message= _ "Forgive me my sins!"
        [/message]
        [message]
            speaker=Zhul
            message= _ "That I am so blessed to gaze upon Eloh herself..."
        [/message]
        [message]
            speaker=Eloh
            message= _ "Hail my people. In your time of trial I appear to you, to save you yet again."
        [/message]
        [message]
            speaker=Eloh
            message= _ "I come to you with dire news: one of you has betrayed me, and is a traitor to your cause."
        [/message]
        [message]
            role=mystic_speaker
            message= _ "What?"
        [/message]
        [message]
            role=scout_speaker
            message= _ "No!"
        [/message]
        [message]
            role=rider_speaker
            message= _ "Who?"
        [/message]
        [message]
            speaker=Eloh
            message= _ "Did I not say that I would deliver you from evil and bring you to the promised land? I have shepherded you out of the harsh deserts and under the mountains. And your salvation was almost at hand."
        [/message]
        [message]
            speaker=Eloh
            message= _ "But there was one who grew corrupted by his power and rejected my divine plan. He sought to usurp my authority. He had no faith and believed that he knew better than me, I who have watched over you for generations. He wanted to lead you astray. In these perilous lands, the fate of your journey stands upon the edge of a knife, falter once and all shall fail."
        [/message]
        [message]
            speaker=Eloh
            message= _ "Yes, I speak of your so-called leader, Kaleh. I did call out to him initially because I thought he was one of the faithful, but he betrayed my trust. The humans you are slaughtering wanted to help you, until Kaleh foolishly attacked them. And now Kaleh has you serving the evil merfolk and their insidious plans. Follow his path and he would have you bow down and serve the merfolk’s foul god."
        [/message]
        [message]
            speaker=Eloh
            message= _ "That is why I called out to Tanstafaal, one of my loyal followers. All is not yet lost. Follow him and I can still deliver you from your peril. But first, come back to me, stop fighting these humans, and kill this heretic Kaleh and his cronies."
        [/message]
        [if]
            [variable]
                name=ally_race
                equals=dwarf
            [/variable]
            [then]
                [message]
                    speaker=Kaleh
                    message= _ "Wait, my people, do not be deceived. This thing that appears by Tanstafaal’s side is not our god. I too was fooled at first, but I have come to realize by her actions that she is an impostor. When she appeared to me the night before Garak died, she told me to kill all that lived under the mountains, even the dwarves who ended up helping us. Likewise when we escaped from the caves, she appeared to me again, and told me to bow down to the humans, else she would destroy me. Never has Eloh threatened one of us or dictated our actions."
                [/message]
                [message]
                    role=fighter_speaker
                    message= _ "Why should we trust you? We have not heard Eloh’s words directly. Only now that you have led us into this folly has Eloh appeared to us."
                [/message]
                [message]
                    speaker=Kaleh
                    message= _ "She claims to be the one who has shepherded us during this journey, but who protected you across the harsh sands, who fought the orcs and led you under the mountains, who led you out again, against all odds? I did. I have bled for you, every step of the way. If you will not trust me based on my words, then trust me based on my actions. I have done the best I could for my people, and I stand by my actions. I believe that the merfolk are our friends, as the dwarves were. I refuse to bow down to harsh words and threats; we elves have always been free to make our own choices. We are not slaves, and will not blindly follow either humans or some false god."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Kaleh
                    message= _ "Wait, my people, do not be deceived. This thing that appears by Tanstafaal’s side is not our god. I too was fooled at first, but I have come to realize by her actions that she is an impostor. When she appeared to me the night before Garak died, she told me to kill all that lived under the mountains, even the trolls who ended up helping us. Likewise when we escaped from the caves, she appeared to me again, and told me to bow down to the humans, else she would destroy me. Never has Eloh threatened one of us or dictated our actions."
                [/message]
                [message]
                    role=fighter_speaker
                    message= _ "Why should we trust you? We have not heard these words directly. Only now that you have led us into this folly has she appeared to us."
                [/message]
                [message]
                    speaker=Kaleh
                    message= _ "She claims to be the one who has shepherded us during this journey, but who protected you across the harsh sands, who fought the orcs and led you under the mountains, who led you out again, against all odds? I did. I have bled for you, every step of the way. If you will not trust me based on my words, then trust me based on my actions. I have done the best I could for my people, and I stand by my actions. I believe that the merfolk are our friends, as the trolls were. I refuse to bow down to harsh words and threats; we elves have always been free to make our own choices. We are not slaves, and will not blindly follow either the humans or some false god."
                [/message]
            [/else]
        [/if]
        [message]
            speaker=Tanstafaal
            message= _ "Your words are meaningless, Kaleh. My brethren, Eloh has appeared to you. She has spoken. Defy her at your own peril. I declare all who oppose Eloh heretics. All who are faithful, join me and let us kill the usurpers!"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Eloh would never ask elf to kill elf. But it seems I have little choice. My people, I have led you this far, join with me and help me crush this new rebellion!"
        [/message]
        [message]
            speaker=Nym
            message= _ "I have followed you this far Kaleh, I will not abandon you now. But I admit that my faith is shaken. If that is not our god, then what is it?"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "I do not know, but given what I have seen of the humans, I think following her would lead us down a dark road indeed. One that I personally do not want to discover the end of."
        [/message]
        [message]
            speaker=Zhul
            message= _ "Forgive me, Kaleh. I do not know what to believe. I... I have to ponder this."
        [/message]

        {MESSAGE_DEPEND_ON_ALLY
        (
            [message]
                speaker=Grog
                message= _ "Great Leader told Grog to serve you, and so Grog will still follow your command. But other elves must be out on a separate island. How will we cross deep water?"
            [/message]
        )
        (
            [message]
                speaker=Nog
                message= _ "Great Leader told Nog to serve you, and so Nog will still follow your command. But other elves must be out on a separate island. How will we cross deep water?"
            [/message]
        )
        (
            [message]
                speaker=Rogrimir
                message= _ "The chieftain told me to serve you, and it will take more than this to shatter my confidence in you, lad. But those elves must be out on a different island, how will we cross the deep water?"
            [/message]
        )
        (
            [message]
                speaker=Jarl
                message= _ "The chieftain told me to serve you, and it will take more than this to shatter my confidence in you, lad. But those elves must be out on a different island, how will we cross the deep water?"
            [/message]
        )}
        # merfolk offer to help

        [message]
            race=merman
            message= _ "I believe that in this we can help. We are very grateful for all you have done for us Kaleh, and though we assure that we mean you no harm, you are right that actions speak louder than words. We are more familiar with the waters than you are, and we noticed that there are two shallow paths leading to the island where the other elves must be. We can show you these paths and help you across so that you may put down this rebellion."
        [/message]

        # change water terrain

        #western bridge

        [terrain]
            terrain=Ww
            x=36, 37, 37, 37, 37, 38, 39, 39, 39, 39, 40, 40, 40, 41
            y=23, 23, 24, 25, 26, 24, 22, 23, 24, 25, 21, 22, 23, 24
        [/terrain]
        [terrain]
            terrain=Wwr # wmllint: ignore
            x=36, 38, 40, 41
            y=24, 23, 24, 23
        [/terrain]

        #southern bridge

        [terrain]
            terrain=Ww
            x=48, 50, 50, 50, 51, 51, 51, 52, 52, 52, 53
            y=27, 27, 28, 30, 28, 29, 30, 26, 28, 29, 30
        [/terrain]
        [terrain]
            terrain=Wwr # wmllint: ignore
            x=51, 52, 50, 49, 51
            y=31, 30, 29, 28, 27
        [/terrain]

        [message]
            speaker=Kaleh
            message= _ "Thank you, I’m sure you will be very useful in the shallow waters. All right people, I don’t want to kill any more than I have to. Too much blood has been spilled already. Knock ’em out, wound them, kill them only if you must. But we must stop Tanstafaal in his lunacy before he destroys us entirely."
        [/message]
        [message]
            speaker=Nym
            message= _ "We who have fought by your side before will stand with you Kaleh, but many of our people are fleeing and joining Tanstafaal. I’m afraid that while you can recall past warriors, you won’t be able to recruit any new ones."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Then we will make do with those few that we have."
        [/message]

        [show_objectives]
        [/show_objectives]

        # move tanstafaal to keep

        [teleport]
            [filter]
                id=Tanstafaal
            [/filter]
            x,y=50, 17
        [/teleport]

        # give tanstafaal some recruits

        {NAMED_GENERIC_UNIT 3 (Quenoth Fighter) 48 16 () ( _ "Elvish Rebel")}
        {NAMED_GENERIC_UNIT 3 (Tauroch Rider) 48 18 () ( _ "Elvish Rebel")}
        {NAMED_GENERIC_UNIT 3 (Quenoth Scout) 51 19 () ( _ "Elvish Rebel")}
        {NAMED_GENERIC_UNIT 3 (Quenoth Warrior) 47 18 () ( _ "Elvish Rebel")}
        {NAMED_GENERIC_UNIT 3 (Quenoth Pathfinder) 50 20 () ( _ "Elvish Rebel")}

        # modify income and gold for rebels

        [modify_side]
            side=3
            {INCOME 9 11 13}
            {GOLD 100 125 150}
        [/modify_side]

        # cut off all recruiting for side 1 elves
        [store_side]
            side=1
            variable=stored_side_1
        [/store_side]
        [set_recruit]
            side=1
            recruit=""
        [/set_recruit]

        # Event 5: Zhul & Eloh conversation
        [event]
            name="turn $($turn_number+2)"
            delayed_variable_substitution=no

            [filter_condition]
                [have_unit]
                    id=Eloh
                [/have_unit]
            [/filter_condition]

            [message]
                speaker=Zhul
                message= _ "I’m sorry Kaleh, I cannot let our people slaughter each other. There must be a way to stop this."
            [/message]
            [message]
                speaker=Kaleh
                message= _ "No, don’t..."
            [/message]
            [message]
                speaker=Zhul
                message= _ "I have no choice, goodbye."
            [/message]
            [teleport]
                [filter]
                    id=Zhul
                [/filter]
                x,y=52, 15
            [/teleport]
            [message]
                speaker=Zhul
                message= _ "Oh Eloh, you know how long I have faithfully served you. I ask you now a boon in return. Do not kill the boy Kaleh, he is just doing what his heart tells him to do. Did you not say, <i>“To err is elven, but to forgive divine”</i>?"
            [/message]

            [message]
                speaker=Eloh
                message= _ "You dare to lecture me? I am a god and you are but a mortal. You of all people should know that your position is to enforce my will, not question it!"
            [/message]
            [message]
                speaker=Zhul
                message= _ "But you yourself can see that many of our people’s faith is wavering. You cannot gain their loyalty by slaughtering the boy and his friends. Be merciful and kind, as you have always been, and there may be no need for this self-annihilating conflict."
            [/message]
            [message]
                speaker=Eloh
                message= _ "Times have changed. Mercy is a sign of weakness. Let this be a lesson to everyone, absolute loyalty is absolute strength. It is clear that you do not understand this concept, Zhul. My people, now is a time to tear down the old guard and create a new empire of strength, fealty and glory! I shall grant those who are loyal eternal life and we will triumph over all enemies!"
            [/message]
            [message]
                speaker=Zhul
                message= _ "No, I—"
            [/message]
            [message]
                speaker=Eloh
                message= _ "No, I don’t think you shall pester me any more. You shall be as a statue, forced to watch events unfold and helpless to interfere. Yes, I think this will be an appropriate punishment. Then perhaps you will learn not to question my divine will."
            [/message]

            [petrify]
                id=Zhul
            [/petrify]
        [/event]

        # Event 6: Kromph gets controlled by Eloh

        [event]
            name="turn $($turn_number+5)"
            delayed_variable_substitution=no

            [filter_condition]
                [have_unit]
                    id=Eloh
                [/have_unit]
                [have_unit]
                    id=Kromph
                [/have_unit]
            [/filter_condition]

            [message]
                speaker=Kromph
                message= _ "Aarrggh! Voices in my head, make them stop!"
            [/message]
            [message]
                speaker=Nym
                message= _ "What? What do you hear?"
            [/message]
            [message]
                speaker=Kromph
                message= _ "Must... Can’t... Must... Help me!"
            [/message]
        [/event]
        [event]
            name="turn $($turn_number+6)"
            delayed_variable_substitution=no

            [filter_condition]
                [have_unit]
                    id=Eloh
                [/have_unit]
                [have_unit]
                    id=Kromph
                [/have_unit]
            [/filter_condition]

            [message]
                speaker=Kromph
                message= _ "Must obey... Can’t resist... I... Yes, Mistress, I am yours."
            [/message]
            [message]
                speaker=Kromph
                message= _ "Pretty lady say elves bad. Kill elves. Kill!"
            [/message]

            [modify_unit]
                [filter]
                    id=Kromph
                [/filter]
                side=3
            [/modify_unit]

            [event]
                name=die
                [filter]
                    id=Eloh
                [/filter]

                # If Kromph is under Eloh’s control, Eloh’s
                # death causes Kromph's as well.
                [filter_condition]
                    [have_unit]
                        id=Kromph
                        side=3
                    [/have_unit]
                [/filter_condition]

                [message]
                    speaker=Kromph
                    message= _ "Mistress gone, must follow commands, but Nym master too, Nym say must protect elves, but mistress say must kill elves, but must protect, must kill, protect, kill, protect, kill, augghh!!"
                [/message]
                [kill]
                    id=Kromph
                    fire_event=no
                    animate=yes
                [/kill]
                [message]
                    speaker=Kaleh
                    message= _ "He just collapsed, the conflicting orders must have been too much for him."
                [/message]
                [message]
                    speaker=Nym
                    message= _ "Poor Kromph, at least he’s finally at rest."
                [/message]
            [/event]
        [/event]
    [/event]

    # Event 7: Crabmen attack elves

    [event]
        name=moveto
        [filter]
            x=46-54
            y=26-30
            side=1
        [/filter]

        {SCATTER_UNITS 3 "Crab Man" 1 x,y,radius=50,28,3 (
            side=7
            name= _ "Angry Crab"
            role=Angry Crab
            animate=yes
        )}

        [message]
            speaker=unit
            message= _ "Where did those things come from? They look dangerous."
        [/message]
    [/event]
    [event]
        name=moveto
        [filter]
            x=39-43
            y=21-26
            side=1
        [/filter]

        {SCATTER_UNITS 3 "Crab Man" 1 x,y,radius=41,23,3 (
            side=7
            name= _ "Angry Crab"
            role=Angry Crab
            animate=yes
        )}

        [message]
            speaker=unit
            message= _ "What are those things? They looked like ticked off giant crabs."
        [/message]
    [/event]

    # event: Grand Appearance of the Iron Council
    # which happens when both Tanstafaal and Eloh die

    [event]
        name=tanstafaal_and_eloh_gone
        [filter_condition]
            [have_unit]
                id=Tanstafaal,Eloh
                count=0
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Kaleh
            message= _ "It is finished. See, my people, Tanstafaal has been killed by his own hand, and the thing pretending to be our god is gone."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "You who call yourself Eloh, I challenge you, if you are truly our god, then show yourself, and strike me down where I stand!"
        [/message]
        [delay]
            time=1000
        [/delay]
        [message]
            speaker=Kaleh
            message= _ "Nothing. Eloh may still watch over us, but that thing was not her. And yet, I do not hold a grudge against all of you who rebelled. I too was deceived at first, and unlike the pretender, I am merciful. For there are too few of us left for us to slaughter each other over minor grievances. Let us declare a general amnesty and unite again, going forward hand in hand, for, god or no god, I will help us find a better land, or die trying."
        [/message]

        # convert all rebel elves into loyal elves

        [message]
            side=3
            message= _ "I think I speak for all of us when I say that we accept your offer of amnesty and will follow you again. You have proved yourself capable as a leader and we too tire of this bloodshed. In hindsight perhaps we were wrong about Eloh and Tanstafaal; we shall have to think about this long and hard."
        [/message]

        [modify_unit]
            [filter]
                side=3
            [/filter]
            side=1
        [/modify_unit]
        [redraw]
            clear_shroud=yes
        [/redraw]

        [message]
            speaker=Kaleh
            message= _ "Thank you. And I have also not forgotten the pledge I made to our merfolk friends. If it is possible, I would like to meet with your master. Your conduct is a testament to your people, and I, at least, trust you."
        [/message]
        [message]
            race=merman
            message= _ "Thank you."
        [/message]

        [remove_shroud]
            x=8-10
            y=8-10
            side=1
        [/remove_shroud]

        # create iron council triad members

        [unit]
            side=4
            type=Necromancer
            id=Hekuba
            name= _ "Hekuba"
            canrecruit=yes
            x,y=9, 9
            [modifications]
                {TRAIT_INTELLIGENT}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
        [unit]
            side=4
            type=Necromancer
            id=Zilchis
            name= _ "Zilchis"
            x,y=10, 8
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]
        [unit]
            side=4
            type=Necromancer
            id=Sultaria
            name= _ "Sultaria"
            x,y=8, 8
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [message]
            speaker=Hekuba
            message= _ "And what about us, little elf, did you forget about us?"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "I could never forget what you did to those merfolk."
        [/message]
        [message]
            speaker=Hekuba
            message= _ "Good, for that is just a taste. You are fools to interfere with our affairs, and the Iron Council does not tolerate fools. The Dark Lady shall swallow your souls and you shall writhe in eternal torment. Arise my brethren, by her power those who have died shall rise up and join us! The very rocks too shall rise up out of the water to aid our crossing. Like a plague we shall pour forth and drive the non-believers before us!"
        [/message]

        # edit terrain to open entrance to NW island lagoon

        [terrain]
            terrain=Ww
            x=15
            y=17
        [/terrain]

        # edit terrain to add paths to NW island

        # NE path

        [terrain]
            terrain=Ww
            x=18, 20, 20, 20, 20, 21, 21, 21, 21
            y=17, 16, 17, 18, 20, 16, 18, 20, 21
        [/terrain]
        [terrain]
            terrain=Wwf # wmllint: ignore
            x=18, 19, 19, 20, 20, 21, 21, 22
            y=16, 16, 17, 19, 21, 17, 19, 20
        [/terrain]

        # SW path

        [terrain]
            terrain=Ww
            x=12, 14, 14, 15, 15, 16, 17, 18, 18, 18
            y=20, 20, 21, 20, 22, 22, 22, 22, 23, 24
        [/terrain]
        [terrain]
            terrain=Wwf # wmllint: ignore
            x=13, 14, 14, 15, 16, 17
            y=20, 18, 19, 21, 21, 23
        [/terrain]

        # create undead units on islands

        # NW base island

        {NAMED_UNIT 4 (Revenant) 17 14 () ( _ "Arisen Warrior") (upkeep=free)}
        {NAMED_UNIT 4 (Bone Shooter) 11 18 () ( _ "Arisen Warrior") (upkeep=free)}
        {NAMED_UNIT 4 (Skeleton) 8 12 () ( _ "Arisen Warrior") (upkeep=free)}
        {NAMED_UNIT 4 (Skeleton Archer) 14 10 () ( _ "Arisen Warrior") (upkeep=free)}

        [message]
            speaker=Nym
            message= _ "Gosh, just when things were starting to calm down."
        [/message]
        [message]
            speaker=Zhul
            message= _ "Our people are scattered and exhausted, where will we go now Kaleh? Shall we retreat into the dunes?"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Before I decide, I have just one question: How did you merfolk plan on bringing us to meet your master, if she dwells far beneath the sea?"
        [/message]
        [message]
            race=merman
            message= _ "Actually we prefer to dwell in the shallow waters, where we may frolic in the great coral reefs under the sun and moon. But I digress, we realize that you people cannot swim like us, and I believe I may have a solution."
        [/message]
        [message]
            race=merman
            message= _ "The humans of the Iron Council dwell in a large island to the northwest; I was taken there several times for interrogation. It is a fearsome place, full of black rock and tall peaks, but in the center is a lagoon. In the lagoon, I saw several ships anchored, which we might be able to use to transport your people across the waves."
        [/message]
        [message]
            speaker=Zhul
            message= _ "Across the waves?! We are a people of the desert, we know nothing of piloting such vessels! And I do not like the idea of putting my life at the mercy of some human-built ship."
        [/message]
        [message]
            race=merman
            message= _ "We have often spied on the humans and have picked up some knowledge of piloting. We also have some magical skills that allow us to control the winds and thus we can easily propel the ships in the right direction. Once out on the open sea we should be safe from danger. Besides, our master lives far out in the waters. Trying to find her and bearing her back here would take too long and there is no other way to get you to her."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "We have already gone to many strange places and survived. I trust the merfolk. If they believe that they can transport us safely across the waters, then I will put my life in their hands."
        [/message]
        [message]
            speaker=Nym
            message= _ "Wherever you go Kaleh, I will follow."
        [/message]
        [message]
            speaker=Zhul
            message= _ "Very well. You have not led us astray so far, I will not leave you now."
        [/message]

        {MESSAGE_DEPEND_ON_ALLY
        (
            [message]
                speaker=Grog
                message= _ "Grog scared of big water and bright sun, but Grog will not dishonor Great Leader. Great Leader say follow Kaleh, and Grog will do so."
            [/message]
        )
        (
            [message]
                speaker=Nog
                message= _ "Nog scared of big water and bright sun, but Nog will not dishonor Great Leader. Great Leader say follow Kaleh, and Nog will do so."
            [/message]
        )
        (
            [message]
                speaker=Rogrimir
                message= _ "Ouch, being stuck between the water and the sun is a terrible place to be, but where you go I will follow."
            [/message]
        )
        (
            [message]
                speaker=Jarl
                message= _ "Ouch, being stuck between the water and the sun is a terrible place to be, but where you go I will follow."
            [/message]
        )}

        [message]
            race=merman
            message= _ "We have attacked the humans in the past, when their boats trespass in our waters, and so they fear us greatly. Their dark mages have cast protective spells upon their boats, preventing any of our kind from boarding them. I am afraid that we cannot capture the boats for you. We will, of course, help you hold off the humans. Later, once we escape, with your help I think we can dispel the protections, but for now you must seize them yourselves."
        [/message]
        [message]
            race=merman
            message= _ "There are four boats in the lagoon. Once you have captured each of the four then we can help you steer them out into the open water and to freedom. Then we can pilot them to shore, safely away from the humans, and load the rest of your people on board. But we will need all four boats to fit all of your remaining people."
        [/message]
        [message]
            speaker=Nym
            message= _ "Truly, there are not as many of us as there once were."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Though the cost be high, we do what we must. Come let us go capture those boats."
        [/message]

        {VARIABLE capture_ships yes}

        [show_objectives]
        [/show_objectives]

        # allow player’s elves to recruit units again
        [set_recruit]
            side=1
            recruit=$stored_side_1.recruit
        [/set_recruit]
        {CLEAR_VARIABLE stored_side_1}

        # modify side 4 iron council to add income and gold

        [modify_side]
            side=4
            {INCOME 5 7 9}
            {GOLD 100 110 130}
        [/modify_side]

        # capture villages for Iron Council (side 4)

        [capture_village]
            x,y=7-18, 9-17
            side=4
        [/capture_village]

        # bring back Alastra, Darius and Zelgant if they haven't died
        # Get rid of events for approaching their old keeps
        [remove_event]
            id=approach_darius
        [/remove_event]
        [remove_event]
            id=approach_alastra
        [/remove_event]
        [remove_event]
            id=approach_zelgant
        [/remove_event]

        [if]
            [variable]
                name=stored_Alastra.length
                equals=1
            [/variable]
            [then]
                [unstore_unit]
                    variable=stored_Alastra
                    find_vacant=yes
                    x,y=9,14
                [/unstore_unit]
            [/then]
        [/if]
        [if]
            [variable]
                name=stored_Zelgant.length
                equals=1
            [/variable]
            [then]
                [unstore_unit]
                    variable=stored_Zelgant
                    find_vacant=yes
                    x,y=15,12
                [/unstore_unit]
            [/then]
        [/if]
        [if]
            [variable]
                name=stored_Darius.length
                equals=1
            [/variable]
            [then]
                [unstore_unit]
                    variable=stored_Darius
                    find_vacant=yes
                    x,y=11,10
                [/unstore_unit]
            [/then]
        [/if]

        {CLEAR_VARIABLE stored_Alastra,stored_Zelgant,stored_Darius}

        # the ship events have now been moved into the council
        # macro to prevent capricious players from capturing
        # the ships before the council appears

        # Capturing ships by elves
        # each ship is actually a village, when player captures a village
        # check for ownership of 4 of the special village type.

        #elf captures a ship

        [event]
            name=capture
            first_time_only=no

            [filter]
                side=1

                [filter_location]
                    terrain=*^Wyc
                [/filter_location]
            [/filter]

            [remove_item]
                x,y=$x1, $y1
            [/remove_item]

            {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>red)" $x1 $y1}

            [if]
                [have_location]
                    terrain=*^Wyc
                    owner_side=1
                    count=4
                [/have_location]

                [then]
                    [endlevel]
                        result=victory
                        bonus=yes
                        {NEW_GOLD_CARRYOVER 40}
                    [/endlevel]
                [/then]
            [/if]
        [/event]

        #enemy captures a ship

        [event]
            name=capture
            first_time_only=no

            [filter]
                [not]
                    side=1
                [/not]

                [filter_location]
                    terrain=*^Wyc
                [/filter_location]
            [/filter]

            [remove_item]
                x,y=$x1, $y1
            [/remove_item]

            {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>purple)" $x1 $y1}
        [/event]
    [/event]

    # Event 8: Meeting and Death of Eloh

    [event]
        name=moveto
        [filter]
            x=51-55
            y=14-18
            side=1
        [/filter]
        [filter_condition]
            [have_unit]
                id=Eloh
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Eloh
            message= _ "You think you can strike me down. This is just a small part of my true power."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Small part or no, if it is mortally possible to destroy you, I shall. Your hands are stained in our blood; you are not our god."
        [/message]
    [/event]

    # Eloh’s death frees Zhul from her stasis

    [event]
        name=last breath
        [filter]
            id=Eloh
        [/filter]

        [message]
            speaker=Eloh
            message= _ "Don’t worry Kaleh, we will see each other again... I promise."
        [/message]
        [kill]
            id=Eloh
            fire_event=yes  # Needed to off Kromph properly
        [/kill]
        [message]
            speaker=Nym
            message= _ "She freaks me out, but at least it seems that she can be destroyed."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "That was just an apparition, but if we meet again I will make her pay for all that she has done."
        [/message]

        [scroll_to_unit]
            id=Zhul
        [/scroll_to_unit]
        [unpetrify]
            id=Zhul
        [/unpetrify]

        [message]
            speaker=Zhul
            message= _ "I’m sorry, Kaleh. My faith clouded my reason. But I wanted so very much to believe."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "You do not need to apologize. What you did was very brave. I wish to... to whatever god still watches over us, that this bloodshed was not necessary. But I could not let half my people be co-opted by that thing. As horrible as it sounds, even death is a better fate."
        [/message]
        [message]
            speaker=Zhul
            message= _ "So when you had the strange encounter with that human Durstrag and his guards, just after we escaped the caves, you were talking to Eloh, or whatever she is?"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Yes, she appeared only to me and demanded that I surrender to the humans. When I refused she threatened me, saying she would kill me if I refused. That’s when I really started to get suspicious."
        [/message]
        [message]
            speaker=Zhul
            message= _ "It is clear that that thing was not our god. I do not know what it was, but I have to keep believing that Eloh is out there somewhere. Without our faith, what do we have left?"
        [/message]
        [message]
            speaker=Nym
            message= _ "We have each other."
        [/message]
        [message]
            speaker=Zhul
            message= _ "That’s not enough. Look, you’re a wonderful girl Nym, and Kaleh, you’ve shown yourself to be a great leader, but our actions have to mean something more than just our day-to-day survival. There has to be a higher purpose, Eloh must have some sort of plan for us. We have to keep believing."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Peace, Zhul, we can discuss theology later. We still have work to do."
        [/message]

        [fire_event]
            name=tanstafaal_and_eloh_gone
        [/fire_event]
    [/event]

    # Event 9: Meeting and Death of Tanstafaal

    [event]
        name=moveto

        [filter]
            side=1
            [filter_adjacent]
                id=Tanstafaal
            [/filter_adjacent]
        [/filter]

        [message]
            speaker=Tanstafaal
            message= _ "You cannot defeat me, I am protected by the goddess now. Finally, Kaleh, I will show everyone who is stronger!"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Oh Tanstafaal, I pity you. This battle was never about you."
        [/message]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Tanstafaal
        [/filter]

        [message]
            speaker=Kaleh
            message= _ "No, do not kill him. He may deserve it, but he will not die at my hands."
        [/message]
        [message]
            speaker=Tanstafaal
            message= _ "Never Kaleh. I will not be your lackey again!"
        [/message]
        [kill]
            id=Tanstafaal
            animate=yes
            fire_event=no
        [/kill]
        [message]
            speaker=Kaleh
            message= _ "Why did he have to kill himself? Oh, poor misguided Tanstafaal. We have lost too many elves today."
        [/message]
        [message]
            speaker=Nym
            message= _ "Do not blame yourself too much, it is Eloh who persuaded him to rebel."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Yes, she too will pay for her part in all of this."
        [/message]
        [fire_event]
            name=tanstafaal_and_eloh_gone
        [/fire_event]
    [/event]

    # Event 10: time over event

    [event]
        name=time over
        [message]
            speaker=Kaleh
            message= _ "We’ve run out of time. The humans are gaining strength and will surely overwhelm us now."
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    # Event 11: VICTORY!

    [event]
        name=victory
        [message]
            speaker=Nym
            message= _ "We’ve captured all four boats!"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Good, then let’s get out of here. The merfolk will help you guide the ships. I’ll muster the rest of our people and retreat from this bloody battlefield. We’ll meet you along the coastline west of here. Don’t worry about losing us, we’ll stick to the coast and the merfolk will help us keep in contact. Once we’ve escaped and are out of range of any counterattacks by the humans, we can load the rest of our people onto the ships."
        [/message]
        [message]
            race=merman
            message= _ "Then by the Sea God’s hand I call forth the winds. May they confound our enemies and blow these ships to safety!"
        [/message]

        # Elves and troll/dwarf get in the ships, enemies disappear (the enemy side won't persist to the next scenario)
        [put_to_recall_list]
            [not]
                race=merman
            [/not]
            heal=yes
        [/put_to_recall_list]

        # Removes the ^Wyc overlay from any location which has it
        [terrain]
            terrain=^
            layer=overlay
            [and]
                terrain=*^Wyc
            [/and]
        [/terrain]

        [remove_item]
            x,y=10, 15
        [/remove_item]
        [sound]
            name=ambient/ship.ogg
        [/sound]
        [move_unit_fake]
            type=Galleon
            side=1
            x=10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 14, 13, 13, 12, 11, 10, 9, 8, 7
            y=15, 15, 15, 16, 16, 17, 18, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25, 25
        [/move_unit_fake]
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>red)~FL()" 7 25}
        [remove_item]
            x,y=9, 12
        [/remove_item]
        [move_unit_fake]
            type=Galleon
            side=1
            x=9, 10, 11, 11, 11, 12, 13, 14, 15, 15, 15, 15, 15, 14, 13, 13, 12, 11, 10, 9, 8
            y=12, 12, 13, 14, 15, 15, 16, 16, 17, 18, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 24
        [/move_unit_fake]
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>red)~FL()" 8 24}
        [remove_item]
            x,y=12, 10
        [/remove_item]
        [sound]
            name=ambient/ship.ogg
        [/sound]
        [move_unit_fake]
            type=Galleon
            side=1
            x=12, 12, 12, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 14, 13, 13, 12, 11, 10, 9, 8
            y=10, 11, 12, 13, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25
        [/move_unit_fake]
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>red)~FL()" 8 25}
        [remove_item]
            x,y=15, 14
        [/remove_item]
        [move_unit_fake]
            type=Galleon
            side=1
            x=15, 14, 14, 15, 15, 15, 15, 15, 15, 14, 13, 13, 12, 11, 10, 9
            y=14, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25
        [/move_unit_fake]
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>red)~FL()" 9 25}
        {CLEAR_VARIABLE number_merfolk_caged}
        {CLEAR_VARIABLE number_merfolk_deaths}
        {CLEAR_VARIABLE capture_ships}
    [/event]

    {UTBS_INCLUDE utils/deaths.cfg}
[/scenario]
