Adding new multiplayer faction

From Mount&Blade Modding Wiki
Jump to: navigation, search

Contents

Adding a new multiplayer faction

This tutorial will cover on how to add new multiplayer factions to warband. It's relatively easy and doesn't really require and coding knowlegde. Only a the module system, proper text editor.(Notepad++, Programmers Notepad etc.) and a working install of python 2.6(Or earlier will do too, but I suggest to use the version 2.6 .Any newer version wont work.)


Module Files to be edited

Module Factions

Module Troops

Module Presentations

Module Scripts

Module Meshes


Module Factions

First of all, open up module_factions. This part is fairly simple and requires only one line of code. So copy this code.

NOTE!!YOUR CUSTOM KINGDOM MUST START FROM NUMBER 8. 7 IS USED FOR REBEL FACTIONS

("kingdom_8",  "Finland",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),    ("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xDDDD33),

and paste it under the sarranid faction code.

("kingdom_6",  "Sarranid Sultanate",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xDDDD33),
("kingdom_8",  "Finland",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xDDDD33),

Change the faction name to your liking. After you have finished, save and open up module troops.


Module Troops

Multiplayer Ai Troops

Now, as you should have module_troops open, search for #Multiplayer ai troops. You should see bunch of lines like this

["swadian_crossbowman_multiplayer_ai","Swadian Crossbowman","Swadian      Crossbowmen",tf_guarantee_all,0,0,fac_kingdom_1,
   [itm_bolts,itm_crossbow,itm_sword_medieval_a,itm_tab_shield_heater_b,
    itm_leather_jerkin,itm_leather_armor,itm_ankle_boots,itm_footman_helmet],   def_attrib|level(19),wp_melee(90)|wp_crossbow(100),knows_common|knows_ironflesh_4|knows_athletics_6|knows_shield_5|knows_power_strike_3,swadian_face_young_1, swadian_face_old_2],

What you want to do, is to copy one of the existing unit lines, copy it, paste it under the last sarranid unit code and then edit to match your liking. So, Ill use the "swadian crossbowman_multiplayer_ai". What I do, is I copy the code, and paste it under the last sarranid unit code. After you have done that, you want to change the unit id. Ill change it to "finnish_rifleman_multiplayer_ai" Remember, the unit id must have "_multiplayer_ai" because its a multiplayer ai troop. Now, the next things you want to edit are the display names. There are two kinds. The display name for single troop, and the display name for several troops. So Edit the "Swadian Crossbowman" to your liking. Ill put it as "Finnish Rifleman". Now, edit the second display name, which for me, is "Swadian Crossbowmen". Ill change it to "Finnish Riflemen". Now, it will look like this

["finnish_rifleman_multiplayer_ai","Finnish Rifleman","Finnish Riflemen",tf_guarantee_all,0,0,fac_kingdom_1,
   [itm_cartridges,itm_cartridges,itm_pystykorva,itm_ukkopekka,
    itm_leather_jerkin,itm_leather_armor,itm_ankle_boots,itm_kypara],
 def_attrib|level(19),wp_melee(90)|wp_crossbow(120),knows_common|knows_ironflesh_4|knows_athletics_6|knows_shield_5|knows_power_strike_3,swadian_face_young_1, swadian_face_old_2],

The next thing we want to edit in that is this line.

tf_guarantee_all,0,0,fac_kingdom_1,

We want to change that to our own factions number, which is 8. So, change it that it looks like this

tf_guarantee_all,0,0,fac_kingdom_8,


Next, you can change the units items if you want, example, changing "itm_leather_jerkin" to "itm_your_model_id". Then, the lines after that are the units skills and attributs. You can change them if you want, but ill leave them for now. Repeat these steps if you need to add more multiplayer ai troops to your multiplayer faction. Now, it's good time to save, just to be safe. You have now succesfully created ai troops to your multiplayer faction. Next, we will create a multiplayer troops which the players can use.



Multiplayer Player Classes



So, in the same file (module_troops), search for #Multiplayer troops. You should see lines like this


["swadian_crossbowman_multiplayer","Swadian Crossbowman","Swadian         Crossbowmen",tf_guarantee_all,0,0,fac_kingdom_1,
 [itm_cartridges,itm_cartridges,itm_pystykorva,itm_ukkopekka,itm_kypara,itm_stickgrenade,itm_pystykorva,itm_sword_medieval_b_small,itm_tab_shield_heater_a,itm_red_shirt,itm_ankle_boots],
 def_attrib_multiplayer|level(19),wpe(90,60,180,90),knows_common|knows_ironflesh_2|knows_athletics_5|knows_shield_5|knows_power_strike_2|knows_riding_1,swadian_face_young_1, swadian_face_old_2],

Again, copy a existing code, paste it under the last sarranid unit code and edit it to your liking. This is pretty much the same as adding multiplayer ai troops, expect, the unit id doesnt have to have the "_multiplayer_ai". It only has to have "_multiplayer" in it. Mine looks like this


 ["finnish_rifleman_multiplayer","Finnish Rifleman","Finnish Riflemen",tf_guarantee_all,0,0,fac_kingdom_8,
 [itm_cartridges,itm_cartridges,itm_pystykorva,itm_ukkopekka,itm_kypara,itm_red_shirt,itm_ankle_boots],
 def_attrib_multiplayer|level(19),wpe(90,60,180,90),knows_common|knows_ironflesh_2|knows_athletics_5|knows_shield_5|knows_power_strike_2|knows_riding_1,swadian_face_young_1, swadian_face_old_2],

Again, if you need to add several troops to the faction, just do the same, only changing the stuff you need to. Now, save up and open up module_presentations.



Module Presentations

Now, as you should have it open, search for "mesh_ui_kingdom_shield_2". You should see lines like this

 (else_try),
        (eq, "$g_multiplayer_team_1_faction", "fac_kingdom_2"),
        (create_mesh_overlay, reg0, "mesh_ui_kingdom_shield_2"),

Copy that code, and paste under the last one. Then it should look like this

 (else_try),
        (eq, "$g_multiplayer_team_1_faction", "fac_kingdom_1"),
        (create_mesh_overlay, reg0, "mesh_ui_kingdom_shield_6"),
 (else_try),
        (eq, "$g_multiplayer_team_1_faction", "fac_kingdom_2"),
        (create_mesh_overlay, reg0, "mesh_ui_kingdom_shield_2"),
 (try_end),

Now, change the "fac_kingdom_2" to your factions number. For me it's "fac_kingdom_8" Now, you can change the "mesh_ui_kingdom_shield_2" to one of the six available ones. Or you can create your own. But I will use one of the existing ones(Adding your own ones will be covered in later steps). So, it now should look like this

 (else_try),
        (eq, "$g_multiplayer_team_1_faction", "fac_kingdom_8"),
        (create_mesh_overlay, reg0, "mesh_ui_kingdom_shield_1"),
 (try_end),

Now, if you scroll down a little bit, you will see the exact same lines, expect, the line "$g_multiplayer_team_1_faction" is changed to "$g_multiplayer_team_2_faction". Again, do the same thing. Copy a existing one, paste it under the last one and change it according to your faction. Like this

 (else_try),
        (eq, "$g_multiplayer_team_2_faction", "fac_kingdom_8"),
        (create_mesh_overlay, reg0, "mesh_ui_kingdom_shield_1"),
      (try_end),

Now, just save up and open module_scripts.


Module Scripts

As you now should have module_scripts open, search for "#Faction banners". It should be quite ate the start of module_scripts. You will see lines like this

 (faction_set_slot, "fac_kingdom_1", slot_faction_banner, "mesh_banner_kingdom_f"),

You want to copy that, and paste it under the last line, like this

 (faction_set_slot, "fac_kingdom_6", slot_faction_banner, "mesh_banner_kingdom_e"),
 (faction_set_slot, "fac_kingdom_7", slot_faction_banner, "mesh_banner_kingdom_e"),

So, change the "fac_kingdom_1" to your factions number. Example, "fac_kingdom_8". Now, you can change what banner will it use. You can leave it as it is or use openbrf to look other banners and then change it, or add your own. Now, search for "#script_determine_team_flags". You will see lines like this

 (else_try),
         (eq, ":team_faction_no", "fac_kingdom_2"),
         (assign, "$team_1_flag_scene_prop", "spr_headquarters_flag_vaegir")

Copy that code, and paste it under

 (else_try),
         (eq, ":team_faction_no", "fac_kingdom_6"),
         (assign, "$team_1_flag_scene_prop", "spr_headquarters_flag_vaegir"),

Like this,

 (else_try),
         (eq, ":team_faction_no", "fac_kingdom_6"),
         (assign, "$team_1_flag_scene_prop", "spr_headquarters_flag_sarranid"),
 (else_try),
         (eq, ":team_faction_no", "fac_kingdom_8"),
         (assign, "$team_1_flag_scene_prop", "spr_headquarters_flag_vaegir"),
       (try_end),

Now, make sure the "fac_kingdom_8" is the number of your faction. You can change what flag will it use. Example, "spr_headquarters_flag_vaegir" could be changed to "spr_headquarters_flag_swadian" Now, if you scroll down, you will see the same codes, expect the "$team_1_flag_scene_prop" is now "$team_2_flag_scene_prop". Again, copy one of the lines, paste id under the last one and change it according to your faction.

Now, search for

 (call_script, "script_multiplayer_set_item_available_for_troop", "itm_warhorse", "trp_sarranid_mamluke_multiplayer"),

What we want to do, is to add a comment which indicates for what troop are we making a item available. Example

 (call_script, "script_multiplayer_set_item_available_for_troop", "itm_warhorse",   "trp_sarranid_mamluke_multiplayer"),
 #Finnish Rifleman

Now, you should check what items did you put to your troops in your module_troops. Example, I assigned these items available for my finnish rifleman

 [itm_cartridges,itm_cartridges,itm_pystykorva,itm_ukkopekka,itm_kypara,itm_red_shirt,itm_ankle_boots ],

Now, I want to make these items actually available for this troop in multiplayer. So, Ill add

 (call_script, "script_multiplayer_set_item_available_for_troop", "itm_cartridges", "trp_finnish_rifleman_multiplayer"),

under #Finnish Rifleman. Like this

 (call_script, "script_multiplayer_set_item_available_for_troop", "itm_warhorse", "trp_sarranid_mamluke_multiplayer"),
 #Finnish Rifleman
 (call_script, "script_multiplayer_set_item_available_for_troop", "itm_cartridges",  "trp_finnish_rifleman_multiplayer"),

You do the same, expect, change the "itm_cartridges" to your item id, example, "itm_leather_jerkin". Then change the "trp_finnish_rifleman_multiplayer" to your troops id. Example "trp_my_unit_multiplayer" Now, you just do the same to make all the items you set your troop to have available. I suggest you do so that the first lines of code would be for weapons,shields, arrows etc. Then a empty line, then armors, helmets gloves etc. Then an empty line and adding anything else you need to still add. like this

 #Finnish Rifleman
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_cartridges", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_pystykorva", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_ukkopekka", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_red_shirt", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_padded_cloth", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_leather_armor", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_haubergeon", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_ankle_boots", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_leather_boots", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_leather_gloves", "trp_finnish_rifleman_multiplayer"),
      (call_script, "script_multiplayer_set_item_available_for_troop", "itm_kypara", "trp_finnish_rifleman_multiplayer"),

