#textdomain wesnoth-After_the_Storm

#define OBSIDIAN_BATTLE_AXE _X _Y
    {PICK_UP items/axe.png {_X} {_Y} (
        type=Skeleton,Deathblade,Revenant,Draug
    )
    ( _ "This axe glimmers with a powerful otherworldly aura. This seems an unusual place to find an enchanted weapon like this, but surely its previous owner doesn’t have a use for it anymore... right?")
    ( _ "A weapon like this could only possibly be used by someone well-versed in axe combat! Either that, or one of our undead minions, I suppose.")
    (
        [object]
            id=obsidian_battle_axe_$x1|_$y1
            image=attacks/battleaxe.png
            name= _ "Obsidian Battle Axe"
            description= _ "This hefty axe has been imbued with a powerful protective magic that increases the wielder’s resistances to arcane, fire, and impact damage by 30%. Using it in combat also increases all melee attack damage by 2."
            duration=forever

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

            [effect]
                apply_to=resistance
                replace=false
                [resistance]
                    arcane=-30
                    impact=-30
                    fire=-30
                [/resistance]
            [/effect]

            [effect]
                apply_to=attack
                range=melee
                increase_damage=2
                set_description= _ "obsidian battle axe"
                set_icon=attacks/battleaxe.png
            [/effect]
        [/object]
    )}
#enddef

#define FIRE_ESSENCE_E1S7 X Y
    {PICK_UP (items/potion-red.png) ({X}) ({Y}) (
        type=Elvish Wayfarer,Orcish Warrior,Orcish Warlord,Quenoth Archer,Quenoth Marksman,Skeleton,Deathblade,Revenant,Draug
    )
    ( _ "Hm, a potion vial? I’m surprised it is still intact after so many centuries. I wonder if— Wait, this is not a potion, it’s fire essence! Yes! It might not last very long, but we can at least set all these disgusting creatures ablaze!")
    ( _ "We should let this be used by one of our sword wielders. Or... perhaps even Mal Keshar’s skeleton fighters might be able to use it somehow — just a thought.")
    (
        [object]
            id=fire_essence_$x1|_$y1
            image=icons/potion-red-1.png
            duration=scenario
            name= _ "Vial of Fire Essence"
            description= _ "The fiery substance contained in this vial increases this unit’s melee damage by 1 and allows them to deal fire damage. Its power only lasts until the end of the scenario."
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=attack
                range=melee
                set_type=fire
                increase_damage=1
            [/effect]
        [/object]
    )
    ITEM_SOUND=torch.ogg}
#enddef

#define AMBER_WARD _X _Y
    {PICK_UP items/amber-necklace.png {_X} {_Y} (
        [not]
            status=not_living
        [/not]
        [not]
            race=bats,faerie
        [/not]
        [not]
            id=Elynia,Anya,Zynara
        [/not]
    )
    ( _ "This amber amulet... it is said that wearing one of these makes your skin sturdier and harder to penetrate with conventional weapons, at the cost of becoming more vulnerable to certain kinds of magic. We should choose carefully who shall have it.")
    ( _ "We might want to give the amulet to some other living creature. I reckon our spellcasters in particular have no use for this artifact.")
    (
        [object]
            id=amber_ward_$x1|_$y1
            image=icons/jewelry_necklace_amber.png
            duration=forever
            name= _ "Amber Ward"
            description= _ "This amulet increases the wearer’s resistance to physical damage (blade, impact and pierce) by 15% and decreases their arcane resistance by 10%."
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=resistance
                replace=no
                [resistance]
                    arcane=10
                    blade=-15
                    impact=-15
                    pierce=-15
                [/resistance]
            [/effect]
        [/object]
    )}
#enddef

