1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[TUT] Adding newly created units to Civ4 in 6 "easy" steps

Discussion in 'Civ4 - Modding Tutorials & Reference' started by Rabbit, White, Jul 5, 2006.

  1. Adding newly created units

    Disclaimer

    By “newly created” I mean units that use new NIF files.
    This tutorial is more like a step-by-step guide really, and it doesn’t cover units that have only been reskinned. It also doesn’t cover more XML than is necessary to accomplish this. If you want to know more about that you should read sovarn’s excellent guide to adding new units. In fact, it is recommended to read it before you read this tutorial, as you will understand much better the steps described here.

    There are also no instructions on how to add/use new buttons for these units, there’s a whole thread on that I believe.

    There are two kinds of units of concern here – one is units that use vanilla animations and the other is, units that use new (either completely new, or slightly modified vanilla) animations. The steps for adding them differ only slightly, in fact only one step is partially different for them. However, difference is important and I will explain it when we get to that step.

    If you only have trouble with the art defines then skip to the last step.

    Step 1

    Once you downloaded the unit, unzip it into your mod’s unit directory, that would be Mods\[mod name]\Assets\Art\Units. Don’t forget to create a folder for the unit if needed. (If you’re putting it in Custome Assets then obviously the path is just CustomAssets\Art\Units.)
    In most cases the creator of a unit will provide all the files needed to make it work unless otherwise stated. If the unit uses vanilla animations then there probably won’t be any animation files (KF and KFM) with the unit, and that is because they are not needed.

    This is important - do not add any other files to the unit’s folder, in 99% of the cases you do not need them and they might mess things up.

    The most common mistake people make is when they download a unit that doesn’t have animation files and then add those files to its folder. That is not necessary and in fact, sometimes can mess things up (I don’t know why but it just does).

    Step 2

    If you haven’t already, then create a folder called XML in your mod’s assets directory. In it create two additional folders – Units and Art.

    Go to these folders in the main civ4 directory and copy the following files from them – CIV4FormationInfos.xml, CIV4UnitClassInfos.xml and CIV4UnitInfos.xml from the Units folder, and CIV4ArtDefines_Unit.xml from the Art folder. Place them in the corresponding new folders you just created.

    Step 3

    Open the UnitInfos file (I’ll be dropping the CIV4 and .xml parts from file names for brevity). Make a copy of any unit entry. By “unit entry” I mean everything between the <UnitInfo> and </UnitInfo> tags, including them. You can make a copy of any unit but it’s best to copy a unit that closely resembles then new unit you’d like to add. Resembles in terms of properties (stats) not look.

    Change the unit’s class and type to something else, usually it’s just UNITCLASS_ (or UNIT_ for type) followed by a capitalized name of the unit.

    A bit lower find the <Description> tag and change its contents to the simple name of the unit, i.e. not capitalized, not with spaces replaced by underscore, just regular ol’ unit name (like Horse Archer). This will mean that in game this unit will use that name. This is however only a temporary solution (for testing purposes), because to do this properly you should change this to a reference to the multi-lingual name of the unit in a different file. That’s where sovarn’s tutorial comes in handy as it explains this in more detail.

    Scroll down until you find the <EarlyArtDefineTag> tag. Change the contents of that tag to something else. Again, like with type and class it’s usually ART_DEF_UNIT_[capitalized unit name].

    At this point you can of course also modify any of the unit’s properties, and again more info on that in sovarn’s tutorial.

    Step 4

    Open the UnitClassInfos file. Make a copy of any unit class entry, i.e. everything in between and including the <UnitClassInfo> and </UnitClassInfo> tags. In the new class info entry change the type to the class (UNITCLASS_) that you gave the new unit (in the UnitInfos files). Change the default unit, i.e. <DefaultUnit> tag contents, to the type (UNIT_) that you gave the new unit.

    Step 5

    Open the FormationInfos file. In it you will find a bunch of formations between the <UnitFormation> tags, it would take a whole ‘nother tutorial to cover this file (seZ? wink, wink, nudge, nudge ;)), but for now to make the new unit use formations, simply add its type to any list where the unit which closely resembles it is found.

    Step 6 - Last and most important step

    Open the ArtDefines_Unit file. Once again, make a copy of the art entry (between and including <UnitArtInfo> and </UnitArtInfo> tags) of a unit that closely resembles the new one.

    Change the type of the art define to match the one you used in the EarlyArtDefineTag in UnitInfos file.

    Change both <NIF> and <SHADERNIF> so that they point to the location of the new unit’s NIF files. If the unit (as it comes in the zip) has an _fx version of the file then the SHADERNIF tag should point to that. If not then the SHADERNIF tag should point to the same file as the NIF tag.

    And now this is where there is a difference between what to do based on the type of unit you’re dealing with.

    If the unit uses vanilla animations then you need to change the KFM tag to point to the location of the original vanilla animation KFM file. That is to say – if the unit should be using warrior animations for example, the KFM tag should point to Art/Units/Warrior/Warrior.kfm.

    To put it another way – the new unit’s KFM tag should be identical to the KFM tag of the vanilla unit who’s animations it’s using.

    As to which animations the unit should use – either the creator gives that information in the thread (or readme file), or it is assumed to be obvious. For example, some new units may use vanilla units’ file names (some of my units use warrior.nif and warrior_fx.nif files), in which case the creator might not specifically state which animations the unit should use, as it is assumed that it should use the same animations as its vanilla namesake.

    If the unit uses new animations (which could be completely new or modified existing ones) then the creator would have provided the necessary animation files with the unit, and so the KFM tag should point to the KFM file that came with the unit.

    You can now run the game (with the mod loaded) and use the new unit. :)

    Conclusion

    That's it. If you follow these steps you should be able to add new units to civ4 without trouble.

    I hope this was helpful. Please feel free to ask me anything (even if it has to do with the wider general topic of adding units, like in sovarn’s tutorial :)).

    And if you still find sections of this tutorial not detailed or clear enough, let me know and I will try to fix that.
     
  2. woodelf

    woodelf Bard

    Joined:
    Jun 12, 2003
    Messages:
    15,036
    Location:
    Gallery
    A nice refresher for me Rabbit since I haven't added a unit in months. Well written. :thumbsup:
     
  3. seZereth

    seZereth FfH´s art monk(ey)

    Joined:
    Feb 3, 2006
    Messages:
    3,900
    Location:
    Bayreuth
    thanks for the tut rabbit, hope this helps people to enjoy our creations ;)
    About a tutorial for the Formations... well perhaps ill do something like this, perhaps... sometimes...;)
     
  4. civ_4_rox

    civ_4_rox Chieftain

    Joined:
    Apr 25, 2006
    Messages:
    12
    Location:
    Canada
    awesome tut good for beginners like me to the whole modding thing
     
  5. Elit3

    Elit3 Chieftain

    Joined:
    Apr 14, 2005
    Messages:
    39
    Ok pretty cool info thanks. but i just downloaded a weapons pack. Wanted to change the marine AK-47 with a European/ Us type weapon. how would i go about doing this?
     
  6. Check out the NIF Viewer tutorials in my sig. :)
     
  7. Edgecrusher

    Edgecrusher Chieftain

    Joined:
    Aug 7, 2006
    Messages:
    915
    Location:
    Massachusetts
    I think this guide would answer my question,... but anywhere here goes.

    I put a new unit in the game (Im using Warlords)... Everything checks out, and when I run the Mod, the unit appears in the Civilopedia, stats, pre-reqs, icons, text, everything is fine... Im thinking, excellent.

    So I load the mod, and play the game (The Unit I put in was the Chinook Helecopter), I learn the techs that open up the Chinook, Icons, everything is there.

    Now here the trouble starts, When I click on the button to put the Chinook, in the queue to be built next, the game crashes.

    Im guessing that it has something to do with the artwork and the little round icon that appears on the map screen during the game. Maybe Im wrong. Im just curious if anyone else has encounted this problem? Or knows what may cause it.
     
  8. Edgecrusher

    Edgecrusher Chieftain

    Joined:
    Aug 7, 2006
    Messages:
    915
    Location:
    Massachusetts
    OK well I fixed that, now the only problem is the city doesnt actually build the unit.

    It just keeps the unit in the queue with a total production of some really large negative number.

    Oh well
     
  9. ir8

    ir8 Chieftain

    Joined:
    Oct 8, 2006
    Messages:
    5
    This game is supposed to be moddable...???

    None of this crap works!!

    I did EVERYTHING EXACTLY as described here... and I can't create a game!!

    Do I have to create a whole new map and everything to use a custom unit, or what?

    These tutorials seem half finished... you tell where to put files but not what's actually going to happen... which is that I get the option to load a game but not to start a new one.

    All attempts at game editors are half finished and unusable.

    This game is NOT easily moddable. Nothing works right, and the people who know how to do it assume everyone else does as well.

    Please explain to me how I can put a unit in this gods-damned game and get it to WORK??

    Sorry to sound so angry, but I only created this account (note the name) after finding out how BS the "moddability" of this game seems to be.
     
  10. First of all, this is obviously not a complete tutorial to creating mods, it only concerns itself with new units.

    Second, if you only follow this tutorial, the unit will not be available in gameplay, you'll be able to access it only through the world builder (or if it is available in game it won't be necessarily balanced, or appear where you expect to on the tech tree, etc.). If you want a unit that becomes part of the game you'll need to go through the tutorial I mentioned at the start at least, and maybe one or two others.

    I'm sorry that you feel frustrated but this is not rocket science. Granted, you might need to read a few tutorials before you can do any signficant modding, but that's the price to pay for extensive moddability. And yes this game is very moddable, some of the moddability isn't easy but that's because it allows you to change complex things. If you want easy moddability stick to making new skins for units. If you want to do anything more involved you'll need to take the time to learn things.

    Everything described in this tutorial works. I pretty much went through the steps as I was writing to make sure I didn't miss anything, exactly because I knew I might make assumptions that are not obvious to new comers.

    If you followed the tutorial but the unit doesn't appear in game then you must've missed something. Also, note the quotes around "easy" - this is a somewhat advanced tutorial. If you have zero experience modding for civ4 you should start with easier stuff. If you're interested in units, then you need to get a handle on the most basic stuff first - start with simply changing unit stats; then move on to creating a new unit that is the exact duplicate of an existing one but with new stats, and such that it's playable; then add a new skin for that new unit. If you got all that figured out then you can move on to this tutorial and I assure you it will be much clearer.
     
  11. strategyonly

    strategyonly C2C Supreme Commander

    Joined:
    Mar 13, 2006
    Messages:
    20,420
    Gender:
    Male
    Location:
    MN
    I got a unit in the game, but the title in the town reads, KEY_TEXT_UNIT_SKELETON, need it to just say skeleton, also i need them to be barbarians and not a unit you could select, how do i do that??
     
  12. That's the description part - if you don't care about other languages you can just change the content of the Description tag from KEY_TEXT_UNIT_SKELETON to Skeleton. If you want multi-language support then you'll need to add an entry to the CIV4GameTextInfos_Objects.xml file.

    As for making them Barbarians, I'm not 100% sure. I would guess that you'd want to give them some prerequisite that will prevent them being ever available in build queue, and you'll need to add them to a list of units the Barbs have available, which is I think found in the CivilizationInfos file.
     
  13. strategyonly

    strategyonly C2C Supreme Commander

    Joined:
    Mar 13, 2006
    Messages:
    20,420
    Gender:
    Male
    Location:
    MN
    I'll give it a shot, THX, heard also that you used to have some japanese flags and stuff, do they work, and where are they?? I could use anything Asian.
     
  14. Here they are, but you can't use them "out of the box" you gotta attach them to units obviously.
     
  15. strategyonly

    strategyonly C2C Supreme Commander

    Joined:
    Mar 13, 2006
    Messages:
    20,420
    Gender:
    Male
    Location:
    MN
    deleted since no one helped out.
     
  16. hun+celt

    hun+celt Chieftain

    Joined:
    Oct 21, 2006
    Messages:
    36
    Location:
    East Coast, US
    Rabbit, White - GREAT tutorial, much thanx from a noob who was forced to teach myself XML (never programmed before) because of the beautiful work of people like yourself. I have a question about sound issues with some of my mechanized units (flavor units for tank, mech. inf etc.) The graphics work fine, but I just get a constant tread-sound loop as long as the unit is on screen. I just did a straight C&P for the ArtDefines_Unit entries and don't get any sound probs with the stock units. Any suggestions would be appreciated.
     
  17. humboldt

    humboldt Chieftain

    Joined:
    May 10, 2003
    Messages:
    13
    Ive been trying to follow this tutorial and add a unit to Warlords, but have had little success. The XML verification shows errors and the games freezes when I try to play the MOD.

    Is there anything I need to do differently if Im trying to MOD the Warlords expansion? I should be using the XML files from the warlords folder right?
     
  18. Chazcon

    Chazcon Chieftain

    Joined:
    Feb 16, 2006
    Messages:
    475
    Location:
    Left Coast
    What do we do with a gloss file? I have one for a unit I downloaded, and when I run the game the edge of the unit's musket is pink!

    I think obviously that the gloss file is not loading, or in not referenced properly. Or in some other way I have screwed up, heh.

    I see no reference in any of the guides about a gloss file.
     
  19. Can you post a screenshot, I'm not really sure what you're talking about.

    In any case, first thing to do is make sure you got all the needed textures, including the gloss one. Double check the zip and if you got everything from it then maybe the author forgot to include a texture so you'll need to get it from its original locations.
     
  20. ArdRaeiss

    ArdRaeiss Chieftain

    Joined:
    Jan 11, 2004
    Messages:
    84
    Location:
    Russia, Saint-Petersburg
    Replace the gloss texture with "empty"(make transparent texture or take the "detail.dds" from any of my latest units) and try again.
    If you still have "pink edge" - the problem is in the bad unwrapping+texturing(you need a border(2-4 pixels at least) around each part to prevent this unwanted white/blue/pink pixels. Easy way - make the neutral gray/black/unit-main-color background for entire texture).
     

Share This Page