Need Help With Tavern Recruitment.

Users who are viewing this thread

OP below.
I know this one have been beaten to death already but I need some help.

I looked at the python script exchange thread an found this post by Geoffrey Ashe (link to post)

I searched the forums but I couldn't find anything that could help me.
The problem is that I cant seem to get any troops into the recruit screen. All I see is a clone of my self.
Also I looked at the SoD V4 source, but it looks exactly the same, to me. I thought I could use their but to no avail.
And yes, I've started a new game :grin:

So I'm wondering if there is a way to fix this?
Or if anyone knows how to enable the feature already existing in the game but is commented out?


Here is the code I'm using. I've left some of the native code visible in the spoilers.
Just so that you can see where I've put it.

SOLVED!
Here is the working code. Made by Geoffrey Ashe.
Solution by Hokie BT.

Code:
##########################################################
# Test : Tavern Recruitment Begin ########################
##########################################################
slot_town_mercs = 66
merc_parties_begin = "p_town_merc_1"
merc_parties_end = "p_castle_1"
#########################################################
# Test : Tavern Recruitment End #########################
#########################################################


 
Code:
[anyone,"tavernkeeper_deliver_wine_lost", [],
 "What? I was waiting for that {s4} for weeks!\
 And now you are telling me that you lost it?\
 You may rest assured that I will let {s1} know about this.", "tavernkeeper_pretalk",
   [(add_xp_as_reward, 40),
    (quest_get_slot, ":quest_target_item", "qst_deliver_wine", slot_quest_target_item),
    (quest_get_slot, ":quest_giver_troop", "qst_deliver_wine", slot_quest_giver_troop),
    (str_store_item_name, s4, ":quest_target_item"),
    (str_store_troop_name, s1, ":quest_giver_troop"),
    (val_add, "$debt_to_merchants_guild", "$qst_deliver_wine_debt"),
    (call_script, "script_end_quest", "qst_deliver_wine"),
   ]],
#######################################################################################
# Test : Tavern recruitment Begin ###################################################
#######################################################################################
  [anyone|plyr,"tavernkeeper_talk", [], "I need to hire some soldiers. Can you help me?", "tavernkeeper_buy_peasants",[]],
  [anyone,"tavernkeeper_buy_peasants",
   [
       (store_encountered_party,reg(3)),
       (store_faction_of_party,reg(4),reg(3)),
       (store_relation,reg(5),"fac_player_supporters_faction",reg(4)),
       (lt, reg(5), -3),
    ], "I don't think anyone from this town will follow somebody like you. Try your luck elsewhere.", "tavernkeeper_buy_peasants_2",[]],
  [anyone,"tavernkeeper_buy_peasants", [], "I know a few fellows who would follow you if you paid for their equipment.", "tavernkeeper_buy_peasants_2",[(store_encountered_party,reg(2)),(party_get_slot,"$tavernkeeper_party",reg(2),slot_town_mercs),(set_mercenary_source_party,"$tavernkeeper_party"),(change_screen_buy_mercenaries)]],
  [anyone,"tavernkeeper_buy_peasants_2", [], "Anything else?", "tavernkeeper_talk",[]],
#######################################################################################
# Test : Tavern recruitment end #####################################################
#######################################################################################
# NOTE TO SELF:
# I altered line 8943. The original line looks like this :  
# [anyone,"tavernkeeper_buy_peasants", [], "I know a few fellows who would follow you if you paid for their equipment.", "tavernkeeper_buy_peasants_2",[(store_encountered_party,reg(2)),(party_get_slot,"$tavernkeeper_party",reg(2)),slot_town_mercs),(set_mercenary_source_party,"$tavernkeeper_party"),(change_screen_buy_mercenaries)]],
#
# I added the "(" to (slot_town_mercs). Otherwise it gives a syntax.
# I changed it to : 
# [anyone,"tavernkeeper_buy_peasants", [], "I know a few fellows who would follow you if you paid for their equipment.", "tavernkeeper_buy_peasants_2",[(store_encountered_party,reg(2)),(party_get_slot,"$tavernkeeper_party",reg(2)),(slot_town_mercs),(set_mercenary_source_party,"$tavernkeeper_party"),(change_screen_buy_mercenaries)]],
###################################################################################
###################################################################################


##  [anyone|plyr,"tavernkeeper_talk", [], "I need to hire some soldiers. Can you help me?", "tavernkeeper_buy_peasants",[]],
##  [anyone,"tavernkeeper_buy_peasants",
##   [
##       (store_encountered_party,reg(3)),
##       (store_faction_of_party,reg(4),reg(3)),
##       (store_relation,reg(5),"fac_player_supporters_faction",reg(4)),
##       (lt, reg(5), -3),
##    ], "I don't think anyone from this town will follow somebody like you. Try your luck elsewhere.", "tavernkeeper_buy_peasants_2",[]],


Code:
[anyone,"tavernkeeper_buy_drinks_end",
   [], "Don't worry {sir/madam}. Your name will be cheered and toasted here all night.", "tavernkeeper_pretalk",
   [
       (troop_remove_gold, "trp_player", "$temp"),
       (call_script, "script_change_player_relation_with_center", "$current_town", 1),
       (store_current_hours,":cur_hours"),
       (assign, "$buy_drinks_last_time", ":cur_hours"),
       ]],
	#####################################################################################
	# Test: Tavern recruitment and Ale Begin ############################################
	#####################################################################################
  [anyone|plyr,"tavernkeeper_talk", [
      (store_current_hours,":cur_hours"),
      (val_sub, ":cur_hours", 24),
      (gt, ":cur_hours", "$buy_drinks_last_time"),
      ], "I'd like to buy me and my men a barrel of your best ale.", "tavernkeeper_buy_drinks_troops",[]],

  [anyone,"tavernkeeper_buy_drinks_troops",
   [
    ], "Of course, {my lord/my lady}. I reckon {reg5} denars should be enough for that. What should I tell the lads?", "tavernkeeper_buy_drinks_troops_2",[
        (assign, "$temp", 20),
      (store_party_size_wo_prisoners, reg5, "p_main_party"),
      (store_mul, "$temp", "$temp", reg5),
        (assign, reg5, "$temp"),
        ]],

  [anyone|plyr,"tavernkeeper_buy_drinks_troops_2",
   [
        (store_troop_gold, ":gold", "trp_player"),
        (ge, ":gold", "$temp"),
        (str_store_party_name, s10, "$current_town"),
    ], "The price is fair enough, let my men have at it.", "tavernkeeper_buy_drinks_troops_end",[
       
        ]],

  [anyone,"tavernkeeper_buy_drinks_troops_end",
   [], "Don't worry {sir/madam}. Your men will enjoy their pints.", "tavernkeeper_pretalk",
   [
       (troop_remove_gold, "trp_player", "$temp"),
      (call_script, "script_change_player_party_morale", 20),
       (store_current_hours,":cur_hours"),
       (assign, "$buy_drinks_last_time", ":cur_hours"),
      (rest_for_hours, 2, 5, 0)
       ]],

  [anyone|plyr,"tavernkeeper_buy_drinks_troops_2", [], "Actually, cancel that order.", "tavernkeeper_pretalk",[]],
	#####################################################################################
	# Test: Tavern recruitment and Ale End ##############################################
	#####################################################################################

  [anyone|plyr,"tavernkeeper_talk", [], "I guess I should leave now.", "close_window",[]],

#Tavern Talk (with companions)
#  [anyone, "companion_recruit_yes", [(neg|hero_can_join, "p_main_party"),], "I don't think can lead any more men than you do now.\
# You need to release someone from service if you want me to join your party.", "close_window", []],


Code:
# Towns (loop)
      (try_for_range, ":town_no", towns_begin, towns_end),
        (store_sub, ":offset", ":town_no", towns_begin),
        (party_set_slot,":town_no", slot_party_type, spt_town),
#        (store_add, ":cur_object_no", "trp_town_1_seneschal", ":offset"),
#        (party_set_slot,":town_no", slot_town_seneschal, ":cur_object_no"),

#####################################################################
# Test : Tavern recruitment Begin #################################
#####################################################################
    (store_add, ":cur_object_no", "p_town_merc_1", ":offset"),
	(party_set_slot,":town_no", slot_town_mercs,":cur_object_no"),
#####################################################################
# Test : Tavern recruitment End ###################################
#####################################################################

        (store_add, ":cur_object_no", "scn_town_1_center", ":offset"),
        (party_set_slot,":town_no", slot_town_center, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_castle", ":offset"),
        (party_set_slot,":town_no", slot_town_castle, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_prison", ":offset"),
        (party_set_slot,":town_no", slot_town_prison, ":cur_object_no"),


Code:
  (store_add, ":cur_slot", slot_troop_enemies_begin, ":troop_enemy_count"),
          (troop_set_slot, ":troop_id", ":cur_slot", ":result"),
          (store_add, ":cur_slot", slot_troop_enemies_begin, ":enemy_troop_enemy_count"),
          (troop_set_slot, ":result", ":cur_slot", ":troop_id"),
        (try_end),
      (try_end),

      (try_for_range, ":unused", 0, 8),
        (call_script, "script_spawn_bandits"),
      (try_end),
	  
###################################################################################
# Test : Tavern Recruitment Begin ###############################################
###################################################################################
		(call_script, "script_add_tavern_troops"),
###################################################################################
# Test : Tavern Recruitment End #################################################
###################################################################################

      (set_spawn_radius, 50),
      (try_for_range, ":unused", 0, 25),
        (spawn_around_party,"p_main_party","pt_looters"),
      (try_end),

      (try_for_range, ":unused", 0, 6),
        (call_script, "script_update_trade_good_prices"),
      (try_end),

This one, below, is pasted at the bottom of the file.
Code:
   ##################################################
	# Test: Tavern Recruitment Begin ###############
	##################################################
#no input/output
#could need a faction check
#that's from the 808 module system

   ("add_tavern_troops",
      [
         (try_for_range,reg(2),merc_parties_begin,merc_parties_end),
              (store_party_size,reg(6),reg(2)),
            (lt,reg(6),30), #never have many more than 30 troops in the tavern
            (store_random,reg(7),8),
            (party_add_members,reg(2),"trp_townsman",reg(7)),
            (store_random,reg(8),5),
            (party_add_members,reg(2),"trp_sea_raider",reg(8)),
            (store_random,reg(9),5),
            (party_add_members,reg(2),"trp_manhunter",reg(9)),
         (try_end),
                
      ]),
	##################################################
	# Test: Tavern Recruitment Begin ###############
	##################################################


Code:
#  ("village_reinforcements","village_reinforcements",pf_is_static|pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(1,1),[]),
#######################################################################################
# Test : Tavern recruitment Begin ###################################################
####################################################################################### 
  ("town_merc_1","sargoth_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_2","tihr_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_3","veluca_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_4","suno_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_5","jelkala_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_6","praven_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_7","uxkhal_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_8","reyvadin_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_9","khudan_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_10","tulga_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_11","curaw_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_12","wercheg_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_13","rivacheg_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_14","halmar_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_15","yalen_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_16","dhirim_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_17","ichamur_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_18","narra_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
#######################################################################################
# Test : Tavern recruitment End ###################################################
####################################################################################### 
  ("zendar","Zendar",pf_disabled|icon_town|pf_is_static|pf_always_visible|pf_hide_defenders, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(18,60),[]),


Code:
#NPC system changes begin
#Move unemployed NPCs around taverns
   (24 * 15, 0, 0,
   [
    (call_script, "script_update_companion_candidates_in_taverns"),
    ],
   []
   ),

#######################################################################################
# Test : Tavern recruitment Begin ###################################################
#######################################################################################

(24.0, 0, 0.0, [],
   [
      (call_script, "script_add_tavern_troops"),
                
   ],
   ),

#######################################################################################
# Test : Tavern recruitment End #####################################################
#######################################################################################


#Process morale and determine personality clashes
  (0, 0, 24,
   [],
[
 
The thing is that if I use the code found in the script exchange I get an error saying:

Unrecognized opcode 66.; LINE NO: 2: At dialog consequence: dlga_tavernkeeper_buy_peasants:tavernkeeper_buy_peasants_2.1. At dialog consequence: dlga_tavernkeeper_buy_peasants:tavernkeeper_buy_peasants_2.1.

And then when I enter where the troops should there's no troops.
It's empty.

And if I use the SoD variant, all I get is a clone of my self but no error.
All I wan't is for the troops to show up in the window and to be able to hire them.


Here is where they differ from each other.
I can't see anything else that
Code:
Here is the original code found in the script exchange:

[anyone|plyr,"tavernkeeper_talk", [], "I need to hire some soldiers. Can you help me?", "tavernkeeper_buy_peasants",[]],
  [anyone,"tavernkeeper_buy_peasants",
   [
       (store_encountered_party,reg(3)),
       (store_faction_of_party,reg(4),reg(3)),
       (store_relation,reg(5),"fac_player_supporters_faction",reg(4)),
       (lt, reg(5), -3),
    ], "I don't think anyone from this town will follow somebody like you. Try your luck elsewhere.", "tavernkeeper_buy_peasants_2",[]],
  [anyone,"tavernkeeper_buy_peasants", [], "I know a few fellows who would follow you if you paid for their equipment.", "tavernkeeper_buy_peasants_2",[(store_encountered_party,reg(2)),(party_get_slot,"$tavernkeeper_party",reg(2)),slot_town_mercs),(set_mercenary_source_party,"$tavernkeeper_party"),(change_screen_buy_mercenaries)]],
  [anyone,"tavernkeeper_buy_peasants_2", [], "Anything else?", "tavernkeeper_talk",[]],


Note that if this code should work at all I have to add a "(" to: slot_town_mercs) 
Otherwise it gives a syntax error.
###################################
###################################

And here is the Sod variant:

[anyone|plyr,"tavernkeeper_talk", [], "I need to hire some soldiers. Can you help me?", "tavernkeeper_buy_peasants",[]],
  [anyone,"tavernkeeper_buy_peasants",
   [
       (store_encountered_party,reg(3)),
       (store_faction_of_party,reg(4),reg(3)),
       (store_relation,reg(5),"fac_player_supporters_faction",reg(4)),
       (lt, reg(5), -3),
    ], "I don't think anyone from this town will follow somebody like you. Try your luck elsewhere.", "tavernkeeper_buy_peasants_2",[]],
  [anyone,"tavernkeeper_buy_peasants", [], "I know a few fellows who would follow you if you paid for their equipment.", "tavernkeeper_buy_peasants_2",[(set_mercenary_source_party,"$tavernkeeper_party"),[change_screen_buy_mercenaries]]],
  [anyone,"tavernkeeper_buy_peasants_2", [], "Anything else?", "tavernkeeper_talk",[]],
 
I used the SOD code in my mod, while they are similar I don't think you could mix-n-match the code so I'd try and first get Geoffrey Ashe's version working.  If that doesn't work then maybe remove it all and try the SOD source.

In terms of the syntax error, you actually don't want to add another ) you need to remove the extra one I highlighted in red.  See if removing this fixes it?

(party_get_slot,"$tavernkeeper_party",reg(2)),slot_town_mercs),
 
Aha. I added a ( to it.
(party_get_slot,"$tavernkeeper_party",reg(2)),(slot_town_mercs),

instead of removing it, like this:

(party_get_slot,"$tavernkeeper_party",reg(2),slot_town_mercs),


I'll try and see if it your solution gets me anywhere.

-EDIT-

Glory and riches to thee!
Your might shall allways prevail and never fail you.

No but seriously, Thanks.
It helped. No errors, all troops showing.
Again. Thank you.

 
damn, good to hear.  I think I tried to help Llew2 out a while back and we could never get it working.  2nd time is the charm apparently....  hehe
 
Hi,

I'd like to get help doing something similar at the tavern.  What I want to do is to check for the faction of the town, and call that faction's basic elite troop and put it into the mercenary buy screen.

I was able to get HokieBT's version working, but that put all factions' nobles for hire so I tried to tweak it to check for faction.  When I tried to adapt the update village volunteers script (with my very newbie knowledge of coding) I got the same error as NaglFaar -- my character shows up in the buy screen.

Here's the code I tried to work with:

 
("get_elite_troops_in_tavern",
  [
        (assign,reg(2), "p_center_nobles" ),
      (store_script_param, ":center_no", 1),
#      (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
      (party_get_slot, ":center_culture", ":center_no", slot_center_culture),#identifies the culture
      (faction_get_slot, ":my_troop", ":center_culture", slot_faction_elite_troop),#identifies elite troop for the culture
                      (store_random,reg(7), :cool:,
                      (val_add, reg(7), 4),
#      (val_mul, ":upper_limit", 3), 
#      (store_add, ":amount_random_divider", 2, ":volunteer_troop_tier"),
#      (val_div, ":upper_limit", ":amount_random_divider"),
     
#      (store_random_in_range, ":amount", 0, ":upper_limit"),
      (party_set_slot, ":center_no", slot_center_volunteer_troop_type, ":my_troop"),
      (party_set_slot, ":center_no", slot_center_volunteer_troop_amount, reg(7)),
      (party_add_members, reg(2), ":volunteer_troop", reg(7)),     
    ]),
 
Dariel, maybe you could use
Code:
slot_faction_tier_5_troop
in there?

Like so:
Code:
("get_elite_troops_in_tavern",
  [
        (assign,reg(2), "p_center_nobles" ),
       (store_script_param, ":center_no", 1),
#       (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
       (party_get_slot, ":center_culture", ":center_no", slot_center_culture),#identifies the culture
       (faction_get_slot, ":my_troop", ":center_culture", slot_faction_tier_5_troop),#identifies elite troop for the culture
                      (store_random,reg(7), 8),
                      (val_add, reg(7), 4),
#       (val_mul, ":upper_limit", 3),   
#       (store_add, ":amount_random_divider", 2, ":volunteer_troop_tier"),
#       (val_div, ":upper_limit", ":amount_random_divider"),
       
#       (store_random_in_range, ":amount", 0, ":upper_limit"),
       (party_set_slot, ":center_no", slot_center_volunteer_troop_type, ":my_troop"),
       (party_set_slot, ":center_no", slot_center_volunteer_troop_amount, reg(7)),
       (party_add_members, reg(2), ":volunteer_troop", reg(7)),       
     ]),
At least, I assume you meant the highest tier troop (defined in module_scripts) with your "elite"? I wouldn't know if it works, though.

 
I got problem with tavern recruitment, this is what module.bat says:


Initializing...
Traceback (most recent call last):
  File "process_global_variables.py", line 11, in <module>
    from process_operations import *
  File "c:\Program Files\Mount&Blade\Modules\test2\process_operations.py", line
20, in <module>
    from module_scripts import *
  File "c:\Program Files\Mount&Blade\Modules\test2\module_scripts.py", line 691,
in <module>
    (party_set_slot,":town_no", slot_town_mercs,":cur_object_no"),
NameError: name 'slot_town_mercs' is not defined
Exporting strings...

what should I do?
 
Definitely not from the tavern recruitment code, as that changes only module_dialogues.py and module_triggers.py.  The error looks like it's coming from module_game_menus.py.
 
Back
Top Bottom