How do I edit basic .xml files?

need my speed

Rex Omnium Imperarium
Joined
Oct 3, 2009
Messages
2,494
Location
European Union (Magna Batavia)
I have been running into an odd series of problems with Civilization VI. In my very first game, when I founded Rome, it contained a Monument - per the unique ability - and all the great people worked fine as well. Then, great people began working worse and worse, until no merchant, scientist, or engineer worked at all. The game tells me their ability is activated, but nothing happens. Mere moments ago, I started a new game as Rome - and there was no Monument in my capital.

This might be because I modded the game all the while, for I just reinstalled the game, and at least as far as Trajan's Monument is concerned, that worked. But the moment I copied over my modded files, it ceased to work - and when I installed it again, I took the above picture; it worked again.

So, how do I actually mod this game? Using the 'Slower Tech' mod, in the proper /Mods folder, works perfectly fine. But editing the .xml files in the game's installation directory apparently causes the game to end up with all kinds of odd bugs. So how would I go about modding this game the proper way?

I have attached the .xml files I have modified, and I have further added the 'Slower Tech' mod, if they need to be integrated - if they don't, then that might be ignored - and I would like to know how I go about turning these .xml files into a proper mod.

Thank you in advance. :)
 

Attachments

  • Assets.rar
    72.6 KB · Views: 80
  • SlowerTech.rar
    1.2 KB · Views: 62
make backup copy of every file you edit, and try every major edit in game. Make notes about what you did last, use notpad++ to see what line you edited so you do not have to search for it too much if you need to repair it, or change edit. And be sure that you know what are you doing so your mods are not full of bugs.
 
I have been modding Civilization IV for years. I am 99% sure my files contain no errors, but you are free to check them out, of course - I would be grateful if you could find any errors.

I would still like to know how to convert all the files - that I just keep into the main directory of the game - into a proper mod.
 
that 1% is the bug you have right now. maybe you misspelled something... in code way, not in language grammar way. I do not have tools atm to compare your files with vanila files and to find all edits.
You can try with online tool if you want.
https://www.diffchecker.com/diff
 
You might be right. But I do not see what I would gain by comparing all my files to the vanilla files - that is a very useful website though! More to the point, .xml files aren't magic. I never edited any file that mentions great people, yet they stopped working. I never edited any file that mentions civilisations, leaders, or their bonuses, yet Trajan's monument didn't spawn. I suspect this is because I am not modding the game as one is supposed to do, by using the /Mods folder. So I'd like to try that out before doing anything else. But I don't know how. Can you help me with that?
 
Last edited:
Well, I am not new to modding - I have been at it for more than a decade - but it is kind of you to try to help people, then. So thank you, and there is no need at all to be sorry for trying to help! Good luck with your own modding. :)
 
you will need a "modname.modinfo" file as instructed here:
Spoiler big quote :

The organization of that file has changed a bit, here is what I've noted so far...

Here is an example:

HTML:
<Mod id="11111111-1111-1111-1111-111111111111" version="1">
    <Properties>
        <Name>Name of your mod</Name>
        <Teaser>Short Description</Teaser>
        <Description>LOC_DESCRIPTION</Description>
        <Authors>Your name goes here</Authors>
        <SpecialThanks>My name goes here :)</SpecialThanks>
    </Properties>
    <Components>
        <UpdateDatabase>
            <Property>
                <RuleSet>YOUR_RULESET</RuleSet>    
            </Property>
            <Items>
                <File>YourRulesChange.xml</File>
                <File>YourRulesChange.sql</File>
            </Items>
        </UpdateDatabase>
        <GameplayScripts>
            <Property>
                <RuleSet>YOUR_RULESET</RuleSet>    
            </Property>
            <Items>
                <File>YourGameplayScripts.Lua</File>
            </Items>
        </GameplayScripts>
        <ImportFiles>
            <Items>
                <File>YourImportedFile</File>
            </Items>
        </ImportFiles>
        <LocalizedText id="YOUR_TEXT">
            <Properties>
                <RuleSet>YOUR_RULESET</RuleSet>
            </Properties>
            <Items>
                <File>YourModTexts_Text.xml</File>
            </Items>
        </LocalizedText>
    </Components>
    <Settings>
        <Custom id="YOUR_SETTING">
            <Items>
                <File>YourConfig.xml</File>
            </Items>
        </Custom>
       <Map>
           <Properties>
               <Name>Your Map Name</Name>
               <Description>Your Map Description</Description>
           </Properties>
           <Items>
               <File>YourMap.Civ6Map</File>
           </Items>
       </Map>
        <LocalizedText id="YOUR_SETTING">
            <Items>
                <File>YourTextsRelatedToSettings_Text.xml</File>
            </Items>
        </LocalizedText>
    </Settings>
    <LocalizedText>
        <Text id="LOC_DESCRIPTION">
            <en_US>Long Description of your mod</en_US>
        </Text>
    </LocalizedText>
    <Files>
        <File>YourRulesChange.xml</File>
        <File>YourRulesChange.sql</File>
        <File>YourGameplayScripts.Lua</File>
        <File>YourModTexts_Text.xml</File>
        <File>YourConfig.xml</File>
        <File>YourTextsRelatedToSettings_Text.xml</File>
        <File>YourImportedFile</File>
        <File>YourMap.Civ6Map</File>
    </Files>
