==== Installation ====

Put the content of this folder inside root folder of the game:
C:\Program Files (x86)\Steam\steamapps\common\Stronghold Crusader Definitive Edition\

IMPORTANT NOTE:
With this framework installed, you can play multiplayer and coop only with players who have same version of framework and same configuration files. If you want to play multiplayer or coop with players who don't have framework, launch the game via "Launch without framework" shortcut.

If you have any questions or feedback, join Discord server: https://discord.gg/tbmpmmV6Tt


== AI behavior configuration ==
Go to directory Stronghold Crusader Definitive Edition_Data\StreamingAssets\AIC and edit appropriate lord file.
common.aicjson contains parameters that are applied to all lords.

AttackArmyIncrement - after each attack, AI will increate the size of its attacking army by this value.
AttackArmyMaxSize - AI will increate additional size of its attacking army until it reach this value.

== Starting troops configuration ==
Go to directory D:\AIFramework\Stronghold Crusader Definitive Edition_Data\StreamingAssets\Spawns and edit appropriate file for human player.

== Starting resources configuration ==
Go to directory D:\AIFramework\Stronghold Crusader Definitive Edition_Data\StreamingAssets\Spawns and edit gold.json and goods.json files.

== Trail campaign configuration ==
Go to directory Stronghold Crusader Definitive Edition_Data\StreamingAssets\Trails and edit appropriate trail file.

== Unit balance configuration ==
Go to directory Stronghold Crusader Definitive Edition_Data\StreamingAssets\Balance and edit appropriate unit or building stats.



=====================
== AIC explanation ==
=====================

Note: those explanation where written just as a hint long time ago. Because of the that some of them be incorrect or misleading. You can find additional informatino about those parameters at UCP wiki page. However, it has different naming.
https://github.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch2/wiki/AI-Personality

== Economy ==
  CriticalPopularityThreshold 		- Upon reaching a value below this, the AI starts to sell more goods than usual, bribe its population and increase food ration.
  LowPopularityThreshold			- Upon reaching a value below this, the AI starts to gradually decrease taxes and increase food ration.
  HighPopularityThreshold			- Upon reaching a value above this, the AI starts to gradually increase taxes and set food ration to normal.
  MinTaxes							- Minimum taxes allowed. This is a value used by LowPopularityThreshold state.
  MaxTaxes							- Maximum taxes allowed. This is a value used by HighPopularityThreshold state.
  Unused3							- This parameter is not used by the game.
  FarmTypes							- The composition and sequence of building types that the AI uses to build farms.
  PopulationPerFarm					- or each specified amount of available population, one farm is placed. Set this to 0 to get no buildings of that type.
  PopulationPerWoodcutter			- For each specified amount of available population, one woodcutter is placed. Set this to 0 to get no buildings of that type.
  PopulationPerQuarry				- For each specified amount of available population, one quarry is placed. Set this to 0 to get no buildings of that type.
  PopulationPerIronMine				- For each specified amount of available population, one ironmine is placed. Set this to 0 to get no buildings of that type.
  PopulationPerPitchRig				- For each specified amount of available population, one pitch rig is placed. Set this to 0 to get no buildings of that type.
  MaxQuarries						- Maximum number of quarries that the AI can has at the same time.
  MaxIronMines						- Maximum number of iron mines that the AI can has at the same time.
  MaxWoodcutters					- Maximum number of woodcutters that the AI can has at the same time.
  MaxPitchRigs						- Maximum number of pitch rigs that the AI can has at the same time.
  MaxFarms							- Maximum number of farms that the AI can has at the same time.
  BuildInterval						- The interval (in AI phases) between the construction of buildings.
  BuildInterruptionDuration			- Delay (in AI phases) until the AI can build again after any of its structures has been destroyed.
  FoodSellThreshold					- The amount of food below which the AI stop selling this resource. This parameter applies to each kind of food separately. Also it applies to wheat.
  AppleBuyThreshold					- If the AI has less than this amount of apples, it will buy it.
  CheeseBuyThreshold				- If the AI has less than this amount of cheese, it will buy it.
  BreadBuyThreshold					- If the AI has less than this amount of bread, it will buy it.
  WheatBuyThreshold					- If the AI has less than this amount of wheat, it will buy it.
  HopBuyThreshold					- If the AI has less than this amount of hop, it will buy it.
  FoodPurchaseSize					- The AI will buy this amount of food, wheat or hop, when it reaches its threshold.
  WeaponPurchaseSize				- The AI will buy this amount of weapon or armor, when it runs out.
  ProductRequestDelay				- Delay (in game weeks) until the AI can request goods again after previous request was accepted.
  ProductSendThreshold				- The AI will reject player requests unless it has this + requested amount of requested resource.
  DoubleRationsThreshold			- If the AI has more than this total food, it will set double ration.
  WoodSellThreshold					- The amount of wood below which the AI stop selling this resource.
  StoneSellThreshold				- The amount of stone below which the AI stop selling this resource.
  MiscSellThreshold					- The amount of uncategorised resources below which the AI stop selling this resource. This parameter applies to each type of resource separately.
  WeaponSellThreshold				- The amount of weapon below which the AI stop selling this resource. This parameter applies to each type of weapon and armor separately.
  AleSellThreshold					- The amount of ale below which the AI stop selling this resource.
  SellVariance						- When the amount of any resource exceeds its sell threshold by this value, the AI starts selling it.
  InactivityThreshold				- Gold threshold below which AI become inactive. In this state it doesn't recruit troops or buy goods.
  BlacksmithMode					- Production mode the AI sets up for its blacksmith's workshops.
  FletcherMode						- Production mode the AI sets up for its fletcher's workshops.
  PoleturnerMode					- Production mode the AI sets up for its poleturner's workshops.
  UnnecessaryResources				- List of resources that the AI always sells without taking into account threshold values, leaving nothing in stock.

