Object types that can be replaced in separate files

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Seomis

Major
49 Badges
Jun 27, 2016
562
418
  • Crusader Kings II: Charlemagne
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - After Dark
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Crusader Kings II
  • Victoria: Revolutions
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Europa Universalis IV: Art of War
  • Crusader Kings II: Legacy of Rome
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Mass Transit
  • Surviving Mars
  • Surviving Mars: Digital Deluxe Edition
  • Shadowrun Returns
  • Shadowrun: Dragonfall
  • Surviving Mars: First Colony Edition
  • Stellaris: Megacorp
  • Prison Architect
  • Europa Universalis IV: Rights of Man
  • Crusader Kings II: Reapers Due
  • Hearts of Iron IV: Colonel
  • Hearts of Iron IV: Cadet
  • Stellaris: Galaxy Edition
  • Cities: Skylines - Snowfall
  • Crusader Kings II: Conclave
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Pillars of Eternity
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Pre-order
  • Cities: Skylines
  • Victoria 2
  • Stellaris
  • Age of Wonders III
Often, creating an identically named object (technology, trait, etc.) in a separate file will duplicate that object instead of replacing it. Because of this, a modder who wants to change an object from the vanilla game normally has to overwrite an entire core file: This is the main source of conflicts between mods. But (!), there are a handful of object types that will be replaced instead of duplicated:
  • Game rules: Place a modified game rule from common/game_rules/00_rules.txt in a new file that comes after asciibetically.

  • Policies: Place a modified policy from common/policies/00_policies.txt in a new file that comes after asciibetically.

  • Scripted triggers: Place a modified trigger from common/scripted_triggers/00_scripted_triggers.txt in a new file that comes after asciibetically.

  • Species rights: Place a modified species right from common/species_rights/species_rights.txt in a new file that comes after asciibetically.

  • Localisation strings: Create a new folder, common/localisation/replace, and put any modified core localized string in <new_file>_l_<language>.yml.
  • Defines: Definitions in common/defines/00_defines.txt can be overwritten individually in a separate file by including only those entries you wish to change, along with the named block they reside in. E.g., NGameplay = { PRESCRIPTED_PLANETS_NUM = 0 }
  • Buildings are overwritten and not duplicated ... kind of. If a building is redefined in a file that loads after the core file, the second definition will--in most contexts--be the only definition of that building. You will, however, see multiple instances of the same building show up in upgrade options. It is therefore best to avoid doing this except for buildings that are not part of an upgrade chain.
  • Events: Strictly speaking, an event can't be overwritten. What can be done instead is putting a modified vanilla event (same id) in a new file that will be read before the core file. This will cause the game to accept the mod's event and reject the core one, with a warning sent to the error log.
  • Static modifiers: Place a changed static modifier from any of the core files in common/static_modifiers in a new file that comes before asciibetically. This works similarly to events but with the added perk of no warnings getting sent to the error log.
Object types that definitely get duplicated include:
  • Component templates
  • Edicts
  • Ethics
  • Ship sizes
  • Technologies
  • Traits
  • War Demands: On first impression this one appears to be overwritable. Only one instance of a demand will appear when declaring war and while a war is in progress. However, once a war is concluded, a demand's effect is run once for every instance of the demand.

If you come across other replaceable object types or see an error above, post here and I'll update the list.
 
Last edited:
  • 6
Reactions:
Also, you can do the same thing with the defines file.

For example by using the following code:
Code:
NDefines.NGraphics.RANDOM_HEIGHT_MIN = 0
NDefines.NGraphics.RANDOM_HEIGHT_MAX = 0

I can just replace 2 lines of code (in a new defines file) rather than overwrite the entire file just to change those two lines.
 
  • 1
Reactions:
Also, you can do the same thing with the defines file.

For example by using the following code:
Code:
NDefines.NGraphics.RANDOM_HEIGHT_MIN = 0
NDefines.NGraphics.RANDOM_HEIGHT_MAX = 0

I can just replace 2 lines of code (in a new defines file) rather than overwrite the entire file just to change those two lines.

Ah, right! Added.
 
There's output to the error log when this is tried. Is there no other negative consequence?
Not as far as I know.
(Note: I know that both "Harder Invaders" and "Ethics and Governments Rebuild" mods use this approach, and with both of those mods it appears to work fine. I have not had issues with them.)
 
Thanks! I'll update this later today. Incidentally, I did test putting a slightly modified copy of an ethic in a separate file, and on initial impression it appeared to overwrite instead of duplicate. I need to do a more thorough lookover, but it's promising!
 
Last edited:
Looks like civics can be overridden individually as well, as long as it's in a new file whose name comes after 00_civics (such as 01_civics).

EDIT: Actually, it might just duplicate them. Lemme test some more...

EDIT2: Okay, it seems to work fine as far as I can tell. Only oddity is that the requirements are listed twice:
1RlPM9V.jpg
 
Last edited:
About buildings showing up twice if they're part of an upgrade chain. I've actually found one mod that doesn't have that issue, for some reason: This one. I'm not sure how the author did it, but despite having modified the level V power plant, when upgrading from IV to V, I don't get the duplicates.
 
About buildings showing up twice if they're part of an upgrade chain. I've actually found one mod that doesn't have that issue, for some reason: This one. I'm not sure how the author did it, but despite having modified the level V power plant, when upgrading from IV to V, I don't get the duplicates.
Check for the duplicate upgrade on a capital planet. The original level 5 upgrade option may not appear on regular planets because it's normally capital only.