Unit Creating

MajorWinters

Chieftain
Joined
Jul 22, 2008
Messages
83
I've been wanting to create some unique modern units, like a unique jet fighter for American, like the F-22, or a unique modern armor for Germany, like the Leopard. However, all the tutorials i've found are way over my head. I was thinking maybe i could just copy an existing unit's details, like the modern armor, rename it and change its stats to what i want. However i"m unsure as to what exactly i'd need to copy and what to edit to do this. If anyone could explain to me how i could do this, or direct me to a simple and easy to understand tutorial i'd much appreciate it.
 
This is an excellent tutorial on how to add units:

Guide: How to add Units to Civ4

For UUs look at a normal civ4 UU the firaxis devs set up, and see how it's done. It's pretty simple, basically you need to create the art entry in ArtDefinesUnit (the tutorial describes this), then copy the default unit entry you want it to be a UU for in UnitInfos and change the UnitType tag, then finally apply the change to CivilizationInfos so that that unique unit replaces the default one for the civilization you set it to.

XML is easy to understand, it's intuitive. If you choose to you can look at it and throw up your hands and give up on it, and claim you don't understand. Alot of people seem to do that. But if you just look at it, your human brain will figure it out pretty quickly. Especially if you read the tutorial. Anyway that tutorial I linked you to is the tutorial I first used to mod civ4, by adding new units. I had no prior knowledge of modding at all at the time, and found it very concise, just needed to follow directions properly to get things to work right.
 
To create a new unit all you have to do is open the CIV4UnitInfos.xml.

Before you do any editing to it however, I would advise you to make a backup of the original file in case you make any mistakes.


