#textdomain wesnoth-did

############## DRAGON ABILITIES ##############

#define ABILITY_SOUL_EATER1
    [dummy]
        id=did_soul_eater1
        name= _ "soul eater"
        name_inactive= _ "soul eater"
        description= _ "This unit heals 4 HP whenever it kills an enemy unit."
        description_inactive= _ "This unit heals 4 HP whenever it kills an enemy unit."
    [/dummy]
#enddef

#define DID_SOUL_EATER1
    [event]
        id=did_soul_eater_die1
        name=die
        first_time_only=no
        [filter_second]
            ability=did_soul_eater1
        [/filter_second]

        [heal_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            amount=4
            animate=yes
        [/heal_unit]
    [/event]
#enddef

#define ABILITY_SOUL_EATER2
    [dummy]
        id=did_soul_eater2
        name= _ "soul eater"
        name_inactive= _ "soul eater"
        description= _ "This unit heals 8 HP whenever it kills an enemy unit."
        description_inactive= _ "This unit heals 8 HP whenever it kills an enemy unit."
    [/dummy]
#enddef

#define DID_SOUL_EATER2
    [event]
        id=did_soul_eater_die2
        name=die
        first_time_only=no
        [filter_second]
            ability=did_soul_eater2
        [/filter_second]

        [heal_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            amount=8
            animate=yes
        [/heal_unit]
    [/event]
#enddef

#define ABILITY_SOUL_EATER3
    [damage]
        id=did_soul_eater3
        name= _ "soul eater"
        name_inactive= _ "soul eater"
        description= _ "This unit gains 15% damage on offense and heals 12 HP whenever it kills an enemy unit."
        description_inactive= _ "This unit gains 15% damage on offense and heals 12 HP whenever it kills an enemy unit."
        multiply=1.15
        active_on=offense
    [/damage]
#enddef

#define DID_SOUL_EATER3
    [event]
        id=did_soul_eater_die3
        name=die
        first_time_only=no
        [filter_second]
            ability=did_soul_eater3
        [/filter_second]

        [heal_unit]
            [filter]
                x,y=$x2,$y2
            [/filter]
            amount=12
            animate=yes
        [/heal_unit]
    [/event]
#enddef

############## LICH ABILITIES ##############

#define ABILITY_MALICE1
    [leadership]
        id=did_malice1
        value=20
        cumulative=no
        affect_self=no
        name= _ "malice"
        description= _ "This unit increases the damage of nearby undead units by 20%."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                race=undead
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_MALICE2
    [leadership]
        id=did_malice2
        value=40
        cumulative=no
        affect_self=no
        name= _ "malice"
        description= _ "This unit increases the damage of nearby undead units by 40%."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                race=undead
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_SHADOW_VEIL
    [dummy]
        id=did_shadow_veil
        name= _ "shadow veil"
        name_inactive= _ "shadow veil"
        description= _ "Allied undead units within a 5 hex radius are hidden."
        description_inactive= _ "Allied undead units within a 5 hex radius are hidden."
    [/dummy]
#enddef

#define ABILITY_SHADOW_VEIL_HELPER SIDE
    [hides]
        id=did_shadow_veil_helper
        [filter]
            [filter_location]
                radius=5
                [filter]
                    ability=did_shadow_veil
                    [filter_side]
                        [allied_with]
                            side={SIDE}
                        [/allied_with]
                    [/filter_side]
                [/filter]
            [/filter_location]
        [/filter]
    [/hides]
#enddef

#define DID_SHADOW_VEIL_HANDLER
    [event]
        id=did_shadow_veil_unit_placed
        name=unit placed
        first_time_only=no
        [filter]
            side=1
            race=undead
            [not]
                ability=did_shadow_veil_helper
            [/not]
        [/filter]
        [filter_condition]
            [have_unit]
                ability=did_shadow_veil
                side=1
            [/have_unit]
        [/filter_condition]
        [modify_unit]
            [filter]
                x,y=$x1,$y1
                [not]
                    ability=did_shadow_veil_helper
                    [or]
                        ability=did_shadow_veil
                    [/or]
                [/not]
            [/filter]
            [object]
                duration=scenario
                [effect]
                    apply_to=new_ability
                    [abilities]
                        {ABILITY_SHADOW_VEIL_HELPER $unit.side}
                    [/abilities]
                [/effect]
            [/object]
        [/modify_unit]
    [/event]
    [event]
        id=did_shadow_veil_malkeshar
        name=post advance
        first_time_only=yes
        [filter]
            type=Mal Keshar
            ability=did_shadow_veil
        [/filter]
        [modify_unit]
            [filter]
                race=undead
                [not]
                    ability=did_shadow_veil_helper
                    [or]
                        ability=did_shadow_veil
                    [/or]
                [/not]
                [filter_side]
                    [allied_with]
                        side=$unit.side
                    [/allied_with]
                [/filter_side]
            [/filter]
            [object]
                take_only_once=no
                duration=scenario
                [effect]
                    apply_to=new_ability
                    [abilities]
                        {ABILITY_SHADOW_VEIL_HELPER $this_unit.side}
                    [/abilities]
                [/effect]
            [/object]
        [/modify_unit]
    [/event]
#enddef

#define WEAPON_SPECIAL_FROST_NOVA
    [dummy]
        id=did_frost_nova
        name= _ "frost nova"
        name_inactive= _ "frost nova"
        description= _ "On offense, this attack will additionally deal 70% of its damage in cold damage to all enemies adjacent to the target."
        description_inactive= _ "On offense, this attack will additionally deal 70% of its damage in cold damage to all enemies adjacent to the target."
    [/dummy]
#enddef

#define DID_FROST_NOVA
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special_id=did_frost_nova
        [/filter_attack]
        [store_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x2,$y2
                    is_enemy=no
                [/filter_adjacent]
                [not]
                    x,y=$x2,$y2
                [/not]
            [/filter]
            variable=opp
        [/store_unit]
        {VARIABLE frost_damage $damage_inflicted}
        {VARIABLE_OP frost_damage multiply 0.7}
        [foreach]
            array=opp
            [do]
                [sound]
                    name="magic-dark.ogg"
                [/sound]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=$frost_damage
                    damage_type=cold
                    delay=25
                [/harm_unit]
                [if]
                    [have_unit]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/have_unit]
                    [else]
                        {VARIABLE exp $opp[$i].level}
                        {VARIABLE_OP exp multiply 8}
                        {VARIABLE_OP unit.experience add "$(max(4, $exp))"}
                        {CLEAR_VARIABLE exp}
                        [unstore_unit]
                            variable=unit
                            find_vacant=no
                        [/unstore_unit]
                    [/else]
                [/if]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE frost_damage}
    [/event]
#enddef

#define WEAPON_SPECIAL_SPELLBIND
    [damage]
        id=did_spellbind
        name= _ "spell bind"
        name_inactive= _ "spell bind"
        description= _ "When this attack is used, the damage taken from fire, cold, and arcane attacks will be reduced by 60%."
        description_inactive= _ "When this attack is used, the damage taken from fire, cold, and arcane attacks will be reduced by 60%."
        [filter_opponent]
            [filter_weapon]
                type=fire,cold,arcane
            [/filter_weapon]
        [/filter_opponent]
        apply_to=opponent
        multiply=0.4
    [/damage]
#enddef

#define WEAPON_SPECIAL_REAP
    [drains]
        id=did_reap
        value=70
        name= _ "reap"
        description= _ "This unit heals for 70% of the damage this attack deals."
    [/drains]
#enddef

#define ABILITY_SOUL_REND
    [dummy]
        id=did_soul_rend
        name= _ "soul rend"
        name_inactive= _ "soul rend"
        description= _ "Every turn, this unit loses 3 hitpoints, but drains 6 hitpoints from each adjacent enemy."
        description_inactive= _ "Every turn, this unit loses 3 hitpoints, but drains 6 hitpoints from each adjacent enemy."
    [/dummy]
#enddef

#define DID_SOUL_REND
    [event]
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                [filter_adjacent]
                    ability=did_soul_rend
                    is_enemy=yes
                [/filter_adjacent]
            [/filter]
            variable=opp
        [/store_unit]
        [store_unit]
            [filter]
                ability=did_soul_rend
            [/filter]
            variable=runit
        [/store_unit]

        [harm_unit]
            [filter]
                ability=did_soul_rend
            [/filter]

            amount=3
            animate=no
            kill=no
        [/harm_unit]

        [floating_text]
            x,y=$runit.x,$runit.y
            color=255,0,0
            # wmllint: markcheck off
            text=3
            # wmllint: markheck on
        [/floating_text]

        {VARIABLE counter 0}
        [foreach]
            array=opp
            [do]
                {VARIABLE_OP counter add 1}
                [sound]
                    name="poison.ogg"
                [/sound]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=6
                    delay=25
                [/harm_unit]
                [if]
                    [have_unit]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/have_unit]
                    [else]
                        {VARIABLE exp $opp[$i].level}
                        {VARIABLE_OP exp multiply 8}
                        {VARIABLE_OP runit.experience add $exp}
                        {CLEAR_VARIABLE exp}
                        [unstore_unit]
                            variable=runit
                            find_vacant=no
                        [/unstore_unit]
                    [/else]
                [/if]
            [/do]
        [/foreach]
        {VARIABLE_OP counter multiply 6}
        [heal_unit]
            [filter]
                ability=did_soul_rend
            [/filter]
            amount=$counter
            animate=yes
        [/heal_unit]
        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE runit}
        {CLEAR_VARIABLE counter}
    [/event]
