#textdomain wesnoth-utbs

[scenario]
    id=12_The_Final_Confrontation
    name= _ "The Final Confrontation"
    next_scenario=13_Epilogue

    {UTBS_MAP 12_The_Final_Confrontation.map}

    {STORY_THE_FINAL_CONFRONTATION}

    {SCENARIO_MUSIC "the_deep_path.ogg"}
    {EXTRA_SCENARIO_MUSIC "revelation.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_city_falls.ogg"}

    victory_when_enemies_defeated=no
    turns="-1"

    {UNDERGROUND}

    #########################################################################################################
    #                   Events table (stuff that can be triggered with 'fire')                              #
    #########################################################################################################
    # eloh_death : causes the post-Eloh events to occur                                                     #
    # create_minion : spawns one of Yechnagoth's minions                                                   #
    # yechnagoth_regenerate : causes Yechnagoth to fully heal                                               #
    # yechnagoth_special_attack : trigger Yechnagoth's special slowing attack                               #
    # yechnagoth_vulnerate : vulnerates Yechnagoth                                                          #
    # yechnagoth_death : triggers Yechnagoth's death event                                                  #
    #########################################################################################################

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

    # Side 2: Eloh
    [side]
        side=2
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=eloh
        user_team_name=_"Eloh"
        {FLAG_VARIANT undead}
        [ai]
            aggression=0.95
            caution=0.1

            # change AI so that enemies target Kaleh's friends
            # more than Kaleh himself. I want to threaten
            # other units more, since Kaleh's death leads to
            # immediate defeat

            [goal]
                name=target
                [criteria]
                    id=Kaleh
                [/criteria]
                value=1
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Nym
                [/criteria]
                value=3
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Zhul
                [/criteria]
                value=3
            [/goal]

            [goal]
                name=target
                [criteria]
                    id=$ally_name
                [/criteria]
                value=3
            [/goal]
        [/ai]
    [/side]

    # Side 3: Brainwashed Elves
    [side]
        side=3
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=eloh
        user_team_name=_"Eloh"

        [ai]
            aggression=0.95
            caution=0.1

            [goal]
                name=target
                [criteria]
                    id=Kaleh
                [/criteria]
                value=1
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Nym
                [/criteria]
                value=3
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Zhul
                [/criteria]
                value=3
            [/goal]

            [goal]
                name=target
                [criteria]
                    id=$ally_name
                [/criteria]
                value=3
            [/goal]
        [/ai]
        {FLAG_VARIANT long}
    [/side]

    # Side 4: Pulsing Spires
    [side]
        side=4
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=eloh
        user_team_name=_"Eloh"
        {FLAG_VARIANT undead}

        [ai]
            aggression=-1.0
            caution=1.0

            [goal]
                name=target
                [criteria]
                    id=Kaleh
                [/criteria]
                value=1
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Nym
                [/criteria]
                value=3
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Zhul
                [/criteria]
                value=3
            [/goal]

            [goal]
                name=target
                [criteria]
                    id=$ally_name
                [/criteria]
                value=3
            [/goal]
        [/ai]
    [/side]

    # Prestart functions:
    # insert items onto map
    # place item images on map
    # recall main heroes
    # store/remove kaleh
    # initialize starting variables
    # set starting scenario objectives

    [event]
        name=prestart

        # add items to map

        {PLACE_IMAGE "items/kaleh-dead.png~NO_TOD_SHIFT()" 10 13}

        # recall heroes
        [recall]
            id=Nym
            x,y=10,16
        [/recall]

        [recall]
            id=Zhul
            x,y=11,17
        [/recall]

        # wmllint: unwho ALL

        # recall dwarf/troll
        [recall]
            id=$ally_name
            x,y=9,17
        [/recall]

        # wmllint: recognize Grog
        # wmllint: recognize Nog
        # wmllint: recognize Rogrimir
        # wmllint: recognize Jarl

        # store/remove kaleh

        [store_unit]
            [filter]
                id=Kaleh
            [/filter]
            kill=yes
            variable=stored_kaleh
        [/store_unit]

        #initialize starting variables

        {VARIABLE allies_killed 0}
        {VARIABLE ally_died_in_final_fight no}
        {VARIABLE number_minions_to_spawn 0}

        # set starting scenario objectives

        [objectives]
            [objective]
                description= _ "Defeat the false Eloh"
                condition=win
                [show_if]
                    [have_unit]
                        # wmllint: recognize Eloh
                        id=Eloh
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Defeat Yechnagoth"
                condition=win
                [show_if]
                    [have_unit]
                        # wmllint: recognize Yechnagoth
                        id=Yechnagoth
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Kaleh"
                condition=lose
            [/objective]

            {IS_LAST_SCENARIO}
        [/objectives]
    [/event]

    # Event 1: Starting dialogue

    [event]
        name=start

        [scroll_to]
            x,y=10,13
        [/scroll_to]

        [redraw]
        [/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Nym
            message= _ "Kaleh! No!"
            image=portraits/nym_moody.png
        [/message]

        [redraw]
        [/redraw]

        [delay]
            time=500
        [/delay]

        # Nym runs to Kaleh's side

        {MOVE_UNIT id=Nym 10 14}

        [delay]
            time=300
        [/delay]

        # Zhul runs to Kaleh's side

        {MOVE_UNIT id=Zhul 11 14}
        {MODIFY_UNIT (id=Zhul) facing nw}

        [message]
            speaker=Zhul
            message= _ "He’s still breathing. Eloh, what grace I have, give unto him."
        [/message]

        [delay]
            time=300
        [/delay]

        [message]
            speaker=Nym
            message= _ "He’s stirring."
        [/message]

        # Ally runs to Kaleh's side

        {MOVE_UNIT id=$ally_name 9 14}

        [delay]
            time=300
        [/delay]

        [if]
            [variable]
                name=ally_race
                equals=dwarf
            [/variable]

            [then]
                [message]
                    speaker=$ally_name
                    message= _ "Aye, there’s still life in the boy. But where is the foul creature that did this to him?"
                [/message]
            [/then]

            [else]
                [message]
                    speaker=$ally_name
                    message= _ "The little one is not dead yet. But where is evil lady that did this to him?"
                [/message]
            [/else]
        [/if]

        [redraw]
        [/redraw]

        [delay]
            time=300
        [/delay]

        [unit]
            type=Divine Incarnation
            id=Eloh
            name= _ "Eloh"
            profile=portraits/eloh.png
            x,y=10,11
            upkeep=free
            side=2
            [modifications]
                {TRAIT_INTELLIGENT}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Eloh
            message= _ "So, the elf’s puny friends think they can save him. But you are too late. He is already mine!"
        [/message]

        [remove_item]
            x,y=10,13
        [/remove_item]

        {VARIABLE_OP stored_kaleh.hitpoints sub 10}
        {VARIABLE stored_kaleh.facing n}

        [unstore_unit]
            variable=stored_kaleh
            find_vacant=yes
        [/unstore_unit]

        [if]
            [have_unit]
                id=$ally_name
            [/have_unit]

            [then]
                {MESSAGE_DEPEND_ON_ALLY
                (
                    [message]
                        speaker=Kaleh
                        message= _ "Nym, Zhul, Grog, you shouldn’t have."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        message= _ "Nym, Zhul, Nog, you shouldn’t have."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        message= _ "Nym, Zhul, Rogrimir, you shouldn’t have."
                    [/message]
                )

                (
                    [message]
                        speaker=Kaleh
                        message= _ "Nym, Zhul, Jarl, you shouldn’t have."
                    [/message]
                )}
            [/then]

            [else]
                [message]
                    speaker=Kaleh
                    message= _ "Nym, Zhul, you shouldn’t have."
                [/message]
            [/else]
        [/if]

        [message]
            speaker=Eloh
            message= _ "Your struggles were mildly entertaining, but futile in the end. For I am powerful beyond your imagining, and this is the seat of my power!"
        [/message]

        [message]
            speaker=Zhul
            message= _ "You are not Eloh. You are but a pitiful mockery of her power and glory!"
        [/message]

        [message]
            speaker=Eloh
            message= _ "Is that what you think? I shall prove you wrong. Look out upon your people and despair!"
        [/message]

        [move_unit_fake]
            type=Quenoth Fighter
            side=3
            x=9,8
            y=20,16
        [/move_unit_fake]

        [unit]
            type=Quenoth Fighter
            id=Anarion
            name= _ "Anarion"
            x=8
            y=16
            side=3
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        [redraw]
        [/redraw]

        [delay]
            time=100
        [/delay]

        [move_unit_fake]
            type=Tauroch Rider
            side=3
            x=11,12
            y=20,16
        [/move_unit_fake]

        [unit]
            type=Tauroch Rider
            id=Zylea
            name= _ "Zylea"
            x=12
            y=16
            side=3
            [modifications]
                {TRAIT_DEXTROUS}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [message]
            speaker=Anarion
            message= _ "All hail Eloh!"
        [/message]

        [message]
            speaker=Zylea
            message= _ "Death to the heretics!"
        [/message]

        [message]
            speaker=Eloh
            message= _ "They worship their true god."
        [/message]

        [message]
            speaker=Eloh
            message= _ "Come and bow down before your true master, boy."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Your wish is my command."
        [/message]

        [redraw]
        [/redraw]

        [delay]
            time=300
        [/delay]

        # Kaleh moves over to Eloh

        {MOVE_UNIT id=Kaleh 10 12}

        [harm_unit]
            [filter]
                id=Eloh
            [/filter]

            [filter_second]
                id=Kaleh
            [/filter_second]

            [primary_attack]
                name=sword
            [/primary_attack]
            animate=yes
            # Do damage according to Kaleh's first, sword attack
            amount=$stored_kaleh.attack[0].damage
            alignment=lawful
            damage_type=blade
        [/harm_unit]

        {CLEAR_VARIABLE stored_kaleh}

        [redraw]
        [/redraw]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Eloh
            image=portraits/eloh_rage.png
            message= _ "Argh, you stabbed me!"
        [/message]

        [message]
            speaker=Kaleh
            # wmllint: local spelling Kalehssar
            message= _ "I have crossed deserts, mountains, and oceans and watched my people bleed every step of the way. I did not come all this way to give up now. I am tired of being called boy; I am Kalehssar, the leader of my people and I will fight you until my dying breath!"
        [/message]

        [message]
            speaker=Eloh
            image=portraits/eloh_rage.png
            message= _ "I command you to stop this foolishness!"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Never!"
        [/message]

        [message]
            speaker=Nym
            message= _ "The shell brooches Melusand gave us, they’re glowing!"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "You will never dominate us, not while hope survives!"
        [/message]

        [message]
            speaker=Eloh
            image=portraits/eloh_rage.png
            message= _ "So be it. You choose death? Then you shall receive it from those you hold most dear. Kill the unbelievers, let none survive!"
        [/message]

        [message]
            speaker=Anarion
            message= _ "Yes mistress."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Ignore our brethren, we must destroy her!"
        [/message]
    [/event]

    # Create an alien minion
    [event]
        name=create_minion
        first_time_only=no
        {SCATTER_UNITS 1 (Crawling Horror) 0 (
            x=6-14
            y=7-14
            terrain=Rr,Uu

            [not]
                [filter]
                [/filter]
            [/not]
        ) (
            side=2
            upkeep=free
        )}
    [/event]

    # Event 1: The Death of Eloh and the revealing of the true monster

    [event]
        name=last breath

        [filter]
            id=Eloh
        [/filter]

        [fire_event]
            name=eloh_death
        [/fire_event]
    [/event]

    [event]
        name=eloh_death

        [message]
            speaker=Eloh
            image=portraits/eloh_rage.png
            message= _ "You think you killed me? You have no idea what you are facing."
        [/message]

        [message]
            speaker=Nym
            message= _ "Who is she really? Could it be Zhangor, back to avenge his imprisonment?"
            image=portraits/nym_moody.png
        [/message]

        [message]
            speaker=Eloh
            image=portraits/eloh_rage.png
            message= _ "Nonsense. Unlike that fool, I do not care about petty things like revenge. Nor do I depend on mortals to enact my will. No, I shall destroy you myself!"
        [/message]

        [kill]
            id=Eloh
            animate=no
            fire_event=no
        [/kill]

        [modify_unit]
            [filter]
                side=3
            [/filter]
            side=1
        [/modify_unit]

        [message]
            type=Quenoth Fighter, Tauroch Rider
            message= _ "Huh? What happened?"
        [/message]

        [message]
            speaker=Zhul
            message= _ "Her spell has been broken. But I don’t think we have won yet. Come aid us!"
        [/message]

        [message]
            type=Quenoth Fighter, Tauroch Rider
            message= _ "Yes priestess."
        [/message]

        [scroll]
            x=25
        [/scroll]
        [scroll]
            x=-25
        [/scroll]
        [scroll]
            x=25
        [/scroll]
        [scroll]
            x=-25
        [/scroll]
        [scroll]
            x=25
        [/scroll]
        [scroll]
            x=-25
        [/scroll]

        [redraw]
        [/redraw]

        [delay]
            time=400
        [/delay]

        [color_adjust]
            red,green,blue=40,0,100
        [/color_adjust]

        [redraw]
        [/redraw]

        [delay]
            time=250
        [/delay]

        [color_adjust]
            red,green,blue=0,0,0
        [/color_adjust]

        [redraw]
        [/redraw]

        # main body appears

        [terrain]
            terrain=Urb # wmllint: ignore
            x,y=10,10
        [/terrain]

        # create main body unit here

        [unit]
            type=Central Body1
            id=Yechnagoth
            name= _ "Yechnagoth"
            side=2
            x,y=10,10
        [/unit]
#define UTBS_YECH_CS
        CS(-240,30,20)#enddef
        [item]
            halo=halo/illuminates-aura.png~{UTBS_YECH_CS}
            x,y=10,10
        [/item]

        # add roots around central body

        #{PLACE_IMAGE scenery/castle-ruins.png 9 11}
        #{PLACE_IMAGE scenery/castle-ruins.png 10 11}
        #{PLACE_IMAGE scenery/castle-ruins.png 11 11}
        #{PLACE_IMAGE scenery/castle-ruins.png 9 10}
        #{PLACE_IMAGE scenery/castle-ruins.png 10 9}
        #{PLACE_IMAGE scenery/castle-ruins.png 11 10}

        # Pulsing Spires appear

        {RANDOM 0..1}

        [if]
            [variable]
                name=random
                numerical_equals=1
            [/variable]

            [then]
                [terrain]
                    terrain=Uu
                    x=8,8,14
                    y=7,13,10
                [/terrain]

                # create Pulsing Spires at:
                # (8,7) (8,13) (14,10)

                [unit]
                    type=Pulsing Spire
                    side=4
                    x,y=8,7
                [/unit]

                [unit]
                    type=Pulsing Spire
                    side=4
                    x,y=8,13
                [/unit]

                [unit]
                    type=Pulsing Spire
                    side=4
                    x,y=14,10
                [/unit]
            [/then]

            [else]
                [terrain]
                    terrain=Uu
                    x=6,12,12
                    y=10,7,13
                [/terrain]

                # create Pulsing Spires at:
                # (6,10) (12,7) (12,13)

                [unit]
                    type=Pulsing Spire
                    side=4
                    x,y=6,10
                [/unit]

                [unit]
                    type=Pulsing Spire
                    side=4
                    x,y=12,7
                [/unit]

                [unit]
                    type=Pulsing Spire
                    side=4
                    x,y=12,13
                [/unit]
            [/else]
        [/if]

        [redraw]
        [/redraw]

        [message]
            speaker=Nym
            message= _ "What is that thing?!"
            image=portraits/nym_moody.png
        [/message]

        [message]
            speaker=Zhul
            message= _ "Eloh protect us!"
        [/message]

        [color_adjust]
            red,green,blue=33,181,140
        [/color_adjust]

        [redraw]
        [/redraw]

        [delay]
            time=250
        [/delay]

        [color_adjust]
            red,green,blue=0,0,0
        [/color_adjust]

        [redraw]
        [/redraw]

        # create 3/4/5 bugs
        [fire_event]
            name=create_minion
        [/fire_event]
        [fire_event]
            name=create_minion
        [/fire_event]
        [fire_event]
            name=create_minion
        [/fire_event]
#ifdef NORMAL
        [fire_event]
            name=create_minion
        [/fire_event]
#endif
#ifdef HARD
        [fire_event]
            name=create_minion
        [/fire_event]
        [fire_event]
            name=create_minion
        [/fire_event]
#endif

        [redraw]
        [/redraw]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Zhul
            message= _ "Curse Uria, more abominations!"
        [/message]

        [message]
            speaker=Nym
            message= _ "Is it even possible to kill this thing? It’s huge!"
            image=portraits/nym_moody.png
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It must have some sort of weak point. Look at those pulsing spires, I thought they were stone, but they seem to be alive. Maybe if we destroy them it will weaken the creature. No matter what horrors appear, we must keep attacking it. We can’t stop now!"
        [/message]

        [show_objectives]
        [/show_objectives]

        # Start spawning minions, increasing the number each turn.
        {VARIABLE number_minions_to_spawn 1}
        [event]
            name="turn $($turn_number+{ON_DIFFICULTY 2 2 1})"
            delayed_variable_substitution=no
            {VARIABLE number_minions_to_spawn 2}
        [/event]
        [event]
            name="turn $($turn_number+{ON_DIFFICULTY 5 4 3})"
            delayed_variable_substitution=no
            {VARIABLE number_minions_to_spawn 3}
        [/event]
        [event]
            name="turn $($turn_number+{ON_DIFFICULTY 8 7 6})"
            delayed_variable_substitution=no
            {VARIABLE number_minions_to_spawn 4}
        [/event]
        [event]
            name="turn $($turn_number+{ON_DIFFICULTY 14 12 10})"
            delayed_variable_substitution=no
            {VARIABLE number_minions_to_spawn 5}
        [/event]
        [event]
            name="turn $($turn_number+{ON_DIFFICULTY 19 17 15})"
            delayed_variable_substitution=no
            {VARIABLE number_minions_to_spawn 6}
        [/event]
        [event]
            name="turn $($turn_number+{ON_DIFFICULTY 25 23 21})"
            delayed_variable_substitution=no
            {VARIABLE number_minions_to_spawn 7}
        [/event]

        # Also give everyone their movement back so it doesn't feel so bad right after you kill fake Eloh

        [heal_unit]
            [filter]
                side=1
            [/filter]

            amount=0
            moves=full
            restore_statuses=yes
            restore_attacks=yes
        [/heal_unit]
        {CLEAR_VARIABLE heal_amount}
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [filter_condition]
            [have_unit]
                id=Yechnagoth
            [/have_unit]
        [/filter_condition]

        {VARIABLE helper_level 4}
        [while]
            [variable]
                name=helper_level
                greater_than=0
            [/variable]
            [variable]
                name=possible_helpers.length
                equals=0
            [/variable]
            [do]
                [store_unit]
                    [filter]
                        side=1
                        level=$helper_level
                        x,y=recall,recall
                        [not]
                            race=merman
                        [/not]
                    [/filter]

                    kill=no
                    variable=possible_helpers
                [/store_unit]
                {VARIABLE_OP helper_level sub 1}
            [/do]
        [/while]
        {CLEAR_VARIABLE helper_level}

        [if]
            [variable]
                name=possible_helpers.length
                greater_than=0
            [/variable]

            [then]
                {VARIABLE_OP random_helper_i rand "1..$possible_helpers.length"}
                {VARIABLE_OP random_helper_i sub 1}

                [move_unit_fake]
                    type=$possible_helpers[$random_helper_i].type
                    side=1
                    x=10,10
                    y=20,18
                [/move_unit_fake]

                [recall]
                    id=$possible_helpers[$random_helper_i].id
                    x,y=10,18
                    show=no
                [/recall]

                {CLEAR_VARIABLE random_helper_i}
            [/then]
        [/if]
        {CLEAR_VARIABLE possible_helpers}
    [/event]

    # Event 2: New minions are created each turn
    [event]
        name=new turn
        first_time_only=no

        [repeat]
            times=$number_minions_to_spawn

            [do]
                [fire_event]
                    name=create_minion
                [/fire_event]
            [/do]
        [/repeat]
    [/event]

    # Event 3: Central Body heals fully each turn
    # let's move this to the unit type, rather than an event, so there are some indications for the player that tactics like poison won't work.

    [event]
        name=new turn
        first_time_only=no

        [filter_condition]
            [have_unit]
                type=Central Body
            [/have_unit]
        [/filter_condition]

        [fire_event]
            name=yechnagoth_regenerate
        [/fire_event]
    [/event]

    [event]
        name=yechnagoth_regenerate
        first_time_only=no

        [store_unit]
            [filter]
                type=Central Body
            [/filter]
            variable=stored_alien
        [/store_unit]

        [set_variable]
            name=temp
            value=$stored_alien.hitpoints
        [/set_variable]

        [if]
            [variable]
                name=temp
                less_than=$stored_alien.max_hitpoints
            [/variable]

            [then]
                [fire_event]
                    name=invulnerable_comment
                [/fire_event]
            [/then]
        [/if]

        {CLEAR_VARIABLE (temp,stored_alien)}
    [/event]

    [event]
        name=invulnerable_comment

        [message]
            speaker=Kaleh
            message= _ "That central body is healing faster than we can damage it. It’s almost as if our attacks are doing no damage at all. We got to try another tactic, and fast!"
        [/message]
    [/event]

    # Event 4: Special attack by Central Body each turn

    [event]
        name=new turn
        first_time_only=no

        [filter_condition]
            [have_unit]
                id=Yechnagoth
            [/have_unit]
        [/filter_condition]

        [fire_event]
            name=yechnagoth_special_attack
        [/fire_event]
    [/event]

    [event]
        name=yechnagoth_special_attack
        first_time_only=no

        [store_unit]
            [filter]
                side=1
                {EVERYWHERE}
            [/filter]

            kill=no
            variable=elf_list
        [/store_unit]

        {VARIABLE_OP victim_i rand "1..$elf_list.length"}
        {VARIABLE_OP victim_i sub 1}

        {VARIABLE victim_id $elf_list[$victim_i].id}
        {CLEAR_VARIABLE (elf_list,victim_i)}

        #used to be 140,255,247

        [color_adjust]
            red,green,blue=40,0,100
        [/color_adjust]

        [redraw]
        [/redraw]

        [delay]
            time=250
        [/delay]

        [color_adjust]
            red,green,blue=0,0,0
        [/color_adjust]

        [redraw]
        [/redraw]

        [delay]
            time=100
        [/delay]

        # Add two effects slow unit and damage it
        # 1: do damage to unit (9/12/15 based on difficulty?-stops healing)
        # 2: slow unit
        [sound]
            name=squishy-strike.wav
        [/sound]

        [harm_unit]
            [filter]
                id=$victim_id
            [/filter]

            amount={ON_DIFFICULTY 9 12 15}
            alignment=chaotic
            damage_type=fire
            kill=no
            slowed=yes
        [/harm_unit]

        [if]
            [variable]
                name=hit_by_special_attack
                not_equals=yes
            [/variable]

            [then]
                {VARIABLE hit_by_special_attack yes}

                [message]
                    speaker=$victim_id
                    message= _ "What the heck? That central creature just hit me with some sort of slime. It hurts and I— I’m stuck!"
                [/message]
            [/then]

            [else]
                [message]
                    speaker=$victim_id
                    message= _ "Ow, I’m stuck!"
                [/message]
            [/else]
        [/if]

        {CLEAR_VARIABLE victim_id}
    [/event]

    # Event 5: When player destroys all 3 Pulsing Spires, Central Body is weakened

    [event]
        name=die
        first_time_only=no

        [filter]
            type=Pulsing Spire
        [/filter]

        [filter_condition]
            [have_unit]
                type=Pulsing Spire
                count=2
            [/have_unit]
        [/filter_condition]

        [remove_item]
            x,y=10,10
        [/remove_item]
        [item]
            halo=halo/illuminates-aura.png~{UTBS_YECH_CS}:500,halo/illuminates-aura.png~{UTBS_YECH_CS}~O(0.6):100
            x,y=10,10
        [/item]
    [/event]

    [event]
        name=die
        first_time_only=no

        [filter]
            type=Pulsing Spire
        [/filter]

        [filter_condition]
            [have_unit]
                type=Pulsing Spire
                count=1
            [/have_unit]
        [/filter_condition]

        [remove_item]
            x,y=10,10
        [/remove_item]
        [item]
            halo=halo/illuminates-aura.png~{UTBS_YECH_CS}~O(0.6):200,halo/illuminates-aura.png~{UTBS_YECH_CS}~O(0.2):400
            x,y=10,10
        [/item]
    [/event]

    [event]
        name=die
        first_time_only=no

        [filter]
            type=Pulsing Spire
        [/filter]

        [filter_condition]
            [have_unit]
                type=Pulsing Spire
                count=0
            [/have_unit]
        [/filter_condition]

        [remove_item]
            x,y=10,10
        [/remove_item]
        [fire_event]
            name=yechnagoth_vulnerate
        [/fire_event]
    [/event]

    [event]
        name=yechnagoth_vulnerate

        # when all 3 spires are destroyed, weaken main body
        [kill]
            type=Pulsing Spire
            fire_event=no
            animate=no
        [/kill]

        [scroll]
            x=20
        [/scroll]
        [scroll]
            x=-20
        [/scroll]
        [scroll]
            x=20
        [/scroll]
        [scroll]
            x=-20
        [/scroll]
        [scroll]
            x=20
        [/scroll]
        [scroll]
            x=-20
        [/scroll]

        [message]
            speaker=narrator
            message= _ "<big><b>Aaaurrgghh!!</b></big>"
            image= # wmllint: no-icon
        [/message]

        [kill]
            type=Central Body1
            animate=no
            fire_event=no
        [/kill]

        [unit]
            type=Central Body2
            id=Yechnagoth
            name= _ "Yechnagoth"
            side=2
            x,y=10,10
        [/unit]

        [redraw]
        [/redraw]

        [message]
            speaker=Kaleh
            message= _ "I think we’re finally doing some damage. We must attack the central body, while it remains vulnerable!"
        [/message]
    [/event]

    # Event 6: Death of weakened Central Body

    [event]
        name=last breath

        [filter]
            type=Central Body2
        [/filter]

        # shake cavern

        [scroll]
            x=40
        [/scroll]
        [scroll]
            x=-40
        [/scroll]
        [scroll]
            x=40
        [/scroll]
        [scroll]
            x=-40
        [/scroll]
        [scroll]
            x=40
        [/scroll]
        [scroll]
            x=-40
        [/scroll]

        # flash dark blue, light blue, very light blue,

        # dark blue

        [color_adjust]
            red,green,blue=40,0,100
        [/color_adjust]

        [redraw]
        [/redraw]

        [delay]
            time=300
        [/delay]

        #light blue

        [color_adjust]
            red,green,blue=33,181,140
        [/color_adjust]

        [redraw]
        [/redraw]

        [delay]
            time=300
        [/delay]

        # very light blue

        [color_adjust]
            red,green,blue=140,255,247
        [/color_adjust]

        [redraw]
        [/redraw]

        [delay]
            time=300
        [/delay]

        # back to normal

        [color_adjust]
            red,green,blue=0,0,0
        [/color_adjust]

        [redraw]
        [/redraw]
    [/event]

    [event]
        name=die

        [filter]
            type=Central Body2
        [/filter]

        [fire_event]
            name=yechnagoth_death
        [/fire_event]
    [/event]

    [event]
        name=yechnagoth_death

        # have a minion scream

        [message]
            type=Crawling Horror
            message= _ "Aiiee!!"    # wmllint: no spellcheck
        [/message]

        [redraw]
        [/redraw]

        # kill minions

        [kill]
            type=Crawling Horror,Pulsing Spire
            animate=yes
            fire_event=no
        [/kill]

        [redraw]
        [/redraw]

        # wait
        [delay]
            time=2500
        [/delay]

        #ending conversation

        [message]
            speaker=Kaleh
            message= _ "At last. It is finished."
        [/message]

        [if]
            [have_unit]
                id=Nym
            [/have_unit]

            [then]
                [message]
                    speaker=Nym
                    message= _ "Is Yechnagoth really dead?"
                    image=portraits/nym_moody.png
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "Yes, she’s dead Nym."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "I almost can’t believe it."
                [/message]
            [/then]
        [/if]

        [message]
            speaker=Zhul
            message= _ "Behold, the pretender has been defeated. Eloh’s might has prevailed."
        [/message]

        {MESSAGE_DEPEND_ON_ALLY
        (
            [message]
                speaker=Grog
                message= _ "Ugh. Grog is covered in blood and guts and nasty blue goo. Whatever creature was, she doesn’t smell any better dead than she did alive."
            [/message]
        )
        (
            [message]
                speaker=Nog
                message= _ "Ugh. Nog is covered in blood and guts and nasty blue goo. Whatever creature was, she doesn’t smell any better dead than she did alive."
            [/message]
        )
        (
            [message]
                speaker=Rogrimir
                message= _ "Ugh. I’m covered in blood and guts, and this nasty blue stuff. I don’t know what in the nine hells we were fighting, but she doesn’t smell any better dead than she did alive."
            [/message]
        )
        (
            [message]
                speaker=Jarl
                message= _ "Ugh. I’m covered in blood and guts, and this nasty blue stuff. I don’t know what in the nine hells we were fighting, but she doesn’t smell any better dead than she did alive."
            [/message]
        )}

        [if]
            [have_unit]
                id=Nym,Zhul,$ally_name
            [/have_unit]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "Let’s get out of here."
                [/message]
            [/then]
        [/if]

        {CLEAR_VARIABLE number_minions_to_spawn}
        {CLEAR_VARIABLE hit_by_special_attack}

        [endlevel]
            result=victory
            bonus=no
            carryover_report=no
            linger_mode=no
            {NEW_GOLD_CARRYOVER 0}
        [/endlevel]
    [/event]

#define UTBS_IN_FINAL_FIGHT
#enddef
    {UTBS_INCLUDE utils/deaths.cfg}
#undef UTBS_IN_FINAL_FIGHT
[/scenario]


#textdomain wesnoth-utbs

[scenario]
    id=13_Epilogue
    name= _ "Epilogue"

    {UTBS_MAP 13_Epilogue.map}

    {SCENARIO_MUSIC "elf-land.ogg"}
    {EXTRA_SCENARIO_MUSIC "journeys_end.ogg"}
    {EXTRA_SCENARIO_MUSIC "love_theme.ogg"}

    victory_when_enemies_defeated=no
    turns=unlimited
    theme=Cutscene_Minimal

    {DAWN1}

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

    # These two are referred to for searching the recall list, but wmllint
    # will still complain about "unknown '<NAME>' referred to by id" without
    # these comments.
    #
    # wmllint: recognize Nym
    # wmllint: recognize Zhul

    # Prestart functions:

    [event]
        name=prestart

        # capture all villages for side 1
        [capture_village]
            x=0-50
            y=0-50
            side=1
        [/capture_village]
    [/event]

    # Event 1: Starting dialogue

    [event]
        name=start

        [message]
            speaker=Kaleh
            message= _ "I stumbled out into the daylight, scarcely believing that we were victorious. Looking out over the island it took me a moment to realize what had changed. The fetid darkness had lifted from the land and I saw the suns shining brightly for what seemed like the first time in ages. Gazing across the bright green trees and sparkling ocean I realized that once this had been a place of beauty. Several of our brethren were waiting for me and I was overjoyed to discover that they were no longer the mindless slaves I had seen before. They too had broken free from their enchantment."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Indeed with Yechnagoth’s death it seems that all of her minions reverted to their original chaotic tendencies. Luckily we had already destroyed most of the island’s foul inhabitants, and lacking their former discipline we had no trouble exterminating the remaining orcs and undead. The naga too fled before us, and they have not bothered us since. For once we seemed to be safe from imminent danger."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "A few days later Melusand herself appeared and she declared the cleansing of this island a miracle. We made a pact between elf and merfolk and vowed to live together in peace and prosperity. Melusand blessed the island, and named it ‘Quenoth Isle’ in honor of our people. The merfolk have been very helpful in teaching us how to adapt to this strange land, though I still have trouble getting used to being surrounded by water. It used to be more precious than gold. Still, I could hardly imagine a better home for my people. Between the bounty of the sea and the many fruits of the jungle there is no shortage of food. We are isolated from the chaos on the mainland and the merfolk guard the waters. Melusand says now is a time for peace and prosperity. Part of me didn’t think we would survive our journey, there were so many close calls. Coming here almost does seem like a miracle. If only I could forget the price we paid..."
        [/message]

        # change depending on how many friends died

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

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. And it is only through Eloh’s grace and a good bit of luck that none of them died in that bloody battle. But so many others that I grew up with were not so lucky. Why did so many of us have to die? I wish I could go back and do it all over again."
                [/message]
            [/then]

            [else]
                {INCIDENTAL_MUSIC sad.ogg}
            [/else]
        [/if]

        # if only 1 friend dies, then have 3 different texts depending on who died

        [if]
            [variable]
                name=allies_killed
                numerical_equals=1
            [/variable]

            [then]
                [if]
                    [have_unit]
                        id=Nym
                        search_recall_list=yes
                        count=0
                    [/have_unit]

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Nym back. She followed me faithfully and fought by my side for so long, to lose her at the end... I wish I could go back and do it all over again."
                        [/message]
                        [message]
                            speaker=Kaleh
                            message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by Nym’s death in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Nym was willing to sacrifice her life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But sometimes that seems a small consolation."
                        [/message]
                    [/then]
                [/if]

                [if]
                    [have_unit]
                        id=Zhul
                        search_recall_list=yes
                        count=0
                    [/have_unit]

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Zhul back. She followed me faithfully and fought by my side for so long, to lose her at the end... I wish I could go back and do it all over again."
                        [/message]
                        [message]
                            speaker=Kaleh
                            message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by Zhul’s death in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Zhul was willing to sacrifice her life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But sometimes that seems a small consolation."
                        [/message]
                    [/then]
                [/if]

                [if]
                    [variable]
                        name=ally_died_in_final_fight
                        boolean_equals=yes
                    [/variable]

                    [then]
                        {MESSAGE_DEPEND_ON_ALLY
                        (
                            [message]
                                speaker=Kaleh
                                message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Grog back. He left his homeland to fight faithfully by my side, and then to lose him at the end... I wish I could go back and do it all over again."
                            [/message]
                            [message]
                                speaker=Kaleh
                                message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by the death of Grog in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Grog was willing to sacrifice his life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But when I think of the desperate war that his people are probably still fighting underground, it seems a small consolation."
                            [/message]
                        )
                        (
                            [message]
                                speaker=Kaleh
                                message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Nog back. He left his homeland to fight faithfully by my side, and then to lose him at the end... I wish I could go back and do it all over again."
                            [/message]
                            [message]
                                speaker=Kaleh
                                message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by the death of Nog in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Nog was willing to sacrifice his life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But when I think of the desperate war that his people are probably still fighting underground, it seems a small consolation."
                            [/message]
                        )
                        (
                            [message]
                                speaker=Kaleh
                                message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Rogrimir back. He left his homeland to fight faithfully by my side, and then to lose him at the end... I wish I could go back and do it all over again."
                            [/message]
                            [message]
                                speaker=Kaleh
                                message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by the death of Rogrimir in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Rogrimir was willing to sacrifice his life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But when I think of the desperate war that his people are probably still fighting underground, it seems a small consolation."
                            [/message]
                        )
                        (
                            [message]
                                speaker=Kaleh
                                message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Jarl back. He left his homeland to fight faithfully by my side, and then to lose him at the end... I wish I could go back and do it all over again."
                            [/message]
                            [message]
                                speaker=Kaleh
                                message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by the death of Jarl in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Jarl was willing to sacrifice his life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But when I think of the desperate war that his people are probably still fighting underground, it seems a small consolation."
                            [/message]
                        )}
                    [/then]
                [/if]
            [/then]
        [/if]

        [if]
            [variable]
                name=allies_killed
                greater_than=1
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring any one of them back. They followed me faithfully and fought by my side for so long, to lose them at the end... I wish I could go back and do it all over again."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by my friends’ deaths in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that they were willing to sacrifice their lives to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But I still miss each one of them horribly."
                [/message]
            [/then]
        [/if]

        [if]
            [have_unit]
                id=Nym
                search_recall_list=yes
                count=0
            [/have_unit]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/nym.png
                    message= _ "We carried Nym to a small island to the north which had a single peak with a beautiful view of the surrounding islands. It seemed to me to be a lookout that Nym would appreciate. So I and a few others climbed to the top of the peak and dug a grave for Nym so that she might always look down upon us and see all that we accomplished with her gift. For she gave us the gift of life, and every day I strive to make the most use of it I can. I will always remember her. Nym, who was with me ever since I was a child and during every step of the journey, who was always faithful, but never hesitated to speak her mind, who managed to crack a joke no matter how grim the situation. How I miss her laugh, her smile, her..."
                [/message]
            [/then]
        [/if]

        [if]
            [have_unit]
                id=Zhul
                search_recall_list=yes
                count=0
            [/have_unit]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/zhul_shyde.png
                    message= _ "Zhul’s funeral was a huge ceremony, like those she told us about from ages ago. I led a procession of our few remaining priestesses and all of the faithful around the entire island, so that she might see all that she had given to us. Being a priestess of the desert sands we buried her in one of the large beaches at the northwest end of the island. At the final battle she was one of the oldest elves left and I suppose I should thank Eloh that she did not die during our journey. She was my guide and my faith and my link to the past. I am sorry that she did not live to see the fruits of her labors, but I hope that she is with Eloh now, in a better place."
                [/message]
            [/then]
        [/if]

        # if ally dies in the final battle
        [if]
            [variable]
                name=ally_died_in_final_fight
                boolean_equals=yes
            [/variable]

            [then]
                {MESSAGE_DEPEND_ON_ALLY
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/trolls/troll-hero-alt.png
                        message= _ "I am saddened by the death of Grog, but by saving my life in the end he did fulfill his life debt to me. I think he also would have been glad to have died in battle. I considered leading an expedition to go back and return his body to his people, but my fellow elves have been weakened by our long journey and I do not want to risk losing any more. Instead I searched all across the islands and at last in the rocky outcroppings to the northwest I found a series of caves. They were not as deep as his homeland but I thought Grog would have appreciated being laid to rest under some solid rock. And so we buried him with much honor and will long remember the service that his kind has done for our people."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/trolls/troll-hero-alt.png
                        message= _ "I am saddened by the death of Nog, but by saving my life in the end he did fulfill his life debt to me. I think he also would have been glad to have died in battle. I considered leading an expedition to go back and return his body to his people, but my fellow elves have been weakened by our long journey and I do not want to risk losing any more. Instead I searched all across the islands and at last in the rocky outcroppings to the northwest I found a series of caves. They were not as deep as his homeland but I thought Nog would have appreciated being laid to rest under some solid rock. And so we buried him with much honor and will long remember the service that his kind has done for our people."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/dwarves/fighter-2.png
                        message= _ "I am saddened by the death of Rogrimir, but by saving my life in the end he did fulfill his life debt to me. I think he also would have been glad to have died in battle. I considered leading an expedition to go back and return his body to his people, but my fellow elves have been weakened by our long journey and I do not want to risk losing any more. Instead I searched all across the islands and at last in the rocky outcroppings to the northwest I found a series of caves. They were not as deep as his homeland but I thought Rogrimir would have appreciated being laid to rest under some solid rock. And so we buried him with much honor and will long remember the service that his kind has done for our people."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/dwarves/fighter-2.png
                        message= _ "I am saddened by the death of Jarl, but by saving my life in the end he did fulfill his life debt to me. I think he also would have been glad to have died in battle. I considered leading an expedition to go back and return his body to his people, but my fellow elves have been weakened by our long journey and I do not want to risk losing any more. Instead I searched all across the islands and at last in the rocky outcroppings to the northwest I found a series of caves. They were not as deep as his homeland but I thought Jarl would have appreciated being laid to rest under some solid rock. And so we buried him with much honor and will long remember the service that his kind has done for our people."
                    [/message]
                )}
            [/then]
        [/if]

        # if nym doesn't die
        [if]
            [have_unit]
                id=Nym
                search_recall_list=yes
            [/have_unit]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/nym.png
                    message= _ "Although I am not as devout as Zhul is, I thank Eloh every day that Nym survived that horrible battle in the Black Citadel. No one has been more enthusiastic than she in embracing our life among the islands. She delights in swimming and sailing among the shallows and spends so much time in the water that sometimes I think she is half mermaid herself. Her sparkling laugh and quick wit are a daily gift to us. She entertains the children with thrilling (though often slightly embellished) tales of our great journey, and at times when I get moody, she reminds me what a joy it is to be alive in this great land. She is a living testament to the fact that even though we were born among the sands we can thrive anywhere we have the will to live."
                [/message]
            [/then]
        [/if]

        # if zhul doesn't die
        [if]
            [have_unit]
                id=Zhul
                search_recall_list=yes
            [/have_unit]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/zhul.png
                    message= _ "The oldest of the surviving elves, Zhul is moving slower now, but she still has that sparkle in her eye. Despite the hardships of our journey and Yechnagoth’s deceptions, our victory has only strengthened her faith. She will be as quick as always to correct the error of your ways if you ever express a disbelief in the powers of Eloh. She told me recently that all the trials and triumphs of our journey were but parts of Eloh’s great plan for us, and this new home is our reward. She is spending her time now teaching a whole new generation of priestesses and telling all the old stories to the children so that they won’t be forgotten. She has started designing a sacred grove in the jungle for Eloh, as our people did in the olden times. I am still not quite used to seeing so many trees, but perhaps, as some people say, it is a sign that the peace and prosperity of old has come again."
                [/message]
            [/then]
        [/if]

        # if ally doesn't die
        [if]
            [have_unit]
                id=$ally_name
                search_recall_list=yes
            [/have_unit]

            [then]
                {MESSAGE_DEPEND_ON_ALLY
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/trolls/troll-hero-alt.png
                        message= _ "By saving my life, Grog fulfilled his life debt to me, but we convinced him to hang around for a while and revel in the celebrations that we held after our great victory. We celebrated for days and days, thanking Eloh and the merfolk’s god, and delighting in the bounty and beauty of our new home. And afterwards we set to work building new dwellings for our people. Grog stayed to help us with the construction, he was the hardest worker among us. But after a while he came to me and told me that he had to return to his own people. Grog said his time with us had been like a wonderful dream, and he promised he would remember us always, but his people needed him and he had to go back home. He said that someday he would return and visit us again, but I doubt I shall ever see him again in life. All the same I treasure the memory of him and his kind, and I will long remember his steadfast loyalty and all that he did to aid us in our struggle."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/trolls/troll-hero-alt.png
                        message= _ "By saving my life, Nog fulfilled his life debt to me, but we convinced him to hang around for a while and revel in the celebrations that we held after our great victory. We celebrated for days and days, thanking Eloh and the merfolk’s god, and delighting in the bounty and beauty of our new home. And afterwards we set to work building new dwellings for our people. Nog stayed to help us with the construction, he was the hardest worker among us. But after a while he came to me and told me that he had to return to his own people. Nog said his time with us had been like a wonderful dream, and he promised he would remember us always, but his people needed him and he had to go back home. He said that someday he would return and visit us again, but I doubt I shall ever see him again in life. All the same I treasure the memory of him and his kind, and I will long remember his steadfast loyalty and all that he did to aid us in our struggle."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/dwarves/fighter-2.png
                        message= _ "By saving my life, Rogrimir fulfilled his life debt to me, but we convinced him to hang around for a while and revel in the celebrations that we held after our great victory. We celebrated for days and days, thanking Eloh and the merfolk’s god, and delighting in the bounty and beauty of our new home. Afterwards we set to work building new dwellings for our people. Rogrimir stayed to help us with the construction, he was the hardest worker among us. But after a while he came to me and told me that he had to return to his own people. Rogrimir said his time with us had been like a wonderful dream, and he promised he would remember us always, but his people needed him and he had to go back home. He said that someday he would return and visit us again, but I doubt I shall ever see him again in life. All the same I treasure the memory of him and his kind, and I will long remember his steadfast loyalty and all that he did to aid us in our struggle."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/dwarves/fighter-2.png
                        message= _ "By saving my life, Jarl fulfilled his life debt to me, but we convinced him to hang around for a while and revel in the celebrations that we held after our great victory. We celebrated for days and days, thanking Eloh and the merfolk’s god, and delighting in the bounty and beauty of our new home. Afterwards we set to work building new dwellings for our people. Jarl stayed to help us with the construction, he was the hardest worker among us. But after a while he came to me and told me that he had to return to his own people. Jarl said his time with us had been like a wonderful dream, and he promised he would remember us always, but his people needed him and he had to go back home. He said that someday he would return and visit us again, but I doubt I shall ever see him again in life. All the same I treasure the memory of him and his kind, and I will long remember his steadfast loyalty and all that he did to aid us in our struggle."
                    [/message]
                )}
            [/then]
        [/if]

        # if ally died before the final battle
        [if]
            [have_unit]
                id=$ally_name
                search_recall_list=yes
                count=0
            [/have_unit]

            [variable]
                name=ally_died_in_final_fight
                boolean_equals=no
            [/variable]

            [then]
                {MESSAGE_DEPEND_ON_ALLY
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/trolls/troll-hero-alt.png
                        message= _ "And I will always remember Grog who died along our journey. A braver warrior I have never seen, and though he was taken from us too soon, I am glad for the short time that I knew him."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/trolls/troll-hero-alt.png
                        message= _ "And I will always remember Nog who died along our journey. A braver warrior I have never seen, and though he was taken from us too soon, I am glad for the short time that I knew him."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/dwarves/fighter-2.png
                        message= _ "And I will always remember Rogrimir who died along our journey. A braver warrior I have never seen, and though he was taken from us too soon, I am glad for the short time that I knew him."
                    [/message]
                )
                (
                    [message]
                        speaker=Kaleh
                        image=portraits/dwarves/fighter-2.png
                        message= _ "And I will always remember Jarl who died along our journey. A braver warrior I have never seen, and though he was taken from us too soon, I am glad for the short time that I knew him."
                    [/message]
                )}
            [/then]
        [/if]

        [message]
            speaker=Kaleh
            image=portraits/garak.png
            message= _ "So much has happened since we left the desert, but looking back upon our journey I do not want to forget Garak and his sacrifice. I doubt that we would have made it out of the sands alive if it was not for his strength and guidance. I remember how he used to smile when charging into battle, and how he would pray over the bodies of his fallen friends afterwards. I think of him sometimes, buried in the sands with his fellow warriors. I think he would have been proud of us. He was both a great warrior and a great teacher. He will be remembered."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "As for the Black Citadel, after much discussion we decided to go back to the ancient rituals for purifying unclean land, with fire. We filled the entire structure with wood and oil and set the place ablaze to make sure that any remnants of Yechnagoth’s infestation would be purged by holy fire. We then tore the citadel down, stone by stone. I was tempted to save the stones for construction in the future, but I did not know what foul magics might still linger in them, and I did not want to take any chances. So with the help of the merfolk, we carried the stones far out into the water and cast them down to the bottom of the ocean. Once the last stone had been removed, we decided that no matter what we built or grew around it, that area would be left bare as a reminder of the evil that once dwelt here and all those who gave their lives to destroy it."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It has been several years since the events that I chronicle here, and I’m not quite as spry and limber as I used to be, so I decided it was about time that I write this all down lest something happen to me. My one wish is that our descendants do not forget all those who made the ultimate sacrifice so that there might be a future for our people. Looking at the ruins of the ancient empires, I know that time erases all things. We have forgotten so much about the Golden Age. Do not let our story suffer the same fate. For as long as the tales of those now departed are still told, in some sense they are still alive and still with us. Honor those who have died. Remember our mistakes so you will not repeat them. And most of all, treasure every day, for it is a gift, from us to you."
        [/message]

        # if both Nym and Zhul survived, then play special bonus conclusion
        [if]
            [have_unit]
                id=Nym,Zhul
                search_recall_list=yes
                count=2
            [/have_unit]

            [then]
                [store_unit]
                    [filter]
                        id=Nym
                        x,y=recall,recall
                    [/filter]
                    variable=stored_unit
                [/store_unit]

                [move_unit_fake]
                    type=$stored_unit.type
                    gender=female
                    side=1
                    x=30,31,32,32,33,34,34,35,36
                    y=38,38,38,39,40,40,41,42,42
                [/move_unit_fake]

                [unstore_unit]
                    variable=stored_unit
                    x,y=36,42
                [/unstore_unit]

                [redraw]
                [/redraw]

                [delay]
                    time=300
                [/delay]

                [message]
                    speaker=Nym
                    message= _ "Hey Kaleh, how’s the writing going?"
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "Actually I just finished."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "You’ve been working on that thing for months. I’m impressed."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "Yes, it feels good to finally be done."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "Well, your timing was perfect. Zhul is dedicating the new grove to Eloh, and you know there’ll be one heck of a celebration afterwards."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "I suppose we wouldn’t want to miss that. I wonder if they will still have any of that wine left from last year?"
                [/message]

                [message]
                    speaker=Nym
                    message= _ "We’ll just have to find out. Come on!"
                [/message]

                [redraw]
                [/redraw]

                [hide_unit]
                    id=Nym
                [/hide_unit]

                [move_unit_fake]
                    type=$stored_unit.type
                    gender=female
                    side=1
                    x=36,35,35,34,34,33,33,33,33
                    y=42,42,41,40,39,39,38,37,36
                [/move_unit_fake]

                [store_unit]
                    [filter]
                        id=Kaleh
                    [/filter]
                    variable=stored_unit
                [/store_unit]

                [hide_unit]
                    id=Kaleh
                [/hide_unit]

                [move_unit_fake]
                    type=$stored_unit.type
                    side=1
                    x=37,36,35,35,34,34,33,33,33,33,33
                    y=44,43,43,42,41,40,40,39,38,37,36
                [/move_unit_fake]

                {CLEAR_VARIABLE stored_unit}

                [delay]
                    time=1500
                [/delay]
            [/then]

            [else]
                [redraw]
                [/redraw]

                [delay]
                    time=2000
                [/delay]
            [/else]
        [/if]

        [endlevel]
            carryover_report=no
            replay_save=no
            linger_mode=no
        [/endlevel]
    [/event]
[/scenario]


#textdomain wesnoth-utbs
[race]
    id=quenoth
    help_taxonomy=elf
    male_name= _ "race^Quenoth Elf"
    female_name= _ "race+female^Quenoth Elf"
    plural_name= _ "race^Quenoth Elves"
    description= _"Compared to the elves of the Great Continent around the time of Wesnoth, the Quenoth Elves are far more suited to life in the desert."
    num_traits=2
    markov_chain_size=2
    {ELVISH_NAMES}
    {TRAIT_DEXTROUS}
[/race]
[race]
    id=hidden_race
    male_name= _ "Unknown"
    female_name= _ "Unknown"
    plural_name= _ "Unknown"
    description="src=units/unknown-unit.png~RC(magenta>red) align=left float=yes" + _ "

The race of this unit cannot be revealed yet. You must discover it in the game to be allowed to see its description."
    num_traits=2
    markov_chain_size=2
    {ELVISH_NAMES}
    {TRAIT_DEXTROUS}
[/race]

#desert elves move fast across the sands, but are not used to forests
#they are also a bit faster in caves
[movetype]
    name=quenoth_foot
    [movement_costs]
        shallow_water=3
        reef=2
        swamp_water=2
        flat=1
        sand=1
        forest=2
        hills=2
        mountains=3
        village=1
        castle=1
        cave=2
        frozen=3
        fungus=2
    [/movement_costs]
    [vision_costs]
        deep_water=3
        unwalkable=3
    [/vision_costs]
    [defense]
        shallow_water=80
        reef=70
        swamp_water=70
        flat=60
        sand=40
        forest=50
        hills=50
        mountains=40
        village=40
        castle=40
        cave=70
        frozen=70
        fungus=50
    [/defense]
    {WOODLAND_RESISTANCE}
[/movetype]

[movetype]
    name=quenoth_beast
    [movement_costs]
        shallow_water=2
        reef=2
        swamp_water=2
        flat=1
        sand=1
        forest=2
        hills=2
        mountains=3
        village=1
        castle=1
        cave=2
        frozen=2
        fungus=2
    [/movement_costs]
    [vision_costs]
        deep_water=3
        unwalkable=3
    [/vision_costs]
    [defense]
        shallow_water=70
        reef=70
        swamp_water=70
        flat=70
        sand=50
        forest=60
        hills=60
        mountains=60
        village=70
        castle=60
        cave=70
        frozen=60
        fungus=70
    [/defense]
    [resistance]
        blade=80
        pierce=100
        impact=80
        fire=90
        cold=80
        arcane=110
    [/resistance]
[/movetype]

[movetype]
    name=quenoth_horse
    [movement_costs]
        shallow_water=3
        reef=2
        swamp_water=2
        flat=1
        sand=1
        forest=2
        hills=2
        mountains=3
        village=1
        castle=1
        cave=2
        frozen=3
        fungus=2
    [/movement_costs]
    [vision_costs]
        deep_water=3
        unwalkable=3
    [/vision_costs]
    [defense]
        shallow_water=80
        reef=70
        swamp_water=70
        flat=50
        sand=50
        forest=60
        hills=50
        mountains=60
        village=50
        castle=50
        cave=70
        frozen=70
        fungus=70
    [/defense]
    {WOODLAND_RESISTANCE}
    [+resistance]
        pierce=120
    [/resistance]
