Help: Mod Not Working

HardRocker

Student.
Joined
Jun 26, 2009
Messages
385
Location
Washington, U.S.A.
Okay, so I am finally getting the basics of ModBuddy, and I decided to create a mod for myself that would increase the population of cities. It has always irked me when I look at the Demographics and see a population of, say, 20,000,000, because I have always wanted the populations to be in the hundreds of millions for each major civ, much like today in our world.

So I changed the Global Defines to allow cities to be founded closer, lowered base growth threshold for cities, decreased food eaten per citizen from 2 to 1, and decreased unhappiness per population from 1 to 0.75.

I was mainly doing this to see if it would work, but I see no actual change in-game. Nothing I changed in GlobalDefines.xml (GameRules1.xml with ModBuddy) shows or makes any difference in-game.

Are these unchangeable? If not, what am I doing wrong? :confused:

Spoiler XML I used in GameRules1.xml :
?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 4/8/2012 1:16:06 PM -->
<GameData>
<Defines>
<Update>
<Set Value="2"/>
<Where Name="MIN_CITY_RANGE"/>
</Update>
<Update>
<Set Value="8"/>
<Where Name="MIN_CIV_STARTING_DISTANCE"/>
</Update>
<Update>
<Set Value="1"/>
<Where Name="FOOD_CONSUMPTION_PER_POPULATION"/>
</Update>
<Update>
<Set Value="7"/>
<Where Name="CITY_GROWTH_MULTIPLIER"/>
</Update>
<Update>
<Set Value="0.75"/>
<Where Name="UNHAPPINESS_PER_POPULATION"/>
</Update>
<Update>
<Set Value="14"/>
<Where Name="BASE_CITY_GROWTH_THRESHOLD"/>
</Update>
</Defines>
</GameData>


EDIT: OH, and I changed Civ minimum starting distance, because I like a lot of CityStates in my games. idk if that's what made it not work
 
In XML modding, if any one part of a file is in error, the entire file is thrown out. This is why you should always check the log files, to find out WHY none of the things are working. But in the meantime, I can tell you an obvious one: you can't use a Float value for a variable defined as an Integer. In this case, that's UNHAPPINESS_PER_POPULATION. It's "1" in the default game. Not "1.0", it's "1", meaning an integer. That means you can't set it to 0.75 in a mod. (Yes, I know, the unhappiness-per-captured-population is 1.34, and THAT can be multiplied all you want. Doesn't change the fact that this particular value is an integer.)

There are a couple easy ways around that limitation, though. For instance, in the HandicapInfos file, it gives a happiness multiplier to the player depending on the difficulty level (with the value as a percentile, i.e. 100 means 1.0). So all you'd need to do is update all of those values to be 75% of their previous values; you can do that explicitly through XML Updates, or with a single SQL command. I've used this mechanism in my own mod, where each population adds 1.2 unhappiness.

On a more general note, if the only thing you don't like about the existing demographics are the numbers they use, then change THAT. What you're changing here involves a huge amount of different aspects of the game, so things will break in non-obvious ways for the AI if you're not very careful.
 
In XML modding, if any one part of a file is in error, the entire file is thrown out. This is why you should always check the log files, to find out WHY none of the things are working. But in the meantime, I can tell you an obvious one: you can't use a Float value for a variable defined as an Integer. In this case, that's UNHAPPINESS_PER_POPULATION. It's "1" in the default game. Not "1.0", it's "1", meaning an integer. That means you can't set it to 0.75 in a mod. (Yes, I know, the unhappiness-per-captured-population is 1.34, and THAT can be multiplied all you want. Doesn't change the fact that this particular value is an integer.)

There are a couple easy ways around that limitation, though. For instance, in the HandicapInfos file, it gives a happiness multiplier to the player depending on the difficulty level (with the value as a percentile, i.e. 100 means 1.0). So all you'd need to do is update all of those values to be 75% of their previous values; you can do that explicitly through XML Updates, or with a single SQL command. I've used this mechanism in my own mod, where each population adds 1.2 unhappiness.

On a more general note, if the only thing you don't like about the existing demographics are the numbers they use, then change THAT. What you're changing here involves a huge amount of different aspects of the game, so things will break in non-obvious ways for the AI if you're not very careful.

Thanks for the feedback, I am always looking for advice on CiV stuff from you guys, and you in particular have been a big help with all my questions. :goodjob:

I think I will change the handicap percentages, thanks for redirecting me! ;)
 
Ok, so another question concerning the handicaps, how would I change the percentages as a row rather than as a file? Meaning, how would I change:
Spoiler :
<PopulationUnhappinessMod>100</PopulationUnhappinessMod>

Into:
Spoiler :
<PopulationUnhappinessMod>75</PopulationUnhappinessMod>

Without putting all that messy stuff into a new file? Or is that the only way?

Really hope I wasn't too vague, I sometimes do that :blush:
 
Ok, so another question concerning the handicaps, how would I change the percentages as a row rather than as a file

It's pretty simple. In XML, you'd do this:
Code:
<GameData>
  <HandicapInfos>
    <Update>
      <Set PopulationUnhappinessMod="75"/>
      <Where Type="HANDICAP_PRINCE"/>
    </Update>
  </HandicapInfos>
</GameData>
and so on for the other handicaps.

This sort of change is actually much easier and more complete in SQL, where you can just write the entire thing as a single line:
UPDATE HandicapInfos SET PopulationUnhappinessMod = PopulationUnhappinessMod * 0.75
and that's it. It'd update the values for all handicap entries, including those added by any other mods you might be using at the same time. You load an SQL file the same way you do an XML (OnModActivate/UpdateDatabase).
 
OK, so I honestly don't know what I did this time. Not even the slightest clue.

This is the stuff that I used in the XML:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 4/8/2012 1:16:06 PM -->
<GameData>
	<Defines>
		<Update>
			<Where Name="MIN_CITY_RANGE"/>
			<Set>
				<Value>2</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="MIN_CIV_STARTING_DISTANCE"/>
			<Set>
				<Value>8</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="FOOD_CONSUMPTION_PER_POPULATION"/>
			<Set>
				<Value>1</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="CITY_GROWTH_MULTIPLIER"/>
			<Set>
				<Value>7</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="BASE_CITY_GROWTH_THRESHOLD"/>
			<Set>
				<Value>14</Value>
			</Set>
		</Update>
	</Defines>
	<HandicapInfos>
		<Update>
			<Set PopulationUnhappinessMod="30/>"
			<Where Type="HANDICAP_SETTLER"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="45/>"
			<Where Type="HANDICAP_CHIEFTAN"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="60/>"
			<Where Type="HANDICAP_WARLORD"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75/>"
			<Where Type="HANDICAP_PRINCE"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75/>"
			<Where Type="HANDICAP_KING"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75/>"
			<Where Type="HANDICAP_EMPEROR"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75/>"
			<Where Type="HANDICAP_IMMORTAL"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75/>"
			<Where Type="HANDICAP_DIETY"/>
		</Update>
	</HandicapInfos>
</GameData>
 
Your quotation marks are all messed up. Lines like
<Set PopulationUnhappinessMod="30/>"
need to be
<Set PopulationUnhappinessMod="30"/>

And again, check your logfiles first (Database.log and xml.log in this case) and it'll tell you exactly which line isn't working.
 
OK, so I fixed the quotation marks :blush: and I checked the logs, but this is what it says:

Code:
[683.923] **** Validating Game Database *****
[685.390] Performing Localization Checks
[685.390] Checking Tag Format...
[685.390] Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.
[685.405] Validating UnitGameplay
[685.405] Number of selection sounds doesn't match number of units.
[685.405] Validating Notifications
[685.405] **** VALIDATION FAILED *****
[685.405] Validation Took 1.474820 seconds
[685.967] **** Validating Prefetch Process *****
[685.967] **** Validation Success *****
[685.967] SetGlobalActionInfo
[685.967] 
-- SQLite Memory Statistics --
Memory Usage:
		[Cur]		[Max]
Malloc:		759448		2996432
PageCache:	4862		4982
LookAside:	1369		3202
Scratch:	0		1

Static Buffer Overflows:
		[TooLarge]	[NoSpace]
PageCache:	364240		2565376
Scratch:	0		0

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

Prepared Statements:
Current:		23
------------------------------

I didn't get anything useful from this, but maybe I am a noob.

This is what my current code looks like:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 4/8/2012 1:16:06 PM -->
<GameData>
	<Defines>
		<Update>
			<Where Name="MIN_CITY_RANGE"/>
			<Set>
				<Value>2</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="MIN_CIV_STARTING_DISTANCE"/>
			<Set>
				<Value>8</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="FOOD_CONSUMPTION_PER_POPULATION"/>
			<Set>
				<Value>1</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="CITY_GROWTH_MULTIPLIER"/>
			<Set>
				<Value>7</Value>
			</Set>
		</Update>
		<Update>
			<Where Name="BASE_CITY_GROWTH_THRESHOLD"/>
			<Set>
				<Value>14</Value>
			</Set>
		</Update>
	</Defines>
	<HandicapInfos>
		<Update>
			<Set PopulationUnhappinessMod="30"/>
			<Where Type="HANDICAP_SETTLER"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="45"/>
			<Where Type="HANDICAP_CHIEFTAN"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="60"/>
			<Where Type="HANDICAP_WARLORD"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75"/>
			<Where Type="HANDICAP_PRINCE"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75"/>
			<Where Type="HANDICAP_KING"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75"/>
			<Where Type="HANDICAP_EMPEROR"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75"/>
			<Where Type="HANDICAP_IMMORTAL"/>
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="75"/>
			<Where Type="HANDICAP_DIETY"/>
		</Update>
	</HandicapInfos>
</GameData>

I feel like I should be able to interpret this on my own, but I can't make sense of it :confused:
 
That's a normal logfile, i.e. what you'll see if you don't have any errors it can catch. So it SHOULD work, and when I cut and pasted your changes into my own mod, it DID work. So the error's on your end, probably a typo in your OnModActivated/UpdateDatabase command or something.

In general, this is why you should post your files (xml and .modinfo) as attachments to your post, instead of relying on the (code) environment; sometimes, the error isn't in your XML itself, and we'd have no way to catch that for you.
 
What do you think I need to do to fix the Database? Complete reinstall?

Because I can, but I would rather avoid it if I can...
 
What do you think I need to do to fix the Database? Complete reinstall?

No, I didn't say there's an error in the database. I said there's an error in your mod, and it's not an XML error. For instance, if the syntax on the UpdateDatabase command you use to load the XML was wrong, then your mod won't do anything even if the XML has no mistakes.

(And if you don't know what I mean by "UpdateDatabase", then that's the problem.)
 
Yes, that is the problem, then. :blush:

Okay, this one's easy then.

When you create a mod in ModBuddy, you have to go into the mod's Properties page. Easiest way to do that is to go to the right-hand side of the page, where it lists the various files, right-click on the very top item (the one with the mod's name), and select "Properties". This'll bring up a window with 5 vertical tabs: Mod Info, Custom Properties, Associations, Actions, and Content. This window is also the first one you'll see when you create a new mod, so it should be fairly familiar.

The important two for modding are the last two: Actions is used for XML and SQL, while Content is used for Lua. So go to the Actions tab.
Click "Add". The first part should say OnModActivated as a default; keep that. The second part should say UpdateDatabase as a default; keep that, too. (See? Easy.) For the third field, you need to type in the name of the XML file you want to load, including relative paths if you placed it inside a subdirectory of the mod. So in my mod, that third field might be something like "XML/GameInfo/CIV5GameOptions.xml". Remember that XML files do NOT have to follow any naming convention or directory structure; it's just more convenient for those of us who make huge mods to do it that way.

Do that OnModActivated/UpdateDatabase for EVERY GameData-modifying XML or SQL file. (You do NOT use it for XML that's not related to GameData, which mainly comes up if you're modifying the user interface.)

Build the mod, and run it. That's all it takes.

If you ever decide to add some Lua functionality to your mod, you do a similar process in the Content tab, except there the magic word (the thing you'll nearly always put into the first column) is InGameUIAddin.

The only remaining concept for new modders is VFS. That stands for "Virtual File System". Any file that isn't GameData and isn't Lua you've made yourself (i.e. the two things we added through the Actions and Content tabs, respectively) needs to have VFS set to "true", which you do by right-clicking on each file in ModBuddy and selecting "Properties", which'll bring up a small window with a few options, one of which is "Import into VFS". The default is False, so you need to set it to "true" for:
> Any graphical files you create (icon atlases, background images, wonder splash screens, etc.)
> Any non-GameData files that are intended to replace the file of the same name in the existing game (most often this means UI modding, but you also get it if you're adjusting things like unit models)
> Any non-executable Lua (which usually means if you make a "utility" Lua file containing lots of subroutines that are intended to be used by other Lua functions, where you'll want to use an Include statement).

Why do I bring VFS up? Because it's the only major change made to Civ5 modding after Kael wrote his modder's guide, so it's the single biggest hurdle new modders run into once they get past basic XML alterations.
 
Now I understand. My noobyness is slowly falling away :)

Thank you for your help, my mod is now fully functional, and while it may "break the AI in inobvious ways", this is'n't my primary concern at the moment. :goodjob:

HERE IT IS!!!
 

Attachments

Back
Top Bottom