#enddef

############## SPECTRAL SERVANT ABILITIES ##############

#define WEAPON_SPECIAL_MALEVOLENCE
    [damage]
        id=did_malevolence
        name= _ "malevolence"
        name_inactive= _ "malevolence"
        description= _ "This attack gains 50% damage on offense, but causes this unit to lose 1 hp per hit."
        description_inactive= _ "This attack gains 50% damage on offense, but causes this unit to lose 1 hp per hit."
        multiply=1.5
        active_on=offense
    [/damage]
    [heal_on_hit]
        id=did_malevolence_anti_heal
        value=-1
        active_on=offense
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_HYSTERIA
    [swarm]
        id=did_hysteria
        name= _ "hysteria"
        description= _ "This attack gains up to 10 strikes when this unit is wounded."
        swarm_attacks_min=10
    [/swarm]
#enddef

#define ABILITY_SORROW1
    [leadership]
        id=sorrow
        value=-20
        cumulative=no
        name= _ "sorrow"
        description= _ "Adjacent enemy units do 20% less damage."
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_SORROW2
    [leadership]
        id=sorrow
        value=-40
        cumulative=no
        name= _ "sorrow"
        description= _ "Adjacent enemy units do 40% less damage."
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/leadership]
#enddef

############## MALIN KESHAR ABILITIES ##############