[/movetype]

[movetype]
    name=quenoth_float
    flying=yes
    [movement_costs]
        deep_water={UNREACHABLE}
        shallow_water=1
        reef=1
        swamp_water=1
        flat=1
        sand=1
        forest=2
        hills=1
        mountains=2
        village=1
        castle=1
        cave=1
        unwalkable=2
        frozen=2
        fungus=2
    [/movement_costs]
    [vision_costs]
        deep_water=3
    [/vision_costs]
    [defense]
        deep_water=70
        shallow_water=60
        reef=50
        swamp_water=60
        flat=50
        sand=40
        forest=50
        hills=50
        mountains=40
        village=40
        castle=40
        cave=70
        frozen=60
        fungus=50
        unwalkable=70
    [/defense]
    {WOODLAND_RESISTANCE}
[/movetype]


#textdomain wesnoth-utbs
[unit_type]
    id=Human Commander
    name= _ "Human Commander"
    race=human
    image="units/humans/human-commander.png"
    profile="portraits/commander.png"
    {LEADING_ANIM "units/humans/human-commander.png" "units/humans/human-commander.png" 11,-21}
    {DEFENSE_ANIM "units/humans/human-commander.png" "units/humans/human-commander.png" {SOUND_LIST:HUMAN_HIT} }
    hitpoints=72
    movement_type=smallfoot
    [movement_costs]
        hills=1
        sand=1
    [/movement_costs]
    [defense]
        hills=50
        sand=40
    [/defense]
    movement=6
    experience=150
    {AMLA_DEFAULT}
    level=3
    alignment=chaotic
    advances_to=null
    cost=60
    [abilities]
        {ABILITY_LEADERSHIP}
    [/abilities]
    usage=fighter
    description= _ "In this new harsh world, might often makes right and these commanders are strong enough to rise to positions of leadership. Leading small groups of warriors, commanders rally their troops around them and show no mercy to their enemies, striking fiercely with both sword and bow."
    die_sound={SOUND_LIST:HUMAN_DIE}
    [attack]
        name=sword
        #textdomain wesnoth-units
        description= _"sword"
        type=blade
        range=melee
        damage=9
        number=4
        icon=attacks/sword-human.png
    [/attack]
    [attack]
        name=bow
        description= _"bow"
        #textdomain wesnoth-utbs
        type=pierce
        range=ranged
        damage=11
        number=3
    [/attack]
    [attack_anim]
        [filter_attack]
            name=bow
        [/filter_attack]
        missile_start_time=-150
        [missile_frame]
            duration=150
            image=projectiles/missile-n.png
            image_diagonal=projectiles/missile-ne.png
        [/missile_frame]
        start_time=-350
        [frame]
            image="units/humans/human-commander.png:500"
        [/frame]
        {SOUND:HIT_AND_MISS bow.ogg bow-miss.ogg -350}
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=sword
        [/filter_attack]
        start_time=-300
        offset=0.0~0.3,0.3~0.5,0.5~0.60,0.60~0.3,0.3~0.0
        [frame]
            image="units/humans/human-commander.png:450"
        [/frame]
        {SOUND:HIT_AND_MISS {SOUND_LIST:SWORD_SWISH} {SOUND_LIST:MISS} -100}
    [/attack_anim]
