The file data/unit_models/battle_models.modeldb (the "Model DB" file) is key to driving the animations of the little sim soldiers on the tactical battle display. For many (most?) of us Total War addicts, this is one of the cooler aspects of the game system -- and the focus of many modders' attention. So, understanding how to update this file correctly is critical to getting a mod to work.
I think I've finally cracked the code! In these posts, I'm going to present what I've learned, in the hopes that it will help reduce the frustrations of aspiring modders everywhere.That way, they can publish their results sooner, and we can all have more fun!
![]()
There are three key concepts for understanding this file:
- Counted-length Lists (the number of items in the list, followed by the items themselves. A String is a List of characters).
- Record structures (different Record types can have different structure).
- Placeholders (NULL values, also known as 'nil' in some places).
With these, we can explain the whole file.
As KnightErrant explained, the file is structured. In fact, it is one long counted-length List of Records. Each of these top-level Records has the same structure:
- Name
- Number
- List of mesh Records
- Faction List of texture/sprite Records
- (Parallel) faction List of texture/sprite Records for AttachmentSets
- List of animation Records
Where things get a little confusing is that the last two sometimes omit values, and leave a "0 " (representing NULL) placeholder -- because the Record structure expects something there (even if it's "nothing").
Here's a short example:
What this means:Code:16 albanian_cavalry 1 4 60 unit_models/_Units/LB_Plain_Fancy/albanian_cavalry_lod0.mesh 121 60 unit_models/_Units/LB_Plain_Fancy/albanian_cavalry_lod1.mesh 900 60 unit_models/_Units/LB_Plain_Fancy/albanian_cavalry_lod2.mesh 2500 60 unit_models/_Units/LB_Plain_Fancy/albanian_cavalry_lod3.mesh 6400 1 4 merc 71 unit_models/_Units/LB_Plain_Fancy/textures/LB_plain_fancy_mercs.texture 72 unit_models/_Units/LB_Plain_Fancy/textures/LB_plain_fancy_normal.texture 45 unit_sprites/merc_Albanian_Cavalry_sprite.spr 1 4 merc 65 unit_models/AttachmentSets/Final European Light_merc_diff.texture 65 unit_models/AttachmentSets/Final European Light_merc_norm.texture 0 1 5 Horse 13 MTW2_HR_Spear 12 MTW2_HR_Mace 1 21 MTW2_HR_spear_Primary 1 17 MTW2_Mace_Primary 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
- Name: "albanian_cavalry"
- The 1 means ... something (height? scaling? mass?). For mounts, this is always 1.12.
- The mesh Record follows. It is a List of 4 Records, each always has 2 items:
- a mesh file path String (the path is relative to the data directory) and
- an Integer (the distance, in terrain units, at which to use the mesh)
- 1 faction texture/sprite Record follows, they always have 4 items:
- a String (the faction's name). In this case, it's Mercenary-only unit (faction merc).
- the faction-specific texture file path String (again, relative file paths)
- the "normal" texture file path String (also relative)
- 1 sprite file path String (also relative)
- 1 (parallel) faction texture/sprite Record follows, this time for the AttachmentSet(s).
NOTE: the 3rd (sprite) path String is always NULL for the AttachmentSets.- 1 animation Record follows, they always have 4 items:
- a Record containing 3 Strings naming the animations to use:
- Mount (or "none"). In this case, a Horse.
- Primary Weapon. In this case, a Horse Rider (HR_, Camel Riders are CR_, and Elephant Riders are ER_) Spear.
- Secondary Weapon (or NULL, if the unit has only a Primary). In this case, a Right-Handed Mace.
- a List of Primary Weapon animations (usually 2: offensive and shield). In this case, only the Spear -- no shield.
- a List of Secondary Weapon animations (if present, same structure as Primary). In this case, only the Mace -- no shield.
- animation timing settings (unless the line starts with -1, in which case the values will all be zero)
Once you realize that the non-zero numbers are just the length of the things to follow, you almost stop noticing them. When you understand the structure, and format the text accordingly, you can easily spot errors.
Then, you can focus on the important details: does the name of the (primary, secondary) animation match the corresponding name of the weapon? Do these agree with the values in the export_descr_unit.txt ("EDU") file? Do the named files exist at the right locations? etc.
I've uploaded a copy of the re-formatted file I'm using to: http://www.twcenter.net/forums/downl...o=file&id=1979
Bookmarks