I made new UnitClasses, but it doesn't work

skagh

Chieftain
Joined
Nov 24, 2017
Messages
2
Code:
<GameData>
    <UnitClasses>
        <Row>
            <Type>UNITCLASS_BLACK_HAWK</Type>
            <Description>TXT_KEY_UNIT_BLACK_HAWK</Description>
            <DefaultUnit>UNIT_BLACK_HAWK</DefaultUnit>
        </Row>
    </UnitClasses>
    <Language_en_US>
        <Row tag="TXT_KEY_UNIT_BLACK_HAWK">
            <Text>Black Hawk</Text>
        </Row>
    </Language_en_US>
  <Units>
      <Row>
          <Class>UNITCLASS_BLACK_HAWK</Class>
          <Type>UNIT_BLACK_HAWK</Type>
          <PrereqTech>TECH_TRAPPING</PrereqTech>
          <Combat>50</Combat>
          <Cost>37</Cost>
          <Moves>5</Moves>
          <CombatClass>UNITCOMBAT_ARMOR</CombatClass>
          <Domain>DOMAIN_LAND</Domain>
          <DefaultUnitAI>UNITAI_FAST_ATTACK</DefaultUnitAI>
          <Description>TXT_KEY_UNIT_BLACK_HAWK</Description>
          <Civilopedia>TXT_KEY_CIVILOPEDIA_UNIT_BLACK_HAWK_TEXT</Civilopedia>
          <Strategy>TXT_KEY_UNIT_BLACK_HAWK_STRATEGY</Strategy>
          <Help>TXT_KEY_UNIT_HELP_BLACK_HAWK</Help>
          <MilitarySupport>true</MilitarySupport>
          <MilitaryProduction>true</MilitaryProduction>
          <Pillage>true</Pillage>
          <IgnoreBuildingDefense>true</IgnoreBuildingDefense>
          <Mechanized>true</Mechanized>
          <GoodyHutUpgradeUnitClass>UNITCLASS_MODERN_ARMOR</GoodyHutUpgradeUnitClass>
          <AdvancedStartCost>50</AdvancedStartCost>
          <XPValueAttack>3</XPValueAttack>
          <XPValueDefense>3</XPValueDefense>
          <UnitArtInfo>ART_DEF_UNIT_TANK</UnitArtInfo>
          <UnitFlagIconOffset>57</UnitFlagIconOffset>
          <PortraitIndex>13</PortraitIndex>
          <IconAtlas>UNIT_ATLAS_2</IconAtlas>
          <MoveRate>WHEELED</MoveRate>
      </Row>
  </Units>

  <Unit_AITypes>
    <Row>
      <UnitType>UNIT_BLACK_HAWK</UnitType>
      <UnitAIType>UNITAI_DEFENSE</UnitAIType>
    </Row>
  </Unit_AITypes>
  <Unit_FreePromotions>
      <Row>
          <UnitType>UNIT_BLACK_HAWK</UnitType>
          <PromotionType>PROMOTION_REPAIR</PromotionType>
      </Row>
  </Unit_FreePromotions>
  <Unit_Flavors>
    <Row>
      <UnitType>UNIT_BLACK_HAWK</UnitType>
      <FlavorType>FLAVOR_OFFENSE</FlavorType>
      <Flavor>15</Flavor>
    </Row>
    <Row>
      <UnitType>UNIT_BLACK_HAWK</UnitType>
      <FlavorType>FLAVOR_DEFENSE</FlavorType>
      <Flavor>9</Flavor>
    </Row>
  </Unit_Flavors>
  <UnitGameplay2DScripts>
    <Row>
      <UnitType>UNIT_BLACK_HAWK</UnitType>
      <SelectionSound>AS2D_SELECT_STEALTH_BOMBER</SelectionSound>
      <FirstSelectionSound>AS2D_BIRTH_STEALTH_BOMBER</FirstSelectionSound>
    </Row>
  </UnitGameplay2DScripts>

  <Language_en_US>
    <Row Tag="TXT_KEY_UNIT_BLACK_HAWK">
      <Text>Stealth Bomber</Text>
    </Row>
    <Row Tag="TXT_KEY_CIVILOPEDIA_UNIT_BLACK_HAWK_TEXT">
      <Text><!-- Add Civilopedia text here --></Text>
    </Row>
    <Row Tag="TXT_KEY_UNIT_BLACK_HAWK_STRATEGY">
      <Text>The Stealth Bomber is an upgraded bomber, possessing increased range, a greater Ranged Combat Strength, and an increased ability to avoid enemy anti-aircraft and fighters. The Stealth Bomber has the "air recon" ability, which means that everything within 6 tiles of its starting location is visible at the beginning of the turn. Note that Stealth Bombers cannot be transported aboard Carriers. See the rules on Aircraft for more information.</Text>
    </Row>
    <Row Tag="TXT_KEY_UNIT_HELP_BLACK_HAWK">
      <Text>A long-range Air Unit that rains death from above onto enemy Units and Cities.</Text>
    </Row>
  </Language_en_US>
</GameData>

I was trying to make new UnitClasses, but It doesn't work. In Database Log,

Invalid Reference on Civilization_UnitClassOverrides.UnitType - "UNIT_BLACK_HAWK" does not exist in Units
Invalid Reference on Civilization_UnitClassOverrides.UnitClassType - "UNITCLASS_BLACK_HAWK" does not exist in UnitClasses

See, It is Invalid reference. What's wrong about it?
 
There was probably another error in Database.log, somewhere along the lines of a language-tag not being unique.
More specifically, this is your problem:
Code:
<GameData>
    [..]
    <Language_en_US>
        <Row tag="TXT_KEY_UNIT_BLACK_HAWK">
            <Text>Black Hawk</Text>
        </Row>
    </Language_en_US>
 [..]
  <Language_en_US>
    <Row Tag="TXT_KEY_UNIT_BLACK_HAWK">
      <Text>Stealth Bomber</Text>
    </Row>
    [..]
  </Language_en_US>
</GameData>
You define the same textkey twice, causing an error and causing the game to discard this ENTIRE file. It so happens to be that your unittype and unitclass are defined here, meaning that they never get added as this file is discarded due to the language-error.
Remove either of the text-key definitions and it should run with no problems (as far as I can see from this single file)
 
Top Bottom