#textdomain wesnoth-utbs

#define KALEH_LEVEL_BONUS
    # We increase damage by one when we increase the level.
    [effect]
        apply_to=attack
        times=per level
        increase_damage=1
    [/effect]
#enddef

#define KALEH_ADVANCEMENT HP_RAISE XP EFFECT VARIATION
    [advancement]
        max_times=1
        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total={HP_RAISE}
            increase={HP_RAISE}
        [/effect]
        [effect]
            apply_to=max_experience
            increase={XP}
        [/effect]
        [effect]
            apply_to=variation
            name={VARIATION}
        [/effect]
        {EFFECT}
    [/advancement]
#enddef

# ADVANCEMENTS:
#define KALEH_LEADERSHIP VARIATION
    {KALEH_ADVANCEMENT 3 8 (
        id=leadership
        description= _ "a leader in battle"
        image=units/elves-desert/kaleh-leading.png
        require_amla=""
        [effect]
            apply_to=new_ability
            [filter]
                level=2
            [/filter]
            [abilities]
                {ABILITY_LEADERSHIP_LEVEL_2}
            [/abilities]
        [/effect]
        [effect]
            apply_to=new_ability
            [filter]
                level=3
            [/filter]
            [abilities]
                {ABILITY_LEADERSHIP_LEVEL_3}
            [/abilities]
        [/effect]
    ) {VARIATION}}
#enddef

#define KALEH_BOLAS VARIATION
    {KALEH_ADVANCEMENT 4 6 (
        id=bolas
        description= _ "trained by Nym in using the bolas"
        image=attacks/bolas.png
        require_amla=""
        [effect]
            apply_to=new_attack
            name=bolas
            description= _"bolas"
            type=impact
            range=ranged
            damage=4
            number=2
            [specials]
                {WEAPON_SPECIAL_SLOW}
            [/specials]
            icon=attacks/bolas.png
        [/effect]
        [effect]
            apply_to=attack
            name=bolas
            times=per level
            increase_damage=1
        [/effect]
        [effect]
            apply_to=new_animation
            [attack_anim]
                [filter_attack]
                    name=bolas
                [/filter_attack]
                [missile_frame]
                    begin=-150
                    end=0
                    image=projectiles/bolas-n.png
                    image_diagonal=projectiles/bolas-ne.png
                [/missile_frame]
                [if]
                    hits=yes
                    [frame]
                        begin=-300
                        end=-200
                        image=units/elves-desert/kaleh.png
                        sound=hatchet.wav
                    [/frame]
                [/if]
                [else]
                    hits=no
                    [frame]
                        begin=-300
                        end=-200
                        image=units/elves-desert/kaleh.png
                        sound=hatchet-miss.wav
                    [/frame]
                [/else]
                [frame]
                    begin=-200
                    end=0
                    image=units/elves-desert/kaleh.png
                [/frame]
                {SOUND:SLOW}
            [/attack_anim]
        [/effect]
    ) {VARIATION}}
#enddef

# Special macro to add the damage bonus per level. Use only once!
#define KALEH_SWORD_FIRST VARIATION
    {KALEH_ADVANCEMENT 6 4 (
        id=sword
        description= _ "a better swordsman"
        image=attacks/sword-elven.png
        require_amla=""
        [effect]
            apply_to=attack
            range=melee
            increase_damage=2
        [/effect]
        {KALEH_LEVEL_BONUS}
    ) {VARIATION}}
#enddef

#define KALEH_SWORD VARIATION
    {KALEH_ADVANCEMENT 6 4 (
        id=sword
        description= _ "a better swordsman"
        image=attacks/sword-elven.png
        require_amla=""
        [effect]
            apply_to=attack
            range=melee
            increase_damage=2
        [/effect]
    ) {VARIATION}}
#enddef

#define KALEH_SWORD2 VARIATION
    {KALEH_ADVANCEMENT 6 6 (
        id=sword2
        description= _ "a better swordsman"
        image=attacks/sword-elven.png
        require_amla=sword
        [effect]
            apply_to=attack
            range=melee
            increase_damage=2
        [/effect]
    ) {VARIATION}}
#enddef

# Special macro to add the damage bonus per level. Use only once!
#define KALEH_BOW_FIRST VARIATION
    {KALEH_ADVANCEMENT 4 4 (
        id=bow
        description= _ "a better archer"
        image=attacks/bow-elven.png
        require_amla=""
        [effect]
            apply_to=attack
            name=bow
            increase_damage=1
            increase_attacks=1
        [/effect]
        {KALEH_LEVEL_BONUS}
    ) {VARIATION}}
#enddef

#define KALEH_BOW VARIATION
    {KALEH_ADVANCEMENT 4 4 (
        id=bow
        description= _ "a better archer"
        image=attacks/bow-elven.png
        require_amla=""
        [effect]
            apply_to=attack
            name=bow
            increase_damage=1
            increase_attacks=1
        [/effect]
    ) {VARIATION}}
