Some basic Civ5 Modding questions

primem0ver

Emperor
Joined
Jun 16, 2006
Messages
1,158
Location
Peoria, AZ
I bought Civ V when it first came out and did not like it at all because of the limitations in modding and the fact that it requires steam. I cannot stand steam and that is the number 1 reason why I avoided Civ V like the plague. Now however I am forced to have steam because of the game Skyrim so I decided to come back and check on Civ V modding.

It looks like modding have evolved considerably since this game was first released. The SDK has been released as well. I am assuming this means that the source code can be modified. So here are some basic questions and some things I have noticed that I would like feedback on.

  1. Can the Civ V source code be modified?
  2. If so, how flexible is that modification? Is it anywhere near as modifiable as Civ IV was?
  3. Has anyone worked on a mod that allows cities to be built on or under water? Would such a mod be possible in Civ V?
  4. I have no interest in Civ V if terrains and terrain features cannot be added because I am working on an engine that produces realistic terrains that include biome classification. I have read that no one has added terrains because of limitations that exist or problems that it creates. What are these limitations/problems?
  5. How does the hex grid work in terms of cardinal directions? Is there a way to look up which hex corresponds to a specific longitude and latitude?
  6. I remember a lot of talk about lack of unit stacks in Civ V before the game was released. Are unit stacks allowed in Civ V? If not, can this rule be modified using the source code?
 
  1. Can the Civ V source code be modified?
  2. If so, how flexible is that modification? Is it anywhere near as modifiable as Civ IV was?
  3. Has anyone worked on a mod that allows cities to be built on or under water? Would such a mod be possible in Civ V?
  4. I have no interest in Civ V if terrains and terrain features cannot be added because I am working on an engine that produces realistic terrains that include biome classification. I have read that no one has added terrains because of limitations that exist or problems that it creates. What are these limitations/problems?
  5. How does the hex grid work in terms of cardinal directions? Is there a way to look up which hex corresponds to a specific longitude and latitude?
  6. I remember a lot of talk about lack of unit stacks in Civ V before the game was released. Are unit stacks allowed in Civ V? If not, can this rule be modified using the source code?

1) Yes
2) Have not edited the Civ IV dll enough to answer that in depth, but the short answer is generally "no, it is not as modder friendly".
3) It is possible, but irregularities may occur with the interaction with other game mechanics.
4) The graphics engine source code is not released to the public, only the game engine source code.
5) Plenty of iterative examples in both the Lua and C++ code, such as:
Code:
for(iDX = -(iRange); iDX <= iRange; iDX++)
		{
			for(iDY = -(iRange); iDY <= iRange; iDY++)
			{
				pLoopPlot = plotXYWithRangeCheck(pPlot->getX(), pPlot->getY(), iDX, iDY, iRange);

				if(pLoopPlot != NULL)
				{
					if(pLoopPlot->isCity())
					{
						if(pLoopPlot->getLandmass() == pPlot->getLandmass())
						{
							return false;
						}
						else if(hexDistance(iDX, iDY) < iRange)  // one less for off shore
						{
							return false;
						}
					}
				}
			}
		}

However, the game engine simply expresses/stores the co-ordinates of each plot in [X|Y] format if you're not doing any sort of iteration/path-finding with it.
6) You may modify the maximum number of units per stack using PLOT_UNIT_LIMIT in GlobalDefines.xml; however do note that in order to stack your civilians under another player's units (you can freely stack them under your own), you will need to change the source code in the DLL (don't remember off the top of my head where, but it's controlled by a single if statement)
 
Thanks for your feedback. I wasn't clear if any of these answered question #4. Right now that is the most important question. Here is the thread that sparked this question. Here is another thread that asks a similar question and no one has answered it.

All terrain texture mods seem to be replacements for current textures and not new terrains. Adding terrains in Civ IV was fairly easy to do. What problems does it introduce in Civ V as suggested by the answer to the question in first thread above?

EDIT: Another question I have is that mods are NOT supposed to be exclusive. In other words you can have multiple mods running at the same time (the delete tag allows this). How does that work with SDK mods? Can only one SDK mod run at the same time or is there some mechanism that allows more than one dll mod to run?
 
Thanks for your feedback. I wasn't clear if any of these answered question #4. Right now that is the most important question. Here is the thread that sparked this question. Here is another thread that asks a similar question and no one has answered it.

