How do you enable a unit for the barbarians?

I looked for this and couldn't find it either. Let me know if you figure it out. I can add a unit that only they can produce in their cities, but it doesn't generate the unit as part of the barbarian spread process.
 
In the file CIV4CvilizationInfos.xml, all the Civs are defined. If you go down a ways in the file to where the barbs are defined, you'll see some code that looks like this:
Code:
            <Unit>
               <UnitClassType>UNITCLASS_SETTLER</UnitClassType>
               <UnitType>NONE</UnitType>
            </Unit>

The <UnitType>NONE</UnitType> means that the barbs can't build this unit. If you change the NONE to UNIT_SETTLER, they should be able to build the SETTLER unit. Or presumably you could just remove the whole UNIT declaration for the unit of interest.

--Kristine
 
Yeah, that will give them the ability to produce them in their cities, but they won't be spawned as part of the barbarian creation process (which as far as I can tell doesn't exist in any xml or python).
 
Kael said:
Yeah, that will give them the ability to produce them in their cities, but they won't be spawned as part of the barbarian creation process (which as far as I can tell doesn't exist in any xml or python).

I guess I misread what Thalassicus wrote. Sorry.

--Kristine
 
Yeah, I'm looking for a way to have them spawn for barbarians. :)

It would be really weird if this particular aspect is hardcoded (what units appear), it might have just been overlooked. My goal is to add a 1-1 Canoe "animal" to the early game for coastlines.

Got everything set up and couldn't find a boolean value for barbarian spawning. It's weird, because there's information in the unit listings for what terrain types animals can appear in (the "Native Terrain" and "Feature" lists). I tried duplicating the Lion and just renaming the unit type, but it didn't appear in the game, so it must be handled elsewhere.

I did a search for "lion", "animal", and "barbarian" in many of the scripting files too, didn't come up with anything.
 
Adding animals is easy. There is a boolean field that determines if something is an animal or not. If it is it spawns when the animals spawn. I have added Hill Giants, Skeletons and Tigers as animals and they spawn without a problem.

<bAnimal>1</bAnimal> in the unit definition sets this.

But animals have certain characteristics, most noteably they can't enter cultural borders, so they will never attack cities.

You may not be seeing your canoe because animals have a chance of appearing equal to 1 out of (whatever number you set) for the amount of available tiles that support them. So if there aren't very many coast tiles on a map, and the animal only exists on coast tiles there is a good chance one won't even appear.
 
I do have that, but after going through 50 turns or so none appear worldwide. By 1 out of X, what value are you referring to, the number of terrain types in TerrainNatives?

I have tried 4 test games using Shift+Enter to advance rapidly, have not seen the canoe spawn. Here is the unit listing:

Spoiler :
Code:
<UnitInfo>
	<Class>UNITCLASS_CANOE</Class>
	<Type>UNIT_CANOE</Type>
	<UniqueNames/>
	<Special>NONE</Special>
	<Capture>NONE</Capture>
	<Combat>UNITCOMBAT_NAVAL</Combat>
	<Domain>DOMAIN_SEA</Domain>
	<DefaultUnitAI>UNITAI_ATTACK_SEA</DefaultUnitAI>
	<Invisible>NONE</Invisible>
	<SeeInvisible>NONE</SeeInvisible>
	<Description>TXT_KEY_UNIT_CANOE</Description>
	<Civilopedia>TXT_KEY_UNIT_CANOE_PEDIA</Civilopedia>
	<Strategy>TXT_KEY_UNIT_ANIMAL_STRATEGY</Strategy>
	<Advisor>NONE</Advisor>
	<bAnimal>1</bAnimal>
	<bFood>0</bFood>
	<bNoBadGoodies>0</bNoBadGoodies>
	<bOnlyDefensive>0</bOnlyDefensive>
	<bNoCapture>0</bNoCapture>
	<bRivalTerritory>0</bRivalTerritory>
	<bMilitaryHappiness>0</bMilitaryHappiness>
	<bMilitarySupport>0</bMilitarySupport>
	<bMilitaryProduction>0</bMilitaryProduction>
	<bPillage>0</bPillage>
	<bSabotage>0</bSabotage>
	<bDestroy>0</bDestroy>
	<bStealPlans>0</bStealPlans>
	<bInvestigate>0</bInvestigate>
	<bCounterSpy>0</bCounterSpy>
	<bFound>0</bFound>
	<bGoldenAge>0</bGoldenAge>
	<bInvisible>0</bInvisible>
	<bFirstStrikeImmune>0</bFirstStrikeImmune>
	<bNoDefensiveBonus>1</bNoDefensiveBonus>
	<bIgnoreBuildingDefense>0</bIgnoreBuildingDefense>
	<bCanMoveImpassable>0</bCanMoveImpassable>
	<bFlatMovementCost>0</bFlatMovementCost>
	<bIgnoreTerrainCost>0</bIgnoreTerrainCost>
	<bNukeImmune>0</bNukeImmune>
	<bPrereqBonuses>0</bPrereqBonuses>
	<bPrereqReligion>0</bPrereqReligion>
	<bMechanized>1</bMechanized>
	<bRenderBelowWater>1</bRenderBelowWater>
	<UnitClassUpgrades/>
	<UnitAIs>
		<UnitAI>
			<UnitAIType>UNITAI_ATTACK_SEA</UnitAIType>
			<bUnitAI>1</bUnitAI>
		</UnitAI>
	</UnitAIs>
	<NotUnitAIs/>
	<Builds/>
	<ReligionSpreads/>
	<GreatPeoples/>
	<Buildings/>
	<ForceBuildings/>
	<HolyCity>NONE</HolyCity>
	<ReligionType>NONE</ReligionType>
	<StateReligion>NONE</StateReligion>
	<PrereqReligion>NONE</PrereqReligion>
	<PrereqBuilding>NONE</PrereqBuilding>
	<PrereqTech>NONE</PrereqTech>
	<TechTypes/>
	<BonusType>NONE</BonusType>
	<PrereqBonuses/>
	<ProductionTraits/>
	<Flavors/>
	<iAIWeight>0</iAIWeight>
	<iCost>-1</iCost>
	<iHurryCostModifier>0</iHurryCostModifier>
	<iMinAreaSize>-1</iMinAreaSize>
	<iMoves>1</iMoves>
	<iAirRange>0</iAirRange>
	<iNukeRange>-1</iNukeRange>
	<iWorkRate>0</iWorkRate>
	<iBaseDiscover>0</iBaseDiscover>
	<iDiscoverMultiplier>0</iDiscoverMultiplier>
	<iBaseHurry>0</iBaseHurry>
	<iHurryMultiplier>0</iHurryMultiplier>
	<iBaseTrade>0</iBaseTrade>
	<iTradeMultiplier>0</iTradeMultiplier>
	<iGreatWorkCulture>0</iGreatWorkCulture>
	<TerrainImpassables>
		<TerrainImpassable>
			<TerrainType>TERRAIN_OCEAN</TerrainType>
			<bTerrainImpassable>1</bTerrainImpassable>
		</TerrainImpassable>
	</TerrainImpassables>
	<FeatureImpassables/>
	<iCombat>1</iCombat>
	<iAirCombat>0</iAirCombat>
	<iAirCombatLimit>0</iAirCombatLimit>
	<iXPValueAttack>4</iXPValueAttack>
	<iXPValueDefense>2</iXPValueDefense>
	<iFirstStrikes>0</iFirstStrikes>
	<iChanceFirstStrikes>0</iChanceFirstStrikes>
	<iInterceptionProbability>0</iInterceptionProbability>
	<iEvasionProbability>0</iEvasionProbability>
	<iWithdrawalProb>0</iWithdrawalProb>
	<iCollateralDamage>0</iCollateralDamage>
	<iCollateralDamageLimit>0</iCollateralDamageLimit>
	<iCollateralDamageMaxUnits>0</iCollateralDamageMaxUnits>
	<iCityAttack>0</iCityAttack>
	<iCityDefense>0</iCityDefense>
	<iAnimalCombat>0</iAnimalCombat>
	<iHillsDefense>0</iHillsDefense>
	<TerrainNatives>
		<TerrainNative>
			<TerrainType>TERRAIN_COAST</TerrainType>
			<bTerrainNative>1</bTerrainNative>
		</TerrainNative>
	</TerrainNatives>
	<FeatureNatives/>
	<TerrainDefenses/>
	<FeatureDefenses/>
	<UnitClassAttackMods/>
	<UnitClassDefenseMods/>
	<UnitCombatMods/>
	<DomainMods/>
	<BonusProductionModifiers/>
	<iBombRate>0</iBombRate>
	<iBombardRate>0</iBombardRate>
	<SpecialCargo>NONE</SpecialCargo>
	<DomainCargo>NONE</DomainCargo>
	<iCargo>0</iCargo>
	<iConscription>0</iConscription>
	<iCultureGarrison>0</iCultureGarrison>
	<iExtraCost>0</iExtraCost>
	<iAsset>0</iAsset>
	<iPower>0</iPower>
	<UnitMeshGroups>
		<iGroupSize>1</iGroupSize>
		<fMaxSpeed>2.25</fMaxSpeed>
		<iMeleeWaveSize>1</iMeleeWaveSize>
		<iRangedWaveSize>1</iRangedWaveSize>
		<UnitMeshGroup>
			<iRequired>1</iRequired>
			<EarlyArtDefineTag>ART_DEF_UNIT_CANOE</EarlyArtDefineTag>
		</UnitMeshGroup>
	</UnitMeshGroups>
	<Button>,Art/Interface/Buttons/Units/Galley.dds,Art/Interface/Buttons/Unit_Resource_Atlas.dds,3,9</Button>
	<HotKey/>
	<bAltDown>0</bAltDown>
	<bShiftDown>0</bShiftDown>
	<bCtrlDown>0</bCtrlDown>
	<iHotKeyPriority>0</iHotKeyPriority>
	<FreePromotions/>
