1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Help - Changing a "new" unit for an existing one

Discussion in 'Civ5 - Creation & Customization' started by Alexander666, Dec 3, 2012.

  1. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Sooo, I am making a Spartan Civilization mod. Almost finished too :)

    But, until now I have been using the Greek Hoplite as the unique unit. I have made another icon for it and want to exchange the Greek Hoplite with my Spartan unit.

    This is the xml I have put in my CIV5Units.xml:

    Spoiler :
    Code:
    <GameData>
    	<Units>
    		<Row>
    			<Class>UNITCLASS_SPEARMAN</Class>
    			<Type>UNIT_SPARTAN</Type>
    			<PrereqTech>TECH_BRONZE_WORKING</PrereqTech>
    			<Combat>10</Combat>
    			<Cost>56</Cost>
    			<Moves>2</Moves>
    			<CombatClass>UNITCOMBAT_MELEE</CombatClass>
    			<Domain>DOMAIN_LAND</Domain>
    			<DefaultUnitAI>UNITAI_COUNTER</DefaultUnitAI>
    			<Description>TXT_KEY_UNIT_SPARTAN</Description>
    			<Civilopedia>TXT_KEY_CIV5_ANTIQUITY_SPARTAN_TEXT</Civilopedia>
    			<Strategy>TXT_KEY_UNIT_SPARTAN_STRATEGY</Strategy>
    			<Help>TXT_KEY_UNIT_HELP_SPARTAN</Help>
    			<MilitarySupport>true</MilitarySupport>
    			<MilitaryProduction>true</MilitaryProduction>
    			<Pillage>true</Pillage>
    			<ObsoleteTech>TECH_CIVIL_SERVICE</ObsoleteTech>
    			<GoodyHutUpgradeUnitClass>UNITCLASS_SPEARMAN</GoodyHutUpgradeUnitClass>
    			<AdvancedStartCost>15</AdvancedStartCost>
    			<XPValueAttack>3</XPValueAttack>
    			<XPValueDefense>3</XPValueDefense>
    			<Conscription>2</Conscription>
    			<UnitArtInfo>ART_DEF_UNIT_U_GREEK_HOPLITE</UnitArtInfo>
    			<UnitFlagIconOffset>10</UnitFlagIconOffset>
    			<IconAtlas>CIV_COLOR_ATLAS_LEGENDS</IconAtlas>
    			<PortraitIndex>3</PortraitIndex>
    		</Row>
    	</Units>
    	<Unit_AITypes>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<UnitAIType>UNITAI_COUNTER</UnitAIType>
    		</Row>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<UnitAIType>UNITAI_ATTACK</UnitAIType>
    		</Row>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<UnitAIType>UNITAI_DEFENSE</UnitAIType>
    		</Row>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<UnitAIType>UNITAI_EXPLORE</UnitAIType>
    		</Row>
    	</Unit_AITypes>
    	<UnitCLassUpgrades>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<UnitClassType>UNITCLASS_PIKEMAN</UnitClassType>
    		</Row>
    	</UnitCLassUpgrades>
    	<UnitFlavors>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<FlavorType>FLAVOR_OFFENSE</FlavorType>
    			<Flavor>4</Flavor>
    		</Row>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<FlavorType>FLAVOR_DEFENSE</FlavorType>
    			<Flavor>8</Flavor>
    		</Row>
    	</UnitFlavors>
    	<Unit_UniqueNames>
    		<Row>
    			<UnitType>UNIT_WORKER</UnitType>
    			<UniqueName>TXT_KEY_SPARTAN_HELOT</UniqueName>
    		</Row>
    	</Unit_UniqueNames>
    </GameData>


    For now I am satisfied by just using the unit game graphics from the Greek Hoplite, hence leaving <UnitArtInfo>ART_DEF_UNIT_U_GREEK_HOPLITE</UnitArtInfo> in the code. I assume that is the correct way to do that.

    And here is what I put in the table in my GameText file:
    Spoiler :
    Code:
    ...(snip)...
    <Row Tag="TXT_KEY_UNIT_SPARTAN">
    	<Text>Spartan</Text>
    </Row>
    <Row Tag="TXT_KEY_CIV5_ANTIQUITY_SPARTAN_TEXT">
    	<Text>Civilopedia text here.</Text>
    </Row>
    <Row Tag="TXT_KEY_UNIT_SPARTAN_STRATEGY">
    	<Text>Strategy text here.</Text>
    </Row>
    <Row Tag="TXT_KEY_UNIT_HELP_SPARTAN">
    	<Text>Ancient Era Unit which specializes in defeating Mounted Units. Only the Spartans may build it. This Unit has a higher [ICON_STRENGTH] Combat Strength than the Spearman which it replaces.</Text>
    </Row>
    ...(snip)...


    And this is from the Civ main xml:

    Spoiler :
    Code:
    ...(snip)...
    <Civilization_UnitClassOverrides>
    		<Row>
    			<CivilizationType>CIVILIZATION_SPARTA</CivilizationType>
    			<UnitClassType>UNITCLASS_SPEARMAN</UnitClassType>
    			<UnitType>UNIT_SPARTAN</UnitType>
    		</Row>
    		<!--<Row>
    			<CivilizationType>CIVILIZATION_SPARTA</CivilizationType>
    			<UnitClassType>UNITCLASS_SPEARMAN</UnitClassType>
    			<UnitType>UNIT_GREEK_HOPLITE</UnitType>
    		</Row>-->
    	</Civilization_UnitClassOverrides>
    ...(snip)...


    I have remembered to include the files as OnModActivated UpdateDatabase in the project :)

    I am sure the problem is isolated to this unit because omitting the override code and using UNIT_GREEK_HOPLITE instead works.

    When I omit the UNIT_GREEK_HOPLITE and use UNIT_SPARTAN in my override code, I get the "can't scroll down on the Leader selection screen" problem. And the Unit won't show. This is usually a TXT problem, but to me it looks like everything is done correctly in that department.

    So, dear fellow modders - what am I doing wrong?
     
  2. Craig_Sutter

    Craig_Sutter Deity

    Joined:
    Aug 13, 2002
    Messages:
    2,747
    Gender:
    Male
    Location:
    Calgary, Canada
    A civilization needs two UU/UB/UI or it does not come out right in the selections screen. I think if you add a placeholder UU/UB from another civilization, the Spartan civilization will work.
     
  3. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,426
    Location:
    Near Portsmouth, UK
    <UnitCLassUpgrades>...</UnitCLassUpgrades>

    should be lower case

    There may be other errors ... so ... enable logging and check the database.log and xml.log files
     
  4. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Hi Craig, thanks for posting. I do have a unique building in there. As I wrote, everything works fine when I omit my Spartan unit and put in the Greek Hoplite in its stead. So -something- is missing or wrong in the Spartan Unit code. Just can't find it :scan:
     
  5. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Whoward, well done spotting that error. It wasn't the culprit though. I still have the same issue.
     
  6. Irkalla

    Irkalla ENTP POWWWEEEEEER

    Joined:
    Sep 25, 2012
    Messages:
    1,009
    Location:
    Way down around Vicksburg
    Yes. XML is pretty fanatical about proper capitalization.
     
  7. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,178
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    Alexander666, you seem to have missed whoward69's suggestion...

    Enable logging and check the logs. If you don't understand it, post the contents of xml.log and database.log here.
     
  8. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Oh, right - thanks...

    Here is the Database log:
    Spoiler :
    [51442.094] constraint failed
    [51442.094] While executing - 'INSERT INTO ArtDefine_StrategicView(StrategicViewType, TileType, Asset) VALUES(?,?,?)'
    [51446.422] no such table: ContentPackage.LocalizedText
    [51451.250] Validating Foreign Key Constraints...
    [51451.250] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [51451.250] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [51451.250] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [51452.625] Invalid Reference on UnitGameplay2DScripts.UnitType - "UNIT_HITTITE_WARCHARIOT" does not exist in Units
    [51452.625] Invalid Reference on UnitGameplay2DScripts.UnitType - "UNIT_SUMERIAN_PHALANX" does not exist in Units
    [51452.625] Failed Validation.
    [51453.187]
    -- SQLite Memory Statistics --
    Memory Usage:
    [Cur] [Max]
    Malloc: 401328 33259544
    PageCache: 4390 4982
    LookAside: 0 0
    Scratch: 0 1

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

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

    Prepared Statements:
    Current: 10
    ------------------------------


    Strange, as none of the units are any I have had my fingers/code in.

    Since I am not operating with the lua's I don't think it's relevant, but here is the lua log in any case:
    Spoiler :
    [51282.656] Initializing Lua 5.1.4


    Here is the XML log:
    Spoiler :
    [51451.234] **** Validating Game Database *****
    [51452.625] Performing Localization Checks
    [51452.625] Checking Tag Format...
    [51452.625] Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.
    [51452.625] In table Language_en_US...
    [51452.625] Tag (TXT_KEYMODDING_SHOWDLCMODS) does not start with 'TXT_KEY_'
    [51452.640] Validating UnitGameplay
    [51452.640] Number of selection sounds doesn't match number of units.
    [51452.640] Validating Notifications
    [51452.640] Number of notification xml entries does not match enum size
    [51452.640] **** VALIDATION FAILED *****
    [51452.640] Validation Took 1.410058 seconds
    [51453.187] **** Validating Prefetch Process *****
    [51453.187] **** Validation Success *****
    [51453.187] SetGlobalActionInfo
    [51453.187]
    -- SQLite Memory Statistics --
    Memory Usage:
    [Cur] [Max]
    Malloc: 401328 33259544
    PageCache: 4390 4982
    LookAside: 0 0
    Scratch: 0 1

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

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

    Prepared Statements:
    Current: 10
    ------------------------------


    Other logs I need to post?
     
  9. Horem

    Horem Emperor

    Joined:
    Apr 1, 2010
    Messages:
    1,720
    Location:
    Wales, UK
    You get them log's while your failed game was running? database.log seems to be not complete for a mod boot up, the text you posted is the vanilla booting up, should then duplicate similar entry once you go through the mods menu.
     
  10. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Hi Horem, well since I cannot choose the leader on the leader selection screen, I guees it never fully loads?

    I can select the mod on the mod screen - click Single player - then I cannot scroll down to choose my leader. I have tried that before when something is wrong with the GameText TXT, but I can't find the problem in there as it is. Those are posted in the first post.

    This is the latest log:
    Spoiler :
    Code:
    [58374.094] constraint failed
    [58374.094] While executing - 'INSERT INTO ArtDefine_StrategicView(StrategicViewType, TileType, Asset) VALUES(?,?,?)'
    [58377.766] no such table: ContentPackage.LocalizedText
    [58381.640] Validating Foreign Key Constraints...
    [58381.640] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [58381.640] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [58381.640] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [58383.062] Invalid Reference on UnitGameplay2DScripts.UnitType - "UNIT_HITTITE_WARCHARIOT" does not exist in Units
    [58383.062] Invalid Reference on UnitGameplay2DScripts.UnitType - "UNIT_SUMERIAN_PHALANX" does not exist in Units
    [58383.062] Failed Validation.
    [58383.687] 
    -- SQLite Memory Statistics --
    Memory Usage:
    		[Cur]		[Max]
    Malloc:		386016		33257144
    PageCache:	4384		4982
    LookAside:	0		0
    Scratch:	0		1
    
    Static Buffer Overflows:
    		[TooLarge]	[NoSpace]
    PageCache:	0		29697160
    Scratch:	0		0
    
    Largest Allocations:
    Malloc:		131072
    PageCache:	1160
    Scratch:	6640
    
    Prepared Statements:
    Current:		10
    ------------------------------


    Thanks to all of you who are looking in to this. This is an awesome community :king:
     
  11. Horem

    Horem Emperor

    Joined:
    Apr 1, 2010
    Messages:
    1,720
    Location:
    Wales, UK
    Have you tried with just the basic <Unit> Code and comment out ALL the rest?
    Also I would suggest you get SQLite for Firefox(or similar DB tool) so you can check to see if you additions actualy get applied to the database.
     
  12. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    I have tried with only this:

    Spoiler :
    Code:
    	<Units>
    		<Row>
    			<Class>UNITCLASS_SPEARMAN</Class>
    			<Type>UNIT_SPARTAN</Type>
    			<PrereqTech>TECH_BRONZE_WORKING</PrereqTech>
    			<Combat>10</Combat>
    			<Cost>56</Cost>
    			<Moves>2</Moves>
    			<CombatClass>UNITCOMBAT_MELEE</CombatClass>
    			<Domain>DOMAIN_LAND</Domain>
    			<DefaultUnitAI>UNITAI_COUNTER</DefaultUnitAI>
    			<Description>TXT_KEY_UNIT_SPARTAN</Description>
    			<Civilopedia>TXT_KEY_CIV5_ANTIQUITY_SPARTAN_TEXT</Civilopedia>
    			<Strategy>TXT_KEY_UNIT_SPARTAN_STRATEGY</Strategy>
    			<Help>TXT_KEY_UNIT_HELP_SPARTAN</Help>
    			<MilitarySupport>true</MilitarySupport>
    			<MilitaryProduction>true</MilitaryProduction>
    			<Pillage>true</Pillage>
    			<ObsoleteTech>TECH_CIVIL_SERVICE</ObsoleteTech>
    			<GoodyHutUpgradeUnitClass>UNITCLASS_SPEARMAN</GoodyHutUpgradeUnitClass>
    			<AdvancedStartCost>15</AdvancedStartCost>
    			<XPValueAttack>3</XPValueAttack>
    			<XPValueDefense>3</XPValueDefense>
    			<Conscription>2</Conscription>
    			<UnitArtInfo>ART_DEF_UNIT_U_GREEK_HOPLITE</UnitArtInfo>
    			<UnitFlagIconOffset>10</UnitFlagIconOffset>
    			<IconAtlas>CIV_COLOR_ATLAS_LEGENDS</IconAtlas>
    			<PortraitIndex>3</PortraitIndex>
    		</Row>
    	</Units>


    Should I shave the code even further...?
     
  13. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Wait wait wait! This is working!

    Hahaaa, now I just have to narrow down which ai codes are meesing this up.
    THANKS GUYS! :)

    Looks like I will be publishing the Sparta civ after some beta testing :D
     
  14. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Apparantly this snippet kills the mod:

    Spoiler :
    Code:
    	<UnitClassUpgrades>
    		<Row>
    			<UnitType>UNIT_SPARTAN</UnitType>
    			<UnitClassType>UNITCLASS_PIKEMAN</UnitClassType>
    		</Row>
    	</UnitClassUpgrades>

    ...which is so odd, because it is copied from the games original CIV5Units.xml and ofcourse modified to the unit.

    So, WITH the upgrade code in place, mod dies. Without that bit and the mod is fine (but can't upgrade my Spartans to Pikemen).
     
  15. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,426
    Location:
    Near Portsmouth, UK
    No it's not.

    The tag is <Unit_ClassUpgrades> (not <UnitClassUpgrades>) so you are trying to update a non-existant database table. Again, the database.log file would have told you this.
     
  16. Alexander666

    Alexander666 Chieftain

    Joined:
    Nov 29, 2012
    Messages:
    24
    Hah! That hit the spot - Thanks man!
    So weird because I snatched it directly from the original files.

    Here is the link for the "finished" beta mod:
    http://forums.civfanatics.com/showthread.php?t=481947

    Take a look at it if you feel like trying it out (goes for anyone).



    PS. Feedback is welcome, especially the kind of feedback with including codes ;)
     

Share This Page