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

Trying to add unit based on existing model?

Discussion in 'Civ5 - Creation & Customization' started by Peng Qi, Apr 29, 2015.

  1. Peng Qi

    Peng Qi Emperor

    Joined:
    Aug 19, 2007
    Messages:
    1,431
    Location:
    Irrelevant.
    I'm not sure why this code isn't working. Sorry for the questionspam! Learning on your own is hard. :(

    First of all, I followed the procedures in Kael's guide to create this code for a Scout upgrade:
    Code:
    		<Row>
    			<Class>UNITCLASS_ADVENTURER</Class>
    			<Type>UNIT_ADVENTURER</Type>
    			<PrereqTech>TECH_METAL_CASTING</PrereqTech>
    			<Combat>10</Combat>
    			<Cost>100</Cost>
    			<Moves>2</Moves>
    			<CombatClass>UNITCOMBAT_RECON</CombatClass>
    			<Domain>DOMAIN_LAND</Domain>
    			<DefaultUnitAI>UNITAI_EXPLORE</DefaultUnitAI>
    			<Description>TXT_KEY_UNIT_ADVENTURER</Description>
    			<Civilopedia>TXT_KEY_CIV5_ANTIQUITY_SCOUT_TEXT</Civilopedia>
    			<Strategy>TXT_KEY_UNIT_SCOUT_STRATEGY</Strategy>
    			<Help>TXT_KEY_UNIT_HELP_ADVENTURER</Help>
    			<NoBadGoodies>true</NoBadGoodies>
    			<Pillage>true</Pillage>
    			<MilitarySupport>true</MilitarySupport>
    			<MilitaryProduction>true</MilitaryProduction>
    			<ObsoleteTech>TECH_SCIENTIFIC_THEORY</ObsoleteTech>
    			<GoodyHutUpgradeUnitClass>UNITCLASS_SWORDSMAN</GoodyHutUpgradeUnitClass>
    			<AdvancedStartCost>20</AdvancedStartCost>
    			<XPValueAttack>3</XPValueAttack>
    			<XPValueDefense>3</XPValueDefense>
    			<UnitArtInfo>ART_DEF_UNIT_ADVENTURER</UnitArtInfo>
    			<UnitFlagAtlas>EXPANSION_SCEN_UNIT_FLAG_ATLAS</UnitFlagAtlas>
    			<UnitFlagIconOffset>1</UnitFlagIconOffset>
    			<IconAtlas>EXPANSION_SCEN_UNIT_ATLAS</IconAtlas>
    			<PortraitIndex>1</PortraitIndex>
    		</Row>
    I also made an ArtDefines file with the following:
    Code:
    <UnitArtInfos>
    	<UnitArtInfo>
    		<Type>ART_DEF_UNIT_ADVENTURER</Type>
    		<Formation>Barbarian</Formation>
    		<DamageStates>1</DamageStates>
    		<UnitMemberArt>
    			<MemberType>ART_DEF_UNIT_MEMBER_U_SAXON_HUSCARL</MemberType>
    			<MemberCount>6</MemberCount>
    		</UnitMemberArt>
    	</UnitArtInfo>
    </UnitArtInfos>
    Note I'm using a model from the Fall of Rome scenario, which is why the Flag and Atlas are goofy. I presumed these would work as-is because the unit loads normally into Nexus's Unit Viewer, but I'm a noob so half of my presumptions are stupid and this could be the problem.

    Note this doesn't crash the game or anything, it just...doesn't seem to load properly. The unit doesn't appear in the tech tree, can't be built, and Scouts don't upgrade to it, despite me adding this code as well:
    Code:
    		<Update>
    			<Where UnitType="UNIT_SCOUT"/>
    			<Set GoodyHutUpgradeUnitClass="UNITCLASS_ADVENTURER"/>
    			<Set ObsoleteTech="TECH_METAL_CASTING"/>
    		</Update>
    		<Update>
    			<Where UnitType="UNIT_PATHFINDER"/>
    			<Set GoodyHutUpgradeUnitClass="UNITCLASS_ADVENTURER"/>
    			<Set ObsoleteTech="TECH_METAL_CASTING"/>
    		</Update>
    There's lots of other code I added, but I don't suspect it's the problem so I'm not going to include all of it.

    Halp? :sad:

    EDIT: Oh, and I of course have UpdateDatabase entries for both files. Neither are in the VFS; is that correct?
     
  2. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    6,929
    Location:
    Illinois, USA
    Unfortunately I have to tell you there's not much you did there that is correct. It's getting a little late for me, so a substantive response won't be possible until my tomorrow USA time.

    Having said that, you can only state "Set" once for every "Update". Combine them so they are
    Code:
    <Update>
    	<Where [COLOR="Red"]UnitType[/COLOR]="UNIT_SCOUT"/>
    	<Set GoodyHutUpgradeUnitClass="UNITCLASS_ADVENTURER" ObsoleteTech="TECH_METAL_CASTING"/>
    </Update>
    <Update>
    	<Where [COLOR="red"]UnitType[/COLOR]="UNIT_PATHFINDER"/>
    	<Set GoodyHutUpgradeUnitClass="UNITCLASS_ADVENTURER" ObsoleteTech="TECH_METAL_CASTING"/>
    </Update>
    However, the parts noted in red are still incorrect if appearing within the table <Units>. If not occuring within the table <Units>, that is also part of your problem, as Columns "GoodyHutUpgradeUnitClass" and "ObsoleteTech" are specific to table <Units>.

    It needs to be:
    Code:
    <Update>
    	<Where [color="blue"]Type[/color]="UNIT_SCOUT"/>
    	<Set GoodyHutUpgradeUnitClass="UNITCLASS_ADVENTURER" ObsoleteTech="TECH_METAL_CASTING"/>
    </Update>
    <Update>
    	<Where [color="blue"]Type[/color]="UNIT_PATHFINDER"/>
    	<Set GoodyHutUpgradeUnitClass="UNITCLASS_ADVENTURER" ObsoleteTech="TECH_METAL_CASTING"/>
    </Update>
    --------------------------------------------------------------------------------------------------------

    These tables are no longer used:
    Code:
    <UnitArtInfos>
    	<UnitArtInfo>
    <UnitMemberArtInfos>
    	<UnitMemberArtInfo>
    
    Which have been replaced by these tables for defining the "Art" a new unit should use:
    Code:
    <ArtDefine_UnitInfos>
    <ArtDefine_UnitInfoMemberInfos>
    <ArtDefine_UnitMemberInfos>
    <ArtDefine_StrategicView>
    <ArtDefine_UnitMemberCombats>
    <ArtDefine_UnitMemberCombatWeapons>
    See this recent thread

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

    Anything more substantive will have to wait until the morning USA time unless another forum member responds in the meantime. However, I would suggest you go ahead and whoward69's zip your mods and attach tutorial if you aren't able to get the mod working.
     
  3. Peng Qi

    Peng Qi Emperor

    Joined:
    Aug 19, 2007
    Messages:
    1,431
    Location:
    Irrelevant.
    Thanks for the response!

    Don't worry about telling me I wrote a pile of mess. I have zero programming experience before like...three weeks ago (well, unless you count Visual Basic! Then I have a few months of experience back in freshman year of highschool in 1997! :D Oh, and one day of experience with HyperCard from 1995!). I'd be shocked if I didn't write half of everything completely wrong.
     
  4. Peng Qi

    Peng Qi Emperor

    Joined:
    Aug 19, 2007
    Messages:
    1,431
    Location:
    Irrelevant.
    I've located this thread which has proven absurdly invaluable to what I'm doing! I might not even need any more help! :D
     

Share This Page