[/unit_type]


#textdomain wesnoth-utbs
# This is the Alien Central Body with his immune to attacks
[unit_type]
    id=Central Body Base
    name= _ "Central Body"
    race=monster
    image=units/alien/core-compact.png
    image_icon="units/alien/core-compact.png~SCALE(72,72)"
    [standing_anim]
        [frame]
            duration=100
            image="units/alien/core-compact.png"
            auto_hflip=no
        [/frame]
    [/standing_anim]
    hitpoints=150
    movement_type=smallfoot
    [movement_costs]
        cave={UNREACHABLE}
        flat={UNREACHABLE}
    [/movement_costs]
    [resistance]
        blade=0
        pierce=0
        impact=0
        fire=0
        cold=0
        arcane=0
    [/resistance]
    movement=7
    experience=150
    {AMLA_DEFAULT}
    level=3
    alignment=chaotic
    advances_to=null
    cost=20
    usage=fighter
    do_not_list=yes
    description= _ "This thing is impossible to describe, no one has seen anything like it before."
    {DEFENSE_ANIM_FILTERED ("units/alien/core-compact.png") ("units/alien/core-compact.png") ("wail.wav") (direction=n,ne,se,s)}
    {DEFENSE_ANIM_FILTERED ("units/alien/core-compact.png~FL(horiz)") ("units/alien/core-compact.png~FL(horiz)") ("wail.wav") (direction=nw,sw)}

    [attack]
        name=energy ray
        description= _"energy ray"
        icon=attacks/energyray.png
        type=cold
        range=melee
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage=10
        number=3
    [/attack]
    [attack]
        name=energy ray
        description= _"energy ray"
        icon=attacks/energyray.png
        type=cold
        range=ranged
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage=10
        number=3
    [/attack]
    [attack_anim]
        # NOTE: The following attack filter deliberately matches both ranged and melee.
        [filter_attack]
            name=energy ray
        [/filter_attack]
        start_time=-100
        missile_start_time=-50
        [missile_frame]
            duration=200
            image="projectiles/darkmissile-n.png"
            image_diagonal="projectiles/darkmissile-ne.png"
        [/missile_frame]
        [frame]
            image="units/alien/core-compact.png:200"
            auto_hflip=no
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -100}
    [/attack_anim]