#define BOW_OF_KRYSVELEN _X _Y
    {PICK_UP items/bow-crystal.png {_X} {_Y} (
        type=Skeleton Archer,Bone Shooter,Banebow,Poacher,Trapper,Huntsman,Ranger
    )
    ( _ "Surely this isn’t... It is! It’s the fabled bow of Krysvelen! It is said that one night in 1064 YW, an errant elf well-learned in the mystic arts chanced upon the small fishing village of Krysvelen while it was under threat by hostile orcs. The unmatched prowess of the archers manning the village’s defense caught the elf by surprise, for he had never seen humans able to surpass elvenkind’s skill with the bow and arrow. He was so impressed, after the end of the battle he used his magic to give the Krysvelenians a parting gift: an enchanted bow that imbues any arrows shot with a powerful ice magic capable of slowing down targets to a crawl.

Of course the veracity of the story has been disputed too many times to count, especially since nobody ever found any solid proof of the bow’s existence, and most accounts claim that the elf was over a thousand years old — imagine the insanity! But how on earth did the bow find its way from the Glamdrol mountain range to this region? No matter, we should just get on with it and give it to one of our most skilled archers.")
    ( _ "We really need to give this to someone who is actually able to use a bow... Even one of our undead archers should do since the magic stems from the bow itself.")
    (
        [object]
            id=bow_of_kysvelen
            image=attacks/bow-elven-magic.png
            duration=forever
            name= _ "Bow of Krysvelen"
            description= _ "Within this legendary bow lies a powerful elemental magic able to slow down targets. Rather disappointingly, it does nothing to increase the damage dealt by the unit. Its power is only active on offense."
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=attack
                range=ranged
                set_description= _ "bow of krysvelen"
                set_icon=attacks/bow-elven-magic.png
                [set_specials]
                    mode=append
                    {WEAPON_SPECIAL_SLOW}
                    [+slow]
                        active_on=offense
                    [/slow]
                [/set_specials]
            [/effect]
        [/object]
    )}
#enddef

# Technically this one can be obtained by either of two sides in the scenario
# it appears on, but since one of them is discarded later on we want to keep it
# restricted to side 1.
#define POTION_OF_BLOODLUST _X _Y
    {PICK_UP items/potion-red.png {_X} {_Y} (
        [not]
            type=Ghost,Wraith,Spectre,Shadow,Nightgaunt,Walking Corpse,Soulless,Elvish Shaman,Elvish Druid,Elvish Shyde,Necromancer,Lich,Dark Sorcerer,Dark Adept
        [/not]
        [not]
            race=bats,faerie
        [/not]
        [not]
            id=Elynia,Anya
        [/not]
    )
    ( _ "Examining the contents of this vial, it appears to be a potion of bloodlust, and there is enough to last us for weeks too! It is said that just a few drops is enough to awaken a warrior’s primal instincts and turn them into an unstoppable killing force... which naturally doesn’t come without some concerning side-effects. Are we sure we want a bloodthirsty lunatic marching to battle with us? It may be too big a risk for us given our current situation.")
    ( _ "This potion will only be useful to someone wielding a proper weapon for close combat. And no, a Necromancer’s staff does not count.")
    (
        [modify_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            [trait]
                id=bloodlust
                male_name= _ "bloodlust"
                female_name= _ "female^bloodlust"
                #textdomain wesnoth-help
                description= _ "Always rest heals"
                #textdomain wesnoth-After_the_Storm
                help_text= _ "Units with the <italic>text='bloodlust'</italic> trait are able to heal 2 hitpoints each turn regardless of whether they engaged in combat the turn before."

                [effect]
                    apply_to=healthy
                [/effect]
            [/trait]
        [/modify_unit]

        [object]
            id=bloodlust_potion_$x1|_$y1
            name= _ "Potion of Bloodlust"
            image=icons/potion-red-1.png
            duration=forever
            description= _ "This potion provides this unit with a damage increase of 1 and the berserk special for its melee attacks. Additionally, the unit receives a health increase of 15%, and its resistances are altered thus:

 • arcane: -20% resistance
 • blade: +10% resistance
 • cold: +5% resistance
 • fire: +5% resistance
 • impact: +10% resistance
 • pierce: +10% resistance"

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

            [effect]
                apply_to=attack
                range=melee
                increase_damage=1
                [set_specials]
                    mode=append
                    {WEAPON_SPECIAL_BERSERK}
                [/set_specials]
            [/effect]
            [effect]
                apply_to=hitpoints
                increase,increase_total=15%,15%
            [/effect]
            [effect]
                apply_to=resistance
                replace=no
                [resistance]
                    arcane=20
                    blade,impact,pierce=-10,-10,-10
                    cold,fire=-5,-5
                [/resistance]
            [/effect]
        [/object]
    ) ITEM_SOUND=potion.ogg}
#enddef

#define RING_OF_AGILITY _X _Y
    {PICK_UP items/ring-white.png {_X} {_Y} (
        [not]
            status=not_living
        [/not]
        [not]
            race=bats
        [/not]
        [not]
            id=Elynia,Anya
        [/not]
    )
    ( _ "This shiny silver ring has some runes engraved on it, I can barely make them out... “You who take this ring will be swifter and more graceful, no matter what weight you carry on your back.” I have a feeling it’s going to be very useful to us in the near future.")
    ( _ "Sadly, only living humans could possibly make use of this ring. And our faerie supporters as well, I suppose. Wait, do those pesky bats count as living creatures? I don’t even know.")
    (
        [object]
            id=ring_of_agility_$x1|_$y1
            name= _ "Ring of Quicksilver"
            image=icons/jewelry_ring_prismatic.png
            duration=forever
            description= _ "This ring grants its bearer swifter movement (1 extra movement point) and increased defense (by 5%) on all terrains."

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

            [effect]
                apply_to=movement
                increase=1
            [/effect]
            [effect]
                apply_to=defense
                replace=no
                [defense]
                    shallow_water=-5
                    reef=-5
                    swamp_water=-5
                    flat=-5
                    sand=-5
                    forest=-5
                    hills=-5
                    mountains=-5
                    village=-5
                    castle=-5
                    cave=-5
                    frozen=-5
                    fungus=-5
                [/defense]
            [/effect]
        [/object]

        [message]
            speaker=unit
            message= _ "Whoah... I feel fast!"
        [/message]
    )}
#enddef

#define FIRE_ESSENCE_E3S5_A _X _Y
    {PICK_UP items/potion-grey.png {_X} {_Y} ()
    ( _ "It appears to be a potion vial...") ()
    (
        [object]
            id=fire_essence_$x1|_$y1
            image=attacks/blank-attack.png
            duration=turn
            name= _ "Empty Vial"
            description= _ "It’s empty."
            [filter]
                x,y=$x1,$y1
            [/filter]
        [/object]
    )}
#enddef

#define FIRE_ESSENCE_E3S5_B _X _Y
    {PICK_UP items/potion-red.png {_X} {_Y} (
        type=Skeleton,Deathblade,Revenant,Draug,Elvish Fighter,Elvish Captain,Elvish Marshal,Elvish Hero,Elvish Champion,Footpad,Outlaw,Fugitive,Thug,Bandit,Highwayman
    )
    ( _ "This small vial seems to still have essence left in it...")
    ( _ "We should let this be used by someone who excels at fighting in close quarters.")
    (
        [object]
            id=fire_essence_$x1|_$y1
            image=icons/potion_red_small.png
            duration=forever
            name= _ "Vial of Shardia’s Tears"
            description= _ "This vial contains a purer form of fire essence that seemingly lasts forever. The damage dealt by the unit in melee combat is increased by 1 and its type is set to fire. The unit’s fire resistance is increased by 10% and its cold resistance decreased by 5%."
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=attack
                range=melee
                set_type=fire
                increase_damage=1
            [/effect]
            [effect]
                apply_to=resistance
                replace=no
                [resistance]
                    fire=-10
                    cold=5
                [/resistance]
            [/effect]
        [/object]
    )
    ITEM_SOUND=melee-fire.ogg}
#enddef

# Exclude the arcane resistance reduction from this so as not to make the
# original owner in E3S5 weaker than he already is.
#define EFFECTS_STAFF_OF_AKHYLS_COMMON
    [effect]
        apply_to=attack
        range=melee
        [or]
            range=ranged
            type=arcane
        [/or]
        [set_specials]
            mode=append
            {WEAPON_SPECIAL_POISON}
        [/set_specials]
    [/effect]
    [effect]
        apply_to=attack
        range=melee
        set_description= _ "staff of akhlys"
        set_icon=attacks/staff-green.png
    [/effect]
#enddef

# NOTE: Do not use PICK_UP for this.
#define STAFF_OF_AKHLYS _X _Y
    {PLACE_IMAGE items/staff.png {_X} {_Y}}

    [event]
        id=staff_of_akhlys_aux
        name=moveto
        delayed_variable_substitution=no
        [filter]
            side=1
            [not]
                id=Irylean
            [/not]
            x={_X}
            y={_Y}
        [/filter]

        [message]
            speaker=unit
            {UNIT_SPEAKS_FOR_UNDEAD_MINION id=Anya}
            scroll=no
            message= _ "So the lich was carrying this staff... Ugh, it’s all covered in filth and dry rotten flesh. How about we let Irylean take a look at it instead?"
        [/message]
    [/event]

    [event]
        name=moveto
        delayed_variable_substitution=no
        [filter]
            id=Irylean
            x={_X}
            y={_Y}
        [/filter]

        [message]
            speaker=Irylean
            message= _ "The lich must have been using the power of this staff to cast poison on us. I have a feeling I am the only one who is willing to experiment with it, so... I may as well just grab it, don’t you think?"
        [/message]

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

        [harm_unit]
            [filter]
                id=Irylean
            [/filter]
            kill=no
            amount=1
            animate=yes
            poisoned=yes
        [/harm_unit]

        [object]
            id=staff_of_akhlys
            image=attacks/staff-green.png
            duration=forever
            name= _ "Staff of Akhlys"
            description= _ "This ornate staff of unknown origin gives off a sickly aura that even cave creatures avoid. The wielder’s arcane resistance is decreased by 10% and her melee attack and arcane magic inflict the poison effect on targets.

It is a good thing that undead wielders are immune to the staff’s aura."
            [filter]
                id=Irylean
            [/filter]

            [effect]
                apply_to=resistance
                replace=no
                [resistance]
                    arcane=10
                [/resistance]
            [/effect]

            {EFFECTS_STAFF_OF_AKHYLS_COMMON}
        [/object]

        [message]
            speaker=Irylean
            message= _ "Ugh... I feel... very much unwell now... Hopefully it will pass after a while. You know, this is one of those times I feel that perhaps it’s time for me to have a proper look into the whole lichdom business — it may save me a lot of trouble in the long run."
        [/message]

        [message]
            speaker=Elynia
            message= _ "In order to make my life just a bit easier I am going to pretend you have the situation under control and that you aren’t being affected by the power of your new toy at all."
        [/message]

        [message]
            speaker=Irylean
            message= _ "I will be all right, I just... need a few minutes while I throw up in the corner over there."
        [/message]

        [remove_event]
            id=staff_of_akhlys_aux
        [/remove_event]
    [/event]
#enddef

# This is not so much an item but rather an ability that a special unit has.
#define XIAELS_BLESSING
    [object]
        id=xiaels_blessing
        name= _ "Xia’el’s Blessing"
        image=attacks/faerie-fire.png
        description= _ "This unit is able to bestow upon all faeries on its side the kindled trait, which lets them ignore time of day penalties, increases their hitpoints by 15%, and their resistances to non-arcane damage by 5%. While the trait itself is permanent, new recruits will no longer receive the trait if you lose Daeira."
        duration=forever

        [filter]
            id=Daeira
        [/filter]

        [effect]
            apply_to=new_ability
            [abilities]
                # This ability is defined as a visual aid only. The actual
                # implementation depends on Daeira's presence and not on anyone
                # having the ability.
                [dummy]
                    id=xiaels_blessing
                    name= _ "xia’el’s blessing"
                    description= _ "This unit is able to grant all faeries on its side the kindled trait, which lets them ignore time of day penalties, increases their hitpoints by 15%, and their resistances to non-arcane damage by 5%."
                [/dummy]
            [/abilities]
        [/effect]
    [/object]

    {ATTACH_EVENTS_TO_UNIT id=Daeira ({LIGHT_OF_XIAEL:EVENTS})}
#enddef

#define LIGHT_OF_XIAEL:EVENTS
    [event]
        id=light_of_xiael:prerecruit
        name=prerecruit
        first_time_only=no
        [filter]
            side=1
            race=faerie
            [not]
                id=Elynia,Anya,Daeira
                [or]
                    [filter_wml]
                        [variables]
                            has_light_of_xiael=yes
                        [/variables]
                    [/filter_wml]
                [/or]
            [/not]
        [/filter]

        {LIGHT_OF_XIAEL:APPLY_TO_SINGULAR_UNIT id=$unit.id}
    [/event]
#enddef

#define LIGHT_OF_XIAEL:APPLY_TO_ALL
    [store_unit]
        [filter]
            side=1
            race=faerie
            [not]
                id=Elynia,Anya,Daeira
                [or]
                    [filter_wml]
                        [variables]
                            has_light_of_xiael=yes
                        [/variables]
                    [/filter_wml]
                [/or]
            [/not]
        [/filter]
        kill=no
        variable=faeries_store
    [/store_unit]

    [foreach]
        array=faeries_store
        variable=faerie
        [do]
            {VARIABLE faerie.variables.has_light_of_xiael yes}

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

            # This uses [modify_unit] so it must be done after deserializing
            # the unit.
            {LIGHT_OF_XIAEL:APPLY_TO_SINGULAR_UNIT id=$faerie.id}
        [/do]
    [/foreach]

    {CLEAR_VARIABLE faeries_store}
#enddef

#define LIGHT_OF_XIAEL:TRAIT_KINDLED
    [trait]
        id=kindled
        male_name= _ "kindled"
        female_name= _ "female^kindled"
        description= _ "Ignores time of day penalties and has increased physical attributes"
        help_text=_ "Units with this trait ignore time of day penalties, have their hitpoints increased by 15%, and their resistance to non-arcane damage is increased by 5%."

        [effect]
            apply_to=fearless
        [/effect]

        [effect]
            apply_to=hitpoints
            increase,increase_total=15%,15%
        [/effect]

        [effect]
            apply_to=resistance
            replace=no
            [resistance]
                blade=-5
                fire=-5
                cold=-5
                impact=-5
                pierce=-5
            [/resistance]
        [/effect]
    [/trait]
#enddef

#define LIGHT_OF_XIAEL:APPLY_TO_SINGULAR_UNIT _SUF
    [modify_unit]
        [filter]
            {_SUF}
        [/filter]

        {LIGHT_OF_XIAEL:TRAIT_KINDLED}
    [/modify_unit]
#enddef


#textdomain wesnoth-After_the_Storm

#define OBJECTIVE_BONUS _TEXT
    [objective]
        {BONUS_OBJECTIVE_CAPTION}
        description={_TEXT} # wmllint: ignore
        condition=win
    [/objective]
#enddef

#define ZYNARA_UNDEAD_RECRUITMENT_NOTES
    {OBJECTIVE_NOTE ( _ "Zynara is only able to control a limited number of Ghost line units per scenario")}
    {OBJECTIVE_NOTE ( _ "If you attempt to recruit an additional Ghost, you will permanently lose control of a random Ghost line unit and become unable to recruit—but not recall—more for the remainder of the scenario")}
    {OBJECTIVE_NOTE ( _ "Ghost line units in your recall list also count towards the limit")}
#enddef

#define UNLIMITED_PLAYER_MOVES_NOTE
    {OBJECTIVE_NOTE ( _ "You cannot end your turn; however, you can move your units around freely, ignoring their maximum movement points")}
#enddef

#define UNLIMITED_LEADER_MOVES_NOTE
    {OBJECTIVE_NOTE ( _ "You cannot end your turn; however, you can move your leader unit around freely, ignoring its maximum movement points")}
#enddef

#define CONVERSATION_SCENARIO_NOTES
    {OBJECTIVE_NOTE ( _ "Move units next to other units or objects of interest to trigger actions")}
#enddef

#define LIMITED_CHARACTER_MOVES_NOTE
    {OBJECTIVE_NOTE ( _ "A bind spell disallows Elynia from moving when she is not within Elyssa's maximum movement range")}
    {OBJECTIVE_NOTE ( _ "You will need to synchronize both characters’ movements to prevent Elynia from lagging behind")}
#enddef

#define FIRE_GUARDIAN_SUMMONING_NOTE
    # po: The Fire Wraith unit type name translation may be found in the
    # po: wesnoth-units textdomain in mainline.
    {OBJECTIVE_NOTE ( _ "Fire Wraiths can be summoned by right clicking on a vacant hex adjacent to Elyssa")}
    {OBJECTIVE_NOTE ( _ "You may only have six Fire Wraiths on the map at any given time")}
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm
#
# This file is dedicated to implementation details of the segmented
# scenario mechanism employed throughout AtS E3.
#
# If you are looking for public macros for use in your scenario,
# see scenario-segment-utils.cfg instead.
#
# You can stop reading past this point.
#

#
# floor_config.floor[] structure:
#
# map_data          <attribute>   The terrain map data for the floor.
#
# music_playlist    <node>        Music playlist for the floor, containing
#                                  an optional array of [music] nodes.
#                                  Music is left untouched for floors
#                                  lacking their own playlist.
#
# schedule          <node>        ToD schedule for the floor, containing
#                                  an optional array of [time] nodes.
#                                  The schedule is reset to the _initial_
#                                  ToD as detected on prestart when not
#                                  specified.
#
# default_time      <node>        Fallback ToD schedule corresponding to
#                                  to the current ToD detected during
#                                  prestart. This is TimeWML without an
#                                  enclosing [time] node.
#

#define FLOOR_VARIABLES_CONFIGURATION
    [event]
        name=prestart
        [set_variables]
            name=floor_config
            mode=replace
            [value]
                current=0
            [/value]
        [/set_variables]

        [store_time_of_day]
            variable=floor_config.default_time
        [/store_time_of_day]
    [/event]

    [event]
        id=floor_controller_victory_cleanup
        name=victory

        {CLEAR_VARIABLE floor_config}
    [/event]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm
#
# Macros controlling the segmented scenario mechanism employed
# throughout AtS E3.
#
# The SEGMENTED_SCENARIO macro is one of the cornerstones of this mechanism.
# It is expected to be substituted early in the scenario file, before any
# custom events. Use ADD_SEGMENT to add configurations for each floor.
#
# Scenarios using this mechanisms should provide no initial map data, and
# they should also take care of placing any necessary leaders on the map
# by hand (see below for information about custom events).
#
# The ON_FLOOR macro provides a convenient way to switch floors including
# a minimal amount of code each time. You *must* use this macro in your own
# prestart event to update the gamestate according to your desired initial
# floor.
#
# Events that can only take place when on a given floor can be defined with
# the auxiliary ON_FLOOR macro, which sets or adds a [filter_condition]
# requirement so the event only triggers on that floor.
#
# It is possible to hook into the floors mechanism via specific custom
# event handlers, that will be invoked as appropriate when entering or
# leaving floors, according to any first_time_only limitations for those
# handlers.
#
# The custom events emitted are:
#
#   * "enter floor $n": Takes place right after entering the floor $n
#     (after the floor switch code is executed and "setup floor $n"
#     emitted). If $n is not provided, the handler will run for *any*
#     floor before any floor-specific handlers. At this point, the
#     $floor_config.current variable reflects the *new* floor number.
#
#   * "leave floor $n": Takes place right before leaving the floor $n
#     (before the floor switch code is executed and "setup floor $n"
#     emitted). If $n is not provided, the handler will run for *any*
#     floor before any floor-specific handlers. At this point, the
#     $floor_config.current variable reflects the *old* floor number.
#
#   * "setup floor $n": Takes place during the configuration of the
#     given floor $n, after most of the floor switch code is executed.
#     If $n is not provided, the handler will run for *any*  floor
#     before any floor-specific handlers. At this point, the
#     $floor_config.current variable reflects the *new* floor number.
#
# Generally, only the $floor_config.current variable should be accessed
# by your own scenario code, and it should be treated as a *constant*.
#
# During victory events, $floor_config (and thus $floor_config.current)
# ceases to exist unless you use the PRESERVE_FLOOR_CONFIGURATION_ON_VICTORY
# macro before.
#
# When switching floors, all items and units previously on-map (except
# side 1 units) are destroyed without emitting events for them. You might
# want to use the "leave floor" events to take care of tracking any
# units that might remain on-map when this happens. Shroud, fog, and terrain
# changes aren't tracked or handled by this implementation either.
#

##
# Accompanies the definition of an event that's only fired when the player
# is on a specific floor. This should go _after_ or instead of any other
# [filter_condition] nodes for the event definition.
#
# Arguments:
#
#   _NUM                   The required floor number.
#
##
#define ON_FLOOR _NUM
    [+filter_condition]
        {VARIABLE_NUMERICAL_EQUALS floor_config.current {_NUM} }
    [/filter_condition]
#enddef

##
# This is the main macro including the code blocks configuring the scenario
# floors and such. It should go near the top of the scenario. You should not
# specify your own initial map data.
##
#define SEGMENTED_SCENARIO
    {NO_MAP_DATA}

    {FLOOR_VARIABLES_CONFIGURATION}
#enddef

##
# Defines a new floor. Floors are automatically numbered
# in a sequence as they are added, starting from 1. At least
# one floor is needed for the scenario to work properly, and
# there must be a prestart event using the SWITCH_FLOOR macro
# to select the initial floor as well.
#
# Arguments:
#
#   _MAP_DATA              The terrain map data.
#
#   _SCHEDULE_TIME_WML     The ToD schedule ([time] nodes) for
#                           this floor. If empty, the ToD detected
#                           on prestart for the first turn will be
#                           used instead.
#
#   _PLAYLIST_MUSIC_WML    The playlist WML ([music] nodes) for
#                           this floor. If empty, music is left
#                           unchanged each time the player enters
#                           the floor.
#
##
#define ADD_SEGMENT _MAP_DATA _SCHEDULE_TIME_WML _PLAYLIST_MUSIC_WML
    [event]
        name=prestart

        [set_variables]
            name=floor_config.floor
            mode=append
            [value]
                map_data={_MAP_DATA}
                [schedule]
                    {_SCHEDULE_TIME_WML}
                [/schedule]
                [music_playlist]
                    {_PLAYLIST_MUSIC_WML}
                [/music_playlist]
            [/value]
        [/set_variables]
    [/event]
#enddef

##
# Disables the automatic destruction of the $floor_config container
# on victory, making the regular victory event (or subsequent scenarios)
# responsible for its cleanup.
#
# This is provided merely as a convenience to retrieve $floor_config.current
# during victory. Its use is not recommended.
##
#define PRESERVE_FLOOR_CONFIGURATION_ON_VICTORY
    [remove_event]
        id=floor_controller_victory_cleanup # wmllint: ignore
    [/remove_event]
#enddef

##
# This is the trigger used for switching between floors.
#
# Arguments:
#
#   _NUM                   The new floor number.
#
##
#define SWITCH_FLOOR _NUM
    [change_floor]
        floor_number={_NUM}
    [/change_floor]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define AMLA_MENU_HINT:BASE _TEXT
    [event]
        id=amla_menu_hint
        name=turn 2

        [scroll_to_unit]
            side=1
            canrecruit=yes
        [/scroll_to_unit]

        [transient_message]
            image=icons/book.png
            message={_TEXT}
        [/transient_message]
    [/event]
#enddef

#define NO_END_CREDITS
    [+endlevel]
        end_credits=no
    [/endlevel]
#enddef

#define NO_END_TEXT
    [+endlevel]
        end_text=" " # wmllint: ignore
        # NOTE: end_text_duration cannot be zero; that causes the engine
        # to fallback to 3500 milliseconds.
        end_text_duration=1
    [/endlevel]
#enddef

#define NO_ENDLEVEL_MUSIC
    [+endlevel]
        music=silence.ogg
    [/endlevel]
#enddef

#define UNLIMITED_PLAYER_MOVES
    [event]
        id=UNLIMITED_PLAYER_MOVES_impl
        name=moveto
        first_time_only=no
        [filter]
            side=1
        [/filter]

        {VARIABLE unit.moves $unit.max_moves}

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

        [allow_undo][/allow_undo]
    [/event]
#enddef

#define DISABLE_UNLIMITED_PLAYER_MOVES
    [remove_event]
        id=UNLIMITED_PLAYER_MOVES_impl # wmllint: ignore
    [/remove_event]
#enddef

#define NO_RECRUITS_OR_RECALLS _EXTRA_CONDITION
    #
    # NOTE: Wesnoth 1.11.1 and later only seem to deduct gold once
    # the unit has passed prerecruit/prerecall without being deleted
    # from the gamemap.
    #

    [event]
        name=prerecruit
        first_time_only=no
        [filter]
            side=1
        [/filter]
        [filter_condition]
            {_EXTRA_CONDITION}
        [/filter_condition]

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

        [fire_event]
            name=ui_handler_NO_RECRUITS_OR_RECALLS
        [/fire_event]
    [/event]

    [event]
        name=prerecall
        first_time_only=no
        [filter]
            side=1
        [/filter]
        [filter_condition]
            {_EXTRA_CONDITION}
        [/filter_condition]

        {PUT_TO_RECALL_LIST (x,y=$x1,$y1)}

        [fire_event]
            name=ui_handler_NO_RECRUITS_OR_RECALLS
        [/fire_event]
    [/event]

    [event]
        id=ui_handler_NO_RECRUITS_OR_RECALLS
        name=ui_handler_NO_RECRUITS_OR_RECALLS
        first_time_only=no
        [transient_message]
            message= _ "You cannot recruit or recall units at this time!"
        [/transient_message]
    [/event]
#enddef

#define SET_TALK_UNITS _SUF
    [store_unit]
        [filter]
            [not]
                {_SUF}
            [/not]
            [filter_wml]
                [variables]
                    can_talk=yes
                [/variables]
            [/filter_wml]
        [/filter]
        variable=temp_SET_TALK_UNITS_store
    [/store_unit]

    [foreach]
        array=temp_SET_TALK_UNITS_store
        [do]
            {CLEAR_VARIABLE this_item.variables.can_talk}

            [unstore_unit]
                variable=this_item
                find_vacant=no
            [/unstore_unit]
        [/do]
    [/foreach]

    [store_unit]
        [filter]
            {_SUF}
        [/filter]
        variable=temp_SET_TALK_UNITS_store
    [/store_unit]

    [foreach]
        array=temp_SET_TALK_UNITS_store
        [do]
            {VARIABLE this_item.variables.can_talk yes}

            [unstore_unit]
                variable=this_item
                find_vacant=no
            [/unstore_unit]
        [/do]
    [/foreach]

    {CLEAR_VARIABLE temp_SET_TALK_UNITS_store}
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define GLOBAL_LIGHTING_BAD_DAWN
    {SCHEDULE_LIGHTING 0 -30 -30}
#enddef

#define GLOBAL_LIGHTING_BAD_MORNING
    {SCHEDULE_LIGHTING 5 -20 20}
#enddef

#define GLOBAL_LIGHTING_BAD_DAY
    {SCHEDULE_LIGHTING 10 -15 40}
#enddef

#define GLOBAL_LIGHTING_BAD_DUSK
    {SCHEDULE_LIGHTING 0 -30 20}
#enddef

#define GLOBAL_LIGHTING_BAD_NIGHT_SHORT
    {SCHEDULE_LIGHTING -60 -50 0}
#enddef

#define GLOBAL_LIGHTING_BAD_NIGHT
    {SCHEDULE_LIGHTING -70 -60 0}
#enddef


#textdomain wesnoth-After_the_Storm

# FIXME: are these values correct?
#define DEFAULT_ECONOMY
    village_gold=1
    income=0
#enddef

#define TRANSFER_UNITS_FROM_SIDE _SRC_SIDE _FILTER _DST_SIDE
    [modify_unit]
        [filter]
            side={_SRC_SIDE}
            {_FILTER}
        [/filter]

        side={_DST_SIDE}

        [variables]
            transferred_from_side={_SRC_SIDE}
        [/variables]
    [/modify_unit]
#enddef

#define RECALL_SIDE_LOYALS _SIDE _LIMIT
    [store_unit_ids]
        [filter]
            side={_SIDE}
            canrecruit=no
            x,y=recall,recall
            [filter_wml]
                [not]
                    upkeep=full
                [/not]
            [/filter_wml]
        [/filter]
        variable=temp_RECALL_SIDE_LOYALS_ids
    [/store_unit_ids]

    {VARIABLE temp_RECALL_SIDE_LOYALS_limit ({_LIMIT})}

    #
    # The limit defaults to "unlimited" (see below) when _LIMIT is
    # the empty string.
    #

    [if]
        {VARIABLE_NUMERICAL_EQUALS temp_RECALL_SIDE_LOYALS_limit 0}
        [then]
            # NOTE: the number used here is meant to be greater than or equal
            # to game_config::max_loop!
            {VARIABLE temp_RECALL_SIDE_LOYALS_limit 99999}
        [/then]
    [/if]

    [while]
        {VARIABLE_NUMERICAL_GREATER_THAN temp_RECALL_SIDE_LOYALS_limit 0}
        {VARIABLE_NUMERICAL_GREATER_THAN temp_RECALL_SIDE_LOYALS_ids.length 0}
        [do]
            [recall]
                id=$temp_RECALL_SIDE_LOYALS_ids[0].id
            [/recall]

            {CLEAR_VARIABLE temp_RECALL_SIDE_LOYALS_ids[0]}

            {VARIABLE_DEC temp_RECALL_SIDE_LOYALS_limit}
        [/do]
    [/while]

    {CLEAR_VARIABLE temp_RECALL_SIDE_LOYALS_ids,temp_RECALL_SIDE_LOYALS_limit}
#enddef

#define RECALL_SIDE_UNITS_AT _SIDE _SUF _X _Y
    [store_unit]
        [filter]
            side={_SIDE}
            canrecruit=no
            x,y=recall,recall
            [and]
                {_SUF}
            [/and]
        [/filter]
        variable=temp_RSUA_units
        kill=no
    [/store_unit]

    [foreach]
        array=temp_RSUA_units
        variable=temp_RSUA_unit
        [do]
            [recall]
                id=$temp_RSUA_unit.id
                x={_X}
                y={_Y}
                show=no
            [/recall]
        [/do]
    [/foreach]

    {CLEAR_VARIABLE temp_RSUA_units}
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define HIVE_NOISE_1_SOUND_SOURCE
    {BACKGROUND_SOUND_SOURCE_GENERIC __ss_hive_noise_1_all ambient/dark-1.ogg}
#enddef

#define HIVE_NOISE_3_SOUND_SOURCE
    {BACKGROUND_SOUND_SOURCE_GENERIC __ss_hive_noise_3_all ambient/dark-3.ogg}
#enddef

#define SOUND_LIST:EXPLOSION
explosion-big.ogg,explosion.ogg #enddef

#define SOUND_LIST:COLLAPSING_FACILITY
rumble.ogg,cave-in.ogg,explosion-big.ogg,explosion.ogg,thunder1.wav,thunder2.wav,thunder3.wav #enddef

#define SOUND_LIST:BIRDS
ambient/birds[1~3].ogg #enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

# wmlindent: start ignoring

#define SPECIAL_NOTE_ABSORB_DAMAGE
    _ "This unit will not take any damage from attacks." #enddef

#define SPECIAL_NOTE_DEMOLITION
    _ "On death, this unit destroys all adjacent hexes and units, and the hex they are standing on." #enddef

#define SPECIAL_NOTE_PHYSICAL_ENDURANCE
    _ "This unit will instantly regenerate half of the damage deal on it with non-arcane attacks, unless it would otherwise kill it." #enddef

#define SPECIAL_NOTE_STUN
    _ "This unit is able to disrupt its opponent’s zone of control with a powerful attack, only available during offense." #enddef

#define SPECIAL_NOTE_AQUEOUS
    _ "This unit benefits from defending on water terrains in various ways." #enddef

#define SPECIAL_NOTE_ABSCOND
    _ "This unit is able to escape certain death once every other turn." #enddef

#define SPECIAL_NOTE_SEISMIC
    _ "This unit is able to deal area-of-effect damage to units once every turn, with a chance of stunning and slowing them as well." #enddef

# wmlindent: stop ignoring

#
# UtBS abilities
#

#textdomain wesnoth-utbs

#define SPECIAL_NOTE_SHOCK
_"This unit’s melee attack can overwhelm the defenses of enemies, preventing them from retaliating as effectively."#enddef

#define SPECIAL_NOTE_FORMATION
_"Groups of units of this type are able to shield each other in combat."#enddef

#define SPECIAL_NOTE_DISENGAGE
_"This unit can move either before or after attacking."#enddef

#define SPECIAL_NOTE_DAZE
_"This unit can daze its enemies, reducing their accuracy and defense until they end a turn."#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define ANIMATED_FOUNTAIN _X _Y
    [terrain_graphics]
        x={_X}
        y={_Y}
        [tile]
            x=0
            y=0
            [image]
                layer=0
                name="../scenery/fountain-[01~13].png:100"
            [/image]
        [/tile]
    [/terrain_graphics]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define UNIT_TO_GLOBAL_STORE _ID _STORE_ID
    [store_unit]
        [filter]
            id={_ID}
        [/filter]
        variable=persist_store
        kill=no
        mode=replace
    [/store_unit]

    {WRITE_VARIABLE_INTO_GLOBAL persist_store {_STORE_ID} NAMESPACE={PERSISTENT_NS_ATS}}

    {CLEAR_VARIABLE persist_store}
#enddef

#define UNIT_FROM_GLOBAL_STORE _STORE_ID
    {READ_GLOBAL_INTO_VARIABLE ({_STORE_ID}) ({_STORE_ID}) NAMESPACE={PERSISTENT_NS_ATS}}
#enddef

#
# Incorporates unit stats from a globally-stored version of the unit into the
# live (on-map) version.
#
# NOTE: This should only be used during prestart and never during regular
#       gameplay events as it also resets the unit's combat stats.
#
#define UPDATE_UNIT_FROM_GLOBAL_STORE _ID _STORE_ID
    {READ_GLOBAL_INTO_VARIABLE ({_STORE_ID}) persist_store NAMESPACE={PERSISTENT_NS_ATS}}

    [if]
        {VARIABLE_ARRAY_NOT_EMPTY persist_store}
        [then]
            {LOG_ATS "Updating "+{_ID}+" from global store"}

            # Verify that the live unit's type matches the stored version.
            # Otherwise force a clean-slate rebuild into the stored unit
            # type.
            [if]
                [have_unit]
                    id={_ID}
                    type=$persist_store.type
                [/have_unit]
                [else]
                    {LOG_ATS "Rebuilding unit for "+{_ID}+" to new unit type '$persist_store.type'"}

                    {TRANSFORM_UNIT (id={_ID}) $persist_store.type}
                [/else]
            [/if]

            # Reapply AMLAs as needed.
            [if]
                {VARIABLE_ARRAY_NOT_EMPTY persist_store.modifications.advancement}
                [then]
                    {LOG_ATS "Applying $persist_store.modifications.advancement.length stored AMLAs to "+{_ID}}

                    [apply_amlas]
                        id={_ID}
                        [insert_tag]
                            name="advancement"
                            variable="persist_store.modifications.advancement"
                        [/insert_tag]
                    [/apply_amlas]
                [/then]
            [/if]

            # Reapply objects that have a description (so we can safely assume
            # they are not objects used for internal purposes).
            [if]
                {VARIABLE_ARRAY_NOT_EMPTY persist_store.modifications.object}
                [then]
                    {LOG_ATS "Applying $persist_store.modifications.object.length stored [object]s to "+{_ID}}

                    [apply_objects]
                        id={_ID}
                        [insert_tag]
                            name="object"
                            variable="persist_store.modifications.object"
                        [/insert_tag]
                    [/apply_objects]
                [/then]
            [/if]

            # Reset combat stats and record its old XP ratio for usage by AMLA_XP_CAP.
            [modify_unit]
                [filter]
                    id={_ID}
                [/filter]
                moves=$persist_store.max_moves
                attacks_left=$persist_store.max_attacks
                [variables]
                    amla_xp_cap_old_ratio="$(1.0*$persist_store.experience / $persist_store.max_experience)"
                [/variables]
            [/modify_unit]

            {LOG_ATS "Unit update from global store finished"}
        [/then]
    [/if]

    {CLEAR_VARIABLE persist_store}
#enddef

#define INJURED_VARIATION_STATS
    hitpoints=1
    max_hitpoints=1
    experience=0
    max_experience=0
    moves=0
    max_attacks=0
    attacks_left=0
#enddef

#define APPLY_INJURED_VARIATION _SUF _FACING
    [object]
        [filter]
            {_SUF}
        [/filter]
        [effect]
            apply_to=variation
            name=injured
        [/effect]
        silent=yes
    [/object]

    [modify_unit]
        [filter]
            {_SUF}
        [/filter]
        {INJURED_VARIATION_STATS}
        facing={_FACING}
        [status]
            slowed=no
            poisoned=no
            petrified=no
            unhealable=no
        [/status]
    [/modify_unit]
#enddef

# Needed in scenario events for E2S4
#define UNDEAD_RECRUITMENT:ZYNARA:LIMIT
{DIFF 8 6 4} #enddef

#define UNDEAD_RECRUITMENT:ZYNARA:WILD_GHOSTS_SIDE _SIDE_NUM
    [event]
        name=prestart

        # NOTE: The variable name is hardcoded in the implementation of the
        #       [player_ghost_trap] WML action.
        {VARIABLE wild_ghosts_side {_SIDE_NUM}}
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE wild_ghosts_side}
    [/event]
#enddef

#define UNDEAD_RECRUITMENT:ZYNARA
    [event]
        id=ur_zynara_precruit
        name=prerecruit
        first_time_only=no
        [filter]
            side=1
            type=Ghost,Wraith,Spectre,Shadow,Nightgaunt
        [/filter]
        [filter_condition]
            [have_unit]
                id=Zynara
                side=1
            [/have_unit]
        [/filter_condition]

        {VARIABLE player_ghost_limit {UNDEAD_RECRUITMENT:ZYNARA:LIMIT}}

        [if]
            [player_ghost_limit_reached]
                variable="player_ghost_count"
                limit="$player_ghost_limit"
            [/player_ghost_limit_reached]

            [then]
                [message]
                    speaker=Zynara
                    message= _ "My lady, no! I cannot keep that many spirits under control!"
                [/message]

                [transient_message]
                    message= _ "You are no longer able to recruit Ghosts for the remainder of this scenario."
                [/transient_message]

                [disallow_recruit]
                    side=1
                    type=Ghost
                [/disallow_recruit]

                [event]
                    name=victory

                    [allow_recruit]
                        side=1
                        type=Ghost
                    [/allow_recruit]
                [/event]

                [player_ghost_trap][/player_ghost_trap]
            [/then]

            [else]
                {VARIABLE_MINUS player_ghost_limit $player_ghost_count}

                [switch]
                    variable="player_ghost_limit"

                    [case]
                        value=3
                        [message]
                            speaker=Zynara
                            message= _ "My lady, I can summon up to three more spirits."
                        [/message]
                    [/case]

                    [case]
                        value=2
                        [message]
                            speaker=Zynara
                            message= _ "I can summon two more spirits."
                        [/message]
                    [/case]

                    [case]
                        value=1
                        [message]
                            speaker=Zynara
                            message= _ "I can only summon one more spirit!"
                        [/message]
                    [/case]

                    [case]
                        value=0
                        [message]
                            speaker=Zynara
                            message= _ "My lady, I will not be able to control additional spirits unless we get rid of some of the ones we already have at our command."
                        [/message]
                    [/case]
                [/switch]

                [allow_undo][/allow_undo]
            [/else]
        [/if]

        {CLEAR_VARIABLE player_ghost_count,player_ghost_limit}
    [/event]
#enddef

#define UNDEAD_RECRUITMENT:IRYLEAN
    [event]
        id=ur_irylean_prerecruit
        name=prerecruit
        first_time_only=no
        [filter]
            side=1
            type=Walking Corpse
        [/filter]
        [filter_condition]
            [have_unit]
                side=1
                id=Irylean
            [/have_unit]
        [/filter_condition]

        {VARIABLE_RANDOM temp_URI_variation gryphon,wolf,bat}

        [object]
            silent=yes
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=variation
                name=$temp_URI_variation
            [/effect]
        [/object]

        [heal_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            restore_statuses=no
        [/heal_unit]

        {CLEAR_VARIABLE temp_URI_variation}
    [/event]
#enddef

#
# Disallow a unit (slave) from moving when it gets away from another unit's
# (master) movement range.
#
# 1. We set the slave's remaining MP to 0 on each turn refresh unless it is
#    within range of its master.
#
# 2. We set the slave's remaining MP to 0 on moveto whenever it leaves its
#    master's range. We don't care how far away from its master's range it can
#    move. This can happen because of either the master or the slave moving.
#
# 3. On each case above, we store the slave's previous remaining MP in a unit
#    variable so we can restore them once the master moves so that the slave
#    is within his movement range again.
#
# 4. Handling the master or the slave's death is left as an exercise to the
#    reader.
#
# 5. Handling masters and slaves who do not belong to the same side is also
#    left as an exercise to the reader.
#
# 6. Allowing this macro to be used multiple times in a scenario is also left
#    as an exercise to the reader.
#
# Also note that this macro could be alternatively called SLAVE_UNIT. Not that
# there's anything wrong with that.(tm)
#
#define BIND_UNIT_TO_UNIT_MOVEMENT_RANGE _MASTER_SUF _SLAVE_SUF
    [event]
        id=bind_uu_immobilize_helper_eh # (3a)
        name=immobilize bound unit
        first_time_only=no

        {LOG_ATS_DBG "UU: $unit.id has been immobilized ($unit.moves| MP)"}

        {VARIABLE unit.variables.uu_moves $unit.moves}

        # Default attribute values since the 1.9.0 config optimizations are
        # undocumented and thus unreliable, so set an explicit flag to check
        # for.
        {VARIABLE unit.variables.uu_immobilized yes}

        {VARIABLE unit.moves 0}

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

        [redraw]
            side=$unit.side
        [/redraw]
    [/event]

    [event]
        id=bind_uu_mobilize_helper_eh # (3b)
        name=mobilize bound unit
        first_time_only=no

        {LOG_ATS_DBG "UU: $unit.id has been mobilized ($unit.variables.uu_moves| MP)"}

        {VARIABLE unit.moves $unit.variables.uu_moves}

        {CLEAR_VARIABLE unit.variables.uu_moves,unit.variables.uu_immobilized}

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

        [redraw]
            side=$unit.side
        [/redraw]
    [/event]

    [event]
        id=bind_uu_turn_refresh_eh # (1)
        name=turn refresh
        first_time_only=no
        [filter_side]
            [has_unit]
                {_SLAVE_SUF}
                [or]
                    {_MASTER_SUF}
                [/or]
            [/has_unit]
        [/filter_side]

        {LOG_ATS_DBG "UU: in turn refresh handler"}

        [check_unit_in_range]
            [filter]
                {_MASTER_SUF}
            [/filter]
            [filter_second]
                {_SLAVE_SUF}
            [/filter_second]
            variable=temp_bind_uu_in_range
        [/check_unit_in_range]

        [if]
            {VARIABLE_BOOLEAN_EQUALS temp_bind_uu_in_range no}
            [then]
                [fire_event]
                    name=immobilize bound unit
                    [primary_unit]
                        {_SLAVE_SUF}
                    [/primary_unit]
                [/fire_event]
            [/then]
            [else]
                [store_unit]
                    [filter]
                        {_SLAVE_SUF}
                    [/filter]
                    variable=temp_bind_uu_slave
                [/store_unit]

                # We only need to clear state here, since the game's internal
                # pre-turn refresh logic already reset the unit's MP.
                {CLEAR_VARIABLE temp_bind_uu_slave.variables.uu_moves,temp_bind_uu_slave.variables.uu_immobilized}

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

                {CLEAR_VARIABLE temp_bind_uu_slave}
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_bind_uu_in_range}
    [/event]

    [event]
        id=bind_uu_moveto_eh # (2)
        name=moveto
        first_time_only=no
        [filter]
            {_SLAVE_SUF}
            [or]
                {_MASTER_SUF}
            [/or]
        [/filter]

        {LOG_ATS_DBG "UU: in moveto handler"}

        [check_unit_in_range]
            [filter]
                {_MASTER_SUF}
            [/filter]
            [filter_second]
                {_SLAVE_SUF}
            [/filter_second]
            variable=temp_bind_uu_in_range
        [/check_unit_in_range]

        [if]
            {VARIABLE_BOOLEAN_EQUALS temp_bind_uu_in_range no}
            [then] # Not within master's range.
                [if]
                    [have_unit]
                        {_SLAVE_SUF}
                        [not]
                            [filter_wml]
                                [variables]
                                    uu_immobilized=yes
                                [/variables]
                            [/filter_wml]
                        [/not]
                    [/have_unit]
                    [then]
                        # Wasn't immobilized before, needs to be immobilized now.
                        [fire_event]
                            name=immobilize bound unit
                            [primary_unit]
                                {_SLAVE_SUF}
                            [/primary_unit]
                        [/fire_event]
                    [/then]
                    [else]
                        # Slave state won't be changed by this move, allow
                        # undoing.
                        [allow_undo][/allow_undo]
                    [/else]
                [/if]
            [/then]
            [else] # Now within master's range.
                [if]
                    [have_unit]
                        {_SLAVE_SUF}
                        [filter_wml]
                            [variables]
                                uu_immobilized=yes
                            [/variables]
                        [/filter_wml]
                    [/have_unit]
                    [then]
                        # Was immobilized before, restore MP and clear state.
                        [fire_event]
                            name=mobilize bound unit
                            [primary_unit]
                                {_SLAVE_SUF}
                            [/primary_unit]
                        [/fire_event]
                    [/then]
                    [else]
                        # Slave state won't be changed by this move, allow
                        # undoing.
                        [allow_undo][/allow_undo]
                    [/else]
                [/if]
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_bind_uu_in_range}
    [/event]
