#textdomain wesnoth-help

# These are all direct clones of the mainline healing abilities, except that
# they are set to exclude units suffering from dehydration. Dehydration is only
# delayed by healers, so they must not actually heal a dehydrated unit any
# hitpoints.
#
# The ability macros go into wesnoth textdomain since the strings are identical
# to their core counterparts, but the special notes belong to wesnoth-utbs.

#define UTBS_ABILITY_HEALS
    [heals]
        value=4
        id=healing
        affect_allies=yes
        name= _ "heals +4"
        female_name= _ "female^heals +4"
        description=  _ "Allows the unit to heal adjacent allied units at the beginning of our 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]
            [filter]
                [not]
                    status=dehydration_slowed_by_healer
                [/not]
            [/filter]
        [/affect_adjacent]
    [/heals]
#enddef

#define UTBS_ABILITY_EXTRA_HEAL
    [heals]
        value=8
        id=healing
        affect_allies=yes
        name= _ "heals +8"
        female_name= _ "female^heals +8"
        description= _ "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]
            [filter]
                [not]
                    status=dehydration_slowed_by_healer
                [/not]
            [/filter]
        [/affect_adjacent]
    [/heals]
#enddef

#define UTBS_ABILITY_CURES
    {ABILITY_UNPOISON}
    {UTBS_ABILITY_EXTRA_HEAL}
#enddef

#textdomain wesnoth-utbs

#define SPECIAL_NOTES_UTBS_HEALS
_" This unit is capable of basic healing and slowing dehydration."#enddef

#define SPECIAL_NOTES_UTBS_CURES
_" This unit is capable of healing those around it, slowing dehydration, and curing them of poison."#enddef

# This is the Teaching ability owned by Garak

#define ABILITY_TEACHING
    [dummy]
        id=teaching
        name= _ "teaching"
        female_name= _ "female^teaching"
        description= _ "At the start of every turn, this unit redistributes its experience points to all the units of the same side adjacent to it. If no suitable unit is adjacent, its experience just goes back to zero."
    [/dummy]
#enddef

#define WEAPON_SPECIAL_SHOCK
    # Canned definition of the Shock ability to be included in a
    # [specials] clause.
    [attacks]
        id=shock
        name= _ "shock"
        description= _ "When this attack is used on offense, the opponent will retaliate with one less strike than normally, to a minimum of one strike."
        sub=1
        active_on=offense
        apply_to=opponent
        [filter_base_value]
            greater_than=1
        [/filter_base_value]
    [/attacks]
#enddef

#define ABILITY_FORMATION
    [dummy]
        id=formation
        name= _ "formation"
        female_name= _ "female^formation"
        description= _ "This unit gains a +10% bonus to defense when another unit with the same ability is adjacent to it. However, this cannot raise the unit’s defense above 70%."
    [/dummy]
#enddef

#define ABILITY_DISENGAGE
    [dummy]
        id=disengage
        name= _ "disengage"
        female_name= _ "female^disengage"
        description= _ "If this unit doesn’t move before attacking, it will retain its movement points after the attack."
    [/dummy]
#enddef

#define WEAPON_SPECIAL_DAZE
    [dummy]
        id=daze
        name= _ "daze"
        description= _ "When hit with this attack, an enemy suffers a 10% penalty both to their defense and chance to hit for one turn. Other specials that affect chance to hit (e.g. magical and marksman) take precedence over this special.

Magical attacks will still have a 70% chance to hit.
Marksman attacks are only affected if the chance to hit is greater than 60%."
    [/dummy]
#enddef

#define ABILITY_DISTRACT
    [skirmisher]
        id=distract
        name= _ "distract"
        female_name= _ "female^distract"
        description= _ "This unit negates enemy Zones of Control around itself for allied units (but not for itself)."
        affect_self=no
        affect_allies=yes
        [affect_adjacent]
        [/affect_adjacent]
    [/skirmisher]
#enddef

#define ABILITY_SUPPORT
    [dummy]
        id=support
        name= _ "support"
        female_name= _ "female^support"
        description= _ "The upkeep costs of adjacent friendly units are lowered by 1."
    [/dummy]
#enddef

#define SPECIAL_NOTES_SHOCK
_" This unit’s melee attack can overwhelm the defenses of enemies, preventing them from retaliating as effectively."#enddef

#define SPECIAL_NOTES_FORMATION
_" Groups of units of this type are able to shield each other in combat."#enddef

#define SPECIAL_NOTES_DISENGAGE
_" This unit can move either before or after attacking."#enddef

