B Tutorial Animation How to add New Animations to your module.

Users who are viewing this thread

cdvader

Introduction.
Greetings, it's CdVader again, with another tutorial. This time, I'll show you how to either Add a new animation or edit old ones. The reason I'm making this tutorial is because of a Post I saw, and that made me think "Hey, why not make a tutorial!" :razz: . So, Berserker Pride asked this.
[quote author= Berserker Pride]I wonder if you could duplicate an animation so that you wouldn't have to overwrite an existing throwing type. [/quote]
And hopefully, I will show you how to do that.

Anyway. Thanks to 'mtarini' we can now edit, add, and do all kinds of things with Animations. Let's begin.

What do we need?
The game.
Mount & Blade - Version 1.011.
Mount & Blade - Module System for Version 1.011.

Some kind of a animation editing program. Here's two of the (probably) most known:
Autodesk 3ds Max
Blender

And the import/export SMD scripts for them.
3ds Max SMD Import/Export
Blender SMD Import
Working Blender Export Script.

And the most important thing of all.
Open BRF

PART 1 - Getting ready.
Okay. First of all, make sure you've got a working copy of Mount & Blade v1.011 and the ModuleSystem all set-up. Before you begin this tutorial, You must have SOME knowledge of the Module System. I highly recommend The Official ModuleSystem Documentation or another, a extremely good (a bit advanced) ModuleSystem Documentation made by Jik. After you have set up the ModuleSystem and gone through the Documentations, we can continue.

Now, install 'mtarinis' Open BRF. Just download & extract it to somewhere, like onto your desktop. OpenBRF is a very good alternative to BRFEdit, because it can edit Animations and Skeletons, which BRFEdit cannot. However, since OpenBRF is still in it's very early development stages (Alpha stage), it doesn't have all the necessary features like Material, Collision or Shader tabs. Thus, currently you should only use OpenBRF for Skeleton and Animation related stuff, and BRFEdit for all the other. But I'm quite sure that soon enough, OpenBRF will be better and more complete.

The next step is to get a Animation and Skeleton editing program. Blender is a bit complicated, but good. And it's also free, which is a really good thing. The other solution - 3ds Max is better in all ways, especially the price part. That's the only downside of Max - It costs around 3500$. I personally use 3ds Max. To get it, either download the 30-day Tutorial or, if you're lucky, you may get a Commercial edition (Or something like that) from school.

Okay, I belive we're ready.

Part 2 - Adding a "new" animation.
If anyone has seen the movie "Braveheart", in the last battle William's good friend inspired his fellow lads to battle by throwing William's giant sword over the field. If you haven't seen the movie, you can see the scene here. William Wallace's sword flight. It's really epic and it can also hurt your enemy real bad (Should the throw hit the enemy). So we'll try to create something like that, expect a bit more simpler, less epic, so you could throw many swords in a row.

Alright. Open 'OpenBRF', go to File > Open and open uni_throws. Whoa, a lot of Opens in that sentence. Ok, click on 'throw_javelin' and Duplicate it (press Right-Click). Rename it (Right-Click again) to 'throw_braveheart'. Go to File > Save and exit OpenBRF. Basically, that's how you duplicate Animations, so you won't run into the problem Berserker Pride had. If you don't duplicate and rename a animation, and then make a new animation line in module_animations.py, it will overwrite the type.

However, if you want to actually add in completely new, from-scratch animations, then either open 'skeletons.brf' using OpenBRF and export the skeleton there as 'Nude' or go to Tools > Edit Reference Data, click on the Skeleton tab and click on "human" and Export it as 'Nude'. Get the new, exported Nude skeleton to Blender or 3ds Max using a SMD Importer. When exporting from Max, make sure you tick it to a "Sequence" instead of "Referene". I am not sure about how it works in Blender. Currently, the OpenBRF's exporter is a bit unfinished (OpenBRF is still in Alpha stage), so all of the bones seem to be out of place, but you can actually create new animations, the only down-side is that it is harder to understand the skeleton than normal. However, do not fret, OpenBRF's Importer seems to re-fix the screwed up bone system. Importing it is really easy too, just open an existing .brf file (Can't make new ones currently) and go to Import > Skeletal Animation. That's it.
Okay, so in short, look at the old, existing animations to see how much Frames you approximately you need, export a Nude skeleton without any animations, make your animation, Import as Skeletal Animation and watch your new animation!
If you want to see a example, download this file. Don't worry, it's an .AVI so it cannot be a virus. It's a basic animation showed in OpenBRF I did just to test.

Okay, 'new' animation set-up, we can now move on. Go where your ModuleSystem is located, and open "module_animations.py", "header_items.py" and, not so necessary but for the sake of keeping it simple, "module_items.py". First, we will edit module_animations.py. Copy "ready_javelin" and "release_javelin" approximately at line 509. Paste them (replacing the old "unused_human_anims") at line 1123. Make sure you replace the old animations. Now, rename the stuff to _braveheart. Should look like this.

Code:
 ["ready_braveheart", acf_rotate_body,
   [0.3, "throw_braveheart", 0, 30, blend_in_ready],
 ],
 ["release_braveheart", acf_rotate_body,
   [1.0, "throw_braveheart", 55, 100, arf_blend_in_0],
 ],

Basically, these small script parts "define" the animation. If you look at the first script, 4 major things catch your eye. "ready_braveheart" is the first, that is the animation ID, used for referencing the animation. The next thing is "acf_rotate_body", which is pretty easy to guess. It rotates the body. The next thing is "throw_braveheart". That is the name of the animation resource/sequence, and the last one, "blend_in_ready", is basically a line that makes the animation blend in with other animations. The "0, 30" part is the frame count. Now you know all that is necessary, and we can move on.

Go to header_items.py. Find "itcf_throw_javelin" and copy the whole thing to the bottom of the itcf_ list, right before the itc_cleaver. Rename it to itcf_throw_braveheart". If you did it right, it should look like this.

Code:
itcf_force_64_bits                                   = 0x8000000000000000
itcf_throw_braveheart                                   = 0x0000000000040000
itc_cleaver

And now we make a new itc_ . Basically, from my understanding, an itc_ (item capabilities) is a list of various animations packed together. If you put itc_scimitar to your item, you will not be able to stab/thrust, because the itc_ doesn't have itcf_thrust_onehanded. itcf_, again from my understanding, is necessary to link into itc_ tag. So, now you have two choices. You either make a new itc_ OR simply put itcf_ to your item. However, I prefer to use itc_ in any case, because then it looks cleaner and you can, if needed, add other animations to the itc_ later. So let's make a new itc_ called itc_braveheart below itc_greatlance. If you did it right, it should look like this.

Code:
itc_greatlance = itcf_thrust_onehanded_lance |itcf_thrust_onehanded_lance_horseback| itcf_thrust_polearm
itc_braveheart = itcf_force_64_bits | itcf_throw_braveheart
ixmesh_inventory   = 0x1000000000000000

I'm not 100% sure why the itcf_force_64_bits is for, but most of the itc_ seem to have it, and it works with it perfectly, so it's better we keep it in. Okay. We can now save and move on to module_items.py. In module_items.py, simply copy 'practice_javelin' or other javelin kind of weapon, and paste it at the very end, right before the last ']'. If you did it right, it should look something like this.

Code:
["rabati", "Rabati", [("rabati",0)], itp_type_head_armor   ,0, 278 , weight(2)|abundance(100)|head_armor(20)|body_armor(0)|leg_armor(0) ,imodbits_cloth ],
["braveheart_sword", "Braveheart Sword", [("b_bastard_sword",0),("b_bastard_sword", ixmesh_carry)], itp_type_thrown |itp_primary|itp_bonus_against_shield ,itc_braveheart|itcf_carry_quiver_back|itcf_show_holster_when_drawn, 0, weight(5) | spd_rtng(91) | shoot_speed(28) | thrust_damage(27, blunt) | max_ammo(50) | weapon_length(75), imodbits_thrown],
]

As you can see, we have added itc_braveheart to the item. I also kept the old itcf_carry_quiver_back, just to show that you can have both itc_ and itcf_ on the item. You can and should add the two itcf_ to itc_braveheart. Then it looks much cleaner. Okay. You've got ALL basically ready, I hope I haven't forgot anything or something like that. Now start making decapitation animations! And don't forget to post some feedback...

Enjoy,
cdvader.

Critical Update (15/08/09) - You *can not* make a completely new .brf file from scratch and put your custom animation in it, else you will get a RGL error. However, you *can* add your new custom animation to an existing .brf file in CommonRes/ which has the prefix ani_ and you will not get a RGL error.
I have yet to test if adding ani_ or uni_ to your custom mod .brf files work.

Credits.
A big thanks to mtarini for Open-BRF.
And, of course, a big thanks to Armagan for Mount & Blade.
 
Excellent tutorial! I'll try it out with Blender and tell you how it goes once I figure some things out!
 
Yup. Thanks for the feedback. And I thought this was a hot topic. :razz: . By the way, if you want to set custom animation types, look at the other itcf_ files. For example, if you want to have a reload animation, you need to make "itcf_reload_customanimation". If you want to have parry, set it to "itcf_parry_customanimation". I'm pretty sure this is how it works.

I hope you get the main idea.
cdvader, baned with what the Hexadecimal numbers mean.

EDIT: Also, you can make some pretty awesome stuff by simply editing the existing animations, too. For example, I exported the "equip_arms" animation sequence from "ani_equip_arms.brf" as a .smd and opened it in 3ds Max, looked for the right sequence what I wanted and came up with this.

Code:
 ["equip_custom_arm", 0, [1.0, "equip_arms", 132, 153, arf_blend_in_0]],
 #["unequip_custom_arm", 0, [1.0, "equip_arms", 153, 132, arf_blend_in_0]], #Untested.

I think it's pretty cool. And I think it's unused. Basically, it equips something with the right hand in a rather long reach. Probably useful for giant longswords.
 
Drat, SMD import works fine now but openBRF export still screws up my skeletons in Blender edit: and can't import it back properly. Won't be able to test this yet... I'm gonna make a bug report first.
 
cool tutorial... thanks!

But, can you relate on: how can I add a custom run animation (say) so that that some characters use it,  other don't?
For example, say I wanted orcs in a fantasy module to walk/pose/run differently from humans...



 
However, do not fret, OpenBRF's Importer seems to re-fix the screwed up bone system.

Doesn't work this way for me atm, it did for version 0.0.7 but only with SMDs exported from openBRF.

When exporting from Max, make sure you tick it to a "Sequence" instead of "Referene".
Ach, I think there may be a problem here. The only option I have with my Blender export script is "Selected as reference model".

What's the difference between sequence & reference? If I can't export as sequence does that mean that time stamps/frames don't work?
 
This tutorial rules! There's tons of new animations I'll make for my mod!
 
Amade, the OpenBRF's Exporter screws up the skeleton, yes, but when you re-import the SMD file to OpenBRF, the skeleton seems to be re-fixed.

mtarini, I haven't found anything for the Skins system, like the item system (I mean, I don't think there's itcf_ flags for other stuff expect items). However, if you want to have your orcs run differently, you could try putting the right prefix before the animation...

Code:
Default:
["run_right_onehanded", acf_enforce_lowerbody,
   [0.8, "run_man_right_onehanded", 0, 24, arf_use_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0], 
 ],

New bit:
["run_right_onehanded_orc", acf_enforce_lowerbody,
   [0.8, "run_orc_right_onehanded", 0, 24, arf_use_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0], 
 ],

'run_right_onehanded_orc' is the name of the custom animation. I think they're hardcoded using the prefixes. Example, for equipping items, you do 'equip_onehanded_orc'. That's why you need to keep run_right_onehanded but add in your last, custom bit _orc.
'run_orc_right_onehanded' is the name of the sequence. Same as above.

The only fault to this is that I don't know how to "link" them to your Skin type. Oh and, by Skin type I mean module_skins.py and header_troops.py . The Skins are the tf_ flags, basically.

Rize, thanks. I got a free commercial edition. :smile:
 
cdvader said:
Amade, the OpenBRF's Exporter screws up the skeleton, yes, but when you re-import the SMD file to OpenBRF, the skeleton seems to be re-fixed.

That's what I thought too, but after editing it in Blender and reimporting into openBRF it gave me an error message (reported in the openBRF thread). Wouldn't work anyway, 'cos the Blender export script I used didn't have an option for exporting animation sequence.

I did find a new script which can export animation sequence after some searching and it works alright (after a hell lot of trial and error) but there's a certain problem where BRFedit can import the output SMDs just fine yet openBRF can't and simply crashes. I think I know what the problem is but I don't want to burden mtarini with any more than what I've piled on him :'P

I'll see if I can modify the export script to make it work with openBRF. If all else fails I'll post some more info about it and ask for help.

edit: eierkopf has released BRFexport script for Blender which solves this problem. See updated links in cdvader's first post.
 
Well, wunderboy's 3ds Max SMD exporter works. For now, a fixed exporter would be really good. And with your extremely detailed bug report, it might be possible.

cdvader
 
Dain - vader said 'you could try' but I don't think he's tried this.  I briefly tried similar stuff in the past and couldn't get it to work so I think we're stuck with one "run" animation, etc.  But if somebody can get this to work it would be very cool.
 
Yup, I haven't tried it. But I'm quite sure you can actually have new run, idle, etc animations by a simple method. Let's say we take run_right_onehanded. As far as I understand, you can not and MUST not edit the name or other stuff. However, it's said in comments that you can edit the sequence/resource and it's length.

Code:
 ["run_right_onehanded", acf_enforce_lowerbody,
   [0.8, "run_man_right_onehanded", 0, 24, arf_use_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0], 
 ],

Change it to...

 ["run_right_onehanded", acf_enforce_lowerbody,
   [0.8, "run_man_right_onehanded_new", 1, 25, arf_use_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0], 
 ],

The "run_,am_right_onehanded_new" is the new resource/sequence. 
The 1,25 are the new sequence lengths. Other things are not edited.

I'm posive that it works. BUT! You're still stuck to only one run animation.
cdvader
 
Only one run?  :cry:

Uhm... a glimpse of hope comes from the presence in the native game of a "feminine stance" reserved for female characters.
I've see a brf file with that stance (an animation), and I think that I've seen it used, in-game, by female characters only.

How is that achieved?
Maybe that is done with a more general mechanism which could be reused for, say orcs?
("orcs" could be a third... gender, so to speak - ahah)
 
Well no, you can have multiple random walks and runs to the existing actions, I've just added a few walk variants.. but you can't add an entirely new set of runs for a new weapon type.

Check over MBX, we have a wee problem with mounted anims :razz:
 
[quote author=Dain Ironfoot]Well no, you can have multiple random walks and runs to the existing actions, I've just added a few walk variants.[/quote]
Care to share?

[quote author=Dain Ironfoot]Check over MBX, we have a wee problem with mounted anims .[/quote]
Link please.

EDIT: oops.
 
Eh what? You want my animations which I've made for my mod? The answer will have to be no I'm afraid. I can show some screenshots somewhen when I have it to my satisfaction (animations based off a split file have a weird low framerate problem)

And the discussion is in a private forum, so a link wont help much :p The problem I've found is that OpenBRF resets the root bone somehow, so a mounted animation gets turned into a walking animation.. which makes the character slide up and down through the horse.
 
Dain: I'm not sure I'm understanding you.

I was suggesting, on the premise the native system has a stance animation which is used only for female characters,
we could reuse the mechanism behind that to have a class of characters (say, orcs) which used only their own stance/movement animations.

Are you saying that the premise is not true (I might be wrong), or that it is hardcoded, or... what?


The other "import" problem for mounted horses... I'll see to that!
 
As far as I know, it's impossible for us to create a new weapon "type" with unique idle and movement animations (E.g for the sake of argument, a pike) We can't add a new "Walk_pike" a new "stand_pike" etc..
 
Back
Top Bottom