#textdomain wesnoth-did

#define MALIN_ADVANCEMENT HP_INCREMENT XP_INCREMENT_E XP_INCREMENT_N XP_INCREMENT_H EFFECT_WML VARIATION_NAME
    [advancement]
        max_times=-1
        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total={HP_INCREMENT}
            increase={HP_INCREMENT}
            heal_full=no
        [/effect]
        [effect]
            apply_to=max_experience
            increase={ON_DIFFICULTY {XP_INCREMENT_E} {XP_INCREMENT_N} {XP_INCREMENT_H}}
        [/effect]
        [effect]
            apply_to=variation
            name={VARIATION_NAME}
        [/effect]
        {EFFECT_WML}
    [/advancement]
#enddef

#define MALIN_ADVANCE HP_INCREMENT XP_INCREMENT_E XP_INCREMENT_N XP_INCREMENT_H EFFECT_WML TYPE_NAME
    [advancement]
        max_times=-1
        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total={HP_INCREMENT}
            increase={HP_INCREMENT}
            heal_full=no
        [/effect]
        [effect]
            apply_to=max_experience
            increase={ON_DIFFICULTY {XP_INCREMENT_E} {XP_INCREMENT_N} {XP_INCREMENT_H}}
        [/effect]
        [effect]
            apply_to=type
            name={TYPE_NAME}
        [/effect]
        {EFFECT_WML}
    [/advancement]
#enddef

#define AUTO_ADVANCE HP_INCREMENT EXP_E EXP_N EXP_H VARIATION_NAME
    [advancement]
        max_times=-1
        always_display=yes
        description= _ "Increased hitpoints"
        image=icons/potion_red_medium.png
        [effect]
            apply_to=hitpoints
            increase_total={HP_INCREMENT}
            increase={HP_INCREMENT}
            heal_full=no
        [/effect]
        [effect]
            apply_to=variation
            name={VARIATION_NAME}
        [/effect]
        [effect]
            apply_to=max_experience
            increase={ON_DIFFICULTY {EXP_E} {EXP_N} {EXP_H}}
        [/effect]
    [/advancement]
#enddef

############## LEVEL 1 ADVANCEMENTS ##############

#define AM_MELEE VARIANT_NAME
    {MALIN_ADVANCEMENT 2 11 13 15 (
        id=am_melee
        description= _ "+1 melee damage"
        image=attacks/sword-human-short.png
        [effect]
            apply_to=attack
            range=melee
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define AM_RANGED VARIANT_NAME
    {MALIN_ADVANCEMENT 2 8 10 12 (
        id=am_ranged
        description= _ "+1 ranged damage"
        image=attacks/mud-glob.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_MELEE_MAGICAL VARIANT_NAME
    {MALIN_ADVANCEMENT 0 16 19 22 (
        id=malin_melee_magical
        description= _ "Malin’s sword gains the magical special"
        exclude_amla=malin_melee_magical
        image=attacks/magic-missile.png
        [effect]
            apply_to=attack
            range=melee
            [set_specials]
                {WEAPON_SPECIAL_MAGICAL}
                mode=append
            [/set_specials]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define AM_MELEE_ADVANCE
    {MALIN_ADVANCE 2 10 12 14 (
        id=am_melee_advance
        description= _ "+1 melee damage"
        image=attacks/sword-human-short.png
        [effect]
            apply_to=attack
            range=melee
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=15
        [/effect]
    ) MalinNecromancer}
#enddef

#define AM_RANGED_ADVANCE
    {MALIN_ADVANCE 2 8 10 12 (
        id=am_ranged_advance
        description= _ "+1 ranged damage"
        image=attacks/mud-glob.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            increase=-100%
        [/effect]
        [effect]
            apply_to=max_experience
            set=15
        [/effect]
    ) MalinNecromancer}
#enddef

############## LEVEL 2 ADVANCEMENTS ##############

#define MALIN_MELEE_PLAGUE VARIANT_NAME
    {MALIN_ADVANCEMENT 4 32 35 38 (
        id=malin_melee_plague
        description= _ "Malin’s sword gains the plague special"
        exclude_amla=malin_melee_plague
        image=attacks/staff-necromantic.png
        [effect]
            apply_to=attack
            range=melee
            [set_specials]
                {WEAPON_SPECIAL_PLAGUE}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=attack
            range=melee
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_RANGED VARIANT_NAME
    {MALIN_ADVANCEMENT -3 45 50 55 (
        id=malin_ranged
        description= _ "+2 ranged damage, but -10% arcane resistance"
        image=attacks/iceball.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=2
        [/effect]
        [effect]
            apply_to=resistance
            [resistance]
                arcane=10
            [/resistance]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_MELEE_VITALIZE VARIANT_NAME
    {MALIN_ADVANCEMENT 2 39 43 47 (
        id=malin_melee_vitalize
        description= _ "Malin’s melee attack heals him every hit"
        exclude_amla=malin_melee_vitalize
        image=attacks/baneblade.png
        [effect]
            apply_to=attack
            range=melee
            [set_specials]
                {WEAPON_SPECIAL_VITALIZE1}
                mode=append
            [/set_specials]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_RANGED_IMPETUITY VARIANT_NAME
    {MALIN_ADVANCEMENT 2 36 40 44 (
        id=malin_ranged_impetuity
        description= _ "Chill tempest gains the impetuity special"
        exclude_amla=malin_ranged_impetuity
        image=attacks/lightning.png
        [effect]
            apply_to=attack
            name=chill wave
            [set_specials]
                {WEAPON_SPECIAL_IMPETUITY}
                mode=append
            [/set_specials]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_CORPSE_LAUNCHER VARIANT_NAME
    {MALIN_ADVANCEMENT 0 36 40 44 (
        id=malin_corpse_launcher
        description= _ "Malin gains a special corpse launching attack"
        require_amla=malin_melee_plague
        exclude_amla=malin_corpse_launcher
        image=attacks/dragonstaff.png
        [effect]
            apply_to=new_attack
            name=corpse launch
            description= _"corpse launch"
            type=impact
            range=ranged
            damage=0
            number=1
            [specials]
                {WEAPON_SPECIAL_CORPSE_LAUNCHER}
                {WEAPON_SPECIAL_MAGICAL}
            [/specials]
            icon=attacks/dragonstaff.png
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_MELEE_ADVANCE
    {MALIN_ADVANCE 3 28 32 36 (
        id=malin_melee_advance
        description= _ "+2 melee damage"
        image=attacks/sword-human-short.png
        [effect]
            apply_to=attack
            range=melee
            increase_damage=2
        [/effect]
        [effect]
            apply_to=max_experience
            increase=-100%
        [/effect]
        [effect]
            apply_to=max_experience
            increase=19
        [/effect]
    ) MalinDarkMage}
#enddef

#define MALIN_RANGED_ADVANCE
    {MALIN_ADVANCE -2 30 33 36 (
        id=malin_ranged_advance
        description= _ "+2 ranged damage, but -10% arcane resistance"
        image=attacks/iceball.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=2
        [/effect]
        [effect]
            apply_to=resistance
            [resistance]
                arcane=10
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            set=20
        [/effect]
    ) MalinDarkMage}
#enddef

#define MALIN_RESIST_ADVANCE
    {MALIN_ADVANCE 5 40 44 48 (
        id=malin_resist_advance
        description= _ "Malin gains +10% resistance to blade and pierce, but loses -10% resistance to arcane"
        image=icons/rusty_targ.png
        [effect]
            apply_to=resistance
            [resistance]
                blade=-10
                pierce=-10
                arcane=10
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            set=20
        [/effect]
    ) MalinDarkMage}
#enddef

############## LEVEL 3 ADVANCEMENTS ##############

#define MALIN_RESIST VARIANT_NAME
    {MALIN_ADVANCEMENT 3 40 44 48 (
        id=malin_resist
        description= _ "Malin gains +10% resistance to blade and pierce, but loses -10% resistance to arcane"
        image=icons/rusty_targ.png
        [effect]
            apply_to=resistance
            [resistance]
                blade=-10
                pierce=-10
                arcane=10
            [/resistance]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_MELEE_VITALIZE2 VARIANT_NAME
    {MALIN_ADVANCEMENT 2 46 50 54 (
        id=malin_melee_vitalize2
        description= _ "Improves the vitalize special"
        exclude_amla=malin_melee_vitalize2
        require_amla=malin_melee_vitalize
        image=attacks/baneblade.png
        [effect]
            apply_to=attack
            range=melee
            remove_specials=did_vitalize1
        [/effect]
        [effect]
            apply_to=attack
            range=melee
            [set_specials]
                {WEAPON_SPECIAL_VITALIZE2}
                mode=append
            [/set_specials]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_CORPSE_MASTER VARIANT_NAME
    {MALIN_ADVANCEMENT 4 38 42 46 (
        id=malin_corpse_master
        description= _ "Gains the corpse master ability"
        image=attacks/touch-zombie.png
        require_amla=malin_melee_plague
        exclude_amla=malin_corpse_master
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_CORPSE_MASTER}
            [/abilities]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_RANGED_STRIKES VARIANT_NAME
    {MALIN_ADVANCEMENT -12 0 0 0 (
        id=malin_ranged_strikes
        description= _ "+1 ranged strikes, but -20% arcane resistance and -12 hp"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            range=ranged
            increase_attacks=1
        [/effect]
        [effect]
            apply_to=resistance
            [resistance]
                arcane=20
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_RANGED_FERVOR VARIANT_NAME
    {MALIN_ADVANCEMENT 4 0 0 0 (
        id=malin_ranged_fervor
        description= _ "Shadow wave gains the fervor special and -10% arcane resistance"
        image=attacks/dark-missile.png
        [effect]
            apply_to=attack
            name=shadow wave
            [set_specials]
                {WEAPON_SPECIAL_FERVOR}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=resistance
            [resistance]
                arcane=10
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MALIN_CONSUMPTION VARIANT_NAME
    {MALIN_ADVANCEMENT 3 0 0 0 (
        id=malin_consumption
        description= _ "Gains the consumption ability"
        image=attacks/curse.png
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_CONSUMPTION}
            [/abilities]
        [/effect]
        [effect]
            apply_to=resistance
            [resistance]
                arcane=10
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) {VARIANT_NAME}}
#enddef

##################################################

#define APPRENTICE_MAGE_BASE
#ifdef EASY
    experience=17
#endif
#ifdef NORMAL
    experience=20
#endif
#ifdef HARD
    experience=23
#endif
    hitpoints=35
    advances_to=null
    [attack]
        name=short sword
        #textdomain wesnoth-units
        description=_ "short sword"
        #textdomain wesnoth-did
        icon=attacks/sword-human-short.png
        type=blade
        range=melee
        damage=4
        number=3
    [/attack]
    [attack]
        name=magic blast
        description=_ "magic blast"
        icon="attacks/mud-glob.png" # dark missile is next level up
        type=impact
        range=ranged
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage=5
        number=2
    [/attack]
#enddef

#define APPRENTICE_NECROMANCER_BASE
    hitpoints=40
    advances_to=null
    [attack]
        name=short sword
        #textdomain wesnoth-units
        description=_ "short sword"
        icon=attacks/sword-human-short.png
        type=blade
        range=melee
        damage=5
        number=3
    [/attack]
    [attack]
        name=chill wave
        description=_"chill wave"
        type=cold
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=11
        number=2
        icon=attacks/iceball.png
    [/attack]
    [attack]
        name=shadow wave
        description=_"shadow wave"
        #textdomain wesnoth-did
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=8
        number=2
        icon=attacks/dark-missile.png
    [/attack]

    {DID_CORPSE_LAUNCH}
#enddef

#define DARK_MAGE_BASE
    hitpoints=45
    advances_to=null
    [attack]
        name=short sword
        #textdomain wesnoth-units
        description=_ "short sword"
        icon=attacks/sword-human-short.png
        type=blade
        range=melee
        damage=4
        number=3
    [/attack]
    [attack]
        name=chill wave
        description=_"chill wave"
        type=cold
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=13
        number=2
        icon=attacks/iceball.png
    [/attack]
    [attack]
        name=shadow wave
        description=_"shadow wave"
        #textdomain wesnoth-did
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=10
        number=2
        icon=attacks/dark-missile.png
    [/attack]

    {DID_CONSUMPTION}
    {DID_CORPSE_LAUNCH}
#enddef

[unit_type]
    id=Malin Keshar
    {APPRENTICE_MAGE_BASE}
    [base_unit]
        id=Apprentice Mage
    [/base_unit]
    [variation]
        {APPRENTICE_MAGE_BASE}
        hide_help=yes
        variation_id=AM1
        inherit=yes
        {AM_MELEE AM2}
        {AM_RANGED AM2}
    [/variation]
    [variation]
        {APPRENTICE_MAGE_BASE}
        hide_help=yes
        variation_id=AM2
        inherit=yes
        {AM_MELEE AM3}
        {AM_RANGED AM3}
        {MALIN_MELEE_MAGICAL AM3}
    [/variation]
    [variation]
        {APPRENTICE_MAGE_BASE}
        hide_help=yes
        variation_id=AM3
        inherit=yes
        {AM_MELEE_ADVANCE}
        {AM_RANGED_ADVANCE}
    [/variation]
[/unit_type]

[unit_type]
    id=MalinNecromancer
    {APPRENTICE_NECROMANCER_BASE}
    [base_unit]
        id=Apprentice Necromancer
    [/base_unit]
    experience=0
    {AUTO_ADVANCE 2 26 29 32 AN1}

    [variation]
        {APPRENTICE_NECROMANCER_BASE}
        hide_help=yes
        variation_id=AN1
        inherit=yes
        {AM_MELEE AN2}
        {MALIN_RANGED AN2}
        {MALIN_RANGED_IMPETUITY AN2}
        {MALIN_MELEE_MAGICAL AN2}
        {MALIN_MELEE_PLAGUE AN2}
    [/variation]
    [variation]
        {APPRENTICE_NECROMANCER_BASE}
        hide_help=yes
        variation_id=AN2
        inherit=yes
        {MALIN_RANGED_IMPETUITY AN3}
        {MALIN_CORPSE_LAUNCHER AN3}
        {MALIN_MELEE_MAGICAL AN3}
        {MALIN_MELEE_PLAGUE AN3}
        {MALIN_MELEE_VITALIZE AN3}
    [/variation]
    [variation]
        {APPRENTICE_NECROMANCER_BASE}
        hide_help=yes
        variation_id=AN3
        inherit=yes
        {MALIN_MELEE_ADVANCE}
        {MALIN_RANGED_ADVANCE}
        {MALIN_RESIST_ADVANCE}
    [/variation]
[/unit_type]

[unit_type]
    id=MalinDarkMage
    {DARK_MAGE_BASE}
    [base_unit]
        id=Dark Mage
    [/base_unit]
    experience=0
    {AUTO_ADVANCE 3 41 45 49 DM1}

    [variation]
        {DARK_MAGE_BASE}
        hide_help=yes
        variation_id=DM1
        inherit=yes
        {MALIN_RANGED DM2}
        {MALIN_RESIST DM2}
        {MALIN_RANGED_IMPETUITY DM2}
        {MALIN_CORPSE_LAUNCHER DM2}
        {MALIN_CORPSE_MASTER DM2}
        {MALIN_MELEE_VITALIZE DM2}
        {MALIN_MELEE_VITALIZE2 DM2}
    [/variation]
    [variation]
        {DARK_MAGE_BASE}
        hide_help=yes
        variation_id=DM2
        inherit=yes
        {MALIN_RANGED_STRIKES DM3}
        {MALIN_RANGED_FERVOR DM3}
        {MALIN_CONSUMPTION DM3}
    [/variation]
    [variation]
        {DARK_MAGE_BASE}
        hide_help=yes
        variation_id=DM3
        inherit=yes
        {AMLA_MALIN_KESHAR}
    [/variation]
[/unit_type]

#undef MALIN_ADVANCEMENT
#undef MALIN_ADVANCE
#undef AUTO_ADVANCE
#undef AM_MELEE
#undef AM_RANGED
#undef MALIN_MELEE_MAGICAL
#undef AM_MELEE_ADVANCE
#undef AM_RANGED_ADVANCE
#undef MALIN_RANGED
#undef MALIN_MELEE_VITALIZE
#undef MALIN_MELEE_PLAGUE
#undef MALIN_RANGED_FERVOR
#undef MALIN_RANGED_IMPETUITY
#undef MALIN_MELEE_ADVANCE
#undef MALIN_RANGED_ADVANCE
#undef MALIN_RESIST_ADVANCE
#undef MALIN_RESIST
#undef MALIN_MELEE_VITALIZE2
#undef MALIN_CORPSE_MASTER
#undef MALIN_CORPSE_LAUNCHER
#undef MALIN_RANGED_STRIKES
#undef MALIN_CONSUMPTION
#undef APPRENTICE_MAGE_BASE
#undef APPRENTICE_NECROMANCER_BASE
#undef DARK_MAGE_BASE


#textdomain wesnoth-did

#define MAL_KESHAR_ADVANCEMENT HP_INCREMENT XP_INCREMENT_E XP_INCREMENT_N XP_INCREMENT_H EFFECT_WML VARIATION_NAME
    [advancement]
        max_times=-1
        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total={HP_INCREMENT}
            increase={HP_INCREMENT}
            heal_full=no
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_E}
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_N}
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_H}
        [/effect]
#endif
        [effect]
            apply_to=variation
            name={VARIATION_NAME}
        [/effect]
        {EFFECT_WML}
    [/advancement]
#enddef

############## LICH ADVANCEMENTS ##############

#define LICH_MELEE VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 4 14 17 20 (
        id=lich_melee
        description= _ "+1 melee damage"
        image=attacks/touch-undead.png
        [effect]
            apply_to=attack
            name=touch
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define LICH_RANGED VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 2 22 26 30 (
        id=lich_ranged
        description= _ "+1 ranged damage"
        image=attacks/dark-missile.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define LICH_MOVEMENT VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 3 17 21 25 (
        id=lich_movement_melee
        description= _ "+1 movement"
        image=icons/sandals.png
        [effect]
            apply_to=movement
            increase=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

############## ANCIENT LICH ABILITIES ##############

#define ANCIENT_LICH_MALICE VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 0 50 55 60 (
        id=ancient_lich_malice
        description= _ "Nearby undead units gain 20% damage"
        image=attacks/wail.png
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_MALICE1}
            [/abilities]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define ANCIENT_LICH_RESIST VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 0 70 75 80 (
        id=ancient_lich_resist
        description= _ "Gains +10% resistance to blade, impact, and pierce"
        image=icons/potion_red_medium.png
        [effect]
            apply_to=resistance
            [resistance]
                blade=-10
                impact=-10
                pierce=-10
            [/resistance]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define ANCIENT_LICH_NOVA VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 2 0 0 0 (
        id=ancient_lich_nova
        description= _ "Chill tempest gains area of effect damage"
        image=attacks/iceball.png
        [effect]
            apply_to=attack
            name=chill tempest
            [set_specials]
                {WEAPON_SPECIAL_FROST_NOVA}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define ANCIENT_LICH_SPELLBIND VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 4 0 0 0 (
        id=ancient_lich_spellbind
        description= _ "Shadow wave reduces incoming magic damage"
        image=attacks/dark-missile.png
        [effect]
            apply_to=attack
            name=shadow wave
            [set_specials]
                {WEAPON_SPECIAL_SPELLBIND}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=attack
            name=shadow wave
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define ANCIENT_LICH_REND VARIANT_NAME
    {MAL_KESHAR_ADVANCEMENT 5 0 0 0 (
        id=ancient_lich_blood
        description= _ "Drain HP from nearby enemies, but lose HP every turn"
        image=attacks/curse.png
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SOUL_REND}
            [/abilities]
        [/effect]
        [effect]
            apply_to=attack
            name=touch
            remove_specials=drains
        [/effect]
        [effect]
            apply_to=attack
            name=touch
            [set_specials]
                {WEAPON_SPECIAL_REAP}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=attack
            name=touch
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define MAL_KESHAR_LICH_BASE
    hitpoints=55
    movement=5
#ifdef EASY
    experience=25
#endif
#ifdef NORMAL
    experience=31
#endif
#ifdef HARD
    experience=37
#endif
    advances_to=null
    [movement_costs]
        cave=1
        fungus=1
    [/movement_costs]
    [attack]
        name=touch
        description=_"touch"
        icon=attacks/touch-undead.png
        type=arcane
        range=melee
        damage=7
        number=3
        [specials]
            {WEAPON_SPECIAL_DRAIN}
        [/specials]
    [/attack]
    [attack]
        name=chill tempest
        description=_"chill tempest"
        type=cold
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=11
        number=3
        icon=attacks/iceball.png
    [/attack]
    [attack]
        name=shadow wave
        description=_"shadow wave"
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=9
        number=3
        icon=attacks/dark-missile.png
    [/attack]

    {DID_FROST_NOVA}
    {DID_SOUL_REND}
    {DID_SHADOW_VEIL_HANDLER}
#enddef

#define MAL_KESHAR_ANCIENT_LICH_BASE
    name= _ "Ancient Lich"
    image="units/undead-necromancers/ancient-lich.png"
    hitpoints=70
    movement=5
#ifdef EASY
    experience=90
#endif
#ifdef NORMAL
    experience=95
#endif
#ifdef HARD
    experience=100
#endif
    level=4
    cost=100
    usage=mixed fighter
    description= _ "A lich that accrues enough power over its newfound immortal lifespan becomes one who can stain souls with despair and sow ruin across the world. Invariably in command of a nigh-limitless horde of risen warriors and undead monsters, a lich of this order has a mastery of dark sorcery that can bring dread to the most storied magi of human and elven kind. Such a figure usually marks a dark and bloody chapter in history, and in those times of need, it is only through the tireless efforts of the most valiant heroes that the rise of an Ancient Lich has not led to the shadows ruling the world for the rest of time."
    {DEFENSE_ANIM "units/undead-necromancers/ancient-lich-defend.png" "units/undead-necromancers/ancient-lich.png" {SOUND_LIST:LICH_HIT} }
    [movement_costs]
        cave=1
        fungus=1
    [/movement_costs]
    [attack]
        name=touch
        description=_"touch"
        icon=attacks/touch-undead.png
        type=arcane
        range=melee
        damage=7
        number=4
        [specials]
            {WEAPON_SPECIAL_DRAIN}
        [/specials]
    [/attack]
    [attack]
        name=chill tempest
        description=_"chill tempest"
        type=cold
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=11
        number=5
        icon=attacks/iceball.png
    [/attack]
    [attack]
        name=shadow wave
        description=_"shadow wave"
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        range=ranged
        damage=8
        number=5
        icon=attacks/dark-missile.png
    [/attack]

    [idle_anim]
        {STANDARD_IDLE_FILTER}
        start_time=0
        [frame]
            duration=2310
            image="units/undead-necromancers/ancient-lich.png"
            halo=halo/undead/idle-flash-[1~21].png
            halo_x=6~0,0
            halo_y=-6~0,0
        [/frame]
    [/idle_anim]

    [recruiting_anim]
        [filter_second]
            race=undead
        [/filter_second]
        start_time=-300
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[1,2].png:75"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        sound_start_time=-75
        [sound_frame]
            sound=magic-dark-big.ogg
        [/sound_frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[2,1].png:50"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich.png:1"
        [/frame]
    [/recruiting_anim]
    [attack_anim]
        [filter_attack]
            name=chill tempest
        [/filter_attack]

        offset=0

        {MISSILE_FRAME_CHILL_TEMPEST 0 -15}

        start_time=-355
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[1,2].png:75"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark-big.ogg magic-dark-big-miss.ogg -150}
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[2,1].png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=shadow wave
        [/filter_attack]

        {MISSILE_FRAME_SHADOW_WAVE}

        start_time=-675
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[1,2].png:75"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-3.png"
            halo=halo/undead/black-magic-[1~5].png:[75*4,50]
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-3.png:200"
        [/frame]
        {SOUND:HIT_AND_MISS magic-dark-big.ogg magic-dark-big-miss.ogg -50}
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[2,1].png:50"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich.png:50"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=touch
        [/filter_attack]
        start_time=-250
        [frame]
            image="units/undead-necromancers/ancient-lich.png:50"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-melee-[1~2].png:[100,200]"
        [/frame]
        {SOUND:HIT_AND_MISS wail-sml.wav {SOUND_LIST:MISS} -100}
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-1.png:75"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich.png:75"
        [/frame]
    [/attack_anim]
#enddef

[unit_type]
    id=Mal Keshar
    [base_unit]
        id=Lich
    [/base_unit]
    {MAL_KESHAR_LICH_BASE}

    ########## LEVEL 3 ##########
    [variation]
        {MAL_KESHAR_LICH_BASE}
        hide_help=yes
        variation_id=MKL1
        inherit=yes
        {LICH_MELEE MKL2}
        {LICH_RANGED MKL2}
    [/variation]

    [variation]
        {MAL_KESHAR_LICH_BASE}
        hide_help=yes
        variation_id=MKL2
        inherit=yes
        {LICH_MELEE MKL3MELEE}
        {LICH_RANGED MKL3RANGED}
    [/variation]

    [variation]
        {MAL_KESHAR_LICH_BASE}
        hide_help=yes
        variation_id=MKL3MELEE
        inherit=yes
        {LICH_RANGED MKL4}
        {LICH_MOVEMENT MKL4}
    [/variation]
    [variation]
        {MAL_KESHAR_LICH_BASE}
        hide_help=yes
        variation_id=MKL3RANGED
        inherit=yes
        {LICH_MELEE MKL4}
        {LICH_MOVEMENT MKL4}
    [/variation]

    ########## LEVEL 4 ##########
    [variation]
        {MAL_KESHAR_ANCIENT_LICH_BASE}
        hide_help=yes
        variation_id=MKL4
        inherit=yes
        {ANCIENT_LICH_MALICE MKL4MAL}
        {LICH_MELEE MKL4DMG}
        {LICH_RANGED MKL4DMG}
        {LICH_MOVEMENT MKL4MVT}
    [/variation]

    [variation]
        {MAL_KESHAR_ANCIENT_LICH_BASE}
        hide_help=yes
        variation_id=MKL4MAL
        inherit=yes
        {LICH_MELEE MKL5}
        {LICH_RANGED MKL5}
        {LICH_MOVEMENT MKL5}
        {ANCIENT_LICH_RESIST MKL5}
    [/variation]
    [variation]
        {MAL_KESHAR_ANCIENT_LICH_BASE}
        hide_help=yes
        variation_id=MKL4DMG
        inherit=yes
        {ANCIENT_LICH_MALICE MKL5}
        {LICH_MELEE MKL5}
        {LICH_RANGED MKL5}
        {LICH_MOVEMENT MKL5}
        {ANCIENT_LICH_RESIST MKL5}
    [/variation]
    [variation]
        {MAL_KESHAR_ANCIENT_LICH_BASE}
        hide_help=yes
        variation_id=MKL4MVT
        inherit=yes
        {ANCIENT_LICH_MALICE MKL5}
        {LICH_MELEE MKL5}
        {LICH_RANGED MKL5}
        {ANCIENT_LICH_RESIST MKL5}
    [/variation]

    [variation]
        {MAL_KESHAR_ANCIENT_LICH_BASE}
        hide_help=yes
        variation_id=MKL5
        inherit=yes
        {ANCIENT_LICH_NOVA MKL6}
        {ANCIENT_LICH_SPELLBIND MKL6}
        {ANCIENT_LICH_REND MKL6}
    [/variation]

    [variation]
        {MAL_KESHAR_ANCIENT_LICH_BASE}
        hide_help=yes
        variation_id=MKL6
        inherit=yes
        {AMLA_MAL_KESHAR}
    [/variation]
[/unit_type]

#undef MAL_KESHAR_ADVANCEMENT
#undef LICH_MELEE
#undef LICH_RANGED
#undef LICH_MOVEMENT
#undef ANCIENT_LICH_MALICE
#undef ANCIENT_LICH_RESIST
#undef ANCIENT_LICH_NOVA
#undef ANCIENT_LICH_SPELLBIND
#undef ANCIENT_LICH_REND
#undef MAL_KESHAR_LICH_BASE
#undef MAL_KESHAR_ANCIENT_LICH_BASE


#textdomain wesnoth-did
# Same as normal, except advances to Ghast DiD
[unit_type]
    id=Necrophage DiD
    [base_unit]
        id=Necrophage
    [/base_unit]
    advances_to=Ghast DiD
    hide_help=yes
    do_not_list=yes
[/unit_type]


#textdomain wesnoth-did

#define GHOST_ADVANCEMENT HP_INCREMENT XP_INCREMENT_E XP_INCREMENT_N XP_INCREMENT_H EFFECT_WML VARIATION_NAME
    [advancement]
        max_times=-1
        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total={HP_INCREMENT}
            increase={HP_INCREMENT}
            heal_full=no
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_E}
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_N}
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_H}
        [/effect]
#endif
        [effect]
            apply_to=variation
            name={VARIATION_NAME}
        [/effect]
        {EFFECT_WML}
    [/advancement]
#enddef

#define GHOST_ADVANCE HP_INCREMENT XP_INCREMENT_E XP_INCREMENT_N XP_INCREMENT_H EFFECT_WML TYPE_NAME
    [advancement]
        max_times=-1
        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total={HP_INCREMENT}
            increase={HP_INCREMENT}
            heal_full=no
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_E}
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_N}
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase={XP_INCREMENT_H}
        [/effect]
#endif
        [effect]
            apply_to=type
            name={TYPE_NAME}
        [/effect]
        {EFFECT_WML}
    [/advancement]
#enddef

#define AUTO_ADVANCE VARIATION_NAME
    [advancement]
        max_times=-1
        always_display=yes
        description= _ "+2 HP"
        image=icons/potion_green_small.png
        [effect]
            apply_to=variation
            name={VARIATION_NAME}
        [/effect]
        [effect]
            apply_to=hitpoints
            increase_total=2
            increase=2
            heal_full=no
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=44
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=49
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=54
        [/effect]
#endif
    [/advancement]
#enddef

############## GHOST ADVANCEMENTS ##############

#define GHOST_MELEE VARIANT_NAME
    {GHOST_ADVANCEMENT 2 10 12 14 (
        id=ghost_melee
        description= _ "+1 melee damage"
        image=attacks/touch-undead.png
        [effect]
            apply_to=attack
            name=touch
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define GHOST_RANGED VARIANT_NAME
    {GHOST_ADVANCEMENT 2 10 12 14 (
        id=ghost_ranged
        description= _ "+1 ranged damage"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define GHOST_MOVEMENT VARIANT_NAME
    {GHOST_ADVANCEMENT 0 12 14 16 (
        id=ghost_movement
        description= _ "+1 movement"
        image=icons/sandals.png
        [effect]
            apply_to=movement
            increase=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define GHOST_MELEE_ADVANCE
    {GHOST_ADVANCE 1 10 12 14 (
        id=ghost_melee_advance
        description= _ "+1 melee damage"
        image=attacks/touch-undead.png
        [effect]
            apply_to=attack
            name=touch
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=15
        [/effect]
    ) Phantom}
#enddef

#define GHOST_RANGED_ADVANCE
    {GHOST_ADVANCE 1 10 12 14 (
        id=ghost_ranged_advance
        description= _ "+1 ranged damage"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=15
        [/effect]
    ) Phantom}
#enddef

#define GHOST_MOVE_ADVANCE
    {GHOST_ADVANCE 0 12 14 16 (
        id=ghost_move_advance
        description= _ "+1 movement"
        image=icons/sandals.png
        [effect]
            apply_to=movement
            increase=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=15
        [/effect]
    ) Phantom}
#enddef

############## WRAITH ADVANCEMENTS ##############

#define WRAITH_MELEE VARIANT_NAME
    {GHOST_ADVANCEMENT 2 10 12 14 (
        id=wraith_melee
        description= _ "+1 melee damage"
        image=attacks/baneblade.png
        [effect]
            apply_to=attack
            name=baneblade
            increase_damage=1
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define WRAITH_MALEVOLENCE VARIANT_NAME
    {GHOST_ADVANCEMENT 1 40 45 50 (
        id=wraith_malevolence
        description= _ "Wail gains the malevolence special"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            name=wail
            [set_specials]
                {WEAPON_SPECIAL_MALEVOLENCE}
                mode=append
            [/set_specials]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define WRAITH_HYSTERIA VARIANT_NAME
    {GHOST_ADVANCEMENT 4 50 55 60 (
        id=wraith_hysteria
        description= _ "Wail gains the hysteria special"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            name=wail
            [set_specials]
                {WEAPON_SPECIAL_HYSTERIA}
                mode=append
            [/set_specials]
        [/effect]
    ) {VARIANT_NAME}}
#enddef

#define WRAITH_MELEE_ADVANCE
    {GHOST_ADVANCE 2 10 12 14 (
        id=wraith_melee_advance
        description= _ "+1 melee damage"
        image=attacks/baneblade.png
        [effect]
            apply_to=attack
            name=baneblade
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) Eidolon}
#enddef

#define WRAITH_RANGED_ADVANCE
    {GHOST_ADVANCE 2 10 12 14 (
        id=wraith_ranged_advance
        description= _ "+1 ranged damage"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) Eidolon}
#enddef

#define WRAITH_MALEVOLENCE_ADVANCE
    {GHOST_ADVANCE 1 40 45 50 (
        id=wraith_malevolence_advance
        description= _ "Wail gains the malevolence special"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            name=wail
            [set_specials]
                {WEAPON_SPECIAL_MALEVOLENCE}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) Eidolon}
#enddef

#define WRAITH_HYSTERIA_ADVANCE
    {GHOST_ADVANCE 4 50 55 60 (
        id=wraith_hysteria_advance
        description= _ "Wail gains the hysteria special"
        image=attacks/wail.png
        [effect]
            apply_to=attack
            name=wail
            [set_specials]
                {WEAPON_SPECIAL_HYSTERIA}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) Eidolon}
#enddef

#define WRAITH_RESIST_ADVANCE
    {GHOST_ADVANCE 6 40 45 50 (
        id=wraith_resist_advance
        description= _ "Gains +20% resistance to fire"
        image=attacks/fire-blast.png
        [effect]
            apply_to=resistance
            [resistance]
                fire=-20
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            set=90
        [/effect]
    ) Eidolon}
#enddef

#define GHOST_BASE
    name= _ "Spectral Servant"
    hitpoints=17
    movement=6
#ifdef EASY
    experience=14
#endif
#ifdef NORMAL
    experience=16
#endif
#ifdef HARD
    experience=18
#endif
    advances_to=null
    [attack]
        name=touch
        description=_"touch"
        icon=attacks/touch-undead.png
        type=arcane
        range=melee
        damage=5
        number=3
        [specials]
            {WEAPON_SPECIAL_DRAIN}
        [/specials]
    [/attack]
    [attack]
        name=wail
        description=_"wail"
        type=cold
        range=ranged
        damage=4
        number=3
    [/attack]
#enddef

#define WRAITH_BASE
    name= _ "Phantom"
    hitpoints=22
    movement=6
    advances_to=null
    [attack]
        name=baneblade
        description=_"baneblade"    # wmllint: no spellcheck (until name->id)
        type=arcane
        range=melee
        damage=6
        number=4
        [specials]
            {WEAPON_SPECIAL_DRAIN}
        [/specials]
    [/attack]
    [attack]
        name=wail
        description=_"wail"
        type=cold
        range=ranged
        damage=4
        number=4
    [/attack]
#enddef

#define SPECTRE_BASE
    name= _ "Eidolon"
    hitpoints=27
    movement=6
    experience=90
    advances_to=null
    [attack]
        name=baneblade
        description=_"baneblade"    # wmllint: no spellcheck (until name->id)
        type=arcane
        range=melee
        damage=8
        number=4
        [specials]
            {WEAPON_SPECIAL_DRAIN}
        [/specials]
    [/attack]
    [attack]
        name=wail
        description=_"wail"
        type=cold
        range=ranged
        damage=6
        number=4
    [/attack]
#enddef

[unit_type]
    id=Spectral Servant
    {GHOST_BASE}
    [base_unit]
        id=Ghost
    [/base_unit]
    [variation]
        {GHOST_BASE}
        hide_help=yes
        variation_id=SS1
        inherit=yes
        {GHOST_MELEE SS2MELEE}
        {GHOST_RANGED SS2RANGED}
    [/variation]
    [variation]
        {GHOST_BASE}
        hide_help=yes
        variation_id=SS2MELEE
        inherit=yes
        {GHOST_RANGED_ADVANCE}
        {GHOST_MOVE_ADVANCE}
    [/variation]
    [variation]
        {GHOST_BASE}
        hide_help=yes
        variation_id=SS2RANGED
        inherit=yes
        {GHOST_MELEE_ADVANCE}
        {GHOST_MOVE_ADVANCE}
    [/variation]
[/unit_type]

[unit_type]
    id=Phantom
    {WRAITH_BASE}
    [base_unit]
        id=Wraith
    [/base_unit]
    experience=0
    {AUTO_ADVANCE W0}

    [variation]
        {WRAITH_BASE}
        hide_help=yes
        variation_id=W0
        inherit=yes
        {WRAITH_MALEVOLENCE W1}
        {WRAITH_HYSTERIA W1}
        {WRAITH_MELEE W1NOABILITY}
        {GHOST_RANGED W1NOABILITY}
    [/variation]
    [variation]
        {WRAITH_BASE}
        hide_help=yes
        variation_id=W1
        inherit=yes
        {WRAITH_MELEE W2}
        {GHOST_RANGED W2}
        {GHOST_MOVEMENT W2}
    [/variation]
    [variation]
        {WRAITH_BASE}
        hide_help=yes
        variation_id=W1NOABILITY
        inherit=yes
        {WRAITH_MALEVOLENCE W2}
        {WRAITH_HYSTERIA W2}
        {WRAITH_MELEE W2NOABILITY}
        {GHOST_RANGED W2NOABILITY}
        {GHOST_MOVEMENT W2NOABILITY}
    [/variation]
    [variation]
        {WRAITH_BASE}
        hide_help=yes
        variation_id=W2
        inherit=yes
        {WRAITH_MELEE_ADVANCE}
        {WRAITH_RANGED_ADVANCE}
        {WRAITH_RESIST_ADVANCE}
    [/variation]
    [variation]
        {WRAITH_BASE}
        hide_help=yes
        variation_id=W2NOABILITY
        inherit=yes
        {WRAITH_MELEE_ADVANCE}
        {WRAITH_RANGED_ADVANCE}
        {WRAITH_MALEVOLENCE_ADVANCE}
        {WRAITH_HYSTERIA_ADVANCE}
    [/variation]
[/unit_type]

[unit_type]
    id=Eidolon
    {SPECTRE_BASE}
    [base_unit]
        id=Spectre
    [/base_unit]
    {AMLA_EIDOLON}
[/unit_type]

#undef GHOST_ADVANCEMENT
#undef GHOST_ADVANCE
#undef AUTO_ADVANCE
#undef GHOST_MELEE
#undef GHOST_RANGED
#undef GHOST_MOVEMENT
#undef GHOST_MELEE_ADVANCE
#undef GHOST_RANGED_ADVANCE
#undef GHOST_MOVE_ADVANCE
#undef WRAITH_MELEE
#undef WRAITH_MALEVOLENCE
#undef WRAITH_HYSTERIA
#undef WRAITH_MELEE_ADVANCE
#undef WRAITH_RANGED_ADVANCE
#undef WRAITH_MALEVOLENCE_ADVANCE
#undef WRAITH_HYSTERIA_ADVANCE
#undef WRAITH_RESIST_ADVANCE
#undef GHOST_BASE
#undef WRAITH_BASE
#undef SPECTRE_BASE


#textdomain wesnoth-did

############## DRAGON ABILITIES ##############

#define ABILITY_SOUL_EATER1
    [dummy]
        id=did_soul_eater1
        name= _ "soul eater"
        name_inactive= _ "soul eater"
        description= _ "This unit heals 4 HP whenever it kills an enemy unit."
        description_inactive= _ "This unit heals 4 HP whenever it kills an enemy unit."
    [/dummy]
#enddef

#define DID_SOUL_EATER1
    [event]
        id=did_soul_eater_die1
        name=die
        first_time_only=no
        [filter_second]
            ability=did_soul_eater1
        [/filter_second]

        [heal_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            amount=4
            animate=yes
        [/heal_unit]
    [/event]
#enddef

#define ABILITY_SOUL_EATER2
    [dummy]
        id=did_soul_eater2
        name= _ "soul eater"
        name_inactive= _ "soul eater"
        description= _ "This unit heals 8 HP whenever it kills an enemy unit."
        description_inactive= _ "This unit heals 8 HP whenever it kills an enemy unit."
    [/dummy]
#enddef

#define DID_SOUL_EATER2
    [event]
        id=did_soul_eater_die2
        name=die
        first_time_only=no
        [filter_second]
            ability=did_soul_eater2
        [/filter_second]

        [heal_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            amount=8
            animate=yes
        [/heal_unit]
    [/event]
#enddef

#define ABILITY_SOUL_EATER3
    [damage]
        id=did_soul_eater3
        name= _ "soul eater"
        name_inactive= _ "soul eater"
        description= _ "This unit gains 15% damage on offense and heals 12 HP whenever it kills an enemy unit."
        description_inactive= _ "This unit gains 15% damage on offense and heals 12 HP whenever it kills an enemy unit."
        multiply=1.15
        active_on=offense
    [/damage]
#enddef

#define DID_SOUL_EATER3
    [event]
        id=did_soul_eater_die3
        name=die
        first_time_only=no
        [filter_second]
            ability=did_soul_eater3
        [/filter_second]

        [heal_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            amount=12
            animate=yes
        [/heal_unit]
    [/event]
#enddef

############## LICH ABILITIES ##############

#define ABILITY_MALICE1
    [leadership]
        id=did_malice1
        value=20
        cumulative=no
        affect_self=no
        name= _ "malice"
        description= _ "This unit increases the damage of nearby undead units by 20%."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                race=undead
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_MALICE2
    [leadership]
        id=did_malice2
        value=40
        cumulative=no
        affect_self=no
        name= _ "malice"
        description= _ "This unit increases the damage of nearby undead units by 40%."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                race=undead
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_SHADOW_VEIL
    [dummy]
        id=did_shadow_veil
        name= _ "shadow veil"
        name_inactive= _ "shadow veil"
        description= _ "Allied undead units within a 5 hex radius are hidden."
        description_inactive= _ "Allied undead units within a 5 hex radius are hidden."
    [/dummy]
#enddef

#define ABILITY_SHADOW_VEIL_HELPER SIDE
    [hides]
        id=did_shadow_veil_helper
        [filter]
            [filter_location]
                radius=5
                [filter]
                    ability=did_shadow_veil
                    [filter_side]
                        [allied_with]
                            side={SIDE}
                        [/allied_with]
                    [/filter_side]
                [/filter]
            [/filter_location]
        [/filter]
    [/hides]
#enddef

#define DID_SHADOW_VEIL_HANDLER
    [event]
        id=did_shadow_veil_unit_placed
        name=unit placed
        first_time_only=no
        [filter]
            side=1
            race=undead
            [not]
                ability=did_shadow_veil_helper
            [/not]
        [/filter]
        [filter_condition]
            [have_unit]
                ability=did_shadow_veil
                side=1
            [/have_unit]
        [/filter_condition]
        [modify_unit]
            [filter]
                x,y=$x1,$y1
                [not]
                    ability=did_shadow_veil_helper
                    [or]
                        ability=did_shadow_veil
                    [/or]
                [/not]
            [/filter]
            [object]
                duration=scenario
                [effect]
                    apply_to=new_ability
                    [abilities]
                        {ABILITY_SHADOW_VEIL_HELPER $unit.side}
                    [/abilities]
                [/effect]
            [/object]
        [/modify_unit]
    [/event]
    [event]
        id=did_shadow_veil_malkeshar
        name=post advance
        first_time_only=yes
        [filter]
            type=Mal Keshar
            ability=did_shadow_veil
        [/filter]
        [modify_unit]
            [filter]
                race=undead
                [not]
                    ability=did_shadow_veil_helper
                    [or]
                        ability=did_shadow_veil
                    [/or]
                [/not]
                [filter_side]
                    [allied_with]
                        side=$unit.side
                    [/allied_with]
                [/filter_side]
            [/filter]
            [object]
                take_only_once=no
                duration=scenario
                [effect]
                    apply_to=new_ability
                    [abilities]
                        {ABILITY_SHADOW_VEIL_HELPER $this_unit.side}
                    [/abilities]
                [/effect]
            [/object]
        [/modify_unit]
    [/event]
#enddef

#define WEAPON_SPECIAL_FROST_NOVA
    [dummy]
        id=did_frost_nova
        name= _ "frost nova"
        name_inactive= _ "frost nova"
        description= _ "On offense, this attack will additionally deal 70% of its damage in cold damage to all enemies adjacent to the target."
        description_inactive= _ "On offense, this attack will additionally deal 70% of its damage in cold damage to all enemies adjacent to the target."
    [/dummy]
#enddef

#define DID_FROST_NOVA
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special_id=did_frost_nova
        [/filter_attack]
        [store_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x2,$y2
                    is_enemy=no
                [/filter_adjacent]
                [not]
                    x,y=$x2,$y2
                [/not]
            [/filter]
            variable=opp
        [/store_unit]
        {VARIABLE frost_damage $damage_inflicted}
        {VARIABLE_OP frost_damage multiply 0.7}
        [foreach]
            array=opp
            [do]
                [sound]
                    name="magic-dark.ogg"
                [/sound]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=$frost_damage
                    damage_type=cold
                    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]
        [/foreach]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE frost_damage}
    [/event]
#enddef

#define WEAPON_SPECIAL_SPELLBIND
    [damage]
        id=did_spellbind
        name= _ "spell bind"
        name_inactive= _ "spell bind"
        description= _ "When this attack is used, the damage taken from fire, cold, and arcane attacks will be reduced by 60%."
        description_inactive= _ "When this attack is used, the damage taken from fire, cold, and arcane attacks will be reduced by 60%."
        [filter_opponent]
            [filter_weapon]
                type=fire,cold,arcane
            [/filter_weapon]
        [/filter_opponent]
        apply_to=opponent
        multiply=0.4
    [/damage]
#enddef

#define WEAPON_SPECIAL_REAP
    [drains]
        id=did_reap
        value=70
        name= _ "reap"
        description= _ "This unit heals for 70% of the damage this attack deals."
    [/drains]
#enddef

#define ABILITY_SOUL_REND
    [dummy]
        id=did_soul_rend
        name= _ "soul rend"
        name_inactive= _ "soul rend"
        description= _ "Every turn, this unit loses 5 hitpoints, but drains 4 hitpoints from each adjacent enemy."
        description_inactive= _ "Every turn, this unit loses 5 hitpoints, but drains 4 hitpoints from each adjacent enemy."
    [/dummy]
#enddef

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

        [store_unit]
            [filter]
                [filter_adjacent]
                    ability=did_soul_rend
                    is_enemy=yes
                [/filter_adjacent]
            [/filter]
            variable=opp
        [/store_unit]
        [store_unit]
            [filter]
                ability=did_soul_rend
            [/filter]
            variable=runit
        [/store_unit]

        [harm_unit]
            [filter]
                ability=did_soul_rend
            [/filter]

            amount=5
            animate=no
            kill=no
        [/harm_unit]

        [floating_text]
            x,y=$runit.x,$runit.y
            color=255,0,0
            text=5
        [/floating_text]

        {VARIABLE counter 0}
        [foreach]
            array=opp
            [do]
                {VARIABLE_OP counter add 1}
                [sound]
                    name="poison.ogg"
                [/sound]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=4
                    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 runit.experience add $exp}
                        {CLEAR_VARIABLE exp}
                        [unstore_unit]
                            variable=runit
                            find_vacant=no
                        [/unstore_unit]
                    [/else]
                [/if]
            [/do]
        [/foreach]
        {VARIABLE_OP counter multiply 4}
        [heal_unit]
            [filter]
                ability=did_soul_rend
            [/filter]
            amount=$counter
            animate=yes
        [/heal_unit]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE runit}
        {CLEAR_VARIABLE counter}
    [/event]
#enddef

############## SPECTRAL SERVANT ABILITIES ##############

#define WEAPON_SPECIAL_MALEVOLENCE
    [damage]
        id=did_malevolence
        name= _ "malevolence"
        name_inactive= _ "malevolence"
        description= _ "This attack gains 50% damage on offense, but causes this unit to lose 1 hp per hit."
        description_inactive= _ "This attack gains 50% damage on offense, but causes this unit to lose 1 hp per hit."
        multiply=1.5
        active_on=offense
    [/damage]
    [heal_on_hit]
        id=did_malevolence_anti_heal
        value=-1
        active_on=offense
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_HYSTERIA
    [swarm]
        id=did_hysteria
        name= _ "hysteria"
        description= _ "This attack gains up to 10 strikes when this unit is wounded."
        swarm_attacks_min=10
    [/swarm]
#enddef

#define ABILITY_SORROW1
    [leadership]
        id=sorrow
        value=-20
        cumulative=no
        name= _ "sorrow"
        description= _ "Adjacent enemy units do 20% less damage."
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_SORROW2
    [leadership]
        id=sorrow
        value=-40
        cumulative=no
        name= _ "sorrow"
        description= _ "Adjacent enemy units do 40% less damage."
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/leadership]
#enddef

############## MALIN KESHAR ABILITIES ##############

#define WEAPON_SPECIAL_VITALIZE1
    [heal_on_hit]
        id=did_vitalize1
        value=2
        name= _ "vitalize"
        description= _ "This unit heals 2 HP every time this attack hits."
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_VITALIZE2
    [heal_on_hit]
        id=did_vitalize2
        value=4
        name= _ "vitalize"
        description= _ "This unit heals 4 HP every time this attack hits."
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_FERVOR
    [attacks]
        id=did_fervor
        name= _ "fervor"
        name_inactive= _ "fervor"
        description= _ "This attack gains 2 attacks on offense, but causes this unit to lose 4 hp per hit."
        description_inactive= _ "This attack gains 2 attacks on offense, but causes this unit to lose 4 hp per hit."
        add=2
        active_on=offense
    [/attacks]
    [heal_on_hit]
        id=did_fervor_anti_heal
        value=-4
        active_on=offense
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_IMPETUITY
    [attacks]
        id=did_impetuity
        name= _ "impetuity"
        name_inactive= _ "impetuity"
        description= _ "This attack loses one strike on offense but deals three times the normal damage."
        description_inactive= _ "This attack loses one strike on offense but deals three times the normal damage."
        sub=1
        active_on=offense
    [/attacks]
    [damage]
        id=did_impetuity_damage
        multiply=3
        active_on=offense
    [/damage]
#enddef

#define WEAPON_SPECIAL_CORPSE_LAUNCHER
    [attacks]
        id=did_corpse_launcher
        name= _ "corpse launcher"
        description= _ "On offense, enemies cannot retaliate against this attack. This attack consumes 3 HP from each nearby allied corpse to deal 11 impact damage (per corpse) to the target on top of this attack’s base damage."
        value=0
        cumulative=no
        apply_to=opponent
        active_on=offense
    [/attacks]
    [damage]
        id=did_corpse_damage
        add=11
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=1
                type=Walking Corpse,Soulless
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=22
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=2
                type=Walking Corpse,Soulless
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=33
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=3
                type=Walking Corpse,Soulless
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=44
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=4
                type=Walking Corpse,Soulless
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=55
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=5
                type=Walking Corpse,Soulless
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=66
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=6
                type=Walking Corpse,Soulless
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
#enddef

#define DID_CORPSE_LAUNCH
    [event]
        id=did_corpse_launch_handler
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special_id=did_corpse_launcher
        [/filter_attack]
        [store_unit]
            [filter]
                type=Walking Corpse,Soulless
                [filter_adjacent]
                    x,y=$x1,$y1
                    is_enemy=no
                [/filter_adjacent]
                [not]
                    x,y=$x1,$y1
                [/not]
            [/filter]
            variable=zombie
        [/store_unit]
        [foreach]
            array=zombie
            [do]
                [harm_unit]
                    [filter]
                        x,y=$zombie[$i].x,$zombie[$i].y
                    [/filter]
                    fire_event=yes
                    animate=no
                    kill=no
                    amount=3
                    delay=25
                [/harm_unit]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE zombie}
    [/event]
#enddef

#define ABILITY_CONSUMPTION
    [leadership]
        id=did_consumption
        value=25
        cumulative=no
        affect_self=yes
        name= _ "consumption"
        description= _ "At night, this unit and adjacent allied undead gain 25% damage. However, this unit loses 2 HP per turn."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                race=undead
            [/filter]
        [/affect_adjacent]
        [filter_self]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
        [/filter_self]
    [/leadership]
#enddef

#define DID_CONSUMPTION
    [event]
        id=did_consumption_handler
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                ability=did_consumption
            [/filter]
            variable=cunit
        [/store_unit]

        [if]
            [have_location]
                x,y=$cunit.x,$cunit.y
                time_of_day=chaotic
            [/have_location]
            [then]
                [harm_unit]
                    [filter]
                        ability=did_consumption
                    [/filter]

                    amount=2
                    animate=no
                    kill=no
                [/harm_unit]

                [floating_text]
                    x,y=$cunit.x,$cunit.y
                    color=255,0,0
                    text=2
                [/floating_text]
            [/then]
        [/if]
        {CLEAR_VARIABLE cunit}
    [/event]
#enddef

#define ABILITY_CORPSE_MASTER
    [heals]
        id=did_corpse_master
        value=8
        affect_allies=yes
        affect_self=no
        affect_enemies=no
        name= _ "corpse master"
        description= _ "Adjacent allied corpses heal 8 HP per turn and gain 30% resistance to blade, impact, and pierce."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type=Walking Corpse,Soulless
            [/filter]
        [/affect_adjacent]
    [/heals]
    [resistance]
        id=did_corpse_master_resist
        add=30
        max_value=90
        cumulative=no
        affect_self=no
        affect_allies=yes
        affect_enemies=no
        apply_to=blade,pierce,impact
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type=Walking Corpse,Soulless
            [/filter]
        [/affect_adjacent]
    [/resistance]
#enddef

#define ABILITY_ZOMBIE_FRENZY
    [leadership]
        id=did_zombie_frenzy
        value=30
        cumulative=no
        affect_self=no
        affect_allies=yes
        affect_enemies=no
        name= _ "zombie frenzy"
        description= _ "Adjacent allied corpses gain 30% damage and are berserk."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type=Walking Corpse,Soulless
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [berserk]
        id=did_zombie_frenzy_berserk
        value=30
        affect_self=no
        affect_allies=yes
        affect_enemies=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type=Walking Corpse,Soulless
            [/filter]
        [/affect_adjacent]
    [/berserk]
#enddef

############## DROGAN GHOUL ABILITIES ##############

#define ABILITY_CANNIBALIZE1
    [regenerate]
        id=did_cannibalize1
        value=2
        affect_self=yes
        name= _ "cannibalize"
        description= _ "On each turn, this unit regenerates 2 HP per adjacent allied ghoul-type unit, but consumes 1 HP from each ally in the process."
        [filter]
            [filter_adjacent]
                count=1
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=4
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=2
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=6
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=3
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=8
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=4
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=10
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=5
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=12
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=6
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [heals]
        value=-1
        id=did_cannibalize_antiheal
        affect_allies=yes
        affect_self=no
        [affect_adjacent]
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_CANNIBALIZE2
    [regenerate]
        id=did_cannibalize2
        value=4
        affect_self=yes
        name= _ "cannibalize"
        description= _ "On each turn, this unit regenerates 4 HP per adjacent allied ghoul-type unit, but consumes 2 HP from each ally in the process."
        [filter]
            [filter_adjacent]
                count=1
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=8
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=2
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=12
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=3
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=16
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=4
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=20
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=5
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=24
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=6
                type=Ghoul,Necrophage,Ghast
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [heals]
        value=-2
        id=did_cannibalize_antiheal
        affect_allies=yes
        affect_self=no
        [affect_adjacent]
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_DEATH_CLOUD
    [dummy]
        id=did_death_cloud
        name= _ "death cloud"
        description= _ "This unit poisons all nearby enemy units on the start of every new turn."
    [/dummy]
#enddef

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

        [store_unit]
            [filter]
                [filter_adjacent]
                    ability=did_death_cloud
                    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]
#enddef

############## MISC ABILITIES ##############

#define ABILITY_DRUNK
    [resistance]
        id=did_drunk
        add=10
        max_value=90
        name= _ "drunk"
        female_name= _ "female^drunk"
        description= _ "This unit is drunk and has 10% increased resistances."
        affect_self=yes
    [/resistance]
#enddef

#define WEAPON_SPECIAL_DRUNKEN_RAGE
    [berserk]
        id=did_drunken_rage
        name= _ "drunken rage"
        description= _ "On offense, this attack presses the engagement for 4 rounds of attacks."
        value=4
        active_on=offense
    [/berserk]
#enddef


#textdomain wesnoth-did

############## DRAGON OPTIONS ##############

#define AMLA_OPTION_DRAGON_MELEE
    [advancement]
        max_times=4
        description=_"Jaw damage +1, Claws damage +2"
        image="attacks/fangs.png"
        id=amla_dragon_melee
        strict_amla=yes
        [effect]
            apply_to=attack
            name=jaw
            increase_damage=1
        [/effect]
        [effect]
            apply_to=attack
            name=claws
            increase_damage=2
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=12%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=14%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=16%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_DRAGON_CARAPACE
    [advancement]
        max_times=2
        description=_"+10% resistance to blade and impact"
        image="attacks/ram.png"
        id=amla_dragon_carapace
        strict_amla=yes
        [effect]
            apply_to=resistance
            [resistance]
                blade=-10
                impact=-10
            [/resistance]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=12%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=14%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_DRAGON_FLIGHT
    [advancement]
        max_times=2
        description=_"+1 movement"
        image="attacks/slam-drake.png"
        id=amla_dragon_flight
        strict_amla=yes
        [effect]
            apply_to=movement
            increase=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=11%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=12%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_DRAGON_SOUL_EATER1
    [advancement]
        max_times=1
        description=_"Gain the Soul Eater ability"
        image="attacks/wail.png"
        id=amla_dragon_soul_eater1
        strict_amla=yes
        require_amla=amla_dragon_melee
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SOUL_EATER1}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_DRAGON_SOUL_EATER2
    [advancement]
        max_times=1
        description=_"Improve the Soul Eater ability"
        image="attacks/wail.png"
        id=amla_dragon_soul_eater2
        strict_amla=yes
        require_amla=amla_dragon_melee,amla_dragon_carapace,amla_dragon_soul_eater1
        [effect]
            apply_to=remove_ability
            [abilities]
                {ABILITY_SOUL_EATER1}
            [/abilities]
        [/effect]
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SOUL_EATER2}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=45
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_DRAGON_SOUL_EATER3
    [advancement]
        max_times=1
        description=_"Further improve the Soul Eater ability"
        image="attacks/wail.png"
        id=amla_dragon_soul_eater3
        strict_amla=yes
        require_amla=amla_dragon_melee,amla_dragon_melee,amla_dragon_carapace,amla_dragon_flight,amla_dragon_soul_eater2
        [effect]
            apply_to=remove_ability
            [abilities]
                {ABILITY_SOUL_EATER2}
            [/abilities]
        [/effect]
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SOUL_EATER3}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=60
        [/effect]
    [/advancement]
#enddef

############## MAL KESHAR OPTIONS ##############

#define AMLA_MAL_KESHAR
    {AMLA_OPTION_MELEE_TOUCH}
    {AMLA_OPTION_CHILL_TEMPEST}
    {AMLA_OPTION_SHADOW_WAVE}
    {AMLA_OPTION_MALICE2}
    {AMLA_OPTION_SHADOW_VEIL}
    {AMLA_OPTION_FROST_NOVA}
    {AMLA_OPTION_SPELLBIND}
    {AMLA_OPTION_REND}
    {AMLA_DEFAULT}
#enddef

#define AMLA_OPTION_MELEE_TOUCH
    [advancement]
        max_times=6
        description=_"+1 melee damage"
        image=attacks/touch-undead.png
        id=mal_keshar_amla_melee
        strict_amla=yes
        [effect]
            apply_to=attack
            name=touch
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=16%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=18%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_CHILL_TEMPEST
    [advancement]
        max_times=3
        description=_"+1 chill tempest damage"
        image=attacks/iceball.png
        id=mal_keshar_amla_chill
        strict_amla=yes
        [effect]
            apply_to=attack
            name=chill tempest
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=16%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=18%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_SHADOW_WAVE
    [advancement]
        max_times=5
        description=_"+1 shadow wave damage"
        image=attacks/dark-missile.png
        id=mal_keshar_amla_shadow
        strict_amla=yes
        [effect]
            apply_to=attack
            name=shadow wave
            increase_damage=2
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=16%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=18%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_FROST_NOVA
    [advancement]
        max_times=1
        id=mal_keshar_nova
        strict_amla=yes
        require_amla=mal_keshar_amla_chill,mal_keshar_amla_chill
        exclude_amla=ancient_lich_nova,mal_keshar_spellbind,mal_keshar_rend
        description= _ "Chill tempest gains area of effect damage"
        image=attacks/iceball.png
        [effect]
            apply_to=attack
            name=chill tempest
            [set_specials]
                {WEAPON_SPECIAL_FROST_NOVA}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_SPELLBIND
    [advancement]
        max_times=1
        id=mal_keshar_spellbind
        strict_amla=yes
        require_amla=mal_keshar_amla_shadow,mal_keshar_amla_shadow
        exclude_amla=ancient_lich_spellbind,mal_keshar_nova,mal_keshar_rend
        description= _ "Shadow wave reduces incoming fire, cold, and arcane damage"
        image=attacks/dark-missile.png
        [effect]
            apply_to=attack
            name=shadow wave
            [set_specials]
                {WEAPON_SPECIAL_SPELLBIND}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_REND
    [advancement]
        max_times=1
        id=mal_keshar_rend
        strict_amla=yes
        require_amla=mal_keshar_amla_melee,mal_keshar_amla_melee
        exclude_amla=ancient_lich_blood,mal_keshar_nova,mal_keshar_spellbind
        description= _ "Drain HP from nearby enemies, but lose HP every turn"
        image=attacks/curse.png
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SOUL_REND}
            [/abilities]
        [/effect]
        [effect]
            apply_to=attack
            name=touch
            remove_specials=drains
        [/effect]
        [effect]
            apply_to=attack
            name=touch
            [set_specials]
                {WEAPON_SPECIAL_REAP}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_MALICE2
    [advancement]
        max_times=1
        description=_"Improve the malice ability"
        image="attacks/wail.png"
        id=mal_keshar_amla_malice2
        strict_amla=yes
        require_amla=mal_keshar_amla_shadow,ancient_lich_malice
        [effect]
            apply_to=remove_ability
            [abilities]
                {ABILITY_MALICE1}
            [/abilities]
        [/effect]
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_MALICE2}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_SHADOW_VEIL
    [advancement]
        max_times=1
        description=_"Gain the ability to hide allied units"
        image="attacks/gaze.png"
        id=mal_keshar_amla_shadow_veil
        strict_amla=yes
        require_amla=mal_keshar_amla_shadow,mal_keshar_amla_shadow,mal_keshar_amla_chill
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SHADOW_VEIL}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
    [/advancement]
#enddef

############## EIDOLON OPTIONS ##############

#define AMLA_EIDOLON
    {AMLA_OPTION_BANEBLADE}
    {AMLA_OPTION_WAIL}
    {AMLA_OPTION_REAPER}
    {AMLA_OPTION_SORROW1}
    {AMLA_OPTION_SORROW2}
    {AMLA_DEFAULT}
#enddef

#define AMLA_OPTION_BANEBLADE
    [advancement]
        max_times=4
        description=_"+1 melee damage"
        image=attacks/baneblade.png
        id=eidolon_baneblade
        strict_amla=yes
        [effect]
            apply_to=attack
            name=baneblade
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=16%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=18%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_WAIL
    [advancement]
        max_times=5
        description=_"+1 ranged damage"
        image=attacks/wail.png
        id=eidolon_wail
        strict_amla=yes
        [effect]
            apply_to=attack
            name=wail
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=16%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=18%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_REAPER
    [advancement]
        max_times=1
        description=_"Improved baneblade drain"
        image="attacks/scythe.png"
        id=eidolon_reap
        strict_amla=yes
        require_amla=eidolon_baneblade,eidolon_baneblade
        [effect]
            apply_to=attack
            name=baneblade
            remove_specials=drains
        [/effect]
        [effect]
            apply_to=attack
            name=baneblade
            [set_specials]
                {WEAPON_SPECIAL_REAP}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_SORROW1
    [advancement]
        max_times=1
        description=_"Reduces nearby enemy units’ damage"
        image="attacks/curse.png"
        id=eidolon_sorrow1
        strict_amla=yes
        require_amla=eidolon_wail
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SORROW1}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_SORROW2
    [advancement]
        max_times=1
        description=_"Improves the sorrow ability"
        image="attacks/curse.png"
        id=eidolon_sorrow2
        strict_amla=yes
        require_amla=eidolon_wail,eidolon_wail,eidolon_sorrow1
        [effect]
            apply_to=remove_ability
            [abilities]
                {ABILITY_SORROW1}
            [/abilities]
        [/effect]
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SORROW2}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
    [/advancement]
#enddef

############## MALIN KESHAR OPTIONS ##############

#define AMLA_MALIN_KESHAR
    {AMLA_OPTION_MELEE_SWORD}
    {AMLA_OPTION_MALIN_RANGED}
    {AMLA_OPTION_VITALIZE}
    {AMLA_OPTION_CORPSE_LAUNCHER}
    {AMLA_OPTION_CORPSE_MASTER}
    {AMLA_OPTION_ZOMBIE_FRENZY}
    {AMLA_DEFAULT}
#enddef

#define AMLA_OPTION_MELEE_SWORD
    [advancement]
        max_times=4
        description=_"+1 melee damage"
        image=attacks/sword-human-short.png
        id=malin_keshar_amla_melee
        strict_amla=yes
        [effect]
            apply_to=attack
            name=short sword
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=16%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=18%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_MALIN_RANGED
    [advancement]
        max_times=2
        description=_"+1 ranged damage"
        image=attacks/iceball.png
        id=malin_keshar_amla_ranged
        strict_amla=yes
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=27%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=33%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_VITALIZE
    [advancement]
        max_times=1
        id=malin_melee_vitalize_amla
        description= _ "Improves the vitalize special"
        strict_amla=yes
        exclude_amla=malin_melee_vitalize2
        require_amla=malin_melee_vitalize,malin_keshar_amla_melee
        image=attacks/baneblade.png
        [effect]
            apply_to=attack
            range=melee
            remove_specials=did_vitalize1
        [/effect]
        [effect]
            apply_to=attack
            range=melee
            [set_specials]
                {WEAPON_SPECIAL_VITALIZE2}
                mode=append
            [/set_specials]
        [/effect]
        [effect]
            apply_to=max_experience
            increase=50
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_CORPSE_LAUNCHER
    [advancement]
        max_times=1
        description=_"Gains the corpse launch attack"
        image="attacks/dragonstaff.png"
        id=malin_corpse_launch_amla
        strict_amla=yes
        require_amla=malin_melee_plague
        exclude_amla=malin_corpse_launcher
        [effect]
            apply_to=new_attack
            name=corpse launch
            description= _"corpse launch"
            type=impact
            range=ranged
            damage=0
            number=1
            [specials]
                {WEAPON_SPECIAL_CORPSE_LAUNCHER}
                {WEAPON_SPECIAL_MAGICAL}
            [/specials]
            icon=attacks/dragonstaff.png
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=40
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_CORPSE_MASTER
    [advancement]
        max_times=1
        description=_"Gains the corpse master ability"
        image="attacks/touch-zombie.png"
        id=malin_corpse_master_amla
        strict_amla=yes
        require_amla=malin_melee_plague
        exclude_amla=malin_corpse_master
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_CORPSE_MASTER}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=40
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_ZOMBIE_FRENZY
    [advancement]
        max_times=1
        description=_"Gains the zombie frenzy ability"
        image="attacks/frenzy.png"
        id=malin_zombie_frenzy_amla
        strict_amla=yes
        require_amla=malin_melee_plague,malin_keshar_amla_melee
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_ZOMBIE_FRENZY}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=60
        [/effect]
    [/advancement]
#enddef

############## DROGAN GHOUL OPTIONS ##############

#define AMLA_OPTION_GHOUL_MELEE
    [advancement]
        max_times=5
        description=_"+1 melee damage"
        image=attacks/fangs.png
        id=ghast_melee
        strict_amla=yes
        [effect]
            apply_to=attack
            name=bite
            increase_damage=1
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=8%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=9%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_GHOUL_RESIST
    [advancement]
        max_times=4
        description=_"+5% resistance to blade and impact"
        image=icons/potion_red_small.png
        id=ghast_resist
        strict_amla=yes
        [effect]
            apply_to=resistance
            [resistance]
                blade=-5
                impact=-5
            [/resistance]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
#ifdef EASY
        [effect]
            apply_to=max_experience
            increase=6%
        [/effect]
#endif
#ifdef NORMAL
        [effect]
            apply_to=max_experience
            increase=7%
        [/effect]
#endif
#ifdef HARD
        [effect]
            apply_to=max_experience
            increase=8%
        [/effect]
#endif
    [/advancement]
#enddef

#define AMLA_OPTION_CANNIBALIZE1
    [advancement]
        max_times=1
        description=_"Gains the cannibalize ability"
        image="attacks/staff-necromantic.png"
        id=ghast_cannibalize1
        strict_amla=yes
        require_amla=ghast_melee
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_CANNIBALIZE1}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=30
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_CANNIBALIZE2
    [advancement]
        max_times=1
        description=_"Improves the cannibalize ability"
        image="attacks/staff-necromantic.png"
        id=ghast_cannibalize2
        strict_amla=yes
        require_amla=ghast_melee,ghast_melee,ghast_resist,ghast_cannibalize1
        [effect]
            apply_to=remove_ability
            [abilities]
                {ABILITY_CANNIBALIZE1}
            [/abilities]
        [/effect]
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_CANNIBALIZE2}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=60
        [/effect]
    [/advancement]
#enddef

#define AMLA_OPTION_DEATH_CLOUD
    [advancement]
        max_times=1
        description=_"Gains the death cloud ability"
        image="attacks/wail.png"
        id=ghast_death_cloud
        strict_amla=yes
        require_amla=ghast_melee,ghast_resist,ghast_resist,ghast_resist,ghast_cannibalize1
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_DEATH_CLOUD}
            [/abilities]
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=50
        [/effect]
    [/advancement]
#enddef