#enddef

#define FORCE_MOBILIZE_BOUND_UNIT _SLAVE_SUF
    [if]
        [have_unit]
            {_SLAVE_SUF}
            [filter_wml]
                [variables]
                    uu_immobilized=yes
                [/variables]
            [/filter_wml]
        [/have_unit]
        [then]
            [fire_event]
                name=mobilize bound unit
                [primary_unit]
                    {_SLAVE_SUF}
                [/primary_unit]
            [/fire_event]
        [/then]
    [/if]
#enddef

#define DISABLE_BOUND_UNITS
    # First, mobilize any applicable still bound units.

    [store_unit]
        [filter]
            [filter_wml]
                [variables]
                    uu_immobilized=yes
                [/variables]
            [/filter_wml]
        [/filter]
        variable=temp_uuu_immobilized_units
        kill=no
    [/store_unit]

    [foreach]
        array=temp_uuu_immobilized_units
        [do]
            [fire_event]
                name=mobilize bound unit
                [primary_unit]
                    x,y=$this_item.x,$this_item.y
                [/primary_unit]
            [/fire_event]
        [/do]
    [/foreach]

    {CLEAR_VARIABLE temp_uuu_immobilized_units}

    # With that out of the way, we can eliminate all the event handlers
    # previously involved.

    [remove_event]
        id=bind_uu_immobilize_helper_eh,bind_uu_mobilize_helper_eh,bind_uu_turn_refresh_eh,bind_uu_moveto_eh # wmllint: ignore
    [/remove_event]