</UnitInfo>[/spoiler]

I have also tried it with UNITAI_ATTACK_ANIMAL and/or Combat NONE, with no effect. These are the other differences:

Code:
<Class>UNITCLASS_LION</Class> 	<Class>UNITCLASS_CANOE</Class>
<Type>UNIT_LION</Type> 		<Type>UNIT_CANOE</Type>
<Domain>DOMAIN_LAND</Domain>	<Domain>DOMAIN_SEA</Domain>
<bMechanized>0</bMechanized>	<bMechanized>1</bMechanized>
<TerrainImpassables/>		<TerrainImpassables>
<iCombat>2</iCombat>		<iCombat>1</iCombat>
<TerrainNatives>		<TerrainNatives>
<UnitMeshGroups>		<UnitMeshGroups>

The animal-spawn algorithm might not even check naval tiles, to save on processing. This is actually rather likely...although I couldn't get it to spawn through normal (later) barbarian appearences either through XML editing alone. It's possible that land animals might be the only way to spawn units as a barbarian currently.
 
My Hill Giant is attached (which works). The only difference I see is the hill giant has UNITAI_ANIMAL. I have never created anything I wanted to spawn as an animal with a different AI.

As for the 1 out of X I am talking about the entry in the CIV4HandicapInfo.xml file that has the following setting for each level of difficulty: <iUnownedTilesPerGameAnimal>50</iUnownedTilesPerGameAnimal>. The lower you make that number, the more likely you are to see animals.


Spoiler :

<UnitInfo>
<Class>UNITCLASS_HILL_GIANT</Class>
<Type>UNIT_HILL_GIANT</Type>
<UniqueNames/>
<Special>NONE</Special>
<Capture>NONE</Capture>
<Combat>UNITCOMBAT_GIANT</Combat>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_ANIMAL</DefaultUnitAI>
<Invisible>NONE</Invisible>
<SeeInvisible>NONE</SeeInvisible>
<Description>TXT_KEY_UNIT_HILL_GIANT</Description>
<Civilopedia>TXT_KEY_UNIT_HILL_GIANT_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_HILL_GIANT_STRATEGY</Strategy>
<Advisor>NONE</Advisor>
<bAnimal>1</bAnimal>
<bFood>0</bFood>
<bNoBadGoodies>0</bNoBadGoodies>
<bOnlyDefensive>0</bOnlyDefensive>
<bNoCapture>0</bNoCapture>
<bRivalTerritory>0</bRivalTerritory>
<bMilitaryHappiness>0</bMilitaryHappiness>
<bMilitarySupport>0</bMilitarySupport>
<bMilitaryProduction>0</bMilitaryProduction>
<bPillage>0</bPillage>
<bSabotage>0</bSabotage>
<bDestroy>0</bDestroy>
<bStealPlans>0</bStealPlans>
<bInvestigate>0</bInvestigate>
<bCounterSpy>0</bCounterSpy>
<bFound>0</bFound>
<bGoldenAge>0</bGoldenAge>
<bInvisible>0</bInvisible>
<bFirstStrikeImmune>0</bFirstStrikeImmune>
<bNoDefensiveBonus>1</bNoDefensiveBonus>
<bIgnoreBuildingDefense>0</bIgnoreBuildingDefense>
<bCanMoveImpassable>0</bCanMoveImpassable>
<bFlatMovementCost>0</bFlatMovementCost>
<bIgnoreTerrainCost>0</bIgnoreTerrainCost>
<bNukeImmune>0</bNukeImmune>
<bPrereqBonuses>0</bPrereqBonuses>
<bPrereqReligion>0</bPrereqReligion>
<bMechanized>0</bMechanized>
<UnitClassUpgrades/>
<UnitAIs>
<UnitAI>
<UnitAIType>UNITAI_ANIMAL</UnitAIType>
<bUnitAI>1</bUnitAI>
</UnitAI>
</UnitAIs>
<NotUnitAIs/>
<Builds/>
<ReligionSpreads/>
<GreatPeoples/>
<Buildings/>
<ForceBuildings/>
<HolyCity>NONE</HolyCity>
<ReligionType>NONE</ReligionType>
<StateReligion>NONE</StateReligion>
<PrereqReligion>NONE</PrereqReligion>
<PrereqBuilding>NONE</PrereqBuilding>
<PrereqTech>NONE</PrereqTech>
<TechTypes/>
<BonusType>NONE</BonusType>
<PrereqBonuses/>
<ProductionTraits/>
<Flavors/>
<iAIWeight>0</iAIWeight>
<iCost>-1</iCost>
<iHurryCostModifier>0</iHurryCostModifier>
<iMinAreaSize>-1</iMinAreaSize>
<iMoves>1</iMoves>
<iAirRange>0</iAirRange>
<iNukeRange>-1</iNukeRange>
<iWorkRate>0</iWorkRate>
<iBaseDiscover>0</iBaseDiscover>
<iDiscoverMultiplier>0</iDiscoverMultiplier>
<iBaseHurry>0</iBaseHurry>
<iHurryMultiplier>0</iHurryMultiplier>
<iBaseTrade>0</iBaseTrade>
<iTradeMultiplier>0</iTradeMultiplier>
<iGreatWorkCulture>0</iGreatWorkCulture>
<TerrainImpassables/>
<FeatureImpassables/>
<iCombat>6</iCombat>
<iAirCombat>0</iAirCombat>
<iAirCombatLimit>0</iAirCombatLimit>
<iXPValueAttack>8</iXPValueAttack>
<iXPValueDefense>4</iXPValueDefense>
<iFirstStrikes>0</iFirstStrikes>
<iChanceFirstStrikes>0</iChanceFirstStrikes>
<iInterceptionProbability>0</iInterceptionProbability>
<iEvasionProbability>0</iEvasionProbability>
<iWithdrawalProb>0</iWithdrawalProb>
<iCollateralDamage>0</iCollateralDamage>
<iCollateralDamageLimit>0</iCollateralDamageLimit>
<iCollateralDamageMaxUnits>0</iCollateralDamageMaxUnits>
<iCityAttack>0</iCityAttack>
<iCityDefense>0</iCityDefense>
<iAnimalCombat>0</iAnimalCombat>
<iHillsDefense>0</iHillsDefense>
<TerrainNatives>
<TerrainNative>
<TerrainType>TERRAIN_HILL</TerrainType>
<bTerrainNative>1</bTerrainNative>
</TerrainNative>
<TerrainNative>
<TerrainType>TERRAIN_DESERT</TerrainType>
<bTerrainNative>1</bTerrainNative>
</TerrainNative>
</TerrainNatives>
<FeatureNatives/>
<TerrainDefenses/>
<FeatureDefenses/>
<UnitClassAttackMods/>
<UnitClassDefenseMods/>
<UnitCombatMods/>
<DomainMods/>
<BonusProductionModifiers/>
<iBombRate>0</iBombRate>
<iBombardRate>0</iBombardRate>
<SpecialCargo>NONE</SpecialCargo>
<DomainCargo>NONE</DomainCargo>
<iCargo>0</iCargo>
<iConscription>0</iConscription>
<iCultureGarrison>0</iCultureGarrison>
<iExtraCost>0</iExtraCost>
<iAsset>2</iAsset>
<iPower>2</iPower>
<UnitMeshGroups>
<iGroupSize>1</iGroupSize>
<fMaxSpeed>1.00</fMaxSpeed>
<iMeleeWaveSize>1</iMeleeWaveSize>
<iRangedWaveSize>0</iRangedWaveSize>
<UnitMeshGroup>
<iRequired>1</iRequired>
<EarlyArtDefineTag>ART_DEF_UNIT_HILL_GIANT</EarlyArtDefineTag>
</UnitMeshGroup>
</UnitMeshGroups>
<Button>Art/Interface/Buttons/Units/Hillgiant.dds</Button>
<HotKey/>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<FreePromotions>
<FreePromotion>
<PromotionType>PROMOTION_SENTRY</PromotionType>
<bFreePromotion>1</bFreePromotion>
</FreePromotion>
</FreePromotions>
</UnitInfo>
 
Good information. I was looking for this too.
(the search function of this forum works great)
 
Back
Top Bottom