Custom Items into your mod using Open Brf
This tutorial will take you through the steps of adding your own items to your mod. It's quite easy, doesn't require much coding at all nor knowledge of coding.
Contents |
Required Things
- A DDS plugin for your photo editing software. Gimp: Gimp DDS plugin , Photoshop: Nvidia DDS plugin
- Marco Tarini's OpenBRF to get your texture and model together into the game. Open Brf
- A proper text editor. Example: Programmers Notepad | Notepad++
- Newest version of the Module System: Download
- Python 2.6 (Or earlier if wanted. Newer versions WONT WORK) Python 2.6
Setting up your mod folder
First, we need to create a working mod folder for your mod. So, navigate to your Mount&Blade Warband Modules folder.
If you have installed through steam and used the default installation path for it, it should be located in here:
C:\Program Files\Steam\steamapps\common\mountblade warband\modules
Or if you did not install it through steam:
C:\Program Files\Mount&Blade Warband\Modules
These are the defaults for Windows XP. Vista Entries will be added.
So, now in your modules folder, copy the native folder, paste it there. You will get a folder called "copy native". Change the name to whatever you want your mod name to be. For me
Finland At WW2
Now, we need to change our module_info directory to match your mod directory. So, open up your module system folder and look for module info. Open it up with your text editor (Which I presume is a good one which I mentione earlier on in the tutorial). You will see two lines:
#export_dir = "../" export_dir = "E:/Program Files/Steam/steamapps/common/mountblade warband/Modules/Finland At WW2/"
What you do is change the second line to match your mod folder. For me it's this
export_dir = "E:/Program Files/Steam/steamapps/common/mountblade warband/Modules/Finland At WW2/"
Save it up. Now, to test that everything works, run the build_module.bat. I presume that you have installed python properly by now. If your not sure, take a look in this thread . So, if any errors occure like "Python not recognised", take a look in the thread.
Now, if everything went fine, Congratulations! You succesfully compiled your mod for the first time. Now, lets get onto Open Brf!
OpenBRF
BRF files (Binary Resource Files) contains your model, the material for your model and the texture files. I will take you through of adding your item, adding a basic configuration on the material settings, talking about lods and multimeshing too. Some information:
- Texture files MUST BE in DDS format. For non alpha map textures, BC1/DXT1 compression. For texture maps with alpha maps, BC1/DXT5. Using Mipmaps is suggested.
- Model files MUST BE in .obj format. A model can be put together from several different parts and models can (And should) have LODS (Level of Detail).
- Skeletal animations must be in .smd format.
- Vertex animated meshes are supported
So, furthermore, lets get started. So, first things first. Export your model in .obj format. But before you do export, make sure you have the right export/import settings:
Tessellation: Triangulation
SwapY and Z axes
Import Scale: 10.0
Export Scale: 0.1
Subdivision steps: 0
It's very important that the model is triangulated when exporting. If not, you will get problems.
Now, when you have applied the settings, go on and export the model to somewhere where it is easy to find.
Next, we need to make our texture files into DDS file format. As I mentioned, it is very important, otherwise the game can't read the texture files. So, in either Gimp or Photoshop (Could be paint.net as it also supports saving in DDS), go on and save your texture(Textures if you have Normal and Specular maps, which is recommended). Again, save them to a place where it's easy to find them. Now, the next step is to copy your dds files to your mods texture folder. So, find your dds textures, copy them (Ctrl C or right click and click copy), navigate to your mod folder. In there, go to textures folder and paste the dds files there.
Now, we will start work with Open Brf. Fire it up. Now, you have six tabs starting from the top left hand corner. We only need to worry about the "Import" tab. So, click on and press "Static mesh". Find your model file (Which should be in .obj format!) and import it. If it says that the model has multiple materials, just click no. Now, you will get a tab called "Mesh". This is where all your models will be in. As you noticed, your model has blue and white checkboard pattern. It's because it's missing a texture. So, now, we need to create a material for your model. The material controls various settings. Shaders, all the diffuses (texture maps), Specularity settings (How much the item shines), Rendering order and finally, the material flags. In all basicness, your model file contains the following:
- The model
- The material
- The texture(s)
Now, go on and create a material for your mesh from the import tab. Name it something that is easy to connect to the mesh. Now, when you have creater the material, it will most likely have the checkboard pattern (Unless you named the material the same as your texture, then it will show the texture). Now, first of all, we need to get the texture maps right on the material. So, for the Diffuse A, put your main texture map name for it.  Next, if you made normal and specular maps for your texture (Use Crazybump if your not too familiar making ones.) We need to assign  them to the material. Normal map on the Bump entry, and Specular map to the Specular entry. Next, we need to change the shader. The simple shader is not good for anything, expect testing the model in-game.  Lets say Id be adding a sword. There are various shaders for swords and helmets but Ill use
specular_shader_noskin_bump_high_Instanced
This shader uses both Bump (Normal map) and the specular map.
Now, we need to add the basic Spec RGB settings. I suggest you play around with them if the specular maps are too shiny. But for all basic meshes with specular maps, I use these settings:
10 10 10
Coeff: 16
Rend ord: 0
Next, add 720 the material flags. This enables
Blend
Blend Add
Blend Multiply
Specular Enable
Not entirely sure what the blend flags do, but the specular enable is pretty self explanatory.
Now, the last step is to actually import our texture(s) into the brf file. To do this, go to the import tab and press "New Texture". Give the name exactly the same as your textures in the texture folder. If it's not exactly the same, you will get problems later on. When you have done everything, go to "File" and press "Save as". Give it a name and save in M&B Resource Brf. Save it up and lets get to new stuff.
Configuring Module ini
Look for module.ini in your mod folder. When you find it, open it up. First, search for
scan_module_textures
If it's
scan_module_textures = 0
Change it to 1. Like this
scan_module_textures = 1
This makes the mod check the mods texture folder for textures.
Next, we need to add our brf file. So, search for this line
load_resource = materials_face_gen
Create a space between it and add
load_mod_resource = pystykorva_mesh
load_mod_resource tells the mod to load the resource from the mods own resource folder. Make sure you set the  "pystykorva_mesh"
To match your resource file. So, it's the resource files name without the .brf tag at the end. When your read, save it up and close it.
Adding the item to the module system
Now, go to your module system folder, and look for module_items. When you find it, open it up.
Now , module items is the file where you add all your items. Swords, helmets, clothing, everything. Now, lets say id like to add a basic sword into my mod. What I do is find a existing sword code, copy it and change it to my liking. Here is an example
["sword_viking_1", "Nordic Sword", [("sword_viking_c",0),("sword_viking_c_scabbard ", ixmesh_carry)], itp_type_one_handed_wpn|itp_merchandise|itp_primary, itc_longsword|itcf_carry_sword_left_hip|itcf_show_holster_when_drawn, 147 , weight(1.5)|difficulty(0)|spd_rtng(99) | weapon_length(94)|swing_damage(28 , cut) | thrust_damage(20 , Â pierce),imodbits_sword_high ] ,
sword_viking_1 is the id of our item which can be then used in other files. "Nordic Sword" is the name of the sword which appears in game. "sword_viking_c" is the actual model name in the brf file. So, if you would want add your sword. you change the "sword_viking_c" to match the name of your sword in the brf file. So if my swords name would be mysword in the brf file, it would go look something like this
["my_sword", "My Uber Cool Sword", [("mysword",0),("sword_viking_c_scabbard ", ixmesh_carry)], itp_type_one_handed_wpn|itp_merchandise|itp_primary, itc_longsword|itcf_carry_sword_left_hip|itcf_show_holster_when_drawn, 147 , weight(1.5)|difficulty(0)|spd_rtng(99) | weapon_length(94)|swing_damage(28 , cut) | thrust_damage(20 , Â pierce),imodbits_sword_high ] ,
The "sword_viking_c_scabbard" is the scabbard where the sword is put when you sheath it. Now, if you want to change the swords stats,
you could change the weight(), difficulty(What does it require), spd_rtn(Speed rating, how fast you swing it), weapon_length(Use the measure tool in openbrf to get the accurate length), swing_damage(Self explanatory), thrust_damage(Self explanatory),
After you have edited it your liking, save it up and build_module.bat. If it goes fine, congratulations! You have succesfully added your item. If it builds with errors, make sure you have done everything right.