SP Tutorial Module System How to make troops recruitable from castle/towns.

Users who are viewing this thread

laszers

Veteran
Hello everyone, and as the topic say's this will show you how to make troops available for recruitment from castles and towns. 

This is a very discussed topic, and many people think it requires a lot of coding and modding skills. But all it really requires is the module system.

Before I start this tutorial, I would like to say all credit to Dunde for helping me with the codes, and Ritter Dummbatz for the encouragement for making the tutorial.
The only mod I know this works with is PBOD, any others i cannot say for sure (works fine for native, obviously).
I am using ms 1.134
make sure you backup all modified game files.

first off is scripts

place this code
#script_cf_town_castle_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_castle_recruit_volunteers_cond",
    [(store_faction_of_party, ":town_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
    (ge, ":center_relation", 0),
    (this_or_next|ge, ":center_relation", 5),
    (this_or_next|eq, ":town_faction", "$players_kingdom"),
    (this_or_next|ge, ":town_faction_relation", 0),
    (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
    (            eq, "$players_kingdom", 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (ge, ":free_capacity", 1),
    ]),

below or above this
 
  #script_cf_village_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_village_recruit_volunteers_cond",
    [

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_checking_volunteer_availability_script"),
(try_end),

(neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
    (neg|party_slot_eq, "$current_town", slot_village_state, svs_being_raided),
    (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
    (store_faction_of_party, ":village_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":village_faction_relation", ":village_faction", "fac_player_faction"),

    (ge, ":center_relation", 0),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_center_relation_at_least_zero"),
(try_end),




    (this_or_next|ge, ":center_relation", 5),
    (this_or_next|eq, ":village_faction", "$players_kingdom"),
    (this_or_next|ge, ":village_faction_relation", 0),
    (this_or_next|eq, ":village_faction", "$supported_pretender_old_faction"),
(eq, "$players_kingdom", 0),

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_relationfaction_conditions_met"),
(try_end),


    (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_troops_available"),
(try_end),


    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (ge, ":free_capacity", 1),

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_party_has_capacity"),
(try_end),


    ]),
just search it

scripts 2;
place this code
#script_town_castle_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_castle_recruit_nobles_recruit",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

below or above this
#script_village_recruit_volunteers_recruit
  # INPUT: none
  # OUTPUT: none
  ("village_recruit_volunteers_recruit",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_2_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 10),#10 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 10),#10 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

search it

make sure you put these two in the order listed above, as it could cause complications other wise.

next is simple triggers.

simple triggers
  # Adding mercenary troops to the towns
  (72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", centers_begin, centers_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      (call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),

past this over the existing, script_update_mercenary_units_of_towns

next is one of the most confusing.

module Game menu's 1;
    ("recruit_nobles",[(call_script, "script_cf_town_castle_recruit_volunteers_cond"),]
      ,"Recruit Nobles.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_nobles"),
        (try_end),
        ]),
put below "go to lords hall" in castle_castle menu, just search it.

    ("castle_castle",
      [       
        (party_slot_eq,"$current_town",slot_party_type, spt_castle),       
       
        (eq, "$sneaked_into_town", 0),       
       
        (str_clear, s1),
        (try_begin),
          (store_faction_of_party, ":center_faction", "$current_town"),
          (faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),
          (faction_slot_eq, ":center_faction", slot_faction_ai_object, "$current_town"),
          (str_store_string, s1, "str__join_the_feast"),
        (try_end),
        ],"Go to the Lord's hall{s1}.",
      [         
          (try_begin),
            (this_or_next|eq, "$all_doors_locked", 1),
            (eq, "$sneaked_into_town", 1),         
            (display_message,"str_door_locked",0xFFFFAAAA),
          (else_try),
    (this_or_next|neq, "$players_kingdom", "$g_encountered_party_faction"),
    (neg|troop_slot_ge, "trp_player", slot_troop_renown, 50),
(neg|troop_slot_ge, "trp_player", slot_troop_renown, 125),
(neq, "$g_player_eligible_feast_center_no", "$current_town"),

(faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_state, sfai_feast),
(faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_object, "$g_encountered_party"),

(neg|check_quest_active, "qst_wed_betrothed"),
(neg|check_quest_active, "qst_wed_betrothed_female"),

(neg|troop_slot_ge, "trp_player", slot_troop_spouse, active_npcs_begin), #Married players always make the cut

(jump_to_menu, "mnu_cannot_enter_court"),
  (else_try),
            (assign, "$town_entered", 1),
            (call_script, "script_enter_court", "$current_town"),
          (try_end),
        ], "Door to the castle."),

module game Menu's 2;

 
  (
    "recruit_nobles",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_recruit_nobles_recruit"),
                       
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

place this at the end of module game menus before the last ]

if you have any problems let me know in a post. i will soon be adding how to recruit separate troop trees through castles and towns.

if the tutorial was unclear please tell me so i can improve upon it.

MAKE SURE TO WAIT THREE DAYS IN GAME, MENU WILL NOT SHOW UP OTHERWISE

please post if this helped you.

--------------------------------------------------------------------------------------------------------------------------------

Here is the separate troop trees part of the tutorial

This tutorial allows you to implement a code that lets you recruit troops from both castles and towns, however you can recruit nobles from castles, and regulars from towns.

first off is scripts

you will copy and paste the first script code right below itself, you must rename the script so it may look like this,
#script_cf_town_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_recruit_volunteers_cond",  #renamed
    [(store_faction_of_party, ":town_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
    (ge, ":center_relation", 0),
    (this_or_next|ge, ":center_relation", 5),
    (this_or_next|eq, ":town_faction", "$players_kingdom"),
    (this_or_next|ge, ":town_faction_relation", 0),
    (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
    (            eq, "$players_kingdom", 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (ge, ":free_capacity", 1),
    ]),
    put this script right below the one you put in the first tutorial

For the next one you have to edit a tiny bit more.

#script_town_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_recruit_nobles_recruit", #renamed
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop),  #changed tier so it wouldnt recruit nobles.
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),
Paste this one just as you did the first, right below the one you put in the first tutorial.

Now for module game menus, we are going to change it so each tree is specifically recruited from castle or town.

("recruit_nobles",[(is_between, "$current_town",
        castles_begin, castles_end),      (call_script,                                         
      "script_cf_town_castle_recruit_volunteers_cond"),]
      ,"Recruit Nobles.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_nobles"),
        (try_end),
        ]),
place this over the original, in the first tutorial. this will make it so nobles are only recruited from castles.

this code will allow for regulars to be recruited from towns.
("recruit_normals",[(is_between, "$current_town",
        towns_begin, towns_end),      (call_script,
      "script_cf_town_recruit_volunteers_cond"),]
      ,"Recruit Volunteers.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_normales"),
        (try_end),
        ]),
