How do I add a UU only purchasable with faith?

Gushis

Chieftain
Joined
Feb 6, 2017
Messages
50
I'm trying to do that, the unit works fine but I can't purchase it like I can purchase a missionary. How does the game determine religious units and when they can be bought?

Spoiler :

Code:
<GameData>
    <UnitClasses>
        <Row>
            <Type>UNITCLASS_PRIEST</Type>
            <Description></Description>
            <DefaultUnit>UNIT_FRIGATE</DefaultUnit>
        </Row>
        <Row>
            <Type>UNITCLASS_CTHUN</Type>
            <Description></Description>
            <DefaultUnit>UNIT_FRIGATE</DefaultUnit>
        </Row>
    </UnitClasses>
   
    <Units>
        <Row>
            <Type>UNIT_CTHUN</Type>
            <Description>TXT_KEY_UNIT_CTHUN</Description>
            <Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_CTHUN_TEXT</Civilopedia>
            <Strategy>TXT_KEY_UNIT_CTHUN_STRATEGY</Strategy>
            <Help>TXT_KEY_UNIT_HELP_CTHUN</Help>
            <Requirements></Requirements>
            <Combat>450</Combat>
            <RangedCombat>6666</RangedCombat>
            <Cost>-1</Cost>
            <FaithCost>7500</FaithCost>
            <RequiresFaithPurchaseEnabled>1</RequiresFaithPurchaseEnabled>
            <PurchaseOnly>0</PurchaseOnly>
            <MoveAfterPurchase>0</MoveAfterPurchase>
            <Moves>4</Moves>
            <Immobile>0</Immobile>
            <Range>2</Range>
            <BaseSightRange>2</BaseSightRange>
            <Class>UNITCLASS_CTHUN</Class>
            <Special></Special>
            <Capture></Capture>
            <CombatClass>UNITCOMBAT_ARCHER</CombatClass>
            <Domain>DOMAIN_LAND</Domain>
            <CivilianAttackPriority></CivilianAttackPriority>
            <DefaultUnitAI>UNITAI_RANGED</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></PrereqTech>
            <ObsoleteTech></ObsoleteTech>
            <GoodyHutUpgradeUnitClass></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></PolicyType>
            <RangedCombatLimit>0</RangedCombatLimit>
            <XPValueAttack>0</XPValueAttack>
            <XPValueDefense>0</XPValueDefense>
            <SpecialCargo></SpecialCargo>
            <DomainCargo></DomainCargo>
            <Conscription>0</Conscription>
            <ExtraMaintenanceCost>0</ExtraMaintenanceCost>
            <NoMaintenance>1</NoMaintenance>
            <Unhappiness>0</Unhappiness>
            <UnitArtInfo>ART_DEF_UNIT_MISSIONARY</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>67</UnitFlagIconOffset>
            <PortraitIndex>20</PortraitIndex>
            <IconAtlas>UNIT_ATLAS_2</IconAtlas>
            <UnitFlagAtlas>UNIT_FLAG_ATLAS</UnitFlagAtlas>
        </Row>
    </Units>

    <Unit_AITypes>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <UnitAIType>UNITAI_RANGED</UnitAIType>
        </Row>
    </Unit_AITypes>
    <!-- Unit_Buildings -->
    <!-- Unit_BuildingClassRequireds -->
    <!-- Unit_ProductionModifierBuildings -->
    <!-- Unit_Builds -->
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <PromotionType>PROMOTION_ONLY_DEFENSIVE</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <PromotionType>PROMOTION_SECOND_ATTACK</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <PromotionType>PROMOTION_BLITZ</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <PromotionType>PROMOTION_LOGISTICS</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <PromotionType>PROMOTION_INVULNERABIILITY</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <PromotionType>PROMOTION_RESTLESSNESS</PromotionType>
        </Row>

    </Unit_FreePromotions>
    <Unit_Flavors>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <FlavorType>FLAVOR_OFFENSE</FlavorType>
            <Flavor>666</Flavor>
        </Row>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <FlavorType>FLAVOR_DEFENSE</FlavorType>
            <Flavor>666</Flavor>
        </Row>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <FlavorType>FLAVOR_RANGED</FlavorType>
            <Flavor>10</Flavor>
        </Row>
    </Unit_Flavors>
    <!-- Unit_GreatPersons -->
    <!-- Unit_ResourceQuantityRequirements -->
    <!-- Unit_UniqueNames -->
    <!-- Unit_YieldFromKills -->
    <!-- Unit_NotAITypes -->
    <!-- Unit_ProductionTraits -->
    <!-- Unit_TechTypes -->
    <!-- UnitPromotions_CivilianUnitType -->
    <UnitGameplay2DScripts>
        <Row>
            <UnitType>UNIT_CTHUN</UnitType>
            <SelectionSound>AS2D_SELECT_CROSSBOWMAN</SelectionSound>
            <FirstSelectionSound>AS2D_BIRTH_CROSSBOWMAN</FirstSelectionSound>
        </Row>
    </UnitGameplay2DScripts>

    <Language_en_US>
        <Row Tag="TXT_KEY_UNIT_CTHUN">
            <Text>C'thun</Text>
        </Row>
        <Row Tag="TXT_KEY_CIVILOPEDIA_UNITS_CTHUN_TEXT">
            <Text>
                <!-- Add Civilopedia text here -->
            </Text>
        </Row>
        <Row Tag="TXT_KEY_UNIT_CTHUN_STRATEGY">
            <Text>I bleed for C'thun! Can attack 5 times.</Text>
        </Row>
        <Row Tag="TXT_KEY_UNIT_HELP_CTHUN">
            <Text>I bleed for C'thun! Can Attack 5 times.</Text>
        </Row>
    </Language_en_US>