</Mod>

the Mod id must be unique, you can generate one (like for civ5) with a GUID generator, if two mods are installed with the same Mod id, one will be ignored.

Under <Components> you can use those tags:
  • UpdateDatabase
  • LocalizedText
  • ImportFiles (like a map script)
  • GameplayScripts
  • UserInterface
  • Custom
Under <Settings> you can use those tags
  • Map
  • Custom
  • LocalizedText
There is also a <ModArt> tag that I have no idea how to use.

The setting section is used to update the DebugConfiguration.sqlite DB that can be found in ..\Documents\my games\Sid Meier's Civilization VI\Cache

The <UpdateDatabase> tag used in <Components> update the DebugGameplay.sqlite DB

AFAIK <RuleSet> is not required, but without it your mod will be activated by default, the use of a rule set may allow some... things I guess... maybe compatibility between mods.

Ask your questions here, I may not have the answers, but I hope some people have or that we'll find them by testing and testing and testing (I've done a lot to get that, and also a bit of search for strings in the game's files)

after you have a modinfo file for your mod, you can start work on the sql, lua and xml files.
i suggest you use
Code:
<Replace>
    <Row></Row>
</Replace> 
or
<Update>
    <Where />
    <Set></Set>
</Update>
rather than the straight up
Code:
<Row></Row>
 
Right, I found that... So I need to find all the changes I made, in all the files, and put all the lines I changed between the <Replace> or <Update> tags?

... How could anyone claim Civilization IV is not by far the easiest game to mod?
 
if you for example only changed housing on the neighborhood district, you do something like this:
Code:
<Districts>
    <Update>
        <Where DistrictType="DISTRICT_NEIGHBORHOOD" />
        <Set Housing="8" />
    </Update>
</Districts>

if you change more than 1 thing on a thing, you do same thing but change the set housing tag to something like this:
Code:
<Set>
    <Housing>8</Housing>
    <Appeal>1</Appeal>
</Set>

however... if you change all of the things or nearly all the things, just copy the whole row tag from the original into the mod xml within a replace tag within the right building/district/whatever tag, make the changes
 
Alright. Using Ivan's site is really handy for this - thank you again Ivan!

... But I'm afraid I am utterly lost. I truly do not understand this.

Could you perhaps show me this by example, by, for example, integrating the Slower Tech component, the Warmongerer component, and the Civics.xml file? Because I honestly don't understand the first thing of this.

I've messed around to create this, to integrate only the above three files:

Code:
<Mod id="19df33ad-510e-48e8-bc64-dc573d6a21cb>
    <Properties>
        <Name>My Mod</Name>
        <Teaser>My Mod</Teaser>
        <Description>My Mod</Description>
        <Authors>need my speed / nlspeed</Authors>
        <SpecialThanks>Myself</SpecialThanks>
    </Properties>
    <Files>
        <File>Rules.sql</File>
        <File>Warmonger.xml</File>
        <File>Civics.xml</File>
    </Files>  
    <Settings>
        <Custom id="SlowerTech">
            <Items>
                <Component>SlowerTechComponent</Component>
            </Items>
        </Custom>
    </Settings>   
    <Components>
        <UpdateDatabase id="SlowerTechComponent">
            <Properties>
                <Name>My Mod</Name>
            </Properties>
            <Items>
                <File>Rules.sql</File>
            </Items>
        </UpdateDatabase>
        <UpdateDatabase id="MARK_WARMONGER_GAMEPLAY_DATA">
            <Items>
                <File>Warmonger.xml</File>
            </Items>
        </UpdateDatabase>
        <UpdateDatabase id="Civics">
            <Items>
                <File>Civics.xml</File>
            </Items>
        </UpdateDatabase>
    </Components>
</Mod>

But I have no clue whether this is correct, for it looks way too complicated and makes no sense to me. <Files> lists the relevant files, but these files are files that tell other files how to update themselves. <Settings>, <Components>, <UpdateDatabase>... Why? What is all that? Why would I want that? I simply want to use my own files, why must this be so confusing. I just don't understand what I'm doing.