#define ABILITY_ENLIGHTENED
    [teleport]
        id=did_enlightened
        name= _ "enlightened"
        female_name= _ "female^enlightened"
        description= _ "This unit can teleport between mushroom groves."
        [tunnel]
            id=did_enlightened_teleport
            [source]
                terrain=*^Emf*,*^Tf*
                formula="unit = teleport_unit or not unit where unit = unit_at(loc)"
            [/source]

            [target]
                terrain=*^Emf*,*^Tf*
                formula="not unit_at(loc)"
            [/target]

            [filter]
                ability=did_enlightened
            [/filter]
        [/tunnel]
    [/teleport]
#enddef

#define WEAPON_SPECIAL_VITALIZE1
    [heal_on_hit]
        id=did_vitalize1
        value=2
        name= _ "vitalize"
        description= _ "This unit heals 2 HP every time this attack hits."
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_VITALIZE2
    [heal_on_hit]
        id=did_vitalize2
        value=4
        name= _ "vitalize"
        description= _ "This unit heals 4 HP every time this attack hits."
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_FERVOR
    [attacks]
        id=did_fervor
        name= _ "fervor"
        name_inactive= _ "fervor"
        description= _ "This attack gains 2 attacks on offense, but causes this unit to lose 4 hp per hit."
        description_inactive= _ "This attack gains 2 attacks on offense, but causes this unit to lose 4 hp per hit."
        add=2
        active_on=offense
    [/attacks]
    [heal_on_hit]
        id=did_fervor_anti_heal
        value=-4
        active_on=offense
    [/heal_on_hit]
#enddef

#define WEAPON_SPECIAL_IMPETUITY
    [attacks]
        id=did_impetuity
        name= _ "impetuity"
        name_inactive= _ "impetuity"
        description= _ "This attack loses one strike on offense but deals three times the normal damage."
        description_inactive= _ "This attack loses one strike on offense but deals three times the normal damage."
        sub=1
        active_on=offense
    [/attacks]
    [damage]
        id=did_impetuity_damage
        multiply=3
        active_on=offense
    [/damage]
#enddef