#enddef

#define KALEH_BOW2 VARIATION
    {KALEH_ADVANCEMENT 4 6 (
        id=bow2
        description= _ "a better archer"
        image=attacks/bow-elven.png
        require_amla=bow
        [effect]
            apply_to=attack
            name=bow
            increase_damage=2
        [/effect]
    ) {VARIATION}}
#enddef

#define KALEH_BOW3 VARIATION
    {KALEH_ADVANCEMENT 4 8 (
        id=bow3
        description= _ "a marksman with the bow"
        image=attacks/bow-elven.png
        require_amla=bow2
        [effect]
            apply_to=attack
            name=bow
            increase_damage=1
            [set_specials]
                {WEAPON_SPECIAL_MARKSMAN}
            [/set_specials]
        [/effect]
    ) {VARIATION}}
#enddef

#define KALEH_SUSTENANCE VARIATION
    {KALEH_ADVANCEMENT 5 8 (
        id=sustenance
        description= _ "gain +20% resistance under the sun"
        image=attacks/sand-storm.png
        require_amla=bow
        [effect]
            apply_to=new_ability
            [abilities]
                [resistance]
                    id=sustenance
                    add=20
                    max_value=30
                    apply_to=blade,pierce,impact,fire,cold,arcane
                    [filter_base_value]
                        greater_than=-1
                    [/filter_base_value]
                    [filter_self]
                        [filter_location]
                            time_of_day=lawful
                        [/filter_location]
                    [/filter_self]
                    name= _ "sustenance"
                    description= _ "Sustenance:
This unit's resistances are increased by 20% in daylight, on defense and attack. Vulnerabilities are not affected."
                    affect_self=yes
                [/resistance]
            [/abilities]
        [/effect]
    ) {VARIATION}}
#enddef

#define KALEH_ARMOR VARIATION
    {KALEH_ADVANCEMENT 6 10 (
        id=armor
        description= _ "gain +10% resistance to blade, pierce and impact"
        image=attacks/heater-shield.png
        require_amla="sword,sword2"
        [effect]
            apply_to=new_ability
            [abilities]
                [resistance]
                    id=armor
                    add=10
                    max_value=30
                    apply_to=blade,pierce,impact
                    # don't clutter ability list
                    name= ""
                    description= ""	# wmllint: ignore
                    affect_self=yes
                [/resistance]
            [/abilities]
        [/effect]
    ) {VARIATION}}
#enddef
#define KALEH_STUN VARIATION
    {KALEH_ADVANCEMENT 4 10 (
        id=stun
        description= _ "gain a stunning attack that disrupts enemy ZOC"
        image=attacks/scimitar.png
        require_amla="sword"
        [effect]
            apply_to=new_attack
            name=sword_rush
            description= _ "sword"
            type=blade
            icon=attacks/sword-elven.png
            damage=5
            number=4
            range=melee
            defense_weight=0
            [specials]
                [chance_to_hit]
                    id=stun
                    name= _ "stun"
                    description= _ "Stun:
This attack puts enormous pressure on the enemy, disrupting his ZOC if a hit is landed. The attacker is exposing himself to attack and will be slowed as a result of the effort. Not active on defense."
                    name_inactive= _ "stun"
                    description_inactive= _ "Stun:
This attack puts enormous pressure on the enemy, disrupting his ZOC if a hit is landed. The attacker is exposing himself to attack and will be slowed as a result of the effort. Not active on defense."
                    apply_to=opponent
                    value=60
                    cumulative=yes
                [/chance_to_hit]
            [/specials]
        [/effect]
        [effect]
            apply_to=attack
            name=sword_rush
            times=per level
            increase_damage=1
        [/effect]
    ) {VARIATION}}
#enddef

#define KALEH_ATTACKS MELEE_DAMAGE MELEE_STRIKES RANGE_DAMAGE RANGE_STRIKES
#enddef

