Please help a modding Noob

noto2

Emperor
Joined
Jul 11, 2008
Messages
1,715
I decided to start modding on my own, to make a civ balancing mod, but I have no idea how to get anything to work.

I've looked into the game's XML files and also the XML files of various mods, and I still don't understand what I'm doing wrong.

First question - if I'm making a mod to tweak civ traits, should I copy the trait XML file and change that? Or should I make a new XML file with the <update> commands?

Second question - maybe if someone could give me an example of how to do something I'm trying to do, I could figure out where I went wrong. Let's say I want to make Rome's trait the same as the Meritocracy bonus with city connections (+1 happiness for city connected to the capital). How would I do that? I tried taking the code from Meritocracy and copying/pasting into Rome's trait, while adding the column definition into the table, but it didn't work.
 
Have you read through Derek 'Kael' Paxton's guide to modding in Civ5 ? http://forums.civfanatics.com/showthread.php?t=385009

While many things are not up-to-date anymore it is still the seminal work on how in general modding works in Civ5.

----------------------------------------------------------------------------

Yes, you want to make <Updates> to existing data within the XML when you make a mod.

And, no, you cannot copy a column or group of columns from one game-table into another. Even if you add the definition for the column from gametable-A to gametable-B, all this does is create additional lines of inert text within the game's Database. This new column-name information has to be implemented by an lua script at the very least in order to instruct the game on what to do with this new information within the database for gametable-B.

----------------------------------------------------------------------------------

In XML you can create an entire new game-table, but you cannot alter an existing gametable to add new columns to it. Altering an existing gametable can only be done using the SQL language. But in all cases where you alter an existing gametable or add a brand-new gametable, a minimum of an lua script is also required to impliment this new data.
 
Wow thank you for the quick response, and you just saved me a lot of time now that I know I can't play willy-nilly with the tables.
 
There is a mod called 'weak Civ AI mod'

In it, the civ traits are changed. There are only XML and SQL files. What I don't understand is the XML file changing traits changes abilities that are not in the original trait table. For example, he gave India a buff to worker productivity. How is this possible? I don't see an Lua script...

<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 4/5/2014 8:48:00 PM -->
<GameData>
<Traits>
<Update>
<Where Type="TRAIT_POPULATION_GROWTH"/>
<Set WorkerSpeedModifier="15" />
</Update>
</Traits>
</GameData>
 
Ah, so it is. It's a chore looking through everything since everything is split up between expansions and DLC packs :p
 
WorkerSpeedModifier is in fact part of the Traits table, it's just not used by any vanilla civs (IIRC it's used by some scenario-specific civs).
This!

UnitPromotions, Buildings, Traits, Units, Policies all seem to have columns defined that are never used anywhere or are used only in one or another of the Firaxis-made Scenarios, or were added to a table to support one of the DLC civs. Then again, there are a few columns that are orphaned leftovers from Civ4 that actually do not appear to do anything.

You have to look through the existing definitions of the tables to know what are and are not valid columns for any given table. G&K added some columns as I recall, and BNW adds some more columns to many of the 'primary' tables.

Ah, so it is. It's a chore looking through everything since everything is split up between expansions and DLC packs :p
Generally the table definitions are only contained within the file within XML-folders for the expansion packs and not within the folders for the add-on DLC. (by add-on DLC I mean either the Scenarios or the added civs you get from having the Inca & Spain DLC).
  1. Vanilla files are at:
    C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization V\assets\Gameplay\XML
  2. G&K files are at:
    C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization V\assets\DLC\Expansion\Gameplay\XML
  3. BNW files are at:
    C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization V\assets\DLC\Expansion2\Gameplay\XML
The beginning portion of your file path might be slightly different depending on whether you have Win7, Win10, etc. (I have Win8.1)

If you have BNW, don't spend a whole lot of time looking through the stuff in the G&K and Vanilla folders, for example.
 
It's a chore looking through everything since everything is split up between expansions and DLC packs :p

Just look directly in the (combined) database then - see here
 
So I've been able to go into other peoples' mods and change things, and get it to work, but so far using Modbuddy I can't get my mods to work.