== Defense ==
  WaypointPatrolInterval			- The interval (in AI phases) between switching of rally point for castle patrols.
  WaypointPatrolGroupCount			- Number of groups castle patrol troops splits into for each waypoint type.
  WaypointSiegeEngineThreshold		- The AI won't build any defensive siege engines or recruit engineers unless it has this much gold + siege price.
  WaypointSiegeEngineBuildInterval	- The interval (in AI phases) between the construction of castle siege engines.
  Unused4							- This parameter is not used by the game.
  Unused5							- This parameter is not used by the game.
  DefenseRecruitmentProbabilities	- The probabilities of switching to defence recruitment mode for each AI's strength state.
  RaidRecruitmentProbabilities		- The probabilities of switching to raid recruitment mode for each AI's strength state.
  AttackRecruitmentProbabilities	- The probabilities of switching to attack recruitment mode for each AI's strength state.
  RangedConfrontBase				- Base amount of troops required to form a ranged response squad. The actual number may vary depending on the losses.
  RangedConfrontType				- Ranged unit type that is used in response to the loss of production workers.
  MeleeConfrontCount				- The amount of troops required to form a melee response squad.
  MeleeConfrontType					- Melee unit type that is used in response to the loss of production workers.
  DiggerCount						- The amount of troops that is used to dig castle moat.
  DiggerType						- Unit type that is used to dig castle moat.
  RecruitIntervals					- The intervals (in AI phases) between troops recruitment for each AI strength state.
  TotalCount						- Total amount of troops that are used to protect production and defend the castle.
  ProtectionPatrolGroupCount		- Number of groups protection patrol troops splits into.
  ProtectionPatrol					- Whether protection troops stay at one place or distribute evenly and patrol between production buildings.
  ProtectionPatrolInterval			- The interval (in AI phases) between the switching of rally point for protection patrols.
  CastleCount						- Amount of troops that are used to defence the castle.
  UnitTypes							- The composition and sequence that the AI uses to recruit castle defence and production protection troops.
  
== Raid ==

  UnitCountBase						- Base amount of troops required to form a raid squad.
  UnitCountVariance					- Maximum extra number of units that raid squad may has in addition to base number.
  UnitTypes							- The composition and sequence of unit types that the AI uses to recruit raid troops. Raid troops attack enemy production buildings independently of main attack wave.
  SiegeEngineTypes					- The composition and sequence of unit prototypes that the AI uses to build raid siege engines.
  SiegeEngineCount					- Maximum number of siege engines the AI can build for the raid.
  RetargetInterval					- The interval (in AI phases) between raid troops target updates.
  
== Attack ==
  UnitCountBase						- Base number of units required to begin an attack wave.
  UnitCountVariance					- Maximum extra number of units that attack wave can include in addition to base number.
  PlayerOrderThreshold				- The AI will reject player orders unless it has this amount of attack troops.
  AdvanceRallyPercentage			- The percentage of attack troops that must gather at rally point before siege begins.
  RetreatRallyPercentage			- The percentage of attack troops that must retreat in position before attack is considered complete.
  SiegePhaseDuration				- The duration (in AI phases) of how long the AI tries to attack the castle with siege engines before main army attacks.
  SuccessRetreatDelay				- Delay (in AI phases) until the AI can retreat after target player is defeated.
  BaseCooperationChance				- Chance to coordinate AI's attack with its allies' attacks. This is only a base value. With each attack cooperation chance increases.
  SiegeEngineTypes					- The composition and sequence of unit types that the AI uses to build attack siege engines.
  CowThrowInterval					- Specifies how rarely the AI throws cows (how many stones are thrown per one cow). 0 - disable cow throwing.
  Unused6							- This parameter is not used by the game.
  EngineerLimit						- Maximum number of engineers that attack wave can contain.
  DiggerType						- Unit type that is used to dig moat during a siege.
  DiggerLimit						- Maximum number of moat digging troops that attack wave can contain.
  VanguardType						- Unit type that is used to engage enemy walls before main army moves in.
  VanguardLimit						- Maximum number of vanguard troops that attack wave can contain.
  AssassinLimit						- Maximum number of assassins that attack wave can contain.
  LaddermanLimit					- Maximum number of laddermen that attack wave can contain.
  TunnelerLimit						- Maximum number of tunnelers that attack wave can contain.
  PatrolType						- Unit type that is used to patrols around the enemy castle during the attack.
  PatrolLimit						- Maximum number of patrol troops that attack wave can contain.
  PatrolGroupCount					- Number of groups patrol troops split into.
  BackupType						- Unit type that is used to stay back and attack when walls are breached.
  BackupLimit						- Maximum number of backup troops that attack wave can contain.
  BackupGroupCount					- Number of groups backup troops split into.
  EngageType						- Unit type that is used to engage enemy troops outside the castle during the attack.
  EngageLimit						- Maximum number of engage troops that attack wave can contain.
  SiegeProtectionType				- These units patrol between siege enginees during the attack in order to protect them.
  SiegeProtectionCount				- Maximum amount of siege protection troops that attack wave can have.
  SiegeProtectionGroupCount			- Number of groups siege propection units split into.
  PrimeTypes						- The composition and sequence of unit types that the AI uses to recruit prime attack troops.
  PrimeLimit						- Maximum number of prime troops that attack wave can contain.
  PrimeGroupCount					- Number of groups prime attack troops split into.
  TargetPreference					- Specify how the AI chooses a target player to attack.