All terrain texture mods seem to be replacements for current textures and not new terrains. Adding terrains in Civ IV was fairly easy to do. What problems does it introduce in Civ V as suggested by the answer to the question in first thread above?

EDIT: Another question I have is that mods are NOT supposed to be exclusive. In other words you can have multiple mods running at the same time (the delete tag allows this). How does that work with SDK mods? Can only one SDK mod run at the same time or is there some mechanism that allows more than one dll mod to run?

My apologies, I've edited & enumerated the points for you now.

The mod-exclusivity works like this (let's assume there's only 2 mods in the mix, to keep things simple, shall we?):

- Only 1 .DLL mod may be "active", in the sense that the mod loaded last will have it's DLL be the one active. There is no work-around to this, sorry. You seem to have some Computer Science experience, so I will presume that you should already know why this is.
- Mods modifying a copy of an existing core Lua file (for example: "FeatureGenerator.lua") have the same issue - only the one loaded last will have its changes apply (for that particular file)
- Mods containing XML & SQL files of the (exact) same name will also run into issues, although I do not remember them off the top of my head.

What you seek to do may or may not be possible, if you can figure out how to get them into the game; you will have to experiment yourself to see what works and what doesn't. Please refer to this thread for a guideline of current modding limitations.


[*]No access to graphics dll. Related:
  • Can't update terrain graphics in-game (e.g., you can't terraform hills to flat, water to land, etc.).
[*]No access to UI dll. Related:
  • Don't have "Get" methods for all of the different Controls we can "Set"
 
4) The graphics engine source code is not released to the public, only the game engine source code.

...

[*]No access to graphics dll. Related:

Can't update terrain graphics in-game (e.g., you can't terraform hills to flat, water to land, etc.).

I think there is a misunderstanding over what I mean by "terrain" and adding terrains because these statements don't seem relevant to what I mean.

Like what is said above for Civ5, in Civ4 terrain graphics could not be updated in game. They could only be changed in the world builder/editor (such as changing hills to flat etc...). Does the same apply to the Civ5 world builder/editor?

I am not trying to "add" or change terrains in game (other than in the world builder). What I want to be able to do is add different terrain types like "plains" and "grass".

Right now we have these basic "flat" terrains as well as an equivalent for hill terrains:
tundra,
snow,
plains,
grass,
desert

I would like to be able to add things like:
steppe (barren rock),
chaparral,
savannah,
mud,
barren desert,
dunes,
forest floor,
jungle floor, (in reality the jungle floor does NOT have the same food value as grass or plains),
and possibly one more.

All of the ones I add would have different base values for food, work, and money as well as a different graphic.

In addition I would like to add the following features:
mixed forest (both deciduous and coniferous trees)
tall grass,
arid foliage,
burnt forest
 
As for question 3, there's this mod.

Thanks for the tip.

EDIT: Another question for you all. Is Civ V up to date in terms of computing? Is it multi-threaded using multiple cores, and possibly even memory beyond 2GB?
 
Thanks for the tip.

EDIT: Another question for you all. Is Civ V up to date in terms of computing? Is it multi-threaded using multiple cores, and possibly even memory beyond 2GB?

A lot of it isn't MT'ed (hence the ridiculously long wait times on map generation, and during the later stages of the game when waiting on other players)
 
Like what is said above for Civ5, in Civ4 terrain graphics could not be updated in game. They could only be changed in the world builder/editor (such as changing hills to flat etc...). Does the same apply to the Civ5 world builder/editor?

I am not trying to "add" or change terrains in game (other than in the world builder). What I want to be able to do is add different terrain types like "plains" and "grass".

- Wasn't there some tsunami-event mod for Civ 4 that changed a coastal-land tile into water? My memory is hazy about that though.

- Oh, you can probably get new terrain into the game without much issue (provided you find out how to).... you just have a LOT of work for yourself to do beyond just importing the textures & graphics into the game ....

You will need to re-write large portions of TerrainGenerator.lua (and possibly individual map scripts), as well as AssignStartingPlots.lua if you want:
a) your terrain to ever appear in your games
b) if you want resources to spawn on your terrain
c) if you want the map to be balanced & take into account the yield values for your new terrains when determining start positions, as well as region creation
d) a few other factors I probably forgot to mention

- Features can be added in a fairly straightforward manner iirc; you will need to apply changes to FeatureGenerator.lua to make them spawn, as well as AssignStartingPlots.lua (again :lol:) to have the rest of the resource distribution, start locations, and regional/map-balance systems interact with it.
 
