Modding:Modifiers

**Modifiers** are a powerful tool to be used in modding. Here is an example for their basic structure (AssaultDoctrine.xml):

```
<modifiers>
    <modifier>
        <conditions>
            <unit>
                <type name="SpaceMarines/AssaultSpaceMarine"/>
            </unit>
        </conditions>
        <effects>
            <accuracy add="2"/>
        </effects>
    </modifier>
</modifiers>

```

## <modifiers>

Contains any number of modifiers.

There are a couple alternatives to the standard <modifiers> tag which trigger during different times and apply to different targets, more information below.

```
<modifiers>
</modifiers>

```

```
<onCombatOpponentModifiers>
</onCombatOpponentModifiers>

```

```
<opponentModifiers>
</opponentModifiers>

```

```
<onTraitRemovedModifiers>
</onTraitRemovedModifiers>

```

```
<onTileEnteredModifiers>
</onTileEnteredModifiers>

```

```
<perTurnModifiers>
</perTurnModifiers>

```

```
<onUnitDisappearedModifiers>
</onUnitDisappearedModifiers>

```

## <modifier>

Contains effects and optionally also triggering conditions.

The <modifier> tag can have the following attributes:

```
<modifier visible="0">

```

Causes the modifier effects not to be visible in the tooltip.

```
<modifier requiredUpgrade="Necrons/CityDefenseBonus">

```

Causes the modifier effects to require a research upgrade to be unlocked.

## <conditions>

Contains conditions which have to be true for the effects to be applied. If several conditions are listed, all must be true (AND logic), unless conditions block has <conditions match="Any">, in this case only one single condition must be true (OR logic).

```
<unit>
</unit>

```

```
<building>
</building>

```

```
<weapon>
</weapon>

```

```
<tile>
</tile>

```

```
<player>
</player>

```

```
<encounter>
</encounter>

```

The tags above are needed for the following checks (see example at the top of the page):

If you need to check for only one condition in the list, use match="Any":

```
 <unit match="Any">
 <weapon match="Any">
 <opponent match="Any">
 <... match="Any">

```
By default, **all** conditions listed inside must be true for the entire block to pass (AND logic).

This one seems to work slightly differently because it's found outside of modifiers:

```
<targetConditions>
    <unit>
        <trait name="Flyer"/>
    </unit>
</targetConditions>

```

Encounter conditions:

```
<encounter>
    <self>
    </self>
    <opponent>
    </opponent>
    <opponentTile>
    </opponentTile>
    <weapon>
    </weapon>
</encounter>

```

```
<encounter>
    <opponent>
        <attacking/>
    </opponent>
</encounter>

```

```
<encounter>
    <opponent>
        <destroyed/>
    </opponent>
</encounter>

```

```
<encounter>
    <opponent>
        <firingMeleeWeapons/>
    </opponent>
</encounter>

```

## <effects>

Can do a number of different things like change values or spawn and remove units or apply traits to units. For a list of things that can be inserted for [Stat], see Stats

## Stats

Stats are values that can be changed by effects or checked by conditions.

### Basic unit stats

armor

hitpoints, hitpointsMax, hitpointsFraction
Current and maximum  . Fraction is a fraction of the max hitpoints, but applied to the current hitpoints.
healthPercentage
Might be the remaining health as a percentage. Used for conditions.
morale, moraleMax
Current and maximum  .
movement, movementMax
Current and maximum  .
movementCost
The movement cost of a tile. A forest increases movement cost by 1. A city sets the maximum to 1 for allied units. <movementCost min="100"/> force the move to end.
healingRate

cargoSlots

### Resource related

production
 .
productionCost

requisitions, energy, food, ore, influence
Produces resources per turn when positive, costs upkeep per turn when negative. When applied as mul to a tile then it will be the tile's resource yield.
requisitionsCost, energyCost, foodCost, oreCost, influenceCost
One time production cost.
research
 production or upkeep? Can this be production cost as well?
loyalty
 bonus or penalty.
growth
Population   for cities.
populationLimit
Population housing for cities.
### Other stats

actionPointsMax
  When set to 0, the unit won't be able to shoot. Found in stunned.xml. Can't be used for conditions?
stealth
Maybe makes units invisible, maybe makes them ignore overwatch? <stealth add="1"/> found in forest.xml.
cargoSlotsRequired
How many   a unit takes up? -1 means untransportable.
influencePerExperience
Sets an amount of influenced gained with experience. Used by the Space Marine Captain ability.
moraleLossFactor
Increases or slows down   loss. Used by vox caster and mobrule.
hitpointsPerMoraleLoss
How much   are lost (maybe gained) by morale loss?
### Combat related

accuracy, rangedAccuracy, meleeAccuracy
Total, ranged and melee  .
damage, rangedDamage, meleeDamage
Total, ranged and melee  .
attacks, meleeAttacks
Total, and melee  .
armorPenetration, rangedArmorPenetration, meleeArmorPenetration
Total, ranged and melee  .
attacksTaken
Increases amount of attacks when attacked? Found in swarms.xml.
additionalMembersHit
Applies the weapon damage to multiple members of a squad. Used by blast and template weapons. See damage calculation.
circumstanceMeleeDamage
Melee damage modifier. Used by Fear.xml and Zealot.xml.
minDamageFromHitpointsFraction
Used by  Gauss: Scales the minimum damage with the hitpoints of the target unit.
 weapons.
damageFromHitpoints
Used by  Gauss: Scales the minimum damage with the hitpoints of the target unit.
 weapons.
rangedDamageReduction, invulnerableDamageReduction, feelNoPainDamageReduction, witchfireDamageReduction, cityDamageReduction, heroDamageReduction
Types of  . See damage calculation.
rangedDamageReductionBypass
Makes attacks ignore ranged  . <rangedDamageReductionBypass add="1.0"/> will bypass 100%.
damageTaken
Changes how much damage is taken? Found in misfortune.xml.
encounterRange
Allows checking for range of a specific encounter.
## Other information

For traits, the category="buff" or category="debuff" attribute controls the colour of the icon. Buff is green and debuff red.