Post by Thuro on Dec 2, 2013 20:06:37 GMT
From mr.master
So, this tutorial will cover on how to add new multiplayer factions to warband. If there's a tutorial on this already, please notify me so I can lock this :wink: There are only three module system files we need to edit.
Module factions
Module troops
Module presentations
Module scripts
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
and paste it under the sarranid faction code.
Change the faction name to your liking. After you have finished, save and open up module troops.
Module Troops
Now, as you should have module_troops open, search for #Multiplayer ai troops. You should see bunch of lines like this
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
The next thing we want to edit in that is this line.
So, in the same file (module_troops), search for #Multiplayer troops. You should see lines like this
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
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_6". You should see lines like this
Copy that code, and paste under the last one. Then it should look like this
Now, change the "fac_kingdom_2" to your factions number. For me it's "fac_kingdom_7"
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. So, it now should look like this
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
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
You want to copy that, and paste it under the last line, like this
So, change the "fac_kingdom_6" to your factions number. Example, "fac_kingdom_7". 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. Now, search for "#script_determine_team_flags". You will see lines like this
Copy that code, and paste it under
Like this,
Now, make sure the "fac_kingdom_7" 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
Now, I want to make these items actually available for this troop in multiplayer. So, Ill add
Now, just save up and compile. Hopefully, if you did everything right (and I explained everything right :wink:) it should work. It may seem hard to do but really, it's very easy. Hopefully this tutorial wasn't to messy If any errors occure, double check that you have done everything as you should have and that you have saved the files. Then just try to re-compile few times.
Making Items available in multiplayer
So, by request, I thought Id add this section also to this tutorial. So, 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
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:
So, as my item is a musket type weapon, it goes under bow category. So, it would look like this
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
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
Remember to have the _multiplayer at the end. Now you have the the item of your choice available to the troop you wanted.
So, this tutorial will cover on how to add new multiplayer factions to warband. If there's a tutorial on this already, please notify me so I can lock this :wink: There are only three module system files we need to edit.
Module factions
Module troops
Module presentations
Module scripts
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
("kingdom_7", "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_7", "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
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 7. So, change it that it looks like this tf_guarantee_all,0,0,fac_kingdom_7,
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.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_7,
[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_6". 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_7"
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. So, it now should look like this
(else_try),
(eq, "$g_multiplayer_team_1_faction", "fac_kingdom_7"),
(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_7"),
(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_6" to your factions number. Example, "fac_kingdom_7". 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. 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_7"),
(assign, "$team_1_flag_scene_prop", "spr_headquarters_flag_vaegir"),
(try_end),
Now, make sure the "fac_kingdom_7" 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"),
Now, just save up and compile. Hopefully, if you did everything right (and I explained everything right :wink:) it should work. It may seem hard to do but really, it's very easy. Hopefully this tutorial wasn't to messy If any errors occure, double check that you have done everything as you should have and that you have saved the files. Then just try to re-compile few times.
Making Items available in multiplayer
So, by request, I thought Id add this section also to this tutorial. So, 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.