I just made a simple mod for Carthage, using xml to override the harbor and give Carthage a special harbor (just called it a carthage harbor, I'll do the renaming and new art later) and tried to give it the hanse +5% production per trade route bonus. I also tried to delete the African elephant unit but none of this worked.

<GameData>
<Civilization_BuildingClassOverrides>
<Row>
<CivilizationType>CIVILIZATION_CARTHAGE</CivilizationType>

<BuildingClassType>BUILDINGCLASS_HARBOR</BuildingClassType>

<BuildingType>BUILDING_CARTHAGE_HARBOR</BuildingType>
</Row>
</Civilization_BuildingClassOverrides>
<Buildings>
<Row>
<Type>BUILDING_CARTHAGE_HARBOR</Type>
<BuildingClass>BUILDINGCLASS_HARBOR</BuildingClass>
<Cost>120</Cost>
<GoldMaintenance>2</GoldMaintenance>
<PrereqTech>TECH_COMPASS</PrereqTech>
<Help>TXT_KEY_BUILDING_HARBOR_HELP</Help>
<Description>TXT_KEY_BUILDING_HARBOR</Description>
<Civilopedia>TXT_KEY_BUILDING_HARBOR_PEDIA</Civilopedia>
<Strategy>TXT_KEY_BUILDING_HARBOR_STRATEGY</Strategy>
<ArtDefineTag>HARBOR</ArtDefineTag>
<Water>true</Water>
<MinAreaSize>10</MinAreaSize>
<ConquestProb>66</ConquestProb>
<HurryCostModifier>25</HurryCostModifier>
<ArtInfoEraVariation>true</ArtInfoEraVariation>
<DisplayPosition>16</DisplayPosition>
<AllowsWaterRoutes>true</AllowsWaterRoutes>
<TradeRouteSeaDistanceModifier>75</TradeRouteSeaDistanceModifier>
<TradeRouteSeaGoldBonus>125</TradeRouteSeaGoldBonus>
<IconAtlas>BW_ATLAS_1</IconAtlas>
<PortraitIndex>26</PortraitIndex>
<CityStateTradeRouteProductionModifier>5</CityStateTradeRouteProductionModifier>
<TradeRouteRecipientBonus>1</TradeRouteRecipientBonus>
<TradeRouteTargetBonus>1</TradeRouteTargetBonus>
</Row>
</Buildings>
<Traits>
<Update>
<Set FreeBuilding="NULL" />
<Where Type="TRAIT_PHOENICIAN_HERITAGE"/>
</Update>
<Update>
<Set NumTradeRoutesModifier="34"/>
<Where Type="TRAIT_PHOENICIAN_HERITAGE"/>
</Update>

</Traits>
<Units>
<Delete Type="UNIT_CARTHAGINIAN_FOREST_ELEPHANT"/>
</Units>
</GameData>


and the mod info file

<?xml version="1.0" encoding="utf-8"?>
<Mod id="8940bcd1-b2e6-4a8e-8545-e15f9f3467e9" version="1">
<Properties>
<Name>Cmod Carthage</Name>
<Stability>Alpha</Stability>
<Teaser>Cothon gives +5% production per CS trade route
Carthage gets +1/3 trade routes
Retains quintereme
loses war elephant
retain</Teaser>
<Description>Cothon gives +5% production per CS trade route
Carthage gets +1/3 trade routes
Retains quintereme
loses war elephant
retains mountain crossing ability</Description>
<Authors>connor</Authors>
<HideSetupGame>0</HideSetupGame>
<AffectsSavedGames>1</AffectsSavedGames>
<MinCompatibleSaveVersion>0</MinCompatibleSaveVersion>
<SupportsSinglePlayer>1</SupportsSinglePlayer>
<SupportsMultiplayer>1</SupportsMultiplayer>
<SupportsHotSeat>1</SupportsHotSeat>
<SupportsMac>1</SupportsMac>
<ReloadAudioSystem>0</ReloadAudioSystem>
<ReloadLandmarkSystem>0</ReloadLandmarkSystem>
<ReloadStrategicViewSystem>0</ReloadStrategicViewSystem>
<ReloadUnitSystem>0</ReloadUnitSystem>
</Properties>
<Dependencies />
<References />
<Blocks />
<Files>
<File md5="548F5122EE1E2462535B38A094314D5D" import="0">textcharthage.sql</File>
<File md5="5A25C00FD1DB65A0438ED8E98D0DB054" import="0">xml/carthage changes.xml</File>
</Files>
<Actions>
<OnModActivated>
<UpdateDatabase>xml/carthage changes.xml</UpdateDatabase>
<UpdateDatabase>textcharthage.sql</UpdateDatabase>
</OnModActivated>
</Actions>
</Mod>



Please tell me, what have I done wrong?
 
Walls of (unformatted) code are very hard to read (use the [ CODE ] tags to format it) but also mean we have make the mod up ourselves, much better to attach the built mod (see second link in my sig). But before you do that, enable logging (1st link in my sig) and see what errors you are getting, as a SINGLE error in the XML file will cause the ENTIRE file to be discarded
 
Code:
 Like this?

Again, thank you for the quick reply. I'll log and/or upload my mod next time I have a problem. I rebuilt this particular mod and got it to work, I'm not 100% sure why it failed the first time.

A quick question, when you delete a unit, such as

Code:
 <Units>
			<Delete Type="UNIT_CARTHAGINIAN_FOREST_ELEPHANT"/>
	</Units>

Must such a command be followed by

Code:
 <DeleteMissingReferences table="Units" column="Type"/>
??

I threw that last bit in the second time when I got it to work, I'm not entirely sure what it does.
 
A unit (or a building or a policy or a tech or a ...) is more than just an entry in the <Units> table, there are also entries in the Unit_Xyz tables and possibly tables such as Xyz_FreeUnits, which you should/must also remove. The <DeleteMissingReferences .../> tag does all that tidying for you (except for things like the TXT_KEY_ entries). It's good for Units and Buildings, but should be used with care for Policies, Techs, etc, as it can cascade into other tables, where you'd then need to delete missing refs from those tables.
 
Top Bottom