Update tag does not work for certain units in XML

Marsarah

Chieftain
Joined
Oct 3, 2019
Messages
4
Hi all!

I've been modding Civ V for a while and got stuck in one aspect: updating existing units in XML with the Update tag.

The setup: I am not using Modbuddy. Instead, I placed my mod files in the Assets/DLC/Expansion2 directory and edited the Expansion2.Civ5Pkg file to hookup the new files. This works. I was able to create 13 new civilizations. I did this on purpose to be able to play with friends.

The problem: I want to now change existing unit data without modifying game files (I want to do it from my mod files). Specifically, I wan to to make Gatling Gun have 2 range by default.

What I tried:
<GameData>
<Units>
<Update>
<Set Range="2" />
<Where Type="UNIT_GATLINGGUN" />
</Update>
</GameData>

- this does not work

<GameData>
<Units>
<Update>
<Set Range="3" />
<Where Type="UNIT_ARCHER" />
</Update>
</GameData>

- I did this as a test to see if my setup and logic are correct and it works.

<Delete Type="UNIT_GATLINGGUN" />

- does not work

<Delete Type="UNIT_ARCHER" />

- again, as a test: it works

What I noticed:
- the gatling gun unit is initially declared in the CIV5Units_Expansion2.xml
- there is another definition in CIV5Units_Inherited_Expansion2.xml but here the "Replace" tag is used.

What I tried again:
- I commented out the entire "replace" tag from CIV5Units_Inherited_Expansion2.xml and deleted the unit in my file (used the "delete type=" entry). This worked. I then tried to update the range to 2 and it did not work.
- I added a "Replace" tag in my mod file (copy-pasted from CIV5Units_Inherited_Expansion2.xml and changed the range to 2 in the process) and every other entry associated with the Gatling gun in that file and it still does not work.

It seems that the CIV5Units_Inherited_Expansion2.xml is loaded after my mod file, ignoring the changes I make to it in my mod file or something...

Any help would be appreciated.

Thanks!

Moderator Action: Moved to main C&C forum as that is where questions are best answered. Good luck. leif[/mod]
 
Last edited by a moderator:
UNIT_ARCHER is a Vanilla unit so is added to the game's database before any data from either of the two Expansions.
UNIT_GATLINGGUN was introduced by Gods and Kings.

BNW "Units" files
  • CIV5Units.xml is the Brave New World file where adjustments or deletions of Vanilla units are made for the Brave New World expansion.
  • CIV5Units_Inherited_Expansion2.xml is the Brave New World file where adjustments are made to the database for units that were first introduced into the game by Gods and Kings.
  • CIV5Units_Expansion2.xml is the Brave New World file where units new to Brave New World are defined.

"<Replace>" literally replaces any previous definition within the table that has a matching value for column <Type>. If your code is executing before the CIV5Units_Inherited_Expansion2.xml is executed, then any change you make to UNIT_GATLINGGUN will be over-written. "<Update>" would also fail in such a case because the changes made by the Update would be over-written as well. "<Delete>" will not accomplish anything in this condition because <Replace> is XML syntax for SQL's INSERT OR REPLACE INTO: if there is a matching <Type> within the table, that row is rewritten, but if there is not a matching row within the table, then a new row is added with the data given within the <Replace> syntax.

UNIT_GATLINGGUN is not contained anywhere within the file CIV5Units_Expansion2.xml.

In order to fix your problem you would have to make sure your changes are in a file that is listed farther down in the file "activations" list of the Expansion2.Civ5Pkg file. Otherwise you need to do it from a real mod, which will always load after all of the Expansions and DLC load their code into the game.

What you are running into is just one more of many reasons why it is generally not advised to alter the game's base files. You really can't ruin your game, but you may need to do a "verify integrity of game cache" if you goof up something badly -- though with the latest corruption of the Steam Interface I'm not at all sure where they moved that functionality.
 
I appreciate the quick and detailed reply. It is very instructive and makes sense.

I changed the position of the unit update xml file reference within the Expansion2.Civ5Pkg and it worked. I placed it specifically after the below tags:

<GameData>CIV5Units_Inherited_Expansion2.xml</GameData>
<GameData>CIV5Units_Expansion2.xml</GameData>

The only thing that I had to do different is instead of using an Update statement, I had to use the Replace statement. This worked like mentioned.

Again, thank you!
 
Hi, sorry to resurrect this post, but where does one find the "*****.Civ5Pkg files described above?
Surely they are not in the Assets\Gameplay \etc. path, I have not seen them. in the last two weeks that I came back to modding after a hiatus of over 10 to 12 years and boy am I rustier than a nail left by the seashore!! Thanks in advance.
 
Top Bottom