GUIDE: Adding new units

Thanks for the writeup. It was very useful. Using it I was mostly successful in adding a new unit, though I haven't yet modified the button.

I am unable to get a unit I am adding to be a unique unit. In fact, it seems any player civilization starts with one of the new units. I've added the unit to my new civilization in CIV4CivilizationInfos.xml in the unit tag, but not under free units, and it still shows up no matter which civilization I choose. Any ideas?
 
I was able to figure out the unique unit issue. When a unit class is created, it is available to all civilizations. If the unit you want to be a unique unit is the default unit type for this class, it won't work. The other civs will be able to implement the unit class, whose default unit is your "unique" unit.

To remedy this, a unique unit should be a member of an existing class type. The game then replaces the default unit type of that class with your new unit when playing the new Civ.
 
Are there any tips or tricks from experienced modders regarding how best to *delete* units from CIV IV? I am working on a medieval/fantasy mod. I have been able to add new units successfully, but when I try to replace or delete existing modern units I get all sorts of xml errors. I was thinking of just trying to add in some sort of prereq that would never happen so that they will never appear in game instead of deleting them - but am wondering if there are different/better suggestions. I just want to keep my fantasy/medieval kingdoms from building air craft carriers. :p Thanks for any suggestions! Great tutorial on adding units!
 
The prob with your idea is that the units will still be there in the Pedia which could be confusing for players.
The best way would just to reference out all the instances of the units i reckon. but that is a lot of files.
 
Hey, I really appreciate this tutorial.. but did it go smoothly? Nooo...

I replaced the Greeks with Byzantines, and I wanted to make a cataphract unique unit for them. I wasn't getting too involved.... modify a horse archer, and just use knight graphics until I could get better at graphic enhancement.

Ok, my Byzantines now have the cataphract as a unique unit, but it shows up twice on the build menu in any city, and when I finally build one, all I get is a glowing red ball. :confused:

How do I make a unique unit and have it use another units graphics? In Civ3, that was pretty easy to do. Now I'm just frustrated. :mad:

Thanks for the tutorial, just need some advice....
 
<UnitInfo>
<Class>UNITCLASS_HORSE_ARCHER</Class>
<Type>UNIT_CATAPHRACT</Type>
<UniqueNames/>
<Special>NONE</Special>
<Capture>NONE</Capture>
<Combat>UNITCOMBAT_MOUNTED</Combat>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
<Invisible>NONE</Invisible>
<SeeInvisible>NONE</SeeInvisible>
<Description>TXT_KEY_UNIT_CATAPHRACT</Description>
<Civilopedia>TXT_KEY_UNIT_CATAPHRACT_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_CATAPHRACT_STRATEGY</Strategy>
<Advisor>ADVISOR_MILITARY</Advisor>
<bAnimal>0</bAnimal>
<bFood>0</bFood>
<bNoBadGoodies>0</bNoBadGoodies>
<bOnlyDefensive>0</bOnlyDefensive>
<bNoCapture>0</bNoCapture>
<bRivalTerritory>0</bRivalTerritory>
<bMilitaryHappiness>1</bMilitaryHappiness>
<bMilitarySupport>1</bMilitarySupport>
<bMilitaryProduction>1</bMilitaryProduction>
<bPillage>1</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>1</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>
<UnitClassUpgrade>
<UnitClassUpgradeType>UNITCLASS_CAVALRY</UnitClassUpgradeType>
<bUnitClassUpgrade>1</bUnitClassUpgrade>
</UnitClassUpgrade>
</UnitClassUpgrades>
<UnitAIs>
<UnitAI>
<UnitAIType>UNITAI_ATTACK</UnitAIType>
<bUnitAI>1</bUnitAI>
</UnitAI>
<UnitAI>
<UnitAIType>UNITAI_PILLAGE</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>TECH_IRON_WORKING</PrereqTech>
<TechTypes>
<PrereqTech>TECH_HORSEBACK_RIDING</PrereqTech>
<PrereqTech>NONE</PrereqTech>
<PrereqTech>NONE</PrereqTech>
</TechTypes>
<BonusType>BONUS_HORSE</BonusType>
<PrereqBonuses>
<BonusType>BONUS_IRON</BonusType>
<BonusType>NONE</BonusType>
<BonusType>NONE</BonusType>
<BonusType>NONE</BonusType>
</PrereqBonuses>
<ProductionTraits/>
<Flavors/>
<iAIWeight>0</iAIWeight>
<iCost>70</iCost>
<iHurryCostModifier>0</iHurryCostModifier>
<iMinAreaSize>-1</iMinAreaSize>
<iMoves>2</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>8</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/>
<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>6</iCultureGarrison>
<iExtraCost>0</iExtraCost>
<iAsset>3</iAsset>
<iPower>6</iPower>
<UnitMeshGroups>
<iGroupSize>3</iGroupSize>
<fMaxSpeed>1.75</fMaxSpeed>
<iMeleeWaveSize>3</iMeleeWaveSize>
<iRangedWaveSize>3</iRangedWaveSize>
<UnitMeshGroup>
<iRequired>3</iRequired>
<EarlyArtDefineTag>ART_DEF_UNIT_CATAPHRACT</EarlyArtDefineTag>
</UnitMeshGroup>
</UnitMeshGroups>
<Button>,Art/Interface/Buttons/Units/Knight.dds</Button>
<HotKey/>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<FreePromotions>
<FreePromotion>
<PromotionType>PROMOTION_SHOCK</PromotionType>
<bFreePromotion>1</bFreePromotion>
</FreePromotion>
</FreePromotions>
</UnitInfo>
 
Gnostic: First, there actually is a Cataphract (Greek Companion) model in the game. I think it is in the Greek World mod folder if I remember correctly.