#define SPECIAL_NOTES_DAZE
_" This unit can daze its enemies, reducing their accuracy and defense until they end a turn."#enddef

#define SPECIAL_NOTES_DISTRACT
_"This unit is capable of distracting opponents, allowing allied units to trespass their Zones of Control and move unhindered around them."#enddef

#define ABILITY_DISENGAGE_EVENTS
    [event]
        name=attack end
        first_time_only=no

        [filter]
            ability=disengage

            [not]
                [filter_wml]
                    moves=$this_unit.max_moves
                [/filter_wml]
            [/not]
        [/filter]

        {VARIABLE unit.moves 0}

        [unstore_unit]
            variable=unit
            find_vacant=no
        [/unstore_unit]
    [/event]
#enddef

#define WEAPON_SPECIAL_DAZE_EVENTS
    [event]
        id=weapon_special_daze_event_1
        name=unit placed
        first_time_only=no

        [filter]
            [not]
                [has_attack]
                    special=enemy_dazed
                [/has_attack]
            [/not]
        [/filter]

        [object]
            silent=yes

            [filter]
                x,y=$x1,$y1
            [/filter]

            [effect]
                apply_to=attack
                [not]
                    special=magical
                [/not]
                [not]
                    special=marksman
                [/not]
                [not]
                    special=enemy_dazed
                [/not]

                [set_specials]
                    mode=append

                    [chance_to_hit]
                        id=enemy_dazed
                        name=""
                        description=""
                        add=10
                        [filter_opponent]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_opponent]
                    [/chance_to_hit]
                [/set_specials]
            [/effect]
            [effect]
                apply_to=attack
                special=marksman
                [and]
                    special=poison
                [/and]
                [not]
                    special=enemy_dazed
                [/not]

                # Note: instead of simply appending, we have to use replace and
                # put marksman last because the +10% from daze must be applied
                # first; the other way around, the base value would already be
                # potentially modified by marksman
                [set_specials]
                    mode=replace

                    [chance_to_hit]
                        id=enemy_dazed
                        name=""
                        description=""
                        add=10
                        active_on=offense
                        [filter_base_value]
                            greater_than_equal_to=60
                        [/filter_base_value]
                        [filter_opponent]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_opponent]
                    [/chance_to_hit]
                    {WEAPON_SPECIAL_MARKSMAN}
                    {WEAPON_SPECIAL_POISON}
                    [chance_to_hit]
                        id=enemy_dazed_marksman_defense
                        name=""
                        description=""
                        add=10
                        active_on=defense
                        [filter_opponent]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_opponent]
                    [/chance_to_hit]
                [/set_specials]
            [/effect]
            [effect]
                apply_to=attack
                special=marksman
                [not]
                    special=poison
                [/not]
                [not]
                    special=enemy_dazed
                [/not]

                # Note: instead of simply appending, we have to use replace and
                # put marksman last because the +10% from daze must be applied
                # first; the other way around, the base value would already be
                # potentially modified by marksman
                [set_specials]
                    mode=replace

                    [chance_to_hit]
                        id=enemy_dazed
                        name=""
                        description=""
                        add=10
                        active_on=offense
                        [filter_base_value]
                            greater_than_equal_to=60
                        [/filter_base_value]
                        [filter_opponent]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_opponent]
                    [/chance_to_hit]
                    {WEAPON_SPECIAL_MARKSMAN}
                    [chance_to_hit]
                        id=enemy_dazed_marksman_defense
                        name=""
                        description=""
                        add=10
                        active_on=defense
                        [filter_opponent]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_opponent]
                    [/chance_to_hit]
                [/set_specials]
            [/effect]
        [/object]
    [/event]

    [event]
        id=weapon_special_daze_event_2
        name=attacker hits
        first_time_only=no

        [filter_attack]
            special=daze
        [/filter_attack]

        [filter_second]
            [not]
                [filter_wml]
                    [status]
                        dazed=yes
                    [/status]
                [/filter_wml]
            [/not]
        [/filter_second]

        {VARIABLE second_unit.status.dazed yes}

        [unstore_unit]
            variable=second_unit
            find_vacant=no
            text= _ "dazed"
            female_text = _ "female^dazed"
            red,green,blue=196,196,128
        [/unstore_unit]

        [object]
            silent=yes

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

            [effect]
                apply_to=attack
                [not]
                    special=magical
                [/not]
                [not]
                    special=marksman
                [/not]
                [not]
                    special=self_dazed
                [/not]

                [set_specials]
                    mode=append

                    [chance_to_hit]
                        id=self_dazed
                        name=""
                        description=""
                        sub=10
                        [filter_self]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_self]
                    [/chance_to_hit]
                [/set_specials]
            [/effect]
            [effect]
                apply_to=attack
                special=marksman
                [and]
                    special=poison
                [/and]
                [not]
                    special=self_dazed
                [/not]

                [set_specials]
                    mode=replace

                    [chance_to_hit]
                        id=self_dazed
                        name=""
                        description=""
                        sub=10
                        active_on=offense
                        [filter_base_value]
                            greater_than_equal_to=70
                        [/filter_base_value]
                        [filter_self]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_self]
                    [/chance_to_hit]
                    {WEAPON_SPECIAL_MARKSMAN}
                    {WEAPON_SPECIAL_POISON}
                    [chance_to_hit]
                        id=self_dazed_marksman_defense
                        name=""
                        description=""
                        sub=10
                        active_on=defense
                        [filter_self]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_self]
                    [/chance_to_hit]
                [/set_specials]
            [/effect]
            [effect]
                apply_to=attack
                special=marksman
                [not]
                    special=poison
                [/not]
                [not]
                    special=self_dazed
                [/not]

                [set_specials]
                    mode=replace

                    [chance_to_hit]
                        id=self_dazed
                        name=""
                        description=""
                        sub=10
                        active_on=offense
                        [filter_base_value]
                            greater_than_equal_to=70
                        [/filter_base_value]
                        [filter_self]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_self]
                    [/chance_to_hit]
                    {WEAPON_SPECIAL_MARKSMAN}
                    [chance_to_hit]
                        id=self_dazed_marksman_defense
                        name=""
                        description=""
                        sub=10
                        active_on=defense
                        [filter_self]
                            [filter_wml]
                                [status]
                                    dazed=yes
                                [/status]
                            [/filter_wml]
                        [/filter_self]
                    [/chance_to_hit]
                [/set_specials]
            [/effect]
        [/object]
    [/event]

    [event]
        id=weapon_special_daze_event_3
        name=side turn
        first_time_only=no

        [event]
            name=side turn
            delayed_variable_substitution=no

            #{DEBUG_MSG "side $|side_number turn started, clearing daze from side $side_number units"}

            [modify_unit]
                [filter]
                    side=$side_number
                    [filter_wml]
                        [status]
                            dazed=yes
                        [/status]
                    [/filter_wml]
                [/filter]

                [status]
                    dazed=no
                [/status]
            [/modify_unit]
        [/event]
    [/event]