[/unit_type]

# This is the Alien Central Body which is vulnerable to attacks
[unit_type]
    [base_unit]
        id=Central Body Base
    [/base_unit]
    id=Central Body1
    hide_help=yes
    do_not_list=yes
    [abilities]
        [regenerate]
            value=150
            id=regenerates_yec
            name= _ "alien regenerates"
            female_name= _ "female^alien regenerates"
            description= _ "The unit will heal itself 150 HP per turn. If it is poisoned, it will remove the poison instead of healing."
            affect_self=yes
            poison=cured
        [/regenerate]
    [/abilities]
[/unit_type]

# This is the Alien Central Body which is vulnerable to attacks
[unit_type]
    [base_unit]
        id=Central Body Base
    [/base_unit]
    id=Central Body2
    name= _ "Weakened Central Body"
    hitpoints={ON_DIFFICULTY 80 100 120}
    [resistance]
        blade=110
        pierce=110
        impact=80
        fire=150
        cold=150
        arcane=200
    [/resistance]

    hide_help=yes
    do_not_list=yes
    die_sound=wail-long.wav

    [attack]
        damage=4
    [/attack]
    [attack]
        damage=4
    [/attack]

    [death]
        [die_sound_frame]
            duration=600
            sound=explosion.ogg
        [/die_sound_frame]
        [die_sound_frame]
            duration=800
            sound=lich-hit-1.ogg
        [/die_sound_frame]
        [die_sound_frame]
            duration=400
            sound=explosion.ogg
        [/die_sound_frame]
        [die_sound_frame]
            duration=800
            sound=lich-hit-2.ogg
        [/die_sound_frame]
        [die_sound_frame]
            duration=900
            sound=explosion.ogg
        [/die_sound_frame]
        [die_sound_frame]
            duration=600
            sound=lich-die.ogg
        [/die_sound_frame]
        [die_sound_frame]
            duration=800
            sound=explosion.ogg
        [/die_sound_frame]

        # Creating timed explosions at POS
