Warband Castle/Town Recruitment by Lazsers

Users who are viewing this thread

Hi everyone,

Recently I dicided to give modding warband another try, with some successes here and there, up until I decided to try and implement this old script by laszers (with an updated tutorial by Dalion, thanks again!). Now my module compiles properly and I can actually test how the system works...


Like in many other mods I'm sure, the plan was to have 3 separate troop trees: Commoners, Professionals, Retainers/Nobles.
To give castles more meaning, the idea is to allow the recruitment of better units (duh!). The end goal is to be able to recruit Commoners in villages, Commoners&Professionals in towns, and Professionals&Nobles/Retainers in Castles. For now I simply try to make the base code work (accessible here: https://forums.taleworlds.com/index...s-recruitable-from-castle-towns.202029/page-6)

Now, here are the current problems I am facing:
  • The Professional Recruitment basically works menu-wise until I click "Recruit Them.", at which point nothing happens, I can still go back to the previous menu, I just don't get any recruits.
  • The second problem is for castles: I can click on "recruit troops" as well, but once in the recruitment menu... no more buttons, at which point alt+f4 becomes the only option. Tried copying code in others menu scripts, but my attempts have proven fruitless.
BFA173EEDA6C608DA690CAFAC7AFB8E763DF1DF6


Here is the code, with snippets of surrounding scripts for reference:

module_scripts

Code:
 #script_cf_town_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_recruit_professionals_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", 10),
   (this_or_next|ge, ":center_relation", 0),
   (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),




     (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),


     ]),


  #script_casle_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("cf_castle_recruit_nobles_cond", #renamed
   [(store_faction_of_party, ":cur_faction", "$current_town"),
   (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_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
   (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

module_game_menus Part1

Code:
        ], "Door to the castle."),

   ###Town/Castle Recruitment Part 1
   ("recruit_nobles",[(is_between, "$current_town",
     castles_begin, castles_end), (call_script,
    "script_cf_castle_recruit_nobles_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_professionals",[(is_between, "$current_town",
     towns_begin, towns_end), (call_script,
    "script_cf_town_recruit_professionals_cond"),]
    ,"Recruit Professionals.",
    [
     (try_begin),
      (call_script, "script_cf_enter_center_location_bandit_check"),
     (else_try),
      (jump_to_menu, "mnu_recruit_professionals"),
     (try_end),
     ]),


      ("join_tournament", [(neg|is_currently_night),(party_slot_ge, "$current_town", slot_town_has_tournament, 1),]
       ,"Join the tournament.",

module_game_menus Part2

Code:
        ], "Door to the castle."),

   ###Town/Castle Recruitment Part 1
   ("recruit_nobles",[(is_between, "$current_town",
     castles_begin, castles_end), (call_script,
    "script_cf_castle_recruit_nobles_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_professionals",[(is_between, "$current_town",
     towns_begin, towns_end), (call_script,
    "script_cf_town_recruit_professionals_cond"),]
    ,"Recruit Professionals.",
    [
     (try_begin),
      (call_script, "script_cf_enter_center_location_bandit_check"),
     (else_try),
      (jump_to_menu, "mnu_recruit_professionals"),
     (try_end),
     ]),


      ("join_tournament", [(neg|is_currently_night),(party_slot_ge, "$current_town", slot_town_has_tournament, 1),]
       ,"Join the tournament.",


Code:

###Town/Castle Recruitment Part 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", 200),#200 denars per noble
    (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 noble
      (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_cf_castle_recruit_nobles_cond"),
                 
        (jump_to_menu, "mnu_town"),
      ]),
 
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
      (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),
  ("recruit_professionals",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_3_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", 50),#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", 50),#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_cf_town_recruit_professionals_cond"),
                 
  (jump_to_menu, "mnu_town"),
      ]),
 
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ]),
  ),

  ("notification_relieved_as_marshal", mnf_disable_all_keys,
    "{s4} wishes to inform you that your services as marshal are no longer required. In honor of valiant efforts on behalf of the realm over the last
 
Back
Top Bottom