Thing to bear in mind is that WorldBuilder is not accessed nor accessible in-game. The closest thing available is DonQuiche's In-Game Editor mod. It allows you to alter terrain in-game (add a grasslands tile where there was ocean, for example) but does not update all graphics until save and game re-load. This is not a limitation with the mod, it is Firaxis limitation.

DonQuiche is no longer actively modding, however, and I think the only thing he has 'comitted' himself to do is to keep the IGE up-to-date with regard patches and updates to the game.

The essential differences between CIV4 and CIV5 (as I understand it, I never modded CIV4) is that
  1. CIV5 allows in practical terms an unlimited number of mods to run concurrently. My understanding was that CIV4 only ever allowed one mod at a time.
  2. CIV5 is an Update, Add, or Replace system whereas I think CIV4 was a Replace system.
By Update, Add, or Replace System I mean
  • To Update (change) something that Firaxis provided in CIV5 you only change the one or two lines of XML code needed when altering the XML, and you do so using an <Update> to something within an existing <Row> within a game-table. You do not include the entire file-full set of commands from the same file: you only include your 5 or 6 lines of code to change the Firaxis code you are interested in. Nor do you need to concern yourself with matching-up to the FileName as used by Firaxis when you are doing an XML <Update>, or its equivalent code-syntax if you choose to work directly in SQL.
    • This is all I need in XML to make Pikeman upgrade to Musketman units instead of the usual upgrade to a Lancer:
      Code:
      <GameData>
      	<Unit_ClassUpgrades>
      		<Update>
      			<Set UnitClassType="UNITCLASS_MUSKETMAN"/>
      			<Where UnitType="UNIT_PIKEMAN"/>
      		</Update>
      	</Unit_ClassUpgrades>
      </GameData>
    • I can place that code in a file called "Hamburgers.xml", and so long as I give ModBuddy the proper instructions for how to use "Hamburgers.xml" the game will accept and use the code-change.
  • To Add something new to the game, you just add it and it alone. You do not need to "paste-it-in" to the rest of the code for Buildings, and present that entire file of the original code along with your additions, for example.
  • By Replace I mean that there are some specific types of things that must be changed by Importing to the game's VFS a new version of an existing file. Thorzhammerz mentioned this in regard to the DLL and some of the lua files such as AssignStartingPlots.lua
  • With lua, you can create new functions and run them concurrent to any other mod also adding new lua and concurrent to the original ones supplied by Firaxis (more or less).
    • I say more or less wrt the Firaxis-made ones because the majority of the lua code provided by Firaxis is of the core-game-file type, and these types of files have to be replaced with a changed version of the file having the same file name, and with the changed file set for Import Into the Games VFS system.
The real negatives as I understand it for comparison of CIV5 with CIV4 is the horrific difficulty of creating new unit animations for CIV5, where for CIV4 I understand it was much easier, and that the source code for the CIV5 graphic engine has never been made public so it is deuced difficult for folks to figure out how to add a lot of terrain-related stuff that would make the game much more fun and interesting.
 
Hello LeeS. Thank you for your insight. Does the WorldBuilder application look at the xml for mods to make sure new terrains are usable?

ThorHammerz, I am not really worried about the mapscripts. The engine I am creating will take a map created by the mapscript BEFORE starting locations are determined and modify it based on a significant algorithm that will take some time to run. I am only concerned with the games ability to use new terrain types. The point is to run a ocean current, wind, and climate simulator to create realistic landscapes with true biomes based on the Koppen climate system. Tile yields and placed resources will also be realistic in terms of what would be available from those biomes.

I started this engine a few years ago and then needed a break from it. During that break I started playing Skyrim and got sidetracked for a couple of years. However, I will not give up on creating the simulator because it is a life goal of mine. I have recently started working on it again. I created a thread regarding the engine on civfanatics when I started working on it. That thread can be found here.

My basic reason for starting this thread is to determine whether i want to target my engine and mod changes to/into a Civ 4 mod or a Civ 5 mod.
 
Anything that is in the game's SQL database from the last session of running the game will be used by worldbuilder so long as you go direct from in-game and exit directly to desktop rather than returning to main game menu. If you return to the main game-menu before exiting the game, code added by mods is dumped.


I don't know if that applies also to anything added by lua replacement files or by custom dll files.
 
Top Bottom