#define BURST_FRAME NUMBER TIME DELAY POS
    burst_{NUMBER}_start_time={TIME}
    [burst_{NUMBER}_frame]
        duration={DELAY}
        halo=halo/flame-burst-[1~8].png:50,misc/blank-hex.png:1
        halo_x,halo_y={POS}
        auto_hflip=no
        auto_vflip=no
    [/burst_{NUMBER}_frame]
    [burst_{NUMBER}_frame]
        halo=projectiles/fireball-impact-[1,1~16].png,misc/blank-hex.png:1
        halo_x,halo_y={POS}
        auto_hflip=no
        auto_vflip=no
    [/burst_{NUMBER}_frame]
#enddef

        {BURST_FRAME 1    0 1800  -9,17}
        {BURST_FRAME 2  600 1700  18,0}
        {BURST_FRAME 3 1200 1600  -9,-18}
        {BURST_FRAME 4 1800 1500   9,17}
        {BURST_FRAME 5 2400 1400   8,-18}
        {BURST_FRAME 6 3000 1300 -18,0}

#undef BURST_FRAME

        [frame]
            duration=2500
            image="units/alien/core-compact.png"
            blend_color=255,255,255
            blend_ratio=0.0~1.0
            auto_hflip=no
        [/frame]
        [frame]
            duration=2600
            image="units/alien/core-compact.png"
            blend_color=255,255,255
            blend_ratio=1.0
            alpha=1.0~0.0
            auto_hflip=no
        [/frame]
        [frame]
            duration=1
            image="misc/blank-hex.png"
        [/frame]
    [/death]
[/unit_type]


#textdomain wesnoth-utbs
[unit_type]
    id=Crawling Horror
    name= _ "Crawling Horror"
    race=monster
    image=units/alien/orb-small.png
    hitpoints=30
    movement_type=largefoot
    movement=5
    [resistance]
        blade=100
        pierce=100
        impact=90
        fire=110
        cold=90
        arcane=120
    [/resistance]
    experience=150
    {AMLA_DEFAULT}
    level=0
    alignment=chaotic
    advances_to=null
    cost=20
    usage=fighter
    do_not_list=yes
    description= _ "This thing is impossible to describe, no one has seen anything like it before."
    die_sound=wail-long.wav
    # used to be 6-2 and 4-3
    [attack]
        name=fangs
        #textdomain wesnoth-units
        description= _"fangs"
        #textdomain wesnoth-utbs
        icon=attacks/fangs-horror.png
        type=blade
        range=melee
        damage={ON_DIFFICULTY 7 9 11}
        number=2
    [/attack]
    [attack]
        name=energy ray
        description= _"energy ray"
        icon=attacks/energyray.png
        type=cold
        range=ranged
        damage={ON_DIFFICULTY 4 5 6}
        number=3
    [/attack]
    {DEFENSE_ANIM "units/alien/orb-small-defend.png" units/alien/orb-small.png wail-sml.wav }
    [attack_anim]
        [filter_attack]
            name=energy ray
        [/filter_attack]
        missile_start_time=-200
        [missile_frame]
            duration=200
            image="projectiles/darkmissile-n.png"
            image_diagonal="projectiles/darkmissile-ne.png"
        [/missile_frame]
        start_time=-300
        [frame]
            image=units/alien/orb-small-ranged[1~2].png:[100,250]
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -200}
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=fangs
        [/filter_attack]
        start_time=-200
        [frame]
            image=units/alien/orb-small-melee[1~2].png:[150,200]
        [/frame]
        {SOUND:HIT_AND_MISS bite-small.ogg {SOUND_LIST:MISS} -50}
    [/attack_anim]
[/unit_type]


