#textdomain wesnoth-httt

################################
#
# HTTT MACROS FOLLOW
#
################################

#
# HTTT-specific artifacts
#

#define OBJ_SWORD_FIRE X Y ID
    {PLACE_IMAGE items/flame-sword.png ({X}) ({Y})}
    {VARIABLE sword_taken 0}
    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x={X}
            y={Y}
        [/filter]
        [if]
            [variable]
                name=sword_taken
                numerical_equals=0
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "Do you want this unit to pick up the sword?"
                    [option]
                        message= _ "Yes"
                        [command]
                            [object]
                                id={ID}
                                name= _ "Flaming Sword"
                                image=attacks/sword-flaming.png
                                duration=forever
                                description= _ "This massive blade was created centuries ago by long-forgotten elvish forgemasters, who imbued the bluish steel with an inner magical fire. Tongues of flame dance on the surface, giving the metal a flawless mirrored finish."
                                cannot_use_message= _ "Only the leader of an army can wield this sword!"
                                [filter]
                                    type=Fighter,Commander,Lord,Princess,Battle Princess,Elvish Captain,Elvish Hero,Elvish Marshal,Elvish Champion,Paladin
                                    x,y={X},{Y}
                                [/filter]
                                [then]
                                    [removeitem]
                                        x,y={X},{Y}
                                    [/removeitem]
                                    [message]
                                        speaker=narrator
                                        image="wesnoth-icon.png"
                                        message= _ "As you place your hand around the glittering leather hilt, the sword roars to life! Strangely, you feel no heat once you pick it up, yet the grass at your feet bursts into flame as you test the heft of this mighty weapon."
                                    [/message]
                                    {VARIABLE sword_taken 1}
                                [/then]
                                [effect]
                                    apply_to=new_attack
                                    # the name is intentionally "sword" so that the existing sword animation of the unit will be used
                                    name=sword
                                    description= _ "flaming sword"
                                    icon=attacks/sword-flaming.png
                                    type=fire
                                    range=melee
                                    [specials]
                                        {WEAPON_SPECIAL_MAGICAL}
                                    [/specials]
                                    damage=15
                                    number=4
                                [/effect]

                                # this makes sure that any existing sword attack gets removed
                                [effect]
                                    apply_to=remove_attacks
                                    range=melee
                                    type=blade
                                [/effect]

                                #                                [effect]
                                #                                    apply_to=new_animation
                                #                                    [attack_anim]
                                #                                        [attack_filter]
                                #                                            name=flaming sword
                                #                                        [/attack_filter]
                                #
                                #                                        start_time=-200
                                #
                                #                                        [if]
                                #                                            hits=yes
                                #                                            [frame]
                                #                                                duration=350
                                #                                                sound=fire.wav
                                #                                            [/frame]
                                #                                        [/if]
                                #                                        [else]
                                #                                            hits=no
                                #                                            [frame]
                                #                                                duration=350
                                #                                                sound={SOUND_LIST:MISS}
                                #                                            [/frame]
                                #                                        [/else]
                                #                                    [/attack_anim]
                                #                                [/effect]
                            [/object]
                        [/command]
                    [/option]
                    [option]
                        message= _ "No"
                    [/option]
                [/message]
            [/then]
        [/if]
    [/event]
#enddef

