Starting Modding

gyogen2

Emperor
Joined
May 8, 2014
Messages
1,201
I've noticed there are some users on the forums who are new, or just unfamiliar with making a mod.

I though I'd start a post to offer basic information for them on how to start, as most posts I've seen assume you know the basics. I know I'm not the best modder here(by a long shot), but hoped I could offer some help, and maybe the masters out there could offer more.

This following is an example of creating a basic mod for simple changes:

Adding a new entry:
I will use adding a new starting unit as an example (since I just made a little mod to do so)

First:
Look at the original code, so you'll know what you'll need:

Code:
<MajorStartingUnits>
<Row Era="ERA_ANCIENT" Unit="UNIT_SETTLER"/>
<Row Era="ERA_ANCIENT" Unit="UNIT_WARRIOR" NotStartTile="true"/>

now we're going to add a scout as a starting unit.

There are two basic methods to do this,


SQL:
INSERT INTO MajorStartingUnits('Era', 'Unit', 'NotStartTile') VALUES ('ERA_ANCIENT', 'UNIT_SCOUT', 1);


XML:
<GameInfo>

    <MajorStartingUnits>
        <Row Era="ERA_ANCIENT" Unit="UNIT_SCOUT" NotStartTile="true"/>
    </MajorStartingUnits>

</GameInfo>

In both methods you are doing the same thing:
1. Selecting the Table you will me modifying - MajorStartingUnits
2. Inserting into it the varibles for the row - Era, Unit, and NotStartTile

This same basic format is used to add items into most any of the tables (Just need to make sure the variables are predefined, you cannot add a value to a column that doesn't exist, in that case, you would have to define the column.)

Update an already defined item:

Now,if instead of adding a new entry, we just wanted to undate an existing one, we would use the following format:

SQL:
UPDATE MajorStartingUnits SET Quantity=2  WHERE Era='ERA_ANCIENT' AND Unit='UNIT_SETTLER';

XML:
<GameInfo>
    <MajorStartingUnits>
        <Update>
        <Where Era="ERA_ANCIENT" Unit="UNIT_SETTLER"/>
            <Set Quantity="2"/>
        </Update>
    </MajorStartingUnits>
</GameInfo>

For either example above, you would then want to save the file as the corresponding type (sql or xml)

Creating a modinfo file:

There are plenty of exaples of modinfo files on the forum, so I won't go into great detail all you really need to know is:

Code:
<Mod id="[COLOR=#ff0000]64562d3d-1EG3-4Y79-A44A-052B589R42w[/COLOR]" version="1">  [COLOR=#ff0000]The mod id needs to be unique, if two mods have same id, one will not load.[/COLOR]
    <Properties>
        <Name>Mod Name</Name>
        <Description>What mod is</Description>
        <Authors>You</Authors>
    </Properties>
 
    <Files>
        <File>[COLOR=#0080ff]YourFile.xml/sql[/COLOR]</File> [COLOR=#0080ff]The file(s)included in your mod[/COLOR]
    </Files>
 
    <Components>
        <UpdateDatabase id="Mod Component"> can just be name of mod
            <Items>
                <File>[COLOR=#00b359]YourFile.xml/sql[/COLOR]</File> t[COLOR=#00b359]he file(s)in your mod again (this is where they are loaded into the game database)[/COLOR]
            </Items>
        </UpdateDatabase>
    </Components>
</Mod>

There are other feilds that can be entered in the modinfo, but there are just the basics to get a simple mod to run.

As you progress, you'll probably start making more complex mods, but most will rely on this basic format. If you wish to change/add things that are more than a line, or have more than one entry, just use a text editor such as notepad++, and search the files for all related instances, and make sure you make matching entries.

This is just a very simple intro into civ modding. There are many more, much better modders than me on the forums who can offer much better help, I just wanted to start a thread
for those who are just begining and not sure how to start.

If I have neglected a similar post already up, let me know and I'll remove.
Also Please do correct any mistakes, or info I neglected.
 
Last edited:
Double like! I wish this was up a few days ago when I started trying to edit some of the files!! :)
 
sql does not use true or false, and xml "true" is parsed into '1' in the database via the xml-to-sql parser, so for the sql examples it is probably better to show 1 and 0 rather than strings of "true" or "false" in sql since I am not 100% sure
Code:
INSERT INTO MajorStartingUnits('Era', 'Unit', 'NotStartTile') VALUES ('ERA_ANCIENT', 'UNIT_SCOUT', 'true');
will not have the 'true' at the end interpretted as a text string rather than the '1' that will be needed in the database.


and oh, as you may not have noticed, the forum no longer lets us highlight or otherwise format portions of code (except for spacing) inside a code-block. You just get [color=fff00000123] and [/color] at the ends of the stuff you wanted to highlight.
 
I've noticed there are some users on the forums who are new, or just unfamiliar with making a mod.

I though I'd start a post to offer basic information for them on how to start, as most posts I've seen assume you know the basics. I know I'm not the best modder here(by a long shot), but hoped I could offer some help, and maybe the masters out there could offer more.
tries.

SNIP

This is just a very simple intro into civ modding. There are many more, much better modders than me on the forums who can offer much better help, I just wanted to start a thread
for those who are just begining and not sure how to start.

If I have neglected a similar post already up, let me know and I'll remove.
Also Please do correct any mistakes, or info I neglected.
Hello

I am attempting to modify the "Startunits" mod provided by Misplay and provided in the Change XML without modding thread (which spawned this thread), for the purpose of restricting the additional units to only one or a few civilizations. This would be my first attempt at anything like this, and so far I'm accomplishing zilch useful. Would anyone mind pointing me in the right direction?
 
I am trying to restrict the added starting units (for instance a scout and a second settler) to only a couple of civilizations, or perhaps just one. Sorry about the confusion....been a long week.
 
Last edited:
Okay, if you want to change the number of starting units, you would use Update.
If you want to do it by era, you would need an entry for each era and unit like so:

Spoiler Example :
Code:
<GameInfo>
    <MajorStartingUnits>
        <Update>
        <Where Era="ERA_ANCIENT" Unit="UNIT_SETTLER"/>
            <Set Quantity="1"/>
        </Update>
 
        <Update>
        <Where Era="ERA_ANCIENT" Unit="UNIT_SCOUT"/>
            <Set Quantity="1"/>
        </Update>
    </MajorStartingUnits>

</GameInfo>

If you want to effect all eras, then you would do it as follows, with an entry for each unit:

Code:
<GameInfo>
    <MajorStartingUnits>
        <Update>
        <Where Unit="UNIT_SETTLER"/>
            <Set Quantity="1"/>
        </Update>
    </MajorStartingUnits>
</GameInfo>

Now if you meant you wanted specific civs to have different number of starting units, I am not sure if you can with xml/sql, It is not a setting I have seen, but I could have missed.
I do have a starting unit script someone had requested to give player some more units, if that's what you are looking for, I could modify it for specific civs.
 
Thanks for this, I was playing around with mods last night and wondering why it wasn't working. I just need to update a row instead of doing a new one!
 
Okay, if you want to change the number of starting units, you would use Update.
If you want to do it by era, you would need an entry for each era and unit like so:

Spoiler Example :
Code:
<GameInfo>
    <MajorStartingUnits>
        <Update>
        <Where Era="ERA_ANCIENT" Unit="UNIT_SETTLER"/>
            <Set Quantity="1"/>
        </Update>
 
        <Update>
        <Where Era="ERA_ANCIENT" Unit="UNIT_SCOUT"/>
            <Set Quantity="1"/>
        </Update>
    </MajorStartingUnits>

</GameInfo>

If you want to effect all eras, then you would do it as follows, with an entry for each unit:

Code:
<GameInfo>
    <MajorStartingUnits>
        <Update>
        <Where Unit="UNIT_SETTLER"/>
            <Set Quantity="1"/>
        </Update>
    </MajorStartingUnits>
</GameInfo>

Now if you meant you wanted specific civs to have different number of starting units, I am not sure if you can with xml/sql, It is not a setting I have seen, but I could have missed.
I do have a starting unit script someone had requested to give player some more units, if that's what you are looking for, I could modify it for specific civs.
Well, I was planning to begin with just myself/the player receiving extra units as America, Germany or Norway, then assuming that even worked, later add units for certain AI players to mess with early and mid game dynamics. Given that, and your observations about what is actually likely to be possible, your starting unit script modified for the aforementioned three civs sounds like the best bet, at least for now.
 
Back
Top Bottom