A
GUIDE
TO
settlement_mechanics.xml
This file is one of the most important files for any modification. It controls the behaviour of settlements; how order takes effect, population growth, general income, even wages and upkeep among other things. The file itself is only about 6.40 kb in size and has a rather simple set up. The mathematics involved in understanding how it all falls together may be daunting at first, but i will try to keep it as simple as possible. What this file can do is quite amazing.
Throughout the file you find various pips and pip modifiers, which correspond to various factors. There are 3 types of factors;
SPF - Settlement Population Factor
SOF - Settlement Order Factor
SIF - Settlement Income Factor
Referring to Population Growth, the effects of Order, and the amount of Income generated.
These 3 Factor types, Population (growth), Order and Income. Each have a maximum value they can attain in game, Population Growth 12.5%, Order 500%, and Income unkown (or unlimited). For example, your population growth for any settlement can not exceed 12.5% per turn (nor can it fall below -12.5%), Order can not exceed 500% in game (You know that if order is below 100% there is a chance for riots and losing control of a city), I never found a limit to income as i assume its possible to be very high and possibly unlimited.
The most confusing part to understanding this file is the pip itself. Each factor draws a value from another file. More often then not this value is from the EDB (generally in the capabilities section of a building entry). Bonuses such as law_bonus, population_health_bonus, happiness_bonus etc. There are quite a few types of bonuses - Lets call all of them FUN bonuses. In addition, other values in the capabilities section of a building entry are also referred to by a pip, values such as farming_level, mine_resource etc. To properly understand the workings of the pip i highly suggest understanding the workings of the EDB.
This is where it may start to become confusing, so i will try to elaborate as much as i can and use examples where possible.
Each Factors PIP will be effected by the values in the EDB by the following percentages (per 1.0 as set in the factor itself);
SPF - 0.5%
SOF - 5% (for the most part)
SIF - 10% (for the most part)
For example. SPF_FARMS_BUILT with a pip value of 1.0 will give 0.5% increase in population growth to whatever value this factor is referring to - in this case, SPF_FARMS_BUILT refers to the farming_level capability from the EDB. Looking at the EDB you see each tier is set to one more then the previous tier, increasing population growth by 0.5% for each upgrade of that building. Increasing the value in the EDB will likewise increase this effect. This is a prime example of why knowledge of the EDB will greatly help in understanding this xml file.
The general set up for each factor is somthing like the following;
Code:
<factor name="SOF_HEALTH">
<pip_modifier value="1.0"/>
<city_modifier value="1.0"/>
<castle_modifier value="1.0"/>
<pip_min value="0"/>
<pip_max value="25"/>
</factor>
PURPLE - This is the name of the pip, and generally gives a hint as to what value it refers to. Some factor names still elude me as to what they actually refer to which i will point out later.
RED - Is a global value, it will effect all settlements. (% of the pip itself) Note: You may be able to use negatives. I have not tested negative values though.
BLUE - Affects cities according to the Pip value (% of the pip modifier)
BLUE BOLD - Affects castles according to the Pip value (% of the pip modifier)
NOTE: It is not neccesary to use both castle and city modifiers. If you set the global value for cities you can simply adjust the castle modifier accordingly. With that said, you don't need to use either modifier and simply use the global value.
GREEN - Minimum value the pip value can attain (generally this will refer to the bonus it gives in the EDB; 1, 2, 3 etc)
GREEN BOLD - Maximum value the pip value can attain (generally this will refer to the bonus it gives in the EDB; 1, 2, 3 etc)
NOTE: The engine calculates and keeps track of all bonuses (FUN or BUILDING CAPABILITY). The maximum value for the pip is simply where you will no longer gain its benefits. As an example, say you have a number of buildings that grant happiness bonuses to your settlement. Every time you construct one of these buildings or upgrade it the happiness in the settlement will increase (dependant on the type of factor ofcourse), once these bonuses equal the pip_max value no additional bonuses will effect the settlement. The same can be said for pip_min value. This could be an interesting way to limit order from distance to capital, once a certain distance has been reached the negative order will not increase beyond the pip_max. In addition, the pip _min and _max are not needed for the file to function properly, they merely set limits.
Here is a list of all the Factors. Where possible i have added the value referred to.
Any factor with no statements are ones i have no idea what-so-ever about. Not even an educated guess.
POPULATION GROWTH
SPF_FARMING_LEVEL - Farming level as per regions.txt. 6 in the regions for base farming would be 3% bonus to population growth at 1.0.
SPF_FARMS_BUILT - The farming_level capability from the EDB
SPF_HEALTH - population_health_bonus from the EDB
SPF_BUILDINGS - any bonus given from EDB (1 per building)
SPF_TAX_RATE_BONUS - Only effects low tax rate in game. 1.0 gives 0.5% population growth when settlement has low taxes
SPF_BUILDINGS_FUN - happiness_bonus from the EDB
SPF_GOVERNORS_INFLUENCE - Grants 0.5% population bonus when set to 1.0 when the settlements Governer is present.
SPF_TRADE - This one may be difficult to grasp. 1.0 grants 0.5% populaiton growth per trade item (check your settlement trade) minus any trade item that region already owns and does not couple with duplicate imports/exports.
SPF_SQUALOUR - Squalor has a negative effect on population growth of -0.5% per 1.0. I am unsure where squalor is actually calculated so i dont know how to properly adjust this value. I assume setting the pip_max to 0 may actually eliminate squalor altogether. I believe squalor increases when no change has taken place in that settlement within a number of turns. I have no idea what that number of turns is though. I also believe squalor comes into play when a settlement reaches its max population.
SPF_PLAGUE - This is another value i am unsure of where it calculated. It also has a negative effect on growth of -0.5% population growth per 1.0.
SPF_TAX_RATE_PENALTY - population growth from higher taxes (opposite effect to Tax Rate bonus). Normal taxes grants no bonus or negatives to population growth. High taxes and Very High have a negative effect of -0.5% opulation growth each per 1.0.
ORDER
SOF_GARRISON - This factor sets the maximum order that a number of units can provide. In all my tests 5 units were sufficient to set order to 100% regardless of the pip_modifier value (1.0 or 0.1 or 4.0). I believe this factor simply grants a percantage to a single unit, 5 being order control of 100% in game. This seems to go against my findings of other SOF factors where 5% is per 1.0. Any additional research into this will be appreciated.
SOF_BUILDINGS_LAW - law_bonus in EDB
SOF_BUILDINGS_FUN - happines_bonus in EDB
SOF_GOVERNORS_INFLUENCE - Governors Title holder in settlement
SOF_TAX_BONUS - Only effects low taxes. (30% at 1.0 on low tax only!)... This is another one that seems to go against my general findings or 5% per 1.0.
SOF_TRIUMPH -
SOF_BOOM -
SOF_ENTERTAINED - Did not test this value, i believe it refers to any building giving a FUN bonus.
SOF_HEALTH - population_health_bonus from the EDB
SOF_FEAR - I believe this is related to a generals Fear rating. Its not called Fear, i know, i just can't think of it off the top of my head.
SOF_GLORY -
SOF_SQUALOUR - Comes into effect when the settlement experiences squalor. Once again i do not know where this value is calculated and am unable to test it.
SOF_DISTANCE_TO_CAPITAL - This one still eludes me. I believe (educated guess only) that it refers to the movement distance as set in the characters.txt file (for all pathfinding calculations). 1.0 refers to this distance. Therefore increasing the pip_modifier would increase order issues when a settlement is at that distance (or part thereof). Decreasing the pip_modifier will solve order problems.
SOF_NO_GOVERNANCE - No Governance only adds when NO unit is in a settlement 5.0 gve 75% (15 per 1.0)...
SOF_TAX_PENALTY - The penalty given on high, very high tax rates. (0.25 = 5%) 1.25 = 25%
SOF_TURMOIL - Not properly tested. You can give turmoil through the campaign_script. I suspect it will then change how turmoil effects order. Other things can also cause turmoil. But elude me at the moment.
SOF_BESIEGED - Not tested properly, obviously only comes into play when a settlement is besieged. Setting the pip_modifier to 0.0 will eliminate any order problems when besieged. Increasing it will cause more order issues.
SOF_BLOCKADED - Same as SOF_BESIEGED, except when a port is blockaded by an enemy fleet.
SOF_RELIGIOUS_UNREST - Lowering the pip_modifier will decrease order issues when a region experiences religious unrest. This is another value i have not tested, and therefore can't say what the exact value is that is being modified.
SOF_EXCOMMUNICATION - Same as religious unrest except for when a settlement belongs to an excommunicated faction. If this value is not balanced expect major issues in game from the pope.
INCOME
SIF_FARMS - harvest where 1.0 is 100% collected. From regions.txt
SIF_TAXES - taxes collected Approx. 33% per 1.0.
SIF_MINING - mining_resource capability in the EDB by 10% per 1.0 bonus.
SIF_TRADE - trade_base_income_bonus in the EDB by 100% per 1 bonus. So 0.5 would give 50% trade bonus
SIF_BUILDINGS - any bonus given from EDB (1 per building)
SIF_ADMIN - Alters the admin costs as found in your balance sheet.
SIF_WAGES - Alters wages as per the balance sheet
SIF_UPKEEP - increase/decrease upkeep costs
SIF_CORRUPTION - Not tested, but alters the corruption within your cities. Increasing the pip_modifier will increase corruption.
SIF_ENTERTAINMENT - Not tested, but i believe is is buildings that provide entertainment (FUN)
SIF_DEVASTATION -
As you can see, there are a few Factors i am not 100% sure on (there is a ridiculous amount of time needed to thoroughly test one factor) and some factors im totally at a loss for.
At the bottom of this file you will find the population levels. This dictates when a settlement can upgrade and what its maximum population can be for any given settlement upgrade.
Code:
<population_levels>
<!-- city -->
<level name="village" base="400" upgrade="1500" min="400" max="5999"/>
<level name="town" base="1500" upgrade="6000" min="400" max="11999"/>
<level name="large_town" base="6000" upgrade="12000" min="400" max="23999"/>
<level name="city" base="12000" upgrade="24000" min="400" max="47999"/>
<level name="large_city" base="24000" upgrade="48000" min="400" max="120000"/>
<level name="huge_city" base="48000" min="400" max="240000"/>
<!-- castle -->
<level name="moot_and_bailey" base="400" upgrade="0" min="400" max="5999"/>
<level name="wooden_castle" base="400" upgrade="6000" min="400" max="11999"/>
<level name="castle" base="6000" upgrade="12000" min="400" max="23999"/>
<level name="fortress" base="12000" upgrade="24000" min="400" max="47999"/>
<level name="citadel" base="24000" upgrade="48000" min="400" max="80000"/>
</population_levels>
RED - Minimum population needed to be classed as this level of settlement. It should be equal to the previous levels upgrade value.
BLUE - Required population for this settlement size can be offered to upgrade to the next tier.
GREEN - Minimum population for this settlement size. Population levels will not decrease below this value.
PURPLE- Max population this settlement can hold. Settlement MUST upgrade to increase beyond this point.
I hope this thread is helpful to anyone wishing to modify this file. Any further suggestions to improve this guide is welcome. Feel free to PM regarding issues or questions.