<Units>
    <Row>
        <Type>UNIT_PRIEST</Type>
        <Description>TXT_KEY_UNIT_PRIEST</Description>
        <Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_PRIEST_TEXT</Civilopedia>
        <Strategy>TXT_KEY_UNIT_PRIEST_STRATEGY</Strategy>
        <Help>TXT_KEY_UNIT_HELP_PRIEST</Help>
        <Requirements></Requirements>
        <Combat>250</Combat>
        <RangedCombat>0</RangedCombat>
        <Cost>-1</Cost>
        <FaithCost>400</FaithCost>
        <RequiresFaithPurchaseEnabled>1</RequiresFaithPurchaseEnabled>
        <PurchaseOnly>0</PurchaseOnly>
        <MoveAfterPurchase>0</MoveAfterPurchase>
        <Moves>4</Moves>
        <Immobile>0</Immobile>
        <Range>1</Range>
        <BaseSightRange>2</BaseSightRange>
        <Class>UNITCLASS_PRIEST</Class>
        <Special></Special>
        <Capture></Capture>
        <CombatClass>UNITCOMBAT_WARRIOR</CombatClass>
        <Domain>DOMAIN_LAND</Domain>
        <CivilianAttackPriority></CivilianAttackPriority>
        <DefaultUnitAI>UNITAI_MELEE</DefaultUnitAI>
        <Food>0</Food>
        <NoBadGoodies>0</NoBadGoodies>
        <RivalTerritory>0</RivalTerritory>
        <MilitarySupport>0</MilitarySupport>
        <MilitaryProduction>0</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>1</Suicide>
        <CaptureWhileEmbarked>0</CaptureWhileEmbarked>
        <PrereqTech></PrereqTech>
        <ObsoleteTech></ObsoleteTech>
        <GoodyHutUpgradeUnitClass></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></PolicyType>
        <RangedCombatLimit>0</RangedCombatLimit>
        <XPValueAttack>0</XPValueAttack>
        <XPValueDefense>0</XPValueDefense>
        <SpecialCargo></SpecialCargo>
        <DomainCargo></DomainCargo>
        <Conscription>0</Conscription>
        <ExtraMaintenanceCost>0</ExtraMaintenanceCost>
        <NoMaintenance>1</NoMaintenance>
        <Unhappiness>0</Unhappiness>
        <UnitArtInfo>ART_DEF_UNIT_U_PRIEST</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>4</UnitFlagIconOffset>
        <PortraitIndex>3</PortraitIndex>
        <IconAtlas>CTHUNCIV_COLOR_ATLAS_LEGENDS</IconAtlas>
        <UnitFlagAtlas>CTHUNCIV_COLOR_ATLAS_LEGENDS</UnitFlagAtlas>
    </Row>
</Units>
   
    <Unit_AITypes>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <UnitAIType>UNITAI_RANGED</UnitAIType>
        </Row>
    </Unit_AITypes>
    <!-- Unit_Buildings -->
    <!-- Unit_BuildingClassRequireds -->
    <!-- Unit_ProductionModifierBuildings -->
    <!-- Unit_Builds -->
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <PromotionType>PROMOTION_SMALL_CITY_PENALTY</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <PromotionType>PROMOTION_CITY_PENALTY</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <PromotionType>PROMOTION_DEFENSE_PENALTY</PromotionType>
        </Row>
    </Unit_FreePromotions>
    <Unit_Flavors>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <FlavorType>FLAVOR_OFFENSE</FlavorType>
            <Flavor>10</Flavor>
        </Row>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <FlavorType>FLAVOR_DEFENSE</FlavorType>
            <Flavor>10</Flavor>
        </Row>
    </Unit_Flavors>
    <!-- Unit_GreatPersons -->
    <!-- Unit_ResourceQuantityRequirements -->
    <!-- Unit_UniqueNames -->
    <Unit_YieldFromKills>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <YieldType>YIELD_FAITH</YieldType>
            <Yield>2500</Yield>
        </Row>
    </Unit_YieldFromKills>
    <!-- Unit_NotAITypes -->
    <!-- Unit_ProductionTraits -->
    <!-- Unit_TechTypes -->
    <!-- UnitPromotions_CivilianUnitType -->
    <UnitGameplay2DScripts>
        <Row>
            <UnitType>UNIT_PRIEST</UnitType>
            <SelectionSound>AS2D_SELECT_CROSSBOWMAN</SelectionSound>
            <FirstSelectionSound>AS2D_BIRTH_CROSSBOWMAN</FirstSelectionSound>
        </Row>
    </UnitGameplay2DScripts>

    <Language_en_US>
        <Row Tag="TXT_KEY_UNIT_PRIEST">
            <Text>Priest</Text>
        </Row>
        <Row Tag="TXT_KEY_CIVILOPEDIA_UNITS_PRIEST_TEXT">
            <Text>
                <!-- Add Civilopedia text here -->
            </Text>
        </Row>
        <Row Tag="TXT_KEY_UNIT_PRIEST_STRATEGY">
            <Text>The Priest is the Qiraji unique unit, replacing the Crossbowman. The Chu-Ko-Nu is slightly less powerful than the Crossbowman, but it can attack twice during a turn, giving it a hefty offensive punch. This unit is particularly deadly when garrisoned in a city that is under attack.</Text>
        </Row>
        <Row Tag="TXT_KEY_UNIT_HELP_PRIEST">
            <Text>Medieval ranged infantry Unit. Only the Chinese may build it. This Unit may fire twice in one turn, unlike the Crossbowman which it replaces.</Text>
        </Row>
    </Language_en_US>
   
   
</GameData>
 
see table Belief_EraFaithUnitPurchase in file Civ5Beliefs.xml

The way you are defining the units they are combat units instead of religious units.

Faith purchasing of non-Missionary, non-Inquisitor, and non-Great-People units is based solely on whether the player has Holy Warriors or Religous Fervor beliefs.

In order to implement what you are trying you would need to "fake-out" the game to some degree with an lua script that only allows the unit to be purchased when the player has the correct amount of faith. But the actual purchasing would be done with gold, and then the lua script would "return" the gold to the player and subtract the requisite amount of faith. All very Kludgey and not something for the unitiated in lua to attempt, really.

edit -- as a side note, the game really does not like unique versions of MIssionaries, Inquisitors, and Great Prophets, if that was what you were going after.
 
Last edited:
see table Belief_EraFaithUnitPurchase in file Civ5Beliefs.xml

The way you are defining the units they are combat units instead of religious units.

Faith purchasing of non-Missionary, non-Inquisitor, and non-Great-People units is based solely on whether the player has Holy Warriors or Religous Fervor beliefs.

In order to implement what you are trying you would need to "fake-out" the game to some degree with an lua script that only allows the unit to be purchased when the player has the correct amount of faith. But the actual purchasing would be done with gold, and then the lua script would "return" the gold to the player and subtract the requisite amount of faith. All very Kludgey and not something for the unitiated in lua to attempt, really.

edit -- as a side note, the game really does not like unique versions of MIssionaries, Inquisitors, and Great Prophets, if that was what you were going after.

Thanks! I think I will simply add an upgrade option for the Great Prophet into UNITCLASS_PRIEST (my UU), which has Great Prophet as its default but in my civ it is replaced by Priest, if I managed to explain myself in a way that makes sense. I'm not using LUA because I'm going to be using this mod with my friends and only XML is simple to implement into multiplayer.

EDIT: I think I'll make a dummy unique building called "Summon: whatever" purchasable with faith that summons the unit instead. Do you know how I can make a building purchasable with faith?
 
Last edited:
Buildings, like units, are only purchasable via faith based on the Beliefs a player selects for their religion. The same issues with attempting to get around this restriction apply as apply to units.
 
Back
Top Bottom