GUIDE: Adding new units

oh haha thanks i'll get that done. :) oh dang.... hmmmmm.... well i really wanted this unit to be able to do that. Do you think i can do it? or will it be too complex for me right now...?
and also i'm working on adding in a new screen....but i'm kind of stumped already....in the tutorial it says.... "We are going to import everything from CvPythonExtensions into our module's local namespace and we also import CvScreenEnums" how do i do that? i've put in his pictured code in the python and the python shell but nothing seems to work...
 
oh haha thanks i'll get that done. :) oh dang.... hmmmmm.... well i really wanted this unit to be able to do that. Do you think i can do it? or will it be too complex for me right now...?

Let's say it in this way: If you have something else to do, then do that first.
Complexity should not be the problem, if you have enough time to work on it and if you get the needed software to run.
Everyone can learn programming, in the same way like everyone can learn piano playing. If you have no talent, then you'll need more time and have to work more.

and also i'm working on adding in a new screen....but i'm kind of stumped already....in the tutorial it says.... "We are going to import everything from CvPythonExtensions into our module's local namespace and we also import CvScreenEnums" how do i do that? i've put in his pictured code in the python and the python shell but nothing seems to work...

Which tutorial :confused:?
 
Hi, modding noob here,

I've been trying to add a new unit but the game keeps crashing whenever I try to load a saved game.

I've basically been trying to add an AEGIS cruiser as a unique missile cruiser for the American Empire, I've edited the CIV4UnitInfos.xml, CIV4CivilizationInfos.xml and CIV4GameText_Objects_BTS to add a new UNIT_AMERICAN_AEGIS_CRUISER.

I'm pretty certain I've added the correct things to the xml files except I've kept the

<Civilopedia>TXT_KEY_UNIT_MISSILE_CRUISER_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_MISSILE_CRUISER_STRATEGY</Strategy>
<EarlyArtDefineTag>ART_DEF_UNIT_MISSILE_CRUISER</EarlyArtDefineTag>

parts which i've kept the same as for the default missile cruser as I don't yet want to mess about with a large section of text yet, and I want to keep the graphics of the missile cruiser.

However every time I tried to load saved game I've been playing it fails to load properly, flashing an error message far to quickly for me to see or even screen grab before crashing to desktop.

Is there something I've been overlooking? Do I have to make/copy/rename new graphics/art files for each new unit I add? I've also just been directly editing the xml files in the games folders (I've backed everything up beforehand), does this make a difference?
 
it's jeckels tutorial "How to display a blank civ4 screen"

I can't help there that much :sad:.
Looked at that a long time ago, when i didn't have the abilities to follow it, and now i don't have the time.
Looking at what you wrote...it seems you also need some more time. Like previously said, if you have something else to do, then do that first.
And take the question over to its own tutorial thread ;).
I guess Baldyr might want to have a look at it (me sure too, but mostly observing, i guess).

Hi, modding noob here,

Welcome to CFC :).

@problem:
You say you are trying to load a saved game...a saved game from before modding, or after it already worked successfully?
 
@problem:
You say you are trying to load a saved game...a saved game from before modding, or after it already worked successfully?

Ahhh, I was loading a saved game from before modding, I've just tried with a new game and eveything is working as it should. I didn't realize loading an old saved game was going to be problem as I've done other bits of editing of the xml files (just changing a few unit stats etc.) and they managed to load.

Many thanks.
 
Hello! I have no problem for adding new units in my personnal mod, excepted for the great general. I don't understand why there's always a problem. I suppose there is a difference between normal unit and specialist unit, but I don't find the solution. Could somebody help me? Thanks.
 
I try to create an asian great general. I found an asian ancient warlord and the modern japanese warlord. I added them in ArtDefineUnit, then I add them in UnitArtStyleTypeInfo in the asian style. But when I play with an asian civ and when I get a great general, I can't click on the icon during the game. If I click, there's a bug and Civ ended instantanly. I don't find my error. I just modified xml files ArtDefineUnit and UnitArtStyleTypeInfo. Do you understand my problem?
 
Ah, okay, i know that bug.
It's a problem with file names.
You've added an unit, so you know there are at least 2 files: The .nif and the .kfm.
In the .kfm file, there is the name of the related .nif mentioned, so e.g. in the swordsman.kfm there's the swordsman.nif mentioned. If you now have something like zulu_swordsman.nif and you add this .nif together with the swordsman.kfm, the .kfm will not be able to find the right .nif. That's what causes the problem.
-> the easiest way here is to rename the 2 general .nif files to whatever the original real name was (-> most probably the same as the .kfm name).
 
You're right! There was a problem with the .kfm file downloaded with the warlord. Thanks a lot.

