#textdomain wesnoth-utbs
# Level 9: Blood is Thicker than Water...

[scenario]
    id="9_Blood_is_Thicker_Than_Water"
    name= _ "Blood is Thicker than Water"
    next_scenario=10_Speaking_with_the_Fishes
    map_data="{campaigns/Under_the_Burning_Suns/maps/09_Blood_is_Thicker_Than_Water.map}"
    victory_when_enemies_defeated=no
    snapshot=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=Desert Fighter
        canrecruit=yes
        gold=200
        {INCOME 2 0 0}
        controller=human
        shroud=yes
        fog=no
    [/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

            # AI will attack a weak unit with a max of 3, 4, 5 units
            # depending on the difficulty (default=5)
            {ATTACK_DEPTH 3 4 5}
            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=Desert Fighter, Desert Archer, Desert Hunter, Desert Ranger, Desert Marksman, Desert Hero, Desert Captain, Desert Sentinel, Desert Horseman
        [ai]
            # AI will attack a weak unit with a max of 3, 4, 5 units
            # depending on the difficulty (default=5)
            {ATTACK_DEPTH 3 4 5}
            recruitment_pattern=fighter, archer, fighter, mixed fighter, scout
            aggression=0.75
            caution=0.25
            passive_leader=yes
        [/ai]
    [/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
            # AI will attack a weak unit with a max of 3, 4, 5 units
            # depending on the difficulty (default=5)
            {ATTACK_DEPTH 2 3 4}
            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}
            {TRAIT_LOYAL}
        [/modifications]
        {IS_LOYAL}
        {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 will attack a weak unit with a max of 3, 4, 5 units
            # depending on the difficulty (default=5)
            {ATTACK_DEPTH 3 4 5}
        [/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 will attack a weak unit with a max of 3, 4, 5 units
            # depending on the difficulty (default=5)
            {ATTACK_DEPTH 3 4 5}
        [/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]

    # 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

        # scenario testing units

        #{NAMED_NOTRAIT_UNIT 1 (Desert Fighter) 16 13 (Test) ( _ "Test")}
        #{NAMED_NOTRAIT_UNIT 1 (Desert Fighter) 10 16 (Test) ( _ "Test")}

        # units to free merfolk instantly
        #{NAMED_NOTRAIT_UNIT 1 (Desert Marshal) 27 18 (Lycia) ( _ "Lycia")}
        #{NAMED_NOTRAIT_UNIT 1 (Desert Druid) 32 25 (Shea) ( _ "Shea")}
        #{NAMED_NOTRAIT_UNIT 1 (Desert Avenger) 18 31 (Pythos) ( _ "Pythos")}
        #{NAMED_NOTRAIT_UNIT 1 (Desert Marksman) 26 36 (Larea) ( _ "Larea")}
        #{NAMED_NOTRAIT_UNIT 1 (Desert Horseman) 33 32 (Nonthar) ( _ "Nonthar")}

        # increase cost of all units by 1

        [if]
            [variable]
                name=scen3
                numerical_equals=2
            [/variable]
            [then]
                #go from 7 to 8

                [disallow_recruit]
                    type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter6, Desert Archer6, Desert Hunter6, Desert Shaman6, Desert Scout6
                    side=1
                [/disallow_recruit]
                [allow_recruit]
                    type=Desert Fighter7, Desert Archer7, Desert Hunter7, Desert Shaman7, Desert Scout7
                    side=1
                [/allow_recruit]
            [/then]
            [else]
                [if]
                    [variable]
                        name=scen3
                        numerical_equals=1
                    [/variable]
                    [then]
                        #go from 6 to 7

                        [disallow_recruit]
                            type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter6, Desert Archer6, Desert Hunter6, Desert Shaman6, Desert Scout6
                            side=1
                        [/disallow_recruit]
                        [allow_recruit]
                            type=Desert Fighter7, Desert Archer7, Desert Hunter7, Desert Shaman7, Desert Scout7
                            side=1
                        [/allow_recruit]
                    [/then]
                [/if]
                [if]
                    [variable]
                        name=scen3
                        numerical_equals=3
                    [/variable]
                    [then]
                        #go from 8 to 9

                        [disallow_recruit]
                            type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter6, Desert Archer6, Desert Hunter6, Desert Shaman6, Desert Scout6
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter7, Desert Archer7, Desert Hunter7, Desert Shaman7, Desert Scout7
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter8, Desert Archer8, Desert Hunter8, Desert Shaman8, Desert Scout8
                            side=1
                        [/disallow_recruit]
                        [allow_recruit]
                            type=Desert Fighter9, Desert Archer9, Desert Hunter9, Desert Shaman9, Desert Scout9
                            side=1
                        [/allow_recruit]
                    [/then]
                [/if]
            [/else]
        [/if]

        # 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=Zhul
        [/recall]
        [recall]
            id=Nym
        [/recall]
        # recall dwarf/troll
        [recall]
            id=$ally_name
        [/recall]
        [recall]
            id=Esanoo
        [/recall]
        [recall]
            id=Kromph
        [/recall]

        #initialize starting variables

        [set_variable]
            name=ally_must_live
            value=0
        [/set_variable]
        [set_variable]
            name=number_merfolk_freed
            value=0
        [/set_variable]
        [set_variable]
            name=saw_mermaid_enchantress
            value=0
        [/set_variable]
        [set_variable]
            name=number_merfolk_alive
            value=1
        [/set_variable]
        [set_variable]
            name=merfolk_dead
            value=0
        [/set_variable]
        [set_variable]
            name=eloh_dead
            value=0
        [/set_variable]
        [set_variable]
            name=tanstafaal_dead
            value=0
        [/set_variable]
        [set_variable]
            name=ships_captured
            value=0
        [/set_variable]
        [set_variable]
            name=elf_entered_water
            value=0
        [/set_variable]
        [set_variable]
            name=test_counter
            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]
            summary= _ "Starting Objectives:"
            [objective]
                description= _ "Rescue at least two merfolk by turn 16"
                condition=win
            [/objective]
            [objective]
                description= _ "Three merfolk must survive"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kaleh, Nym, Zhul"
                condition=lose
            [/objective]

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

        [teleport]
            [filter]
                id=Esanoo
            [/filter]
            x,y=46, 42
        [/teleport]

        [terrain]
            x,y=45, 46
            terrain=Hd
        [/terrain]

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

        [unit]
            type=Desert Archer
            id=Elonea
            name= _ "Elonea"
            upkeep=full
            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]
        [if]
            [variable]
                name=ally_race
                equals=Dwarf
            [/variable]
            [then]
                [message]
                    speaker=$ally_name
                    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]
            [/then]
            [else]
                [message]
                    speaker=$ally_name
                    message= _ "Trees look big and strong, like trolls. Dark, too. $intl_ally_name tired of walking under hot sun."
                [/message]
            [/else]
        [/if]
        [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 his 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?"
        [/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]

        {RANDOM_TRAIT_UNIT 2 "Spearman"   45 42   () ( _ "Human Scout") ()}
        {RANDOM_TRAIT_UNIT 2 "Javelineer" 47 42   () ( _ "Human Scout") ()}

        [redraw]
        [/redraw]

        [message]
            x,y=45, 42
            message= _ "Hey, what do we have here?"
        [/message]
        [message]
            speaker=Esanoo
            message= _ "Uh...Uh..."
        [/message]
        [message]
            x,y=47, 42
            message= _ "It's another one of those fish creatures. It must have come back to try to rescue its friends. "
        [/message]
        [message]
            x,y=45, 42
            message= _ "Ha, stupid creature. But we're in luck, the council was looking for the last of these spies."
        [/message]
        [message]
            x,y=47, 42
            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]
            x,y=45, 42
            message= _ "Yeah, we'll be heroes!"
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Not if we gut you first. Attack!"
        [/message]
        [message]
            x,y=45, 42
            message= _ "The Dark Lady protect us, they're elves!"
        [/message]
        [message]
            x,y=47, 42
            message= _ "There's tons of them! Flee, we must warn the others!"
        [/message]
        [kill]
            x,y=45, 42
            animate=no
        [/kill]
        [kill]
            x,y=47, 42
            animate=no
        [/kill]
        [move_unit_fake]
            type=Spearman
            side=2
            x=45, 45, 45, 44
            y=42, 41, 40, 39
        [/move_unit_fake]
        [move_unit_fake]
            type=Javelineer
            side=2
            x=47, 47, 46, 46, 46
            y=42, 41, 40, 39, 38
        [/move_unit_fake]
        [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 okay, 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")}

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

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

        # changed from Pikeman to Spearman
        {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]

    # Macro: Appearance of Eloh and Tanstafaal

    # eloh and tanstafaal appear
    # kaleh's can no longer recruit elves
    # merfolk offer to help kaleh cross the water

    # I need to define this before macro 3 and event 4, because they call
    # this macro

#define ELOH_APPEARS
    [remove_shroud]
        x=51-55
        y=14-17
        side=1
    [/remove_shroud]
    [unit]
        type=Desert Captain
        id=Tanstafaal
        name= _ "Tanstafaal"
        side=3
        x=52
        y=15
        canrecruit=yes
        facing=sw
        [modifications]
            {TRAIT_LOYAL}
            {TRAIT_RESILIENT}
        [/modifications]
        {IS_LOYAL}
    [/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]
    [message]
        type=Desert Fighter3, Desert Fighter4, Desert Fighter5, Desert Fighter6, Desert Fighter7, Desert Fighter8, Desert Hunter3, Desert Hunter4, Desert Hunter5, Desert Hunter6, Desert Hunter7, Desert Hunter8
        side=1
        message= _ "The Goddess!"
    [/message]
    [message]
        type=Desert Archer3, Desert Archer4, Desert Archer5, Desert Archer6, Desert Archer7, Desert Archer8
        side=1
        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]
        type=Desert Fighter3, Desert Fighter4, Desert Fighter5, Desert Fighter6, Desert Fighter7, Desert Fighter8
        side=1
        message= _ "What?"
    [/message]
    [message]
        type=Desert Hunter3, Desert Hunter4, Desert Hunter5, Desert Hunter6, Desert Hunter7, Desert Hunter8
        side=1
        message= _ "No!"
    [/message]
    [message]
        type=Desert Archer3, Desert Archer4, Desert Archer5, Desert Archer6, Desert Archer7, Desert Archer8
        side=1
        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]
                type=Desert Fighter3, Desert Fighter4, Desert Fighter5, Desert Fighter6, Desert Fighter7, Desert Fighter8, Desert Hunter3, Desert Hunter4, Desert Hunter5, Desert Hunter6, Desert Hunter7, Desert Hunter8, Desert Archer3, Desert Archer4, Desert Archer5, Desert Archer6, Desert Archer7, Desert Archer8
                side=1
                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 his 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]
                type=Desert Fighter3, Desert Fighter4, Desert Fighter5, Desert Fighter6, Desert Fighter7, Desert Fighter8, Desert Hunter3, Desert Hunter4, Desert Hunter5, Desert Hunter6, Desert Hunter7, Desert Hunter8, Desert Archer3, Desert Archer4, Desert Archer5, Desert Archer6, Desert Archer7, Desert Archer8
                side=1
                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 his 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, than 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]
    [if]
        [variable]
            name=ally_race
            equals=Dwarf
        [/variable]
        [then]
            [message]
                speaker=$ally_name
                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]
        [/then]
        [else]
            [message]
                speaker=$ally_name
                message= _ "Great Leader told $intl_ally_name to serve you, and so $intl_ally_name will still follow your command. But other elves must be out on a separate island. How will we cross deep water?"
            [/message]
        [/else]
    [/if]

    # merfolk offer to help

    [message]
        role=merfolk
        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

    # Note: to fit the map and storyline, it's tempting to replace these
    # river-ford (Wwf) tiles with coastal-reef (WWr) tiles. But there's a
    # problem; these terrains have different movement costs and the change
    # would slow the elves down not a good thing in thiss context.  This
    # might be a job for a customized terrain type.

    #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]

    # change scenario objectives

    [objectives]
        summary= _ "New Objectives:"
        [objective]
            description= _ "Defeat Tanstafaal and Eloh"
            condition=win
        [/objective]
        [objective]
            description= _ "Three merfolk must survive"
            condition=win
        [/objective]
        [objective]
            description= _ "Death of Kaleh, Nym, Zhul"
            condition=lose
        [/objective]

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

    # move tanstafaal to keep

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

    # give tanstafaal some recruits

    {NAMED_GENERIC_UNIT 3 (Desert Fighter) 48 16 () ( _ "Elvish Rebel")}
    {NAMED_GENERIC_UNIT 3 (Desert Archer) 48 18 () ( _ "Elvish Rebel")}
    {NAMED_GENERIC_UNIT 3 (Desert Hunter) 51 19 () ( _ "Elvish Rebel")}
    {NAMED_GENERIC_UNIT 3 (Desert Hero) 47 18 () ( _ "Elvish Rebel")}
    {NAMED_GENERIC_UNIT 3 (Desert Ranger) 50 20 () ( _ "Elvish Rebel")}

    # modify income and gold for rebels

    [modify_side]
        side=3