#define WEAPON_SPECIAL_CORPSE_LAUNCHER
    [attacks]
        id=did_corpse_launcher
        name= _ "corpse launcher"
        description= _ "On offense, enemies cannot retaliate against this attack. This attack consumes 3 HP from each nearby allied corpse to deal 15 impact damage (per corpse) to the target on top of this attack’s base damage."
        value=0
        cumulative=no
        apply_to=opponent
        active_on=offense
    [/attacks]
    [damage]
        id=did_corpse_damage
        add=15
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=1
                type_adv_tree=Walking Corpse
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=30
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=2
                type_adv_tree=Walking Corpse
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=45
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=3
                type_adv_tree=Walking Corpse
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=60
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=4
                type_adv_tree=Walking Corpse
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=75
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=5
                type_adv_tree=Walking Corpse
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
    [damage]
        id=did_corpse_damage
        add=90
        active_on=offense
        [filter_self]
            [filter_adjacent]
                count=6
                type_adv_tree=Walking Corpse
                is_enemy=no
            [/filter_adjacent]
        [/filter_self]
    [/damage]
#enddef

#define DID_CORPSE_LAUNCH
    [event]
        id=did_corpse_launch_handler
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special_id=did_corpse_launcher
        [/filter_attack]
        [store_unit]
            [filter]
                type_adv_tree=Walking Corpse
                [filter_adjacent]
                    x,y=$x1,$y1
                    is_enemy=no
                [/filter_adjacent]
                [not]
                    x,y=$x1,$y1
                [/not]
            [/filter]
            variable=zombie
        [/store_unit]
        [foreach]
            array=zombie
            [do]
                [harm_unit]
                    [filter]
                        x,y=$zombie[$i].x,$zombie[$i].y
                    [/filter]
                    fire_event=yes
                    animate=no
                    kill=no
                    amount=3
                    delay=25
                [/harm_unit]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE zombie}
    [/event]
#enddef

#define ABILITY_CONSUMPTION
    [leadership]
        id=did_consumption
        value=25
        cumulative=no
        affect_self=yes
        name= _ "consumption"
        description= _ "At night, this unit and adjacent allied undead gain 25% damage. However, this unit loses 2 HP per turn."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                race=undead
            [/filter]
        [/affect_adjacent]
        [filter_self]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
        [/filter_self]
    [/leadership]
#enddef

#define DID_CONSUMPTION
    [event]
        id=did_consumption_handler
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                ability=did_consumption
            [/filter]
            variable=cunit
        [/store_unit]

        [if]
            [have_location]
                x,y=$cunit.x,$cunit.y
                time_of_day=chaotic
            [/have_location]
            [then]
                [harm_unit]
                    [filter]
                        ability=did_consumption
                    [/filter]

                    amount=2
                    animate=no
                    kill=no
                [/harm_unit]

                [floating_text]
                    x,y=$cunit.x,$cunit.y
                    color=255,0,0
                    # wmllint: markcheck off
                    text=2
                    # wmllint: markcheck on
                [/floating_text]
            [/then]
        [/if]
        {CLEAR_VARIABLE cunit}
    [/event]
#enddef

#define ABILITY_CORPSE_MASTER
    [heals]
        id=did_corpse_master
        value=8
        affect_allies=yes
        affect_self=no
        affect_enemies=no
        name= _ "corpse master"
        description= _ "Adjacent allied corpses heal 8 HP per turn and gain 30% resistance to blade, impact, and pierce."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type_adv_tree=Walking Corpse
            [/filter]
        [/affect_adjacent]
    [/heals]
    [resistance]
        id=did_corpse_master_resist
        add=30
        max_value=90
        cumulative=no
        affect_self=no
        affect_allies=yes
        affect_enemies=no
        apply_to=blade,pierce,impact
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type_adv_tree=Walking Corpse
            [/filter]
        [/affect_adjacent]
    [/resistance]
#enddef

#define ABILITY_ZOMBIE_FRENZY
    [leadership]
        id=did_zombie_frenzy
        value=30
        cumulative=no
        affect_self=no
        affect_allies=yes
        affect_enemies=no
        name= _ "zombie frenzy"
        description= _ "Adjacent allied corpses gain 30% damage and are berserk."
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type_adv_tree=Walking Corpse
            [/filter]
        [/affect_adjacent]
    [/leadership]
    [berserk]
        id=did_zombie_frenzy_berserk
        value=30
        affect_self=no
        affect_allies=yes
        affect_enemies=no
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
            [filter]
                type_adv_tree=Walking Corpse
            [/filter]
        [/affect_adjacent]
    [/berserk]
#enddef

############## DROGAN GHOUL ABILITIES ##############

#define ABILITY_CANNIBALIZE1
    [regenerate]
        id=did_cannibalize1
        value=2
        affect_self=yes
        name= _ "cannibalize"
        description= _ "On each turn, this unit regenerates 2 HP per adjacent allied ghoul-type unit, but consumes 1 HP from each ally in the process."
        [filter]
            [filter_adjacent]
                count=1
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=4
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=2
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=6
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=3
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=8
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=4
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=10
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=5
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize1
        value=12
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=6
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [heals]
        value=-1
        id=did_cannibalize_antiheal
        affect_allies=yes
        affect_self=no
        [affect_adjacent]
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_CANNIBALIZE2
    [regenerate]
        id=did_cannibalize2
        value=4
        affect_self=yes
        name= _ "cannibalize"
        description= _ "On each turn, this unit regenerates 4 HP per adjacent allied ghoul-type unit, but consumes 2 HP from each ally in the process."
        [filter]
            [filter_adjacent]
                count=1
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=8
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=2
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=12
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=3
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=16
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=4
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=20
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=5
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [regenerate]
        id=did_cannibalize2
        value=24
        affect_self=yes
        [filter]
            [filter_adjacent]
                count=6
                type_adv_tree=Ghoul
                is_enemy=no
            [/filter_adjacent]
        [/filter]
    [/regenerate]
    [heals]
        value=-2
        id=did_cannibalize_antiheal
        affect_allies=yes
        affect_self=no
        [affect_adjacent]
        [/affect_adjacent]
    [/heals]
#enddef

#define ABILITY_DEATH_CLOUD
    [dummy]
        id=did_death_cloud
        name= _ "death cloud"
        description= _ "This unit poisons all nearby enemy units on the start of every new turn."
    [/dummy]
#enddef

#define DID_DEATH_CLOUD
    [event]
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                [filter_adjacent]
                    ability=did_death_cloud
                    is_enemy=yes
                [/filter_adjacent]
            [/filter]
            variable=opp
        [/store_unit]

        [foreach]
            array=opp
            [do]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=0
                    poisoned=yes
                    delay=25
                [/harm_unit]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE opp}
    [/event]
#enddef

############## NECRON GHOUL ABILITIES ##############

#define WEAPON_SPECIAL_GHOULFICATION
    [plague]
        id=ghoulfication
        name= _ "ghoulfication"
        description= _ "When a unit is killed by this attack, it turns into a ghoul."
        type=Ghoul
    [/plague]
#enddef

#define ABILITY_STARVING
    [dummy]
        id=did_starving
        name= _ "starving"
        name_inactive= _ "starving"
        description= _ "This unit loses 1 hitpoint every turn."
        description_inactive= _ "This unit loses 1 hitpoint every turn."
    [/dummy]
#enddef

#define DID_STARVING
    [event]
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                ability=did_starving
            [/filter]
            variable=runit
        [/store_unit]

        [harm_unit]
            [filter]
                ability=did_starving
            [/filter]

            amount=1
            animate=no
            kill=no
        [/harm_unit]

        [floating_text]
            x,y=$runit.x,$runit.y
            color=255,0,0
            # wmllint: markcheck off
            text=1
            # wmllint: markheck on
        [/floating_text]

        {CLEAR_VARIABLE runit}
    [/event]
#enddef

#define ABILITY_MASOCHISM1
    [leadership]
        id=masochism1
        value="(50 * (1 - hitpoints / max_hitpoints))"
        cumulative=no
        name= _ "masochism"
        female_name= _ "female^masochism"
        description= _ "This unit gains up to 50% damage as its hitpoints are reduced."
        affect_self=yes
    [/leadership]
#enddef

#define ABILITY_MASOCHISM2
    [leadership]
        id=masochism2
        value="(100 * (1 - hitpoints / max_hitpoints))"
        cumulative=no
        name= _ "masochism"
        female_name= _ "female^masochism"
        description= _ "This unit gains up to 100% damage as its hitpoints are reduced."
        affect_self=yes
    [/leadership]
#enddef

############## MISC ABILITIES ##############

#define ABILITY_DRUNK
    [resistance]
        id=did_drunk
        add=10
        max_value=90
        name= _ "drunk"
        female_name= _ "female^drunk"
        description= _ "This unit is drunk and has 10% increased resistances."
        affect_self=yes
    [/resistance]
#enddef

#define WEAPON_SPECIAL_DRUNKEN_RAGE
    [berserk]
        id=did_drunken_rage
        name= _ "drunken rage"
        description= _ "On offense, this attack presses the engagement for 4 rounds of attacks."
        value=4
        active_on=offense
    [/berserk]
#enddef