Note: Notice that in each of these codes for nobles and normal's it has at the beginning castle begin and castle end, but for normal's it has town begin and town end, this determines weather or not they are recruited souly from towns, or castles. 

This code is if you want troops recruited from towns only.
("recruit_normals",[(is_between, "$current_town",
        towns_begin, towns_end),      (call_script,
      "script_cf_town_recruit_volunteers_cond"),] #notice that this part calls on the id given in the first part of the split troop trees tutorial
      ,"Recruit Volunteers.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_normales"),
        (try_end),
        ]),
you can place this code below the noble.


Now for the last game menus.
    "recruit_normales",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop),  #Notice the changed tier
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_recruit_nobles_recruit"),
                       
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),


Remember to wait 3 days, unless you follow ritter's comment.

if you want to recruit different troops from villages as well, then simply change the tier for each script and game menu under villages.

You do not have to change simple triggers.
 
To get rid of 3 days of waiting


Code:
(try_for_range, ":village_no", villages_begin, villages_end),
        (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
(try_end),

Find this inside module_scripts "game_start" and change the range to centers_begin, centers_end.
 
Umm, I just took a quick look at it. I guess you will know as soon as there is another guy who creates a new mod and uses this tutorial. My thoughts were that you may be could point out the places where to actually make the changes a bit more clear. Seems pointless but remember the days when you knew nothing.
 
I just added it on top of Diplomacy 4.1 works fine, but I changed up the script to recruit regular volunteers instead of nobles. I kind of like this idea; why wouldn't you be able to recruit from dense urban areas anyway?

But I am having one little issue and I suspect it is caused by the bottom part of the game_menu.py. When I successfully recruit troops from a town, instead of the menu reverting back into a town menu I get a village menu. surely it's an easy fix but I am way to tired to figure it out. I would really appreciate if someone could fix that.
 
ok, first off check to make sure that the first game menu insert is pointing to the right script, meaning it it should say [(call_script, "script_cf_town_castle_recruit_volunteers_cond"),] after recruit nobles, unless you named it something else.

then in the bottom menu check to make sure that it says jump to menu town, and not jump to menu village.
  (jump_to_menu, "mnu_town"), is what it should look like.

then make sure the first menu insert is in the right place, meaning it should be above, or below "Go to lords hall".

if none of this works then post both your game menu codes for me to have a look at.

thank you for looking at the tutorial.
 
Ah thanks for this  :grin: needed one of these for quite some time now. i will add it to my game later on and tell you if it works. Do i add it to module game menus?
 
I tried it and followed this guide many a time but when i load my warband up it just says "Unexpected end of file while reading :modules/copy of native/menus.txt"

Here is my module system game menus i think that one is causing the problems:

go to lords hall bit
("castle_castle",
      [
        (party_slot_eq,"$current_town",slot_party_type, spt_castle),

        (eq, "$sneaked_into_town", 0),

        (str_clear, s1),
        (try_begin),
          (store_faction_of_party, ":center_faction", "$current_town"),
          (faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),
          (faction_slot_eq, ":center_faction", slot_faction_ai_object, "$current_town"),
          (str_store_string, s1, "str__join_the_feast"),
        (try_end),
        ],"Go to the Lord's hall{s1}.",
      ("recruit_nobles",[(call_script, "script_cf_town_castle_recruit_volunteers_cond"),]
      ,"Recruit Nobles.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_nobles"),
        (try_end),
        ]),
      [
          (try_begin),
            (this_or_next|eq, "$all_doors_locked", 1),
            (eq, "$sneaked_into_town", 1),
            (display_message,"str_door_locked",0xFFFFAAAA),
          (else_try),
    (this_or_next|neq, "$players_kingdom", "$g_encountered_party_faction"),
    (neg|troop_slot_ge, "trp_player", slot_troop_renown, 50),
(neg|troop_slot_ge, "trp_player", slot_troop_renown, 125),
(neq, "$g_player_eligible_feast_center_no", "$current_town"),


Now here is the bit you put at the end
##diplomacy end+
(
    "recruit_normales",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_recruit_nobles_recruit"),
                       
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),
]

Just to let you no im using the diplomacy and PBOD 4.1 on wb 1.143 but do you think this is causing the prolblem?
 
First, thank you for starting this thread! This is exactly the feature that I would like to be able to add to mods.

However, I can't seem to get it to work--specifically the game menus portion. I did correct the "script_cf_town_castle_recruit_volunteers_cond" reference you mention. Nevertheless, the compiler still complains that it cannot find the "mnu_recruit_nobles" object.

Have I put the code in the wrong place?

Here is that whole section, so you can see where I put it:

Code:
    [
      ("castle_castle",
      [        
        (party_slot_eq,"$current_town",slot_party_type, spt_castle),        
        
        (eq, "$sneaked_into_town", 0),         
        
        (str_clear, s1),
        (try_begin),
          (store_faction_of_party, ":center_faction", "$current_town"),
          (faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),
          (faction_slot_eq, ":center_faction", slot_faction_ai_object, "$current_town"),
          (str_store_string, s1, "str__join_the_feast"),
        (try_end),
        ],"Go to the Lord's hall{s1}.",
       [          
           (try_begin),
             (this_or_next|eq, "$all_doors_locked", 1),
             (eq, "$sneaked_into_town", 1),           
             (display_message,"str_door_locked",0xFFFFAAAA),
           (else_try),
		     (this_or_next|neq, "$players_kingdom", "$g_encountered_party_faction"),
		     (neg|troop_slot_ge, "trp_player", slot_troop_renown, 50),
			 (neg|troop_slot_ge, "trp_player", slot_troop_renown, 125),
			 (neq, "$g_player_eligible_feast_center_no", "$current_town"),

			 (faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_state, sfai_feast),
			 (faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_object, "$g_encountered_party"),
			 
			 (neg|check_quest_active, "qst_wed_betrothed"),
			 (neg|check_quest_active, "qst_wed_betrothed_female"),
			 
			 (neg|troop_slot_ge, "trp_player", slot_troop_spouse, active_npcs_begin), #Married players always make the cut
			 
			 (jump_to_menu, "mnu_cannot_enter_court"),
		   (else_try),
             (assign, "$town_entered", 1),
             (call_script, "script_enter_court", "$current_town"),
           (try_end),
        ], "Door to the castle."),

	  ("recruit_nobles",[(call_script, "script_cf_town_castle_recruit_volunteers_cond"),]
       ,"Recruit Nobles.",
       [
         (try_begin),
           (call_script, "script_cf_enter_center_location_bandit_check"),
         (else_try),
           (jump_to_menu, "mnu_recruit_nobles"),
         (try_end),
        ]),

      ("join_tournament", [(neg|is_currently_night),(party_slot_ge, "$current_town", slot_town_has_tournament, 1),]
       ,"Join the tournament.",
       [
           (call_script, "script_fill_tournament_participants_troop", "$current_town", 1),
           (assign, "$g_tournament_cur_tier", 0),
           (assign, "$g_tournament_player_team_won", -1),
           (assign, "$g_tournament_bet_placed", 0),
           (assign, "$g_tournament_bet_win_amount", 0),
           (assign, "$g_tournament_last_bet_tier", -1),
           (assign, "$g_tournament_next_num_teams", 0),
           (assign, "$g_tournament_next_team_size", 0),
           (jump_to_menu, "mnu_town_tournament"),
        ]),

Again, thanks for your help!
 
Nevermind, I got it working.

The name of the last menu needs to be "recruit_nobles" rather than "recruit_normales"--which, of course, makes perfect sense.

Thanks again!
 
Hey! I wanted to say thanks for the tutorial. This is something rather critical for some mods and this is really useful.

However, I did everything, I believe, you stated, but I'm getting an error that perhaps you can help me with. I am using the NMC base (Native Mod Compilation) which uses Custom Commander, Diplomacy, and PBOD.

This how my code in reflection of following your directions

from module_scripts.py for the conditional scripts.
  #script_cf_troop_agent_is_alive
  # INPUT: arg1 = troop_id
  ("cf_troop_agent_is_alive",
    [(store_script_param, ":troop_no", 1),
    (assign, ":alive_count", 0),
    (try_for_agents, ":cur_agent"),
      (agent_get_troop_id, ":cur_agent_troop", ":cur_agent"),
      (eq, ":troop_no", ":cur_agent_troop"),
      (agent_is_alive, ":cur_agent"),
      (val_add, ":alive_count", 1),
    (try_end),
    (gt, ":alive_count", 0),
    ]),
#script_cf_town_castle_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_castle_recruit_volunteers_cond",
    [(store_faction_of_party, ":town_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
    (ge, ":center_relation", 0),
    (this_or_next|ge, ":center_relation", 5),
    (this_or_next|eq, ":town_faction", "$players_kingdom"),
    (this_or_next|ge, ":town_faction_relation", 0),
    (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
    (            eq, "$players_kingdom", 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (ge, ":free_capacity", 1),
    ]),
#script_cf_town_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_recruit_volunteers_cond",  #renamed
    [(store_faction_of_party, ":town_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
    (ge, ":center_relation", 0),
    (this_or_next|ge, ":center_relation", 5),
    (this_or_next|eq, ":town_faction", "$players_kingdom"),
    (this_or_next|ge, ":town_faction_relation", 0),
    (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
    (            eq, "$players_kingdom", 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (ge, ":free_capacity", 1),
    ]),


  #script_cf_village_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_village_recruit_volunteers_cond",
    [

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_checking_volunteer_availability_script"),
(try_end),

(neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
    (neg|party_slot_eq, "$current_town", slot_village_state, svs_being_raided),
    (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
    (store_faction_of_party, ":village_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":village_faction_relation", ":village_faction", "fac_player_faction"),

    (ge, ":center_relation", 0),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_center_relation_at_least_zero"),
(try_end),

The called scripts from module_scripts.py
#script_town_castle_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_castle_recruit_nobles_recruit",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),
#script_town_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_recruit_nobles_recruit", #renamed
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop),  #changed tier so it wouldnt recruit nobles.
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

  #script_village_recruit_volunteers_recruit
  # INPUT: none
  # OUTPUT: none
  ("village_recruit_volunteers_recruit",
    [(party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 10),#10 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 10),#10 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

From module_game_menus.py
("castle_castle",
      [       
        (party_slot_eq,"$current_town",slot_party_type, spt_castle),       
       
        (eq, "$sneaked_into_town", 0),       
       
        (str_clear, s1),
        (try_begin),
          (store_faction_of_party, ":center_faction", "$current_town"),
          (faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),
          (faction_slot_eq, ":center_faction", slot_faction_ai_object, "$current_town"),
          (str_store_string, s1, "str__join_the_feast"),
        (try_end),
        ],"Go to the Lord's hall{s1}.",
("recruit_nobles",[(is_between, "$current_town",castles_begin, castles_end),
(call_script,"script_cf_town_castle_recruit_volunteers_cond"),]
      ,"Recruit Nobles.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_nobles"),
        (try_end),
        ]),
("recruit_normals",[(is_between, "$current_town",towns_begin, towns_end),
(call_script,"script_cf_town_recruit_volunteers_cond"),] #notice that this part calls on the id given in the first part of the split troop trees tutorial
      ,"Recruit Volunteers.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_normales"),
        (try_end),
        ]),
      [         
          (try_begin),
            (this_or_next|eq, "$all_doors_locked", 1),
            (eq, "$sneaked_into_town", 1),         
            (display_message,"str_door_locked",0xFFFFAAAA),
          (else_try),
    (this_or_next|neq, "$players_kingdom", "$g_encountered_party_faction"),
    (neg|troop_slot_ge, "trp_player", slot_troop_renown, 50),
(neg|troop_slot_ge, "trp_player", slot_troop_renown, 125),
(neq, "$g_player_eligible_feast_center_no", "$current_town"),

(faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_state, sfai_feast),
(faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_object, "$g_encountered_party"),

(neg|check_quest_active, "qst_wed_betrothed"),
(neg|check_quest_active, "qst_wed_betrothed_female"),

(neg|troop_slot_ge, "trp_player", slot_troop_spouse, active_npcs_begin), #Married players always make the cut

(jump_to_menu, "mnu_cannot_enter_court"),
  (else_try),
            (assign, "$town_entered", 1),
            (call_script, "script_enter_court", "$current_town"),
          (try_end),
        ], "Door to the castle."),

At the end of module_game_menus.py
  ("recruit_nobles",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
      (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
        (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_recruit_nobles_recruit"),
                       
        (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
      (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),
  ("recruit_normales",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop),  #Notice the changed tier
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_recruit_nobles_recruit"),
                       
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

#TEMPERED CHANGES BEGIN, TOGGLE OPTIONS
  ("entrench_options",0,
  "Entrenchment preferences:",
  "none",
  [
    ],
    [
      ("action_no_drowning",[(eq, "$drowning", 1)],"_Disable drowning in missions.",
      [
(assign,"$drowning",0),
        ]
      ),
 
      ("action_drowning",[(eq, "$drowning", 0)],"_Enable drowning in missions.",
      [
(assign,"$drowning",1),
        ]
      ),
 
      ("go_back",[],
      "Go back.", [(jump_to_menu,"mnu_camp_mod_preferences")]),
      ]
  ),
#TEMPERED CHANGES END 
]

My build_module.bat is this
Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
Traceback (most recent call last):
  File "process_game_menus.py", line 47, in <module>
    save_game_menus(variables,variable_uses,tag_uses,quick_strings)
  File "process_game_menus.py", line 31, in save_game_menus
    save_game_menu_item(ofile,variable_list,variable_uses,menu_item,tag_uses,qui
ck_strings)
  File "process_game_menus.py", line 14, in save_game_menu_item
    save_statement_block(ofile,0, 1, menu_item[3], variable_list, variable_uses,
tag_uses,quick_strings)
  File "D:\NMC Source Files\process_operations.py", line 449, in save_statement_
block
    save_statement(ofile,opcode,no_variables,statement,variable_list,variable_us
es,local_vars, local_var_uses,tag_uses,quick_strings)
  File "D:\NMC Source Files\process_operations.py", line 398, in save_statement
    ofile.write("%d %d "%(opcode, lenstatement))
TypeError: %d format: a number is required, not str
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
WARNING: Global variable never used: g_enemy_surrenders
WARNING: Global variable never used: g_player_surrenders
WARNING: Global variable never used: g_private_battle_with_troop
WARNING: Global variable never used: g_leave_town_outside
WARNING: Global variable never used: g_prisoner_recruit_last_time
WARNING: Global variable never used: playerparty_postbattle_regulars
WARNING: Global variable never used: routed_party_added
WARNING: Global variable never used: thanked_by_ally_leader
WARNING: Global variable never used: last_freed_hero
WARNING: Global variable never used: capture_screen_shown
WARNING: Global variable never used: g_prison_heroes
WARNING: Global variable never used: g_player_besiege_town
WARNING: Global variable never used: g_siege_force_wait
WARNING: Global variable never used: g_siege_sallied_out_once
WARNING: Global variable never used: g_siege_join
WARNING: Global variable never used: qst_train_peasants_against_bandits_currentl
y_training
WARNING: Global variable never used: qst_eliminate_bandits_infesting_village_num
_villagers
WARNING: Global variable never used: g_player_raid_complete
WARNING: Global variable never used: quest_auto_menu
WARNING: Global variable never used: g_tournament_player_team_won
WARNING: Global variable never used: g_tournament_bet_placed
WARNING: Global variable never used: g_tournament_bet_win_amount
WARNING: Global variable never used: g_tournament_last_bet_tier
WARNING: Global variable never used: g_last_assassination_attempt_time
WARNING: Global variable never used: g_last_rest_payment_until
WARNING: Global variable never used: g_train_peasants_against_bandits_num_peasan
ts
WARNING: Global variable never used: last_sneak_attempt_town
WARNING: Global variable never used: last_sneak_attempt_time
WARNING: Global variable never used: g_training_ground_training_count
WARNING: Global variable never used: g_presentation_marshall_selection_max_renow
n_2
WARNING: Global variable never used: g_tutorial_entered
WARNING: Global variable never used: g_dont_give_marshalship_to_player_days
WARNING: Global variable never used: g_duel_vis_point_plyr
WARNING: Global variable never used: g_duel_vis_point_opp
WARNING: Global variable never used: entrench_time
WARNING: Global variable never used: g_player_days_as_marshal
WARNING: Global variable never used: g_player_begin_hp
WARNING: Global variable never used: g_players_policy_set
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .

I know the end global variable issues are related to an earlier compiling issue, but I'm not sure I placed the menu option early on in the right place. Maybe you can help me out. I really appreciate it.

CR

 
I think discovered the source of the error, but I'm still not getting any option to recruit nobles or volunteers.
("castle_castle",
      [       
        (party_slot_eq,"$current_town",slot_party_type, spt_castle),       
       
        (eq, "$sneaked_into_town", 0),       
       
        (str_clear, s1),
        (try_begin),
          (store_faction_of_party, ":center_faction", "$current_town"),
          (faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),
          (faction_slot_eq, ":center_faction", slot_faction_ai_object, "$current_town"),
          (str_store_string, s1, "str__join_the_feast"),
        (try_end),
        ],"Go to the Lord's hall{s1}.",
[         
          (try_begin),
            (this_or_next|eq, "$all_doors_locked", 1),
            (eq, "$sneaked_into_town", 1),         
            (display_message,"str_door_locked",0xFFFFAAAA),
          (else_try),
    (this_or_next|neq, "$players_kingdom", "$g_encountered_party_faction"),
    (neg|troop_slot_ge, "trp_player", slot_troop_renown, 50),
(neg|troop_slot_ge, "trp_player", slot_troop_renown, 125),
(neq, "$g_player_eligible_feast_center_no", "$current_town"),

(faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_state, sfai_feast),
(faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_object, "$g_encountered_party"),

(neg|check_quest_active, "qst_wed_betrothed"),
(neg|check_quest_active, "qst_wed_betrothed_female"),

(neg|troop_slot_ge, "trp_player", slot_troop_spouse, active_npcs_begin), #Married players always make the cut

(jump_to_menu, "mnu_cannot_enter_court"),
  (else_try),
            (assign, "$town_entered", 1),
            (call_script, "script_enter_court", "$current_town"),
          (try_end),
        ], "Door to the castle."),
("recruit_nobles",[(is_between, "$current_town",castles_begin, castles_end),
(call_script,"script_cf_town_castle_recruit_volunteers_cond"),]
      ,"Recruit Nobles.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_nobles"),
        (try_end),
        ]),
("recruit_normals",[(is_between, "$current_town",towns_begin, towns_end),
(call_script,"script_cf_town_recruit_volunteers_cond"),] #notice that this part calls on the id given in the first part of the split troop trees tutorial
      ,"Recruit Volunteers.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_normales"),
        (try_end),
        ]),

      ("join_tournament", [(neg|is_currently_night),(party_slot_ge, "$current_town", slot_town_has_tournament, 1),]
      ,"Join the tournament.",
      [
          (call_script, "script_fill_tournament_participants_troop", "$current_town", 1),
          (assign, "$g_tournament_cur_tier", 0),
          (assign, "$g_tournament_player_team_won", -1),
          (assign, "$g_tournament_bet_placed", 0),
          (assign, "$g_tournament_bet_win_amount", 0),
          (assign, "$g_tournament_last_bet_tier", -1),
          (assign, "$g_tournament_next_num_teams", 0),
          (assign, "$g_tournament_next_team_size", 0),
          (jump_to_menu, "mnu_town_tournament"),
        ]),

Did I put something in wrong?

Thanks again,

CR
 
Make sure to wait three days. also try putting a space in between the last bit of the lords halls and the beginning of the recruit nobles part.
however, like i stated i do not no if this mod is compatible with mods like that. try checking with the creator of the mod if the above does not fix it.
 
laszers said:
Make sure to wait three days. also try putting a space in between the last bit of the lords halls and the beginning of the recruit nobles part.
however, like i stated i do not no if this mod is compatible with mods like that. try checking with the creator of the mod if the above does not fix it.

Thanks for the reply. I wasn't sure if the other mods were also compatible. I'm somewhat new to the Module System.

I'll ask in the Q&A Forum to see if anyone has an answer for me on it then. I appreciate it :smile:

I'll give that a try before I do, though.

Thanks :smile:

CR
 
Heya,

As of yet, it's still not working for me, but I haven't had a chance to address it yet. It compiles, it just never shows up.

Dunno.

the rgl_log shows no error with it though.

CR
 
sorry for the really late reply. my only guess is it isnt compatible with the mod your using. maybe try and see if you can do it with native.
 
Alright I have inserted these scripts and compiled the code. I am using M&B warband, native 1.143

First I must say this tutorial needs to be completely reworked. The explanations are messy and figuring everything out took about four to five hours over three days. However in all fariness I am new to modding.

I would say it would probably be faster for those who are very familiar with M&B code to rewrite their own version of this code than follow this tutorial.

The first error I found was a syntax error from the compiler. As it turns out this
error is cause by a missing parentheses on the recruit normales menu

fixed script for recruit normales menu
(
"recruit_normales",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop),  #Notice the changed tier
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_recruit_nobles_recruit"),
                     
  (jump_to_menu, "mnu_town"),
      ]),
   
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

I also found some other errors I will post later, however I have "fixed" up the code and basically remade the tutorial for the split troops trees inside of a word document.

EDIT:

Alright most errors I found were in the code concerning troop cost.

Here is what i changed for script_town_castle_recruit_nobles_recruit:
  #script_town_castle_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_castle_recruit_nobles_recruit",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

for I changed the price and made a suggestion script_town_recruit_nobles_recruit:
#script_town_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_recruit_nobles_recruit", #renamed
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop)#Since this updated version of the code sets recruit cost to 40 denars it might be good to change the #troop tier
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 40),#40 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),


I also found errors in the recruit_nobles menu that goes at the end of the module_menu:
  (
    "recruit_nobles",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 200),#200 denars per man #I had to set this #as it was still 40
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 200),#200 denars per man #again was 40
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_castle_recruit_nobles_recruit"),
# this one was a big problem, was originally set different and thus player could not recruit troops by #pressing the button
                       
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

I am pretty sure those are all the errors I found when setting up the split troop tree code. These errors may not apply to the first part of your tutorial.

Anyway thank you very much for this code. I am glad the tutorial was messy and there were errors. It gave me the chance to learn a lot.




 
Back
Top Bottom