#enddef

#define FIRE_GUARDIAN_SUMMONING
    [event]
        name=prestart

        {ENABLE_FIRE_GUARDIAN_SUMMONING}
    [/event]

    [event]
        name=victory

        {DISABLE_FIRE_GUARDIAN_SUMMONING}
    [/event]
#enddef

#define ENABLE_FIRE_GUARDIAN_SUMMONING
    [set_menu_item]
        id=wmi_summon_fire_guardian
        # po: The Fire Wraith unit type name translation may be found in the
        # po: wesnoth-units textdomain in mainline.
        description= _ "Summon Fire Wraith"
        image="icons/menu-fire.png"
        [show_if]
            # Only during the player's turn
            {VARIABLE_NUMERICAL_EQUALS side_number 1}
        [/show_if]
        [filter_location]
            [not]
                # Vacant hexes...
                [filter][/filter]
            [/not]
            # ... adjacent to Elyssa while she is under the player's control...
            [filter_adjacent_location]
                [filter]
                    side=1
                    id=Elyssa
                    # ... or to Elynia in E3S10
                    [or]
                        side=1
                        id=Elynia
                        [filter_wml]
                            [variables]
                                is_summoning_target=yes
                            [/variables]
                        [/filter_wml]
                    [/or]
                [/filter]
            [/filter_adjacent_location]
        [/filter_location]
        [command]
            [if]
                [have_location]
                    x,y=$x1,$y1
                    # ... that aren't impassable.
                    terrain=X*,*^X*
                    [not]
                        terrain=*^Xp # FIXME: *^X conflicts with Dark Hive holes, they should be replaced!
                    [/not]
                [/have_location]
                [then]
                    [transient_message]
                        message= _ "You cannot summon a Fire Wraith on an impassable location!"
                    [/transient_message]
                [/then]
                [else]
                    [if]
                        [have_unit]
                            side=1
                            type=Fire Wraith
                            count="6-99999"
                        [/have_unit]
                        [then]
                            [transient_message]
                                message= _ "You cannot control more than six Fire Wraiths at once!"
                            [/transient_message]
                        [/then]
                        [else]
                            [store_direction]
                                [from]
                                    [filter]
                                        id=Elyssa
                                    [/filter]
                                [/from]
                                to_x,to_y=$x1,$y1
                                variable=temp_FIRE_GUARDIAN_facing
                            [/store_direction]

                            [unit]
                                side=1
                                type=Fire Wraith
                                x,y=$x1,$y1
                                moves,attacks_left=0,0
                                random_gender=yes
                                random_traits=yes
                                generate_name=yes
                                animate=yes
                                upkeep=free
                                {IS_LOYAL}
                                facing=$temp_FIRE_GUARDIAN_facing
                                [modifications]
                                    {TRAIT_LOYAL}
                                    [object]
                                        silent=yes
                                        [effect]
                                            apply_to=level
                                            new_level=3
                                        [/effect]
                                        [effect]
                                            apply_to=hitpoints
                                            heal_full=yes
                                            increase_total={DIFF 15 13 9}
                                        [/effect]
                                        [effect]
                                            apply_to=attack
                                            range=melee
                                            increase_damage=1
                                        [/effect]
                                        [effect]
                                            apply_to=attack
                                            range=ranged
                                            increase_damage=1
                                            increase_attacks=2
                                            [set_specials]
                                                {WEAPON_SPECIAL_MARKSMAN}
                                            [/set_specials]
                                        [/effect]
                                        [effect]
                                            apply_to=new_ability
                                            [abilities]
                                                {ABILITY_REGENERATES}
                                            [/abilities]
                                        [/effect]
                                    [/object]
                                [/modifications]
                            [/unit]

                            {CLEAR_VARIABLE temp_FIRE_GUARDIAN_facing}
                        [/else]
                    [/if]
                [/else]
            [/if]
        [/command]
    [/set_menu_item]