#textdomain wesnoth-utbs
[unit_type]
    id=Pulsing Spire
    name= _ "Pulsing Spire"
    race=monster
    image=units/alien/spire.png
    image_icon="units/alien/spire.png~SCALE(72,72)"
    [standing_anim]
        [frame]
            duration=100
            image="units/alien/spire.png"
            auto_hflip=no
        [/frame]
    [/standing_anim]
    hitpoints={ON_DIFFICULTY 60 80 100}
    movement_type=smallfoot
    [movement_costs]
        cave={UNREACHABLE}
        flat={UNREACHABLE}
    [/movement_costs]
    [defense]
        cave=50
    [/defense]
    movement=1
    experience=150
    {AMLA_DEFAULT}
    level=0
    alignment=chaotic
    advances_to=null
    cost=20
    usage=fighter
    do_not_list=yes
    description= _ "This thing is impossible to describe, no one has seen anything like it before."
    die_sound=wail.wav
    {DEFENSE_ANIM_FILTERED ("units/alien/spire.png") ("units/alien/spire.png") ("wail-sml.wav") (direction=n,ne,se,s)}
    {DEFENSE_ANIM_FILTERED ("units/alien/spire.png~FL(horiz)") ("units/alien/spire.png~FL(horiz)") ("wail-sml.wav") (direction=nw,sw)}
    [attack]
        name=energy ray
        description= _"energy ray"
        icon=attacks/energyray.png
        type=cold
        range=ranged
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage={ON_DIFFICULTY 8 12 16}
        number=1
    [/attack]
    [attack_anim]
        [filter_attack]
            name=energy ray
        [/filter_attack]
        start_time=-100
        missile_start_time=-50
        [missile_frame]
            duration=200
            image="projectiles/darkmissile-n.png"
            image_diagonal="projectiles/darkmissile-ne.png"
        [/missile_frame]
        [frame]
            image="units/alien/spire.png:200"
            auto_hflip=no
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark.ogg magic-dark-miss.ogg -100}
    [/attack_anim]
[/unit_type]


#textdomain wesnoth-utbs

# A somewhat weaker and slower version of the Giant Spider.
# Attacks are toned down from 18-2,8-3 to 14-2, 6-3, HP from 54 to 42,
# movement from 6 to 4.

[unit_type]
    [base_unit]
        id=Giant Spider
    [/base_unit]
    id=Cave Spider
    name= _ "Cave Spider"
    hitpoints=42
    movement=4
    description= _ "Cave Spiders roam deep under the earth, devouring many victims. They can bite at close range, thereby poisoning their enemies, and also can attack with a web at long range, slowing their foes down."
    [attack]
        # change damage of the first attack (fangs)
        damage=14
    [/attack]
    [attack]
        # change damage of the second attack (web)
        damage=6
    [/attack]
[/unit_type]


#textdomain wesnoth-utbs
[unit_type]
    id=Crab Man
    name= _ "Monster Crab"
    race=monster
    image="units/monsters/crab.png"
    {DEFENSE_ANIM "units/monsters/crab-defend2.png" "units/monsters/crab-defend1.png" {SOUND_LIST:SKELETON_HIT} }
    hitpoints=29
    movement_type=swimmer
    movement=5
    experience=50
    advances_to=null
    {AMLA_DEFAULT}
    level=1
    alignment=neutral
    cost=17
    usage=fighter
    description= _ "The Monster Crab is a semi-sentient crab the size of a horse. It is one of many twisted monsters recorded by the sages of Wesnoth and probably the creation of some twisted mage. These monstrosities have spread into the wild and prefer to live around coastal waters, preying on both humans and animals."
    die_sound={SOUND_LIST:SKELETON_DIE}
    [attack]
        name=claws
        #textdomain wesnoth-units
        description= _"claws"
        #textdomain wesnoth-utbs
        icon=attacks/claws-crab.png
        type=blade
        range=melee
        damage=9
        number=2
    [/attack]
    [attack_anim]
        [filter_attack]
            name=claws
        [/filter_attack]
        start_time=-250
        offset="0:100,0~0.6:150,0.6~0:200"
        [frame]
            image=units/monsters/crab-attack[1,2,3].png:[150,70,130],units/monsters/crab.png:100
        [/frame]
        {SOUND:HIT_AND_MISS pincers.ogg {SOUND_LIST:MISS} -150}
    [/attack_anim]
[/unit_type]


#textdomain wesnoth-utbs
[unit_type]
    id=Dawarf
    name= _ "Dawarf"
    race=monster
    image="units/monsters/dawarf.png"
    {DEFENSE_ANIM "units/monsters/dawarf-growl.png" "units/monsters/dawarf.png" {SOUND_LIST:ZOMBIE_WEAK_HIT} }
    hitpoints=22
    movement_type=dwarvishfoot
    movement=4
    experience=50
    {AMLA_DEFAULT}
    advances_to=null
    level=1
    alignment=neutral
    cost=17
    usage=fighter
    # wmllint: local spelling Dawarf
    description= _ "Don’t ask where the Dawarf came from. You really don’t want to know. It is a secret well guarded by the great lore-masters of Wesnoth. And it isn’t pretty. Hint: it involves lots of sherbet."
    [attack]
        name=fist
        #textdomain wesnoth-units
        description= _"fist"
        #textdomain wesnoth-utbs
        type=impact
        range=melee
        damage=6
        number=2
    [/attack]
    [attack_anim]
        [filter_attack]
            name=fist
        [/filter_attack]
        start_time=-100
        [frame]
            image=units/monsters/dawarf-melee-[1~2].png:[100*2]
        [/frame]
        {SOUND:HIT_AND_MISS fist.ogg {SOUND_LIST:MISS} 0}
    [/attack_anim]
[/unit_type]


#textdomain wesnoth-utbs
[unit_type]
    id=Dust Devil
    name= _ "Dust Devil"
    race=monster
    {TRAIT_ELEMENTAL}
    usage=scout
    image="units/monsters/dust-devil.png"
    level=1
    advances_to=null
    experience=36
    hitpoints=36
    alignment=neutral
    cost=20
    description= _ "A swirl of dust and desert sand, quick as a wind, impossible to spot when resting and as dangerous as sand storm when riled."
    {DEFENSE_ANIM "units/monsters/dust-devil.png" "units/monsters/dust-devil.png" wose-hit.ogg }
    die_sound=groan.wav
    movement_type=undeadfly
    movement=8
    [movement_costs]
        deep_water={UNREACHABLE}
        shallow_water=3
        swamp_water=3
        cave=2
        fungus=2
        unwalkable=2
    [/movement_costs]
    [defense]
        sand=40
        cave=50
        impassable=50
    [/defense]
    [resistance]
        blade=70
        pierce=50
        impact=50
        fire=120
        cold=150
        arcane=140
    [/resistance]
    [attack]
        name=twister
        description= _ "twister"
        icon=attacks/twister.png
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=melee
        damage=5
        number=2
    [/attack]
    [attack]
        name=sand storm
        description= _ "sand storm"
        icon=attacks/sand-storm.png
        type=impact
        [specials]
            {WEAPON_SPECIAL_SWARM}
        [/specials]
        range=ranged
        damage=3
        number=7
    [/attack]
    [abilities]
        [regenerate]
            [filter_self]
                [filter_location]
                    terrain=Dd,Ds,Hd,Rb,Rd,Re
                [/filter_location]
            [/filter_self]
            value=6
            affect_self="yes"
            name = _ "dust recuperation"
            description= _ "The unit will heal itself 6 HP per turn on sand or dirt terrain."
        [/regenerate]
    [/abilities]
    [advancement]
        id=Dust1
        max_times=4
        description= _ "a stronger Dust Devil"

        # Make the XP bar blue instead of purple.
        major_amla=yes

        [effect]
            apply_to=attack
            range=melee
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            increase_total=2
            increase=2
        [/effect]
        [effect]
            apply_to=max_experience
            increase=12
        [/effect]
    [/advancement]
    [advancement]
        id=Dust2
        max_times=2
        description= _ "a taller Dust Devil"
        major_amla=yes
        [effect]
            apply_to=attack
            range=ranged
            increase_attacks=1
        [/effect]
        [effect]
            apply_to=max_experience
            increase=8
        [/effect]
    [/advancement]
    [advancement]
        id=Dust3
        max_times=100
        description= _ "a fully-healed Dust Devil"
        [effect]
            apply_to=hitpoints
            increase_total=2
            heal_full=yes
        [/effect]
    [/advancement]

    [attack_anim]
        [filter_attack]
            name=sand storm
        [/filter_attack]
        missile_start_time=-200
        [missile_frame]
            duration=320
            offset=1.0
            halo="projectiles/sand-storm-[1~8].png:40"
            auto_vflip=no
        [/missile_frame]
        {SOUND:HIT_AND_MISS magic-faeriefire.ogg magic-faeriefire-miss.ogg -200}
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=twister
        [/filter_attack]
        [frame]
            image=units/monsters/dust-devil.png:200
        [/frame]
        {SOUND:HIT_AND_MISS bite.ogg {SOUND_LIST:MISS} -100}
    [/attack_anim]
[/unit_type]


# wmllint: no translatables
[unit_type]
    [base_unit]
        id=Fire Guardian
    [/base_unit]
    id=Fire Guardian2
    hitpoints=23
    hide_help=yes
    do_not_list=yes
    [attack]
        # This attack intentionally left blank.
    [/attack]
    [attack]
        damage=8
    [/attack]
[/unit_type]


# wmllint: no translatables
[unit_type]
    [base_unit]
        id=Fire Guardian
    [/base_unit]
    id=Fire Guardian3
    hide_help=yes
    do_not_list=yes
    hitpoints=26
    movement=7
    [attack]
        damage=5
    [/attack]
    [attack]
        damage=8
    [/attack]
[/unit_type]