Unit modding

From Europa Universalis 4 Wiki
Jump to navigation Jump to search

Modding Units[edit | edit source]

All units found ingame are stored in /Europa Universalis IV/common/units/.

Land units[edit | edit source]

To add a new historical land unit (i.e. halberd_infantry), you create a file in the /Europa Universalis IV/common/units/ directory following this format:

type = <internal type>              # One of the internal types
unit_type = <technology group>      # Optional. The technology group the unit appears for. Leaving it out will display the unit for all technology groups. 

maneuver = <int>                    # 1 for infantry and artillery, 2 for cavalry
offensive_morale = <int>
defensive_morale = <int>
offensive_fire = <int>
defensive_fire = <int>
offensive_shock = <int>
defensive_shock = <int>

unitsize = <int>                    # Optional. Overrides the standard regiment size (1000), making regiments smaller or bigger with this unit.
manpower = <float>                  # Optional. Overrides the manpower cost for this unit. 1 equals 1000 men.

# Optional, displays the unit as an option when the triggers are met.
trigger = {
    <triggers>
}

Land units can be one of these three internal types:

infantry
cavalry
artillery

Note: changing the unitsize for a unit does not alter the combat formula, which means smaller regiments will do poorly in combat.

Ship units[edit | edit source]

To add a new historical ship unit (i.e. barque), you create a file in the /Europa Universalis IV/common/units/ directory following this format:

type = <internal type>              # One of the internal types
unit_type = <technology group>      # Optional. The technology group the unit appears for. Leaving it out will display the unit for all technology groups. 

hull_size = <int>
base_cannons = <int>
sail_speed = <int>
blockade = <int>

trade_power = <float>   # Optional. Trade power this ship grants when Protecting Trade.
sprite_level = <int>    # Optional. Sprite level for ship (1 to 5)
manpower = <float>      # Optional. Overrides the manpower cost for this unit. 1 equals 1 sailors.

# Optional, displays the unit as an option when the triggers are met.
trigger = {
    <triggers>
}

Ship units can be one of these four internal types:

heavy_ship
light_ship
galley
transport

Internal Types[edit | edit source]

The functionality of the internal types cannot be modified. For example, you cannot remove the cavalry flanking mechanic from units of the cavalry type, or add it to a different internal type.

Other areas in the files such as defines and modifiers refer to these types (i.e. ARTILLERY_SPEED or infantry_power and alter all units that use said internal type.

Technology[edit | edit source]

For units to appear at all, they must be enabled within a technology. Add the following line to a technology to enable a unit:

enable = <unit>

Note: land units can only be enabled in MIL type technologies, whereas ship units can only be enabled in DIP type technologies.

Localisation[edit | edit source]

The localisation for a unit follows this format:

<unit>: "Unit name here"
<unit>DESCR: "Description here"

Special Unit Types[edit | edit source]

Special units like Banners, Streltsy and Janissaries have a mix of hard-coded and soft-coded elements, depending on the specific unit. It is not possible to make entirely custom special units at this time.

Banners[edit | edit source]

Banners are units which are enabled in three possible ways, by culture, modifiers or by government.

Cultures which can use banners are defined at /Europa Universalis IV/common/cultures. They have the following code:

country = { has_banners = 1}
province = { local_has_banners = 1}

The Great Mongol State reform found at /Europa Universalis IV/common/government_reforms/04_government_reforms_tribes instead has the following code:

conditional = {
 allow = { has_dlc = "Mandate of Heaven" }
 allow_banners = yes
}

This allows the Mongol Empire to raise banners out of their primary culture, even though this is not defined in the cultures files.

Banners can also be enabled by the following modifier:

has_banners = 1

This allows any country to raise banners in their primary culture provinces, and can also be used in ideas/events.The amount of banners raised is based on code in at /Europa Universalis IV/common/static_modifiers. Under "development" the following line can be found:

local_amount_of_banners = 0.066

This approximately equates to one banner per 15 development by default.

Modifiers which affect banners can be found in /Europa Universalis IV/common/defines:

 BANNER_DISCIPLINE_BONUS = 0.05,
 BANNER_MANPOWER_USAGE = 0.25,
 BANNER_REINFORCE_SPEED = -0.5,
 BANNER_MAINTENANCE_COST = 0.5,
 BANNER_AGE_MULTIPLIER = 0.50,
 BANNER_STARTING_STRENGTH = 0.1,	

"Starting strength" determines how many people the regiment starts with. A value of 1 means each regiment immediately has 1000 men; a value of 0.1 means they start with 100.

As of Patch 1.33 Unique modifiers can also be applied to Banners in /Europa Universalis IV/common/event_modifiers with the following:

Note: localisation for this is currently broken but the effect will still apply.

the_green_standard_army = {
   reinforce_speed = 0.5
   is_banner_modifier = yes
}

Localisation text which applies to banners follows this format:

 REGCAT_banner:0 "Banners"
 BANNER_NAME:0 "$HOME$'s $NUM$$ORDER$ Banner"

Cossacks[edit | edit source]

Cossacks can be spawned in a province by the following effect:

capital_scope = {
 cossack_cavalry = ROOT
}

This is useful if you want to have a custom way of creating the units, such as via an estate privilege, decision or event.

You can create an estate privilege which enables cossacks by adding the line

mechanics = {
 enables_cossack_regiments
}

The modifiers which affect Cossacks are found in /Europa Universalis IV/common/defines:

COSSACKS_SHOCK_DAMAGE_BONUS = 0.1

As of Patch 1.33 custom modifiers can also be applied to Cossack regiments in /Europa Universalis IV/common/event_modifiers using the following method: Note: localisation for this is currently broken but the effect will still apply.

#country modifier
fear_tactics = {
   cavalry_shock = 1
   is_cossack_modifier = yes
}

Localisation text which applies to cossacks follows this format:

 REGCAT_cossacks:0 "Cossacks"
 COSSACKS_NAME:0 "$HOME$'s $NUM$$ORDER$ Cossacks"
 COSSACKS_REGIMENT:0 "Cossacks Regiment\nShock Damage Bonus: $VAL$"

Janissaries[edit | edit source]

Janissaries are tied to the has_pashas = yes line in /Europa Universalis IV/common/government_reforms. There is currently no effect for manually spawning Janissaries and the unit interface is hardcoded, so they can only be recruited in provinces with heathen religions to the current country. modifiers for janissaries are specified in /Europa Universalis IV/common/static_modifiers:

janissary_regiment = {
	fire_damage_received = -0.1
	shock_damage_received = -0.1
	reinforce_cost_modifier = 1.0
	drill_gain_modifier = 1.0
}

Code concerning janissaries in /Europa Universalis IV/common/defines includes:

 CREATE_JANISSARIES_MIL_COST = 10,				-- Cost to create janissaries (per unit)
 JANISSARIES_USES_CONSTRUCTION = 0,

Unique modifiers can also be applied to Janissaries in /Europa Universalis IV/common/event_modifiers with the following:

loyal_to_sultan = {
   infantry_power = 0.1
   is_janissary_modifier = yes
}

Localisation text which applies to janissaries:

 REGCAT_janissaries:0 "Janissaries"
 STATE_JANISSARIES_MIL_POWER:0 "Costs $AMOUNT|Y$ £mil£"
 CREATEJANISSARIES_TEXT:0 "$EFFECT$"
 STATE_JANISSARIES_CREATED_REGIMENTS:0 "$NUM|Y$ Janissaries will spawn in $PROV|Y$"
 STATE_JANISSARIES_HEATHEN_PROVINCES:1 "State needs at least $AMOUNT|Y$ development of Heathen faith fully cored and controlled by you."
 STATE_JANISSARIES_BATTLE_OR_SIEGE:0 "You cannot conscript Janissaries in a province with an ongoing battle or siege."
 STATE_JANISSARIES_NO_REGIMENTS:0 "The heathen presence in the $STATE|Y$ is too low to provide any Janissaries."
 CREATE_JANISSARIES_BUTTON:1 "Conscript Janissaries"
 CREATEJANISSARIES:1 "Conscript Janissaries"
 JANISSARIES_REGIMENT:0 "Janissary Regiment\n$EFFECT$"
 ONLY_JANISSARY_MODIFIER:0 "§YAffects only Janissary Regiments§!"
 STATE_JANISSARIES_GOVERNMENT_ALLOWS:0 "Only nations with Ottoman Government can Conscript Janissaries."
 STATE_JANISSARIES_COOLDOWN:0 "Can recruit more Janissaries at $DATE|Y$."
 STATE_JANISSARIES_NEED_MIL_POWER:0 "You need $AMOUNT|Y$ £mil£ to Conscript Janissaries"
 STATE_JANISSARIES_TITLE:0 "§YConscript Janissaries§!"
 STATE_JANISSARIES_DESC:2 "With §YOttoman Government§! we are capable of recruiting Janissaries in heathen provinces. The more heathen development, the more Janissaries we can draw from them."
 JANISSARY_FORCELIMIT:1 "We can recruit up to $VAL|%Y$ of our force-limit of $FL$ as §GJanissaries§! as we can only recruit them from our Heathen Provinces.\n"
 JANISSARY_LIMIT_RELIGION:0 "$PROVINCE$ is a $RELIGION$ province, so can not recruit Janissaries here."
 JANISSARY_NAME:0 "$HOME$'s $NUM$$ORDER$ Janissary"
 janissary_regiment:0 "Janissary"
 JANISSARIES_REGIMENT_TYPE:0 "Janissary"
 HAVE_LESS_JANISSARIES_THAN:0 "Have less Janissary Regiments than $VALUE|Y$.\n"
 HAVE_AT_LEAST_JANISSARIES_THAN:0 "Have at least $VALUE|Y$ Janissary Regiments.\n"

Some further things which can be used to mod janissaries are:

  • The on action on_janissaries_raised
  • the triggers num_of_janissaries and janissary_percentage

Streltsy[edit | edit source]


The creation of Streltsy units via Russian governments is tied to the

has_russian_abilities = yes

line in /Europa Universalis IV/common/government_reforms. The "russian abilities" mechanic is hard-coded, so it isn't possible to only have the button which spawns streltsy.

Thankfully, streltsy can also be spawned in a province by the following effect:

capital_scope = {
   streltsy_infantry = ROOT
}

The modifier which causes streltsy to affect stability cost can be found at /Europa Universalis IV/common/static_modifiers.

streltsy_modifier = {
	stability_cost_modifier = 1.0
}

The modifier reflects a forcelimit filled entirely with streltsy. This can be entirely replaced with a different modifier, or set of modifiers.

Modifiers affecting Streltsy can be found in /Europa Universalis IV/common/defines:

STRELTSY_FIRE_DAMAGE_BONUS = 0.1

As of Patch 1.33 Unique modifiers can also be applied to Streltsy in /Europa Universalis IV/common/event_modifiers with the following:

Note: localisation for this is currently broken but the effect will still apply.

army_reforms = {
   discipline = 0.05
   is_janissary_modifier = yes
}

Localisation text which applies to streltsy follows this format:

 REGCAT_streltsy:0 "Streltsy"
 STRELTSY_NAME:0 "$HOME$'s $NUM$$ORDER$ Streltsy Regiment"
 STRELTSY_REGIMENT:0 "Streltsy Regiment\nFire Damage Bonus: $VAL$"
Documentation EffectsTriggersModifiersScopesVariablesLocalisationCustomizable localizationRun files
Scripting Scripted functionAdvisorsAgesBookmarksBuildingsCasus belliColonial regionsCountriesCultureDecisionsDefinesDiplomatic actionsDisastersEmpire of ChinaEstatesEventsFactionsGovernmentGreat projectsHistoryHoly Roman EmpireIdea groupsInstitutionsMercenariesMissionsModifiersNation designerOn ActionsParliamentPeace treatiesPoliciesRebel typesReligionSubject typesTechnologyTrade companiesTrade goodsUnits
Map MapNation designerRandom New WorldTrade nodes
Graphics 3D ModelsInterfaceGraphical AssetsFontsParticlesShadersUnit models
Audio MusicSound
Other Console commandsChecksumJoroDox mod making toolMod structureTroubleshootingThe ValidatorRun files
Guides Adding a provinceSave-game editing