#define KALEH
    id=Kaleh
    race=elf
    name= _ "Kaleh of the Quenoth Elves"
    image=units/elves-desert/kaleh.png
    hitpoints=28
    movement_type=woodland
    #desert elves move fast across the sands, but are not used to forests
    #they are also a bit faster in caves
    [movement_costs]
        sand=1
        forest=2
        cave=2
        frozen=3
    [/movement_costs]
    [defense]
        sand=40
        forest=50
    [/defense]
    movement=5
    experience=22
    level=1
    profile=portraits/kaleh.png
    alignment=lawful
    [leading_anim]
        [frame]
            begin=-150
            end=150
            image=units/elves-desert/kaleh-leading.png
        [/frame]
    [/leading_anim]
    advances_to=null
    cost=14
    usage=fighter
    description= _ "Kaleh is still a young Elf of the Quenoth, on the verge of adulthood. He trained with his father with the bow and sword, joining him in lighter expeditions and raids. When his father was lost, Kaleh became more serious and solemn than is usual for those who walk under the two suns. He turned inwards for answers and guidance, not knowing how much his people would look towards him for guidance in times to come."+{SPECIAL_NOTES}+{SPECIAL_NOTES_LEADERSHIP}+{SPECIAL_NOTES_MARKSMAN}+{SPECIAL_NOTES_SLOW}
    die_sound={SOUND_LIST:ELF_HIT}
    {DEFENSE_ANIM_RANGE "units/elves-desert/kaleh-defend.png" units/elves-desert/kaleh.png {SOUND_LIST:ELF_HIT} melee}
    {DEFENSE_ANIM_RANGE "units/elves-desert/kaleh-ranged-defend.png" units/elves-desert/kaleh-ranged.png {SOUND_LIST:ELF_HIT} ranged}
    # Melee damage increased by 1, ranged damage decreased by 1
    [attack]
        name=sword
        description= _"sword"
        type=blade
        range=melee
        damage=5
        number=4
        icon=attacks/sword-elven.png
    [/attack]
    [attack]
        name=bow
        description= _"bow"
        type=pierce
        range=ranged
        damage=2
        number=3
        icon=attacks/bow-elven.png
    [/attack]
    [attack_anim]
        [filter_attack]
            name=bow
        [/filter_attack]
        [missile_frame]
            begin=-100
            end=0
            image=projectiles/missile-n.png
            image_diagonal=projectiles/missile-ne.png
        [/missile_frame]
        [frame]
            begin=-445
            end=-380
            image="units/elves-desert/kaleh-ranged.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-380
                end=-305
                image="units/elves-desert/kaleh-ranged-1.png"
                sound=bow.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-380
                end=-305
                image="units/elves-desert/kaleh-ranged-1.png"
                sound=bow-miss.ogg
            [/frame]
        [/else]
        [frame]
            begin=-305
            end=-230
            image="units/elves-desert/kaleh-ranged-2.png"
        [/frame]
        [frame]
            begin=-230
            end=-130
            image="units/elves-desert/kaleh-ranged-3.png"
        [/frame]
        [frame]
            begin=-130
            end=-100
            image="units/elves-desert/kaleh-ranged-4.png"
        [/frame]
        [frame]
            begin=-100
            end=0
            image="units/elves-desert/kaleh-ranged-4.png"
        [/frame]
        [frame]
            begin=0
            end=65
            image="units/elves-desert/kaleh-ranged.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=sword
        [/filter_attack]
        [frame]
            begin=-200
            end=-100
            image=units/elves-desert/kaleh-melee-1.png
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image=units/elves-desert/kaleh-melee-2.png
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image=units/elves-desert/kaleh-melee-2.png
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=100
            end=200
            image=units/elves-desert/kaleh.png
        [/frame]
    [/attack_anim]