#enddef

#define DISABLE_FIRE_GUARDIAN_SUMMONING
    [kill]
        type=Fire Wraith
        side=1
    [/kill]

    {REMOVE_MENU_ITEM wmi_summon_fire_guardian}
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define DARKEN_RED_SCREEN _VALUE
    [color_adjust]
        red=0
        green={_VALUE}
        blue={_VALUE}
    [/color_adjust]
#enddef

#
# Play the animation normally shown at the beginning of a
# unit advancement/level up sequence.
#
#define PLAY_LEVELOUT_ANIM _SUF
    [animate_unit]
        [filter]
            {_SUF}
        [/filter]
        flag=levelout
        with_bars=yes
    [/animate_unit]
#enddef

#
# Play the animation normally shown at the end of a unit
# advancement/level up sequence.
#
#define PLAY_LEVELIN_ANIM _SUF
    [animate_unit]
        [filter]
            {_SUF}
        [/filter]
        flag=levelin
        with_bars=yes
    [/animate_unit]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define WEAPON_SPECIAL_STUN_EVENTS
    [event]
        id=weapon_special_stun_attacker_hits
        name=attacker hits
        first_time_only=no
        [filter_attack]
            special=stun
        [/filter_attack]
        [filter_second]
            [not]
                level=0
                [or]
                    status=stunned
                [/or]
            [/not]
        [/filter_second]

        {VARIABLE second_unit.status.stunned yes}

        [unstore_unit]
            find_vacant=no
            variable=second_unit
            female_text= _ "female^stunned"
            male_text= _ "stunned"
            red,green,blue=196,196,128
        [/unstore_unit]

        [object]
            silent=yes
            duration=turn end
            [filter]
                x,y=$x2,$y2
            [/filter]
            [effect]
                apply_to=image_mod
                add="CS(50,50,0)"
            [/effect]
            [effect]
                apply_to=zoc
                value=no
            [/effect]
        [/object]
    [/event]

    [event]
        id=weapon_special_stun_turn_end
        name=side turn end
        first_time_only=no

        [store_unit]
            [filter]
                side=$side_number
                status=stunned
            [/filter]
            variable=temp_STUN_restore_units_store
        [/store_unit]

        [foreach]
            array=temp_STUN_restore_units_store
            [do]
                {CLEAR_VARIABLE this_item.status.stunned}

                [unstore_unit]
                    variable=this_item
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE temp_STUN_restore_units_store}
    [/event]
