#textdomain wesnoth-Genesis

#define ABILITY_IRON_BLOOD
    [resistance]
        id=iron_blood
        apply_to=blade,impact,pierce
        add=20
        max_value=90
        name= _ "iron blood"
        female_name= _ "female^iron blood"
        description= _ "This unit’s physical resistances are increased by 20% when defending."
        affect_self=yes
        active_on=defense
    [/resistance]
#enddef

#define ABILITY_INFUSE_HEALING3
    [heals]
        value=3
        id=healing
        affect_allies=yes
        name= _ "infuse"
        female_name= _ "female^infuse"
        description= _ "A unit cared for by this healer may heal up to 3 HP per turn or be cured of poison."
        affect_self=yes
        poison=cured
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_INFUSE_HEALING6
    [heals]
        value=6
        id=healing
        affect_allies=yes
        name= _ "infuse"
        female_name= _ "female^infuse"
        description= _ "A unit cared for by this healer may heal up to 6 HP per turn or be cured of poison."
        affect_self=yes
        poison=cured
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_INFUSE_HEALING9
    [heals]
        value=9
        id=healing
        affect_allies=yes
        name= _ "infuse"
        female_name= _ "female^infuse"
        description= _ "A unit cared for by this healer may heal up to 9 HP per turn or be cured of poison."
        affect_self=yes
        poison=cured
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_INFUSE3
    {ABILITY_UNPOISON}
    {ABILITY_INFUSE_HEALING3}
#enddef

#define ABILITY_INFUSE6
    {ABILITY_UNPOISON}
    {ABILITY_INFUSE_HEALING6}
#enddef

#define ABILITY_INFUSE9
    {ABILITY_UNPOISON}
    {ABILITY_INFUSE_HEALING9}
#enddef

#define WEAPON_SPECIAL_SOUL_SIPHON
    [dummy]
        id=soul_siphon
        name= _ "reap"
        name_inactive= _ "reap"
        description= _ "A portion of the damage dealt by this attack is converted into healing energy and spread among nearby allies."
        description_inactive= _ "A portion of the damage dealt by this attack is converted into healing energy and spread among nearby allies."
    [/dummy]
#enddef

#define SOUL_SIPHON WEAPON FACTOR
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            name={WEAPON}
            special_id=soul_siphon
        [/filter_attack]
        [store_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x1,$y1
                    is_enemy=no
                [/filter_adjacent]
                [not]
                    x,y=$x2,$y2
                [/not]
            [/filter]
            variable=ally
        [/store_unit]
        {VARIABLE counter 0}
        {VARIABLE heal_health $damage_inflicted}
        {VARIABLE_OP heal_health divide {FACTOR}}
        [for]
            array=ally
            [do]
                {VARIABLE_OP counter add 1}
            [/do]
        [/for]
        [if]
            [variable]
                name=counter
                greater_than=0
            [/variable]
            [then]
                {VARIABLE_OP heal_health divide $counter}
            [/then]
        [/if]
        [for]
            array=ally
            [do]
                [heal_unit]
                    [filter]
                        x,y=$ally[$i].x,$ally[$i].y
                    [/filter]
                    amount=$heal_health
                    animate=yes
                    restore_statuses=no
                [/heal_unit]
            [/do]
        [/for]
        {CLEAR_VARIABLE heal_health}
        {CLEAR_VARIABLE counter}
        {CLEAR_VARIABLE ally}
    [/event]
    [event]
        name=defender hits
        first_time_only=no
        [filter_second_attack]
            special_id=soul_siphon
        [/filter_second_attack]
        [store_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x2,$y2
                    is_enemy=no
                [/filter_adjacent]
                [not]
                    x,y=$x1,$y1
                [/not]
            [/filter]
            variable=ally
        [/store_unit]
        {VARIABLE counter 0}
        {VARIABLE heal_health $damage_inflicted}
        {VARIABLE_OP heal_health divide {FACTOR}}
        [for]
            array=ally
            [do]
                {VARIABLE_OP counter add 1}
            [/do]
        [/for]
        [if]
            [variable]
                name=counter
                greater_than=0
            [/variable]
            [then]
                {VARIABLE_OP heal_health divide $counter}
            [/then]
        [/if]
        [for]
            array=opp
            [do]
                [heal_unit]
                    [filter]
                        x,y=$ally[$i].x,$ally[$i].y
                    [/filter]
                    amount=$heal_health
                    animate=yes
                    restore_statuses=no
                [/heal_unit]
            [/do]
        [/for]
        {CLEAR_VARIABLE heal_health}
        {CLEAR_VARIABLE counter}
        {CLEAR_VARIABLE ally}
    [/event]
#enddef

#define WEAPON_SPECIAL_MALEFICE
    [dummy]
        id=malefice
        name= _ "malefice"
        description= _ "When this attack kills a unit (level 3 and above), it gains 1 damage. Does not work against Undead and Demons."
    [/dummy]
#enddef

#define MALEFICE
    [event]
        id=special_malefice_die
        name=die
        first_time_only=no

        [filter]
            level=3
            [not]
                race=undead,demon,elemental,magical
            [/not]
            [or]
                level=4
                [not]
                    race=undead,demon,elemental,magical
                [/not]
            [/or]
            [or]
                level=5
                [not]
                    race=undead,demon,elemental,magical
                [/not]
            [/or]
            [or]
                level=6
                [not]
                    race=undead,demon,elemental,magical
                [/not]
            [/or]
            [or]
                level=7
                [not]
                    race=undead,demon,elemental,magical
                [/not]
            [/or]
            [and]
                [not]
                    race=undead,demon,elemental,magical
                [/not]
            [/and]
        [/filter]

        [filter_second_attack]
            special_id=malefice
        [/filter_second_attack]

        [store_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            [not]
                x,y=$x1,$y1
            [/not]
        [/store_unit]

        [object]
            [filter]
                x,y=$x2,$y2
            [/filter]
            duration=forever
            silent=yes
            [effect]
                apply_to=attack
                special_id=malefice
                increase_damage=1
            [/effect]
        [/object]
    [/event]
#enddef

#define WEAPON_SPECIAL_AGONY
    [damage]
        id=agony
        name= _ "agony"
        name_inactive= _ "agony"
        description= _ "The immense pain resulting from this attack causes enemies to deal 30% less damage."
        description_inactive= _ "The immense pain resulting from this attack causes enemies to deal 30% less damage."
        apply_to=opponent
        multiply=0.7
    [/damage]
#enddef

#define ABILITY_STRUT
    [dummy]
        id=strut
        name= _ "strut"
        name_inactive= _ "strut"
        description= _ "Adjacent undead units gain 2 extra movement points on each new turn."
        description_inactive= _ "Adjacent undead units gain 2 extra movement points on each new turn."
    [/dummy]
#enddef

#define STRUT
    [event]
        name=turn refresh
        first_time_only=no
        [store_unit]
            [filter]
                race=undead
                [filter_adjacent]
                    ability=strut
                    is_enemy=no
                [/filter_adjacent]
            [/filter]
            variable=fast_unit
        [/store_unit]
        [for]
            array=fast_unit
            [do]
                {VARIABLE_OP fast_unit[$i].moves add 2}

                [unstore_unit]
                    variable=fast_unit[$i]
                    find_vacant=no
                [/unstore_unit]
            [/do]
        [/for]
        {CLEAR_VARIABLE fast_unit}
    [/event]
#enddef

#define ABILITY_TRANSFUSION
    [dummy]
        id=transfusion
        name= _ "transfusion"
        name_inactive= _ "transfusion"
        description= _ "This unit deals damage to nearby enemies on each new turn and heals for the damage dealt."
        description_inactive= _ "This unit deals damage to nearby enemies on each new turn and heals for the damage dealt."
    [/dummy]
#enddef

#define TRANSFUSION
    [event]
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                [filter_adjacent]
                    ability=transfusion
                    is_enemy=yes
                [/filter_adjacent]
            [/filter]
            variable=opp
        [/store_unit]
        [store_unit]
            [filter]
                ability=transfusion
            [/filter]
            variable=tunit
        [/store_unit]
        {VARIABLE counter 0}
        [for]
            array=opp
            [do]
                {VARIABLE_OP counter add 1}
            [/do]
        [/for]
        [for]
            array=opp
            [do]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=6
                    delay=25
                [/harm_unit]
                [if]
                    [have_unit]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/have_unit]
                    [else]
                        {VARIABLE exp $opp[$i].level}
                        {VARIABLE_OP exp multiply 8}
                        {VARIABLE_OP tunit.experience add $exp}
                        {CLEAR_VARIABLE exp}
                        [unstore_unit]
                            variable=tunit
                            find_vacant=no
                        [/unstore_unit]
                    [/else]
                [/if]
            [/do]
        [/for]
        {VARIABLE_OP counter multiply 6}
        [heal_unit]
            [filter]
                ability=transfusion
            [/filter]
            amount=$counter
            animate=yes
        [/heal_unit]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE tunit}
        {CLEAR_VARIABLE counter}
    [/event]
#enddef

#define ABILITY_IRON_WARDEN
    [dummy]
        id=iron warden
        name= _ "iron warden"
        name_inactive= _ "iron warden"
        description= _ "When nearby allies are attacked by physical attacks, they heal for 30% of the damage dealt and return damage equal to the amount healed."
        description_inactive= _ "When nearby allies are attacked by physical attacks, they heal for 30% of the damage dealt and return damage equal to the amount healed."
    [/dummy]
#enddef

#define IRON_WARDEN FACTOR
    [event]
        name=attacker_hits
        first_time_only=no

        [filter_attack]
            type=blade,impact,pierce
        [/filter_attack]

        [filter_second]
            [filter_adjacent]
                ability=iron warden
                is_enemy=no
            [/filter_adjacent]
        [/filter_second]

        [store_unit]
            [filter]
                x,y=$x2,$y2
                [filter_adjacent]
                    ability=iron warden
                    is_enemy=no
                [/filter_adjacent]
            [/filter]
            variable=shielded
        [/store_unit]
        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            variable=opp
        [/store_unit]

        {VARIABLE heal_health $damage_inflicted}
        {VARIABLE_OP heal_health divide {FACTOR}}
        [if]
            [variable]
                name=second_unit.hitpoints
                greater_than=0
            [/variable]
            [then]
                [for]
                    array=shielded
                    [do]
                        [heal_unit]
                            [filter]
                                x,y=$shielded[$i].x,$shielded[$i].y
                            [/filter]
                            amount=$heal_health
                            animate=yes
                            restore_statuses=no
                        [/heal_unit]
                    [/do]
                [/for]

                [harm_unit]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    amount=$heal_health
                    animate=yes
                    fire_event=yes
                [/harm_unit]
            [/then]
        [/if]

        [if]
            [have_unit]
                x,y=$x1,$y1
            [/have_unit]
            [else]
                {VARIABLE exp $opp.level}
                {VARIABLE_OP exp multiply 8}
                {VARIABLE_OP second_unit.experience add $exp}
                {CLEAR_VARIABLE exp}
                [unstore_unit]
                    variable=second_unit
                    find_vacant=no
                [/unstore_unit]
            [/else]
        [/if]

        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE heal_health}
        {CLEAR_VARIABLE shielded}
    [/event]
#enddef


#textdomain wesnoth-Genesis

#define WEAPON_SPECIAL_MIRRORFORCE
    [dummy]
        id=mirrorforce
        name= _ "mirror force"
        name_inactive= _ "mirror force"
        description= _ "This attack reflects 50% of all damage."
        description_inactive= _ "This attack reflects 50% of all damage."
    [/dummy]
#enddef
#define MIRRORFORCE
    [event]
        name=attacker hits
        first_time_only=no
        [filter_second_attack]
            special_id=mirrorforce
        [/filter_second_attack]
        [if]
            [variable]
                name=second_unit.hitpoints
                greater_than=1
            [/variable]
            [then]
                {VARIABLE_OP damage_inflicted multiply 0.5}
                [heal_unit]
                    [filter]
                        x,y=$x2,$y2
                    [/filter]
                    amount=$damage_inflicted
                    animate=no
                    restore_statuses=no
                [/heal_unit]
                [harm_unit]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    kill=no
                    amount=$damage_inflicted
                    animate=no
                    restore_statuses=no
                [/harm_unit]
            [/then]
        [/if]
    [/event]
    [event]
        name=defender hits
        first_time_only=no
        [filter_attack]
            special_id=mirrorforce
        [/filter_attack]
        [if]
            [variable]
                name=unit.hitpoints
                greater_than=1
            [/variable]
            [then]
                {VARIABLE_OP damage_inflicted multiply 0.5}
                [heal_unit]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    amount=$damage_inflicted
                    animate=no
                    restore_statuses=no
                [/heal_unit]
                [harm_unit]
                    [filter]
                        x,y=$x2,$y2
                    [/filter]
                    kill=no
                    amount=$damage_inflicted
                    animate=no
                    restore_statuses=no
                [/harm_unit]
            [/then]
        [/if]
    [/event]
#enddef

#define ABILITY_DREAMWALK
    [dummy]
        id=dreamwalk
        name= _ "dreamwalk"
        name_inactive= _ "dreamwalk"
        description= _ "This unit heals 20% of its missing health a turn and can generate copies of itself."
        description_inactive= _ "This unit heals 20% of its missing health a turn and can generate copies of itself."
    [/dummy]
#enddef

#define ABILITY_DREAMWEAVE
    [dummy]
        id=dreamweave
        name= _ "dreamweave"
        name_inactive= _ "dreamweave"
        description= _ "This unit generates a copy of each adjacent unit on each turn."
        description_inactive= _ "This unit generates a copy of each adjacent unit on each turn."
    [/dummy]
#enddef

#define ABILITY_NOCTURNE
    [dummy]
        id=nocturne
        name= _ "nocturne"
        female_name= _ "female^nocturne"
        description= _ "This unit generates a copy of nearby units (within a radius of 3) on each turn."
        description_inactive= _ "This unit generates a copy of nearby (within a radius of 3)  units on each turn."
    [/dummy]
#enddef

#define WEAPON_SPECIAL_MIRROR
    [dummy]
        id=mirror
        name= _ "mirror"
        name_inactive= _ "mirror"
        description= _ "This attack copies the attack used against it."
        description_inactive= _ "This attack copies the attack used against it."
    [/dummy]
#enddef

# don't use this one for now, I can't get it to work
#define MIRROR_DOESNOTWORK
    [event]
        id=mirror_dreamlord1
        name=attack
        first_time_only=no
        [filter_attack]
            special_id=mirror
        [/filter_attack]

        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            variable=attacker
        [/store_unit]
        [store_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            variable=defender
        [/store_unit]

        [set_variable]
            name=defender.image
            value=$attacker.image
        [/set_variable]
        [set_variable]
            name=defender.profile
            value=$attacker.profile
        [/set_variable]
        [set_variable]
            name=defender.small_profile
            value=$attacker.small_profile
        [/set_variable]
        [set_variable]
            name=defender.facing
            value=$attacker.facing
        [/set_variable]
        [set_variable]
            name=defender.advances_to
            value=$attacker.advances_to
        [/set_variable]
        [set_variable]
            name=defender.name
            value=$attacker.name
        [/set_variable]
        [set_variable]
            name=defender.alignment
            value=$attacker.alignment
        [/set_variable]
        [set_variable]
            name=defender.id
            value=$attacker.id
        [/set_variable]
        [set_variable]
            name=defender.race
            value=$attacker.race
        [/set_variable]
        [set_variable]
            name=defender.movement_type
            value=$attacker.movement_type
        [/set_variable]
        [set_variable]
            name=defender.level
            value=$attacker.level
        [/set_variable]
        [set_variable]
            name=defender.side
            value=$attacker.side
        [/set_variable]
        [set_variable]
            name=defender.flying
            value=$attacker.flying
        [/set_variable]
        [set_variable]
            name=defender.gender
            value=$attacker.gender
        [/set_variable]
        [set_variable]
            name=defender.max_experience
            value=$attacker.max_experience
        [/set_variable]
        [set_variable]
            name=defender.experience
            value=$attacker.experience
        [/set_variable]
        [set_variable]
            name=defender.max_hitpoints
            value=$attacker.max_hitpoints
        [/set_variable]
        [set_variable]
            name=defender.hitpoints
            value=$attacker.hitpoints
        [/set_variable]
        [set_variable]
            name=defender.type
            value=$attacker.type
        [/set_variable]

        [set_variable]
            name=attacker_mirror
            value=1
        [/set_variable]
        [set_variable]
            name=defender_mirror
            value=0
        [/set_variable]

        [unstore_unit]
            variable=defender
            x,y=$x1,$y1
        [/unstore_unit]

        [object]
            take_only_once=no
            silent=yes
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=remove_attacks
                [not]
                    name=$second_weapon.name
                [/not]
            [/effect]
        [/object]

    [/event]
    [event]
        name=attack end
        id=mirror_dreamlord_end
        first_time_only=no

        [if]
            [variable]
                name=attacker_mirror
                numerical_equals=1
            [/variable]
            [then]
                #[unstore_unit]
                #   variable=attacker
                #[/unstore_unit]
            [/then]
        [/if]

#       {CLEAR_VARIABLE attacker_mirror}
#       {CLEAR_VARIABLE defender_mirror}
#       {CLEAR_VARIABLE attacker}
#       {CLEAR_VARIABLE defender}
    [/event]
#enddef


#textdomain wesnoth-Genesis

#define IMMOLATE
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special_id=immolate
        [/filter_attack]
        [store_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x1,$y1
                    is_enemy=yes
                [/filter_adjacent]
                [not]
                    x,y=$x2,$y2
                [/not]
            [/filter]
            variable=opp
        [/store_unit]
        [for]
            array=opp
            [do]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=$damage_inflicted
                    damage_type=fire
                    delay=25
                [/harm_unit]
                [if]
                    [have_unit]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/have_unit]
                    [else]
                        {VARIABLE exp $opp[$i].level}
                        {VARIABLE_OP exp multiply 8}
                        {VARIABLE_OP unit.experience add "$(max(4, $exp))"}
                        {CLEAR_VARIABLE exp}
                        [unstore_unit]
                            variable=unit
                            find_vacant=no
                        [/unstore_unit]
                    [/else]
                [/if]
            [/do]
        [/for]
        {CLEAR_VARIABLE opp}
    [/event]
#enddef
#define WEAPON_SPECIAL_IMMOLATE
    [dummy]
        id=immolate
        name= _ "immolate"
        name_inactive= _ "immolate"
        description= _ "The damage inflicted by this attack will spread to all nearby enemies."
        description_inactive= _ "The damage inflicted by this attack will spread to all nearby enemies."
    [/dummy]
#enddef
#define WEAPON_SPECIAL_OBLITERATE
    [damage]
        id=obliterate
        name= _ "obliterate"
        description= _ "When used offensively, this attack gains a large amount of damage."
        multiply=2.5
        active_on=offense
    [/damage]
#enddef
#define ABILITY_STORM_SHIELD
    [dummy]
        id=storm_shield
        name= _ "storm shield"
        name_inactive= _ "storm shield"
        description= _ "This unit returns damage when attacked. This damage ignores resistances."
        description_inactive= _ "This unit returns damage when attacked. This damage ignores resistances."
    [/dummy]
#enddef
#define STORM_SHIELD
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_second]
            ability=storm_shield
        [/filter_second]
        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            variable=self
        [/store_unit]
        [store_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            variable=opp
        [/store_unit]
        {VARIABLE stormshield $damage_inflicted}
        {VARIABLE_OP stormshield multiply 0.67}
        [harm_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            fire_event=yes
            animate=yes
            amount=$stormshield
            delay=100
        [/harm_unit]
        [if]
            [have_unit]
                x,y=$x1,$y1
            [/have_unit]
            [else]
                {VARIABLE exp $self.level}
                {VARIABLE_OP exp multiply 8}
                {VARIABLE_OP opp.experience add "$(max(4, $exp))"}
                {CLEAR_VARIABLE exp}
                [unstore_unit]
                    variable=opp
                    find_vacant=no
                [/unstore_unit]
            [/else]
        [/if]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE self}
        {CLEAR_VARIABLE stormshield}
    [/event]
#enddef
#define ABILITY_FIRE_SHIELD
    [dummy]
        id=fire_shield
        name= _ "fire shield"
        name_inactive= _ "fire shield"
        description= _ "This unit returns fire damage when attacked by melee attacks."
        description_inactive= _ "This unit returns fire damage when attacked by melee attacks."
    [/dummy]
#enddef
#define FIRE_SHIELD
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_second]
            ability=fire_shield
        [/filter_second]
        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            variable=self
        [/store_unit]
        [store_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            variable=opp
        [/store_unit]
        {VARIABLE fireshield $damage_inflicted}
        {VARIABLE_OP fireshield multiply 0.5}
        [harm_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            fire_event=yes
            animate=yes
            amount=$fireshield
            damage_type=fire
            delay=100
        [/harm_unit]
        [if]
            [have_unit]
                x,y=$x1,$y1
            [/have_unit]
            [else]
                {VARIABLE exp $self.level}
                {VARIABLE_OP exp multiply 8}
                {VARIABLE_OP opp.experience add "$(max(4, $exp))"}
                {CLEAR_VARIABLE exp}
                [unstore_unit]
                    variable=opp
                    find_vacant=no
                [/unstore_unit]
            [/else]
        [/if]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE self}
        {CLEAR_VARIABLE stormshield}
    [/event]
#enddef
#define OBLITERATE WEAPON DMG
    [event]
        id=obliterate handler
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            name={WEAPON}
            special_id=obliterate
        [/filter_attack]
        [store_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            variable=opp
        [/store_unit]
        {VARIABLE obliterate {DMG}}
        [harm_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            fire_event=yes
            animate=yes
            amount=$obliterate
            delay=100
        [/harm_unit]
        [if]
            [have_unit]
                x,y=$x2,$y2
            [/have_unit]
            [else]
                {VARIABLE exp $opp.level}
                {VARIABLE_OP exp multiply 8}
                {VARIABLE_OP unit.experience add "$(max(4, $exp))"}
                {CLEAR_VARIABLE exp}
                [unstore_unit]
                    variable=unit
                    find_vacant=no
                [/unstore_unit]
            [/else]
        [/if]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE obliterate}
    [/event]
#enddef
#define ABILITY_BLESSING_SHARDIA
    [leadership]
        id=blessing_shardia
        value=10
        cumulative=yes
        name= _ "blessing of shardia"
        female_name= _ "female^blessing of shardia"
        description= _ "This unit gains 10% damage during the day."
        affect_self=yes
        [filter_self]
            [filter_location]
                time_of_day=lawful
            [/filter_location]
        [/filter_self]
    [/leadership]
#enddef
#define ABILITY_KINDLE
    [regenerate]
        value=11
        id=kindle
        name= _ "kindle"
        female_name= _ "female^kindle"
        description= _ "The unit will heal itself 11 HP per turn. If it is poisoned, it will remove the poison instead of healing."
        affect_self=yes
        poison=cured
    [/regenerate]
#enddef
#define WEAPON_SPECIAL_INCINERATE
    [damage]
        id=incinerate
        name= _ "incinerate"
        description= _ "When used offensively, this attack gains 50% damage."
        multiply=1.5
        active_on=offense
    [/damage]
#enddef


#textdomain wesnoth-Genesis

#define FAERIE_RECRUITS
    recruit=Faerie Sprite,Dusk Faerie,Faerie Shaman,Yousei Briar Maiden,Equipoise Faerie
#enddef

#define FULL_RECRUIT_LIST
    recruit=Faerie Sprite,Dusk Faerie,Faerie Shaman,Yousei Briar Maiden,Equipoise Faerie,Ghost,Skeleton,Skeleton Archer
#enddef

#define PLAYER_FAE
    type=Fire Fae
    name= _ "Esther"
    id=Esther
    team_name=fae
    user_team_name= _ "team_name^Fae"
    controller=human
    canrecruit=yes
    color=green
#enddef

#define HUMAN_ALLY
    team_name=fae
    user_team_name= _ "team_name^Humans"
    color=white
    controller=ai
#enddef

#define HUMAN_ENEMY
    team_name=humans
    user_team_name= _ "team_name^Humans"
    color=white
    controller=ai
#enddef

#define MONSTER_SIDE
    color=orange
    controller=ai
    team_name=monsters
    user_team_name= _ "team_name^Monsters"
    no_leader=yes
#enddef

#define SPIRIT_ENEMY_SIDE
    controller=ai
    team_name=spirits
    user_team_name= _ "team_name^Spirits"
    color=lightblue
#enddef


#textdomain wesnoth-Genesis

#define AMLA_FIRE_FAERIE
   {AMLA_OPTION_FIREFAERIEMELEE}
   {AMLA_OPTION_FIREFAERIERANGED}
#enddef
#define AMLA_OPTION_FIREFAERIEMELEE
    [advancement]
        max_times=-1
        description=_"increased melee damage"
        image="units/faeries-other/dryad.png"
        id=amla_melee_firefaerie
        strict_amla=yes
        [effect]
            apply_to=attack
            name=fire aura
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=40%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_FIREFAERIERANGED
    [advancement]
        max_times=-1
        description=_"stronger ranged attacks"
        image="units/faeries-other/dryad.png"
        id=amla_ranged_firefaerie
        strict_amla=yes
        [effect]
            apply_to=attack
            name=mystic fire
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=40%
        [/effect]
    [/advancement]
#enddef

#define AMLA_EVENTIDE
   {AMLA_OPTION_EVENTIDEMELEE}
   {AMLA_OPTION_EVENTIDERANGED}
#enddef
#define AMLA_OPTION_EVENTIDEMELEE
    [advancement]
        max_times=-1
        description=_"increased melee damage"
        image=units/faeries-other/eventide-dancer.png
        id=amla_melee_eventide
        strict_amla=yes
        [effect]
            apply_to=attack
            name=faerie touch
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_EVENTIDERANGED
    [advancement]
        max_times=-1
        description=_"stronger ranged attacks"
        image=units/faeries-other/eventide-dancer.png
        id=amla_ranged_eventide
        strict_amla=yes
        [effect]
            apply_to=attack
            name=forest chill
            increase_damage=2
            heal_full=yes
        [/effect]
        [effect]
            apply_to=attack
            name=shadow wave
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=40%
        [/effect]
    [/advancement]
#enddef

#define ABILITY_HEAL6
    [heals]
        value=6
        id=healing
        affect_allies=yes
        name= _ "heals +6"
        female_name= _ "female^heals +6"
        description=  _ "Allows the unit to heal adjacent allied units at the beginning of our turn.

A unit cared for by this healer may heal up to 6 HP per turn, or stop poison from taking effect for that turn.
A poisoned unit cannot be cured of its poison by a healer, and must seek the care of a village or a unit that can cure."
        affect_self=no
        poison=slowed
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_GUARDIAN_ANGEL1
    [dummy]
        id=guardianangel1
        name= _ "guardian angel"
        female_name= _ "female^guardian angel"
        description= _ "Nearby allies (within a radius of 2) have a 20% chance to mitigate half the damage from physical attacks on defense."
    [/dummy]
#enddef
#define ABILITY_GUARDIAN_ANGEL2
    [dummy]
        id=guardianangel2
        name= _ "guardian angel"
        female_name= _ "female^guardian angel"
        description= _ "Nearby allies (within a radius of 2) have a 40% chance to mitigate half the damage from physical attacks on defense."
    [/dummy]
#enddef

#define GUARDIAN_ANGEL TYPE CHANCE FACTOR
    [event]
        name=attacker_hits
        first_time_only=no

        [filter_attack]
            type=blade,impact,pierce
        [/filter_attack]

        [store_unit]
            [filter]
                x,y=$x2,$y2
                [filter_location]
                    radius=2
                    [and]
                        [filter]
                            type={TYPE}
                            ability=guardianangel1,guardianangel2
                            side=$second_unit.side
                        [/filter]
                    [/and]
                [/filter_location]
            [/filter]
            variable=shielded
        [/store_unit]

        [set_variable]
            name=chance_to_heal
            rand=1..100
        [/set_variable]

        {VARIABLE heal_health $damage_inflicted}
        {VARIABLE_OP heal_health divide {FACTOR}}
        [if]
            [variable]
                name=second_unit.hitpoints
                greater_than=0
            [/variable]
            [and]
                [variable]
                    name=chance_to_heal
                    less_than_equal_to={CHANCE}
                [/variable]
            [/and]
            [then]
                [for]
                    array=shielded
                    [do]
                        [heal_unit]
                            [filter]
                                x,y=$shielded[$i].x,$shielded[$i].y
                            [/filter]
                            amount=$heal_health
                            animate=yes
                            restore_statuses=no
                        [/heal_unit]
                    [/do]
                [/for]
            [/then]
        [/if]
        {CLEAR_VARIABLE heal_health}
        {CLEAR_VARIABLE shielded}
        {CLEAR_VARIABLE chance_to_heal}
    [/event]
#enddef
#define ABILITY_SYLVAN_SPARK
    [regenerate]
        value=5
        id=sylvan_spark
        name= _ "sylvan spark"
        description= _ "While in vegetated terrains, the unit will heal itself 5 hp per turn. If it is poisoned, it will remove the poison instead of healing. Vegetated terrains are forest, great tree, farmland and mushroom grove hexes."
        name_inactive= _ "sylvan spark"
        description_inactive= _ "While in vegetated terrains, the unit will heal itself 5 hp per turn. If it is poisoned, it will remove the poison instead of healing. Vegetated terrains are forest, great tree, farmland and mushroom grove hexes."
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain=*^F*, *^Uf, *^Ufi, *^Gvs
            [/filter_location]
        [/filter_self]
        poison=cured
    [/regenerate]
#enddef

#define AMLA_HEALER_FAERIE
   {AMLA_OPTION_HEALERMELEE}
   {AMLA_OPTION_HEALERRANGED}
#enddef
#define AMLA_OPTION_HEALERMELEE
    [advancement]
        max_times=-1
        description=_"increased melee damage"
        image=attacks/touch-faerie.png
        id=amla_melee_healer
        strict_amla=yes
        [effect]
            apply_to=attack
            name=faerie touch
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_HEALERRANGED
    [advancement]
        max_times=-1
        description=_"stronger ranged attacks"
        image=attacks/entangle.png
        id=amla_ranged_healer
        strict_amla=yes
        [effect]
            apply_to=attack
            name=ensnare
            increase_damage=2
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=35%
        [/effect]
    [/advancement]
#enddef

#define WEAPON_SPECIAL_WHIPLASH
    [damage]
        id=whiplash
        name= _ "whiplash"
        name_inactive= _ "whiplash"
        description= _ "The pain resulting from this attack causes enemies to deal 15% less damage."
        description_inactive= _ "The pain resulting from this attack causes enemies to deal 15% less damage."
        apply_to=opponent
        multiply=0.85
    [/damage]
#enddef
#define WEAPON_SPECIAL_BLOOM
    [damage]
        id=bloom_display
        name= _ "bloom"
        name_inactive= _ "bloom"
        description= _ "This attack gains 1 damage for every adjacent allied unit."
        description_inactive= _ "This attack gains 1 damage for every adjacent allied unit."
        apply_to=self
        add=0
        [filter_self]
            [filter_adjacent]
                adjacent=n,ne,se,s,sw,nw
                count=1-6
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=bloom1
        name=
        apply_to=self
        add=1
        [filter_self]
            [filter_adjacent]
                adjacent=n,ne,se,s,sw,nw
                count=1
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=bloom2
        name=
        apply_to=self
        add=2
        [filter_self]
            [filter_adjacent]
                adjacent=n,ne,se,s,sw,nw
                count=2
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=bloom3
        name=
        apply_to=self
        add=3
        [filter_self]
            [filter_adjacent]
                adjacent=n,ne,se,s,sw,nw
                count=3
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=bloom4
        name=
        apply_to=self
        add=4
        [filter_self]
            [filter_adjacent]
                adjacent=n,ne,se,s,sw,nw
                count=4
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=bloom5
        name=
        apply_to=self
        add=5
        [filter_self]
            [filter_adjacent]
                adjacent=n,ne,se,s,sw,nw
                count=5
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=bloom6
        name=
        apply_to=self
        add=6
        [filter_self]
            [filter_adjacent]
                adjacent=n,ne,se,s,sw,nw
                count=6
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
#enddef

#define WEAPON_SPECIAL_BLOSSOM
    [attacks]
        id=blossom
        name= _ "blossom"
        description= _ "On offense, enemies cannot retaliate to this attack.

If this attack hits, the enemy loses 20% magic resistance for one turn.

If this attack misses, the enemy's defense is reduced by 20% for the remainder of the turn."
        value=0
        cumulative=no
        apply_to=opponent
        active_on=offense
    [/attacks]
#enddef

#define CHERRY_BLOSSOM
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special_id=blossom
        [/filter_attack]
        [object]
            [filter]
                x,y=$x2,$y2
            [/filter]
            take_only_once=no
            duration=turn
            silent=yes
            [effect]
                apply_to=resistance
                [resistance]
                    cold=20
                    fire=20
                    arcane=20
                [/resistance]
            [/effect]
        [/object]
    [/event]
    [event]
        name=attacker_misses
        first_time_only=no
        [filter_attack]
            special_id=blossom
        [/filter_attack]
        [object]
            [filter]
                x,y=$x2,$y2
            [/filter]
            take_only_once=no
            duration=turn
            silent=yes
            [effect]
                apply_to=defense
                [defense]
                    deep_water=20
                    shallow_water=20
                    reef=20
                    swamp_water=20
                    flat=20
                    sand=20
                    forest=20
                    hills=20
                    mountains=20
                    village=20
                    castle=20
                    cave=20
                    unwalkable=20
                    impassable=20
                    frozen=20
                    fungus=20
                [/defense]
            [/effect]
        [/object]
    [/event]
#enddef

#define ABILITY_BRIAR_ROSE
    [dummy]
        id=briar rose
        name= _ "briar rose"
        description= _ "This unit poisons all nearby enemy units on the start of every new turn. Additionally, enemies that strike this unit with melee attacks are poisoned."
    [/dummy]
#enddef

#define BRIAR_ROSE
    [event]
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                [filter_adjacent]
                    ability=briar rose
                    is_enemy=yes
                [/filter_adjacent]
            [/filter]
            variable=opp
        [/store_unit]

        [foreach]
            array=opp
            [do]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=0
                    poisoned=yes
                    delay=25
                [/harm_unit]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE opp}
    [/event]
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            range=melee
        [/filter_attack]
        [filter_second]
            ability=briar rose
        [/filter_second]
        [harm_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            fire_event=yes
            animate=yes
            amount=0
            poisoned=yes
            delay=25
        [/harm_unit]
    [/event]
#enddef

#define AMLA_YOUSEI
   {AMLA_OPTION_YOUSEIMELEE}
   {AMLA_OPTION_YOUSEIRANGED}
#enddef
#define AMLA_TSUBAKI
   {AMLA_OPTION_YOUSEIRADIANT}
   {AMLA_OPTION_YOUSEIVITAL}
   {AMLA_OPTION_YOUSEICHERRY}
#enddef
#define AMLA_OPTION_YOUSEIMELEE
    [advancement]
        max_times=-1
        description=_"increased melee damage"
        image=attacks/touch-faerie.png
        id=amla_melee_yousei
        strict_amla=yes
        [effect]
            apply_to=attack
            range=melee
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_YOUSEIRANGED
    [advancement]
        max_times=-1
        description=_"stronger ranged attacks"
        image=attacks/thorns.png
        id=amla_ranged_yousei
        strict_amla=yes
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_YOUSEIRADIANT
    [advancement]
        max_times=-1
        description=_"increases radiant bloom's damage"
        image=attacks/thorns.png
        id=amla_radiant_yousei
        strict_amla=yes
        [effect]
            apply_to=attack
            name=radiant bloom
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_YOUSEIVITAL
    [advancement]
        max_times=-1
        description=_"increases vitalizing bloom's damage"
        image=attacks/thorns.png
        id=amla_vitalizing_yousei
        strict_amla=yes
        [effect]
            apply_to=attack
            name=vitalizing bloom
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_YOUSEICHERRY
    [advancement]
        max_times=2
        description=_"increases cherry blossom's strikes"
        image=attacks/thorns.png
        id=amla_cherry_yousei
        strict_amla=yes
        [effect]
            apply_to=attack
            name=cherry blossom
            increase_attacks=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=100%
        [/effect]
    [/advancement]
#enddef

#define WEAPON_SPECIAL_PRECIPITOUS
    [chance_to_hit]
        id=precipitous
        name= _ "precipitous"
        description= _ "This attack always has a 30% chance to hit."
        value=30
        cumulative=no
    [/chance_to_hit]
#enddef

#define ABILITY_EQUILIBRIUM10
    [dummy]
        id=equilibrium_display
        name= _ "equilibrium"
        female_name= _ "female^equilibrium"
        description= _ "This unit reduces the negative effects of time of day by 10% on adjacent allied units.

Adjacent lawful units only receive a -15% damage penalty at night and adjacent chaotic units receive a -15% damage penalty during the day."
    [/dummy]
    [leadership]
        id=equilibrium10
        name=
        value=10
        cumulative=no
        affect_enemies=no
        [affect_adjacent]
            [filter]
                formula="alignment=lawful"
                [filter_location]
                    time_of_day=chaotic
                [/filter_location]
            [/filter]
        [/affect_adjacent]
        [affect_adjacent]
            [filter]
                formula="alignment=chaotic"
                [filter_location]
                    time_of_day=lawful
                [/filter_location]
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_EQUILIBRIUM15
    [dummy]
        id=equilibrium_display
        name= _ "equilibrium"
        female_name= _ "female^equilibrium"
        description= _ "This unit reduces the negative effects of time of day by 15% on adjacent allied units.

Adjacent lawful units only receive a -10% damage penalty at night and adjacent chaotic units receive a -10% damage penalty during the day."
    [/dummy]
    [leadership]
        id=equilibrium15
        name=
        value=15
        cumulative=no
        affect_enemies=no
        [affect_adjacent]
            [filter]
                formula="alignment=lawful"
                [filter_location]
                    time_of_day=chaotic
                [/filter_location]
            [/filter]
        [/affect_adjacent]
        [affect_adjacent]
            [filter]
                formula="alignment=chaotic"
                [filter_location]
                    time_of_day=lawful
                [/filter_location]
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_EQUILIBRIUM25
    [dummy]
        id=equilibrium_display
        name= _ "equilibrium"
        female_name= _ "female^equilibrium"
        description= _ "This unit reduces the negative effects of time of day by 25% on adjacent allied units.

Adjacent lawful units receive no damage penalty at night and adjacent chaotic units receive no damage penalty during the day."
    [/dummy]
    [leadership]
        id=equilibrium25
        name=
        value=25
        cumulative=no
        affect_enemies=no
        [affect_adjacent]
            [filter]
                formula="alignment=lawful"
                [filter_location]
                    time_of_day=chaotic
                [/filter_location]
            [/filter]
        [/affect_adjacent]
        [affect_adjacent]
            [filter]
                formula="alignment=chaotic"
                [filter_location]
                    time_of_day=lawful
                [/filter_location]
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define AMLA_ARBITER
   {AMLA_OPTION_ARBITERMELEE}
   {AMLA_OPTION_ARBITERWHITE}
   {AMLA_OPTION_ARBITERBLACK}
#enddef
#define AMLA_OPTION_ARBITERMELEE
    [advancement]
        max_times=-1
        description=_"increased melee damage"
        image=attacks/magic-missile.png
        id=amla_melee_arbiter
        strict_amla=yes
        [effect]
            apply_to=attack
            range=melee
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_ARBITERWHITE
    [advancement]
        max_times=-1
        description=_"increases white lotus's damage"
        image=attacks/thorns.png
        id=amla_arbiter_white
        strict_amla=yes
        [effect]
            apply_to=attack
            name=white lotus
            increase_damage=1
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=35%
        [/effect]
    [/advancement]
#enddef
#define AMLA_OPTION_ARBITERBLACK
    [advancement]
        max_times=-1
        description=_"increases black lotus's damage"
        image=attacks/thorns.png
        id=amla_arbiter_black
        strict_amla=yes
        [effect]
            apply_to=attack
            name=black lotus
            increase_damage=2
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
    [/advancement]
#enddef


#textdomain wesnoth-Genesis

#define WEAPON_SPECIAL_PIERCE
    [dummy]
        id=pierce
        name= _ "pierce"
        name_inactive= _ "pierce"
        description= _ "This attack temporarily reduces physical resistance by 5% on hit."
        description_inactive= _ "This attack temporarily reduces physical resistance by 5% on hit."
    [/dummy]
#enddef
#define PIERCE WEAPON
    [event]
		id=pierce handler1
        name=attacker hits
        first_time_only=no
        [filter_attack]
			name={WEAPON}
			special_id=pierce
        [/filter_attack]
		[object]
			[filter]
				x,y=$x2,$y2
			[/filter]
			take_only_once=no
			duration=turn
			silent=yes
			[effect]
				apply_to=resistance
				[resistance]
					blade=5
					pierce=5
					impact=5
				[/resistance]
			[/effect]
		[/object]
	[/event]
    [event]
		id=pierce handler2
        name=defender hits
        first_time_only=no
        [filter_second_attack]
			name={WEAPON}
			special_id=pierce
        [/filter_second_attack]
		[object]
			[filter]
				x,y=$x1,$y1
			[/filter]
			take_only_once=no
			duration=turn
			silent=yes
			[effect]
				apply_to=resistance
				[resistance]
					blade=5
					pierce=5
					impact=5
				[/resistance]
			[/effect]
		[/object]
	[/event]
#enddef

#define ABILITY_BLITZ2
    [dummy]
        id=blitz2
        name= _ "blitz"
        description= _"This unit can attack twice in one turn."
    [/dummy]
#enddef

#define BLITZ2
	[event]
		name=new turn
		first_time_only=no
		[if]
			[have_unit]
				ability=blitz2
			[/have_unit]
			[then]
				[modify_unit]
					[filter]
						ability=blitz2
					[/filter]
					max_attacks=2
					attacks_left=2
				[/modify_unit]
			[/then]
		[/if]
	[/event]
	[event]
		name=attack_end
		first_time_only=no
		[filter]
			ability=blitz2
			x,y=$x1,$y1
		[/filter]
		[if]
			[have_unit]
				ability=blitz2
			[/have_unit]
			[then]
				[modify_unit]
					[filter]
						ability=blitz2
					[/filter]
					moves=5
				[/modify_unit]
			[/then]
		[/if]
	[/event]
#enddef


#textdomain wesnoth-Genesis

#define WEAPON_SPECIAL_DRAIN70
    [drains]
        id=drain70
        value=70
        name= _ "siphon"
        description= _ "This attack draws out small amounts of energy from the enemies it harms."
    [/drains]
#enddef

#define WEAPON_SPECIAL_DRAIN40
    [drains]
        id=drain40
        value=40
        name= _ "siphon"
        description= _ "This attack draws out small amounts of energy from the enemies it harms."
    [/drains]
#enddef

#define WEAPON_SPECIAL_DRAIN30
    [drains]
        id=drain30
        value=30
        name= _ "siphon"
        description= _ "This attack draws out small amounts of energy from the enemies it harms."
    [/drains]
#enddef
#define ABILITY_NIGHT_HUNTER
    [skirmisher]
        id=night_hunter_skirmish
        name= _ "night hunter"
        description= _ "This unit ignores enemy zones of control and gains an additional 30% damage at night."
        affect_self=yes
        [filter_self]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
        [/filter_self]
    [/skirmisher]
    [leadership]
        id=night_hunter_dmg
        value=30
        cumulative=yes
        affect_self=yes
        [filter_self]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
        [/filter_self]
    [/leadership]
#enddef
#define ABILITY_VOID_WARDEN
    [resistance]
        id=void_warden_resist
        add=10
        max_value=90
        name= _ "void warden"
        description= _ "This unit heals 6 HP and gains +10% to all resistances (up to 90%) at night."
        affect_self=yes
        affect_allies=no
        affect_enemies=no
        [filter_self]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
        [/filter_self]
    [/resistance]
    [regenerate]
        id=void_warden_regen
        value=6
        affect_self=yes
        [filter_self]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
        [/filter_self]
        poison=cured
    [/regenerate]
#enddef
#define ABILITY_CLARITY
    [resistance]
        id=clarity
        sub=10
        max_value=90
        apply_to=cold,arcane
        name= _ "clarity"
        female_name= _ "female^clarity"
        description= _ "This unit reduces nearby enemies' cold and arcane resistances by 10% at level 3, 20% at level 4, and 30% at level 5."
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                [filter_adjacent]
                    ability=clarity
                    level=3
                [/filter_adjacent]
            [/filter]
        [/affect_adjacent]
    [/resistance]
    [resistance]
        id=clarity
        sub=20
        max_value=90
        apply_to=cold,arcane
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                [filter_adjacent]
                    ability=clarity
                    level=4
                [/filter_adjacent]
            [/filter]
        [/affect_adjacent]
    [/resistance]
    [resistance]
        id=clarity
        sub=30
        max_value=90
        apply_to=cold,arcane
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            [filter]
                [filter_adjacent]
                    ability=clarity
                    level=5,6,7,8,9,10
                [/filter_adjacent]
            [/filter]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/resistance]
#enddef
#define ABILITY_CLAIRVOYANCE
    [teleport]
        id=clairvoyance
        name= _ "clairvoyance"
        female_name= _ "female^clairvoyance"
        description= _ "This unit may teleport to allied units."
        [tunnel]
            id=clairvoyance
            [source]
                terrain=*
            [/source]
            [filter]
                ability=clairvoyance
            [/filter]
            [target]
                [filter_adjacent_location]
                    [filter]
                        side=$teleport_unit.side
                    [/filter]
                [/filter_adjacent_location]
            [/target]
        [/tunnel]
    [/teleport]
#enddef


#textdomain wesnoth-Genesis

#define CAMPAIGN_INTRO_HEADER
    title="!" # wmllint: ignore
    title_alignment=center
    show_title=yes
#enddef

#define CAMPAIGN_INTRO_PADDING
    "

" #enddef

#define CAMPAIGN_INTRO_WARNING_TITLE
    ""+
    _ "Warning!"+"

" #enddef

# wmlindent: start ignoring
#define CAMPAIGN_INTRO_GAMEPLAY_WARNING
    _ "Many scenarios of this campaign work significantly different from normal Wesnoth gameplay. It is especially important to pay close attention to the mission objectives and not necessarily try to kill every single enemy, especially on shrouded maps, or in places where enemies seem to respawn continuously." #enddef

#define CAMPAIGN_INTRO_CONTENT_WARNING
    _ "This campaign is the prequel to Invasion from the Unknown and After the Storm. It may be useful, but is not necessary to play these campaigns before playing Genesis. You should complete the first episode of Genesis before playing this episode." #enddef

#define CAMPAIGN_INTRO_OPTIONS_WARNING
    _ "A game screen resolution of 800x600 or greater is recommended. Some sequences make use of floating labels, halos, and standing unit animations, so you might want to make sure these options are enabled under Preferences ? Display." #enddef

#define STORYTXT_TITLE_CARD _ID _MAIN_TITLE _ALTERNATE_TITLE
    title={_MAIN_TITLE}+" ("+{_ALTERNATE_TITLE}+")
"+{_ID}+""
#enddef

#define STORYTXT_TITLE_CARD_SIMPLE _ID _MAIN_TITLE
    title={_MAIN_TITLE}+"
"+{_ID}+""
#enddef

#define STORYTXT_CAPTION _TEXT
    ""+{_TEXT}+"

" #enddef

#define STORYTXT_INIT_WARNING
    [story]
        [part]
            music="data/core/sounds/ambient/wardrums.ogg"

            {CAMPAIGN_INTRO_HEADER}

            story={CAMPAIGN_INTRO_WARNING_TITLE}+{CAMPAIGN_INTRO_GAMEPLAY_WARNING}+{CAMPAIGN_INTRO_PADDING}+{CAMPAIGN_INTRO_CONTENT_WARNING}
        [/part]
        [part]

            {CAMPAIGN_INTRO_HEADER}

            story= _ "The "hard" difficulty setting is intended to present a challenge to experienced players. The other difficulty settings should be reasonable for newer players."
        [/part]
    [/story]
#enddef

#define STORYTXT_ETHEA
    [story]
		[switch]
			variable=prev_scenario
			[case]
				value="none"

				[part]
					story={STORYTXT_CAPTION ( _ "Esther")} + _ "..."
				[/part]
			[/case]
			[case]
				value="White City"
				[part]
					story={STORYTXT_CAPTION ( _ "Esther")} + _ "So we need Aryel for something, at least. Not really a surprise, since she's been living up here for a while and knows these parts better than I do. I'm also surprised the humans let us get close to that place. Usually, they're not terribly friendly to the faerie, even if we're not really enemies. They're just scared because faeries tend to be really strong compared to them. And if they knew what we were..."
				[/part]
				[part]
					story={STORYTXT_CAPTION ( _ "Esther")} + _ "Well, I digress. If we go back, we'll just have to make sure that we don't do anything silly. I'd hate to have to fight the humans, especially with the demons being a threat."
				[/part]
			[/case]
			[case]
				value="Glacial Shrine"
				[part]
					story={STORYTXT_CAPTION ( _ "Esther")} + _ "We tried to be helpful, but obviously we couldn't tell the humans too much. Can't let them get dragged into those kind of issues, or they'll all be killed. We talked about what we had learned a little bit, but ultimately it wasn't anything too new, except for the few inscriptions on the last glyph. Those were really different, but we can't really make any assumptions based on those yet, not without more information."
				[/part]
				[part]
					story={STORYTXT_CAPTION ( _ "Esther")} + _ "Surprisingly, though, the general allowed some of his men to follow us. I guess it would get boring just staying in that fort for weeks, especially with nothing but snow and ice around them. The extra help should be useful, but of course, this means that we'll have to be careful not to give them any hints that we're not normal faerie."
				[/part]
			[/case]
			[case]
				value="Black Cauldron"
				[part]
					story={STORYTXT_CAPTION ( _ "Aryel")} + _ "Yumi's the youngest of us by quite a bit. I think she's probably only a few decades old. Okay, so I'm not that much older, but it's just the way she acts. She just seems so... so shy. I don't know what to make of it. It always feels like she's hiding something from us. Is it just because she's afraid? It's not like we're out to get her. Yes, I tease her sometimes, but she knows we won't hurt her. It just doesn't make sense."
				[/part]
				[part]
					story={STORYTXT_CAPTION ( _ "Aryel")} + _ "Maybe I don't have a right to be worried. Esther's been taking care of her just fine, anyway. Right now, the demons are the bigger issue..."
				[/part]
			[/case]
		[/switch]
    [/story]
#enddef


#textdomain wesnoth-Genesis

[scenario]
    id=00_Cutscene
    map_data="{~add-ons/Genesis/episode1/maps/01_Ash.map}"
    turns=-1
    #theme=Cutscene_Minimal
    victory_when_enemies_defeated=no
    next_scenario=01_Eventide_Song

	#{STORYTXT_INIT_WARNING}
	#{LIMBO}
	{ETERNALDARK}

    [side]
        type=Amberlight Fae
        variation=AF3
        name= _ "Esther"
        id=Esther
        facing=se
        [modifications]
            {TRAIT_FEARLESS}
        [/modifications]
        # profile=portraits/esther.png
        canrecruit=yes
        unrenamable=yes
        side=1
        controller=human
        recruit=
		fog=yes
		shroud=yes
        team_name=fae
        user_team_name= _ "team_name^Fae"
    [/side]

    [side]
        side=2
        no_leader=yes
        team_name=demons
        controller=ai
        color=black
        fog=no
        shroud=no
        hidden=yes
    [/side]

    [event]
        name=prestart

        #{FADE_SCREEN}
        [store_unit]
            [filter]
                id=Esther
            [/filter]
            variable=esther
        [/store_unit]
        [kill]
            id=Esther
        [/kill]
        [modify_side]
            side=1
            shroud=yes
        [/modify_side]
        [place_shroud]
            side=1
            x=1-50
            y=1-21
        [/place_shroud]
        [refresh_spell_menu]
            enable=1
        [/refresh_spell_menu]

        [initialize_spells][/initialize_spells]
        [yumi_spell_setup][/yumi_spell_setup]
        [aryel_spell_setup][/aryel_spell_setup]
        [esther_spell_setup][/esther_spell_setup]

		[add_siphon_yumi][/add_siphon_yumi]
		[add_void_blast_yumi][/add_void_blast_yumi]
		[add_ethereal_form_yumi][/add_ethereal_form_yumi]
		[add_astral_blood_yumi][/add_astral_blood_yumi]
		[add_null_flare_yumi][/add_null_flare_yumi]
		[add_shadow_walk_yumi][/add_shadow_walk_yumi]

		[add_infuse_aryel][/add_infuse_aryel]
		[add_malefice_aryel][/add_malefice_aryel]
		[add_blood_bind_aryel][/add_blood_bind_aryel]
		[add_harvest_soul_aryel][/add_harvest_soul_aryel]
		[add_eldritch_bolt_aryel][/add_eldritch_bolt_aryel]

		[add_firebolt_esther][/add_firebolt_esther]
		[add_sunlight_spark_esther][/add_sunlight_spark_esther]
		[add_ember_spear_esther][/add_ember_spear_esther]
		[add_ardent_flare_esther][/add_ardent_flare_esther]
		[add_blazing_star_esther][/add_blazing_star_esther]
		[add_lightning_bolt_esther][/add_lightning_bolt_esther]
    [/event]

    [event]
        name=start

        #{UNFADE_SCREEN}
        [unstore_unit]
            variable=esther
        [/unstore_unit]
        [unhide_unit]
            [filter][/filter]
        [/unhide_unit]
        {CLEAR_VARIABLE esther}

        {REPLACE_SCENARIO_MUSIC underground.ogg}

        [unit]
            side=1
            type=Dusk Fae
            variation=DF3
            canrecruit=yes
            x,y=9,7
            name= _ "Yumi"
            id=Yumi
            unrenamable=yes
            # profile=portraits/yumi.png
            animate=no
        [/unit]

		[unit]
            side=1
            type=Crimson Fae
            variation=CF3
            canrecruit=yes
            x,y=9,7
            name= _ "Aryel"
            id=Aryel
            unrenamable=yes
            # profile=portraits/aryel.png
            animate=no
        [/unit]

    [/event]
	[event]
		name=done

		[endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 100}
            replay_save=no
            carryover_report=no
            linger_mode=no
            next_scenario=01_Eventide_Song
        [/endlevel]
	[/event]
[/scenario]


#textdomain wesnoth-Genesis

[scenario]
    id=01_Eventide_Song
    map_data="{~add-ons/Genesis/episode2/maps/01_Eventide_Song.map}"
	name= _ "Eventide Song"
    turns=-1
    #theme=Cutscene
    victory_when_enemies_defeated=no
    next_scenario=02_Ethea

	{LIMBO}
	{SCENARIO_MUSIC "silence.ogg"}

    [side]
        type=Amberlight Fae
        variation=AF3
        name= _ "Esther"
        id=Esther
        facing=se
        [modifications]
            {TRAIT_FEARLESS}
        [/modifications]
        # profile=portraits/esther.png
        canrecruit=yes
        unrenamable=yes
        side=1
        controller=human
        recruit=
		fog=yes
		shroud=yes
        team_name=fae
        user_team_name= _ "team_name^Fae"
    [/side]

    [side]
        side=2
        no_leader=yes
        team_name=fae
        controller=ai
        color=black
        fog=no
        shroud=no
        hidden=yes
    [/side]

    [event]
        name=prestart

        {FADE_SCREEN}
        [store_unit]
            [filter]
                id=Esther
            [/filter]
            variable=esther
        [/store_unit]
        [kill]
            id=Esther
        [/kill]
		[store_unit]
            [filter]
                id=Aryel
            [/filter]
            variable=aryel
        [/store_unit]
        [kill]
            id=Aryel
        [/kill]
        [modify_side]
            side=1
            shroud=yes
        [/modify_side]
    [/event]

    # PUZZLE 1, make Yumi a cup of tea using flowers and holy water
    # grow the flower, add the flower seeds (flower terrain) to sunlight
    # heat the water first
    # then add the flower to the water

    # PUZZLE 2, fruit popsicle
	# get some fresh fruit from the first area, probably strawberries
	# take it to the "blender" to mash it up nicely
	# then take it to the "freezer" to turn it into a popsicle

    # PUZZLE 3, create some bread for Yumi
	# there is a windmill near a whirlpool, but it isn't moving
	# you need to first light a fire using the sceptre of fire and an unlit brazier
	# then place the fire into the whirlpool, and voila, you have steam to power the windmill
	# then put the grain in the windmill and you're good to go

    # PUZZLE 4, make some pudding
	# light the fire to a pot
	# add the milk
	# add the eggs
	# add the chocolate, vanilla, and sugar (any order, vanilla can be flower3 or flower4)
	# rest of the stuff needs to get drawn

	[event]
		name=preload
		first_time_only=no

		[lua]
			code = << wesnoth.dofile('~add-ons/Genesis/episode2/lua/scenarios/01_Eventide_Song.lua') >>
		[/lua]
	[/event]

    [event]
        name=start

		[unit]
            side=1
            type=Dusk Fae
            variation=DF3
            canrecruit=yes
            x,y=10,5
            name= _ "Yumi"
            id=Yumi
            unrenamable=yes
            # profile=portraits/yumi.png
            animate=no
        [/unit]
		[redraw]
			side=1
			clear_shroud=yes
		[/redraw]

        {UNFADE_SCREEN}
        [unhide_unit]
            [filter][/filter]
        [/unhide_unit]

		[swap_starting_terrain][/swap_starting_terrain]
		[initialize_sound_puzzle][/initialize_sound_puzzle]

		#ifdef EASY
			[set_variable]
				name=large_puzzle_exp
				value=40
			[/set_variable]
			[set_variable]
				name=small_puzzle_exp
				value=25
			[/set_variable]
		#endif
		#ifdef NORMAL
			[set_variable]
				name=large_puzzle_exp
				value=30
			[/set_variable]
			[set_variable]
				name=small_puzzle_exp
				value=20
			[/set_variable]
		#endif
		#ifdef HARD
			[set_variable]
				name=large_puzzle_exp
				value=20
			[/set_variable]
			[set_variable]
				name=small_puzzle_exp
				value=10
			[/set_variable]
		#endif

		[objectives]
			{OBJECTIVE_VICTORY  ( _ "Solve the puzzle")}
		[/objectives]
    [/event]

    ######### SOUND PUZZLE ###########
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=10
            y=7
        [/filter]
		[filter_condition]
			[variable]
				name=puzzle_sound.complete
				numerical_equals=0
			[/variable]
		[/filter_condition]
		[message]
			speaker=narrator
			message= _ "Wind flows on high in the open sky.
Through parted clouds, barest light glimmers
Where streaming water rushes ceaselessly
Into the eternal march of time.
Alone, fallen leaves borne upon the silent gale,
They drift aimlessly into day and night,
Voices muted by the aetherial gyre.
Atop the peak and in the deep valley
Terra's breath stirs to life,
Carried through the blue heavens,
Gracing violet eyes with bright color.
Lips part and she sings
A trio of notes, low to high,
And she fades once more
Into the timless flow of wind."
		[/message]
	[/event]

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=10
            y=3
        [/filter]
        [sound_hex_one][/sound_hex_one]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=8
            y=3
        [/filter]
        [sound_hex_two][/sound_hex_two]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=12
            y=3
        [/filter]
        [sound_hex_three][/sound_hex_three]
    [/event]

    [event]
        name=transition

        {REPLACE_SCENARIO_MUSIC wind.ogg}
        {APPEND_MUSIC           wanderer.ogg}

		[objectives]
			{OBJECTIVE_VICTORY  ( _ "Explore")}
		[/objectives]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Yumi
        [/filter]
        {MODIFY_UNIT (id=Yumi) moves 10}
    [/event]

	######### EARTH PUZZLE ###########
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=15
            y=10
        [/filter]
		[filter_condition]
			[variable]
				name=puzzle_earth.complete
				numerical_equals=0
			[/variable]
		[/filter_condition]
		[message]
			speaker=narrator
			message= _ "Children of earth, their tiny seeds burrow in the soil.
Sunlight graces their subterranean homes and their mauve leaves blossom.
The fire is lit, the water boils,
And the fragrance of lavender perfuses the air."
		[/message]
	[/event]

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=10
            y=9
        [/filter]

		[puzzle_earth_flower_hex][/puzzle_earth_flower_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=13
            y=9
        [/filter]

		[puzzle_earth_sunlight_hex][/puzzle_earth_sunlight_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=14
            y=6
        [/filter]

		[puzzle_earth_water_hex][/puzzle_earth_water_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=18
            y=9
        [/filter]

		[puzzle_earth_fire_hex][/puzzle_earth_fire_hex]
	[/event]

	######### ICE PUZZLE ###########

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=43
            y=15
        [/filter]
		[filter_condition]
			[variable]
				name=puzzle_ice.complete
				numerical_equals=0
			[/variable]
		[/filter_condition]
		[message]
			speaker=narrator
			message= _ "Ruby red crowned with emerald green, the strawberry lies in ice.
Chopped quickly, then frozen,
A sweet and tasty treat awaits."
		[/message]
	[/event]

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=46
            y=12
        [/filter]

		[puzzle_ice_fruit_hex][/puzzle_ice_fruit_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=44
            y=3
        [/filter]

		[puzzle_ice_blender_hex][/puzzle_ice_blender_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=55-58
            y=5-9
        [/filter]

		[puzzle_ice_freezer_hexes][/puzzle_ice_freezer_hexes]
	[/event]

	######### WATER/FIRE PUZZLE ###########

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=31
            y=45
        [/filter]
		[filter_condition]
			[variable]
				name=puzzle_water_fire.complete
				numerical_equals=0
			[/variable]
		[/filter_condition]
		[message]
			speaker=narrator
			message= _ "The whirling fan lies still over swirling waters.
Fire lights the darkness amidst the black sea.
Churning and chruning, the mill springs to life,
A touch of grain is ground to fresh bread."
		[/message]
	[/event]

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=3
            y=50
        [/filter]

		[puzzle_water_fire_scepter_hex][/puzzle_water_fire_scepter_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=9
            y=46
        [/filter]

		[puzzle_water_fire_brazier_hex][/puzzle_water_fire_brazier_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=28
            y=47
        [/filter]

		[puzzle_water_fire_whirlpool_hex][/puzzle_water_fire_whirlpool_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=24
            y=44
        [/filter]

		[puzzle_water_fire_grain_hex][/puzzle_water_fire_grain_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=29
            y=47
        [/filter]

		[puzzle_water_fire_windmill_hex][/puzzle_water_fire_windmill_hex]
	[/event]

	######### LIFE PUZZLE ###########

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=24
            y=27
        [/filter]
		[filter_condition]
			[variable]
				name=puzzle_life.complete
				numerical_equals=0
			[/variable]
		[/filter_condition]
		[message]
			speaker=narrator
			message= _ "Milk and eggs over gentle heat,
Sharp vanilla mellows into sweet fragrance.
Chocolate and sugar melt in,
She stirs with slow strokes,
The taste of fresh pudding brings her senses to life."
		[/message]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=22
            y=26
        [/filter]

		[puzzle_life_fire_hex][/puzzle_life_fire_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=23
            y=26
        [/filter]

		[puzzle_life_brazier_hex][/puzzle_life_brazier_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=11
            y=27
        [/filter]

		[puzzle_life_milk_hex][/puzzle_life_milk_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=30
            y=24
        [/filter]

		[puzzle_life_eggs_hex][/puzzle_life_eggs_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=35
            y=30
        [/filter]

		[puzzle_life_chocolate_hex][/puzzle_life_chocolate_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=13
            y=30
        [/filter]

		[puzzle_life_vanilla_hex][/puzzle_life_vanilla_hex]
	[/event]
	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=21
            y=34
        [/filter]

		[puzzle_life_sugar_hex][/puzzle_life_sugar_hex]
	[/event]

	[event]
        name=moveto
        first_time_only=no
        [filter]
            x=44
            y=37
        [/filter]

		[endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 100}
            replay_save=no
            carryover_report=no
            linger_mode=no
            next_scenario=02_Ethea
        [/endlevel]
	[/event]

	[event]
		name=victory

		[unstore_unit]
			variable=esther
			x,y=1,1
		[/unstore_unit]
		{CLEAR_VARIABLE esther}
		[unstore_unit]
			variable=aryel
			x,y=1,2
		[/unstore_unit]
		{CLEAR_VARIABLE aryel}

		[set_ethea_variables]
		[/set_ethea_variables]
	[/event]

    [event]
		name=done

		[endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 100}
            replay_save=no
            carryover_report=no
            linger_mode=no
            next_scenario=02_Ethea
        [/endlevel]
	[/event]
[/scenario]


#textdomain wesnoth-Genesis

[scenario]
    id=02_Ethea
    map_data="{~add-ons/Genesis/episode2/maps/02_Ethea.map}"
    name= _ "Ethea"
    turns=-1
    theme=Cutscene
    victory_when_enemies_defeated=no
    next_scenario=03g_Amberlight_Shrine

    {DEFAULT_SCHEDULE}

    [side]
        type=Amberlight Fae
        name= _ "Esther"
        id=Esther
        canrecruit=yes
        side=1
        controller=human
        recruit=
        gold=0
        income=-2
        team_name=fae
        user_team_name= _ "team_name^Fae"
    [/side]

    [side]
        side=2
        no_leader=yes
        controller=ai
        color=yellow
        fog=no
        shroud=no
        recruit=
        gold=0
        income=-2
        team_name=fae
        user_team_name= _ "team_name^Demons"
    [/side]

    [side]
        side=3
        no_leader=yes
        controller=ai
        color=blue
        fog=no
        shroud=no
        recruit=
        gold=0
        income=-2
        team_name=critters
        hidden=yes
    [/side]

    # scenarios
    # Mirror lake (puzzle where you get ethereal form for Yumi, a Valdir scenario)
    # echo caverns (ice chamber where you see lots of copies of yourself, Yukiria scenario)
    # Bells of Aerlyn (village in a valley, the bells atop the hill held by rogue demons and no longer ring (mini-boss battle)) (after you finish this, you can play with the bells on the map)
    # Devil's Gorge (first incident of rogue demons, first recruiting scenario)
    # Shardia's light (atop the high mountain, Shardia's light has gone out, figure out how to fix it and get esther's sunlight spark spell, puzzle + valdemon beast)

    # ethea minigames
    # villager wants a vampire bat as a pet, catch one by killing it (it spawns at night, so you need to end turn)
    # the dirty river (river goes by a void hex and turns dirty, so you need to put a rock to block the way and make the river go around it)
    # the scorpion pit (help a demoness feed her pet scorpions by attracting flies with a scone)
    # ice fishing (help an old man catch some fish, you need to go to the thin ice, then heat it with some fire)
    # the big sundial in the temple (aligned at midnight, opens the way into the ancient temple, where you get a buff to your magic)
    # chicken queen will give yumi an egg to improve her HP a tiny bit

    # Uria's shrine (exit)

    [event]
        name=preload
        first_time_only=no

        [lua]
            code = << wesnoth.dofile('~add-ons/Genesis/episode2/lua/scenarios/02_Ethea.lua') >>
        [/lua]
        [initialize_puzzles][/initialize_puzzles]
    [/event]

    [event]
        name=prestart

        [label]
            x,y=54,22
            text = _ "Mirror Lake"
        [/label]
        [label]
            x,y=23,27
            text = _ "Aerlyn"
        [/label]
        [label]
            x,y=27,3
            text = _ "Canyon"
        [/label]
        [label]
            x,y=15,15
            text = _ "Shrine"
        [/label]
        [label]
            x,y=4,21
            text = _ "Echo Caverns"
        [/label]
        [label]
            x,y=35,17
            text = _ "Firefly Summit"
        [/label]

        [switch]
            variable=ethea.prev_scenario
            [case]
                value="Mirror Lake"
                [move_unit]
                    id=Esther
                    to_x,to_y=54,22
                [/move_unit]
            [/case]
            [case]
                value="Echo Vale"
                [move_unit]
                    id=Esther
                    to_x,to_y=6,20
                [/move_unit]
            [/case]
            [case]
                value="Devil Gorge"
                [move_unit]
                    id=Esther
                    to_x,to_y=24,4
                [/move_unit]
            [/case]
            [case]
                value="The Bells of Aerlyn"
                [move_unit]
                    id=Esther
                    to_x,to_y=17,24
                [/move_unit]
            [/case]
            [case]
                value="Firefly Summit"
                [move_unit]
                    id=Esther
                    to_x,to_y=35,17
                [/move_unit]
            [/case]
        [/switch]
        [set_recruit]
            side=1
            recruit=
        [/set_recruit]
#ifdef EASY
        {VARIABLE puzzle_exp 30}
#endif
#ifdef NORMAL
        {VARIABLE puzzle_exp 25}
#endif
#ifdef HARD
        {VARIABLE puzzle_exp 20}
#endif
        {PLACE_IMAGE scenery/rune3.png 45 9}
        {PLACE_IMAGE scenery/rune4.png 45 14}
    [/event]

    [event]
        name=start

        {REPLACE_SCENARIO_MUSIC underground.ogg}

        [switch]
            variable=ethea.prev_scenario
            [case]
                value="Mirror Lake"
                {RECALL_YUMI 53 22}
                {RECALL_ARYEL 54 21}
            [/case]
            [case]
                value="Echo Vale"
                {RECALL_YUMI 5 21}
                {RECALL_ARYEL 5 20}
            [/case]
            [case]
                value="Devil Gorge"
                {RECALL_YUMI 24 5}
                {RECALL_ARYEL 23 5}
            [/case]
            [case]
                value="The Bells of Aerlyn"
                {RECALL_YUMI 17 25}
                {RECALL_ARYEL 18 24}
            [/case]
            [case]
                value="Firefly Summit"
                {RECALL_YUMI 34 17}
                {RECALL_ARYEL 35 18}
            [/case]
            [case]
                value="none"
                {RECALL_YUMI 19 16}
                {RECALL_ARYEL 20 15}
            [/case]
        [/switch]

        [objectives]
            {OBJECTIVE_VICTORY  ( _ "Explore")}
            {OBJECTIVE_NOTE ( _ "Go to the shrine if you are finished exploring the map.")}
        [/objectives]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Aryel
        [/filter]
        {MODIFY_UNIT (id=Aryel) moves 10}
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Esther
        [/filter]
        {MODIFY_UNIT (id=Esther) moves 10}
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Yumi
        [/filter]
        {MODIFY_UNIT (id=Yumi) moves 10}
    [/event]

    ######### MIRROR LAKE ###########

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=43
            y=15
        [/filter]

    [/event]

    ######### BAT LADY ###########

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=27
            y=13
        [/filter]

        [if]
            [not]
                [have_unit]
                    id=Ebitta
                [/have_unit]
            [/not]
            [then]
                [unit]
                    id=Ebitta
                    name= _ "Ebitta"
                    type=Demon
                    gender=female
                    side=2
                    x,y=26,12
                    unrenamable=yes
                [/unit]
            [/then]
        [/if]
        [if]
            [variable]
                name=ethea.bat
                numerical_equals=2
            [/variable]
            [then]
                [move_unit]
                    id=Eksi
                    to_x,to_y=26,12
                [/move_unit]
            [/then]
        [/if]
        [bat_dialogue_hex][/bat_dialogue_hex]
    [/event]
    [event]
        name=new turn
        first_time_only=no
        [filter_condition]
            [have_location]
                time_of_day_id=dusk
            [/have_location]
            [not]
                [have_unit]
                    id=Eksi
                [/have_unit]
            [/not]
        [/filter_condition]

        [if]
            [variable]
                name=ethea.bat
                numerical_equals=1
            [/variable]
            [then]
                [store_locations]
                    variable=locs
                    x=27-30,29-31,31-32,32-38
                    y=15-17,14-15,12-14,11-13
                [/store_locations]
                [set_variable]
                    name=ind
                    rand=0..39
                [/set_variable]
                [unit]
                    id=Eksi
                    name= _ "Eksi"
                    type=Blood Bat
                    side=2
                    x,y=$locs[$ind].x,$locs[$ind].y
                    unrenamable=yes
                [/unit]
                {CLEAR_VARIABLE locs}
                {CLEAR_VARIABLE ind}
            [/then]
        [/if]
    [/event]
    [event]
        name=moveto

        [filter]
            side=1
            [filter_adjacent]
                id=Eksi
            [/filter_adjacent]
        [/filter]
        [message]
            speaker=Eksi
            message= _ "Neep!"
        [/message]
        [message]
            speaker=Aryel
            message= _ "Looks like we found that bat."
        [/message]
        {VARIABLE ethea.bat 2}
    [/event]

    ######### SCORPION LADY ###########

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=8
            y=3
        [/filter]

        [if]
            [not]
                [have_unit]
                    id=Mika
                [/have_unit]
            [/not]
            [then]
                [unit]
                    id=Mika
                    name= _ "Mika"
                    type=Demon Berserker
                    profile=unit_image
                    gender=female
                    side=2
                    x,y=8,3
                    unrenamable=yes
                [/unit]
            [/then]
        [/if]

        [scorpion_dialogue_hex][/scorpion_dialogue_hex]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=15
            y=2
        [/filter]

        [scorpion_sconce_hex][/scorpion_sconce_hex]
    [/event]

    ######### CHICKEN LADY ###########

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=27
            y=26
        [/filter]

        [if]
            [not]
                [have_unit]
                    id=Kadishi
                [/have_unit]
            [/not]
            [then]
                [unit]
                    id=Kadishi
                    name= _ "Kadishi"
                    type=Demon Windlasher
                    profile=unit_image
                    gender=female
                    side=2
                    x,y=27,26
                    unrenamable=yes
                [/unit]
            [/then]
        [/if]

        [chicken_dialogue_hex][/chicken_dialogue_hex]
    [/event]

    ######### FISHERMAN ###########

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=56
            y=29
        [/filter]

        [if]
            [not]
                [have_unit]
                    id=Xlzyx
                [/have_unit]
            [/not]
            [then]
                [unit]
                    id=Xlzyx
                    name= _ "Xlzyx"
                    type=Demon Sword Dancer
                    profile=unit_image
                    gender=male
                    side=2
                    x,y=56,29
                    unrenamable=yes
                [/unit]
            [/then]
        [/if]
        [fisherman_dialogue_hex][/fisherman_dialogue_hex]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=55
            y=32
        [/filter]

        [fishing_puzzle_hex][/fishing_puzzle_hex]
    [/event]

    ######### RIVER VILLAGE ###########

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=41
            y=26
        [/filter]

        [if]
            [not]
                [have_unit]
                    id=Villager
                [/have_unit]
            [/not]
            [then]
                [unit]
                    id=Villager
                    type=Peasant
                    gender=male
                    side=2
                    x,y=41,26
                    generate_name=yes
                [/unit]
            [/then]
        [/if]
        [river_dialogue_hex][/river_dialogue_hex]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=53
            y=18
        [/filter]

        [river_stone_hex][/river_stone_hex]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=48
            y=17
        [/filter]

        [river_puzzle_hex][/river_puzzle_hex]
    [/event]
    [event]
        name=moveto
        [filter]
            x=47
            y=17
        [/filter]

        [message]
            speaker=Esther
            message= _ "Well. That's nasty. Void crud always makes my skin crawl."
        [/message]
    [/event]

    ######### TEMPLE ###########

    [event]
        name=new turn
        first_time_only=no

        [temple_lights][/temple_lights]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=48
            y=7
        [/filter]

        [temple_puzzle_hex][/temple_puzzle_hex]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=56
            y=2
        [/filter]

        [message]
            speaker=Esther
            message= _ "There's an inscription here."
        [/message]
        [message]
            speaker=narrator
            message= _ "<i>White stone </i>"
        [/message]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=58
            y=4
        [/filter]
        [filter_condition]
            [variable]
                name=ethea.temple
                numerical_equals=1
            [/variable]
        [/filter_condition]

        [if]
            [have_location]
                x,y=45,14
                terrain=Bryd^Ii
            [/have_location]
            [then]
                {PLAY_SOUND "magic-faeriefire.ogg"}
                {DELAY 750}
                {PLAY_SOUND "lightning.ogg"}
                {DELAY 500}
                {PLAY_SOUND "lightning.ogg"}
                {DELAY 1000}

                [message]
                    speaker=Esther
                    message= _ "Did you feel that? There's some kind of incredible energy about this tree."
                [/message]
                [message]
                    speaker=Aryel
                    message= _ "You said it. I don't know why, but I feel different somehow. Stronger, maybe? Like I could do more with my spells now."
                [/message]
                [message]
                    speaker=Esther
                    message= _ "Yeah, I think so. We'll probably find out when we have to fight some of those rogue demons."
                [/message]

                {VARIABLE_OP aryel_spell_params.aryel_spell_power add 1}
                {VARIABLE_OP esther_spell_params.esther_spell_power add 1}
                {VARIABLE_OP yumi_spell_params.yumi_spell_power add 1}
                {VARIABLE_OP ethea.temple add 1}
            [/then]
            [else]
                [message]
                    speaker=Esther
                    message= _ "Hmm, nothing's happening."
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory

    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=14-17
            y=13-16
        [/filter]

        [message]
            speaker=Aryel
            message= _ "Should we go to the shrine now?"
        [/message]
        [message]
            speaker=Esther
            [option]
                message= _ "Let's go!"

                [command]
                    [endlevel]
                        result=victory
                        bonus=yes
                        {NEW_GOLD_CARRYOVER 100}
                        replay_save=no
                        carryover_report=no
                        linger_mode=no
                        next_scenario=03g_Amberlight_Shrine
                    [/endlevel]
                [/command]
            [/option]
            [option]
                message= _ "Let's wait a bit."
            [/option]
        [/message]
    [/event]
[/scenario]