#define OBJ_VOID_ARMOR X Y ID
    {PLACE_IMAGE items/armor-golden.png ({X}) ({Y})}
    {VARIABLE armor_taken 0}
    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x,y={X},{Y}
        [/filter]

        [if]
            [variable]
                name=armor_taken
                numerical_equals=0
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "Do you want this unit to pick up the armor?"
                    [option]
                        message= _ "Yes"
                        [command]
                            [object]
                                id={ID}
                                name= _ "Void Armor"
                                image="icon_armor.png"
                                description= _ "A beautiful chest plate crafted from shimmering black steel, the Void Armor is virtually impenetrable to physical weapons!"
                                cannot_use_message= _ "Only a powerful warrior may don this armor!"
                                duration=forever
                                [filter]
                                    side=1
                                    x,y={X},{Y}
                                    type=Fighter,Commander,Lord,Princess,Battle Princess,Elvish Lord,Elvish High Lord,Elvish Fighter,Elvish Captain,Elvish Hero,Elvish Marshal,Elvish Champion,Elvish Ranger,Elvish Avenger,Horseman,Knight,Lancer,Paladin,Grand Knight,Dwarvish Fighter,Dwarvish Steelclad,Dwarvish Lord,Dwarvish Guardsman,Dwarvish Stalwart,Dwarvish Sentinel
                                [/filter]
                                [then]
                                    [removeitem]
                                        x,y={X},{Y}
                                    [/removeitem]
                                    [message]
                                        speaker=narrator
                                        image="wesnoth-icon.png"
                                        message= _ "You struggle to lift and don the heavy plate. Once worn, however, it is amazingly comfortable. You have increased resistance to all physical damage!"
                                    [/message]
                                    
                                    [store_unit]
                                        [filter]
                                            x,y=$x1,$y1
                                        [/filter]
                                        
                                        kill=yes
                                        variable=void_armor_taker
                                    [/store_unit]
                                    
                                    {VARIABLE armor_taken 1}

                                    {VARIABLE void_armor_trait_i $void_armor_taker.modifications.trait.length}

                                    {VARIABLE_OP void_armor_trait format "void_armor_taker.modifications.trait[$void_armor_trait_i].id"}
                                    {VARIABLE $void_armor_trait "void_armor"}

                                    {VARIABLE_OP void_armor_trait format "void_armor_taker.modifications.trait[$void_armor_trait_i].name"}
                                    {VARIABLE_OP $void_armor_trait format ( _ "void armor")}

                                    {VARIABLE_OP void_armor_trait format "void_armor_taker.modifications.trait[$void_armor_trait_i].description"}
                                    {VARIABLE_OP $void_armor_trait format ( _ "The Void Armor grants the following resistances:
blade:  50%
pierce: 50%
impact: 60%
fire:  +10%")}

                                    [unstore_unit]
                                        variable=void_armor_taker
                                        find_vacant=no
                                    [/unstore_unit]

                                    {CLEAR_VARIABLE void_armor_trait}
                                    {CLEAR_VARIABLE void_armor_trait_i}
                                    {CLEAR_VARIABLE void_armor_taker}
                                [/then]
                                #
                                # Set physical resistance to 50/40/40
                                # FIXME: they are now temporarily 50/50/60
                                # because that's what the description string
                                # claims. Should be changed back to 50/40/40
                                # when string freezes permit.
                                #
                                [effect]
                                    apply_to=resistance
                                    replace=true
                                    [resistance]
                                        blade=50
                                        pierce=50
                                        impact=40
                                    [/resistance]
                                [/effect]
                                #
                                # Increase fire resistance by 10%
                                #
                                [effect]
                                    apply_to=resistance
                                    [resistance]
                                        fire=-10
                                    [/resistance]
                                [/effect]
                            [/object]
                        [/command]
                    [/option]
                    [option]
                        message= _ "No"
                    [/option]
                [/message]
            [/then]
        [/if]
    [/event]
#enddef

################################
#
# SCEPTER OF FIRE MACROS FOLLOW
#
################################

#define SOF_TERRAIN_MASK

    [terrain_mask]
        x,y=1,1
        mask="usage=mask
border=0

_f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    Uh,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Uh,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f
    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Uh,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f
    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    Re,    _f,    _f,    Re,    Re,    Re,    Re,    Uh,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    Uh,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    Re
    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Uh,    _f,    _f,    _f,    Uh,    _f,    _f,    Uh
    _f,    _f,    Re,    _f,    Re,    Re,    Re,    _f,    Re,    Re,    Re,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    _f,    _f
    Re,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re
    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    Uh,    Re,    Re,    Re,    Re,    Re,    Re,    Uh,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f
    Uh,    Re,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Uh,    _f,    Re,    _f,    _f,    Re,    Uh,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f
    Re,    Re,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    Uh,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    Re,    Uh,    _f,    _f,    _f,    Uh,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    _f
    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Uh,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    Uh,    _f,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Uh
    Re,    _f,    Uh,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Uh,    Re,    _f,    _f,    _f,    Re,    Re
    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Uh,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f
    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    Uh,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f
    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re
    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Uh,    _f,    _f,    _f,    Uh,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    _f,    Re
    _f,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    Re
    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    Uh,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f
    Re,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Uh,    _f,    Re,    _f,    _f,    Re,    Re,    Re
    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    Re,    _f
    _f,    Re,    _f,    Re,    Uh,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Uh,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f
    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f
    _f,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Uh,    Re,    Re,    Uh,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f
    Re,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f
    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    _f
    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Uh,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Uh,    Re,    _f,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Uh,    _f,    _f,    _f
    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Uh,    _f,    Uh,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re
    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Uh,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f
    _f,    _f,    _f,    Uh,    _f,    Re,    Uh,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Uh,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    Uh,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re
    Re,    Uh,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    Re,    Re,    Uh,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re
    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Uh,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f
    _f,    Re,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    Re
    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    Re,    _f
    Re,    _f,    _f,    _f,    Uh,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f
    Uh,    _f,    Uh,    _f,    _f,    _f,    _f,    _f,    Re,    Uh,    Re,    _f,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re
    _f,    _f,    _f,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    Uh,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    Re
    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Uh,    _f,    Re,    Re,    Uh,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    Uh,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    Uh,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    _f
    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Uh,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f
    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f
    Re,    _f,    _f,    Re,    Re,    Re,    Re,    Re,    _f,    Uh,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    Uh,    _f,    Uh,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    Re
    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f
    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Uh,    _f,    _f,    _f,    Re
    _f,    Re,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    Re,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Uh,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Uh,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    _f
    Re,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f
    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    Uh,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Uh,    Re,    _f,    Re,    Re
    Re,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    Uh,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f
    Re,    _f,    Re,    Uh,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    Re,    Uh,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    _f
    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    Uh,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    _f,    Re,    Re,    _f,    Re,    Re,    Re,    Re,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re
    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Uh,    _f,    _f,    _f,    _f,    _f,    _f
    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    Re
    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Uh,    _f,    _f,    _f
    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    _f,    Re,    _f,    Re,    Uh,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    Re
    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    Uh,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    _f
    _f,    Re,    Re,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re
    Re,    _f,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Uh,    Re,    _f,    _f,    _f,    _f,    Uh,    Re,    Re,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Re,    Uh,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Uh,    _f,    Re,    _f,    Re,    Re,    _f,    _f
    _f,    _f,    _f,    _f,    Re,    Uh,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    Re,    Re,    Uh,    _f,    Re,    Re,    _f,    Re,    Uu^Uf,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Uu^Uf,    Re,    _f,    Re
    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,   Uu^Vud,    _f,    Re,    Re,    Re,    Re,    Re,    _f,    _f,    Re,    _f,    Uu^Uf,    Re,    _f,    _f,    Re,    _f,    Re,   Uu^Vud,    _f,    _f,    Uu^Uf,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Re,   Uu^Vud,    _f
    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Uu^Uf,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,   Uu^Vud,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,   Uu^Vud,    _f,    _f,    _f,    _f
    _f,    _f,    Re,    _f,   Uu^Vud,    _f,    _f,    _f,    _f,    _f,    _f,   Uu^Vud,    Re,    Re,    Re,    _f,    _f,    _f,    Re,    Re,    Re,    Uu^Uf,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Uu^Uf,    _f,    _f,    _f,    Re,    _f,    _f,    Uu^Uf,    _f,    Re,   Uu^Vud,    _f,    Re,    _f,    Re,    _f,    Re
    _f,    _f,    _f,   Uu^Vud,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    Uu^Uf,    Re,    Re,   Uu^Vud,    Re,   Uu^Vud,    _f,    _f,    _f,    _f,   Uu^Vud,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,   Uu^Vud,    _f,    _f,    _f,    _f,    Re,    Re,    _f,    Uu^Uf,    _f,    _f,    _f,    Uu^Uf,    _f,    _f,    Uu^Uf
    _f,    _f,    Re,    _f,   Uu^Vud,    Re,    Re,    _f,    Re,    Re,    _f,    Re,    _f,    _f,    Re,   Uu^Vud,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Re,   Uu^Vud,    _f,    _f,    _f,    _f,    _f,    _f,    Uu^Uf,   Uu^Vud,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    Uu^Uf,    _f,    _f,    _f
    Re,    Re,   Uu^Vud,    Re,    _f,    Re,    _f,    _f,    Re,    Re,    Re,    _f,    Re,    Re,   Uu^Vud,    Re,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,   Uu^Vud,    _f,    Re,    _f,    _f,   Uu^Vud,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    Uu^Uf,    Re
    _f,    Re,    Re,    _f,    _f,    _f,   Uu^Vud,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    Uu^Uf,    _f,    Re,    Re,    Re,   Uu^Vud,    Re,    Uu^Uf,    Re,    _f,    Re,    Re,    Re,    _f,    _f,    _f,   Uu^Vud,    _f,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,   Uu^Vud,    _f,    _f,    _f,    Re,    _f
    Uu^Uf,    Re,   Uu^Vud,    Re,    Re,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    Uu^Uf,    _f,    _f,    _f,    _f,    Re,    Uu^Uf,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,   Uu^Vud,    Re,    _f,    _f,    Re,    _f
    Re,    Re,    Re,    Re,    Re,    Re,    _f,    Re,    _f,    Uu^Uf,    _f,    _f,    _f,    _f,    _f,    Re,   Uu^Vud,    _f,    _f,   Uu^Vud,    Re,    Re,    Re,    Re,    _f,    Re,    Uu^Uf,    _f,    _f,    _f,    Uu^Uf,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,   Uu^Vud,   Uu^Vud,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f
    _f,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Uu^Uf,    _f,    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    Uu^Uf,    _f,    Re,    Re,    Re,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    Uu^Uf
    Re,    _f,    Uu^Uf,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,   Uu^Vud,   Uu^Vud,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Uu^Uf,    Re,    _f,    _f,    _f,    Re,    Re
    Re,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,   Uu^Vud,    Uu^Uf,    _f,    _f,    _f,    _f,    _f,    Uu^Uf,    _f,   Uu^Vud,    Re,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,   Uu^Vud,    Re,    _f,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f
    Re,    _f,    _f,   Uu^Vud,    _f,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,   Uu^Vud,    _f,   Uu^Vud,    _f,    _f,    Re,    Re,    Re,    _f,   Uu^Vud,    _f,    Uu^Uf,   Uu^Vud,    _f,    Re,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Uu^Uf,    _f,    _f,    _f,    _f,    _f
    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    Re,    Re,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    _f,    _f,    _f,    Re,    _f,    _f,    Re
    _f,    Re,    _f,    _f,    Re,    _f,    _f,    _f,    Re,    Re,    _f,    _f,    Re,    _f,   Uu^Vud,    _f,    Re,    Re,    _f,    _f,    _f,    Re,    _f,    Re,    _f,    _f,    _f,   Uu^Vud,    Re,    Uu^Uf,    _f,    _f,    _f,    Uu^Uf,    Re,    _f,    _f,    Re,    _f,    Re,    _f,   Uu^Vud,    Re,    _f,    Re,    Re,    Re,    Re,    _f,    Uu^Uf
"
        [rule]		# Make sure your castle is not converted
            old=Cud
            new=Re, Uu^Vud, Uh, Uu^Uf
            terrain=Cud
        [/rule]
        [rule]		# Make sure cave walls are not converted
            old=Xu
            new=Re, Uu^Vud, Uh, Uu^Uf
            terrain=Xu
        [/rule]
        [rule]		# Make sure the keep is not converted
            old=Kud
            new=Re, Uu^Vud, Uh, Uu^Uf
            terrain=Kud
        [/rule]
        [rule]		# Convert cave villages to stone villages
            old=Vu
            new=_f, Re, Uu^Vud, Uh, Uu^Uf	# wmllint: ignore
            terrain=Uu^Vud
        [/rule]
        [rule]		# Add stone villages
            old=Uu
            new=Uu^Vud
            terrain=Uu^Vud
        [/rule]
        [rule]		# Add roads
            old=Uu
            new=Re
            terrain=Re
        [/rule]
        [rule]		# Add hilly caves
            old=Uu
            new=Uh
            terrain=Uh
        [/rule]
        [rule]		# Add a mushroom forest
            old=Uu
            new=Uu^Uf
            terrain=Uu^Uf
        [/rule]
    [/terrain_mask]

#enddef

#define PLACE_SCEPTER
    [item]
        image=items/sceptre-of-fire.png
    [/item]

    [event]
        same_location_as_previous=yes
        store_location_as=scepter
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=22
            y=32
        [/filter]
        [object]
            id=object_scepter
            name= _ "Scepter of Fire"
            image=items/sceptre-of-fire.png
            duration=forever
            description= _ "This ancient Scepter was forged by the great Dwarves of the Deep Mountains. A symbol of the kingship of Wesnoth, the Scepter has the power to shoot fireballs at enemies of the bearer!"
            cannot_use_message= _ "This is the Scepter of Fire. Only a true successor to the throne can possibly dare to take this!"
            [filter]
                type=Princess,Battle Princess,Fighter,Commander,Lord
            [/filter]
            [effect]
                apply_to=variation
                name=scepter
            [/effect]
        [/object]
    [/event]
#enddef

#define KONRAD_GETS_SCEPTER
    [event]
        same_location_as_previous=yes
        name=moveto
        [filter]
            description=Konrad
        [/filter]
        [set_variable]
            name=scepter
            value="Konrad"
        [/set_variable]
        [message]
            description=Konrad
            message= _ "Here it is at last, I have the Scepter!"
        [/message]
        [message]
            description=Kalenz
            message= _ "So it is in our hands! Now let us leave this stinking pit."
        [/message]
        [message]
            description="Li'sar"
            message= _ "I think that if we travel just a little north, we might be able to get out."
        [/message]
        [endlevel]
            result=victory
        [/endlevel]
    [/event]
#enddef

#define LISAR_GETS_SCEPTER
    [event]
        same_location_as_previous=yes
        name=moveto
        [filter]
            description="Li'sar"
        [/filter]
        [set_variable]
            name=scepter
            value="Li'sar"
        [/set_variable]
        [message]
            description="Li'sar"
            message= _ "At last! I have the Scepter!"
        [/message]
        [message]
            description=Konrad
            message= _ "Indeed. You managed to reach it, Li'sar. I hope you shall use it wisely."
        [/message]
        [message]
            description="Li'sar"
            message= _ "My first use for it is going to be to help us get out of this hole! I hope you consider that wise."
        [/message]
        [message]
            description=Delfador
            message= _ "The Scepter makes its wielder powerful, but hardly immortal, child. Use it prudently. Now come, I believe there is an exit to the north!"
        [/message]
        [message]
            description="Li'sar"
            message= _ "I think I know what I'm doing. Come, let us go!"
        [/message]

        [endlevel]
            result=victory
        [/endlevel]
    [/event]
#enddef

#define PASSAGE_NORMAL DESTINATION WIDTH WINDINESS JAGGED
    [passage]
        destination={DESTINATION}
        width={WIDTH}
        windiness={WINDINESS}
        jagged={JAGGED}
    [/passage]
#enddef

#define PASSAGE_CHANCE CHANCE DESTINATION WIDTH WINDINESS JAGGED
    [passage]
        chance={CHANCE}
        destination={DESTINATION}
        width={WIDTH}
        windiness={WINDINESS}
        jagged={JAGGED}
    [/passage]
#enddef

#define ERASE_CASTLE SIDE TERRAIN
    [store_unit]
        variable=side_store
        [filter]
            side={SIDE}
            canrecruit=yes
        [/filter]
    [/store_unit]
    {VARIABLE min_x $side_store.x}
    {VARIABLE_OP min_x add -1}
    {VARIABLE min_y $side_store.y}
    {VARIABLE_OP min_y add -1}
    {VARIABLE max_x $side_store.x}
    {VARIABLE_OP max_x add 1}
    {VARIABLE max_y $side_store.y}
    {VARIABLE_OP max_y add 1}
    {VARIABLE_OP x_range format ("$min_x|-|$max_x")}
    {VARIABLE_OP y_range format ("$min_y|-|$max_y")}
    [terrain]
        x=$x_range
        y=$y_range
        terrain={TERRAIN}
    [/terrain]
#enddef

#textdomain wesnoth
#define UNDERGROUND_VOLCANO RED GREEN BLUE
    #
    # -30, -40, -40 are the default good values for an underground
    # reddish hue
    #
    [time]
        id=underground
        name= _ "Underground"
        image=misc/schedule-underground.png
        lawful_bonus=-25
        red={RED}
        green={GREEN}
        blue={BLUE}
    [/time]
#enddef

#textdomain wesnoth-httt
#define NEXT_LAVA
    [store_locations]
        variable=potential_locs
        terrain=Xu
        [filter_adjacent_location]
            terrain=U*, Re
            [filter_adjacent_location]
                terrain=U*, Re
                count=4-5
            [/filter_adjacent_location]
        [/filter_adjacent_location]
        [not]
            # don't start near the cave floor around the scepter
            x=$scepter_x
            y=$scepter_y
            radius=5
        [/not]
        [not]
            # don't start near the existing lava
            terrain=Ql
            radius=5
        [/not]
    [/store_locations]
    [if]
        [variable]
            name=potential_locs.length
            greater_than=0
        [/variable]
        [then]
            {VARIABLE lava_count 0}
            {VARIABLE randrange $potential_locs.length}
            {VARIABLE_OP randrange add -1}
            {VARIABLE randrange "0..$randrange"}
            {VARIABLE_OP random random $randrange}
            {CLEAR_VARIABLE lava_body}
            {VARIABLE lava_body.x $potential_locs[$random].x}
            {VARIABLE lava_body.y $potential_locs[$random].y}
            [terrain]
                x=$lava_body.x
                y=$lava_body.y
                terrain=Ql
            [/terrain]
            {CLEAR_VARIABLE potential_locs}
            {CLEAR_VARIABLE randrange}
        [/then]
    [/if]
#enddef

#define EXPAND_LAVA
    # the lava should expand to any cave floor that is not next to a cavewall,
    # or cave floor that is next to cavewall that is already next to lava
    # also if it comes near another lavabody, it should not expand in that direction

    # first we store cavewall that is not already next to this lava
    [store_locations]
        variable=far_walls
        terrain=Xu
        [not]
            find_in=lava_body
            radius=1
        [/not]
    [/store_locations]

    # next we store lava that is not part of this body
    [store_locations]
        variable=far_lava
        terrain=Ql
        [not]
            find_in=lava_body
        [/not]
    [/store_locations]

    # now we store cave floor nearby that doesn't approach the bad stuff
    [store_locations]
        variable=good_floor
        terrain=U*,Re
        [and]
            find_in=lava_body
            radius=1
        [/and]
        [not]
            find_in=far_walls
            radius=1
        [/not]
        [not]
            find_in=far_lava
            radius=1
        [/not]
        [not]
            # don't go anywhere near the cave floor around the scepter
            x,y=$scepter_x,$scepter_y
            radius=4
            [filter_radius]
                terrain=U*,Re
            [/filter_radius]
        [/not]
    [/store_locations]

    [if]
        [variable]
            name=good_floor.length
            greater_than=0
        [/variable]
        [then]
            {FOREACH good_floor i}
            [terrain]
                x=$good_floor[$i].x
                y=$good_floor[$i].y
                terrain=Ql
            [/terrain]
            {NEXT i}
            [store_locations]
                variable=lava_body
                find_in=lava_body
                [or]
                    find_in=good_floor
                [/or]
            [/store_locations]
        [/then]
        [else]
            # this lava can't expand so force a new eruption
            {NEXT_LAVA}
        [/else]
    [/if]
    {CLEAR_VARIABLE far_walls}
    {CLEAR_VARIABLE far_lava}
    {CLEAR_VARIABLE good_floor}

    # everyone on lava dies
    [kill]
        [not]
            type=Gryphon Rider,Gryphon Master
        [/not]
        [filter_location]
            terrain=Ql
        [/filter_location]
        animate=yes
        fire_event=yes
    [/kill]
#enddef

#define WATERFALL_MASK X Y
    [item]
        image=projectiles/icemissile-n-6.png
        x={X}
        y={Y}
    [/item]
    [item]
        image=projectiles/icemissile-n-5.png
        x={X}
        y={Y}
    [/item]
    [item]
        image=projectiles/icemissile-n-4.png
        x={X}
        y={Y}
    [/item]
    [item]
        image=projectiles/icemissile-n-3.png
        x={X}
        y={Y}
    [/item]
    [item]
        image=halo/elven/nature-halo1.png
        x={X}
        y={Y}
    [/item]
#enddef

#define CHECK_VARIABLE NAME VALUE
    [variable]
        name={NAME}
        equals={VALUE}
    [/variable]
#enddef

#define RANDOM_DRAKE X Y

#ifdef EASY

    {RANDOM 0..3}

#endif

#ifdef NORMAL

    {RANDOM 0..9}

#endif

#ifdef HARD

    {RANDOM 0..15}

#endif

    [if]
        {CHECK_VARIABLE random 0}

        [then]
            [unit]
                type=Drake Glider
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 1}

        [then]
            [unit]
                type=Drake Burner
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 2}

        [then]
            [unit]
                type=Drake Fighter
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 3}

        [then]
            [unit]
                type=Drake Clasher
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 4}

        [then]
            [unit]
                type=Sky Drake
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 5}

        [then]
            [unit]
                type=Fire Drake
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 6}

        [then]
            [unit]
                type=Drake Flare
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 7}

        [then]
            [unit]
                type=Drake Warrior
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 8}

        [then]
            [unit]
                type=Drake Gladiator
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 9}

        [then]
            [unit]
                type=Drake Slasher
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 10}

        [then]
            [unit]
                type=Hurricane Drake
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 11}

        [then]
            [unit]
                type=Inferno Drake
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 12}

        [then]
            [unit]
                type=Drake Flameheart
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 13}

        [then]
            [unit]
                type=Drake Blademaster
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 14}

        [then]
            [unit]
                type=Drake Enforcer
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 15}

        [then]
            [unit]
                type=Drake Warden
                side=2
                x={X}
                y={Y}
                generate_description=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]

    {CLEAR_VARIABLE random}

#enddef

#define UNDEAD_GUARDIAN TYPE X Y
    [unit]
        side=3
        type={TYPE}
        x={X}
        y={Y}
        [status]
            hides=yes
        [/status]
        [object]
            silent=yes
            [filter]
                side=3
            [/filter]
            [effect]
                apply_to=movement_costs
                replace=true
                [movement_costs]
                    swamp_water=99
                    deep_water=99
                    shallow_water=99
                    forest=99
                [/movement_costs]
            [/effect]
        [/object]
    [/unit]
#enddef