Then you need to define the texts for "Description", "Civilopedia" and "Strategy". Just writing a text string instead of TXT_KEY_UNIT_BLABLA works fine (unless you want multiple language supporrt). I.e.:

<Description>Cataphract</Description>
<Civilopedia>Some yadda yadda</Civilopedia>
<Strategy/> (Omits it completely.)

You also need to define ART_DEF_UNIT_CATAPHRACT or use ART_DEF_UNIT_KNIGHT instead.

Finally remove the "," before Art/Interface/Buttons/Units/Knight.dds or copy the entire button definition from the Knight. (This is actually an error in the tutorial.)

Hope it helps!
 
oh yeah was meant to fix that error, now it is fixed.

I think the problem is with your unit files rather than the xml (except for that comma but all that would do is mess up the icon).

make sure you dont change any of the names in the unit folder (i.e. nif and kf files.) post what you put in the art defines if you want because im sure that is your problem.

also you may want to change the button image.
 
<UnitArtInfo>
<Type>ART_DEF_UNIT_BYZANTINE_CATAPHRACT</Type>
<fScale>0.42</fScale>
<fInterfaceScale>0.9</fInterfaceScale>
<NIF>Art/Units/Unique/Greek/Cataphract/Cataphract.nif</NIF>
<KFM>Art/Units/Unique/Greek/Cataphract/Cataphract.kfm</KFM>
<SHADERNIF>Art/Units/Unique/Greek/Cataphract/Cataphract_FX.nif</SHADERNIF>
<ShadowDef>
<ShadowNIF>Art/Units/01_UnitShadows/HorseShadow.nif</ShadowNIF>
<ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
<fShadowScale>1.0</fShadowScale>
</ShadowDef>
<fBattleDistance>0.35</fBattleDistance>
<fRangedDeathTime>0.31</fRangedDeathTime>
<bActAsRanged>0</bActAsRanged>
<TrainSound>AS2D_UNIT_BUILD_UNIQUE_UNIT</TrainSound>
<AudioRunSounds>
<AudioRunTypeLoop/>
<AudioRunTypeEnd/>
</AudioRunSounds>
</UnitArtInfo>
 
Mumin: Thanks, I'll check that out... Alexander's companion cav would probably suffice. Being a Total War fan has really sparked my desire for Civ modding

Sovarn: There's my art defines excerpt. I left the extensions for knight, previously, but changed them to cataphract, while renaming every last file in the knight art folders that I unpacked and copied, rather laboriously I might add. :sad:

I will follow your collective suggestions, so hopefully it'll work. :) Thanks!!
 
OMG, I was shoving fast food in my mouth while following your suggestions, and IT WORKED. It was the comma... had to be... because your suggestions reverted my XMLs and art files back to where they were when I originally posted my problem.

I could totally hug you guys.... but I won't. :goodjob: Now... to practice some digi-art so I can make the graphics fit the unit... and finish my cheeseburger....

Peace, y'all
 
Rando said:
Are there any tips or tricks from experienced modders regarding how best to *delete* units from CIV IV? I am working on a medieval/fantasy mod. I have been able to add new units successfully, but when I try to replace or delete existing modern units I get all sorts of xml errors. I was thinking of just trying to add in some sort of prereq that would never happen so that they will never appear in game instead of deleting them - but am wondering if there are different/better suggestions. I just want to keep my fantasy/medieval kingdoms from building air craft carriers. :p Thanks for any suggestions! Great tutorial on adding units!

Set the unit's <iCost> value to -1 and nobody can build it, it's not the proper or complete solution but it's a lot easier the removing them from every file.
 
Thanks for the suggestion on unit value! I will try that. I had been trying to fix it by using a technology prereq, but that was also causing problems. The negative unit value might work better. Thanks again for the suggestion. :goodjob:
 
ONE SIMPLE QUESTION
I have disable the upgrade ability for some units in my costom assets( MG, Inf,Tank, Fighter and Bomber). So in single player, i play with that changes.
Now in MP games what could happend. Am i able to play with no problems and if im the host.
Anyone here could comment. Tanks
 
Okay....I'm creating a new Wehrmacht unit to replace the infantry for the Germans. How do I make it one of Germany's unique units?
 
Hi all ¡
I have a problem adding units I only could have added one, when I add more the previous one does not appear to construct it.

Some solution??
 
I feel so stupid and feel i should know this, I am new at modding and am trying to follow the guide on units and relating it to the Black Knight skin which looks really cool and am just trying to figure out in the instructions (I know this is bad english punctuation, this should not be one complete sentence) where do I stick the unzipped version of that file or the contents of it, in another words, what is already done in the file, what do you have to do, and where do you stick it all. I know I am probably not getting something I should be getting, but I would appreciate instructions from someone who put in the black knight skin step by step. Thanks to anyone who can help in advance. Ceaser kicks butt.
 
I've created a UU for my new civilization (which I'll post once I've fixed this). It is essentially another version of the mali skirmisher, and does not need any new graphics other than the button. It displays fine in all the menus (apart from the civilopedia where I can't get its entry to display anything other than the button for some reason) and there are no error messages in the game.

But whenever I try and build one in-game, Civ 4 bombs to the desktop (there are no error messages prior to this). Why should this be?
 
im having a small issue with this, but otherwise i've added 6 new custom units to my game thanx to this guide =D

whenever i build one of my custom units, instead of the defualt portriat showing next to the city, i get a black circle with a white ! in it. probably the same issue, whenever i have a custom unit selected, but hes off-screen, instead of the the pointy tab showing his portrait, i get a pink circle. obviously im missing either a piece of art or a link to a piece of art, any clues?

i made a custom civ at the same time, so its definately possible that i overlooked something in my gusto.

thanx for the write up!
 
Top Bottom