#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