#enddef

#define WEAPON_SPECIAL_SEISMIC_EVENTS
    # NOTE: We currently run this unconditionally even if seismic cannot
    # proc for this turn anymore. Nothing else should need to hook into the
    # "seismic hits" event dispatch so this shouldn't be an issue for now.

    [event]
        id="seismic:attacker_hits_fwd"
        name=attacker hits
        first_time_only=no
        [filter_attack]
            special=seismic
        [/filter_attack]

        {EVENT_FORWARD_DISPATCH "seismic hits"}
    [/event]

    [event]
        id="seismic:attacker_hits_inv"
        name=defender hits
        first_time_only=no
        [filter_second_attack]
            special=seismic
        [/filter_second_attack]

        {EVENT_INVERSE_DISPATCH "seismic hits"}
    [/event]

    [event]
        id="seismic:main"
        name=seismic hits
        first_time_only=no
        [filter_condition]
            {VARIABLE_NUMERICAL_NOT_EQUALS turn_number $unit.variables.seismic_last_turn}
        [/filter_condition]

        [seismic_impact][/seismic_impact]
    [/event]
#enddef

#
# UtBS abilities
#

#textdomain wesnoth-utbs

#define WEAPON_SPECIAL_DAZE_EVENTS
    [event]
        id=weapon_special_daze_event_2
        name=attacker hits
        first_time_only=no

        [filter_attack]
            special_id=daze
        [/filter_attack]

        [filter_second]
            [not]
                [filter_wml]
                    [status]
                        dazed=yes
                    [/status]
                [/filter_wml]
            [/not]
        [/filter_second]

        {VARIABLE second_unit.status.dazed yes}

        [unstore_unit]
            variable=second_unit
            find_vacant=no
            text= _ "dazed"
            female_text = _ "female^dazed"
            red,green,blue=196,196,128
        [/unstore_unit]

        [object]
            silent=yes
            duration=scenario

            [filter]
                x,y=$x2,$y2
                [not]
                    ability=self_dazed
                [/not]
            [/filter]

            [effect]
                apply_to=new_ability
                [abilities]
                    [chance_to_hit]
                        id=enemy_dazed
                        name=""
                        description=""
                        add=10
                        apply_to=opponent
                        [filter_student]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_student]
                        [filter_opponent]
                            [filter_weapon]
                                [not]
                                    special_id=magical
                                [/not]
                                [not]
                                    special_id_active=marksman
                                [/not]
                            [/filter_weapon]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=enemy_dazed
                        name=""
                        description=""
                        add=10
                        apply_to=opponent
                        [filter_base_value]
                            greater_than_equal_to=60
                        [/filter_base_value]
                        [filter_student]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_student]
                        [filter_opponent]
                            [filter_weapon]
                                special_id_active=marksman
                            [/filter_weapon]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=self_dazed
                        name=""
                        description=""
                        sub=10
                        [filter_student]
                            [filter_weapon]
                                [not]
                                    special_id=magical
                                [/not]
                                [not]
                                    special_id_active=marksman
                                [/not]
                            [/filter_weapon]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_student]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=self_dazed
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=70
                        [/filter_base_value]
                        [filter_student]
                            [filter_weapon]
                                special_id_active=marksman
                            [/filter_weapon]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_student]
                    [/chance_to_hit]
                [/abilities]
            [/effect]
        [/object]
    [/event]

    [event]
        id=weapon_special_daze_event_3
        name=side turn
        first_time_only=no

        [event]
            name=side turn
            delayed_variable_substitution=no

            #{DEBUG_MSG "side $|side_number turn started, clearing daze from side $side_number units"}

            [modify_unit]
                [filter]
                    side=$side_number
                    [filter_wml]
                        [status]
                            dazed=yes
                        [/status]
                    [/filter_wml]
                [/filter]

                [status]
                    dazed=no
                [/status]
            [/modify_unit]
        [/event]
    [/event]
#enddef


#textdomain wesnoth-After_the_Storm

#
# The code for the Stun special is based on the UtBS implementation (as of 1.10),
# with various changes to account for AtS-specific concerns.
#

# wmllint: unbalanced-on
#define WEAPON_SPECIAL_STUN
    [dummy]
        id=stun
        name= _ "stun"
        description= _ "This attack puts enormous pressure on the opponent, disrupting its zone of control if a hit is landed. Not active on defense."
        special_note={SPECIAL_NOTE_STUN}
    [/dummy]

    # Globally included since it's a dependency of Elynia's AMLA tree
    #{WEAPON_SPECIAL_EVENTS STUN}
#enddef

#define WEAPON_SPECIAL_SEISMIC
    [dummy]
        id=seismic
        name= _ "seismic"
        description= _ "On the first hit during a turn, this attack deals 75% splash damage to all enemy units adjacent to the target, and has a 25% chance of inflicting both the slowed and stunned status effects on them as well as the target (calculated separately for each unit). The exact amount of damage dealt will vary for each affected unit according to their resistances, and it will not kill units other than the original target."
        special_note={SPECIAL_NOTE_SEISMIC}
    [/dummy]

    {WEAPON_SPECIAL_EVENTS SEISMIC}

    # This would be needed to handle unstunning units affected by the seism
    # status combo if it wasn't already globally included
    #{WEAPON_SPECIAL_EVENTS STUN}
#enddef

#
# UtBS abilities
#

#define WEAPON_SPECIAL_SHOCK
    # Canned definition of the Shock ability to be included in a
    # [specials] clause.
    [attacks]
        id=shock
        name= _ "shock"
        description= _ "When this attack is used on offense, the opponent will retaliate with one less strike than normally, to a minimum of one strike."
        special_note={SPECIAL_NOTE_SHOCK}
        sub=1
        active_on=offense
        apply_to=opponent
        [filter_base_value]
            greater_than=1
        [/filter_base_value]
    [/attacks]
#enddef

#define WEAPON_SPECIAL_DAZE
    [dummy]
        id=daze
        name= _ "daze"
        description= _ "When hit with this attack, an enemy suffers a 10% penalty both to their defense and chance to hit for one turn. Other specials that affect chance to hit (e.g. magical and marksman) take precedence over this special.

Magical attacks will still have a 70% chance to hit.
Marksman attacks are only affected if the chance to hit is greater than 60%."
        special_note={SPECIAL_NOTE_DAZE}
    [/dummy]

    # Globally included since it's a dependency of Anya's AMLA tree
    #{WEAPON_SPECIAL_EVENTS DAZE}
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#
# This file contains code used to work around bugs found in specific Wesnoth
# versions, using the ifver directive. Even if there is no code here at some
# point, the file is not intended to be removed.
#

# kate: indent-mode normal; encoding utf-8; space-indent on;


# wmllint: no translatables

#define COMPOSITE_GENERIC_SINGLE_PLFB TERRAIN PROB LAYER FLAG BUILDER IMAGESTEM FUNCTION
    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAIN}
            set_no_flag={FLAG}
        [/tile]

        probability={PROB}
        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM} ()}~{FUNCTION}
            variations=";2;3;4;5;6;7;8;9;10;11"
            layer={LAYER}
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define COMPOSITE_OVERLAY_PLFB TERRAIN PROB LAYER FLAG BUILDER IMAGESTEM FUNCTION
    {COMPOSITE_GENERIC_SINGLE_PLFB ({TERRAIN})  ({PROB}) ({LAYER}) ({FLAG}) ({BUILDER}) ({IMAGESTEM}) ({FUNCTION})}
#enddef

#define COMPOSITE_OVERLAY_PL TERRAINLIST PROB LAYER IMAGESTEM FUNCTION
    {COMPOSITE_OVERLAY_PLFB ({TERRAINLIST}) ({PROB}) ({LAYER}) overlay IMAGE_SINGLE ({IMAGESTEM}) ({FUNCTION})}
#enddef

#define COMPOSITE_OVERLAY_L TERRAINLIST LAYER IMAGESTEM FUNCTION
    {COMPOSITE_OVERLAY_PLFB ({TERRAINLIST}) 100 ({LAYER}) overlay IMAGE_SINGLE ({IMAGESTEM}) ({FUNCTION})}
#enddef

#define COMPOSITE_BORDER_RESTRICTED_PLFB TERRAINLIST ADJACENT PROB LAYER FLAG BUILDER IMAGESTEM FUNCTION
    [terrain_graphics]
        map="
, 2
* , *
, 1
* , *
, *"
        [tile]
            pos=1
            type={ADJACENT}
            set_no_flag={FLAG}-@R0
        [/tile]
        [tile]
            pos=2
            type={TERRAINLIST}
            set_no_flag={FLAG}-@R3
        [/tile]

        [image]
            layer={LAYER}
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM} -@R0}~{FUNCTION}
            variations=";2;3;4;5;6;7;8;9;10;11"
            center=90,144
        [/image]
        probability={PROB}
        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef

#define COMPOSITE_TRANSITION_RESTRICTED_PLFB TERRAINLIST ADJACENT PROB LAYER FLAG BUILDER IMAGESTEM FUNCTION
    {COMPOSITE_BORDER_RESTRICTED_PLFB ({TERRAINLIST}) ({ADJACENT}) ({PROB}) ({LAYER}) ({FLAG}) ({BUILDER}) ({IMAGESTEM}) ({FUNCTION})}
#enddef

#define COMPOSITE_TRANSITION_RESTRICTED_LF TERRAINLIST ADJACENT LAYER FLAG IMAGESTEM FUNCTION
    {COMPOSITE_TRANSITION_RESTRICTED_PLFB ({TERRAINLIST}) ({ADJACENT}) 100 ({LAYER}) ({FLAG}) IMAGE_SINGLE ({IMAGESTEM}) ({FUNCTION})}
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


# wmllint: no translatables
# wmlindent: start ignoring

#ifdef EDITOR

# NOTE: Nothing here at the moment. Do not remove this file.

#endif

# wmlindent: stop ignoring

# kate: indent-mode normal; encoding utf-8; space-indent on;


# wmllint: no translatables

# Starfield or some crap
{TERRAIN_BASE_RANDOM      Xzsf                 chasm/abyss                }

# Cracks
{OVERLAY_P                *^Egk         10     ../scenery/ground-crack-2       }
{OVERLAY_P                *^Egk         11     ../scenery/ground-crack-3       }
{OVERLAY_P                *^Egk         13     ../scenery/ground-crack-4       }
{OVERLAY_P                *^Egk         14     ../scenery/ground-crack-5       }
{OVERLAY_P                *^Egk         17     ../scenery/ground-crack-6       }
{OVERLAY_P                *^Egk         20     ../scenery/ground-crack-7       }
{OVERLAY_P                *^Egk         25     ../scenery/ground-crack-8       }
{OVERLAY                  *^Egk                ../scenery/ground-crack-1       }

# Statues
{OVERLAY                  *^Ezx                ../scenery/statue-xiael         }

# Dry grassland elvish castle
{TERRAIN_BASE            Cvz                   elvish-castle-ground-dry}
{NEW:CASTLEWALL          Cvz                   (!,C*,K*,Xu*,Xo*)          !,Ket,!,C*,Ke*    castle/elven/castle}

# Dry grassland elvish castle ruins
{TERRAIN_BASE            Cvrz                  elvish-castle-ground-dry}
{NEW:CASTLEWALL          Cvrz                  (!,C*,K*,Xu*,Xo*)          !,Ket,!,C*,Ke*    castle/elven-ruin/castle}

# Fake fog
{OVERLAY_PL               *^Zow        30 1         fog/fog1  }
{OVERLAY_PL               *^Zow        43 1         fog/fog2  }
{OVERLAY_PL               *^Zow       100 1         fog/fog3  }
{TRANSITION_RESTRICTED_LF *^Zow (!,*^Zow) 1 overlay fog/fog   }

# Blood
{NEW:OVERLAY                              Wwbf        water/ford FLAG=ford LAYER=-519}

{NEW:WATER_342_180                        Wwb,Wwbf    water/water  17 DURATION=125 RANDOM_START=125}
{NEW:WATER_342_180_OVERLAY                Wwb         water-overlay-blood                      -502}
{NEW:WATER_342_180_OVERLAY                Wwbf        water-overlay-blood-ford                 -502}

# Blood transitions
{NEW:WATER_342_180_OVERLAY_TRANSITION     Wwb         (!,Wwb,!,W*,Sm)  -505 water-overlay-blood      0.80}
{NEW:WATER_342_180_OVERLAY_TRANSITION     Wwbf        (!,Wwbf,!,W*,Sm) -505 water-overlay-blood-ford 0.40}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

# Include units WML directory
{LD /units/alien-verlissh}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

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

# A combination of demonfoot and armoredfoot

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

# Include units WML directories
{LD /units/demons}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm
#
# The Quenoth elves' stats differ from UtBS mainly in that they've
# adapted to the tropical forests in Quenoth Island and slightly lost
# affinity to sands.
#
# In practice this means that their forest movement cost is always 1 and
# their defense 10% greater than UtBS' stats up to a maximum of 60%,
# while their sand defense is 10% less down to a minimum of 50%
#

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

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

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

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

# Include units WML directory
{LD /units/elves-quenoth}


#textdomain wesnoth-After_the_Storm

# Include units WML directory
{LD /units/elves-wood}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define ANYA_TELEPORT_HALO_FRAME
    [halo_frame]
        halo="halo/elven/druid-healing[1~5].png:80,halo/elven/druid-healing6.png~O(0.75):80,halo/elven/druid-healing7.png~O(0.5):80,halo/elven/druid-healing8.png~O(0.25):80"
    [/halo_frame]
#enddef

#define ANYA_TELEPORT_ANIMATIONS _BASEFRAME
    [animation]
        apply_to=pre_teleport
        start_time=-600
        alpha="1.0~0.2"
        blend_ratio="0.0~1.0:400,1.0:200"
        blend_color=140,60,255
        [frame]
            duration=600
            image={_BASEFRAME}
        [/frame]

        halo_start_time=-600
        halo_auto_vflip=no
        halo_halo_mod="~CS(-32,-128,0)~O(0.8)"
        halo_halo_y="0~14"

        {ANYA_TELEPORT_HALO_FRAME}
    [/animation]

    [animation]
        apply_to=post_teleport
        start_time=-600
        alpha="0.2~1.0"
        blend_ratio="1.0:200,1.0~0.0:400"
        blend_color=140,60,255
        [frame]
            duration=600
            image={_BASEFRAME}
        [/frame]

        halo_start_time=-500
        halo_auto_vflip=no
        halo_halo_mod="~CS(-32,-128,0)~O(0.8)"
        halo_halo_y="-4~10"

        {ANYA_TELEPORT_HALO_FRAME}
    [/animation]
#enddef

# Include units WML directory
{LD /units/faeries}

#undef ANYA_TELEPORT_ANIMATIONS
#undef ANYA_TELEPORT_HALO_FRAME

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#ifndef __WMLUNITS__

# Include units WML directory
{LD /units/fake}

#endif

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

# Chaos
[movetype]
    name=armorerfoot
    [movement_costs]
        deep_water={UNREACHABLE}
        shallow_water=4
        reef=3
        swamp_water=4
        flat=1
        sand=2
        forest=2
        hills=3
        mountains={UNREACHABLE}
        village=1
        castle=1
        cave=2
        unwalkable={UNREACHABLE}
        impassable={UNREACHABLE}
        frozen=4
        fungus=2
    [/movement_costs]
    [defense]
        deep_water=90
        shallow_water=90
        reef=80
        swamp_water=90
        flat=70
        sand=80
        forest=60
        hills=60
        mountains=80
        village=60
        castle=50
        cave=60
        unwalkable=80
        impassable=80
        frozen=80
        fungus=60
    [/defense]
    [resistance]
        blade=70
        pierce=70
        impact=80
        fire=90
        cold=100
        arcane=80
    [/resistance]
[/movetype]

# Include units WML directory
{LD /units/humans}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

# Include units WML directories
{LD /units/imps}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

# Include units WML directory
{LD /units/mechanical}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

# Include units WML directory
{LD /units/monsters}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

# Include units WML directory
{LD /units/shaxthal}


#textdomain wesnoth-After_the_Storm

# Include units WML directory
{LD /units/undead}

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

[hide_help]
    race=merman,ogre,wose,drake
    type_adv_tree=Horseman,Mage
    type=Elder Mage,Royal Warrior,Elvish Lady
[/hide_help]

#undef DEMON_NAMES

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#define V_CONTROL_SPIRE_BASEFRAME _VARIATION
"units/alien-verlissh/control-spire-{_VARIATION}.png" #enddef

[unit_type]
    id=Verlissh Control Spire
    name= _ "Control Spire"
    race=verlissh
    ignore_race_traits=yes
    image="units/alien-verlissh/control-spire-high.png"
    bar_offset_x,bar_offset_y=0,0
    # the unit box in sidebar and help screen is really limited to 72x72...
    image_icon="units/alien-verlissh/control-spire-high.png~SCALE(72,72)"
    halo="halo/heart-aura.png"
    hitpoints=500
    movement_type=none
    [defense]
        deep_water=0
        shallow_water=0
        swamp_water=0
        reef=0
        flat=0
        sand=0
        forest=0
        hills=0
        mountains=0
        village=0
        castle=0
        cave=0
        frozen=0
        unwalkable=0
        impassable=0
        fungus=0
    [/defense]
    [resistance]
        blade=0
        pierce=0
        impact=0
        fire=0
        cold=0
        arcane=100
    [/resistance]
    movement=1
    {NO_EXPERIENCE_UNIT}
    # This unit is only level zero so units don't gain any
    # experience from surviving an attack.
    level=0
    zoc=yes
    alignment=chaotic
    cost=1000
    usage=archer
    undead_variation=null
    [abilities]
        {ABILITY_REGENERATES}
    [/abilities]
    hide_help=yes
    description= _ "Nobody has ever seen anything like this before."
    die_sound={SOUND_LIST:MATRIX_DIE}
    [attack]
        name=noctum
        description= _ "noctum"
        icon=attacks/noctum.png
        type=arcane
        range=melee
        damage=64
        number=1
        [specials]
            {WEAPON_SPECIAL_ALWAYS_HITS}
        [/specials]
    [/attack]
    [attack]
        name=noctum
        description= _ "noctum"
        icon=attacks/noctum.png
        type=arcane
        range=ranged
        damage=64
        number=1
        [specials]
            {WEAPON_SPECIAL_ALWAYS_HITS}
        [/specials]
    [/attack]

    {VERLISSH_MACHINE_STANDING_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME high})}
    [+standing_anim]
        blend_color=255,0,0
    [/standing_anim]
    {VERLISSH_MACHINE_DEATH_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME high})}
    {VERLISSH_MACHINE_DEFENSE_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME high})}

    [attack_anim]
        [filter_attack]
            name=noctum
        [/filter_attack]
        {VERLISSH_MACHINE_ENERGY_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME high})}
    [/attack_anim]

    [extra_anim]
        flag=portal beam
        start_time=-800
        missile_start_time=-400
        missile_offset=0.5~2.0
        offset=0.0
        blend_ratio="0.0~0.9:400,0.9~0.0:200,0.0:200"
        blend_color=255,0,0
        auto_hflip=no

        [missile_frame][/missile_frame]

        [missile_frame]
            duration=400

            image="projectiles/chaosmissile-n.png"
            image_diagonal="projectiles/chaosmissile-ne.png"

            halo="halo/chaos-halo[1~9].png:[25*8,50]"
        [/missile_frame]

        [frame]
            duration=800
            image={V_CONTROL_SPIRE_BASEFRAME high}
        [/frame]
    [/extra_anim]

    [variation]
        variation_id=low
        inherit=yes
        # the unit box in sidebar and help screen is really limited to 72x72...
        image="units/alien-verlissh/control-spire-low.png~SCALE(72,72)"
        halo="misc/blank-hex.png"

        {VERLISSH_MACHINE_STANDING_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME low})}
        [+standing_anim]
            blend_color=255,0,0
        [/standing_anim]
        {VERLISSH_MACHINE_DEATH_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME low})}
        {VERLISSH_MACHINE_DEFENSE_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME low})}

        [attack_anim]
            [filter_attack]
                name=noctum
            [/filter_attack]
            {VERLISSH_MACHINE_ENERGY_ANIMATION ({V_CONTROL_SPIRE_BASEFRAME low})}
        [/attack_anim]

        [extra_anim]
            [frame]
                image={V_CONTROL_SPIRE_BASEFRAME low}
            [/frame]
        [/extra_anim]
    [/variation]
[/unit_type]

#undef V_CONTROL_SPIRE_BASEFRAME

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-After_the_Storm

#ifdef CAMPAIGN_AFTER_THE_STORM_EPISODE_III
#ifndef __WMLUNITS__

{./angel-of-blood}

#endif
#endif


#textdomain wesnoth-After_the_Storm

[unit_type]
    id=Errant Executor
    name= _ "Errant Executor"
    race=demon
    image="units/demons/errant-executor.png"
    hitpoints=77
    movement_type=demonfoot
    movement=5
    experience=200
    level=4
    alignment=neutral
    advances_to=null
    {AMLA_DEFAULT}
    cost=110
    usage=mixed fighter
    {TRAIT_DEXTROUS}
    [resistance]
        blade=70
        pierce=80
        impact=70
        cold=80
    [/resistance]
    [abilities]
        {ABILITY_LEADERSHIP}
        {ABILITY_STEADFAST}
    [/abilities]
    hide_help=true
    description= _ "Only the mightiest demons are allowed to serve Uria as her greatest vassals and governors of the various peoples of Inferno. After the fall of the Chaos Emperor, rumors of the presence of these figures of legend on Irdya abound and instill great fear among the ill-equipped armies of the northern lands."
    die_sound={SOUND_LIST:HUMAN_DIE}
    {DEFENSE_ANIM "units/demons/errant-executor.png" "units/demons/errant-executor.png" {SOUND_LIST:HUMAN_HIT} }
    [attack]
        name=battle axe
        description= _ "battle axe"
        type=blade
        range=melee
        damage=11
        number=4
        icon=attacks/battleaxe-undead.png
    [/attack]
    [attack]
        name=battle axe
        description= _ "battle axe"
        type=pierce
        range=melee
        damage=21
        number=2
        icon=attacks/battleaxe-undead.png
    [/attack]
    [attack]
        name=infernal tempest
        description= _ "infernal tempest"
        type=cold
        range=ranged
        damage=11
        number=5
        icon=attacks/iceball.png
    [/attack]
    [attack_anim]
        [filter_attack]
            name=battle axe
            type=blade
        [/filter_attack]
        start_time=-250
        [frame]
            duration=150
            image="units/demons/errant-executor.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                duration=200
                image="units/demons/errant-executor.png"
                sound=axe.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=200
                image="units/demons/errant-executor.png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            duration=75
            image="units/demons/errant-executor.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=battle axe
            type=pierce
        [/filter_attack]
        start_time=-250
        [frame]
            duration=150
            image="units/demons/errant-executor.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                duration=200
                image="units/demons/errant-executor.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=200
                image="units/demons/errant-executor.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            duration=75
            image="units/demons/errant-executor.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=infernal tempest
        [/filter_attack]
        {MISSILE_FRAME_INFERNAL_CHILL}
        start_time=-300
        [frame]
            duration=50
            image="units/demons/errant-executor.png"
            halo=halo/saurian-magic-halo-1.png
        [/frame]
        [frame]
            duration=60
            image="units/demons/errant-executor.png"
            halo=halo/saurian-magic-halo-2.png
            sound=magicmissile.wav
        [/frame]
        [frame]
            duration=70
            image="units/demons/errant-executor.png"
            halo=halo/saurian-magic-halo-3.png
        [/frame]
        [frame]
            duration=80
            image="units/demons/errant-executor.png"
            halo=halo/saurian-magic-halo-4.png
        [/frame]
        [frame]
            duration=90
            image="units/demons/errant-executor.png"
            halo=halo/saurian-magic-halo-5.png
        [/frame]
        [frame]
            duration=100
            image="units/demons/errant-executor.png"
            halo=halo/saurian-magic-halo-6.png
        [/frame]
        [frame]
            duration=100
            image="units/demons/errant-executor.png"
            halo=halo/saurian-magic-halo-7.png
        [/frame]
    [/attack_anim]
[/unit_type]

# kate: indent-mode normal; encoding utf-8; space-indent on;