#textdomain wesnoth-httt

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

#
# HTTT-specific artifacts
#

#define OBJ_SWORD_FIRE X Y ID
    [event]
        name=moveto

        [filter]
            side=1
            x={X}
            y={Y}
        [/filter]

        {PLACE_IMAGE items/flame-sword.png ({X}) ({Y})}
        {VARIABLE sword_taken 0}
    [/event]
    [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
                                # wmllint: local spelling forgemasters
                                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,Elvish Lord,Elvish High Lord
                                    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]
                                #                                        [filter_attack]
                                #                                            name=flaming sword
                                #                                        [/filter_attack]
                                #
                                #                                        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"

                        [command]
                            [allow_undo]
                            [/allow_undo]
                        [/command]
                    [/option]
                [/message]
            [/then]

            [else]
                [allow_undo]
                [/allow_undo]
            [/else]
        [/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]
                                    {VARIABLE armor_taken 1}

                                    [set_variables]
                                        name=unit.modifications.trait
                                        mode=append

                                        [value]
                                            id=void_armor
                                            name= _ "void armor"
                                            description= _ "The Void Armor grants the following resistances:
blade:  50%
pierce: 40%
impact: 40%
fire:  +10%"
                                        [/value]
                                    [/set_variables]

                                    [unstore_unit]
                                        variable=unit
                                        find_vacant=no
                                    [/unstore_unit]
                                [/then]
                                #
                                # Set physical resistance to 50/40/40
                                #
                                [effect]
                                    apply_to=resistance
                                    replace=true
                                    [resistance]
                                        blade=50
                                        pierce=60
                                        impact=60
                                    [/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

################################
#
# SCEPTRE OF FIRE MACROS FOLLOW
#
################################

#define SOF_TERRAIN_MASK
    [terrain_mask]
        x,y=1,1
        mask="usage=mask
border_size=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_SCEPTRE
    [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 Sceptre was forged by the great Dwarves of the Heart Mountains. A symbol of the kingship of Wesnoth, the Sceptre has the power to shoot fireballs at enemies of the bearer!"
            cannot_use_message= _ "This is the Sceptre 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_SCEPTRE
    [event]
        same_location_as_previous=yes
        name=moveto
        [filter]
            id=Konrad
        [/filter]
        [set_variable]
            name=scepter
            value="Konrad"
        [/set_variable]
        [message]
            speaker=Konrad
            message= _ "Here it is at last, I have the Sceptre!"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "So it is in our hands! Now let us leave this stinking pit."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "I think that if we travel just a little north, we might be able to get out."
        [/message]
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
#enddef

#define LISAR_GETS_SCEPTRE
    [event]
        same_location_as_previous=yes
        name=moveto
        [filter]
            id="Li'sar"
        [/filter]
        [set_variable]
            name=scepter
            value="Li'sar"
        [/set_variable]
        [message]
            speaker="Li'sar"
            message= _ "At last! I have the Sceptre!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Indeed. You managed to reach it, Li'sar. I hope you shall use it wisely."
        [/message]
        [message]
            speaker="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]
            speaker=Delfador
            message= _ "The Sceptre makes its wielder powerful, but hardly immortal, child. Use it prudently. Now come, I believe there is an exit to the north!"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "I think I know what I'm doing. Come, let us go!"
        [/message]

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
#enddef

#define PASSAGE_NORMAL DESTINATION_NAME WIDTH_NUMBER WINDINESS_NUMBER JAGGED_NUMBER
    [passage]
        destination={DESTINATION_NAME}
        width={WIDTH_NUMBER}
        windiness={WINDINESS_NUMBER}
        jagged={JAGGED_NUMBER}
    [/passage]
#enddef

#define PASSAGE_CHANCE CHANCE_NUMBER DESTINATION_NAME WIDTH_NUMBER WINDINESS_NUMBER JAGGED_NUMBER
    [passage]
        chance={CHANCE_NUMBER}
        destination={DESTINATION_NAME}
        width={WIDTH_NUMBER}
        windiness={WINDINESS_NUMBER}
        jagged={JAGGED_NUMBER}
    [/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_name=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_name=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_name=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_name=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_name=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_name=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_name=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_name=yes
                generate_traits=yes
                ai_special=guardian
            [/unit]
        [/then]
    [/if]
    [if]
        {CHECK_VARIABLE random 8}

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

        [then]
            [unit]
                type=Drake Arbiter
                side=2
                x={X}
                y={Y}
                generate_name=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_name=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_name=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_name=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_name=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_name=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_name=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}
        [object]
            silent=yes
            [filter]
                side=3
            [/filter]
            [effect]
                apply_to=movement_costs
                replace=true
                [movement_costs]
                    swamp_water={UNREACHABLE}
                    deep_water={UNREACHABLE}
                    shallow_water={UNREACHABLE}
                    forest={UNREACHABLE}
                [/movement_costs]
            [/effect]
        [/object]
    [/unit]
#enddef
