How do I update units in a mod?

j51

Blue Star Cadet
Joined
Oct 22, 2006
Messages
1,750
Location
Ping Island
First I tried deleting the units I wanted to change and replacing them with new versions that use the same art, but that didn't work. Now I've tried this:

Code:
<GameData>
	<Units>
		<Update>
			<Where Type="UNIT_RUSSIAN_COSSACK"/>
			<Set>
				<Moves>5</Moves>
			</Set>
		</Update>
		<Update>
			<Where Type="UNIT_MUSKETMAN"/>
			<Set>
				<UnitArtInfo>ART_DEF_UNIT_U_SWEDISH_CAROLEAN</UnitArtInfo>
				<IconAtlas>EXPANSION_UNIT_ATLAS</IconAtlas>
				<PortraitIndex>3</PortraitIndex>
			</Set>
		</Update>
		<Update>
			<Where Type="UNIT_SIAMESE_WARELEPHANT"/>
			<Set>
				<Class>UNITCLASS_LANCER</Class>
				<PrereqTech>TECH_METALLURGY</PrereqTech>
				<Combat>31</Combat>
				<Cost>200</Cost>
				<FaithCost>400</FaithCost>
				<ObsoleteTech>TECH_COMBINED_ARMS</ObsoleteTech>
				<GoodyHutUpgradeUnitClass>UNITCLASS_ANTI_TANK_GUN</GoodyHutUpgradeUnitClass>
				<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
				<AdvancedStartCost>30</AdvancedStartCost>
			</Set>
		</Update>
		<Update>
			<Where Type="UNIT_IROQUOIAN_MOHAWKWARRIOR"/>
			<Set>
				<Class>UNITCLASS_WARRIOR</Class>
				<Combat>8</Combat>
				<Cost>40</Cost>
				<FaithCost>80</FaithCost>
				<ObsoleteTech>TECH_METAL_CASTING</ObsoleteTech>
				<GoodyHutUpgradeUnitClass>UNITCLASS_SPEARMAN</GoodyHutUpgradeUnitClass>
				<AdvancedStartCost>10</AdvancedStartCost>
			</Set>
		</Update>
		<Delete UnitType="UNIT_IROQUOIAN_MOHAWKWARRIOR" PrereqTech="TECH_IRON_WORKING"/>
		<Delete UnitType="UNIT_IROQUOIAN_MOHAWKWARRIOR" HurryCostModifier="20"/>
		<Update>
			<Where Type="UNIT_EGYPTIAN_WARCHARIOT"/>
			<Set>
				<Cost>42</Cost>
				<FaithCost>84</FaithCost>
			</Set>
		</Update>
		<Update>
			<Where Type="UNIT_AZTEC_JAGUAR"/>
			<Set>
				<Class>UNITCLASS_SWORDSMAN</Class>
				<PrereqTech>TECH_IRON_WORKING</PrereqTech>
				<Combat>14</Combat>
				<Cost>75</Cost>
				<FaithCost>150</FaithCost>
				<HurryCostModifier>20</HurryCostModifier>
				<ObsoleteTech>TECH_STEEL</ObsoleteTech>
				<GoodyHutUpgradeUnitClass>UNITCLASS_LONGSWORDSMAN</GoodyHutUpgradeUnitClass>
				<AdvancedStartCost>20</AdvancedStartCost>
			</Set>
		</Update>
		<Update>
			<Where Type="UNIT_CELT_PICTISH_WARRIOR"/>
			<Set>
				<Class>UNITCLASS_SWORDSMAN</Class>
				<PrereqTech>TECH_IRON_WORKING</PrereqTech>
				<Combat>14</Combat>
				<Cost>75</Cost>
				<FaithCost>150</FaithCost>
				<HurryCostModifier>20</HurryCostModifier>
				<ObsoleteTech>TECH_STEEL</ObsoleteTech>
				<GoodyHutUpgradeUnitClass>UNITCLASS_LONGSWORDSMAN</GoodyHutUpgradeUnitClass>
				<AdvancedStartCost>20</AdvancedStartCost>
			</Set>
		</Update>
		<Update>
			<Where Type="UNIT_BYZANTINE_DROMON"/>
			<Set>
				<Class>UNITCLASS_GALLEASS</Class>
				<PrereqTech>TECH_COMPASS</PrereqTech>
				<Combat>16</Combat>
				<RangedCombat>20</RangedCombat>
				<Cost>80</Cost>
				<ObsoleteTech>TECH_NAVIGATION</ObsoleteTech>
			</Set>
		</Update>
		<Update>
			<Where Type="UNIT_SWEDISH_CAROLEAN"/>
			<Set>
				<Class>UNITCLASS_LONGSWORDSMAN</Class>
				<PrereqTech>TECH_STEEL</PrereqTech>
				<Combat>21</Combat>
				<Cost>120</Cost>
				<FaithCost>240</FaithCost>
				<RequiresFaithPurchaseEnabled>true</RequiresFaithPurchaseEnabled>
				<CombatClass>UNITCOMBAT_MELEE</CombatClass>
				<ObsoleteTech>TECH_GUNPOWDER</ObsoleteTech>
				<IgnoreBuildingDefense>false</IgnoreBuildingDefense>
				<GoodyHutUpgradeUnitClass>UNITCLASS_MUSKETMAN</GoodyHutUpgradeUnitClass>
				<AdvancedStartCost>25</AdvancedStartCost>
				<UnitArtInfo>ART_DEF_UNIT_U_SAXON_HUSCARL</UnitArtInfo>
				<UnitFlagAtlas>EXPANSION_SCEN_UNIT_FLAG_ATLAS</UnitFlagAtlas>
				<UnitFlagIconOffset>1</UnitFlagIconOffset>
				<IconAtlas>EXPANSION_SCEN_UNIT_ATLAS</IconAtlas>
				<PortraitIndex>1</PortraitIndex>
			</Set>
		</Update>
		<Delete Type="UNIT_MECH"/>
	</Units>
	<Unit_AITypes>
		<Row>
			<UnitType>UNIT_IROQUOIAN_MOHAWKWARRIOR</UnitType>
			<UnitAIType>UNITAI_EXPLORE</UnitAIType>
		</Row>
		<Delete UnitType="UNIT_AZTEC_JAGUAR" UnitAIType="UNITAI_EXPLORE"/>
		<Delete UnitType="UNIT_CELT_PICTISH_WARRIOR" UnitAIType="UNITAI_EXPLORE"/>
		<Delete UnitType="UNIT_SWEDISH_CAROLEAN" UnitAIType="UNITAI_EXPLORE"/>
	</Unit_AITypes>
	<Unit_ClassUpgrades>
		<Update>
			<Where UnitType="UNIT_IROQUOIAN_MOHAWKWARRIOR"/>
			<Set>
				<UnitClassType>UNITCLASS_SWORDSMAN</UnitClassType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_AZTEC_JAGUAR"/>
			<Set>
				<UnitClassType>UNITCLASS_LONGSWORDSMAN</UnitClassType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_SIAMESE_WARELEPHANT"/>
			<Set>
				<UnitClassType>UNITCLASS_ANTI_TANK_GUN</UnitClassType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_CELT_PICTISH_WARRIOR"/>
			<Set>
				<UnitClassType>UNITCLASS_LONGSWORDSMAN</UnitClassType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_SWEDISH_CAROLEAN"/>
			<Set>
				<UnitClassType>UNITCLASS_MUSKETMAN</UnitClassType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_BYZANTINE_DROMON"/>
			<Set>
				<UnitClassType>UNITCLASS_FRIGATE</UnitClassType>
			</Set>
		</Update>
	</Unit_ClassUpgrades>
	<Unit_Flavors>
		<Update>
			<Where UnitType="UNIT_AZTEC_JAGUAR" FlavorType="FLAVOR_OFFENSE"/>
			<Set>
				<Flavor>10</Flavor>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_AZTEC_JAGUAR" FlavorType="FLAVOR_DEFENSE"/>
			<Set>
				<Flavor>10</Flavor>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_IROQUOIAN_MOHAWKWARRIOR" FlavorType="FLAVOR_OFFENSE"/>
			<Set>
				<Flavor>4</Flavor>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_IROQUOIAN_MOHAWKWARRIOR" FlavorType="FLAVOR_DEFENSE"/>
			<Set>
				<Flavor>4</Flavor>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_CELT_PICTISH_WARRIOR" FlavorType="FLAVOR_OFFENSE"/>
			<Set>
				<Flavor>10</Flavor>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_CELT_PICTISH_WARRIOR" FlavorType="FLAVOR_DEFENSE"/>
			<Set>
				<Flavor>10</Flavor>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_SWEDISH_CAROLEAN" FlavorType="FLAVOR_OFFENSE"/>
			<Set>
				<Flavor>11</Flavor>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_SWEDISH_CAROLEAN" FlavorType="FLAVOR_DEFENSE"/>
			<Set>
				<Flavor>9</Flavor>
			</Set>
		</Update>
		<Row>
			<UnitType>UNIT_IROQUOIAN_MOHAWKWARRIOR</UnitType>
			<FlavorType>FLAVOR_RECON</FlavorType>
			<Flavor>2</Flavor>
		</Row>
		<Delete UnitType="UNIT_AZTEC_JAGUAR" FlavorType="FLAVOR_RECON"/>
	</Unit_Flavors>
	<Unit_FreePromotions>
		<Row>
			<UnitType>UNIT_IROQUOIAN_MOHAWKWARRIOR</UnitType>
			<PromotionType>PROMOTION_WOODSMAN</PromotionType>
		</Row>
		<Row>
			<UnitType>UNIT_ROMAN_LEGION</UnitType>
			<PromotionType>PROMOTION_SPAWN_GENERALS_I</PromotionType>
		</Row>
		<Row>
			<UnitType>UNIT_SIAMESE_WARELEPHANT</UnitType>
			<PromotionType>PROMOTION_FORMATION_1</PromotionType>
		</Row>
		<Row>
			<UnitType>UNIT_CELT_PICTISH_WARRIOR</UnitType>
			<PromotionType>PROMOTION_DRILL_1</PromotionType>
		</Row>
		<Delete UnitType="UNIT_AZTEC_JAGUAR" PromotionType="PROMOTION_WOODSMAN"/>
		<Delete UnitType="UNIT_SIAMESE_WARELEPHANT" PromotionType="PROMOTION_ANTI_MOUNTED_I"/>
		<Delete UnitType="UNIT_CELT_PICTISH_WARRIOR" PromotionType="PROMOTION_FOREIGN_LANDS"/>
	</Unit_FreePromotions>
	<Unit_ResourceQuantityRequirements>
		<Update>
			<Where UnitType="UNIT_MODERN_ARMOR"/>
			<Set>
				<ResourceType>RESOURCE_OIL</ResourceType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_HELICOPTER_GUNSHIP"/>
			<Set>
				<ResourceType>RESOURCE_OIL</ResourceType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_JET_FIGHTER"/>
			<Set>
				<ResourceType>RESOURCE_OIL</ResourceType>
			</Set>
		</Update>
		<Update>
			<Where UnitType="UNIT_STEALTH_BOMBER"/>
			<Set>
				<ResourceType>RESOURCE_OIL</ResourceType>
			</Set>
		</Update>
		<Row>
			<UnitType>UNIT_EGYPTIAN_WARCHARIOT</UnitType>
			<ResourceType>RESOURCE_HORSE</ResourceType>
		</Row>
		<Row>
			<UnitType>UNIT_MISSILE_CRUISER</UnitType>
			<ResourceType>RESOURCE_ALUMINUM</ResourceType>
		</Row>
		<Row>
			<UnitType>UNIT_NUCLEAR_SUBMARINE</UnitType>
			<ResourceType>RESOURCE_URANIUM</ResourceType>
		</Row>
		<Row>
			<UnitType>UNIT_CARRIER</UnitType>
			<ResourceType>RESOURCE_OIL</ResourceType>
		</Row>
		<Row>
			<UnitType>UNIT_MOBILE_SAM</UnitType>
			<ResourceType>RESOURCE_ALUMINUM</ResourceType>
		</Row>
		<Row>
			<UnitType>UNIT_CELT_PICTISH_WARRIOR</UnitType>
			<ResourceType>RESOURCE_IRON</ResourceType>
		</Row>
		<Row>
			<UnitType>UNIT_HUN_HORSE_ARCHER</UnitType>
			<ResourceType>RESOURCE_HORSE</ResourceType>
		</Row>
		<Row>
			<UnitType>UNIT_SWEDISH_CAROLEAN</UnitType>
			<ResourceType>RESOURCE_IRON</ResourceType>
		</Row>
		<Delete UnitType="UNIT_ARABIAN_CAMELARCHER"/>
	</Unit_ResourceQuantityRequirements>
</GameData>

And the changes still won't show up. What's going on?
 
Please use the
Code:
 tags so that code is formatted. Otherwise I refuse to read a wall of text.

Please check your database.log to see if you can find any errors. (MyGames -> Civilization V -> Logs -> Database.log)
Make sure you've added the xml file to your mod using "UpdateDatabase"
Make sure you haven't misspelled a column name, for example "PrerqTech" instead of "PrereqTech". The file will fail to run.


- When deleting you only have to delete UnitType, not UnitAIType as well (this goes for any delete, just offer the name, or the specific column that you want to identify the delete with.


Anywho I opened that file up in ModBuddy (which is a step I really shouldn't have to do) so it formatted on its own. No immediate errors stuck out at me. The problem could be a multitude of these, please perform the general debugging steps listed above to attempt to debug the problem. (if you haven't enabled logging, MyGames -> Civilization 5 -> config.ini -> LoggingEnabled = 1)
 
You can just post the contents of the database.log. That should give us the problem.
 
Code:
[736.078] constraint failed
[736.078] While executing - 'INSERT INTO ArtDefine_StrategicView(StrategicViewType, TileType, Asset) VALUES(?,?,?)'
[756.921] Validating Foreign Key Constraints...
[756.921] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[756.921] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[756.921] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[758.390] Invalid Reference on UnitGameplay2DScripts.UnitType - "UNIT_HITTITE_WARCHARIOT" does not exist in Units
[758.390] Invalid Reference on UnitGameplay2DScripts.UnitType - "UNIT_SUMERIAN_PHALANX" does not exist in Units
[758.390] Failed Validation.
[759.015] 
-- SQLite Memory Statistics --
Memory Usage:
		[Cur]		[Max]
Malloc:		363216		32934776
PageCache:	4358		4982
LookAside:	0		0
Scratch:	0		1

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

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

Prepared Statements:
Current:		6
------------------------------
 
Nothing in the log. Post your .modinfo? Make sure you set it up correctly?
 
Code:
<Mod id="221ca711-6ef8-4cf8-b7b0-ccb910df0c50" version="1">
  <Properties>
    <Name>Supremo Mod</Name>
    <Stability>Alpha</Stability>
    <Teaser>New Colours
New Names
New Units
Changes to existing Units, Buildings, and Techs
Changes to Civ Abilities</Teaser>
    <Description>New Colours
New Names
New Units
Changes to existing Units, Buildings, and Techs
Changes to Civ Abilities</Description>
    <Authors>me</Authors>
    <HideSetupGame>0</HideSetupGame>
    <AffectsSavedGames>1</AffectsSavedGames>
    <MinCompatibleSaveVersion>0</MinCompatibleSaveVersion>
    <SupportsSinglePlayer>1</SupportsSinglePlayer>
    <SupportsMultiplayer>1</SupportsMultiplayer>
    <SupportsHotSeat>1</SupportsHotSeat>
    <SupportsMac>1</SupportsMac>
    <ReloadLandmarkSystem>0</ReloadLandmarkSystem>
    <ReloadStrategicViewSystem>0</ReloadStrategicViewSystem>
    <ReloadUnitSystem>1</ReloadUnitSystem>
  </Properties>
  <Dependencies />
  <References />
  <Blocks />
  <Files>
    <File md5="7DA48807F5E4DD8F046DB19DB8826F11" import="0">Cities_Changes.xml</File>
    <File md5="A0FD4F561ED93205E84B4673BDD6D70B" import="0">Cities_Text.xml</File>
    <File md5="D47CBE560D0F78C1CC7B0C833D224214" import="0">City_State_Changes.xml</File>
    <File md5="1EF7BFB2FCFA1D54399904279AAA2CBE" import="0">Civ_Changes.xml</File>
    <File md5="D461846743DA8E62DC293F81F423CEEB" import="0">Colours.xml</File>
    <File md5="0D7B5FD35C3E87F16DDDFE309B4482D0" import="0">Khazar_Cities.xml</File>
    <File md5="9A3930D456063D1070171F774EE156A1" import="0">Khazar_Text.xml</File>
    <File md5="5B097C9842B304EDA671219D171E9E5E" import="0">Other_Text.xml</File>
    <File md5="B6CA06E6BBDC946EADF1609041383033" import="0">Trait_Changes.xml</File>
    <File md5="A53640B7BA3044E2F549C45A5CE1D210" import="0">Unit_Changes.xml</File>
  </Files>
  <Actions>
    <OnModActivated>
      <UpdateDatabase>Colours.xml</UpdateDatabase>
      <UpdateDatabase>Cities_Changes.xml</UpdateDatabase>
      <UpdateDatabase>Civ_Changes.xml</UpdateDatabase>
      <UpdateDatabase>Trait_Changes.xml</UpdateDatabase>
      <UpdateDatabase>City_State_Changes.xml</UpdateDatabase>
      <UpdateDatabase>Unit_Changes.xml</UpdateDatabase>
      <UpdateDatabase>Cities_Text.xml</UpdateDatabase>
      <UpdateDatabase>Other_Text.xml</UpdateDatabase>
      <UpdateDatabase>Khazar_Cities.xml</UpdateDatabase>
      <UpdateDatabase>Khazar_Text.xml</UpdateDatabase>
    </OnModActivated>
  </Actions>
</Mod>
 
Just post the mod for download and I'll take a look.
 
I'll do that,but also I noticed some issues with the xml.log:

Code:
756.921] **** Validating Game Database *****
[758.390] Performing Localization Checks
[758.390] Checking Tag Format...
[758.390] Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.
[758.390] In table Language_en_US...
[758.390] Tag (TXT_KEYMODDING_SHOWDLCMODS) does not start with 'TXT_KEY_'
[758.406] Validating UnitGameplay
[758.406] Number of selection sounds doesn't match number of units.
[758.406] Validating Notifications
[758.406] Number of notification xml entries does not match enum size
[758.406] **** VALIDATION FAILED *****
[758.406] Validation Took 1.502275 seconds
[759.015] **** Validating Prefetch Process *****
[759.015] **** Validation Success *****
[759.015] SetGlobalActionInfo
[759.015] 
-- SQLite Memory Statistics --
Memory Usage:
		[Cur]		[Max]
Malloc:		363216		32934776
PageCache:	4358		4982
LookAside:	0		0
Scratch:	0		1

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

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

Prepared Statements:
Current:		6
------------------------------

Could that have anything to do with it?
 
Nah those look like generic errors that are harmless.

I'll have to take a closer look at the mod to determine what the problem is.
 
I checked the Database.log when I opened up your mod. Sure enough, the answer was there (did you enable logging? You really should do that, it makes debugging really simple).

Anywho, these lines gave it away:

Code:
[549194.749] no such column: UnitType
[549194.749] In Query - DELETE FROM Units WHERE UnitType = ? AND PrereqTech = ?;
[549194.749] Database::XMLSerializer (Unit_Changes.xml): There was an error executing the delete statement! See Database.log for details.
[549194.749] In XMLSerializer while updating table Units from file Unit_Changes.xml.

So I checked Unit_Changes.xml and sure enough:

Code:
<Delete [B]UnitType[/B]="UNIT_IROQUOIAN_MOHAWKWARRIOR" PrereqTech="TECH_IRON_WORKING"/>
<Delete [B]UnitType[/B]="UNIT_IROQUOIAN_MOHAWKWARRIOR" HurryCostModifier="20"/>

Should be changed to Type, not UnitType!
 
No problem mate glad it works. :)
 
Back
Top Bottom