Okay, so here is a super barebones new unit presented as a module. It has absolutely no frills.
The original unit comes from saibotlieh, with some additional credits and thanks in the readme.
That original graphics pack came only with 4 files (2x .dds files and 2x .nif files) and a subfolder with a button.
I created a folder in the /assets/modules folder called Skeleton.
I created just 4 xml files (like I said, bare bones)
2 of them are schema files, renamed to include the prefix skeleton_
The other two are
Skeleton_CIV4ArtDefines_Unit
Skeleton_CIV4UnitInfos
Then I replaced the button with my own graphics.
For the Skeleton_CIV4UnitInfos.xml file, I used the Hellebardier Unitinfo files as a base. It's a UU for Switzerland that was part of a tutorial on mod-modding simply because I knew it worked after a playtest.
In this file, I changed some tags, including <Type> and <EarlyArtDefineTag> to coincide with the unit.
One question you need to answer is how are you planning to use this unit? Is it supposed to be buildable by itself or is it a Unique Unit? If it's meant to stand alone, you will need to define a
UnitClass for the unit and create a
CIV4UnitClassInfos file in your module. If it is meant as a UU, then you can use an existing UnitClass but you need a
Civ4Civilizations file to tell the game which generic unit the new unit will replace. I assume any modular building or unit needs
six files: the four files you already have, plus a UnitClassInfos (or BuildingClassInfo for buildings) file and a GameText file. What you have done is to hard-code your Description into your UnitInfos, which does work but isn't friendly to switching languages. The GameText file is used for the unit name, unit strategy, and unit background. Due to whatever we've done to game text, any new GameText files have to go into the Text folder rather than stay in the mod.
In the Skeleton_CIV4ArtDefines_Unit.xml file, I changed the button tag to:
<Button>,Modules/Skeleton/btn_skeleton.dds</Button>
(Still not sure why the comma there)
The comma should not be there unless you are using an atlas. If you have a lot of button files, you can organize them into a single atlas file which loads faster. With an atlas, you need the comma; it tells the game to look for an atlas file but load a regular button if the atlas cannot be found.
I also changed this NIF file location, and SHADERNIF location but the unit did not come with a .kfm file, nor any tips on how to go about one, so I playtested with this:
<NIF>Modules/Skeleton/swordsman.nif</NIF>
<KFM>Modules/Skeleton/swordsman.kfm</KFM>
<SHADERNIF>Modules/Skeleton/swordsman_FX.nif</SHADERNIF>
I was able to place the unit via the WorldBuilder, but after a few turns, I got a CTD.
So I unpacked the vanilla assets0.fpk file, grabbed the vanilla swordsman .kfm and .kf files and plopped them into the module folder.
Voila, it works. It's not perfect. There seems to be some animations missing and the unit moves a little wonky, but otherwise, it all works.
KFM files are the animation instructions for a unit. Writing new ones is not something most modders do. Most new units are created by taking an existing unit model and modifying it. For example, you can take a Rifleman unit and change the DDS skin to get a new unit for a new art style.
When you have a new unit based on an existing one, then you can just point the new unit's ArtDefines KFM at the original KFM for the previously-existing unit and the new unit will still work. The only real problem is that you cannot play with
Animations Frozen or the new unit will look like the old, because the KFM calls the old unit's frozen artworks. So in your case, you could have this:
Code:
<NIF>Modules/Skeleton/swordsman.nif</NIF>
<KFM>Art/Units/Swordsman/Swordsman.kfm</KFM>
<SHADERNIF>Modules/Skeleton/swordsman_FX.nif</SHADERNIF>
and that will work. The files don't have to be in the same place.
I was surprised to learn that MLF_CIV4ModularLoadingControls.xml and it's schema file are not required. I believe that has to do with the launcher?
I think only one level of ModularLoadingControls is necessary, and that's the one in the main Modules folder. If the module is turned on in that file, then anything in that module would be loaded. You can use extra ModularLoadingControls if you want to be able to turn off particular parts of a module, but you could also make a separate module just for that part. The launcher is an add-on that isn't necessary to run the mod.
I've noticed some of the units in AND and MCP do not include all these .kf files in the .fpk packed files, but they seem to be necessary.
As I said before, you don't need to copy the KF files as long as your XML points to the right KFM. The KFM and KF files do have to go together, but they don't have to go with the NIF.
I've found some places in the AND artdefines_unit.xml file where the location pointing to .kfm files does not appear to have a .kfm file inside. One example is the Man-O-War, which calls for <KFM>Art/Units/Frigate/Frigate.kfm</KFM> but there is no .kfm in the AND unit assets pack or the vanilla assets pack that I loaded. There are 4 asset packs in the base game, perhaps I didn't unpack all of them and that is why I'm not seeing it. Is that a right assumption? Do I need to fully unpack all the assets to get all the graphics I need for a new unit to display all of the stances, combat graphics, etc?
You can unpack all the assets packs if you want. The files you're not seeing are in those packs. Any file that is not provided by the mod will be pulled from the base game. So the easiest solution is just point the XML at the KFM for the original unit used as a base and the game should take care of the rest.
For future units, I see the vital importance of using subfolders within the module and using modular loading controls to keep them all straight. I know that it's also best practice to pack the files as opposed to what I've done here.
You don't need to pack the files until you have many of them. The MegaPack has so many unit files that loading is incredibly slow unless the files are packed. But there is also a limit to how many packs the game can support.
I think you are on the right track. Just keep working at it.