Results 1 to 17 of 17

Thread: Adding existing units into other factions in battle_models.modeldb made easy

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Adding existing units into other factions in battle_models.modeldb made easy

    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.
    Last edited by Cururu; June 22, 2007 at 04:03 PM.

  2. #2

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    In regard to Step 1G:

    Something that I noticed is that in windows gvim has a slight different behavior than in the Linux system where I originally wrote these macros. Probably is a difference in settings of gvim. As a result, the macro in windows wraps around the file extracting the names of units that have already been extracted. So after, extracting the names of the units check whether there are repeated entries towards the end of the unitsname file. Then delete those repeated entries and continue through the automatic editing procedure explained in my previous post in this thread
    Last edited by Cururu; June 23, 2007 at 10:09 AM.

  3. #3
    Dragon Tex's Avatar Foederatus
    Join Date
    Apr 2007
    Location
    Stationed in Arizona, USA
    Posts
    46

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    This is confusing. Which files do I need to open to start with? Where do I need to put your macros? Which file am I actually editing?

    When I started, I figured I had to open the model file. I did everything stated at the begining but didn't see "/-^M /moors^M?-^M +yy^W^Wp^W^W". I then closed it out and opened the faction.macro. I saw the info there. I started again by following the steps. I did the "i" and had to highlight moors to change it. Hit esc to go back into "normal mode" and typed "ay$" and all it did was add the y$ at the begining of the line. I don't know what to do!

    I really want this to work because it took me 2 weeks to get my current mod to work with the model file. (That was every free time I had at home and work everyday) Needless to say, the wife wasn't too happy!

  4. #4

    Default

    Dragon Tex,

    It is really simple, don't despair.

    In gvim normal mode is the one where you issue commands (always press ESC to go to normal mode ); we type text in the insert mode: to enter the insert mode always type <i> in the normal mode, and gvim should show a msg saying that it entered in Insert mode, and the cursor should change from the a "blocky" version (the normal mode cursor) to a slim bar (the insert mode cursor).

    Anyway here's a series of images that illustrate my first post. I will have to have more than one post because something is preventing me from just pasting the address of the images so they will be attached to the msgs (we are allowed only 5 attachments per post it seems). You just need the BMDB file and the macro files to be in a given directory.

    The first attached figure is what one sees by opening the BMDB file in gvim. Note the "fat" cursor on the upper left of the figure. It indicates we are in normal mode so whatever you type, you are typing commands, not text into your file. So I wrote <:split faction.macro> (again don't type < or >, they are just delimiters) and this command appears at the bottom of the gvim window (figure 2). Figure 3 shows the result of the split command: we have split the gvim window in two and the cursor goes to the first line. Save that first line in a buffer: <"ay$> (the double quote has to be typed, but only at the beginning). Close the upper window (type ZZ). Again split the window to open a file where you will put the unit file (figures 4 and 5)

    Figures 6 and 7:

    You should see the a new empty window after you issue the second split command. After that you put the cursor in the BMDB window (use mouse or CTRL+W twice) and you should get figure 7

    On figure 8 you see the result after applying the macro "faction.macro", it selects all the units from the moors faction. The only one it will not select is the very first one: mount_pony, I think, which you will have to edit by hand (working on that to automate it too, but could not find a good pattern to delimit this field).
    Figure 9 shows the command line to open the other macro file, units.macro. As I posted before there are three different "record" types in BMDB. One for mounts, a second for most other units, and a third for captains and generals. Figure 10 shows the result after opening the units.macro file and yanking the second macro of the file into a buffer a (note the command being output in the lower right corner of the gvim window: it says <"ay>. The moment I press <$> it will yank the entire line containing the macro.
    Last edited by Trajan; June 28, 2007 at 06:15 PM. Reason: Merged double

  5. #5

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    Now comes the fun part:

    Let's edit the entries where we only have the units names, by getting rid of the number appearing before them. Put the cursor on the units window (Figure 1 on this post). Enter in normal mode and type the command appearing on the lower left on Figure 2 of this post. As Figure 3 shows, we got rid of the numbers before the unit names.

    Now I screwed up the order of the figures. Go back to my previous post and put the macro into a buffer "a". After that put the cursor at the beginning of the line of the first unit you want to add to your "target" faction. In this case I chose "desert_cavalry". Note on the lower right of Figure 4 that I've type a command <2@a> (actually at the screenshot I still did not typed "a", because as soon as do it, the command will execute the macro in buffer "a" and the screen output of the command will dissapear). This means that I will add 2 units (desert_cavalry and desert_cavalry_ug1). In figure 5 we see the result: now there is an entry for almoravides in BMDB for the desert_cavalry_ug1 (and desert_cavalry as well, but not shown) and the numbers specifying the number of factions for a given model are updated as well.


    Dragon Tex: all this editing depends on two things:
    The previous formatting of BMDB file like knight's Errant, especially to update the numbers of factions that have a given model. The other is the type of macro you are choosing. Are sure all the 98 units are of the same type or you have mounts, units and generals in that list?
    Last edited by Cururu; June 24, 2007 at 09:43 PM.

  6. #6

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    Dragon Tex,

    Then you should apply the three different kinds of macros for each kind of unit.

    If you have 5 mount units than you should put on the buffer the corresponding macro, found on units.macro file. Then only do <5@a>, i.e. apply that macro 5 times only. Then for the next 91 units you could apply the second macro on the units.macro file, which is designed to operate on all other units except mounts and captains and generals. Make sure you put captains and generals unit names at the end, if they are not already there, so that you only have to issue the command once. Finally for the general and captain models you just do <2@a> once the third macro on units.macro file is put on the buffer a.

    I hope this will help you.

    BTW, you have to save your BMDB file, before checking to see which modifications you have on another program, because what gvim actually does is to save your file in a buffer. So the idea is that you modify the buffer and when you save then the buffer is written on to your file

  7. #7

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    Ok, Cururu this tutorial is not very helpful. I tried the other one, but it blew. No offense, but I can't get through this it is simply too confusing. I really really want to add some new units to France, but alas no one can put it in terms you average joe can understand. I'm not only asking I'm begging for your help. Please just keep it simple and concise.

    Thank you

  8. #8
    The Conquistador's Avatar Libertus
    Join Date
    Feb 2007
    Location
    From the Good ol' US of A
    Posts
    79

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    i need help i don't know how to install i clicked the install exe. but it won't do (sorry for the noob question)

  9. #9
    Dragon Tex's Avatar Foederatus
    Join Date
    Apr 2007
    Location
    Stationed in Arizona, USA
    Posts
    46

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    Ok, I finally got it to work..... kind of.

    I had to move your macros and the model fine to my desk top. I was getting excited cause everything was starting to fall in place. Now, here's the kicker. I wanted to copy all of milan's units. I did everything explained and it pulled all of them. Ok, I kept on going and got the units.macro in and made my changes to all. Went to the file line and did the <"ay$> thing and closed that one out. Went to my "unitfile" and typed <98@a> because milan had a total of 98 entries, because I'm wanting to clone milan. I saved and then open the model file with notepad and saw that it only added one entry.

    I don't know what happened.Is there something else I need to do?

    Just to let you know, I'm not the sharpest knife in the draw, but I am in the draw!

  10. #10
    Dragon Tex's Avatar Foederatus
    Join Date
    Apr 2007
    Location
    Stationed in Arizona, USA
    Posts
    46

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    mounts, units and generals

  11. #11

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    can one of you make a file that gives every faction the units of every other faction - that way, modding would be as easy as just picking and choosing what you want.

  12. #12

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    Bah it makes thinks even worse... A formatted modeldb files would be faster and easier to mod.

  13. #13

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    Quote Originally Posted by Hospitalier Grand Master View Post
    Bah it makes thinks even worse... A formatted modeldb files would be faster and easier to mod.


    Instead of whining, do something about it....
    There are two things which cannot be attacked in front: ignorance and narrow-mindedness. They can only be shaken by the simple development of the contrary qualities. They will not bear discussion. ---- Lord Acton

  14. #14

    Default Re: Adding existing units into other factions in battle_models.modeldb made easy

    Well I am not good as you expert modders... As you can master the programs far easier than me, would be better you to do this.

  15. #15

    Default Invisible Units !!!!!!!!!1

    I have created units, experimented with different types, in SS 6.1 mod. They are always invisible on the battlefield. I have seen others complain of this problem and seen the replies to them refer to "mymod" or --oi.bat or something or other... I dont have these - I am using SS 6.1 for Kingdoms. My men are still invisible... what is the real problem? I can give most troops to another nation by adding my nation to the existing battle_models file. But when I copy a unit EXACTLY, and paste it, and just add a different ownership the men are invisible... is there a file somewhere that needs to be edited? what is the deal??????

  16. #16

    Default Re: Invisible Units !!!!!!!!!1

    Quote Originally Posted by Mjolnir View Post
    I have created units, experimented with different types, in SS 6.1 mod. They are always invisible on the battlefield. I have seen others complain of this problem and seen the replies to them refer to "mymod" or --oi.bat or something or other... I dont have these - I am using SS 6.1 for Kingdoms. My men are still invisible... what is the real problem? I can give most troops to another nation by adding my nation to the existing battle_models file. But when I copy a unit EXACTLY, and paste it, and just add a different ownership the men are invisible... is there a file somewhere that needs to be edited? what is the deal??????
    You only need to work with the EDU and the battle_models.db, if you are using SS then you are using a mymod. All you need to do is understand the way the battle_models.db works, and of course have the actual textures and mesh's in the correct place. Look through a few tutorials on how to create unit, there are plenty about...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •