Does a mod overwrite the entire node or just the elements inside a node?

How are mod values applied to the defaults?  Does a modded value overwrite the entire element or just the attribute/node under the element?

Example:
Say I want to add the ability to raze a city almost right away, rather than after learning Fortifications as is it currently set. 

The Fortifications TechDef contains the following modifier, which enables razing of a city.

<GameModifier>
  <ModType>Player</ModType>
  <Attribute>UnlockCityAction</Attribute>
  <StrVal>Raze</StrVal>
</GameModifier>

For the purposes of this example, I want to attach the Raze ability to the Equipment TechDef  (I guess a torch is now included in the equipment pile). 

So I take a copy of the Techs_Amarian.xml file, place it in the mods directory, and tell the program to use the mods directory.  Then I delete everything except the TechDef for Equipment from the copy so that the basic tech tree is going to be used for everything except this one item.  Finally I add the highlighted lines to the TechDef (the description and AIData is snipped for brevity).  This is the complete file at this point.

<?xml version="1.0" encoding="utf-8"?>
<Techs>
  <TechDef InternalName="Equipment_Amarian">
    <DisplayName>Equipment</DisplayName>
    <Description>...</Description>
    <Image>Weapons_Medallion_Full.png</Image>
    <Color>182,7,3</Color>
    <HotColor>255,48,0</HotColor>
    <Rarity>100</Rarity>
    <Category>Warfare</Category>
    <Infinite>0</Infinite>
    <AppearanceChance>100</AppearanceChance>
    <AIData AIPersonality="AI_General">...</AIData>
 
    <GameModifier>
      <ModType>Player</ModType>
      <Attribute>UnlockCityAction</Attribute>
      <StrVal>Raze</StrVal>
    </GameModifier>

  </TechDef>
</Techs>

Now I would expect this to work, since the "Equipment_Amarian" TechDef has been completely changed, I will overwrite all attributes regardless of how they load the XML files.  However, this is not optimal for me, since if StarDock changes something in the basic tech description (the image, colors, AIPersonality, etc) I would have to update my mod as well or else I would miss out on their changes.  So I would rather have the file look like this, so it only changes exactly what I want to change.  (Yes, I should change the Description to explain this change to the user, but ignore that for now)

<?xml version="1.0" encoding="utf-8"?>
<Techs>
  <TechDef InternalName="Equipment_Amarian">
    <GameModifier>
      <ModType>Player</ModType>
      <Attribute>UnlockCityAction</Attribute>
      <StrVal>Raze</StrVal>
    </GameModifier>
  </TechDef>
</Techs>

Would this work?  Would it add the new game modifier onto the existing base TechDef or would I end up with a TechDef that makes bad things happen since it doesn't have a DisplayName anymore, or an Image file?  I'm guessing this won't work, but it would take an understanding of how the XML files are loaded and parsed to be sure.

TIA

-Sal

5,239 views 8 replies
Reply #1 Top

See this:

Quoting Annatar11, reply 2
If you're changing the core files, I believe you have to delete the data.zip file (binary data that the game uses so it loads faster), and then run the game with /createxmlbinary so it re-creates it with your changes. They should show up, then.
End of Annatar11's quote

I had the SAME problem as you. Did a similar thing with the RAZE city option, modified how armors and weapons researched, and how quickly Adventure levels monsters; all working now.

Good luck!

P.S. Yes, you can modify just ONE element of a XML file. You don't need to do everything. I appreciate that Stardock :)

Reply #2 Top

Quoting James009D, reply 1
See this:


Quoting Annatar11, reply 2If you're changing the core files, I believe you have to delete the data.zip file (binary data that the game uses so it loads faster), and then run the game with /createxmlbinary so it re-creates it with your changes. They should show up, then.

End of James009D's quote

 

Does that mean we are not officially meant to mod the core files? This method does not seem to gel with Stardock's idea of easy mod sharing and uploading if everyone has to recreate the data.zip with each new mod they use.

Reply #3 Top

You can mod it, you're just not supposed to do it IN those files.

@Salizar I believe you have to do it the hard way, unfortunately.

Reply #4 Top

Don't modify core files because they'll get replaced during a patch. They do this to increase loadtime... at some modder expense but a lot of us in beta thought it would be best.

You can mod whatever you want, tbh. Just make your own files in doing so.

Reply #5 Top

Quoting Heavenfall, reply 3
@Salizar I believe you have to do it the hard way, unfortunately.
End of Heavenfall's quote

Yeah, my testing on the weekend seems to indicate that as well.  Doing a partial xml node caused very wierd results, and the odd CTD.  I'm sure it was nothing I did though...  :D

Reply #6 Top

We've discovered that some of the coreXML files are essentially broken. Do not rebuild the data.zip using /createxmlbinary .

Because of this things like tech mods are going to be a little more complex then we anticipated until Stardock fixes it and allows mods to overwrite core data.

Reply #7 Top

Hmm, perhaps that is why the mod I was playing around with on the weekend where I added one tech & changed the description of 2 others, and added a couple new weapons sort of worked.  The techs showed up in the right place, and two of the three techs had the right description, but the third still had the old description.  And I could create units with the newly created weapons, but I couldn't find one in a store to buy for my sov.

Reply #8 Top

Hmmm, double check the code before the third tech, maybe there is a coding error causing the description not to be read. Descriptions are easy to update and shouldnt be any trouble.

The problem with techs that I mention was really referring to changing the tech tree. For example, I'm trying to seperate armor and weapons into separate categories but it requires me to override the original tech pre. reqs first. No idea how that can be done.

New weapons, techs, and descriptions should be fine though.