#ifdef EASY
        income=9
        gold=100
#endif
#ifdef NORMAL
        income=11
        gold=125
#endif
#ifdef HARD
        income=13
        gold=150
#endif
    [/modify_side]

    # cut off all recruiting for side 1 elves

    [disallow_recruit]
        type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
        side=1
    [/disallow_recruit]
    [disallow_recruit]
        type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
        side=1
    [/disallow_recruit]
    [disallow_recruit]
        type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
        side=1
    [/disallow_recruit]
    [disallow_recruit]
        type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
        side=1
    [/disallow_recruit]
    [disallow_recruit]
        type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
        side=1
    [/disallow_recruit]
    [disallow_recruit]
        type=Desert Fighter6, Desert Archer6, Desert Hunter6, Desert Shaman6, Desert Scout6
        side=1
    [/disallow_recruit]
    [disallow_recruit]
        type=Desert Fighter7, Desert Archer7, Desert Hunter7, Desert Shaman7, Desert Scout7
        side=1
    [/disallow_recruit]
    [disallow_recruit]
        type=Desert Fighter8, Desert Archer8, Desert Hunter8, Desert Shaman8, Desert Scout8
        side=1
    [/disallow_recruit]
#enddef

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

    # if number_merfolk_freed = 5
    # then set merfolk_dead to 1
    # 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
    [if]
        [variable]
            name=number_merfolk_freed
            numerical_equals=5
        [/variable]
        [then]
            [set_variable]
                name=merfolk_dead
                value=1
            [/set_variable]
            [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]
                        role=merfolk
                        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]
                        role=merfolk
                        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]
                    [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]
                [/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")}
                    [message]
                        side=4
                        type=Necromancer
                        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]
                        role=merfolk
                        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]

                    # Darius is dead

                    [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]
                [/else]
            [/if]

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

            # activate eloh event

            {ELOH_APPEARS}
        [/then]
    [/if]