#enddef
[unit_type]
    {KALEH}
    [variation]
        {KALEH}
        variation_name=Youth
        inherit=no
        name= _ "Desert Youth"
        # Special macros to add the damage bonus per level. Use only once!
        {KALEH_SWORD_FIRST  Fighter}
        {KALEH_BOW_FIRST    Fighter}
    [/variation]
    # Generic Fighter variation tree.
    [variation]
        {KALEH}
        variation_name=Fighter
        inherit=no
        name= _ "Desert Fighter"
        {KALEH_LEADERSHIP   Captain }
        {KALEH_BOLAS        Hero    }
        {KALEH_SWORD        Fighter1}
        {KALEH_SWORD2       Hero    }
        {KALEH_BOW          Fighter1}
        {KALEH_BOW2         Fighter1}
        {KALEH_BOW3         Fighter1}
        {KALEH_SUSTENANCE   Fighter1}
        {KALEH_ARMOR        Fighter1}
        {KALEH_STUN         Fighter1}
    [/variation]
    [variation]
        {KALEH}
        variation_name=Fighter1
        inherit=no
        level=2
        experience=40
        name= _ "Desert Fighter"
        {KALEH_LEADERSHIP   Captain2}
        {KALEH_BOLAS        Hero2   }
        {KALEH_SWORD        Fighter2}
        {KALEH_SWORD2       Hero2   }
        {KALEH_BOW          Fighter2}
        {KALEH_BOW2         Fighter2}
        {KALEH_BOW3         Fighter2}
        {KALEH_SUSTENANCE   Fighter2}
        {KALEH_ARMOR        Fighter2}
        {KALEH_STUN         Fighter2}
    [/variation]
    [variation]
        {KALEH}
        variation_name=Fighter2
        inherit=no
        level=2
        experience=40
        name= _ "Desert Fighter"
        {KALEH_LEADERSHIP   Captain3}
        {KALEH_BOLAS        Hero3   }
        {KALEH_SWORD        Fighter3}
        {KALEH_SWORD2       Hero3   }
        {KALEH_BOW          Fighter3}
        {KALEH_BOW2         Fighter3}
        {KALEH_BOW3         Fighter3}
        {KALEH_SUSTENANCE   Fighter3}
        {KALEH_ARMOR        Fighter3}
        {KALEH_STUN         Fighter3}
    [/variation]
    [variation]
        {KALEH}
        variation_name=Fighter3
        inherit=no
        level=3
        experience=100
        name= _ "Desert Fighter"
        {KALEH_LEADERSHIP   Captain3}
        {KALEH_BOLAS        Hero3   }
        {KALEH_SWORD        Fighter3}
        {KALEH_SWORD2       Hero3   }
        {KALEH_BOW          Fighter3}
        {KALEH_BOW2         Fighter3}
        {KALEH_BOW3         Fighter3}
        {KALEH_SUSTENANCE   Fighter3}
        {KALEH_ARMOR        Fighter3}
        {KALEH_STUN         Fighter3}
    [/variation]
    # Captain variation tree - reached when leadership is chosen; disables bolas
    [variation]
        {KALEH}
        variation_name=Captain
        inherit=no
        level=2
        experience=40
        name= _ "Desert Captain"
        {KALEH_LEADERSHIP   Captain2}
        {KALEH_SWORD        Captain2}
        {KALEH_SWORD2       Captain2}
        {KALEH_BOW          Captain2}
        {KALEH_BOW2         Captain2}
        {KALEH_BOW3         Captain2}
        {KALEH_SUSTENANCE   Captain2}
        {KALEH_ARMOR        Captain2}
        {KALEH_STUN         Captain2}
    [/variation]
    [variation]
        {KALEH}
        variation_name=Captain2
        inherit=no
        level=2
        experience=40
        name= _ "Desert Captain"
        {KALEH_LEADERSHIP   Captain3}
        {KALEH_SWORD        Captain3}
        {KALEH_SWORD2       Captain3}
        {KALEH_BOW          Captain3}
        {KALEH_BOW2         Captain3}
        {KALEH_BOW3         Captain3}
        {KALEH_SUSTENANCE   Captain3}
        {KALEH_ARMOR        Captain3}
        {KALEH_STUN         Captain3}
    [/variation]
    [variation]
        {KALEH}
        variation_name=Captain3
        inherit=no
        level=3
        experience=100
        name= _ "Desert Marshal"
        {KALEH_LEADERSHIP   Captain3}
        {KALEH_SWORD        Captain3}
        {KALEH_SWORD2       Captain3}
        {KALEH_BOW          Captain3}
        {KALEH_BOW2         Captain3}
        {KALEH_BOW3         Captain3}
        {KALEH_SUSTENANCE   Captain3}
        {KALEH_ARMOR        Captain3}
        {KALEH_STUN         Captain3}
    [/variation]
    # Hero variation tree - reached when bolas or sword2 is chosen; disables leadership
    [variation]
        {KALEH}
        variation_name=Hero
        inherit=no
        level=2
        experience=40
        name= _ "Desert Hero"
        {KALEH_BOLAS        Hero2}
        {KALEH_SWORD        Hero2}
        {KALEH_SWORD2       Hero2}
        {KALEH_BOW          Hero2}
        {KALEH_BOW2         Hero2}
        {KALEH_BOW3         Hero2}
        {KALEH_SUSTENANCE   Hero2}
        {KALEH_ARMOR        Hero2}
        {KALEH_STUN         Hero2}
    [/variation]
    [variation]
        {KALEH}
        variation_name=Hero2
        inherit=no
        level=2
        experience=40
        name= _ "Desert Hero"
        {KALEH_BOLAS        Hero3}
        {KALEH_SWORD        Hero3}
        {KALEH_SWORD2       Hero3}
        {KALEH_BOW          Hero3}
        {KALEH_BOW2         Hero3}
        {KALEH_BOW3         Hero3}
        {KALEH_SUSTENANCE   Hero3}
        {KALEH_ARMOR        Hero3}
        {KALEH_STUN         Hero3}
    [/variation]
    [variation]
        {KALEH}
        variation_name=Hero3
        inherit=no
        level=3
        experience=100
        name= _ "Desert Champion"
        {KALEH_BOLAS        Hero3}
        {KALEH_SWORD        Hero3}
        {KALEH_SWORD2       Hero3}
        {KALEH_BOW          Hero3}
        {KALEH_BOW2         Hero3}
        {KALEH_BOW3         Hero3}
        {KALEH_SUSTENANCE   Hero3}
        {KALEH_ARMOR        Hero3}
        {KALEH_STUN         Hero3}
    [/variation]
[/unit_type]
