Editing the battle_models.modeldb (BMDB) file does not have to be a nightmare.
You only need the right tools and pay attention to the patterns on the
file. Then the computer can do the editing for you while you relax and
worry about more important stuff than cutting and pasting.
Let me show you how I did it. The good thing about it is that you can do it
with free-software and will take you only seconds to add any number of
existing units in BMDB to your faction of choice. Plus you will learn
some simple and yet powerful regular expressions (regexp) that will make
editing any text file much easier for you in the future.
What you'll need:
1) Knight Errant's formatted battle_models.modeldb file (http://www.twcenter.net/forums/downl...o=file&id=1180)
2) gvim (This is a real powerful editor, and best of all, free! Get it
at http://www.vim.org/download.php#pc)
3) the macros for gvim that I've develop to handle battle_models.modeldb
(http://www.twcenter.net/forums/downl...o=file&id=1473)
4) Read the rest of this tutorial. I know it is long but I think it will
pay off!
------------------------------------------
Step One: produce a list of units you want
------------------------------------------
A) Open the battle_models.modeldb in gvim;
B) Press ESC key. That will put you in the "Normal" mode in gvim;
C) Once in normal mode type <:split faction.macro> (dont' type the < or
> they only serve as delimiters for you to see better the command lines
in this text) and press ENTER.
That will split the gvim window in two and open file faction.macro on the
top window. (to move between the separate windows in gvim press ctrl+W
twice, or use the mouse)
D) Your cursor should land at the beginning of the first and only line.
This is file is actually a macro, that will allow you to select all the
units in BMDB assigned to a given faction. Let's put this macro in a
buffer and use it!
E)The macro should look like (don't copy from the post, use the attached files, because the macros get screwed up when pasting my post in here)
Code:
/-^M /moors^M?-^M +yy^W^Wp^W^W
To edit this macro, which is a collection of gvim commands, type <i>,
thus entering in "Insert" mode. Now change <moors> to your liking.
_What the macro does (optional)_
Code:
What the macro will do is to move to the
next line containing a minus sign (/-), then it will look for and move
to the next line containing the faction name (/moors) and move back to
the minus sign it found before (?-) and then the command (+) will
advance the cursor one more line, thus landing on the line containing
the unit name (check BMDB file and see if you understand what the
movement is), belonging to our assigned faction. We then record the name
by yanking the whole line (yy). We then change windows by commands ^W^W
(this was obtained by <CTRL+W>), print the contents of line (command p)
in this other window and then come back to our original window (again
using ^W^W). BTW, the ^M shows in the macro when I pressed ENTER key
.
F) Press ESC key and go back to Normal mode. Then type <"ay$>. This will
save the whole line in a buffer called a (y is gvim command for yanking
text, and we are yanking from the position of the cursor to the end of
the line, $)
G) close the upper window by typing <SHIFT + zz>
H) split the window again. Now type <:split UNITSFILE>. The name
UNITSFILE is a dummy, so you can use whatever you want. For now give a
name that is not in your current folder so that you are creating a new
file. Press <CTRL+W> twice again and go back to the window containing
the BMDB file. Type <:1> to go back to the first line of BMDB.
G) In normal mode type <200@a>. This will execute our macro, stored in
buffer a, 200 times. That should be enough to capture all the units from
your chosen "base" faction. As the macro runs you should see the names
of all units appearing on the UNITSFILE window in gvim. After the macro has
run its course, move your cursor to the unitfile window (CTRL+W twice)
and (still in normal mode) issue the command
<:%s/^[0-9]* //>
That is a regexp to delete all numbers appearing before the unit names.
_explanation of the regexp (optional)_
Code:
% means that this command will act on all lines of our file.
s/^[0-9]* // is the regexp per se. The command "s" will substitute any
numeric character (in any number as the * indicates) followed by a
space (^[0-9]* ) right at the beginning of the line, denoted by "^".
H) Now chose the units you want to keep. If a unit has upgrades, denoted
by suffixes _ug, _ug1, _ug2, keep them as well in the list. In gvim you can
delete a line by tipying <dd> in normal mode. If you want to delete 5
lines, type <5dd>. Cool, eh? If you want to delete a certain range of
lines, say from line 20 to 70 just type, in normal mode, <20,70d>. If
you want to undo anything press <u> or redo it <CTRL+r> as many times as
necessary. Once you decided which units you want let's go to the next
step.
I) Save the file. type <ESC:w>
------------------------------------------
Step Two: Adding your units
------------------------------------------
A) open a third window with the macros: press ESC key (to enter normal
mode) and then type <:split units.macro> (you can use tab key for
auto-completion). On the units.macro file you will find the macros for
adding a given unit appearing on your UNITSFILE to your "target"
faction. This file will contain three macros, one for each type of
record in the BMDB file, because they actually have slightly different
formats. One is for the mount units (like horses, camels etc), another
for all other unit types except for generals and captains, which are in
a third format. SO you should order your units accordingly with this
three types so that the similar types are grouped in consecutive lines,
which makes our life easier because then we can apply each macro a
certain obvious number of times. That should not be much of a problem because
the units in the BMDB appear on this order anyway.
B) Choose a macro and edit it accordingly. The macro for units other
than captains, generals or mounts is
Code:
#/ /5 moors ma/sprites +y`aP:s/5 moors/11 almoravides/ /5 moors / ma/0 +y`aP:s/5 moors/11 almoravides/ ?- /mesh 6400 +y$/"$ +
it looks quite intimidating, but the only thing you need to worry about
is to change the names and numbers for a given faction. If your "base"
faction is "hre" and your target faction is "hungary" then change:
"5 moors" for "3 hre" and
"11 almoravides" for "7 hungary"
C) Go to the beginning of the macro line and type (in normal mode)
<"ay$>
so now the buffer a has the new macro.
D) close the units.macro file without saving. To do this type <:q!> in normal
mode. Now you should have two windows, one with the units names and the other
with the BMDB file. Put you cursor on the first line of the UNITSFILE window
or at the first unit name of the right macro type.
E) count how many units you want to add to your "target" faction using
the new macro you've put on buffer "a". Let's say there are 5 of them,
and again they should be on different consecutive lines.
Go back to normal mode (just press ESC key) and type <5@a>. Then the
macro will add your five units for your target faction.
F) Save the MBDB file. If your cursor is not on the MBDB window put it
there (either with the mouse or CTRL+W) , type ESC key (to go to normal
mode) and then save by
typing (:w).
G) Close the files and YOU ARE DONE!
Normally this should take a couple seconds to complete. For the uninitiated
with gvim it might take longer. But now with gvim, the computer does the job
and you can concentrate on getting the skinning and other 2D art be the core
of your preoccupations.
I hope this will be useful. Dont' feel discourage by the extra step of
installing gvim, because in windows all it takes is to download the installer
and press a button. A plus is that you can now get to play with a real powerful
editor, and can apply some of what you've learn towards editing other text
files needed to mod the game. Good Luck.