After you have done so, and opened the file find the unit you wish to replace.
(For example, if you wan't to make a F-22 unit to Replace the Jet Fighter you should find the jet fighter unit.)

Copy the entire unit (starting and ending with the UnitInfo tag.)
Spoiler example :
<UnitInfo>
<Class>UNITCLASS_JET_FIGHTER</Class>
<Type>UNIT_JET_FIGHTER</Type> - The name of the unit
<UniqueNames/>
<Special>SPECIALUNIT_FIGHTER</Special>
<Capture>NONE</Capture>
<Combat>UNITCOMBAT_AIR</Combat>
<Domain>DOMAIN_AIR</Domain>
<DefaultUnitAI>UNITAI_DEFENSE_AIR</DefaultUnitAI>
<Invisible>NONE</Invisible>
<SeeInvisible>NONE</SeeInvisible>
<Description>TXT_KEY_UNIT_JET_FIGHTER</Description>
<Civilopedia>TXT_KEY_UNIT_JET_FIGHTER_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_JET_FIGHTER_STRATEGY</Strategy>
<Advisor>ADVISOR_MILITARY</Advisor>
<bAnimal>0</bAnimal>
<bFood>0</bFood>
<bNoBadGoodies>0</bNoBadGoodies>
<bOnlyDefensive>0</bOnlyDefensive>
<bNoCapture>0</bNoCapture>
<bQuickCombat>0</bQuickCombat>
<bRivalTerritory>0</bRivalTerritory>
<bMilitaryHappiness>0</bMilitaryHappiness>
<bMilitarySupport>1</bMilitarySupport>
<bMilitaryProduction>1</bMilitaryProduction>
<bPillage>0</bPillage>
<bSpy>0</bSpy>
<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>0</bNoDefensiveBonus>
<bIgnoreBuildingDefense>1</bIgnoreBuildingDefense>
<bCanMoveImpassable>0</bCanMoveImpassable>
<bCanMoveAllTerrain>0</bCanMoveAllTerrain>
<bFlatMovementCost>0</bFlatMovementCost>
<bIgnoreTerrainCost>0</bIgnoreTerrainCost>
<bNukeImmune>0</bNukeImmune>
<bPrereqBonuses>0</bPrereqBonuses>
<bPrereqReligion>0</bPrereqReligion>
<bMechanized>1</bMechanized>
<bSuicide>0</bSuicide>
<bHiddenNationality>0</bHiddenNationality>
<bAlwaysHostile>0</bAlwaysHostile>
<UnitClassUpgrades/>
<UnitClassTargets/>
<UnitCombatTargets/>
<UnitClassDefenders/>
<UnitCombatDefenders/>
<FlankingStrikes/>
<UnitAIs>
<UnitAI>
<UnitAIType>UNITAI_DEFENSE_AIR</UnitAIType>
<bUnitAI>1</bUnitAI>
</UnitAI>
<UnitAI>
<UnitAIType>UNITAI_CARRIER_AIR</UnitAIType>
<bUnitAI>1</bUnitAI>
</UnitAI>
</UnitAIs>
<NotUnitAIs/>
<Builds/>
<ReligionSpreads/>
<CorporationSpreads/>
<GreatPeoples/>
<Buildings/>
<ForceBuildings/>
<HolyCity>NONE</HolyCity>
<ReligionType>NONE</ReligionType>
<StateReligion>NONE</StateReligion>
<PrereqReligion>NONE</PrereqReligion>
<PrereqCorporation>NONE</PrereqCorporation>
<PrereqBuilding>NONE</PrereqBuilding>
<PrereqTech>TECH_ADVANCED_FLIGHT</PrereqTech>
<TechTypes/>
<BonusType>BONUS_OIL</BonusType> - Resources required to build the unit
<PrereqBonuses>
<BonusType>BONUS_ALUMINUM</BonusType>
<BonusType>NONE</BonusType>
<BonusType>NONE</BonusType>
<BonusType>NONE</BonusType>
</PrereqBonuses>
<ProductionTraits/>
<Flavors/>
<iAIWeight>0</iAIWeight>
<iCost>150</iCost> - Cost in hammers
<iHurryCostModifier>0</iHurryCostModifier>
<iAdvancedStartCost>100</iAdvancedStartCost>
<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
<iMinAreaSize>-1</iMinAreaSize>
<iMoves>1</iMoves>
<bNoRevealMap>0</bNoRevealMap>
<iAirRange>10</iAirRange>
<iAirUnitCap>1</iAirUnitCap>
<iDropRange>0</iDropRange>
<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>
<iEspionagePoints>0</iEspionagePoints>
<TerrainImpassables/>
<FeatureImpassables/>
<TerrainPassableTechs/>
<FeaturePassableTechs/>
<iCombat>0</iCombat> <iCombatLimit>0</iCombatLimit>
<iAirCombat>24</iAirCombat>
<iAirCombatLimit>50</iAirCombatLimit>
<iXPValueAttack>4</iXPValueAttack>
<iXPValueDefense>4</iXPValueDefense>
<iFirstStrikes>0</iFirstStrikes>
<iChanceFirstStrikes>0</iChanceFirstStrikes>
<iInterceptionProbability>100</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>
<iHillsAttack>0</iHillsAttack>
<iHillsDefense>0</iHillsDefense>
<TerrainNatives/>
<FeatureNatives/>
<TerrainAttacks/>
<TerrainDefenses/>
<FeatureAttacks/>
<FeatureDefenses/>
<UnitClassAttackMods/>
<UnitClassDefenseMods/>
<UnitCombatMods/>
<UnitCombatCollateralImmunes/>
<DomainMods/>
<BonusProductionModifiers/>
<iBombRate>12</iBombRate>
<iBombardRate>0</iBombardRate>
<SpecialCargo>NONE</SpecialCargo>
<DomainCargo>NONE</DomainCargo>
<iCargo>0</iCargo>
<iConscription>0</iConscription>
<iCultureGarrison>0</iCultureGarrison>
<iExtraCost>0</iExtraCost>
<iAsset>4</iAsset>
<iPower>24</iPower>
<UnitMeshGroups>
<iGroupSize>1</iGroupSize>
<fMaxSpeed>0.75</fMaxSpeed>
<fPadTime>1</fPadTime>
<iMeleeWaveSize>1</iMeleeWaveSize>
<iRangedWaveSize>1</iRangedWaveSize>
<UnitMeshGroup>
<iRequired>1</iRequired>
<EarlyArtDefineTag>ART_DEF_UNIT_JET_FIGHTER</EarlyArtDefineTag>
</UnitMeshGroup>
</UnitMeshGroups>
<FormationType>FORMATION_TYPE_MACHINE</FormationType>
<HotKey/>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<FreePromotions/>
<LeaderPromotion>NONE</LeaderPromotion>
<iLeaderExperience>0</iLeaderExperience>
</UnitInfo>


Than edit the values you want.

PS. I have added some notes to the code.


PPS. Ninjad... take a look at the turtorial as well. Good stuff.
 
@PPQ_Purple

You don't don't need to back up the originals, because you should never alter the original files! There is no reason whatsoever to alter the original game files. I can tell you're trying to give helpful advice, but in reality you're giving horrible advice, and just setting people up for failure.


Any file you plan to alter, just take it, and copy it to the custom assets folder. Then make your changes to the file from there. The game automatically loads custom assets so your changes will take effect unless you're playing multiplayer, and if you want to mod your game for mutiplayer you should make a proper mod.

Again, there is no reason whatsoever to alter your BtS files. Copy them and put the copies in custom assets and then alter those.
 
This is an excellent tutorial on how to add units:

Guide: How to add Units to Civ4

For UUs look at a normal civ4 UU the firaxis devs set up, and see how it's done. It's pretty simple, basically you need to create the art entry in ArtDefinesUnit (the tutorial describes this), then copy the default unit entry you want it to be a UU for in UnitInfos and change the UnitType tag, then finally apply the change to CivilizationInfos so that that unique unit replaces the default one for the civilization you set it to.

XML is easy to understand, it's intuitive. If you choose to you can look at it and throw up your hands and give up on it, and claim you don't understand. Alot of people seem to do that. But if you just look at it, your human brain will figure it out pretty quickly. Especially if you read the tutorial. Anyway that tutorial I linked you to is the tutorial I first used to mod civ4, by adding new units. I had no prior knowledge of modding at all at the time, and found it very concise, just needed to follow directions properly to get things to work right.

I tried following that guide, but like i said over my head. I just can't seem to follow what he is doing, its my fault i know its just when he says "copy such and such folder" i can't find it. I know how to change unit stats and names, I just don't know how to add new units, actually hold on, i may have just solved my problem, can someone tell me how i could make a double of a unit? Something like PPq said, copy an existing units files, and maybe just paste them right where i found them (which would effectively make there be 2 options for building a tank even though they're the same). I could then just rename and re-stat the copy, could someone tell me how to do that, in the mean time i will try to use that tutorial, but i can't seem to find the "art" files for jet fighters, or modern armor for that matter.
 
