Custom Civ UU

Bonyduck Campersang

Odd lookin duck
Joined
Dec 11, 2022
Messages
4,506
I used the template for Babylon's Bowman to create my own UU. It was working fine then, but now I've decided to change to using the Landsknecht. The logs say
Code:
Invalid Reference on Civilization_UnitClassOverrides.UnitType - "UNIT_BUYID_DAYLAMITE_WARRIOR" does not exist in Units
.

In Properties I've verified that the Units.xml file (which contains the update to <Units>) is being updated to the database. I've verified with ctrl+f that the UnitType in Units.xml matches the one in Civilization.xml. Here are the relevant code snippets (which seem alright to me):

XML:
<Civilization_UnitClassOverrides>
    <Row>
      <CivilizationType>CIVILIZATION_BUYIDS</CivilizationType>
      <UnitClassType>UNITCLASS_PIKEMAN</UnitClassType>
      <UnitType>UNIT_BUYID_DAYLAMITE_WARRIOR</UnitType>
    </Row>
  </Civilization_UnitClassOverrides>

<Units>
    <Row>
      <Type>UNIT_BUYID_DAYLAMITE_WARRIOR</Type>
      <Description>TXT_KEY_UNIT_BUYID_DAYLAMITE_WARRIOR</Description>
      <Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MEDIEVAL_LANDSKNECHT_TEXT</Civilopedia>
      <Strategy>TXT_KEY_UNIT_BUYID_DAYLAMITE_WARRIOR_STRATEGY</Strategy>
      <Help>TXT_KEY_UNIT_HELP_DAYLAMITE_WARRIOR</Help>
      <Requirements></Requirements>
      <Combat>16</Combat>
      <RangedCombat>0</RangedCombat>
      <Cost>45</Cost>
      <FaithCost>0</FaithCost>
      <RequiresFaithPurchaseEnabled>0</RequiresFaithPurchaseEnabled>
      <PurchaseOnly>1</PurchaseOnly>
      <MoveAfterPurchase>1</MoveAfterPurchase>
      <Moves>2</Moves>
      <Immobile>0</Immobile>
      <Range>0</Range>
      <BaseSightRange>2</BaseSightRange>
      <Class>UNITCLASS_PIKEMAN</Class>
      <Special></Special>
      <Capture></Capture>
      <CombatClass>UNITCOMBAT_MELEE</CombatClass>
      <Domain>DOMAIN_LAND</Domain>
      <CivilianAttackPriority></CivilianAttackPriority>
      <DefaultUnitAI>UNITAI_COUNTER</DefaultUnitAI>
      <Food>0</Food>
      <NoBadGoodies>0</NoBadGoodies>
      <RivalTerritory>0</RivalTerritory>
      <MilitarySupport>1</MilitarySupport>
      <MilitaryProduction>1</MilitaryProduction>
      <Pillage>1</Pillage>
      <PillagePrereqTech></PillagePrereqTech>
      <Found>0</Found>
      <FoundAbroad>0</FoundAbroad>
      <CultureBombRadius>0</CultureBombRadius>
      <GoldenAgeTurns>0</GoldenAgeTurns>
      <FreePolicies>0</FreePolicies>
      <OneShotTourism>0</OneShotTourism>
      <OneShotTourismPercentOthers>0</OneShotTourismPercentOthers>
      <IgnoreBuildingDefense>0</IgnoreBuildingDefense>
      <PrereqResources>0</PrereqResources>
      <Mechanized>0</Mechanized>
      <Suicide>0</Suicide>
      <CaptureWhileEmbarked>0</CaptureWhileEmbarked>
      <PrereqTech>TECH_CIVIL_SERVICE</PrereqTech>
      <ObsoleteTech></ObsoleteTech>
      <GoodyHutUpgradeUnitClass>UNITCLASS_LANCER</GoodyHutUpgradeUnitClass>
      <HurryCostModifier>0</HurryCostModifier>
      <AdvancedStartCost>20</AdvancedStartCost>
      <MinAreaSize>-1</MinAreaSize>
      <AirInterceptRange>0</AirInterceptRange>
      <AirUnitCap>0</AirUnitCap>
      <NukeDamageLevel>-1</NukeDamageLevel>
      <WorkRate>0</WorkRate>
      <NumFreeTechs>0</NumFreeTechs>
      <BaseBeakersTurnsToCount>0</BaseBeakersTurnsToCount>
      <BaseCultureTurnsToCount>0</BaseCultureTurnsToCount>
      <RushBuilding>0</RushBuilding>
      <BaseHurry>0</BaseHurry>
      <HurryMultiplier>0</HurryMultiplier>
      <BaseGold>0</BaseGold>
      <NumGoldPerEra>0</NumGoldPerEra>
      <SpreadReligion>0</SpreadReligion>
      <RemoveHeresy>0</RemoveHeresy>
      <ReligionSpreads>0</ReligionSpreads>
      <ReligiousStrength>0</ReligiousStrength>
      <FoundReligion>0</FoundReligion>
      <RequiresEnhancedReligion>0</RequiresEnhancedReligion>
      <ProhibitsSpread>0</ProhibitsSpread>
      <CanBuyCityState>0</CanBuyCityState>
      <CombatLimit>100</CombatLimit>
      <RangeAttackOnlyInDomain>0</RangeAttackOnlyInDomain>
      <RangeAttackIgnoreLOS>0</RangeAttackIgnoreLOS>
      <Trade>0</Trade>
      <NumExoticGoods>0</NumExoticGoods>
      <PolicyType>POLICY_TRADE_UNIONS</PolicyType>
      <RangedCombatLimit>0</RangedCombatLimit>
      <XPValueAttack>3</XPValueAttack>
      <XPValueDefense>3</XPValueDefense>
      <SpecialCargo></SpecialCargo>
      <DomainCargo></DomainCargo>
      <Conscription>3</Conscription>
      <ExtraMaintenanceCost>0</ExtraMaintenanceCost>
      <NoMaintenance>0</NoMaintenance>
      <Unhappiness>0</Unhappiness>
      <UnitArtInfo>ART_DEF_UNIT_U_GERMAN_LANDSKNECHT</UnitArtInfo>
      <UnitArtInfoCulturalVariation>0</UnitArtInfoCulturalVariation>
      <UnitArtInfoEraVariation>0</UnitArtInfoEraVariation>
      <ProjectPrereq></ProjectPrereq>
      <SpaceshipProject></SpaceshipProject>
      <LeaderPromotion></LeaderPromotion>
      <LeaderExperience>0</LeaderExperience>
      <DontShowYields>0</DontShowYields>
      <ShowInPedia>1</ShowInPedia>
      <MoveRate>BIPED</MoveRate>
      <UnitFlagIconOffset>33</UnitFlagIconOffset>
      <PortraitIndex>34</PortraitIndex>
      <IconAtlas>UNIT_ATLAS_1</IconAtlas>
      <UnitFlagAtlas>UNIT_FLAG_ATLAS</UnitFlagAtlas>
    </Row>
  </Units>

Mod attached
 

Attachments

<Row Tag="TXT_KEY_UNIT_HELP_LANDSKNECHT"> right at the end of Units.xml
 
But why would that give an error? Wouldn't it just mean there's no English language text for the Dalamite Warrior?
You're trying to add a row that already exists, so it fails, which causes the entire XML to be discarded, which means the unit doesn't exist in the database when you come to reference it from the Civilization_UnitClassOverrides table, hence the error.

"Invalid reference" ... "something I was looking for doesn't exist"
 
what do Unit Flavours do?

Code:
<Unit_Flavors>
    <Row>
      <UnitType>UNIT_BUYID_DAYLAMITE_WARRIOR</UnitType>
      <FlavorType>FLAVOR_OFFENSE</FlavorType>
      <Flavor>6</Flavor>
    </Row>
    <Row>
      <UnitType>UNIT_BUYID_DAYLAMITE_WARRIOR</UnitType>
      <FlavorType>FLAVOR_DEFENSE</FlavorType>
      <Flavor>9</Flavor>
    </Row>
  </Unit_Flavors>
 
Your best bet with flavours is to find a similar Maxis unit/building/policy/leader/whatever and copy them
 
<UnitArtInfo> specifies the 3D model the unit should have in game. <UnitArtInfo>ART_DEF_UNIT_U_GERMAN_LANDSKNECHT</UnitArtInfo> is saying it should look up the 3D graphics information associated with the tag ART_DEF_UNIT_U_GERMAN_LANDSKNECHT and so it will appear in game as a Landsknecht.

The problem with the icon is that you're telling it to use this icon atlas:
Code:
<IconAtlas>DAYLAMITE_WARRIOR_ICON_ATLAS</IconAtlas>
And you're telling it to use the 35th icon in the atlas (the first icon has an index of 0)
Code:
<PortraitIndex>34</PortraitIndex>
But from the way your atlas is defined, there is no 35th icon, because the atlas is only 1x1:
Code:
<Row>
            <Atlas>DAYLAMITE_WARRIOR_ICON_ATLAS</Atlas>
            <IconSize>64</IconSize>
            <Filename>ART/DaylamiteAtlas64.dds</Filename>
            <IconsPerRow>1</IconsPerRow>
            <IconsPerColumn>1</IconsPerColumn>
        </Row>

Also, from the .modinfo file, all these files have not been set to Import into VFS = true, which they need to be:
Code:
<File md5="26D1673E4F76D3EA7998A805D165B5AE" import="0">Art/DaylamiteAtlas128.dds</File>
    <File md5="662460392A0983E593A15CD2CAD32989" import="0">Art/DaylamiteAtlas256.dds</File>
    <File md5="3C02AD1A7EC3239A1D233B935A51839A" import="0">Art/DaylamiteAtlas45.dds</File>
    <File md5="06D132F88ECEF7ECA7A00AC994D536B2" import="0">Art/DaylamiteAtlas64.dds</File>

Oh, and the map image you've set the civilization to use, MapBUYIDS512.dds, does not exist in the mod, which is why the game is complaining about not being able to load that texture and replacing it with a red rectangle instead.
 
What does Order Priority do?

1727100423532.png
 
Top Bottom