I have another question about great generals. Do you know how to customize their names? For exemple, I want to create a list with german names, just for the german civilization. It's boring me when I have Vercingetorix with Japanese...
 
For great generals that is a problem, because their "appearance" is different to every other unit in the game. Normally i'd suggest to give every civ an unique unit for the unit which you want to have the names (works also for GPs, you could have a great prophet UU for every civ, if you wanted to), but due to the spawning mechanisms of the generals that doesn't work.

I've tried my hands once at a mod component which could help here, see this post, "2. Attachment is the request" etc.
Not sure if it works for generals. You would have to create a new unitcombat for the generals, but that's not a problem, but not sure if anything else could prevent proper functioning (besides the there already mentioned problem).
 
Never mind the original problem, I figured out where the *.fpk files were found.

However, I am still running into a problem with step 1 of the initial instructions. Please forgive the stupidity of what I am about to write... I have read the OP several times, as carefully as I can, and I am still at a loss for how to complete some of the instructions. I think the OP assumes the person attempting to create a new unit already knows some basic information, but I don't have that information in my brain. Here's the step I can't quite figure out:

1) "To prepare, go to your customs assets folder or create a new mod. All files in the following guide will use the assets folder as the root. So if i say create a new folder, this folder will be created in the assets folder."
Here's the problem I have. I have installed Civ4 + BTS on my hard drive (E: ), and there is indeed a folder titled Assets in the base Civ4 directory. There is also a folder titled Assets in the Beyond the Sword Directory, which is itself located in the Civ4 base directory. The only place I have anything titled Custom Assets is way over on a totally different drive (F: ) buried in a subdirectory of My Documents, which is clearly where my screenshots and save files are located, along with patch files. These directories within My Documents are for the most part empty with the exception of the various subdirectories for saves.
So, where am I going to be putting the folders and files that I copy and modify? I was about to embark on just putting 'Terry' into the Assets folder within the BTS folder, and going from there, but then I got nervous.

2) "Rename the folder to Terry but keep all the files inside intact i.e. do not touch them otherwise your game will crash and do funny stuff with you RAM. Get the new skin if you have one and replace it over the warrior_128.dds. The new skin has to take this name (in this example)."
I assume this means rename the folder 'Warrior' to 'Terry,' not the whole string of folders.
Concerning the new skin, should the new skin be named warrior_128.dds or terry.dds or something else, like terry_128.dds for example?
The same question for later steps concerning things like making the button files, etc.

It really seems like this should be a fairly simple task, and I'm sure that once a person has successfully done it once, it *is* a simple task, but for someone who has never modded a game in his life, let alone done any work with xml whatsoever, I am clearly lacking some basic information. I am computer literate, believe it or not, and I do understand file structure and subdirectories, etc.

-Sinc
 
1) "To prepare, go to your customs assets folder or create a new mod. All files in the following guide will use the assets folder as the root. So if i say create a new folder, this folder will be created in the assets folder."
Here's the problem I have. I have installed Civ4 + BTS on my hard drive (E: ), and there is indeed a folder titled Assets in the base Civ4 directory. There is also a folder titled Assets in the Beyond the Sword Directory, which is itself located in the Civ4 base directory. The only place I have anything titled Custom Assets is way over on a totally different drive (F: ) buried in a subdirectory of My Documents, which is clearly where my screenshots and save files are located, along with patch files. These directories within My Documents are for the most part empty with the exception of the various subdirectories for saves.
So, where am I going to be putting the folders and files that I copy and modify? I was about to embark on just putting 'Terry' into the Assets folder within the BTS folder, and going from there, but then I got nervous.

Either you put it directly into the Custom Assets on F:, or you create a new folder in Mods\BtS, and add there the needed folders like Assets\, XML\ etc.

2) "Rename the folder to Terry but keep all the files inside intact i.e. do not touch them otherwise your game will crash and do funny stuff with you RAM. Get the new skin if you have one and replace it over the warrior_128.dds. The new skin has to take this name (in this example)."
I assume this means rename the folder 'Warrior' to 'Terry,' not the whole string of folders.
Concerning the new skin, should the new skin be named warrior_128.dds or terry.dds or something else, like terry_128.dds for example?
The same question for later steps concerning things like making the button files, etc.

Yes, only the warrior folder.

skin: The warrior.nif will search for a warrior_128.dds.
So if you have another skin, then it has to be named warrior_128.dds, else the .nif will not find it and it will not get displayed in the game.
 
Awesome, thanks for those answers.

My ultimate goal in learning how to do this is to add a new unit to the game, based off the Privateer, but for later in the game. I intend to use the skins for the Team Pallada Cruiser, which I found in the downloads section, and pretty much looks exactly like what I want. The download for that item contains several dds files, a button file, a nif and a kfm, among other things, like dds files for idle, hurt, running, etc. I want the actual unit to be called an 'Armed Merchant Cruiser.' From what you've just said here, I cannot rename those various files, or else the unit will be looking for things which don't exist, right? But if I call the directory Armed_Merchant_Cruiser, and obviously use that name in all the xml files, then that's what the unit will be called? I assume the xml is looking for the directory, not the actual files inside?
 
You are totally right, besides the last point: The name of a unit is set in Assets\XML\Units\UnitInfo.xml, the entry "description" holds the name:
PHP:
		<UnitInfo>
			<Class>UNITCLASS_WARRIOR</Class>
			<Type>UNIT_WARRIOR</Type>
			<UniqueNames/>
			<Special>NONE</Special>
			<Capture>NONE</Capture>
			<Combat>UNITCOMBAT_MELEE</Combat>
			<Domain>DOMAIN_LAND</Domain>
			<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
			<Invisible>NONE</Invisible>
			<SeeInvisible>NONE</SeeInvisible>
			<Description>TXT_KEY_UNIT_WARRIOR</Description>

The TXT_KEY stuff is located in one of the files in Assets\XML\Text. No idea where, which file does for the Text directory not matter.
 
Thanks again for the answers. I was able to get everything set for the new unit today. It can be built, upgraded to, fight battles, win em and lose em. Basically, it's a modern era privateer. :) It's even got graphics. After, of course, about a dozen restarts of BTS to figure out why it looked like a purple square button in the 'pedia screens. :)

I made it require Combustion as the tech, and require coal or oil to build. No Nuclear-powered armed merchant cruisers! Same power and moves as a transport. +50% attacking or defending against transports. 1 first strike, and starts with Sentry.

I justified the first strike by saying to myself: It's supposed to look just like a regular merchant ship until it opens fire, and that surprise, to me, equates to a first strike.

-Sinc
 
Hello!

I tried to create customised buttons but I have a probleme during the game.

As you can see on this screenshot, the new unit with his own button appear in the civilopedia correctly :
817203Capturedcran20110110130607.png


For an exemple, here an american grenadier, I have no problem when I upgrade an unit to an american grenadier. I can use it in the game. I just have one problem when the unit is out of view on the map. As you can see on this screenshot, a circle button is missing and I just have a pink circle on my screen.
533024Capturedcran20110110132111.png


But when I want to build a new unit with customised button, Civilization crashes immediatly. Does anyone know how to fix this bug?

Here, you can see my "CIV4ArtDefines_Unit.xml" file concerning my american grenadier :
<UnitArtInfo>
<Type>ART_DEF_UNIT_GRENADIER_AMERICAN</Type>
<Button>,Art/Interface/Buttons/Units/Button_Grenadier_American.dds</Button>
<fScale>0.44</fScale>
<fInterfaceScale>1.0</fInterfaceScale>
<bActAsLand>0</bActAsLand>
<bActAsAir>0</bActAsAir>
<NIF>Art/Units/Grenadier_American/brazil_grenadier.nif</NIF>
<KFM>Art/Units/Grenadier/Grenadier.kfm</KFM>
<SHADERNIF>Art/Units/Grenadier_American/brazil_grenadier.nif</SHADERNIF>
<ShadowDef>
<ShadowNIF>Art/Units/01_UnitShadows/UnitShadow.nif</ShadowNIF>
<ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
<fShadowScale>0.95</fShadowScale>
</ShadowDef>
<fBattleDistance>0.35</fBattleDistance>
<fRangedDeathTime>0.31</fRangedDeathTime>
<bActAsRanged>1</bActAsRanged>
<TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
<AudioRunSounds>
<AudioRunTypeLoop/>
<AudioRunTypeEnd/>
</AudioRunSounds>
</UnitArtInfo>
 
Change:
PHP:
<Button>,Art/Interface/Buttons/Units/Button_Grenadier_American.dds</Button>

to:
PHP:
<Button>Art/Interface/Buttons/Units/Button_Grenadier_American.dds</Button>


The commas are probably one of the most confusing things, when you add a new unit the first time.
You only need them if you have a normal button and an atlas file (that's a multi button file), else if you have only a single button then don't add them.

I'm supprised that you even could build one. Normally it leads to a direct crash when you try to select the unit in the cities building menu.
 
Thanks a lot The_J!!! I tried a lot of different things but I don't know why I didn't notice this stupid comma!

But I could build one only when I upgraded an old one to the grenadier. As you said, it was crashing when I select the unit in the menu.
 
Back
Top Bottom