Results 1 to 30 of 268

Thread: Tutorial - Adding a unit to the game

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member Member Musashi's Avatar
    Join Date
    Nov 2002
    Location
    The Mists of Legend
    Posts
    811

    Default Tutorial - Adding a unit to the game

    Ok. This is a LONG and involved process, and it will probably be made significantly easier when CA releases a few more tools. However, this is the process required to get a new unit into the game at the current time.

    I'm going to be using a unit I created as an example throughout this process. My Byzantine Dragoons are sort of a cross between Reiters and Camel Gunners. They're nasty and very powerful, but keep in mind they're for an alternate history fantasy type mod I'm working on. This is a picture of the finished product:


    I'm also going to be assuming you've already run the unpacker.

    Step One: The Unit File

    Go into your data folder and open export_descr_unit.txt. We'll be adding a new unit block to this file. I like to keep the file somewhat organized, so I generally group my additions by type and faction and so on, but it doesn't really matter much where you place them.

    We're going to be creating a unit similar to Reiters, so the simplest thing is to start with the entry for Reiters:
    Code:
    type             Reiters
    dictionary       Reiters      ; Reiters
    category         cavalry
    class            missile
    voice_type       Heavy
    banner faction   main_cavalry
    banner holy      crusade_cavalry
    soldier          Reiters, 32, 0, 1
    mount            heavy horse
    mount_effect     elephant -4, camel -4
    attributes       sea_faring, hide_forest, hardy, can_withdraw, can_formed_charge, cantabrian_circle, gunpowder_unit, start_not_skirmishing, guncavalry
    formation        2, 4.4, 3, 6, 4, square
    stat_health      1, 0
    stat_pri         20, 3, pistol_bullet, 45, 20, missile, missile_gunpowder, piercing, none, musket_shot_set, 25, 1
    ;stat_pri_ex      0, 0, 0
    stat_pri_attr    ap
    stat_sec         11, 5, no, 0, 0, melee, melee_blade, piercing, spear, 25, 1
    ;stat_sec_ex      0, 0, 0
    stat_sec_attr    no
    stat_pri_armour  7, 6, 0, metal
    ;stat_armour_ex   7, 8, 0, 0, 6, 0, 0, metal
    stat_sec_armour  0, 0, flesh
    stat_heat        5
    stat_ground      0, -2, -4, 0
    stat_mental      9, normal, trained
    stat_charge_dist 45
    stat_fire_delay  0
    stat_food        60, 300
    stat_cost        1, 920, 250, 120, 95, 920, 4, 230
    armour_ug_levels 3, 4
    armour_ug_models Reiters, Reiters_ug1
    ownership        hre
    era 2            hre
    ;unit_info        11, 20, 13
    So what we will do is copy and paste that block into the file in another spot, and then make some small changes to it to get it exactly the way we want it.

    The first thing to do is change the type variable. This is the label the game uses for the unit internally. The main thing we need to concern ourselves with for our current purposes is that the game will try to find a unit icon based on this name.

    I've decided to call my troops Byzantine Dragoons, and the game tends to use ES_ or GR_ to designate a Byzantine unit (Although in this case I could simply call them Byzantine Dragoons, that would work just as well), so I've chosen to set the type to GR_Dragoons like so:
    Code:
    type             GR_Dragoons
    Next we have to set the Dictionary entry. The game looks for an entry in the export_units.txt.bin file in order to find the display name and description of the unit. There can't be any spaces in this entry. If I'd called my new unit "Byzantine Dragoons" I'd have had to use a dictionary entry of "Byzantine_Dragoons", or some other one word string.

    The next few lines we leave alone... It's still cavalry, still a missile troop, no need to change the voice or banners... But we do need to change the Soldier entry.

    Experience modding the model db file allows me to say with certainty that the soldier type sets the skeleton and animation sets, while the model and textures are taken from the armour_ug_models line. Technically we could leave the soldier line alone, since we're going to be using the Reiters' animation set. But just for the sake of continuity I'm setting it to GR_Dragoons like so:
    Code:
    soldier          GR_Dragoons, 32, 0, 1
    I also changed the "mount" entry, because I wanted to have them riding the Kataphractoi's horses, but it didn't take. I'll be looking into this later.

    The next thing I changed was the "stat_pri" line. This sets the stats of the primary weapon, in this case, a musket. I didn't want this unit to be an exact clone of the Reiters, rather I wanted it to be a long range skirmisher like the Camel Gunners, so I copied the line from the Camel Gunners' entry.

    I wanted their secondary weapon and armor to match Reiters, so I didn't change any of that. Basically I went all the way down to the armour_ug_models line before making any more changes. This is critical because if we don't change this line, the game is going to look in the model db file for Reiters models, and not find any texture entries for byzantium, and we'll end up with invisible troops even though we did all the hard Model DB work.

    In the end, the entry for my new unit looks like this:
    Code:
    type             GR_Dragoons
    dictionary       GR_Dragoons      ; Byzantine Dragoons
    category         cavalry
    class            missile
    voice_type       Heavy
    banner faction   main_cavalry
    banner holy      crusade_cavalry
    soldier          GR_Dragoons, 32, 0, 1
    mount            eastern armoured horse
    mount_effect     elephant -4, camel -4
    attributes       sea_faring, hide_forest, hardy, can_withdraw, can_formed_charge, cantabrian_circle, gunpowder_unit, start_not_skirmishing, guncavalry
    formation        2, 4.4, 3, 6, 4, square
    stat_health      1, 0
    stat_pri         16, 3, musket_bullet, 180, 20, missile, missile_gunpowder, piercing, none, musket_shot_set, 25, 1
    ;stat_pri_ex      0, 0, 0
    stat_pri_attr    ap
    stat_sec         11, 5, no, 0, 0, melee, melee_blade, piercing, spear, 25, 1
    ;stat_sec_ex      0, 0, 0
    stat_sec_attr    no
    stat_pri_armour  7, 6, 0, metal
    ;stat_armour_ex   7, 8, 0, 0, 6, 0, 0, metal
    stat_sec_armour  0, 0, flesh
    stat_heat        5
    stat_ground      0, -2, -4, 0
    stat_mental      9, normal, trained
    stat_charge_dist 45
    stat_fire_delay  0
    stat_food        60, 300
    stat_cost        1, 920, 250, 120, 95, 920, 4, 230
    armour_ug_levels 3, 4
    armour_ug_models GR_Dragoons, GR_Dragoons_ug1
    ownership        byzantium
    era 2            byzantium
    ;unit_info        11, 20, 13
    Step Two: The EEEEVIL Model DB File

    Now it's time to move on to the next, and hardest step. Coding an entry in the data/unit_models/battle_models.modeldb file, which was obviously never meant to be alterable by hand.

    Be aware that this file ONLY works in the base data/unit_models folder and will NOT work from a mod folder. This obviously has unfortunate implications for our ability to allow mod users to maintain multiple mod installations simultaneously, but there's basically nothing we can do about it until CA gives us some manner of fix or workaround.

    You will need to add --io.file_first to your batch file to get it working.

    What you do is you open the file in notepad. It will look like chaos to the untrained eye (And even to the trained eye it's a royal... erm... well you get the idea).

    Since our unit will actually be using the Reiter model with different textures, prudence dictates that we start by copying the entry for Reiters:
    Code:
    7 reiters 1 4 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod0.mesh 121 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod1.mesh 900 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod2.mesh 2500 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod3.mesh 6400 1 3 hre 73 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_hre.texture 76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_normal.texture 35 unit_sprites/hre_Reiters_sprite.spr 1 3 hre 65 unit_models/AttachmentSets/Final European CB Gun_hre_diff.texture 65 unit_models/AttachmentSets/Final European CB Gun_hre_norm.texture 0  1 5 Horse 14 MTW2_HR_Pistol 13 MTW2_HR_Spear 1 22 MTW2_HR_Pistol_Primary 1 21 MTW2_HR_spear_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002 11 reiters_ug1 1 4 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod0.mesh 121 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod1.mesh 900 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod2.mesh 2500 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod3.mesh 6400 1 3 hre 73 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_hre.texture 76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_normal.texture 39 unit_sprites/hre_Reiters_ug1_sprite.spr 1 3 hre 65 unit_models/AttachmentSets/Final European CB Gun_hre_diff.texture 65 unit_models/AttachmentSets/Final European CB Gun_hre_norm.texture 0  1 5 Horse 14 MTW2_HR_Pistol 13 MTW2_HR_Spear 1 22 MTW2_HR_Pistol_Primary 1 21 MTW2_HR_spear_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    Ugly, isn't it?

    So what can we make of all this? Let's take it one step at a time.

    The first thing to remember is that almost every entry in the file is in the format of "n xxxxx" where n is the number of characters in the string that follows it, and xxxxx is the string.

    Our first entry is "7 reiters". That's 7, the number of characters in the word reiters, and then the word itself. Personally I assume they are using some sort of serialization library that reads all these values into dynamically allocated memory, using the string length numbers to know how many characters to read in, and then looking for another string length directive. But that's really only interesting to nerds like me ;)

    The next entry is "1 4". 4 is naturally a one character string. What this represents is the number of LOD entries the game should be trying to load. This is only really important to know if you're changing the actual meshes for a unit (But it did bite me in the butt once, which is naturally how I figured out what the number does hehe).

    The next three entries:
    Code:
    53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod0.mesh 121 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod1.mesh 900 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod2.mesh 2500 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod3.mesh 6400
    These are meshes to use at various distances from the unit. Note the mesh string, and then the distance. It's fairly straightforward.

    Next up is the start of an actual texture block.
    Code:
    1 3 hre 73 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_hre.texture 76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_normal.texture 35 unit_sprites/hre_Reiters_sprite.spr
    The 1 is the number of texture blocks it should try to read in. The easiest way to think of this is just as the number of factions who can use the unit. In the case of Reiters, only the HRE can use this soldier type, so the number is one, and there is only one texture block.

    3 is the number of letters in the name of the faction the following texture block is for. In this case, the HRE. hre is of course the faction name. This is followed by the length of the next string, which will be the path of the texture which should be used for this unit when it is being employed by the given faction. The next path is to what I think is some kind of alpha map or transparency guide. Don't worry, there's one in every texture directory, so just link to the one that corresponds to the model and texture you're attempting to use.

    The last path is to the sprite file, which is used to render the unit when it's farther away than the distance set for the lowest LOD.

    The next block of code is this:
    Code:
    1 3 hre 65 unit_models/AttachmentSets/Final European CB Gun_hre_diff.texture 65 unit_models/AttachmentSets/Final European CB Gun_hre_norm.texture 0  1 5 Horse 14 MTW2_HR_Pistol 13 MTW2_HR_Spear 1 22 MTW2_HR_Pistol_Primary 1 21 MTW2_HR_spear_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    This is a set of attachments your unit uses. I'm not really 100% sure what any of this stuff does, except that you need to start this block with the number of such blocks it's reading in (Again, the number of factions that use the unit), and the faction name in the usual length-string format.

    And as you can see the whole thing is repeated for the armor upgrade model(s).

    Now lets see what this looks like after we edit it for our new unit (My personal suggestion is to copy the whole block, paste it into a separate notepad window, edit it there, and then paste it back into the file. Be SURE that when you paste it back in, you put the block at the end of another block, and have a single space at both ends).

    Code:
    11 GR_Dragoons 1 4 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod0.mesh 121 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod1.mesh 900 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod2.mesh 2500 53 unit_models/_Units/RN_Half_3Q_Plate/reiters_lod3.mesh 6400 1 9 byzantium 79 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_byzantium.texture 76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_normal.texture 41 unit_sprites/byzantium_Reiters_sprite.spr 1 9 byzantium 65 unit_models/AttachmentSets/Final European CB Gun_hre_diff.texture 65 unit_models/AttachmentSets/Final European CB Gun_hre_norm.texture 0  1 5 Horse 14 MTW2_HR_Pistol 13 MTW2_HR_Spear 1 22 MTW2_HR_Pistol_Primary 1 21 MTW2_HR_spear_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002 11 reiters_ug1 1 4 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod0.mesh 121 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod1.mesh 900 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod2.mesh 2500 57 unit_models/_Units/RN_Half_3Q_Plate/reiters_ug1_lod3.mesh 6400 1 9 byzantium 79 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_byzantium.texture 76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_normal.texture 45 unit_sprites/byzantium_Reiters_ug1_sprite.spr 1 9 byzantium 65 unit_models/AttachmentSets/Final European CB Gun_hre_diff.texture 65 unit_models/AttachmentSets/Final European CB Gun_hre_norm.texture 0  1 5 Horse 14 MTW2_HR_Pistol 13 MTW2_HR_Spear 1 22 MTW2_HR_Pistol_Primary 1 21 MTW2_HR_spear_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    As you can see, a few changes have been made. I kept the meshes, because I want to use the Reiter models. I've changed the faction name, and the texture as well. Note that there is no unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_byzantium.texture , so we'll have to create one. If you read through the section above you should be able to see what's been changed and why.

    Step Three: Texture Alteration

    So, now we have to create our texture! No wait... it's not quite as hard as it sounds.

    First you go to unit_models/_Units/RN_Half_3Q_Plate/textures. In here you'll see textures for this model type for a bunch of different factions. What you need to do is open one, say rn_half_3q_plate_england.texture, with a hex editor, and cut (Cut to the clipboard, you're going to need to paste it back in later) the first 48 bytes. Now rename the file from .texture to .dds, and load it up in your favorite image processing software. I'm going to be talking about how to work with it in Photoshop CS2, because that's what I own.

    What you do now is turn all those areas of British red into Byzantine purple. The way we do that is to go to image->adjustments->replace color, and use the cursor to select a bright red spot. Now use the HSB sliders on the bottom to adjust that bright red to a bright purple. Now adjust the threshold slider at the top until the image looks the way you want it. Presto!

    If you're anal you can work your faction emblem into it the purple fields now, but it will look good as is. Just save the file, change the file extension back to .texture, and paste those 48 bytes back into the beginning of the file.

    You can now start the game and use your new unit in custom games! Aren't you proud of yourself?

    You might notice there are some things missing though. Like their icon looks like a peasant, and when you mouse over the unit it says "unlocalized placement text". We should probably fix that huh?

    Of course we should!

    Step Four: Giving Your Unit An Icon

    So go to data/ui/units/hre and copy #reiters.tga over to the data/ui/units/byzantium folder, and rename it #gr_dragoons.tga. Optionally you can go in and color parts of the icon purple. It's up to you.

    Your unit now has it's very own shiny icon!

    All that's left is the text.

    Step Five: Editing the Unit Text File

    So, what you're going to do is get Alpaca's txt.bin converter from the thread here in this forum, place it in your data/text folder, and run it!

    Now you can edit export_units.txt. Just copy the entry for some other unit, Reiters for instance, and change the labels.

    In other words copy and paste this:
    Code:
    {Reiters}	Reiters
    {Reiters_descr}	Reiters derive their name from the German word reiter, meaning horseman. Generally from German states, Reiters are armed with a pistol and spear, and well protected by plate armour. They often employ the shooting circle tactic to create a continuous cycle of firing and reloading. Once the enemy are softened up by this treatment, they charge in and finish them off the old fashioned way.
    {Reiters_descr_short}	Effective gunpowder units, Reiters are armed with a pistol and spear, and protected by plate armour.
    And change it to this:
    Code:
    {GR_Dragoons}	Reiters
    {GR_Dragoons_descr}	Reiters derive their name from the German word reiter, meaning horseman. Generally from German states, Reiters are armed with a pistol and spear, and well protected by plate armour. They often employ the shooting circle tactic to create a continuous cycle of firing and reloading. Once the enemy are softened up by this treatment, they charge in and finish them off the old fashioned way.
    {GR_Dragoons_descr_short}	Effective gunpowder units, Reiters are armed with a pistol and spear, and protected by plate armour.
    And you're all finished.

    You might want to change the actual text to something more appropriate of course. But my fingers are getting tired from typing all this.

    Thank you for flying Musashi mod lines, we hope you have a pleasant modding experience.
    Last edited by Musashi; 12-22-2006 at 02:24. Reason: Added Unit Portrait + Info about DB file
    Fear nothing except in the certainty that you are your enemy's begetter and its only hope of healing. For everything that does evil is in pain.
    -The Maestro Sartori, Imajica by Clive Barker

  2. #2
    the G-Diffuser Senior Member pevergreen's Avatar
    Join Date
    Nov 2006
    Location
    Brisbane, Australia
    Posts
    11,585
    Blog Entries
    2

    Default Re: Tutorial - Adding a unit to the game

    Clap clap clap etc. Great work there! Will help many a budding modder.
    Quote Originally Posted by TosaInu
    The org will be org until everyone calls it a day.

    Quote Originally Posted by KukriKhan View Post
    but I joke. Some of my best friends are Vietnamese villages.
    Quote Originally Posted by Lemur
    Anyone who wishes to refer to me as peverlemur is free to do so.

  3. #3
    Member Member Musashi's Avatar
    Join Date
    Nov 2002
    Location
    The Mists of Legend
    Posts
    811

    Default Re: Tutorial - Adding a unit to the game

    Thanks... it only took me... 2 and a half hours or so to type it all up and edit it... O.o
    Fear nothing except in the certainty that you are your enemy's begetter and its only hope of healing. For everything that does evil is in pain.
    -The Maestro Sartori, Imajica by Clive Barker

  4. #4

    Default Re: Tutorial - Adding a unit to the game

    Excellent work Musashi!

    Might I suggest an alternate name, albeit not historical or correct name? Byzantine Dragonarioi. What do you think?

    Cataphract Of The City

  5. #5
    Member Member Varyar's Avatar
    Join Date
    Aug 2003
    Location
    Europe
    Posts
    50

    Default Re: Tutorial - Adding a unit to the game

    A question: which of these steps do you need to undertake to simply make an already existent unit available to a new faction? In my case I want to give the Naffatun to the Moors. I don't even care about the texture as long as the guys are there and visible.
    Yalla! My Sultan wishes you dead!

  6. #6
    Member Member the_mango55's Avatar
    Join Date
    Apr 2004
    Location
    Raleigh, North Carolina
    Posts
    94

    Default Re: Tutorial - Adding a unit to the game

    Yeah, I can't get this to work >.<

    Good info though.

    I'm pretty sure its the Model file that's getting me screwed up, because I have created new units for factions by putting mounted unit from one faction on another mount from the same faction, changing the stats, text files, and unit info.



    Do you have to do this in the base game, in a mod folder, or can you do it in either (I have tried both and neither worked)

    BTW, can you post a screenshot of your unit?
    "You're drunk again!"
    "Na Im just exhausted from staying up all night drinking!" - Family guy

  7. #7
    Member Member Musashi's Avatar
    Join Date
    Nov 2002
    Location
    The Mists of Legend
    Posts
    811

    Default Re: Tutorial - Adding a unit to the game

    Quote Originally Posted by Varyar
    A question: which of these steps do you need to undertake to simply make an already existent unit available to a new faction? In my case I want to give the Naffatun to the Moors. I don't even care about the texture as long as the guys are there and visible.
    Well, since Naffatun don't have an entry in the model DB file for the moors, you'll have to either change the lines for the Turks to be for the Moors by changing the faction name (You're in luck, in that they're the same number of letters, so you can literally just change where you see "Turks" to "Moors"), or add texture lines for the Moors. The problem with changing the Turks lines, is that the Naffatun will become invisible when the Turks field them.
    Fear nothing except in the certainty that you are your enemy&#39;s begetter and its only hope of healing. For everything that does evil is in pain.
    -The Maestro Sartori, Imajica by Clive Barker

  8. #8

    Default Re: Tutorial - Adding a unit to the game

    Excellent tutorial.I still have a problem though....
    This is what I tried yo do:
    I want to add a heavy spear unit to the byzantines.Meaning, spearmen with the body and shield and texture of the dismounted byzantine lancers.So I downloaded a mesh editor to give the lancers a spear instead of a sword.Did that, naming the new model gr_heavy_spearmen.And, this is how the battle_models file looks like:

    17 gr_heavy_spearmen
    1 4
    66 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_lod0.mesh 121
    66 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_lod1.mesh 900
    66 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_lod2.mesh 2500
    66 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_lod3.mesh 6400
    1
    9 byzantium
    82 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_byzantium_L.texture
    79 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_normal_L.texture
    52 unit_sprites/byzantium_Byzantine_Infantry_sprite.spr
    1
    9 byzantium
    60 unit_models/AttachmentSets/Final Kite_byzantium_diff.texture
    60 unit_models/AttachmentSets/Final Kite_byzantium_norm.texture 0
    1
    4 None
    10 MTW2_Spear 0
    2
    18 MTW2_Spear_primary
    14 fs_test_shield 0
    16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    21 gr_heavy_spearmen_ug1
    1 3
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug1_lod0.mesh 121
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug1_lod1.mesh 1225
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug1_lod2.mesh 6400
    1
    9 byzantium
    82 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_byzantium_C.texture
    79 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_normal_C.texture
    56 unit_sprites/byzantium_Byzantine_Infantry_ug1_sprite.spr
    1
    9 byzantium
    60 unit_models/AttachmentSets/Final Kite_byzantium_diff.texture
    60 unit_models/AttachmentSets/Final Kite_byzantium_norm.texture 0
    1
    4 None
    10 MTW2_Spear 0
    2
    18 MTW2_Spear_primary
    14 fs_test_shield 0
    16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    21 gr_heavy_spearmen_ug2
    1 3
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug2_lod0.mesh 121
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug2_lod1.mesh 1225
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug2_lod2.mesh 6400
    1
    9 byzantium
    83 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_byzantium_CP.texture
    80 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_normal_CP.texture
    66 unit_sprites/byzantium_Dismounted_Byzantine_Lancers_ug2_sprite.spr
    1
    9 byzantium
    60 unit_models/AttachmentSets/Final Kite_byzantium_diff.texture
    60 unit_models/AttachmentSets/Final Kite_byzantium_norm.texture 0
    1
    4 None
    10 MTW2_Spear 0
    2
    18 MTW2_Spear_primary
    14 fs_test_shield 0
    16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    21 gr_heavy_spearmen__ug3
    1 3
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug3_lod0.mesh 121
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug3_lod1.mesh 1225
    70 unit_models/_Units/ES_Greek_Greek_Heavy/gr_heavy_spearmen_ug3_lod2.mesh 6400
    1
    9 byzantium
    82 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_byzantium_P.texture
    79 unit_models/_Units/ES_Greek_Greek_Heavy/textures/mtw2_es_greek_normal_P.texture
    66 unit_sprites/byzantium_Dismounted_Byzantine_Lancers_ug3_sprite.spr
    1
    9 byzantium
    60 unit_models/AttachmentSets/Final Kite_byzantium_diff.texture
    60 unit_models/AttachmentSets/Final Kite_byzantium_norm.texture 0
    1
    4 None
    10 MTW2_Spear 0
    2
    18 MTW2_Spear_primary
    14 fs_test_shield 0
    16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002

    something must be wrong....the game works if I use another soldier in the EDU file, so the problem must be here.Can anyone help?

  9. #9

    Default Re: Tutorial - Adding a unit to the game

    Turns out I'd used the kite shield texture instead of the triangular shield of the spearmen....I had to do the mesh editing from the beginning, I finally added heavy spearmen to the Byzantines.

  10. #10

    Default Re: Tutorial - Adding a unit to the game

    could you share and if you have pictures show. if you could make if avalible for download .

  11. #11

    Default Re: Tutorial - Adding a unit to the game

    my mounted janissary musketeers as you say "so easy to do" im newbie and excites me mod the units xD, follow the love for guns xD


  12. #12

    Default Re: Tutorial - Adding a unit to the game

    Hmmm....how do I post images?

  13. #13

    Default Re: Tutorial - Adding a unit to the game

    Quote Originally Posted by Lord_XXX
    my mounted janissary musketeers as you say "so easy to do" im newbie and excites me mod the units xD, follow the love for guns xD

    Another little unit modification, my "Granaderos" or in english grenadier, this spanish soldier using a modified handgun shooting exploding shoots



    Here some apachean flying around


    Englishmen receiving a spanish gift



    some flying englishmen, enjoy! love for gunpowder weapons

  14. #14
    Aspiring Historian Member sephirothno12000's Avatar
    Join Date
    Apr 2005
    Location
    U.S.
    Posts
    49

    Default Re: Tutorial - Adding a unit to the game

    Bravo! As soon as I finish upgrading my cpu to finally run the game, I shall be adding many a unit to my beloved HRE.
    "One must look to the past, in order to define the future" Confucius

  15. #15
    Member Member Malachus's Avatar
    Join Date
    Jul 2004
    Location
    Flint, MI
    Posts
    212

    Default Re: Tutorial - Adding a unit to the game

    Alrighty guys, I need some help here. Upon loading the game, it keeps crashing during the splash screen, giving me an error:

    12:18:16.250 [script.err] [error] Script Error in data/export_descr_unit.txt, at line 14770, column 2
    Could not find soldier battle model for unit type 'norman_spearmen'.

    12:18:16.250 [data.invalid] [error] DATABASE_TABLE error found : error reading record from file data/export_descr_unit.txt.


    Essentially, I'm trying to create a Norman Knight that uses the spear instead of a sword. Using, GOM's mesh converter, I edited the druzhina model to use a spear and have a kite shield slung across its back.


    Here's what I have in my modelsdb file (note that I'm using different animations. I want these guys to fight with the spear using both hands and, although not perfect, this is the most realistic-looking animation I could find from what we have so far).

    15 norman_spearmen
    1 4
    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod0.mesh 121
    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod1.mesh 900
    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod2.mesh 2500
    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod3.mesh 6400
    1
    6 sicily
    72 unit_models/_Units/EN_Lmail_Hmail/textures/en_lmail_hmail_sicily.texture
    72 unit_models/_Units/EN_Lmail_Hmail/textures/en_lmail_hmail_normal.texture
    52 unit_sprites/sicily_Dummy_EN_Spearmen_ug3_sprite.spr
    6 sicily
    57 unit_models/AttachmentSets/Final Kite_sicily_diff.texture
    57 unit_models/AttachmentSets/Final Kite_sicily_norm.texture 0
    1
    4 None
    16 MTW2_2HSwordsman 0
    2
    19 MTW2_2H_Axe_primary 0
    16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002


    Here's what I have in my EDU

    type norman spearmen
    dictionary norman_spearmen ; Norman Spearmen
    category infantry
    class spearmen
    voice_type Heavy
    banner faction main_spear
    banner holy crusade
    soldier norman_spearmen, 60, 0, 1.2
    attributes sea_faring, hide_forest, can_withdraw
    formation 1.2, 1.2, 2.4, 2.4, 4, square
    stat_health 1, 0
    stat_pri 8, 3, no, 0, 0, melee, melee_blade, piercing, spear, 25, 0.6
    ;stat_pri_ex 0, 0, 0
    stat_pri_attr spear, spear_bonus_8
    stat_sec 0, 0, no, 0, 0, no, melee_simple, blunt, none, 25, 1
    ;stat_sec_ex 0, 0, 0
    stat_sec_attr no
    stat_pri_armour 8, 6, 0, metal
    ;stat_armour_ex 5, 7, 0, 0, 3, 6, 6, metal
    stat_sec_armour 0, 0, flesh
    stat_heat 4
    stat_ground 1, -2, 3, 2
    stat_mental 5, normal, highly_trained
    stat_charge_dist 20
    stat_fire_delay 0
    stat_food 60, 300
    stat_cost 1, 570, 155, 85, 65, 540, 4, 130
    armour_ug_levels 3
    armour_ug_models norman_spearmen
    ownership sicily
    era 0 sicily
    ;unit_info 7, 0, 14


    The modelsdb file is up-to-date with regards to the first line number of models in the file and as far as I can tell, everything is correct with regards to the counts and spaces. I just can't tell where the breakdown between that file and the EDU is coming from...

    Any help would be greatly appreciated.

    Malachus

  16. #16

    Default Re: Tutorial - Adding a unit to the game

    Hi Malachus

    Quote Originally Posted by Malachus

    12:18:16.250 [script.err] [error] Script Error in data/export_descr_unit.txt, at line 14770, column 2
    Could not find soldier battle model for unit type 'norman_spearmen'.

    12:18:16.250 [data.invalid] [error] DATABASE_TABLE error found : error reading record from file data/export_descr_unit.txt.

    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod0.mesh 121
    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod1.mesh 900
    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod2.mesh 2500
    59 unit_models/_Units/EN_Lmail_Hmail/norman_spearmen_lod3.mesh 6400
    Check you've got the four files in the right folder, also check case on names, etc.

    Quote Originally Posted by Malachus
    4 None
    16 MTW2_2HSwordsman 0
    2
    19 MTW2_2H_Axe_primary 0
    You've given him a secondary animation sequence although he doesn't have a secondary weapon, not sure if this will throw a spanner in the works.

    Quote Originally Posted by Malachus
    armour_ug_levels 3
    armour_ug_models norman_spearmen
    You've got 3 upgade levels but only one upgrade model, again not sure if this will make things fall over.

    Quote Originally Posted by Malachus
    Any help would be greatly appreciated.

    Malachus
    I'm not an expert on text entries but this is what I can see.

    Cheers

    GrumpyOldMan

  17. #17
    Member Member KnightErrant's Avatar
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    458

    Default Re: Tutorial - Adding a unit to the game

    @Malachus

    Also, this looks like it's missing a faction count for the attachment sets:

    1
    6 sicily
    72 unit_models/_Units/EN_Lmail_Hmail/textures/en_lmail_hmail_sicily.texture
    72 unit_models/_Units/EN_Lmail_Hmail/textures/en_lmail_hmail_normal.texture
    52 unit_sprites/sicily_Dummy_EN_Spearmen_ug3_sprite.spr
    6 sicily
    57 unit_models/AttachmentSets/Final Kite_sicily_diff.texture
    57 unit_models/AttachmentSets/Final Kite_sicily_norm.texture 0
    Should be:

    Code:
    1
    6 sicily
    72 unit_models/_Units/EN_Lmail_Hmail/textures/en_lmail_hmail_sicily.texture
    72 unit_models/_Units/EN_Lmail_Hmail/textures/en_lmail_hmail_normal.texture
    52 unit_sprites/sicily_Dummy_EN_Spearmen_ug3_sprite.spr
    1
    6 sicily
    57 unit_models/AttachmentSets/Final Kite_sicily_diff.texture
    57 unit_models/AttachmentSets/Final Kite_sicily_norm.texture 0

  18. #18
    Member Member Malachus's Avatar
    Join Date
    Jul 2004
    Location
    Flint, MI
    Posts
    212

    Default Re: Tutorial - Adding a unit to the game

    Hmm... thanks for the replies guys. Unfortunately, I'm still getting the same problem. I was able to successfully put these guys into the game by essentially replacing the dismounted druzhina unit. I don't know why, but the game is only reading the vanilla unit models names/references, not my own. So frustrating

    Anyway, here are a couple of pics so you can have an idea of what I'm trying to do...


    https://img83.imageshack.us/my.php?i...pearmenaj5.jpg

    https://img83.imageshack.us/my.php?i...earmen2uw1.jpg

    https://img88.imageshack.us/my.php?i...earmen3ic6.jpg
    Last edited by Malachus; 04-21-2007 at 03:18.

  19. #19
    Grand Duke of Zilch Member supadodo's Avatar
    Join Date
    Oct 2006
    Location
    I'm Asian, pick a country in Asia. Most of us look alike anyway.
    Posts
    144

    Default Re: Tutorial - Adding a unit to the game

    Hey I am new to this modding thing so I'm kinda trying hard to get things working by reading the threads and tutorials.

    So I'm trying to put Landskneckt Pikeman for the HRE(they are actually a merc unit)

    First try, without editing th modelDB file, I get it to work but I get silver surfers with sticks and the icon card is a peasant though info is all good.

    So I tried changing the code in modelDB to try and put in textures.

    This is the code:
    kt_pikemen_lod0.mesh 121 64 unit_models/_Units/RN_Light_Lmail/landschneckt_pikemen_lod1.mesh 900 64 unit_models/_Units/RN_Light_Lmail/landschneckt_pikemen_lod2.mesh 2500 64 unit_models/_Units/RN_Light_Lmail/landschneckt_pikemen_lod3.mesh 6400 2 4 merc 71 unit_models/_Units/RN_Light_Lmail/textures/RN_Light_Lmail_merc.texture 72 unit_models/_Units/RN_Light_Lmail/textures/RN_Light_Lmail_normal.texture 49 unit_sprites/merc_Landschneckt_Pikemen_sprite.spr 2 3 hre 65 unit_models/AttachmentSets/Final European Light_merc_diff.texture 65 unit_models/AttachmentSets/Final European Light_merc_norm.texture 0 1 3 None 9 MTW2_Pike 15 MTW2_Non_Shield 1 17 MTW2_Pike_primary 1 18 MTW2_Sword_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    It just gives me a blank screen when I start Med2. I tried searching around this thread for any clue but none worked. Plus I dunno if I had put the landsknecht textures into the hre folder. Can someone please tell me how?
    Okay thx.
    Weird Facts I have contemplated

    -Thesaurus is not a species of dinosaur.
    -Potassium is not found in potatoes.
    -Its Naples, not Nipples.
    -All roads certainly do not lead to Rome. Does your state highway link you to it?
    - Dog is God spelled backwards but praying to dogs is a bit stupid.
    - Fart is Hydrogen Sulfide with methane and oxygen and is indeed flammable.
    - Igniting a fart is painful.

  20. #20

    Default Re: Tutorial - Adding a unit to the game

    Your problem has to do with the number of factions you're trying to load textures for. With the body textures, you're telling the program to load two texture sets, but you only have the code for the mercenary textures. Likewise for the attachment sets - you tell it to read in 2 sets, but only have code for the HRE textures. Assuming you want to keep the pikemen as a mercenary unit as well, it should read like this:
    Code:
    20 landschneckt_pikemen 
    1 4 
    64 unit_models/_Units/RN_Light_Lmail/landschneckt_pikemen_lod0.mesh 121 
    64 unit_models/_Units/RN_Light_Lmail/landschneckt_pikemen_lod1.mesh 900 
    64 unit_models/_Units/RN_Light_Lmail/landschneckt_pikemen_lod2.mesh 2500 
    64 unit_models/_Units/RN_Light_Lmail/landschneckt_pikemen_lod3.mesh 6400 
    2 
    4 merc 
    71 unit_models/_Units/RN_Light_Lmail/textures/RN_Light_Lmail_mercs.texture 
    72 unit_models/_Units/RN_Light_Lmail/textures/RN_Light_Lmail_normal.texture 
    49 unit_sprites/merc_Landschneckt_Pikemen_sprite.spr 
    3 hre
    69 unit_models/_Units/RN_Light_Lmail/textures/RN_Light_Lmail_hre.texture 
    72 unit_models/_Units/RN_Light_Lmail/textures/RN_Light_Lmail_normal.texture 
    49 unit_sprites/merc_Landschneckt_Pikemen_sprite.spr 
    2 
    4 merc 
    65 unit_models/AttachmentSets/Final European Light_merc_diff.texture 
    65 unit_models/AttachmentSets/Final European Light_merc_norm.texture 0  
    3 hre 
    64 unit_models/AttachmentSets/Final European Light_hre_diff.texture 
    64 unit_models/AttachmentSets/Final European Light_hre_norm.texture 0  
    1 
    4 None 
    9 MTW2_Pike 
    15 MTW2_Non_Shield 1 
    17 MTW2_Pike_primary 1 
    18 MTW2_Sword_Primary 
    16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    Hope there's no typos...can't edit

    Oh...and as for my post, it wasn't a problem with the contents of the modeldb file, it was the location. I've since fixed it.

  21. #21

    Default Re: Tutorial - Adding a unit to the game

    Hi there.

    A small question. What if I only want to enlarge the ownership of a certain unit, for instance, allowing everyone to train Musketeers or Organ Guns...

    It is all this still necessary?



    I've been trying to make Janissaries trainable for the Byzantines in every period but I've failed!
    Last edited by elbasto; 06-01-2007 at 00:51.

  22. #22
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Tutorial - Adding a unit to the game

    Musashi, great tut.!!

    I've gone from being utterly intimidated by the battle_models file to feeling pretty confident altering it thanks to your tut.

    Thanks!


    G


    ps; for the "having trouble" modders, set your file up properly so you can read it, makes a huge diff.

    let my explain with an example

    the entry for the basic(non-upgraded) Aventurier;
    Code:
    10 aventurier 1 4 56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod0.mesh 121 56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod1.mesh 900 56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod2.mesh 2500 56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod3.mesh 6400 1 6 france 76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_france.texture 76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_normal.texture 41 unit_sprites/france_Aventurier_sprite.spr 1 6 france 68 unit_models/AttachmentSets/Final European CB Gun_france_diff.texture 68 unit_models/AttachmentSets/Final European CB Gun_france_norm.texture 0  1 4 None 18 MTW2_Fast_Crossbow 20 MTW2_Non_Shield_Fast 1 21 MTW2_Crossbow_Primary 1 18 MTW2_Sword_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    the way I work with it;
    Code:
    10 aventurier 
    1 4 
    56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod0.mesh 121 
    56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod1.mesh 900 
    56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod2.mesh 2500 
    56 unit_models/_Units/RN_Half_3Q_Plate/aventurier_lod3.mesh 6400 
    1 
    6 france 
    76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_france.texture 
    76 unit_models/_Units/RN_Half_3Q_Plate/textures/rn_half_3q_plate_normal.texture 
    41 unit_sprites/france_Aventurier_sprite.spr 
    1 
    6 france 
    68 unit_models/AttachmentSets/Final European CB Gun_france_diff.texture 
    68 unit_models/AttachmentSets/Final European CB Gun_france_norm.texture 0  
    1 4 None 
    18 MTW2_Fast_Crossbow 
    20 MTW2_Non_Shield_Fast 1 
    21 MTW2_Crossbow_Primary 1 
    18 MTW2_Sword_Primary 
    16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002

  23. #23

    Default Re : Tutorial - Adding a unit to the game

    I need to add an officer to a new unit :
    So I have created US Dragoon (Us Cavalry) + one officer that look "US" , I am trying to add this Unit into The Spanish faction (because I still wan't to be able to play the original also) so they should have each a different looking officer .
    The Dragoon spanish should remain with it's own officer, How do I add my new officer to my new unit

    thanks
    Last edited by kungfuserge; 11-02-2007 at 11:04.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO