How Do I Override GlobalDefines.xml Settings??

sir_kris

Chieftain
Joined
Dec 9, 2010
Messages
26
I just tried creating a mod that changes some of the settings specified in GlobalDefines.xml. Unfortunately, my first attempt had absolutely no effect. The mod installed fine and it was enabled, but none of the changes I specified in the mod took effect.

The mod is very simple, just a single xml file. Here are its contents:

<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 8/3/2011 6:39:18 PM -->
<GameData>

<Defines>
<Row Name="START_AREA_HAPPINESS_MULTIPLIER">
<Value>15</Value>
</Row>
<Row Name="HAPPINESS_PER_NATURAL_WONDER">
<Value>3</Value>
</Row>
<Row Name="HAPPINESS_PER_EXTRA_LUXURY">
<Value>0.25</Value>
</Row>
<Row Name="UNHAPPINESS_PER_POPULATION">
<Value>0.25</Value>
</Row>
<Row Name="UNHAPPINESS_PER_OCCUPIED_POPULATION">
<Value>2</Value>
</Row>
<Row Name="UNHAPPINESS_PER_CITY">
<Value>0.2</Value>
</Row>
<Row Name="UNHAPPINESS_PER_CAPTURED_CITY">
<Value>3</Value>
</Row>
<Row Name="UNHAPPY_GROWTH_PENALTY">
<Value>-50</Value>
</Row>
<Row Name="VERY_UNHAPPY_CANT_TRAIN_SETTLERS">
<Value>0</Value>
</Row>
<Row Name="VERY_UNHAPPY_THRESHOLD">
<Value>-30</Value>
</Row>
<Row Name="VERY_UNHAPPY_COMBAT_PENALTY">
<Value>-10</Value>
</Row>
<Row Name="VERY_UNHAPPY_PRODUCTION_PENALTY">
<Value>-15</Value>
</Row>
<Row Name="SUPER_UNHAPPY_THRESHOLD">
<Value>-100</Value>
</Row>
<Row Name="INITIAL_FREE_OUTSIDE_UNITS">
<Value>10</Value>
</Row>
<Row Name="UNIT_MAINTENANCE_GAME_MULTIPLIER">
<Value>16</Value>
</Row>
<Row Name="UNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR">
<Value>15</Value>
</Row>
</Defines>

</GameData>


And before you criticize the settings shown above, please keep in mind that none of these have been tested yet and will probably be tweaked.

Is it possible to change these settings in a mod, and if so, what am I doing wrong? I'm very new to this so I would appreciate any help that can be offered. Thanks!
 
Try using updates instead of whole new entries. Idk if what you have is supposed to work also, but I have always used updates for existing entries.

In case you are not sure how, here is a sample of a couple:

Code:
<GameData>
	<Defines>
		<Update>
			<Set Value="6"/>
			<Where Name="AI_ATTEMPT_RUSH_OVER_X_TURNS_TO_BUILD"/>
		</Update>
		<Update>
			<Set Value="3"/>
			<Where Name="AI_HOMELAND_GREAT_PERSON_TURNS_TO_WAIT"/>
		</Update>
	</Defines>
</GameData>
 
Try using updates instead of whole new entries. Idk if what you have is supposed to work also, but I have always used updates for existing entries.

In case you are not sure how, here is a sample of a couple:

Code:
<GameData>
	<Defines>
		<Update>
			<Set Value="6"/>
			<Where Name="AI_ATTEMPT_RUSH_OVER_X_TURNS_TO_BUILD"/>
		</Update>
		<Update>
			<Set Value="3"/>
			<Where Name="AI_HOMELAND_GREAT_PERSON_TURNS_TO_WAIT"/>
		</Update>
	</Defines>
</GameData>

I just tried your suggestion and was fairly convinced this would fix it. Unfortunately, it had no effect. I made sure I deleted the cache and everything, too. Thanks for trying, though!

Here's what the XML looks like now:

<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 8/3/2011 6:39:18 PM -->
<GameData>

<Defines>
<Update>
<Set Value="15" />
<Where Name="START_AREA_HAPPINESS_MULTIPLIER" />
</Update>
<Update>
<Set Value="3" />
<Where Name="HAPPINESS_PER_NATURAL_WONDER" />
</Update>
<Update>
<Set Value="0.25" />
<Where Name="HAPPINESS_PER_EXTRA_LUXURY" />
</Update>
<Update>
<Set Value="0.25" />
<Where Name="UNHAPPINESS_PER_POPULATION" />
</Update>
<Update>
<Set Value="2" />
<Where Name="UNHAPPINESS_PER_OCCUPIED_POPULATION" />
</Update>
<Update>
<Set Value="0.2" />
<Where Name="UNHAPPINESS_PER_CITY" />
</Update>
<Update>
<Set Value="3" />
<Where Name="UNHAPPINESS_PER_CAPTURED_CITY" />
</Update>
<Update>
<Set Value="-50" />
<Where Name="UNHAPPY_GROWTH_PENALTY" />
</Update>
<Update>
<Set Value="0" />
<Where Name="VERY_UNHAPPY_CANT_TRAIN_SETTLERS" />
</Update>
<Update>
<Set Value="-30" />
<Where Name="VERY_UNHAPPY_THRESHOLD" />
</Update>
<Update>
<Set Value="-10" />
<Where Name="VERY_UNHAPPY_COMBAT_PENALTY" />
</Update>
<Update>
<Set Value="-15" />
<Where Name="VERY_UNHAPPY_PRODUCTION_PENALTY" />
</Update>
<Update>
<Set Value="-100" />
<Where Name="SUPER_UNHAPPY_THRESHOLD" />
</Update>
<Update>
<Set Value="10" />
<Where Name="INITIAL_FREE_OUTSIDE_UNITS" />
</Update>
<Update>
<Set Value="16" />
<Where Name="UNIT_MAINTENANCE_GAME_MULTIPLIER" />
</Update>
<Update>
<Set Value="15" />
<Where Name="UNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR" />
</Update>
</Defines>

</GameData>


In case it helps, here's the modinfo file as well:

<?xml version="1.0" encoding="utf-8"?>
<Mod id="985aa255-58b6-4688-9124-52c3d06ac255" version="1">
<Properties>
<Name>Civilization V - Expansionist Mod</Name>
<Stability>Alpha</Stability>
<Teaser>This mod adjusts happiness and maintenance settings to make Civ 5 more playable for players who enjoy building a large empire t</Teaser>
<Description>This mod adjusts happiness and maintenance settings to make Civ 5 more playable for players who enjoy building a large empire to dominate the globe. Nothing else is changed by this mod.</Description>
<Authors>Kris Craig</Authors>
<SpecialThanks>Firaxis, for making Civ 5 a pain in the ass for anyone who wants more than a half dozen cities.</SpecialThanks>
<HideSetupGame>0</HideSetupGame>
<AffectsSavedGames>1</AffectsSavedGames>
<MinCompatibleSaveVersion>0</MinCompatibleSaveVersion>
<SupportsSinglePlayer>1</SupportsSinglePlayer>
<SupportsMultiplayer>1</SupportsMultiplayer>
<SupportsHotSeat>0</SupportsHotSeat>
<SupportsMac>1</SupportsMac>
<ReloadLandmarkSystem>0</ReloadLandmarkSystem>
<ReloadStrategicViewSystem>0</ReloadStrategicViewSystem>
<ReloadUnitSystem>0</ReloadUnitSystem>
</Properties>
<Dependencies />
<References />
<Blocks />
<Files>
<File md5="3FE1A52FA8F03C317FB09BF0304FCD87" import="0">Game Rules1.xml</File>
</Files>
</Mod>


These are the only 2 files in the mod. I'm at a complete loss here. I can't believe that those settings wouldn't be modifiable; that just wouldn't make any sense! What am I doing wrong?
 
Several mistakes.

First of all, you need the usual OnModActivated/UpdateDatabase for this. You don't have that in your .modinfo file, so of course nothing will work.

Second, you can't use a floating-point value where it's expecting an integer. UNHAPPINESS_PER_POPULATION, for instance, requires an integer. If you give it 0.25, it'll see that as zero. There's a trick to get a non-integer unhappiness where you tweak the unhappiness multipliers in some other file (like the HandicapInfos table), which is how I got it to do 1.2 unhappiness per population in my own mod, but it takes a lot more work.
You had several other variables with this same mistake, like HAPPINESS_PER_EXTRA_LUXURY. So chances are, you won't be able to do all of what you wanted.
 
Several mistakes.

First of all, you need the usual OnModActivated/UpdateDatabase for this. You don't have that in your .modinfo file, so of course nothing will work.

Second, you can't use a floating-point value where it's expecting an integer. UNHAPPINESS_PER_POPULATION, for instance, requires an integer. If you give it 0.25, it'll see that as zero. There's a trick to get a non-integer unhappiness where you tweak the unhappiness multipliers in some other file (like the HandicapInfos table), which is how I got it to do 1.2 unhappiness per population in my own mod, but it takes a lot more work.
You had several other variables with this same mistake, like HAPPINESS_PER_EXTRA_LUXURY. So chances are, you won't be able to do all of what you wanted.

Ahh ok, I was starting to think there might be something missing in the modinfo file. I'm not sure what OnModActivated and UpdateDatabase do or how to use them, but I'm sure a Google search will answer that for me.

As for the float vs int issue, yeah that really sucks. It would've been nice if they'd declared all those variables as floats for more flexible modding. But like you said I guess I can get around this by updating the HandicapInfos table. I'd read somewhere that the values in that table only apply to AI players though, which is why I didn't use it to begin with. I'm guessing that isn't true?