It's not over your head. Sorry you're just giving up and not trying, it's actually very succinct and doesn't require any prior knowledge of programming to understand, all it requires is being able to read and write at a 7th grade level. Your aversion to it is because it "looks complex", you see
<UnitInfo>
...
</UnitInfo>
And throw up your hands because it doesn't look like what you're used to. If you want to pretend you can't understand it, that's fine, but there is no way to write or explain how to add units in a more concise manner.
 
Well, whatever you want to think, i'm saying i can't find the files, i've combed the "arts" folder 3 times and there is no "jet fighter" or modern armor", and a few others actually (for reference i was attempting to use that tutorial and instead of the "warrior" i thought i'd use a unit i wanted). I have used xml before, i;ve changed unit stats and i know its not complex, i just can't follow how to make a NEW unit, i can change existing ones fine. Anyway, i actually just figured it out, i have successfully made a copy of the jet fighter using the unitinfos.xml, and it is usable in game, i just need to know how to make it a unqiue unit for America, could you tell me how to do that? cus other then that i have made it to what i want, oh wait how do i change its name? it still says "jet fighter" but i thought i had changed it to F-22.
 
So the issue wasn't that you didn't understand it, it was that you can't find the art. That's a different question. The art is packed, to check it out you'll need to unpack it. That isn't necessary though as you're going to want to use a J-22 or other unique models not in the default civ4 art. Look through the database to find the art. Then you drop it in the art folder of your custom assets/mod (not your core files!), and set the art in the ArtDefinesUnit file.

As far as UUs go you will need to change the Type, while leaving the UnitClass the same if you want to make it a UU. Then to change the name, you need to change the text key entries (leave the starting convention the same TXT_KEY_UNIT_ or whatever it is for units, as the text files use these openers to find the strings faster, like looking up names in a dictionary it's easier to search by alphabetical order then compare each name in the whole book). When you create a new text entry you'll need to define it in a text file. I recommend you copy a small text file, delete everything except for a single entry, and use that, then just add new entries as you add new units. You'll be happier if you keep your changes separate in the text files in the long run, as it makes merging in other stuff so much easier.
 
So the issue wasn't that you didn't understand it, it was that you can't find the art. That's a different question. The art is packed, to check it out you'll need to unpack it. That isn't necessary though as you're going to want to use a J-22 or other unique models not in the default civ4 art. Look through the database to find the art. Then you drop it in the art folder of your custom assets/mod (not your core files!), and set the art in the ArtDefinesUnit file.

As far as UUs go you will need to change the Type, while leaving the UnitClass the same if you want to make it a UU. Then to change the name, you need to change the text key entries (leave the starting convention the same TXT_KEY_UNIT_ or whatever it is for units, as the text files use these openers to find the strings faster, like looking up names in a dictionary it's easier to search by alphabetical order then compare each name in the whole book). When you create a new text entry you'll need to define it in a text file. I recommend you copy a small text file, delete everything except for a single entry, and use that, then just add new entries as you add new units. You'll be happier if you keep your changes separate in the text files in the long run, as it makes merging in other stuff so much easier.

But how do i specify who's unique unit it is?
 
in CivilizationInfos. Search for _JAGUAR or something like that that will direct you to a unique unit and it'll be self aparent once you see it being used.
 
@PPQ_Purple

You don't don't need to back up the originals, because you should never alter the original files! There is no reason whatsoever to alter the original game files. I can tell you're trying to give helpful advice, but in reality you're giving horrible advice, and just setting people up for failure.
Personally, I have my own modifications going and have had many cases when I wanted to make a slight change to an XML or python file and ended up ruining it and having to backtrack through the files to find why the game is crashing.

He asked how to add a new unit, and I provided him with the data on how to do so.

I newer said that he should be doing any modifications directly to the game folder.
What I did do is give him the name of the file as he requested and explained how to make the modifications that he wants again as he requested.

Wehter he wants to use it to change the original game or some mod, or what ever he wants I did not want to go into that part.

All I said is that since he mentioned he would want to add multiple units and not just one, he might want to back the files up after each change.

I don't know why people are so incompetent at understanding things in context and so insanely agresive. This is not the first time that people have not stoped to think before shouting at me.
 
I am having an issue that seems to be addressed on this thread. Hope someone is watching...

I have created a UU scout, using the methods described above (the very same ones I've used for year on CIV vanilla). However, now, as I start on ROM:AND, I am experiencing an odd issue. Despite listing the unit under my civ in civ4civilizationinfo.xml; AI civs are able to make my UU. I've even adjusted the xml to require the UU to require my UB and it is still allowing AI civs to make my unit. Am I missing something?
 
Probably your UU is set as the default unit.
Setting your UB makes no difference, since it is the same building_class as the default one. The code is checking for building_class and not building_type.
 
Probably your UU is set as the default unit.
Setting your UB makes no difference, since it is the same building_class as the default one. The code is checking for building_class and not building_type.



Yes, it was just that stupid...lol. I figured it out, but forgot to come edit. Thanks for the response.
 
You are not stupid at all, you are learning, and making mistakes is part of that. Soon you’ll be able to clone and modify xml entries and grasp what modding freedom that gives you.

Not everyone learns well via instruction, some of us learn by doing. Never be afraid to ask for help, never be afraid to test stuff out. My best advice is to log and back up changes, before you alter them again, so you have a good version to revert to.

There are online guides to civ4 xml files that comment on the function of each <Whatever>...</Whatever> tag that were / are a great help as well.

Happy modding and get in touch if you need help! Might be something I need to learn about too.
 
Top Bottom