#enddef

    # 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

    # Merman Warrior Urruga (1st NW island)

    [event]
        name=moveto

        [filter]
            x,y=25, 36
            side=1
        [/filter]
        [if]
            [variable]
                name=merfolk_dead
                numerical_equals=0
            [/variable]
            [then]
                [removeitem]
                    x,y=25, 36
                [/removeitem]
                [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_freed
                        numerical_equals=0
                    [/variable]
                    [then]
                        [if]
                            [have_unit]
                                id=Esanoo
                            [/have_unit]
                            [then]
                                [message]
                                    speaker=Urruga
                                    message= _ "Free at last. Thanks be to the Sea God. But wait a minute, you're elves!?! "
                                [/message]
                                [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=Urruga
                                    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=Urruga
                                    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]
                    [/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]
                [set_variable]
                    name=number_merfolk_freed
                    add=1
                [/set_variable]
                [set_variable]
                    name=number_merfolk_alive
                    add=1
                [/set_variable]
                [role]
                    role=merfolk
                    type=Merman Warrior
                [/role]
                {CHECK_IF_FREED_ALL_MERFOLK}
            [/then]
        [/if]
    [/event]

    # Merman Warrior Nuvassa (1st NE island)

    [event]
        name=moveto
        [filter]
            x,y=34, 31
            side=1
        [/filter]
        [if]
            [variable]
                name=merfolk_dead
                numerical_equals=0
            [/variable]
            [then]
                [removeitem]
                    x,y=34, 31
                [/removeitem]
                [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_freed
                        numerical_equals=0
                    [/variable]
                    [then]
                        [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=Nuvassa
                                    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=Nuvassa
                                    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]
                    [/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]
                [set_variable]
                    name=number_merfolk_freed
                    add=1
                [/set_variable]
                [set_variable]
                    name=number_merfolk_alive
                    add=1
                [/set_variable]
                [role]
                    role=merfolk
                    type=Merman Warrior
                [/role]
                {CHECK_IF_FREED_ALL_MERFOLK}
            [/then]
        [/if]
    [/event]

    # Merman Spearman Yantili (2nd NW sandy island)

    [event]
        name=moveto
        [filter]
            x,y=18, 32
            side=1
        [/filter]
        [if]
            [variable]
                name=merfolk_dead
                numerical_equals=0
            [/variable]
            [then]
                [removeitem]
                    x,y=18, 32
                [/removeitem]
                [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_freed
                        numerical_equals=0
                    [/variable]
                    [then]
                        [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=Yantili
                                    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=Yantili
                                    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]
                    [/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]
                [set_variable]
                    name=number_merfolk_freed
                    add=1
                [/set_variable]
                [set_variable]
                    name=number_merfolk_alive
                    add=1
                [/set_variable]
                [role]
                    role=merfolk
                    type=Merman Spearman
                [/role]
                {CHECK_IF_FREED_ALL_MERFOLK}
            [/then]
        [/if]
    [/event]

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

    [event]
        name=moveto
        [filter]
            x,y=31, 25
            side=1
        [/filter]
        [if]
            [variable]
                name=merfolk_dead
                numerical_equals=0
            [/variable]
            [then]
                [removeitem]
                    x,y=31, 25
                [/removeitem]
                [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_freed
                        numerical_equals=0
                    [/variable]
                    [then]
                        [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=Il-tian
                                    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=Il-tian
                                    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]
                    [/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]
                [set_variable]
                    name=number_merfolk_freed
                    add=1
                [/set_variable]
                [set_variable]
                    name=number_merfolk_alive
                    add=1
                [/set_variable]
                [role]
                    role=merfolk
                    type=Mermaid Priestess
                [/role]
                {CHECK_IF_FREED_ALL_MERFOLK}
            [/then]
        [/if]
    [/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]
        [set_variable]
            name=saw_mermaid_enchantress
            value=1
        [/set_variable]
        [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
        [filter]
            x,y=27, 19
            side=1
        [/filter]
        [if]
            [variable]
                name=merfolk_dead
                numerical_equals=0
            [/variable]
            [then]
                [removeitem]
                    x,y=27, 19
                [/removeitem]
                [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}
                [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]
                [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}
                [set_variable]
                    name=number_merfolk_freed
                    add=1
                [/set_variable]
                [set_variable]
                    name=number_merfolk_alive
                    add=1
                [/set_variable]
                [role]
                    role=merfolk
                    type=Mermaid Enchantress
                [/role]
                {CHECK_IF_FREED_ALL_MERFOLK}
            [/then]
        [/if]
    [/event]

    # Event 2.1: Merfolk death counter

    # Each time a merfolk dies, decrement number_merfolk_alive counter
    # after caged merfolk have been killed, if number_merfolk_alive < 3
    # then defeat

    # But before caged merfolk have been killed
    # if number_merfolk_alive + (5 - number_merfolk_freed)
    # drops below 3, then it is impossible to have 3 live merfolk, so defeat

    [event]
        name=die
        first_time_only=no

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

        [set_variable]
            name=number_merfolk_alive
            add=-1
        [/set_variable]

        # if all merfolk in cages have been sacrificed, then if the number of
        # merfolk alive drops below 3, then player has lost.

        [if]
            [variable]
                name=merfolk_dead
                numerical_equals=1
            [/variable]
            [then]
                [if]
                    [variable]
                        name=number_merfolk_alive
                        less_than=3
                    [/variable]
                    [then]
                        [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]
                        [endlevel]
                            result=defeat
                        [/endlevel]
                    [/then]
                [/if]
            [/then]

            # else if merfolk in cages haven't been killed. Then add number of
            # merfolk alive to number still in cages. If total is less than 3
            # then player has lost.

            [else]
                # total = number player has alive + number in cages
                [set_variable]
                    name=total_merfolk_alive
                    value=$number_merfolk_alive
                [/set_variable]

                # take number of merfolk freed, multiply by -1, add to 5, and this
                # gives you the number still left in cages

                [set_variable]
                    name=merfolk_in_cages
                    value=5
                [/set_variable]
                [set_variable]
                    name=temp
                    value=$number_merfolk_freed
                [/set_variable]
                [set_variable]
                    name=temp
                    multiply=-1
                [/set_variable]
                [set_variable]
                    name=merfolk_in_cages
                    add=$temp
                [/set_variable]
                # add number in cages to number player has to get total
                [set_variable]
                    name=total_merfolk_alive
                    add=$merfolk_in_cages
                [/set_variable]
                {CLEAR_VARIABLE merfolk_in_cages}
                {CLEAR_VARIABLE temp}
                [if]
                    [variable]
                        name=total_merfolk_alive
                        less_than=3
                    [/variable]
                    [then]
                        [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]
                        [endlevel]
                            result=defeat
                        [/endlevel]
                    [/then]
                [/if]
            [/else]
        [/if]
    [/event]

    # Event 2.2 Elves discover salt water

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            race=elf
        [/filter]
        [allow_undo]
        [/allow_undo]
        [if]
            [variable]
                name=elf_entered_water
                numerical_equals=0
            [/variable]
            [then]
                [store_locations]
                    x=$x1
                    y=$y1
                    terrain=Ww
                    variable=locs
                [/store_locations]
                [set_variable]
                    name=temp
                    value=$locs.length
                [/set_variable]
                [if]
                    [variable]
                        name=temp
                        numerical_equals=1
                    [/variable]
                    [then]
                        [set_variable]
                            name=elf_entered_water
                            value=1
                        [/set_variable]
                        [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]
                    [/then]
                [/if]
                {CLEAR_VARIABLE locs}
                {CLEAR_VARIABLE temp}
            [/then]
        [/if]
    [/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]
                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 was 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
        [filter]
            x=27-35
            y=23-28
            side=1
        [/filter]
        [if]
            [have_unit]
                id=Zelgant
            [/have_unit]
            [then]
                [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]
            [/then]
        [/if]
    [/event]
    [event]
        name=moveto
        [filter]
            x=15-21
            y=31-36
            side=1
        [/filter]
        [if]
            [have_unit]
                id=Alastra
            [/have_unit]
            [then]
                [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]
            [/then]
        [/if]
    [/event]
    [event]
        name=moveto
        [filter]
            x=19-26
            y=22-26
            side=1
        [/filter]
        [if]
            [have_unit]
                id=Darius
            [/have_unit]
            [then]
                [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]
            [/then]
        [/if]
    [/event]

    # Event 4: Time runs out

    # turn = 16 and merfolk_dead = 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_dead to 1
    # if number_merfolk_freed is less than 2, defeat
    # else, have humans retreat, go to eloh event

    [event]
        name=turn 16
        [if]
            [variable]
                name=merfolk_dead
                numerical_equals=0
            [/variable]
            [then]
                [set_variable]
                    name=merfolk_dead
                    value=1
                [/set_variable]

                # 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_GENERIC_UNIT 4 (Necromancer) 15 28 (Hekuba) ( _ "Hekuba")}
                        # wmllint: recognize Hekuba
                        [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

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

                [if]
                    [variable]
                        name=saw_mermaid_enchantress
                        numerical_equals=0
                    [/variable]

                    [variable]
                        name=number_merfolk_freed
                        numerical_equals=4
                    [/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]
                                    role=merfolk
                                    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 fate has befallen her?"
                                [/message]

                                [message]
                                    role=merfolk
                                    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]
                                    role=merfolk
                                    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]
                                    role=merfolk
                                    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
                [removeitem]
                    x=25
                    y=36
                [/removeitem]
                [removeitem]
                    x=34
                    y=31
                [/removeitem]
                [removeitem]
                    x=18
                    y=32
                [/removeitem]
                [removeitem]
                    x=31
                    y=25
                [/removeitem]
                [removeitem]
                    x=27
                    y=19
                [/removeitem]

                # if player hasn't saved 2 merfolk then defeat
                [if]
                    [variable]
                        name=number_merfolk_freed
                        less_than=2
                    [/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
                    # becuase if all 5 merfolk were saved then 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]
                    [/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
                            # 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]
                        [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]
                    [/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")}
                        # wmllint: recognize Hekuba

                        [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]
                            role=merfolk
                            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]

                        # Darius is dead

                        [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]
                    [/else]
                [/if]

                #cut income for side 2, 5, 6

                [modify_side]
                    side=2
                    income=0
                    gold=0
                [/modify_side]
                [modify_side]
                    side=5
                    income=0
                    gold=0
                [/modify_side]
                [modify_side]
                    side=6
                    income=0
                    gold=0
                [/modify_side]

                # activate eloh event

                {ELOH_APPEARS}
            [/then]
        [/if]
    [/event]

    # Event 4.5 Eloh turn counter: count each turn since Eloh arrived

    # For some reason this event fires but the variable does get incremented
    # if I put this event later down in the file. So that's why I put it
    # first

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

    # Event 6: If Flesh Golem is alive, 4-6 turns after eloh appears
    # he turns against the elves

    # Event 4.5:
    [event]
        name=new turn
        first_time_only=no

        [if]
            [have_unit]
                id=Eloh
            [/have_unit]
            [then]
                [set_variable]
                    name=test_counter
                    add=1
                [/set_variable]

                # Event 5: Zhul & Eloh conversation
                [if]
                    [variable]
                        name=test_counter
                        numerical_equals=2
                    [/variable]
                    [then]
                        [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: 'to err is elven, but to forgive divine'? "
                        [/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]

                        {MODIFY_UNIT id=Zhul status.petrified yes}
                    [/then]
                [/if]

                # Event 6: Kromph gets controlled by Eloh

                [if]
                    [variable]
                        name=test_counter
                        numerical_equals=5
                    [/variable]
                    [have_unit]
                        id=Kromph
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Kromph
                            message= _ "Aaarrrgggh! 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]
                    [/then]
                [/if]
                [if]
                    [variable]
                        name=test_counter
                        numerical_equals=6
                    [/variable]
                    [have_unit]
                        id=Kromph
                    [/have_unit]
                    [then]
                        [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 id=Kromph side 3}

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

                            # If Kromph is under Eloh's control, Eloh's
                            # death causes Kromph's as well.x
                            [if]
                                [have_unit]
                                    id=Kromph
                                    side=3
                                [/have_unit]
                                [then]
                                    [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, aauuggghhhhh!!!"
                                    [/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]
                                [/then]
                            [/if]
                        [/event]
                    [/then]
                [/if]
            [/then]
        [/if]
    [/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
            upkeep=full
            animate=yes
        )}

        [message]
            role=Angry Crab
            message= _ "Aaaargh! Fresh meat!"
        [/message]
        [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
            upkeep=full
            animate=yes
        )}

        [message]
            role=Angry Crab
            message= _ "Gaaaggghhh! Kill!"  # wmllint: no spellcheck
        [/message]
        [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

        [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 side=3 side 1}
        [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]
            role=merfolk
            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 back 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]
            role=merfolk
            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]
            role=merfolk
            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]
            role=merfolk
            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]
        [if]
            [variable]
                name=ally_race
                equals=Dwarf
            [/variable]
            [then]
                [message]
                    speaker=$ally_name
                    message= _ "Ouch, being stuck between the water and the sun is a terrible place to be, but where you go I will follow."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=$ally_name
                    message= _ "$intl_ally_name scared of big water and bright sun, but $intl_ally_name will not dishonor Great Leader. Great Leader say follow Kaleh, and $intl_ally_name will do so."
                [/message]
            [/else]
        [/if]
        [message]
            role=merfolk
            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]
            role=merfolk
            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]

        # change scenario objectives

        [objectives]
            summary= _ "New Objectives:"
            [objective]
                description= _ "Capture all 4 human ships"
                condition=win
            [/objective]
            [objective]
                description= _ "Three merfolk must survive"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kaleh, Nym, Zhul"
                condition=lose
            [/objective]

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

        # allow player's elves to recruit units again
        # same code as start of scenario

        [if]
            [variable]
                name=scen3
                numerical_equals=2
            [/variable]
            [then]
                #go from 6 to 7

                [disallow_recruit]
                    type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
                    side=1
                [/disallow_recruit]
                [disallow_recruit]
                    type=Desert Fighter6, Desert Archer6, Desert Hunter6, Desert Shaman6, Desert Scout6
                    side=1
                [/disallow_recruit]
                [allow_recruit]
                    type=Desert Fighter7, Desert Archer7, Desert Hunter7, Desert Shaman7, Desert Scout7
                    side=1
                [/allow_recruit]
            [/then]
            [else]
                [if]
                    [variable]
                        name=scen3
                        numerical_equals=1
                    [/variable]
                    [then]
                        #go from 5 to 6

                        [disallow_recruit]
                            type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
                            side=1
                        [/disallow_recruit]
                        [allow_recruit]
                            type=Desert Fighter6, Desert Archer6, Desert Hunter6, Desert Shaman6, Desert Scout6
                            side=1
                        [/allow_recruit]
                    [/then]
                [/if]

                [if]
                    [variable]
                        name=scen3
                        numerical_equals=3
                    [/variable]
                    [then]
                        #go from 7 to 8

                        [disallow_recruit]
                            type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter6, Desert Archer6, Desert Hunter6, Desert Shaman6, Desert Scout6
                            side=1
                        [/disallow_recruit]
                        [disallow_recruit]
                            type=Desert Fighter7, Desert Archer7, Desert Hunter7, Desert Shaman7, Desert Scout7
                            side=1
                        [/disallow_recruit]
                        [allow_recruit]
                            type=Desert Fighter8, Desert Archer8, Desert Hunter8, Desert Shaman8, Desert Scout8
                            side=1
                        [/allow_recruit]
                    [/then]
                [/if]
            [/else]
        [/if]

        # modify side 4 iron council to add income and gold

        [modify_side]
            side=4
#ifdef EASY
            income=5
            gold=100
#endif
#ifdef NORMAL
            income=7
            gold=110
#endif
#ifdef HARD
            income=9
            gold=130
#endif
        [/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

        [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
        # increment counter, when enemy captures a village, decrement it.

        #elf captures a ship

        [event]
            name=capture
            first_time_only=no
            delayed_variable_substitution=yes

            [filter]
                x=9, 10, 12, 15
                y=12, 15, 10, 14
                side=1
            [/filter]
            [set_variable]
                name=ships_captured
                add=1
            [/set_variable]
            [removeitem]
                x,y=$x1, $y1
            [/removeitem]
            {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>red)" $x1 $y1}
            [if]
                [variable]
                    name=ships_captured
                    numerical_equals=4
                [/variable]
                [then]
                    [endlevel]
                        name=victory
                        bonus=yes
                        {NEW_GOLD_CARRYOVER 40}
                    [/endlevel]
                [/then]
            [/if]
        [/event]

        #enemy captures a ship

        [event]
            name=capture
            first_time_only=no
            delayed_variable_substitution=yes

            [filter]
                x=9, 10, 12, 15
                y=12, 15, 10, 14
                [not]
                    side=1
                [/not]
            [/filter]
            [set_variable]
                name=ships_captured
                add=-1
            [/set_variable]
            [removeitem]
                x,y=$x1, $y1
            [/removeitem]
            {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]
        [if]
            [have_unit]
                id=Eloh
            [/have_unit]
            [then]
                [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]
            [/then]
        [/if]
    [/event]

    # Eloh's death frees Zhul from her stasis

    [event]
        name=last breath
        [filter]
            id=Eloh
        [/filter]
        [set_variable]
            name=eloh_dead
            value=1
        [/set_variable]
        [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]
        [if]
            [variable]
                name=tanstafaal_dead
                numerical_equals=1
            [/variable]
            [then]
                [fire_event]
                    name=tanstafaal_and_eloh_gone
                [/fire_event]
            [/then]
        [/if]
    [/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]
        [set_variable]
            name=tanstafaal_dead
            value=1
        [/set_variable]
        [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]
        [if]
            [variable]
                name=eloh_dead
                numerical_equals=1
            [/variable]
            [then]
                [fire_event]
                    name=tanstafaal_and_eloh_gone
                [/fire_event]
            [/then]
        [/if]
    [/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]
            role=merfolk
            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]
        [terrain]
            terrain=Ww
            x=9, 10, 12, 15
            y=12, 15, 10, 14
        [/terrain]
        [removeitem]
            x,y=10, 15
        [/removeitem]
        [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)" 7 25}
        [removeitem]
            x,y=9, 12
        [/removeitem]
        [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)" 8 24}
        [removeitem]
            x,y=12, 10
        [/removeitem]
        [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)" 8 25}
        [removeitem]
            x,y=15, 14
        [/removeitem]
        [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)" 9 25}
        {CLEAR_VARIABLE number_merfolk_freed}
        {CLEAR_VARIABLE number_merfolk_alive}
        {CLEAR_VARIABLE saw_mermaid_enchantress}
        {CLEAR_VARIABLE merfolk_dead}
        {CLEAR_VARIABLE elf_entered_water}
        {CLEAR_VARIABLE test_counter}
        {CLEAR_VARIABLE eloh_dead}
        {CLEAR_VARIABLE tanstafaal_dead}
        {CLEAR_VARIABLE Zhul_var}
        {CLEAR_VARIABLE ships_captured}
        {CLEAR_VARIABLE unitstats}
    [/event]

    {campaigns/Under_the_Burning_Suns/utils/kaleh-abilities.cfg}
    {campaigns/Under_the_Burning_Suns/utils/deaths.cfg}
[/scenario]
