Unit Creating

Discussion in 'Civ4 - Creation & Customization' started by MajorWinters, Jan 15, 2010.

  1. MajorWinters

    MajorWinters Chieftain

    Jul 22, 2008
    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.
  2. phungus420

    phungus420 Deity

    Mar 1, 2003
    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.
  3. PPQ_Purple

    PPQ_Purple Techpriest Engineer

    Oct 11, 2008
    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 :
    <Type>UNIT_JET_FIGHTER</Type> - The name of the unit
    <BonusType>BONUS_OIL</BonusType> - Resources required to build the unit
    <iCost>150</iCost> - Cost in hammers
    <iCombat>0</iCombat> <iCombatLimit>0</iCombatLimit>

    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.
  4. phungus420

    phungus420 Deity

    Mar 1, 2003

    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.
  5. MajorWinters

    MajorWinters Chieftain

    Jul 22, 2008
    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.
  6. phungus420

    phungus420 Deity

    Mar 1, 2003
    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
    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.
  7. MajorWinters

    MajorWinters Chieftain

    Jul 22, 2008
    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.
  8. phungus420

    phungus420 Deity

    Mar 1, 2003
    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.
  9. MajorWinters

    MajorWinters Chieftain

    Jul 22, 2008
    But how do i specify who's unique unit it is?
  10. phungus420

    phungus420 Deity

    Mar 1, 2003
    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.
  11. PPQ_Purple

    PPQ_Purple Techpriest Engineer

    Oct 11, 2008
    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.
  12. TheVinci

    TheVinci Chieftain

    May 31, 2009
    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?
  13. Zeta Nexus

    Zeta Nexus <{[(Nexus)]}>

    Jan 23, 2014
    In a constant brainstorm...
    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.
    TheVinci likes this.
  14. TheVinci

    TheVinci Chieftain

    May 31, 2009

    Yes, it was just that stupid...lol. I figured it out, but forgot to come edit. Thanks for the response.
    Zeta Nexus likes this.
  15. Spillsandstains

    Spillsandstains Warlord

    Mar 31, 2008
    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.
    TheVinci likes this.

Share This Page