#enddef

#define ABILITY_FORMATION_EVENTS
    [event]
        id=ability_formation_event
        name=unit placed
        first_time_only=no

        [filter]
            [not]
                side=1
            [/not]

            [not]
                [filter_wml]
                    [attack]
                        [specials]
                            [chance_to_hit]
                                id=formation_enemy_1
                            [/chance_to_hit]
                        [/specials]
                    [/attack]
                [/filter_wml]
            [/not]
        [/filter]

        [object]
            silent=yes

            [filter]
                id=$unit.id
            [/filter]

            [effect]
                apply_to=attack

                [set_specials]
                    mode=append

                    [chance_to_hit]
                        id=formation_enemy_1
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=40
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=1-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_2
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=50
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=2-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_3
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=60
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=3-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_4
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=70
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=4-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_5
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=80
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                [/set_specials]
            [/effect]
        [/object]
    [/event]
#enddef

#define ABILITY_SUPPORT_EVENTS
    [event]
        name=unit placed
        first_time_only=no

        [filter]
            side=1

            [not]
                level=0
            [/not]

            [filter_wml]
                upkeep=full
            [/filter_wml]

            [filter_adjacent]
                ability=support
            [/filter_adjacent]
        [/filter]

        {VARIABLE unit.variables.original_upkeep $unit.upkeep}
        {VARIABLE unit.variables.upkeep_supported yes}
        {VARIABLE unit.upkeep "$($unit.level - 1)"}

        [unstore_unit]
            variable=unit
            find_vacant=no
            fire_event=no
        [/unstore_unit]
    [/event]

    [event]
        name=set_support_upkeep
        first_time_only=no

        [foreach]
            array=update_support_units
            variable=support_unit

            [do]
                [if]
                    [have_unit]
                        x,y=$support_unit.x,$support_unit.y

                        [not]
                            level=0
                        [/not]

                        [filter_wml]
                            upkeep=full
                        [/filter_wml]

                        [filter_adjacent]
                            ability=support
                        [/filter_adjacent]
                    [/have_unit]

                    [then]
                        {VARIABLE support_unit.variables.original_upkeep $support_unit.upkeep}
                        {VARIABLE support_unit.variables.upkeep_supported yes}
                        {VARIABLE support_unit.upkeep "$($support_unit.level - 1)"}
                    [/then]

                    [else]
                        [if]
                            [have_unit]
                                x,y=$support_unit.x,$support_unit.y

                                [not]
                                    level=0
                                [/not]

                                [filter_wml]
                                    [variables]
                                        upkeep_supported=yes
                                    [/variables]
                                [/filter_wml]

                                [not]
                                    [filter_adjacent]
                                        ability=support
                                    [/filter_adjacent]
                                [/not]
                            [/have_unit]

                            [then]
                                {VARIABLE support_unit.upkeep $support_unit.variables.original_upkeep}
                                {VARIABLE support_unit.variables.upkeep_supported no}
                            [/then]

                            [else]
                                [continue][/continue]
                            [/else]
                        [/if]
                    [/else]
                [/if]

                [unstore_unit]
                    variable=support_unit
                    find_vacant=no
                    fire_event=no
                [/unstore_unit]
            [/do]
        [/foreach]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            side=1
            ability=support
        [/filter]

        [store_unit]
            [filter]
                [filter_wml]
                    upkeep=full
                [/filter_wml]

                [filter_adjacent]
                    x,y=$x1,$y1
                [/filter_adjacent]

                [or]
                    [filter_wml]
                        [variables]
                            upkeep_supported=yes
                        [/variables]
                    [/filter_wml]

                    [filter_location]
                        [filter_adjacent_location]
                            x,y=$x2,$y2
                        [/filter_adjacent_location]
                    [/filter_location]
                [/or]
            [/filter]

            kill=no
            variable=update_support_units
        [/store_unit]

        [fire_event]
            name=set_support_upkeep
        [/fire_event]

        {CLEAR_VARIABLE update_support_units}

        [on_undo]
            [store_unit]
                [filter]
                    [filter_wml]
                        upkeep=full
                    [/filter_wml]

                    [filter_location]
                        [filter_adjacent_location]
                            x,y=$x2,$y2
                        [/filter_adjacent_location]
                    [/filter_location]

                    [or]
                        [filter_wml]
                            [variables]
                                upkeep_supported=yes
                            [/variables]
                        [/filter_wml]

                        [filter_location]
                            [filter_adjacent_location]
                                x,y=$x1,$y1
                            [/filter_adjacent_location]
                        [/filter_location]
                    [/or]
                [/filter]

                kill=no
                variable=update_support_units
            [/store_unit]

            [fire_event]
                name=set_support_upkeep
            [/fire_event]

            {CLEAR_VARIABLE update_support_units}
        [/on_undo]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            side=1

            [not]
                ability=support
            [/not]

            [and]
                [filter_wml]
                    upkeep=full
                [/filter_wml]

                [filter_adjacent]
                    side=1
                    ability=support
                [/filter_adjacent]

                [or]
                    [filter_wml]
                        [variables]
                            upkeep_supported=yes
                        [/variables]
                    [/filter_wml]

                    [not]
                        [filter_adjacent]
                            side=1
                            ability=support
                        [/filter_adjacent]
                    [/not]
                [/or]
            [/and]
        [/filter]

        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]

            kill=no
            variable=update_support_units
        [/store_unit]

        [fire_event]
            name=set_support_upkeep
        [/fire_event]

        {CLEAR_VARIABLE update_support_units}

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

                kill=no
                variable=update_support_units
            [/store_unit]

            [fire_event]
                name=set_support_upkeep
            [/fire_event]

            {CLEAR_VARIABLE update_support_units}
        [/on_undo]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=die,post advance
        first_time_only=no

        [filter]
            side=1
            ability=support
        [/filter]

        [store_unit]
            [filter]
                side=1

                [filter_adjacent]
                    x,y=$x1,$y1
                [/filter_adjacent]
            [/filter]

            kill=no
            variable=update_support_units
        [/store_unit]

        [fire_event]
            name=set_support_upkeep
        [/fire_event]

        {CLEAR_VARIABLE update_support_units}
    [/event]

    [event]
        name=post advance
        first_time_only=no

        [filter]
            side=1

            [filter_adjacent]
                ability=support
            [/filter_adjacent]
        [/filter]

        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]

            kill=no
            variable=update_support_units
        [/store_unit]

        [fire_event]
            name=set_support_upkeep
        [/fire_event]

        {CLEAR_VARIABLE update_support_units}
    [/event]
#enddef