Adding your own Flags

Module Meshes

Before we start, it's important that all the flags are exactly in the same order as the factions are in module Factions. So if the first faction is fac_8, the first flag entries MUST BE for fac_8

First, we need to create new entries to Module Meshes. Search for this line

 ("flag_project_sr", 0, "flag_project_sr", 0, 0, 0, 0, 0, 0, 1, 1, 1),

Copy it, paste under it. The first "flag_project_sr" is the id of the line which can be referranced later on in other files. The second "flag_projet_sr" is the actual name of the mesh in the brf file. This is what I have for my custom faction

  ("flag_project_fi", 0, "flag_project_fi", 0, 0, 0, 0, 0, 0, 1, 1, 1),

I used the same template of the other entries. Just changed the faction "_sr" to "_fi".

Next, search for

 ("banner_kingdom_f", 0, "banner_kingdom_f", 0, 0, 0, -90, 0, 0, 1, 1, 1),

Copy it, paste under it. Pretty much as the previous one, expect the actual mesh is a bit different and this mesh is used differently in-game than the last one. This is my entry

 ("banner_kingdom_fi", 0, "banner_kingdom_fi", 0, 0, 0, -90, 0, 0, 1, 1, 1),

Next, search for

 ("ui_kingdom_shield_6", 0, "ui_kingdom_shield_6", 0, 0, 0, 0, 0, 0, 1, 1, 1),

Copy it, paste under it. Same as the previous. This is the shield which will be seen in example, battle mode in the top left hand corner. My entry

  ("ui_kingdom_shield_8", 0, "ui_kingdom_shield_8", 0, 0, 0, 0, 0, 0, 1, 1, 1),

Now, you can go back to module presentations and change the codes to use your flags.

Module Scene Props

First, search for

 ("headquarters_flag_sarranid",sokf_moveable|sokf_face_player,"flag_sarranid","0", []),

Copy it, paste under it. Again, First is the id of the entry used to referance in other files. The "Flag_sarranid" is the actual mesh name in the brf file. Make sure it matches your own. My entry

 ("headquarters_flag_finland",sokf_moveable|sokf_face_player,"flag_finland","0", []),

Now, search for

 ("ctf_flag_kingdom_7", sokf_moveable|sokf_face_player, "ctf_flag_kingdom_3", "0", []),

Again, copy it, paste under it. Change the id and mesh referance to your own. My entry

 ("ctf_flag_kingdom_8", sokf_moveable|sokf_face_player, "ctf_flag_kingdom_ru", "0", []),

Now you can go edit module scripts to use your own flags.

Adding your own items to multiplayer

Adding items to multiplayer is relatively easy. So, the only file we will be needing in this part is module_script because I presume you have already added your item to module_items.

So first of all, open up module scripts of course. Look for

 (item_set_slot, "itm_heavy_crossbow", slot_item_multiplayer_item_class, multi_item_class_type_bow),

So, the "itm_your_item_id" Is the item made available and the multi_item_class_type_bow means what kind of item it is. There are various of types, all listed under here:

arrow
bolt
bow
sword
two_handed_sword
axe
two_handed_axe
blunt
picks
cleavers
spear
lance
small_shield
throwing
throwing_axe
light_armor
light_foot
light_helm
glove
horse

So, as my item is a musket type weapon, it goes under bow category. So, it would look like this

   (item_set_slot, "itm_pystykorva", slot_item_multiplayer_item_class, multi_item_class_type_bow),

Now, the weapon is usable in multiplayer but still needs to be assigned to a class. So, I want to make this weapon available for my finnish rifleman, Ill search for the finnish rifleman equipment entries, and add this in. So find the troop you want to add the item for, example Swadian crossbowman. For me, its Finnish rifleman. Now, make an entry like this

 (call_script, "script_multiplayer_set_item_available_for_troop", "itm_pystykorva", "trp_finnish_rifleman_multiplayer"),

So, change the itm code to your item. For me it was itm_pystykorva. Then, change the line trp_finnish_rifleman_multiplayer To your troop you want to add it in. Example, if it would be for swadian crossbowman, it would be like this

trp_swadian_crossbowman_multiplayer

Remember to have the _multiplayer at the end. Now you have the the item of your choice available to the troop you wanted.


--85.157.202.245 21:40, 19 March 2011 (CET) Mr.Master

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox