#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}
    [animation]
        apply_to=pre_teleport
        start_time=-1200
        alpha="1.0~0.2"
        blend_ratio="0.0~1.0:400,1.0:200"
        blend_color=140,60,255

        teleport_sparkle_1_start_time=-1200
        teleport_sparkle_2_start_time=-1000
        teleport_sparkle_3_start_time=-800

        [teleport_sparkle_1_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=-10
            halo_y=30~-30
        [/teleport_sparkle_1_frame]
        [teleport_sparkle_2_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=0
            halo_y=40~-40
        [/teleport_sparkle_2_frame]
        [teleport_sparkle_3_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=10
            halo_y=30~-30
        [/teleport_sparkle_3_frame]

        [frame]
            image="units/undead-necromancers/lich-magic-[1~3].png:[100*2,300]"
        [/frame]
        [frame]
            image="misc/blank-hex.png:300"
        [/frame]
    [/animation]

    [animation]
        apply_to=post_teleport
        start_time=-1200
        alpha="0.2~1.0"
        blend_ratio="1.0:200,1.0~0.0:400"
        blend_color=140,60,255

        teleport_sparkle_1_start_time=-1200
        teleport_sparkle_2_start_time=-1000
        teleport_sparkle_3_start_time=-800

        [teleport_sparkle_1_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=10
            halo_y=-30~30
        [/teleport_sparkle_1_frame]
        [teleport_sparkle_2_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=0
            halo_y=-40~40
        [/teleport_sparkle_2_frame]
        [teleport_sparkle_3_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=-10
            halo_y=-30~30
        [/teleport_sparkle_3_frame]
        [frame]
            image="misc/blank-hex.png:300"
        [/frame]
        [frame]
            image="units/undead-necromancers/lich-magic-[3~1].png:[300,100*2]"
        [/frame]
    [/animation]
#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]
    [animation]
        apply_to=pre_teleport
        start_time=-1200
        alpha="1.0~0.2"
        blend_ratio="0.0~1.0:400,1.0:200"
        blend_color=140,60,255

        teleport_sparkle_1_start_time=-1200
        teleport_sparkle_2_start_time=-1000
        teleport_sparkle_3_start_time=-800

        [teleport_sparkle_1_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=-10
            halo_y=30~-30
        [/teleport_sparkle_1_frame]
        [teleport_sparkle_2_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=0
            halo_y=40~-40
        [/teleport_sparkle_2_frame]
        [teleport_sparkle_3_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=10
            halo_y=30~-30
        [/teleport_sparkle_3_frame]

        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[1~3].png:[100*2,300]"
        [/frame]
        [frame]
            image="misc/blank-hex.png:300"
        [/frame]
    [/animation]

    [animation]
        apply_to=post_teleport
        start_time=-1200
        alpha="0.2~1.0"
        blend_ratio="1.0:200,1.0~0.0:400"
        blend_color=140,60,255

        teleport_sparkle_1_start_time=-1200
        teleport_sparkle_2_start_time=-1000
        teleport_sparkle_3_start_time=-800

        [teleport_sparkle_1_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=10
            halo_y=-30~30
        [/teleport_sparkle_1_frame]
        [teleport_sparkle_2_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=0
            halo_y=-40~40
        [/teleport_sparkle_2_frame]
        [teleport_sparkle_3_frame]
            duration=800
            halo=halo/teleport-[9,8,1~9].png
            halo_x=-10
            halo_y=-30~30
        [/teleport_sparkle_3_frame]
        [frame]
            image="misc/blank-hex.png:300"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[3~1].png:[300,100*2]"
        [/frame]
    [/animation]
#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