Thanks for your help! I have one more question. It looks like the HandicapInfos table values are also defined as integers. Can I get away with changing some of the definitions in CIV5HandicapInfos.xml from "integer" to "decimal" (I'm thinking via an "alter table" SQL query)? Or would that not work or cause something else to break?
 
Ugh ok, I just tried what you suggested and it's still not working. Obviously, I'm still getting something wrong. The mod is enabled and I always clear the cache before a new attempt. None of the changes to the game rules are taking effect.

Here's the updated modinfo file:

<?xml version="1.0" encoding="utf-8"?>
<Mod id="985aa255-58b6-4688-9124-52c3d06ac255" version="1">
<Properties>
<Name>Civilization V - Expansionist Mod</Name>
<Stability>Alpha</Stability>
<Teaser>This mod adjusts happiness and maintenance settings to make Civ 5 more playable for players who enjoy building a large empire t</Teaser>
<Description>This mod adjusts happiness and maintenance settings to make Civ 5 more playable for players who enjoy building a large empire to dominate the globe. Nothing else is changed by this mod.</Description>
<Authors>Kris Craig</Authors>
<SpecialThanks>Firaxis, for making Civ 5 a pain in the ass for anyone who wants more than a half dozen cities.</SpecialThanks>
<HideSetupGame>0</HideSetupGame>
<AffectsSavedGames>1</AffectsSavedGames>
<MinCompatibleSaveVersion>0</MinCompatibleSaveVersion>
<SupportsSinglePlayer>1</SupportsSinglePlayer>
<SupportsMultiplayer>1</SupportsMultiplayer>
<SupportsHotSeat>0</SupportsHotSeat>
<SupportsMac>1</SupportsMac>
<ReloadLandmarkSystem>0</ReloadLandmarkSystem>
<ReloadStrategicViewSystem>0</ReloadStrategicViewSystem>
<ReloadUnitSystem>0</ReloadUnitSystem>
</Properties>
<Actions>
<OnModActivated>
<UpdateDatabase>GameRules1.xml</UpdateDatabase>
<UpdateDatabase>GameRules1.sql</UpdateDatabase>
</OnModActivated>
</Actions>
<Dependencies />
<References />
<Blocks />
<Files>
<File md5="523D4C7B2BEC85441790B5F539600BB3" import="0">Game Rules1.sql</File>
<File md5="7B3A0EADF6A90041D1C945BCD2117EFC" import="0">Game Rules1.xml</File>
</Files>
</Mod>


Here's the updated XML file:

<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 8/3/2011 6:39:18 PM -->
<GameData>

<Defines>
<Update>
<Set Value="15" />
<Where Name="START_AREA_HAPPINESS_MULTIPLIER" />
</Update>
<Update>
<Set Value="3" />
<Where Name="HAPPINESS_PER_NATURAL_WONDER" />
</Update>
<Update>
<Set Value="1" />
<Where Name="HAPPINESS_PER_EXTRA_LUXURY" />
</Update>
<Update>
<Set Value="1" />
<Where Name="UNHAPPINESS_PER_POPULATION" />
</Update>
<Update>
<Set Value="2" />
<Where Name="UNHAPPINESS_PER_OCCUPIED_POPULATION" />
</Update>
<Update>
<Set Value="1" />
<Where Name="UNHAPPINESS_PER_CITY" />
</Update>
<Update>
<Set Value="3" />
<Where Name="UNHAPPINESS_PER_CAPTURED_CITY" />
</Update>
<Update>
<Set Value="-50" />
<Where Name="UNHAPPY_GROWTH_PENALTY" />
</Update>
<Update>
<Set Value="0" />
<Where Name="VERY_UNHAPPY_CANT_TRAIN_SETTLERS" />
</Update>
<Update>
<Set Value="-30" />
<Where Name="VERY_UNHAPPY_THRESHOLD" />
</Update>
<Update>
<Set Value="-10" />
<Where Name="VERY_UNHAPPY_COMBAT_PENALTY" />
</Update>
<Update>
<Set Value="-15" />
<Where Name="VERY_UNHAPPY_PRODUCTION_PENALTY" />
</Update>
<Update>
<Set Value="-100" />
<Where Name="SUPER_UNHAPPY_THRESHOLD" />
</Update>
<Update>
<Set Value="10" />
<Where Name="INITIAL_FREE_OUTSIDE_UNITS" />
</Update>
<Update>
<Set Value="16" />
<Where Name="UNIT_MAINTENANCE_GAME_MULTIPLIER" />
</Update>
<Update>
<Set Value="15" />
<Where Name="UNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR" />
</Update>
</Defines>

</GameData>


And here's the SQL file that I added:

update HandicapInfos set NumCitiesUnhappinessMod = ROUND( NumCitiesUnhappinessMod / 10, 0 );
update HandicapInfos set PopulationUnhappinessMod = ROUND( PopulationUnhappinessMod / 10, 0 );
update HandicapInfos set HappinessDefault = ROUND( HappinessDefault * 1.5, 0 );
update HandicapInfos set UnitCostPercent = ROUND( UnitCostPercent / 2, 0 );


The update queries lack a where clause so they should be applied to all difficulty levels. The rounding should prevent any decimal issues with the int columns. But none of this is taking effect! What am I still missing??
 
Ahh ok, I was starting to think there might be something missing in the modinfo file. I'm not sure what OnModActivated and UpdateDatabase do or how to use them, but I'm sure a Google search will answer that for me.

While Google IS the "font of all knowledge", there's no need for that. Go download Kael's beginner's modders guide, over in the References section. There's a sticky for it. It explains that inside.

Short version: for any GameData XML or SQL to work, you need to go into the Actions tab for your mod and type the following (and it's case-sensitive):
First column: OnModActivated
Second column: UpdateDatabase
Third column: the filename, including any directory names inside the main mod directory. So if you created an XML subdirectory to store all your XML changes, then you'd type "XML/Bob.xml" or whatever.

That's it. Basically, for GameData structures you use that command, for newly-made Lua you go into the Content tab and declare an InGameUIAddin entry, and for everything else you use VFS=true.

Thanks for your help! I have one more question. It looks like the HandicapInfos table values are also defined as integers. Can I get away with changing some of the definitions in CIV5HandicapInfos.xml from "integer" to "decimal" (I'm thinking via an "alter table" SQL query)? Or would that not work or cause something else to break?

No, you can't change definitions, as far as I know. While SQL would probably allow you to do something like that, I'm sure it'd break all of the existing entries. But there's no need; while the HandicapInfos tables are also integers, they're PERCENT integers. That is, a value of 100 means to scale things by 1.00. So changing the UnhappinessMod-type variables from (60, 75, and 100) to (72, 90, and 120) effectively multiplies all population unhappiness by a factor of 1.2. This is why I said it'd take some work; you'd have to do an Update for each entry in that table, OR add an SQL multiplier.

Any variable that has "Mod" or "Modifier" in its name works this way, by determining the percentage by which the base value is modified. So even though they're stored as integers, it's basically the same as using a decimal.
 
While Google IS the "font of all knowledge", there's no need for that. Go download Kael's beginner's modders guide, over in the References section. There's a sticky for it. It explains that inside.

Short version: for any GameData XML or SQL to work, you need to go into the Actions tab for your mod and type the following (and it's case-sensitive):
First column: OnModActivated
Second column: UpdateDatabase
Third column: the filename, including any directory names inside the main mod directory. So if you created an XML subdirectory to store all your XML changes, then you'd type "XML/Bob.xml" or whatever.

That's it. Basically, for GameData structures you use that command, for newly-made Lua you go into the Content tab and declare an InGameUIAddin entry, and for everything else you use VFS=true.



No, you can't change definitions, as far as I know. While SQL would probably allow you to do something like that, I'm sure it'd break all of the existing entries. But there's no need; while the HandicapInfos tables are also integers, they're PERCENT integers. That is, a value of 100 means to scale things by 1.00. So changing the UnhappinessMod-type variables from (60, 75, and 100) to (72, 90, and 120) effectively multiplies all population unhappiness by a factor of 1.2. This is why I said it'd take some work; you'd have to do an Update for each entry in that table, OR add an SQL multiplier.

Any variable that has "Mod" or "Modifier" in its name works this way, by determining the percentage by which the base value is modified. So even though they're stored as integers, it's basically the same as using a decimal.

Yeah I realized the percentages part once I took a closer look at the HandicapInfos.xml file, so that's cool.

The only thing I can think of is I'd added the onmodload/updatedatabase tags to the file manually instead of using Mod Buddy. I just did it in Mod Buddy now and am gonna see if that fixes it.
 
But none of this is taking effect! What am I still missing??

Well, let's try the obvious questions:

1> What do your logfiles say? Specifically the xml.log file should tell you exactly what you did wrong, assuming you remembered to turn on log files in the first place.
2> An XML file will fail if any command in it is invalid. So the usual way to debug this, if the logfiles don't say anything, is to either comment out half the file and see if it starts working, or split the XML commands into multiple files so that a failure on one won't cause all to stop working. Have you tried that sort of debugging? Or even try just using the XML without the SQL, or vice versa?
3> Are you remembering to actually enable the mod in the Browse Mods menu, and then setting up a new game within that Mods menu instead of going back to the main menu?
4> Are you creating a new game to test this, or are you trying to load an older game? (Older games won't work for any mod that has the "Affects Saved Games" flag turned on, which you do.)
 
Well, let's try the obvious questions:

1> What do your logfiles say? Specifically the xml.log file should tell you exactly what you did wrong, assuming you remembered to turn on log files in the first place.

I didn't even know there were log files. Where would I enable this?

2> An XML file will fail if any command in it is invalid. So the usual way to debug this, if the logfiles don't say anything, is to either comment out half the file and see if it starts working, or split the XML commands into multiple files so that a failure on one won't cause all to stop working. Have you tried that sort of debugging? Or even try just using the XML without the SQL, or vice versa?

If I had access to a log file, then I could debug it no problemo (I am an experienced programmer, after all). I'll try to find where the logging settings are located, as that will no doubt prove very helpful.

3> Are you remembering to actually enable the mod in the Browse Mods menu, and then setting up a new game within that Mods menu instead of going back to the main menu?

Yes. I'm also deleting the contents of the "cache" and "ModUserData" directories before starting the game each time, just to be safe.

4> Are you creating a new game to test this, or are you trying to load an older game? (Older games won't work for any mod that has the "Affects Saved Games" flag turned on, which you do.)

I'm creating a new game every time, using identical settings each time to minimize any possible variables between tests. I used to work as an SDET at Microsoft so I'm fairly well acquainted with best test practices. =)
 
Lucky me, it looks like it's already enabled. Here's the contents of xml.log:

[520980.580] **** Validating Game Database *****
[520981.625] Performing Localization Checks
[520981.625] Checking Tag Format...
[520981.625] Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.
[520981.640] Validating UnitGameplay
[520981.640] Number of selection sounds doesn't match number of units.
[520981.640] Validating Notifications
[520981.640] **** VALIDATION FAILED *****
[520981.640] Validation Took 1.051070 seconds
[520982.093] **** Validating Prefetch Process *****
[520982.093] **** Validation Success *****
[520982.093] SetGlobalActionInfo
[520982.093]
-- SQLite Memory Statistics --
Memory Usage:
[Cur] [Max]
Malloc: 284392 3476296
PageCache: 2909 4982
LookAside: 45 1864
Scratch: 0 1

Static Buffer Overflows:
[TooLarge] [NoSpace]
PageCache: 0 3097200
Scratch: 0 0

Largest Allocations:
Malloc: 65280
PageCache: 1160
Scratch: 6640

Prepared Statements:
Current: 5
------------------------------


Would that note about tags be the problem? Either that, or the verification failure for notifications? Thing is, I don't think I changed either one of those things, so I'm not sure how there can be a causation. Any ideas?
 
[520980.580] **** Validating Game Database *****
[520981.625] Performing Localization Checks
[520981.625] Checking Tag Format...
[520981.625] Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.
[520981.640] Validating UnitGameplay
[520981.640] Number of selection sounds doesn't match number of units.
[520981.640] Validating Notifications
[520981.640] **** VALIDATION FAILED *****
[520981.640] Validation Took 1.051070 seconds
[520982.093] **** Validating Prefetch Process *****
[520982.093] **** Validation Success *****
[520982.093] SetGlobalActionInfo

Ignore this. This is the default block of errors, because the vanilla game's database has a few issues. So it didn't catch anything.

And I wasn't doubting your testing ability, it's just that we've been burned far too many times by people who DON'T do these things and then ask for help.

So now we go to the brute-force debugging. Go into your XML file and put a comment block around half of it. That is, use a
<!--
at the start of the area to be commented, and a
-->
at the end.

Then try it again. If it works, then you know the uncommented half has no major errors in it; uncomment a few more entries and try again. But if it doesn't work, then there must be at least one error in the half that's uncommented, so move the other way and comment out more.

But before you do this, try just disabling the SQL entirely, or the XML entirely (which you can do by removing the OnModActivated command). See if either of those solve it.
 
Ignore this. This is the default block of errors, because the vanilla game's database has a few issues. So it didn't catch anything.

And I wasn't doubting your testing ability, it's just that we've been burned far too many times by people who DON'T do these things and then ask for help.

So now we go to the brute-force debugging. Go into your XML file and put a comment block around half of it. That is, use a
<!--
at the start of the area to be commented, and a
-->
at the end.

Then try it again. If it works, then you know the uncommented half has no major errors in it; uncomment a few more entries and try again. But if it doesn't work, then there must be at least one error in the half that's uncommented, so move the other way and comment out more.

But before you do this, try just disabling the SQL entirely, or the XML entirely (which you can do by removing the OnModActivated command). See if either of those solve it.

Alrighty, thanks! I'll dig into it and let ya know what I find.
 
Back
Top Bottom