Building Modding

**Buildings**, in modding terminology, comprise the various cities, camps, bridges and resource buildings on the map.

It is possible to mod the base stats of these various buildings to tweak consumption and production rates. It is also possible to define additional types of buildings, which can then be added to custom maps through the map editor and used in custom scenarios. The general rules of entity modding apply when modding buildings.

If you are instead looking for how to mod building upgrades, which are constructed in-game within these cities, camps, bridges and resource buildings at the cost of wood and gold, please refer to the upgrade modding tutorial instead.

## Modding Cities

Cities are by far the most complex type of building, having the most different types of attributes and many attributes having several separate values for each of the population levels. The files also contains information for which portraits and miniature graphics are used for each possible native faction group, though a default variant will still be used for faction groups that aren't explicitly defined here.

### Example

```
<entity>
	<type>citycommon</type>
	<class>city</class>
	<constxpdefeat>1000</constxpdefeat>
	<constmissiledamagerate>5</constmissiledamagerate>
	<constmissilerange>6</constmissilerange>
	<constsupplyrange>30</constsupplyrange>
	<constcost>0</constcost>
	<growthdays>20 35 70 125 250 450 700 1100 1600 2300 3500 3500</growthdays>
	<assimilatedays>200 300 500 700 1000 1300 1700 2100 2500 3000 3500 4000</assimilatedays>
	<woodcost>75 150 250 400 600 850 1200 1700 2400 3200 4500 0</woodcost>
	<upgradeslots>1 1 2 2 3 3 4 4 5 5 6 6</upgradeslots>
	<recruitrate>2.5 3.0 3.4 3.8 4.3 4.7 5.1 5.5 6.0 6.5 7.0 8.0</recruitrate>
	<maxrecruits>80 90 100 110 120 130 140 150 160 170 180 190</maxrecruits>
	<supplyconsumption>10 16 21 29 37 48 58 68 82 96 112 128</supplyconsumption>
	<supplycapacity>300 400 500 600 700 800 900 1000 1100 1200 1300 1400</supplycapacity>
	<supplyrange>20.0 22.0 24.0 26.0 28.0 30.0 32.0 34.0 36.0 38.0 40.0 42.0</supplyrange>
	<woodcapacity>500 600 700 800 900 1100 1300 1500 1700 2000 2300 2600</woodcapacity>
	<hitpoints>100 150 200 275 350 425 525 625 725 850 975 1100</hitpoints>
	<income>50 65 75 95 110 125 145 160 180 205 230 255</income>
	<viewrange>7.0 8.0 9.0 10.0 10.5 11.0 11.5 12.0 12.0 12.0 12.0 12.0</viewrange>
	<maxgarrison>30 40 50 65 80 100 120 140 165 190 215 240</maxgarrison>
	<maxpillage>200 350 500 750 1000 1250 1500 2000 2500 3000 4000 5000</maxpillage>

	<wallsegment class="fortificationprop" type="commonwall"/>
	<tower class="fortificationprop" type="commonwalltower"/>
	<gate class="fortificationprop" type="commonwallgate"/>

	<miniatureent state="0" factiongroup="etruscan" class="objectmesh" type="mesh_mini_city_etruscan"/>
	<miniatureent state="1" factiongroup="etruscan" class="objectmesh" type="mesh_mini_city_etruscan"/>
	<miniatureent state="2" factiongroup="etruscan" class="objectmesh" type="mesh_mini_city_etruscan"/>

	<miniatureent state="0" factiongroup="latin" class="objectmesh" type="mesh_mini_city_latin"/>
	<miniatureent state="1" factiongroup="latin" class="objectmesh" type="mesh_mini_city_latin"/>
	<miniatureent state="2" factiongroup="latin" class="objectmesh" type="mesh_mini_city_latin"/>

	<miniatureent state="0" factiongroup="greek" class="objectmesh" type="mesh_mini_city_greek"/>
	<miniatureent state="1" factiongroup="greek" class="objectmesh" type="mesh_mini_city_greek"/>
	<miniatureent state="2" factiongroup="greek" class="objectmesh" type="mesh_mini_city_greek"/>

	<miniatureent state="0" factiongroup="gaul" class="objectmesh" type="mesh_mini_city_gaul"/>
	<miniatureent state="1" factiongroup="gaul" class="objectmesh" type="mesh_mini_city_gaul"/>
	<miniatureent state="2" factiongroup="gaul" class="objectmesh" type="mesh_mini_city_gaul"/>

	<miniatureent state="0" factiongroup="sabellic" class="objectmesh" type="mesh_mini_city_latin"/>
	<miniatureent state="1" factiongroup="sabellic" class="objectmesh" type="mesh_mini_city_latin"/>
	<miniatureent state="2" factiongroup="sabellic" class="objectmesh" type="mesh_mini_city_latin"/>

	<miniatureent state="0" factiongroup="illyric" class="objectmesh" type="mesh_mini_city_gaul"/>
	<miniatureent state="1" factiongroup="illyric" class="objectmesh" type="mesh_mini_city_gaul"/>
	<miniatureent state="2" factiongroup="illyric" class="objectmesh" type="mesh_mini_city_gaul"/>

	<portrait factiongroup="etruscan" atlas="objportraits" sprite="cityetruscan"/>
	<portrait factiongroup="latin"  atlas="objportraits" sprite="citylatin"/>
	<portrait factiongroup="sabellic"  atlas="objportraits" sprite="citylatin"/>
	<portrait factiongroup="greek"  atlas="objportraits" sprite="citygreek"/>
	<portrait factiongroup="gaul"  atlas="objportraits" sprite="citygallic"/>
	<portrait factiongroup="illyric"  atlas="objportraits" sprite="citygallic"/>
</entity>

```

## Modding Bridges

Bridges are constructable buildings on the map that only support wall upgrades, and connect 2 points on the map (usually on opposite sides of rivers), one of which needs to first be captured and connected via supply lines in order to begin constructing the bridge with wood.

### Example

```
<entity>
	<type>woodbridge</type>
	<class>bridge</class>
	<constxpdefeat>1000</constxpdefeat>
	<consthitpoints>200</consthitpoints>
	<constmissiledamagerate>8</constmissiledamagerate>
	<constmissilerange>6</constmissilerange>
	<constmaxgarrison>40</constmaxgarrison>
	<constsupplycapacity>200</constsupplycapacity>
	<constwoodcapacity>200</constwoodcapacity>
	<constsupplyrange>12</constsupplyrange>
	<constviewrange>3</constviewrange>
	<constcost>15</constcost>

	<bridgesegment class="constructedprop" type="bridgewood_segment"/>
	<tower class="fortificationprop" type="bridgewood_towers"/>
	<gate class="fortificationprop" type="bridgewood_gate"/>
	<miniatureent state="0" class="objectmesh" type="mesh_mini_bridge"/>
	<miniatureent state="1" class="objectmesh" type="mesh_mini_bridge"/>
	<miniaturehead class="objectmesh" type="mesh_mini_bridge_unbuilt"/>
	<miniatureford class="objectmesh" type="mesh_mini_bridge_ford"/>
	<portrait state="0" atlas="objportraits" sprite="bridge"/>
	<portrait state="1" atlas="objportraits" sprite="bridge"/>
</entity>

```

## Modding Camps/Forts

Camps (known internally as forts) are constructable buildings on the map that can support walls as well as certain other types of upgrades. Modding forts is largely the same as modding bridges, with some differences in defining graphical assets.

### Example

```
<entity>
	<type>fortcommon</type>
	<class>fort</class>
	<constxpdefeat>1000</constxpdefeat>
	<consthitpoints>300</consthitpoints>
	<constmissiledamagerate>8</constmissiledamagerate>
	<constmissilerange>6</constmissilerange>
	<constmaxgarrison>100</constmaxgarrison>
	<constsupplycapacity>200</constsupplycapacity>
	<constwoodcapacity>200</constwoodcapacity>
	<constsupplyrange>16</constsupplyrange>
	<constviewrange>5</constviewrange>
	<constcost>15</constcost>
	<wallsegment class="fortificationprop" type="commonwallfort"/>
	<tower class="fortificationprop" type="commonwalltowerfort"/>
	<gate class="fortificationprop" type="commonwallgate"/>
	<miniatureent state="0" class="objectmesh" type="mesh_mini_fort"/>
	<miniatureent state="1" class="objectmesh" type="mesh_mini_fort"/>
	<miniatureent state="2" class="objectmesh" type="mesh_mini_fort"/>
	<terraindecalmesh class="objectmesh" type="TerrainDirtDecal"/>
	<portrait state="0" atlas="objportraits" sprite="fort"/>
	<portrait state="1" atlas="objportraits" sprite="fort"/>
	<portrait state="2" atlas="objportraits" sprite="fort"/>
</entity>

```

## Modding Resource Buildings

Resource buildings produce wood, gold and/or food when garrisoned with workers or slaves. Unlike other building types they cannot be garrisoned with military units and can't defend themselves with missile fire. They also do not block movement of the pathing regions in which they exist, and instead are usually placed on the edge of the walkable area.

Resource buildings have 3 possible classes, namely: farm, cattlefarm and mine. The exact technical differences between these classes isn't clear and they may be partially interchangeable. In vanilla, lumber camps and mines use the 'mine' class; farms, vineyards and fisheries use the 'farm' class; and livestock farms use the 'cattlefarm' class. As a general rule, when defining new types of resource buildings it may be safer to use 'farm' if the building produces food (possibly along with gold and/or wood) and 'mine' if it doesn't.

### Examples

```
<entity>
	<type>cattlefarm</type>
	<class>cattlefarm</class>

	<article>BuildingTypes::CattleFarm</article>
	<portrait atlas="objportraits" sprite="cattle"/>

	<miniaturemesh class="objectmesh" type="mesh_mini_livestock"/>
	<tradetilesprite atlas="overlay" sprite="sheeptile"/>

	<constviewrange>1</constviewrange>
	<constcapturedays>3</constcapturedays>
	<constworkercapacity>20</constworkercapacity>

	<constgoldproduction>1</constgoldproduction>

	<constwintersupplyproduction>0.2</constwintersupplyproduction>
	<constspringsupplyproduction>0.7</constspringsupplyproduction>
	<constsummersupplyproduction>1.4</constsummersupplyproduction>
	<constautumnsupplyproduction>1.0</constautumnsupplyproduction>

	<constdaystorepair>360</constdaystorepair>

	<requisitioncost>50</requisitioncost>

	<productionattr>livestockoutput</productionattr>
</entity>

```

```
<entity>
	<type>fishery</type>
	<class>farm</class>

	<article>BuildingTypes::Fishery</article>
	<portrait atlas="objportraits" sprite="fishery"/>

	<miniaturemesh class="objectmesh" type="mesh_mini_fishery"/>
	<tradetilesprite atlas="overlay" sprite="fishtile"/>
	<wateraccess>true</wateraccess>

	<constviewrange>1</constviewrange>
	<constcapturedays>3</constcapturedays>
	<constworkercapacity>20</constworkercapacity>

	<constwintersupplyproduction>0.0</constwintersupplyproduction>
	<constspringsupplyproduction>1.1</constspringsupplyproduction>
	<constsummersupplyproduction>1.1</constsummersupplyproduction>
	<constautumnsupplyproduction>1.1</constautumnsupplyproduction>

	<constdaystorepair>30</constdaystorepair>

	<requisitioncost>50</requisitioncost>

	<productionattr>fisheryoutput</productionattr>
</entity>

```

```
<entity>
	<type>woodmill</type>
	<class>mine</class>

	<article>BuildingTypes::WoodMill</article>
	<portrait atlas="objportraits" sprite="woodmill"/>

	<miniaturemesh class="objectmesh" type="mesh_mini_loggingCamp"/>
	<tradetilesprite atlas="overlay" sprite="woodtile"/>

	<constviewrange>1</constviewrange>
	<constcapturedays>3</constcapturedays>
	<constworkercapacity>20</constworkercapacity>
	<constwoodproduction>0.75</constwoodproduction>
	<requisitioncost>50</requisitioncost>
	<constdaystorepair>120</constdaystorepair>

	<productionattr>lumberoutput</productionattr>
</entity>

```

### Default Types

* cattlefarm
* farm
* fishery
* vineyard
* woodmill
* mine