#textdomain wesnoth
# Ability macros to be included in the SingleWML description of a unit.

#define ABILITY_HEALS
    # Canned definition of the heal+4 ability to be included in an [abilities] clause.
    [heals]
        value=4
        id=healing
        affect_allies=yes
        name= _ "heals +4"
        description=  _ "Heals +4:
Allows the unit to heal adjacent friendly units at the beginning of each turn.

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

#define ABILITY_EXTRA_HEAL
    [heals]
        value=8
        id=healing
        affect_allies=yes
        name= _ "heals +8"
        description= _ "Heals +8:
This unit combines herbal remedies with magic to heal units more quickly than is normally possible on the battlefield.

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

#define ABILITY_UNPOISON
    # Canned definition of the cure-poison ability to be included
    # in an [abilities] clause.
    [heals]
        affect_allies=yes
        id=curing
        name= _ "cures"
        description= _ "Cures:
A curer can cure a unit of poison, although that unit will receive no additional healing on the turn it is cured of the poison."
        affect_self=no
        poison=cured
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_CURES
    # Canned definition of the cure ability (which entails heal+8) to be
    # included in an [abilities] clause..
    {ABILITY_UNPOISON}
    {ABILITY_EXTRA_HEAL}
#enddef

#define ABILITY_REGENERATES
    # Canned definition of the Regenerate ability to be included in an [abilities]
    # clause.
    [regenerate]
        value=8
        id=regenerates
        name= _ "regenerates"
        description= _ "Regenerates:
The unit will heal itself 8 HP per turn. If it is poisoned, it will remove the poison instead of healing."
        affect_self=yes
        poison=cured
    [/regenerate]
#enddef

#define ABILITY_STEADFAST
    # Canned definition of the Steadfast ability to be included in an [abilities]
    # clause.
    [resistance]
        id=steadfast
        multiply=2
        max_value=50
        apply_to=blade,pierce,impact,fire,cold,arcane
        [filter_base_value]
            greater_than=0
        [/filter_base_value]
        name= _ "steadfast"
        description= _ "Steadfast:
This unit's resistances are doubled, up to a maximum of 50%, when defending. Vulnerabilities are not affected."
        affect_self=yes
        active_on=defense
    [/resistance]
#enddef

#define ABILITY_LEADERSHIP_LEVEL_1
    # Canned definition of the Leadership (level 1) ability to be included in an
    # [abilities] clause.
    [leadership]
        id=leadership
        value=25
        cumulative=no
        name= _ "leadership"
        description= _ "Leadership:
This unit can lead friendly units that are next to it, making them fight better.

Adjacent friendly units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=0
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_LEADERSHIP_LEVEL_2
    # Canned definition of the Leadership (level 2) ability to be included in an
    # [abilities] clause.
    [leadership]
        id=leadership
        value=50
        cumulative=no
        name= _ "leadership"
        description= _ "Leadership:
This unit can lead friendly units that are next to it, making them fight better.

Adjacent friendly units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=0
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=25
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=1
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_LEADERSHIP_LEVEL_3
    # Canned definition of the Leadership (level 3) ability to be included in an
    # [abilities] clause.
    [leadership]
        id=leadership
        value=75
        cumulative=no
        name= _ "leadership"
        description= _ "Leadership:
This unit can lead friendly units that are next to it, making them fight better.

Adjacent friendly units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=0
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=50
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=1
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=25
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=2
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_LEADERSHIP_LEVEL_4
    # Canned definition of the Leadership (level 4) ability to be included in an
    # [abilities] clause.
    [leadership]
        id=leadership
        value=100
        cumulative=no
        name= _ "leadership"
        description= _ "Leadership:
This unit can lead friendly units that are next to it, making them fight better.

Adjacent friendly units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=0
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=75
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=1
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=50
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=2
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=25
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=3
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_LEADERSHIP_LEVEL_5
    # Canned definition of the Leadership (level 5) ability to be included in an
    # [abilities] clause.
    [leadership]
        id=leadership
        value=125
        cumulative=no
        name= _ "leadership"
        description= _ "Leadership:
This unit can lead friendly units that are next to it, making them fight better.

Adjacent friendly units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=0
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=100
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=1
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=75
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=2
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=50
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=3
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [leadership]
        id=leadership
        value=25
        cumulative=no
        affect_self=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                level=4
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_SKIRMISHER
    # Canned definition of the Skirmisher ability to be included in an [abilities]
    # clause.
    [skirmisher]
        id=skirmisher
        name= _ "skirmisher"
        description= _ "Skirmisher:
This unit is skilled in moving past enemies quickly, and ignores all enemy Zones of Control."
        affect_self=yes
    [/skirmisher]
#enddef

#define ABILITY_ILLUMINATES
    # Canned definition of the Illuminates ability to be included in an
    # [abilities] clause.
    [illuminates]
        id=illumination
        value=25
        max_value=25
        cumulative=no
        name= _ "illuminates"
        description= _ "Illuminates:
This unit illuminates the surrounding area, making lawful units fight better, and chaotic units fight worse.

Any units adjacent to this unit will fight as if it were dusk when it is night, and as if it were day when it is dusk."
        affect_self=yes
    [/illuminates]
#enddef

#define ABILITY_TELEPORT
    # Canned definition of the TELEPORT ability to be included in an
    # [abilities] clause.
    [teleport]
        id=teleport
        name= _ "teleport"
        description= _ "Teleport:
This unit may teleport between any two empty villages owned by its side using one of its moves."
    [/teleport]
#enddef

#define ABILITY_AMBUSH
    # Canned definition of the Ambush ability to be included in an
    # [abilities] clause.
    [hides]
        id=ambush
        name= _ "ambush"
        name_inactive= _ "ambush"
        description= _ "Ambush:
This unit can hide in forest, and remain undetected by its enemies.

Enemy units cannot see this unit while it is in forest, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        description_inactive= _ "Ambush:
This unit can hide in forest, and remain undetected by its enemies.

Enemy units cannot see this unit while it is in forest, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain=Gs^Fp,Gg^Fet,Gs^Ft,Aa^Fpa
            [/filter_location]
        [/filter_self]
    [/hides]
#enddef

#define ABILITY_NIGHTSTALK
    # Canned definition of the Nightstalk ability to be included in an
    # [abilities] clause.
    [hides]
        id=nightstalk
        name= _ "nightstalk"
        description= _ "Nightstalk:
The unit becomes invisible during night.

Enemy units cannot see this unit at night, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        name_inactive= _ "nightstalk"
        description_inactive= _ "Nightstalk:
The unit becomes invisible during night.

Enemy units cannot see this unit at night, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        affect_self=yes
        [filter_self]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
        [/filter_self]
    [/hides]
#enddef

#define ABILITY_CONCEALMENT
    # Canned definition of the Concealment ability to be included in an
    # [abilities] clause.
    [hides]
        id=concealment
        name= _ "concealment"
        description= _ "Concealment:
This unit can hide in villages (with the exception of water villages), and remain undetected by its enemies, except by those standing next to it.

Enemy units can not see this unit while it is in a village, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        name_inactive= _ "concealment"
        description_inactive= _ "Concealment:
This unit can hide in villages (with the exception of water villages), and remain undetected by its enemies, except by those standing next to it.

Enemy units can not see this unit while it is in a village, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain=Ss^Vhs, Ss^Vm, Gs^Vht, Uu^Vu, Uu^Vud, Hh^Vhh, Ha^Vhha, Mm^Vhh, Gg^Ve, Aa^Vha, Gg^Vh, Dd^Vda, Dd^Vdt, Aa^Vea
            [/filter_location]
        [/filter_self]
    [/hides]
#enddef

#define ABILITY_SUBMERGE
    # Canned definition of the Submerge ability to be included in an
    # [abilities] clause.
    [hides]
        id=submerge
        name= _ "submerge"
        description= _ "Submerge:
This unit can hide in deep water, and remain undetected by its enemies.

Enemy units cannot see this unit while it is in deep water, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        name_inactive= _ "submerge"
        description_inactive= _ "Submerge:
This unit can hide in deep water, and remain undetected by its enemies.

Enemy units cannot see this unit while it is in deep water, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain=Wo
            [/filter_location]
        [/filter_self]
    [/hides]
#enddef

# wmllint: unbalanced-on
#define ABILITY_FEEDING
    # Canned definition of the Feeding ability to be included in an
    # [abilities] clause.  Note: this is deliberately unbalanced WML,
    # in order to close the abilities clause then insert the event
    # then reopen the abilities clause.
    [dummy]
        id=feeding
        name= _ "feeding"
        description=_ "Feeding:
This unit gains 1 hitpoint added to its maximum whenever it kills a living unit."
    [/dummy]
[/abilities]
[event]
    name=die
    first_time_only=no

    [filter]
        [not]
            [wml_filter]
                [status]
                    not_living="yes"
                [/status]
            [/wml_filter]
        [/not]
    [/filter]

    [filter_second]
        ability=feeding
    [/filter_second]

    [unstore_unit]
        variable=second_unit
        {COLOR_HEAL}
        text= _ "+1 max HP"
        find_vacant=no
    [/unstore_unit]

    [object]
        silent=yes
        duration=forever

        [filter]
            x,y=$x2,$y2
        [/filter]

        [effect]
            apply_to=hitpoints
            increase_total=1
            increase=1
        [/effect]
    [/object]
[/event]
[+abilities]
#enddef
# wmllint: unbalanced-off

#weapons specials

#define WEAPON_SPECIAL_BERSERK
    # Canned definition of the Berserk ability to be included in a
    # [specials] clause.
    [berserk]
        id=berserk
        name= _ "berserk"
        description= _ "Berserk:
Whether used offensively or defensively, this attack presses the engagement until one of the combatants is slain, or 30 rounds of attacks have occurred."
        value=30
    [/berserk]
#enddef

#define WEAPON_SPECIAL_BACKSTAB
    # Canned definition of the Backstab ability to be included in a
    # [specials] clause.
    [damage]
        id=backstab
        name= _ "backstab"
        description= _ "Backstab:
When used offensively, this attack deals double damage if there is an enemy of the target on the opposite side of the target, and that unit is not incapacitated (e.g. turned to stone)."
        multiply=2
        backstab=yes
        active_on=offense
    [/damage]
#enddef

#define WEAPON_SPECIAL_PLAGUE_TYPE TYPE
    # Canned definition of the Plague ability to be included in a
    # [specials] clause (with type specifier).
    [plague]
        id=plague({TYPE})
        name= _ "plague"
        description= _ "Plague:
When a unit is killed by a Plague attack, that unit is replaced with a unit identical to and on the same side as the unit with the Plague attack. This doesn't work on Undead or units in villages."
        type={TYPE}
    [/plague]
#enddef

#define WEAPON_SPECIAL_PLAGUE
    # Canned definition of the Plague ability to be included in a
    # [specials] clause.
    [plague]
        id=plague
        name= _ "plague"
        description= _ "Plague:
When a unit is killed by a Plague attack, that unit is replaced with a Walking Corpse on the same side as the unit with the Plague attack. This doesn't work on Undead or units in villages."
        type=Walking Corpse
    [/plague]
#enddef

#define WEAPON_SPECIAL_SLOW
    # Canned definition of the Slow ability to be included in a
    # [specials] clause.
    [slow]
        id=slow
        name= _ "slows"
        description= _ "Slow:
This attack slows the target until it ends a turn. Slow halves the damage caused by attacks and the movement cost for a slowed unit is doubled. A unit that is slowed will feature a snail icon in its sidebar information when it is selected."
    [/slow]
#enddef

#define WEAPON_SPECIAL_STONE
    # Canned definition of the Stone ability to be included in a
    # [specials] clause.
    [stones]
        id=stones
        name= _ "stones"
        description= _ "Stone:
This attack turns the target to stone. Units that have been turned to stone may not move or attack."
    [/stones]
#enddef

#define WEAPON_SPECIAL_MARKSMAN
    # Canned definition of the Marksman ability to be included in a
    # [specials] clause.
    [chance_to_hit]
        id=marksman
        name= _ "marksman"
        description= _ "Marksman:
When used offensively, this attack always has at least a 60% chance to hit."
        value=60
        cumulative=yes
        active_on=offense
    [/chance_to_hit]
#enddef

#define WEAPON_SPECIAL_MAGICAL
    # Canned definition of the Magical (targeting) ability to be included in a
    # [specials] clause.
    [chance_to_hit]
        id=magical
        name= _ "magical"
        description= _ "Magical:
This attack always has a 70% chance to hit regardless of the defensive ability of the unit being attacked."
        value=70
        cumulative=no
    [/chance_to_hit]
#enddef

#define WEAPON_SPECIAL_SWARM
    # Canned definition of the Swarm ability to be included in a
    # [specials] clause.
    [attacks]
        id=swarm
        name= _ "swarm"
        description= _ "Swarm:
The number of strikes of this attack decreases when the unit is wounded. The number of strikes is proportional to the % of HP/maximum HP the unit has. For example a unit with 3/4 of its maximum HP will get 3/4 of the number of strikes."
    [/attacks]
#enddef

#define WEAPON_SPECIAL_CHARGE
    # Canned definition of the Charge ability to be included in a
    # [specials] clause.
    [damage]
        id=charge
        name= _ "charge"
        description= _ "Charge:
When used offensively, this attack deals double damage to the target. It also causes this unit to take double damage from the target's counterattack."
        multiply=2
        apply_to=both
        active_on=offense
    [/damage]
#enddef

#define WEAPON_SPECIAL_DRAIN
    # Canned definition of the Drain ability to be included in a
    # [specials] clause.
    [drains]
        id=drains
        name= _ "drains"
        description= _ "Drain:
This unit drains health from living units, healing itself for half the amount of damage it deals (rounded down)."
    [/drains]
#enddef

#define WEAPON_SPECIAL_FIRSTSTRIKE
    # Canned definition of the First-strike ability to be included in a
    # [specials] clause.
    [firststrike]
        id=firststrike
        name= _ "firststrike"
        description= _ "First Strike:
This unit always strikes first with this attack, even if they are defending."
    [/firststrike]
#enddef

#define WEAPON_SPECIAL_POISON
    # Canned definition of the Poison ability to be included in a
    # [specials] clause.
    [poison]
        id=poison
        name= _ "poison"
        description= _ "Poison:
This attack poisons living targets. Poisoned units lose 8 HP every turn until they are cured or are reduced to 1 HP. Poison can not, of itself, kill a unit."
    [/poison]
#enddef
