I have asked for this in this thread https://forums.taleworlds.com/index.php/topic,340058.0.html and thanks to Somebody an gdwitt I have manage to make it work,so i decided to make a tutorial about this,so lets get started.First off all is module_constants
Add this
Bellow this
################################################################################
THIS PART IS VERY IMPORTANT,PAY ATTENTION TO AVOID MISTAKES
in modules_dialogs search for #Tavern Talk (with troops), IF YOUR MOD HAVE DIPLOMACY INTEGRATED REPLACE THE ENTIRE DIALOG WITH THIS
IF YOUR MOD DON'T HAVE DIPLOMACY REPLACE THE ENTIRE DIALOG WITH THIS
################################################################################
in modules_scripts search for #script_update_mercenary_units_of_towns replace the entire code with this new one
in modules_game_menus add this
bellow this
That it,you will now find two mercenary leaders in the tavern,this code is excellent if you are adding a lot of mercs in your mod.
CREDITS
Some parts of this code are taken from Floris Source,so obviously the Floris Mod Team deserves the credit.
Somebody and gdwitt for script guidance
Add this
Code:
slot_center_mercenary_troop_type_2 = 901 #use another number if this one is already being used
slot_center_mercenary_troop_amount_2 = 902 #use another number if this one is already being used
Code:
slot_center_mercenary_troop_type = 90
slot_center_mercenary_troop_amount = 91
################################################################################
THIS PART IS VERY IMPORTANT,PAY ATTENTION TO AVOID MISTAKES
in modules_dialogs search for #Tavern Talk (with troops), IF YOUR MOD HAVE DIPLOMACY INTEGRATED REPLACE THE ENTIRE DIALOG WITH THIS
Code:
#Tavern Talk (with troops)
[anyone, "start", [
(eq, "$talk_context", tc_tavern_talk),
(neg|troop_is_hero, "$g_talk_troop"),
(neg|is_between, "$g_talk_troop", "trp_swadian_merchant", "trp_startup_merchants_end"),
(assign, ":mercenary_amount", -1),
#(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
#(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(try_begin), #Extra mercenaries in tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount_2),
(try_end), #Tavern end
(gt, ":mercenary_amount", 0),
(store_sub, reg3, ":mercenary_amount", 1),
(store_sub, reg4, reg3, 1),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(assign, ":join_cost", reg0),
(store_mul, reg5, ":mercenary_amount", reg0),
(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(val_min, ":mercenary_amount", ":free_capacity"),
(store_troop_gold, ":cur_gold", "trp_player"),
(try_begin),
(gt, ":join_cost", 0),
(val_div, ":cur_gold", ":join_cost"),
(val_min, ":mercenary_amount", ":cur_gold"),
(try_end),
(assign, "$temp", ":mercenary_amount"),
],
"Do you have a need for mercenaries, {sir/madam}?\
{reg3?Me and {reg4?{reg3} of my mates:one of my mates} are:I am} looking for a master.\
We'll join you for {reg5} denars.", "mercenary_tavern_talk", []],
[anyone, "start", [
(eq, "$talk_context", tc_tavern_talk),
],
"Any orders, {sir/madam}?", "mercenary_after_recruited", []],
[anyone|plyr, "mercenary_after_recruited", [],
"Make your preparations. We'll be moving at dawn.", "mercenary_after_recruited_2", []],
[anyone|plyr, "mercenary_after_recruited", [],
"Take your time. We'll be staying in this town for a while.", "mercenary_after_recruited_2", []],
[anyone, "mercenary_after_recruited_2", [], "Yes {sir/madam}. We'll be ready when you tell us to leave.", "close_window", []],
[anyone|plyr, "mercenary_tavern_talk", [(try_begin), #More Mercaneries Tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount_2),
(try_end),
(eq, ":mercenary_amount", "$temp"),
#(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(store_mul, reg5, "$temp", reg0), #Tavern End
],
"All right. I will hire all of you. Here is {reg5} denars.", "mercenary_tavern_talk_hire", []],
[anyone|plyr, "mercenary_tavern_talk", [(try_begin), #More Mercaneries Tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount_2),
(try_end),
(lt, "$temp", ":mercenary_amount"),
(gt, "$temp", 0),
(assign, reg6, "$temp"),
#(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(store_mul, reg5, "$temp", reg0),
],
"All right. But I can only hire {reg6} of you. Here is {reg5} denars.", "mercenary_tavern_talk_hire", []],
[anyone, "mercenary_tavern_talk_hire", [(store_random_in_range, ":rand", 0, 4),
(try_begin),
(eq, ":rand", 0),
(gt, "$temp", 1),
##diplomacy start+ lads -> {reg65?companions:lads}; {sir/madame} -> {s0}
(call_script, "script_dplmc_print_subordinate_says_sir_madame_to_s0"),
(str_store_string, s17,
"@You chose well, {s0}. My {reg65?companions:lads} know how to keep their word and earn their pay."),
##diplomacy end+
(else_try),
(eq, ":rand", 1),
##diplomacy start+ {sir/madame} -> {s0}
(call_script, "script_dplmc_print_subordinate_says_sir_madame_to_s0"),
(str_store_string, s17,
"@Well done, {s0}. Keep the money and wine coming our way, and there's no foe in Calradia you need fear."),
##diplomacy end+
(else_try),
(eq, ":rand", 2),
##diplomacy start+ {sir/madame} -> {s0}
(call_script, "script_dplmc_print_subordinate_says_sir_madame_to_s0"),
(str_store_string, s17,
"@We are at your service, {s0}. Point us in the direction of those who need hurting, and we'll do the rest."),
##diplomacy end+
(else_try),
(str_store_string, s17,
"str_you_will_not_be_disappointed_sirmadam_you_will_not_find_better_warriors_in_all_calradia"),
(try_end),],
"{s17}", "close_window", [
# (party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(try_begin), #More Mercaneries Tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(assign, ":slot", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(assign, ":slot", slot_center_mercenary_troop_amount_2),
(try_end),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(store_mul, ":total_cost", "$temp", reg0),
(troop_remove_gold, "trp_player", ":total_cost"),
(party_add_members, "p_main_party", ":mercenary_troop", "$temp"),
# (party_set_slot, "$g_encountered_party", slot_center_mercenary_troop_amount, 0),
(party_set_slot, "$g_encountered_party", ":slot", 0),
]],
[anyone|plyr, "mercenary_tavern_talk", [(eq, "$temp", 0),
(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(ge, ":free_capacity", 1)],
##diplomacy start+ Gender-check to avoid accidental absurdities if there are female mercenaries
"That sounds good. But I can't afford to hire any more {reg65?soldiers:men} right now.", "tavern_mercenary_cant_lead", []],
##diplomacy end+
[anyone, "tavern_mercenary_cant_lead", [], "That's a pity. Well, {reg3?we will:I will} be lingering around here for a while,\
if you need to hire anyone.", "close_window", []],
[anyone|plyr, "mercenary_tavern_talk", [(eq, "$temp", 0),
(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(eq, ":free_capacity", 0)],
##diplomacy start+ Gender-check to avoid accidental absurdities if there are female mercenaries
"That sounds good. But I can't lead any more {reg65?soldiers:men} right now.", "tavern_mercenary_cant_lead", []],
##diplomacy end+
[anyone|plyr, "mercenary_tavern_talk", [],
"Sorry. I don't need any other men right now.", "close_window", []],
IF YOUR MOD DON'T HAVE DIPLOMACY REPLACE THE ENTIRE DIALOG WITH THIS
Code:
#Tavern Talk (with troops)
[anyone, "start", [
(eq, "$talk_context", tc_tavern_talk),
(neg|troop_is_hero, "$g_talk_troop"),
(neg|is_between, "$g_talk_troop", "trp_swadian_merchant", "trp_startup_merchants_end"),
(assign, ":mercenary_amount", -1),
#(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
#(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(try_begin), #Extra mercenaries in tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount_2),
(try_end), #Tavern end
(gt, ":mercenary_amount", 0),
(store_sub, reg3, ":mercenary_amount", 1),
(store_sub, reg4, reg3, 1),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(assign, ":join_cost", reg0),
(store_mul, reg5, ":mercenary_amount", reg0),
(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(val_min, ":mercenary_amount", ":free_capacity"),
(store_troop_gold, ":cur_gold", "trp_player"),
(try_begin),
(gt, ":join_cost", 0),
(val_div, ":cur_gold", ":join_cost"),
(val_min, ":mercenary_amount", ":cur_gold"),
(try_end),
(assign, "$temp", ":mercenary_amount"),
],
"Do you have a need for mercenaries, {sir/madam}?\
{reg3?Me and {reg4?{reg3} of my mates:one of my mates} are:I am} looking for a master.\
We'll join you for {reg5} denars.", "mercenary_tavern_talk", []],
[anyone, "start", [
(eq, "$talk_context", tc_tavern_talk),
],
"Any orders, {sir/madam}?", "mercenary_after_recruited", []],
[anyone|plyr, "mercenary_after_recruited", [],
"Make your preparations. We'll be moving at dawn.", "mercenary_after_recruited_2", []],
[anyone|plyr, "mercenary_after_recruited", [],
"Take your time. We'll be staying in this town for a while.", "mercenary_after_recruited_2", []],
[anyone, "mercenary_after_recruited_2", [], "Yes {sir/madam}. We'll be ready when you tell us to leave.", "close_window", []],
[anyone|plyr, "mercenary_tavern_talk", [(try_begin), #More Mercaneries Tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount_2),
(try_end),
(eq, ":mercenary_amount", "$temp"),
#(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(store_mul, reg5, "$temp", reg0), #Tavern End
],
"All right. I will hire all of you. Here is {reg5} denars.", "mercenary_tavern_talk_hire", []],
[anyone|plyr, "mercenary_tavern_talk", [(try_begin), #More Mercaneries Tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(party_get_slot, ":mercenary_amount", "$g_encountered_party", slot_center_mercenary_troop_amount_2),
(try_end),
(lt, "$temp", ":mercenary_amount"),
(gt, "$temp", 0),
(assign, reg6, "$temp"),
#(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(store_mul, reg5, "$temp", reg0),
],
"All right. But I can only hire {reg6} of you. Here is {reg5} denars.", "mercenary_tavern_talk_hire", []],
[anyone, "mercenary_tavern_talk_hire", [(store_random_in_range, ":rand", 0, 4),
(try_begin),
(eq, ":rand", 0),
(gt, "$temp", 1),
(str_store_string, s17,
"@You chose well, {sir/madam}. My lads know how to keep their word and earn their pay."),
(else_try),
(eq, ":rand", 1),
(str_store_string, s17,
"@Well done, {sir/madam}. Keep the money and wine coming our way, and there's no foe in Calradia you need fear."),
(else_try),
(eq, ":rand", 2),
(str_store_string, s17,
"@We are at your service, {sir/madam}. Point us in the direction of those who need hurting, and we'll do the rest."),
(else_try),
(str_store_string, s17,
"str_you_will_not_be_disappointed_sirmadam_you_will_not_find_better_warriors_in_all_calradia"),
(try_end),],
"{s17}", "close_window", [
# (party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(try_begin), #More Mercaneries Tavern
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type),
(eq, "$g_talk_troop", ":mercenary_troop"),
(assign, ":slot", slot_center_mercenary_troop_amount),
(else_try),
(party_get_slot, ":mercenary_troop", "$g_encountered_party", slot_center_mercenary_troop_type_2),
(assign, ":slot", slot_center_mercenary_troop_amount_2),
(try_end),
(call_script, "script_game_get_join_cost", ":mercenary_troop"),
(store_mul, ":total_cost", "$temp", reg0),
(troop_remove_gold, "trp_player", ":total_cost"),
(party_add_members, "p_main_party", ":mercenary_troop", "$temp"),
# (party_set_slot, "$g_encountered_party", slot_center_mercenary_troop_amount, 0),
(party_set_slot, "$g_encountered_party", ":slot", 0),
]],
[anyone|plyr, "mercenary_tavern_talk", [(eq, "$temp", 0),
(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(ge, ":free_capacity", 1)],
##diplomacy start+ Gender-check to avoid accidental absurdities if there are female mercenaries
"That sounds good. But I can't afford to hire any more {reg65?soldiers:men} right now.", "tavern_mercenary_cant_lead", []],
##diplomacy end+
[anyone, "tavern_mercenary_cant_lead", [], "That's a pity. Well, {reg3?we will:I will} be lingering around here for a while,\
if you need to hire anyone.", "close_window", []],
[anyone|plyr, "mercenary_tavern_talk", [(eq, "$temp", 0),
(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(eq, ":free_capacity", 0)],
##diplomacy start+ Gender-check to avoid accidental absurdities if there are female mercenaries
"That sounds good. But I can't lead any more {reg65?soldiers:men} right now.", "tavern_mercenary_cant_lead", []],
##diplomacy end+
[anyone|plyr, "mercenary_tavern_talk", [],
"Sorry. I don't need any other men right now.", "close_window", []],
in modules_scripts search for #script_update_mercenary_units_of_towns replace the entire code with this new one
Code:
#script_update_mercenary_units_of_towns
# INPUT: none
# OUTPUT: none
("update_mercenary_units_of_towns",
[(try_for_range, ":town_no", towns_begin, towns_end),
(store_random_in_range,":troop_no", mercenary_troops_begin, mercenary_troops_end),
(party_set_slot, ":town_no", slot_center_mercenary_troop_type, ":troop_no"),
(store_random_in_range, ":amount", 3, 15),#min and max mercs,change as you want
(party_set_slot, ":town_no", slot_center_mercenary_troop_amount, ":amount"), #This adds a second mercenary to the tavern
(store_random_in_range, ":troop_no2", mercenary_troops_begin, mercenary_troops_end),
(party_set_slot, ":town_no", slot_center_mercenary_troop_type_2, ":troop_no2"),
(store_random_in_range, ":amount2", 3, 15),#min and max mercs,change as you want
(party_set_slot, ":town_no", slot_center_mercenary_troop_amount_2, ":amount2"),
(try_end),
]),
("start_update_mercenary_units_of_towns",
[(try_for_range, ":town_no", towns_begin, towns_end),
(store_random_in_range,":troop_no", mercenary_troops_begin, mercenary_troops_end),
(party_set_slot, ":town_no", slot_center_mercenary_troop_type, ":troop_no"),
(store_random_in_range, ":amount", 3, 15),#min and max mercs,change as you want
(party_set_slot, ":town_no", slot_center_mercenary_troop_amount, ":amount"), #This adds a second mercenary to the tavern
(store_random_in_range, ":troop_no2", mercenary_troops_begin, mercenary_troops_end),
(party_set_slot, ":town_no", slot_center_mercenary_troop_type_2, ":troop_no2"),
(store_random_in_range, ":amount2", 3, 15),#min and max mercs,change as you want
(party_set_slot, ":town_no", slot_center_mercenary_troop_amount_2, ":amount2"),
(try_end),
]),
in modules_game_menus add this
Code:
(party_get_slot, ":mercenary_troop2", "$current_town", slot_center_mercenary_troop_type_2), #Adds a menu for the second group of mercenaries in the tavern
(party_get_slot, ":mercenary_amount2", "$current_town", slot_center_mercenary_troop_amount_2),
(try_begin),
(gt, ":mercenary_amount2", 0),
(gt, ":mercenary_troop2", 0),
(set_visitor, ":cur_entry", ":mercenary_troop2"),
(val_add, ":cur_entry", 1),
(try_end),
bellow this
Code:
(party_get_slot, ":mercenary_troop", "$current_town", slot_center_mercenary_troop_type),
(party_get_slot, ":mercenary_amount", "$current_town", slot_center_mercenary_troop_amount),
(try_begin),
(gt, ":mercenary_troop", 0),
(gt, ":mercenary_amount", 0),
(set_visitor, ":cur_entry", ":mercenary_troop"),
(val_add, ":cur_entry", 1),
(try_end),
That it,you will now find two mercenary leaders in the tavern,this code is excellent if you are adding a lot of mercs in your mod.
CREDITS
Some parts of this code are taken from Floris Source,so obviously the Floris Mod Team deserves the credit.
Somebody and gdwitt for script guidance