JFD's and Pouakai's Mercenaries/Code

Each leader is accorded a new flavour: Mercenaries. This determines the likelihood that an AI will consider to take out a Mercenary Contract. To add support to this new flavour, please see my Master Support File. If a leader does not have support for this flavour, they will default to a value of 5.

This mod has been designed to be extremly modular; it is very simple to add a new Contract. In what follows, we are going to detail how to make a new Contract. Because Pouakai believes XML is easier, we shall do so in that format.

## Adding a New Contract

A new Contract is added not disimilarly to a new Social Policy:

```
<JFD_Contracts>

   <Type>CONTRACT_JFD_AMSAIG</Type>

   <Category>CONTRACT_JFD_MERCENARY</Category>

   <Description>TXT_KEY_CONTRACT_JFD_AMSAIG_DESC</Description>

   <Adjective>TXT_KEY_CONTRACT_JFD_AMSAIG_ADJ</Adjective>

   <Civilopedia>TXT_KEY_CONTRACT_JFD_AMSAIG_TEXT</Civilopedia>

   <ObsoleteEra>ERA_CLASSICAL</ObsoleteEra>

   <PrereqEra>ERA_ANCIENT</PrereqEra>

   <PromotionType>PROMOTION_JFD_AMSAIG</PromotionType>

   <Rating>3</Rating>

   <Turns>25</Turns>

   <YieldCost>[ICON_GOLD]</YieldCost>

</JFD_Contracts>

```

Here, we can see a few familiar tags: **Description** determines the name of the Contract, **Adjective** determines the denonym by which its units are known, and **Civilopedia** is a short blurb about the Contract's givers. Others are intuitive: **PromotionType** determines the unique promotion that a Contract's units come with, **Rating** determines the quality of that Contract, **Turns** determine its length, and the **PrereqEra** and **ObsoleteEra** tags determine when that Contract becomes available and when it does not. Finally, **YieldCost** is used to specify whether the Contract should be purchased with Gold ( ) or Faith ( ).

There are also a few additional tags which are not needed, but which you may wish to make use of: **IsSlavery** determines whether the Contract's units are slaves (and will become unavailable with Sovereignty's 'Emancipation Reform'), **PrereqReligion** specifies that the player must have founded a specific religion (or must have a specific State Religion with Piety) before they can take this Contract, and **PrereqCivilization**specifies that the player must be a specific civilization.

Once the body of your Contract is created, there are two more steps. The first is in assigning what units that Contract should be allowed to offer. This can be specified by a particular unit type, a particular unit class, or a particular combat type. Although you may only choose from one of these, there is no limit to the number of unit types, classes, or combat types that a Contract can pick from.

```
<JFD_Contract_UnitCombats>

   <ContractType>CONTRACT_JFD_AMSAIG</ContractType>

   <UnitCombatType>UNITCOMBAT_ARCHER</UnitCombatType>

</JFD_Contract_UnitCombats>

```

```
<JFD_Contract_UnitCombats>

   <ContractType>CONTRACT_JFD_AMSAIG</ContractType>

   <CultureType>JFD_Northern</CultureType>

   <UnitCombatType>UNITCOMBAT_MELEE</UnitCombatType>

</JFD_Contract_UnitCombats>

```

Here, we are detailing that the Amsaig Contract may choose any unit from the Archer (a.k.a. Ranged) combat type, whilst only picking units from the Melee combat type that belong to a civilization from the Northern culture group. However, if a unit like this cannot be found, it will instead choose a default melee unit. If you instead wish the Contract to become unavailable if this happens, you must set the **UseOnlyCultureType** tag to true. This tag is available for both the unit classes and the unit combats table.

Finally, to complete your Contract you must create the promotion specified in the JFD\_Contracts table above. There is, however, one thing that you must do in this process, and that is to assign that promotion to a specific dialect:

```
<UnitPromotions_JFD_UnitDialogues>

   <PromotionType>PROMOTION_JFD_AMSAIG</PromotionType>

   <UnitDialogue>AS2D_SOUND_JFD_CELTIC</UnitDialogue>

</UnitPromotions_JFD_UnitDialogues>

```

With Cultural Diversity's unit dialogue component, this will override the standard dialogue used by this Contract's units for a unique one. In this case, if we were playing as the Americans, our Amsaig Mercenaries, instead of speaking American English, would speak Celtic.

Note: If you wish to add a new Contract but do not want your mod to depend upon Mercenaries, you will need to copy the tables found under the CONTRACTS heading in Core/Mercenaries\_Master.sql.

## Modding Costs, Maintenance, and Turns

Finally, there is one other thing that you can modify, and that is the cost, maintenance, and duration of Contracts. In *Mercenaries*, the Jiayuguan Fort Wonder already increases the length of a Contract's duration, but you may also want to modify the costs and maintenance with one of the following tables:

```
CREATE TABLE IF NOT EXISTS
Building_JFD_ContractModifiers (

BuildingType        text REFERENCES Buildings(Type) default null,

CostModifier        integer                         default 0,

MaintenanceModifier integer                         default 0,

TurnsModifier       integer                         default 0);

```

```
CREATE TABLE IF NOT EXISTS
Policy_JFD_ContractModifiers (

PolicyType          text REFERENCES Policies(Type) default null,

CostModifier        integer                         default 0,

MaintenanceModifier integer                         default 0,

TurnsModifier       integer                         default 0);

```

```
CREATE TABLE IF NOT EXISTS
Trait_JFD_ContractModifiers (

TraitType           text REFERENCES Traits(Type)    default null,

CostModifier        integer                         default 0,

MaintenanceModifier integer                         default 0,

TurnsModifier       integer                         default 0);

```

Simply choose which is most appropriate for your needs, add the CREATE TABLE code above to your mod, and fill in the table itself as per the preceding tutorial.

## References

1. ↑ this promotion is absolutely necessary. If a Contract does not have this filled, it will be ignored.
2. ↑ you may leave ObsoleteEra as null if the Contract does not become obsolete.