Upgrade Modding

Ugrades are a type of entity that can be added to brigades or buildings for defined bonuses.

## Upgrade Entity File

The general rules of entity modding apply to upgrades; the contents of the entity defined can have the following tags:

An example upgrade file is posted here:

```
<entitygroup>
<entity>
	<type>mercenarypost</type>
	<class>upgrade</class>

	<article>Upgrades::MercenaryPost</article>

	<objtype>city</objtype>

	<attribute attrtype="mercenarypost" op="add">4</attribute>

	<defaultnext>mercenarypost2</defaultnext>

	<portrait atlas="upgradeportraits" sprite="mercenarypost"/>

	<costwood>400</costwood>
	<costgold>20</costgold>
</entity>
<entity>
	<type>mercenarypost2</type>
	<class>upgrade</class>

	<article>Upgrades::MercenaryPost</article>

	<objtype>city</objtype>
	<prereq class="upgrade" type="mercenarypost"/>

	<inprogattribute attrtype="mercenarypost" op="add">4</inprogattribute>
	<attribute attrtype="mercenarypost" op="add">6</attribute>

	<portrait atlas="upgradeportraits" sprite="mercenarypost"/>

	<costwood>400</costwood>
	<costgold>50</costgold>
</entity>
</entitygroup>

```

## Attribute Definition

The bonuses given by upgrades, stances, skills, attached generals and inherent to some factions are called "upgrade attributes". When an entity has an upgrade attribute, it is defined in the following way:

```
<attribute attrtype="hitpoints" op="mult">0.5</attribute>

```

The attrtype reflects what stat the attribute modified, the op reflects how it applies that change, and the data that's a child of it (0.5 in the given example) is how much it changes.

The valid ops are:

* add, which adds the given value.
* mult, which multiplies the existing value by 1 + the given value.
* bool, which flips a property in the object between 0 or 1.

The default attrtypes are:

You can also define your own attributes. These will not modify any stats but can be used as custom requirements; for example, you can have a faction skill or event give a faction the "custombuildattr" attribute, which you can list as the requirement to build a certain brigade or upgrade. The string named Upgrades::Attributes::custombuildattr would control how that attribute is displayed.

## Default Upgrade Types

* barracks
* barracks2
* battlements
* engineer
* engineer2
* engineer3
* engineer4
* engineer5
* farm\_capacity
* farm\_production
* farm\_protection
* fieldrange
* fieldtactician
* fieldtactician2
* fieldtactician3
* fieldtactician4
* fieldtactician5
* fisheryriver
* fisheryocean
* hunter
* hunter2
* hunter3
* hunter4
* hunter5
* library
* library2
* market
* market2
* marksman
* marksman2
* marksman3
* marksman4
* marksman5
* medic
* medic2
* medic3
* medic4
* medic5
* mercenarypost
* mercenarypost2
* monument
* monument2
* nightwatch
* nightwatch2
* nightwatch3
* quartermaster
* quartermaster2
* quartermaster3
* quartermaster4
* quartermaster5
* raider
* raider2
* raider3
* raider4
* raider5
* sanitation
* sanitation2
* sanitation3
* scout
* scout2
* scout3
* scout4
* scout5
* shipyard
* slavemarket
* stables
* standardbearer
* standardbearer2
* standardbearer3
* standardbearer4
* standardbearer5
* tradingpost
* trainer
* trainer2
* trainer3
* trainer4
* trainer5
* trainingground
* trainingground2
* trainingground3
* wallstone
* wallwood
* warehouse
* watchtower
* weaponmaster
* weaponmaster2
* weaponmaster3
* weaponmaster4
* weaponmaster5
* workshop