• Civilization 7 has been announced. For more info please check the forum here .

Help Modding

Oukselo

Chieftain
Joined
May 21, 2012
Messages
6
Location
Montreal
Hi, This is my first time modding and I've run into trouble. I'm using the beginner's guide by Kael along with Moddbuddy but I'm having trouble adding a unit to the game.

My Goal is to create a Song of Ice and Fire mod and the first step is to make a House of Stark Civ. I'm trying to create a special unit for them called "Clansman", It's in the swordsman class but uses Barbarian art. Similar to the way Kael uses Barbarian art in his guide for his new unit.

When I try to play as House Stark there is no Clansman in the game at all, nor is there a swordsman. If I'm right it means that my definition of a clansman isn't being understood by the game. I've ticked off Reload Unit System and I've set all the files associated with new units to "import VFS" true. I'm stumped and could use some help.

Here's my definition of a Clansman
Spoiler :
GameData>
<Units>
<Row>
<Class>UNITCLASS_SWORDSMAN</Class>
<Type>UNIT_CLANSMEN</Type>
<PrereqTech>TECH_IRON_WORKING</PrereqTech>
<Combat>11</Combat>
<Cost>75</Cost>
<Moves>2</Moves>
<HurryCostModifier>20</HurryCostModifier>
<CombatClass>UNITCOMBAT_MELEE</CombatClass>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_CLANSMEN</Description>
<Civilopedia>TXT_KEY_CIV5_ANTIQUITY_SWORDSMAN_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_SWORDSMAN_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_CLANSMEN</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<ObsoleteTech>TECH_GUNPOWDER</ObsoleteTech>
<GoodyHutUpgradeUnitClass>UNITCLASS_LONGSWORDSMAN</GoodyHutUpgradeUnitClass>
<AdvancedStartCost>20</AdvancedStartCost>
<WorkRate>100</WorkRate>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<Conscription>1</Conscription>
<UnitArtInfo>ART_DEF_UNIT_CLANSMEN</UnitArtInfo>
<UnitFlagIconOffset>3</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_1</IconAtlas>
<PortraitIndex>25</PortraitIndex>
<MoveRate>HEAVY_BIPED</MoveRate>
</Row>
</Units>
<Unit_FreePromotions>
<Row>
<UnitType>UNIT_CLANSMEN</UnitType>
<PromotionType>PROMOTION_IGNORE_TERRAIN_COST</PromotionType>
<LostWithUpgrade>true</LostWithUpgrade>
</Row>
</Unit_FreePromotions>
<Unit_AITypes>
<Row>
<UnitType>UNIT_CLANSMEN</UnitType>
<UnitType>UNITAI_ATTACK</UnitType>
</Row>
<Row>
<UnitType>UNIT_CLANSMEN</UnitType>
<UnitType>UNITAI_DEFENSE</UnitType>
</Row>
<Row>
<UnitType>UNIT_CLANSMEN</UnitType>
<UnitType>UNITAI_EXPLORE</UnitType>
</Row>
</Unit_AITypes>
<Unit_ClassUpgrades>
<Row>
<UnitType>UNIT_CLANSMEN</UnitType>
<UnitClassType>UNITCLASS_LONGSWORDSMAN</UnitClassType>
</Row>
</Unit_ClassUpgrades>
<Unit_Flavors>
<Row>
<UnitType>UNIT_CLANSMAN</UnitType>
<FlavorType>FLAVOR_RECON</FlavorType>
<Flavor>3</Flavor>
</Row>
<Row>
<UnitType>UNIT_CLANSMAN</UnitType>
<FlavorType>FLAVOR_OFFENSE</FlavorType>
<Flavor>6</Flavor>
</Row>
<Row>
<UnitType>UNIT_CLANSMAN</UnitType>
<FlavorType>FLAVOR_DEFENSE</FlavorType>
<Flavor>6</Flavor>
</Row>
</Unit_Flavors>
</GameData>