Moving on... The Slower Tech thing is a .sql file that looks like this:

Code:
/*
    Slower Tech by Era
    by Gedemon (2016)
    original idea and code by alpaca
*/


-----------------------------------------------
-- Technology cost
-----------------------------------------------

UPDATE Technologies SET Cost = Cost*2    WHERE EraType ='ERA_ANCIENT'; -- just for reference
UPDATE Technologies SET Cost = Cost*3 WHERE EraType ='ERA_CLASSICAL';
UPDATE Technologies SET Cost = Cost*3    WHERE EraType ='ERA_MEDIEVAL';
UPDATE Technologies SET Cost = Cost*3    WHERE EraType ='ERA_RENAISSANCE';
UPDATE Technologies SET Cost = Cost*3    WHERE EraType ='ERA_INDUSTRIAL';
UPDATE Technologies SET Cost = Cost*3    WHERE EraType ='ERA_MODERN';
UPDATE Technologies SET Cost = Cost*3    WHERE EraType ='ERA_ATOMIC';
UPDATE Technologies SET Cost = Cost*3    WHERE EraType ='ERA_INFORMATION';

UPDATE Civics SET Cost = Cost*2    WHERE EraType ='ERA_ANCIENT'; -- just for reference
UPDATE Civics SET Cost = Cost*3    WHERE EraType ='ERA_CLASSICAL';
UPDATE Civics SET Cost = Cost*3    WHERE EraType ='ERA_MEDIEVAL';
UPDATE Civics SET Cost = Cost*3    WHERE EraType ='ERA_RENAISSANCE';
UPDATE Civics SET Cost = Cost*3    WHERE EraType ='ERA_INDUSTRIAL';
UPDATE Civics SET Cost = Cost*3    WHERE EraType ='ERA_MODERN';
UPDATE Civics SET Cost = Cost*3    WHERE EraType ='ERA_ATOMIC';
UPDATE Civics SET Cost = Cost*3    WHERE EraType ='ERA_INFORMATION';

Whereas the Warmonger thing is a .xml file that, as such, looks completely different. Why is there a .sql and a .xml file?

Code:
<GameInfo>
    <Eras>
        <Update>
            <Where EraType="ERA_ANCIENT"/>
            <Set WarmongerPoints="0"/>
        </Update>

        <Update>
            <Where EraType="ERA_CLASSICAL"/>
            <Set WarmongerPoints="2"/>
        </Update>

        <Update>
            <Where EraType="ERA_MEDIEVAL"/>
            <Set WarmongerPoints="4"/>
        </Update>

        <Update>
            <Where EraType="ERA_RENAISSANCE"/>
            <Set WarmongerPoints="6"/>
        </Update>

        <Update>
            <Where EraType="ERA_INDUSTRIAL"/>
            <Set WarmongerPoints="8"/>
        </Update>

        <Update>
            <Where EraType="ERA_MODERN"/>
            <Set WarmongerPoints="10"/>
        </Update>

        <Update>
            <Where EraType="ERA_ATOMIC"/>
            <Set WarmongerPoints="10"/>
        </Update>

        <Update>
            <Where EraType="ERA_INFORMATION"/>
            <Set WarmongerPoints="10"/>
        </Update>
    </Eras>
</GameInfo>

And so what do I do to change the Civics.xml file in the main directory? The only thing I have changed there is the Eureka boost for all civics: http://i.imgur.com/OmeqL7u.png

But I have zero clue how to even begin doing this...
 
I am an old Civ 4 modder as well. For Civ 6 I've taken the leap to modding mostly in SQL. The advantage of SQL is you can generally isolate errors better because usually if a line is broken the error is contained to that one line, vs XML where the whole file goes. In particular its useful because you can perform calculations.

The reason there is a SQL file in your above example is likely that the modder just wanted to update every single entry in the table with new values using a calculation (he's multiplying the values to increase them). I dont know why s/he used XML for the second file. It could have been in SQL as well. Maybe he just had the XML version already handy.

That said, there are times when XML can be handy, because XML "looks" similar to the XML data in the existing game files, which can sometimes potentially make it easier to figure out how to structure something. Particularly useful when adding something new to the game like a civ or unit. Altho there's an argument for SQL there too (mostly the ability to isolate errors, as just described).
 
I do believe I understand how this works now... It is extremely tedious and absolutely user-unfriendly, mind. But the tiny things I did to experiment worked.

Changed coastal and ocean yields: http://i.imgur.com/k5FMU3s.jpg
Changed Harbour district buildings yields (well, I'm only showing the Seaport - I should have probably simply deleted the row instead of updating it to provide +0 gold): http://i.imgur.com/XKk1GY9.jpg

This is a very useful source.
 
Top Bottom