ERROR: Invalid Reference on TraitModifiers.ModifierId

Narvana

Chieftain
Joined
Nov 20, 2016
Messages
62
I was messing with Tamar's abilities in Expansion1_Leaders.xml and Expansion1_Leaders_Major.xml. I did everything as usual, but some errors occur and I can't find out why.

Can you guide me what is wrong according to this database?

[2920990.438] [Localization]: StartupErrorMessages.xml
[2920990.438] [Localization]: Input XML does not contain database entry tags. GameData, GameInfo or Database
[2920993.354] [Localization]: Validating Foreign Key Constraints...
[2920993.354] [Localization]: Passed Validation.
[2920993.368] [Configuration]: Validating Foreign Key Constraints...
[2920993.368] [Configuration]: Passed Validation.
[2920999.440] [FullTextSearch]: Initializing FullTextSearch
[2920999.898] [Gameplay]: Validating Foreign Key Constraints...
[2920999.909] [Gameplay]: Passed Validation.
[2921001.131] [Configuration]: Validating Foreign Key Constraints...
[2921001.131] [Configuration]: Passed Validation.
[2921001.963] [HallofFame]: Database found. Checking versions...
[2921001.965] [HallofFame]: Database is up-to-date!
[2921008.335] [FullTextSearch]: FTS - Creating Context
[2921035.083] [Configuration]: Validating Foreign Key Constraints...
[2921035.084] [Configuration]: Passed Validation.
[2921041.990] [Gameplay] ERROR: FOREIGN KEY constraint failed
[2921041.990] [Gameplay] ERROR: FOREIGN KEY constraint failed
[2921041.990] [Gameplay]: Validating Foreign Key Constraints...
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT2" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT3" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT4" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT5" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT6" does not exist in Modifiers
[2921042.018] [Gameplay]: Failed Validation.
[2921045.494] [Configuration]: Validating Foreign Key Constraints...
[2921045.494] [Configuration]: Passed Validation.
[2921046.295] [FullTextSearch]: FTS - Creating Context

'TRAIT_MILITARY_GOVERNMENT_SLOTX' is what I used to change stuff. That's how I reference this in the code of ...Leaders_Major.xml

<TraitModifiers>
<Row TraitType="TRAIT_LEADER_RELIGION_CITY_STATES" ModifierId="TRAIT_MILITARY_GOVERNMENT_SLOT"/>
<Row TraitType="TRAIT_LEADER_RELIGION_CITY_STATES" ModifierId="TRAIT_MILITARY_GOVERNMENT_SLOT2"/>
<Row TraitType="TRAIT_LEADER_RELIGION_CITY_STATES" ModifierId="TRAIT_MILITARY_GOVERNMENT_SLOT3"/>
<Row TraitType="TRAIT_LEADER_RELIGION_CITY_STATES" ModifierId="TRAIT_MILITARY_GOVERNMENT_SLOT4"/>
<Row TraitType="TRAIT_LEADER_RELIGION_CITY_STATES" ModifierId="TRAIT_MILITARY_GOVERNMENT_SLOT5"/>
<Row TraitType="TRAIT_LEADER_RELIGION_CITY_STATES" ModifierId="TRAIT_MILITARY_GOVERNMENT_SLOT6"/>
</TraitModifiers>

And in ...Leaders.xml:

<Modifiers>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT</ModifierId>
<ModifierType>MODIFIER_PLAYER_CULTURE_ADJUST_GOVERNMENT_SLOTS_MODIFIER</ModifierType>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT2</ModifierId>
<ModifierType>MODIFIER_PLAYER_UNITS_ADJUST_MOVEMENT</ModifierType>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT3</ModifierId>
<ModifierType>MODIFIER_PLAYER_UNITS_ADJUST_COMBAT_STRENGTH</ModifierType>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT4</ModifierId>
<ModifierType>MODIFIER_PLAYER_CITIES_ADJUST_CITY_YIELD_MODIFIER</ModifierType>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT5</ModifierId>
<ModifierType>MODIFIER_PLAYER_ADJUST_UNIT_MAINTENANCE_DISCOUNT</ModifierType>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT6</ModifierId>
<ModifierType>MODIFIER_PLAYER_CITIES_EXTRA_DISTRICT</ModifierType>
</Row>
</Modifiers>

<ModifierArguments>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT</ModifierId>
<Name>GovernmentSlotType</Name>
<Value>SLOT_WILDCARD</Value>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT2</ModifierId>
<Name>Amount</Name>
<Value>2</Value>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT3</ModifierId>
<Name>Amount</Name>
<Value>15</Value>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT4</ModifierId>
<Name>YieldType</Name>
<Value>YIELD_PRODUCTION</Value>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT4</ModifierId>
<Name>Amount</Name>
<Value>25</Value>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT5</ModifierId>
<Name>Amount</Name>
<Value>100</Value>
</Row>
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT6</ModifierId>
<Name>Amount</Name>
<Value>12</Value>
</Row>
</ModifierArguments>

So what is causing the error here?
 
How are you applying your changes? Are you appending extra code directly into the base-game (and DLC) files? Or are you configuring your amendments/additions as a mod?

Code:
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT2" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT3" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT4" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT5" does not exist in Modifiers
[2921042.009] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "TRAIT_MILITARY_GOVERNMENT_SLOT6" does not exist in Modifiers

This set of errors is essentially telling you that, at the point the Leaders_Major.xml entries are being read, those Modifiers have not been defined. Now, you do seem to define these in the Leaders.xml, so there are two possibilities:

1. You've got an error in the Leaders.xml somewhere that is preventing all of the file from loading.
2. The Leaders_Major.xml is attempting to execute before the Leaders.xml file.

From what I could see in the Expansion1 .modinfo (I am assuming you are editing directly), the order of the files appears to be fine - as you would expect, given it's base-game code and the make-up of these files are the same as what you're trying to achieve.

Code:
[2921041.990] [Gameplay] ERROR: FOREIGN KEY constraint failed
[2921041.990] [Gameplay] ERROR: FOREIGN KEY constraint failed

These are likely to be key to unravelling the mystery. You may want to consult your Modding.log (same folder as Database.log) and look for the unique number-stamp [2921041.990] (sometimes it's a digit different, so .989 or .991 at the end) which will point you to which file the 'ERROR: FOREIGN KEY constraint failed' errors are coming from.

The bit that is confusing to me is that you do not receive an error for TRAIT_MILITARY_GOVERNMENT_SLOT, which you seem to be defining in the same way and in the same place - I'd expect this to show up as an error, too, if you have a syntax error that's bombing the Leaders.xml file out.
 
This ModifierId already exists as part of the base game
Code:
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT</ModifierId>
<ModifierType>MODIFIER_PLAYER_CULTURE_ADJUST_GOVERNMENT_SLOTS_MODIFIER</ModifierType>
</Row>
All designations for ModifierId must be unique, so since there is already a ModifierId with this designation a fatal syntax error results. Why this is not being reported in Database.log I am not sure but this sort of thing is one of many reasons why it is never a good idea to alter the game's original files.
 
This ModifierId already exists as part of the base game
Code:
<Row>
<ModifierId>TRAIT_MILITARY_GOVERNMENT_SLOT</ModifierId>
<ModifierType>MODIFIER_PLAYER_CULTURE_ADJUST_GOVERNMENT_SLOTS_MODIFIER</ModifierType>
</Row>
All designations for ModifierId must be unique, so since there is already a ModifierId with this designation a fatal syntax error results. Why this is not being reported in Database.log I am not sure but this sort of thing is one of many reasons why it is never a good idea to alter the game's original files.

...and that explains why there's no error for that specific ModifierId in the same format as the others - as this ModifierId does exist.

However, the duplication is the reason the file is failing to load and why OP is seeing the other Modifiers fail to be defined.

Re: editing base-game files directly, of course - totally agree!
 
Back
Top Bottom