And here's my Unit Art Infos
Spoiler :
<UnitArtInfos>
<UnitArtInfo>
<Type>ART_DEF_UNIT_BARBARIAN_EURO</Type>
<Formation>Barbarian</Formation>
<DamageStates>1</DamageStates>
<UnitMemberArt>
<MemberType>ART_DEF_UNIT_MEMBER_BARBARIAN_EURO_ALPHA</MemberType>
<MemberCount>6</MemberCount>
</UnitMemberArt>
<UnitMemberArt>
<MemberType>ART_DEF_UNIT_MEMBER_BARBARIAN_EURO_BRAVO</MemberType>
<MemberCount>2</MemberCount>
</UnitMemberArt>
<UnitMemberArt>
<MemberType>ART_DEF_UNIT_MEMBER_BARBARIAN_EURO_CHARLIE</MemberType>
<MemberCount>2</MemberCount>
</UnitMemberArt>
</UnitArtInfo>

<UnitArtInfo>
<Type>ART_DEF_UNIT_CLANSMAN</Type>
<Formation>LooseCivilian</Formation>
<DamageStates>1</DamageStates>
<UnitMemberArt>
<MemberType>ART_DEF_UNIT_MEMBER_BARBARIAN_EURO_ALPHA</MemberType>
<MemberCount>2</MemberCount>
</UnitMemberArt>
<UnitMemberArt>
<MemberType>ART_DEF_UNIT_MEMBER_BARBARIAN_EURO_BRAVO</MemberType>
<MemberCount>6</MemberCount>
</UnitMemberArt>
<UnitMemberArt>
<MemberType>ART_DEF_UNIT_MEMBER_BARBARIAN_EURO_CHARLIE</MemberType>
<MemberCount>2</MemberCount>
</UnitMemberArt>
</UnitArtInfo>
</UnitArtInfos>
 
First of all, you should check your log files first. That's what they're for. Specifically, xml.log and Database.log will tell you exactly what's wrong. You have to enable logging first, but you should be doing that anyway if you're doing any sort of modding.

Now, looking at the specifics, take this part:
Code:
<Unit_FreePromotions>
  <Row>
    <UnitType>UNIT_CLANSMEN</UnitType>
    <PromotionType>PROMOTION_IGNORE_TERRAIN_COST</PromotionType>
    <LostWithUpgrade>true</LostWithUpgrade>
 </Row>
</Unit_FreePromotions>

The Unit_FreePromotions table doesn't have the LostWithUpgrade flag; that's inside the UnitPromotions table. So this is invalid, and would fail. Let's go back to the rules of XML modding:
1> If a table doesn't already have a variable X, then you can't assign variable X no matter how obvious you think the connection should be. That is, just because Buildings can give promotions, that by no means allows Projects to give promotions. Or, in your case, just because the Promotions table has a LostWithUpgrade entry doesn't mean that other promotion-related tables can accept one.
2> If one line fails, the whole file fails. This is usually a good reason to split your XML up into multiple files, since it makes it much more easy to track down the cause of an issue in those few situations where the logs don't say anything.
3> Logfiles are your friend for XML modding, and FireTuner is essential for Lua. Without these tools, you're wasting a tremendous amount of time trying to find problems.

Also, when you're posting XML code, use the (CODE) environment to preserve spacing (except use brackets instead of parentheses). What you posted is just a mess, very hard to read because of its lack of indentation.

Now, one other thing. The Art Infos you posted: I'm assuming those are being added to the end of the existing unitartinfos files, because I'm sure you know that art definitions, unlike GameData, do NOT use the <Update> syntax. You have to replace the core game's file in its entirety.
 
Spatzimaus already pointed out the that LostWithUpgrade won't work in Unit_FreePromotions.

The other possible issues I can see is your GoodyHutUpgradeUnitClass is currently "UNITCLASS_LONGSWORDSMA N", that may just be a copy paste issue but if not you probably intended not to have that additional space.

Did you also add a row in Civilization_UnitClassOverrides?
 
Ok so my inexperience is very obvious and my mod is rife with errors. Thanks for the help I really appreciate it, I've made the following changes:
1. I removed the <LostWithUpgrade>true</LostWithUpgrade> line
2. I did not have the entire ArtInfos files from the game. So I extracted it from the game with nexus then copy/pasted the file into the mod and added my art info at the end
3.My Civilization_UnitClassOverrides referred to a CLANSMAN when it should be CLANSMEN

But despite all this my problem persists. I tried to use the DataBase.log when I first started my mod but it never said anything so I ignored it. I didn't realize you have to enable logging Where do I do that? It would really help me figure this out myself.
 
I didn't realize you have to enable logging Where do I do that? It would really help me figure this out myself.

Go into your user directory; on Windows 7, that's My Games/Sid Meier's Civilization V/. This is the directory where the actual mods get installed, etc., and the Logs directory is inside here, so since you said you've already looked at the logs then I'm sure you know where this is. Look for the file config.ini in that user directory. Open it in Notepad or something similar.

Right up at the top will be EnableTuner. Set that to 1. This is needed to use FireTuner, which is essential for a lot of debugging purposes, especially once you get into Lua modding.

About two-thirds of the way down the file will be LoggingEnabled. Set that to 1. This is the one that matters for your current issues.

Near LoggingEnabled will be a cluster of other variables with "Logging" in the name. Set whichever ones look interesting to 1; if all you're doing is basic XML modding then you can leave these all turned off.
 
That's much better, now I can track down all my typos. I'm still having two problems:

First, my units all appear as Spearmen which I think has to do with one error I can't figure out:
Code:
[11533.372] Database::XMLSerializer (XML/Units/UnitArtDefines.xml): 'Row' or 'Delete' expected, got 'Type'.
I thought you didn't need any <Row> in a UnitArtInfos and I'm not sure what I would need delete for...

Second, my Clansmen don't seem require iron which they should, where is it specified that a unit needs iron? Would it be in the Swordsman class or am I missing it in my definition of a Clansman?
 
I thought you didn't need any <Row> in a UnitArtInfos and I'm not sure what I would need delete for...

You need to do the exact same format as what the existing art definitions use (which generally included Row declarations), and again, you CANNOT just add your custom definitions. You have to replace the entire original file, using the VFS, with your new additions appended to the bottom. So if your file only has the two art definitions you listed in your first post, it'll break the game.

Second, my Clansmen don't seem require iron which they should, where is it specified that a unit needs iron?

Look for the Unit_ResourceQuantityRequirements table, or something with a similar name. (I'm at work and don't have the files in front of me.) It'll be in the Units.xml file and it'll be the one table with ResourceType as an argument, so it shouldn't be hard to find. You need to put an entry into that table if you want your new unit to require any sort of resource. I'd assumed that you'd intended your unit to be resourceless, since you hadn't put an entry in that table.
 
You have to replace the entire original file, using the VFS, with your new additions appended to the bottom.
Yes I have the whole file with my bit added in. In fact I get the same error when I just copy the original file and make no changes at all.
 
From the error message you've posted "[11533.372] Database::XMLSerializer (XML/Units/UnitArtDefines.xml): 'Row' or 'Delete' expected, got 'Type'." you've added an "Action -> UpdateDatabase" entry for the unit art file - don't! You just need to set "Import into VFS" to true
 
you've added an "Action -> UpdateDatabase" entry for the unit art file - don't!

That, too. But also, what I was referring to was that the error message said the name of the file was "UnitArtDefines.xml". When you're using VFS, the modified file has to have the exact same filename as the file it's replacing. It's not like normal XML, where you can name the file whatever you want. So if you're replacing civ5artdefines_units.xml, then the one in your mod has to have exactly that same name.
 
From the error message you've posted "[11533.372] Database::XMLSerializer (XML/Units/UnitArtDefines.xml): 'Row' or 'Delete' expected, got 'Type'." you've added an "Action -> UpdateDatabase" entry for the unit art file - don't! You just need to set "Import into VFS" to true
When you're using VFS, the modified file has to have the exact same filename as the file it's replacing.

Yes and Yes! Everything works now, thanks a lot.
 
Top Bottom