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

Users who are viewing this thread

Sir William the Brave said:
Will this work in Mount and Blade Vanilla.
No idea but try comparing the Warband codes with the Vanilla ones. If they match mostly then maybe it will work. I doubt that they are too different considering that recruiting seemingly works the same way in both games.
 
GunFred said:
Sir William the Brave said:
Will this work in Mount and Blade Vanilla.
No idea but try comparing the Warband codes with the Vanilla ones. If they match mostly then maybe it will work. I doubt that they are too different considering that recruiting seemingly works the same way in both games.
Can you test it for me please?
 
Sir William the Brave said:
GunFred said:
Sir William the Brave said:
Will this work in Mount and Blade Vanilla.
No idea but try comparing the Warband codes with the Vanilla ones. If they match mostly then maybe it will work. I doubt that they are too different considering that recruiting seemingly works the same way in both games.
Can you test it for me please?
Sorry, I have no Vanilla modding experience at all so you will have to test it yourself.
 
Sir William the Brave said:
Will this work in Mount and Blade Vanilla.

The best I could get without problems is that I can recruit only in towns- simple implement this code and change simple trigger:

  # 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),
    ]),

change red into this:
    (try_for_range, ":village_no", towns_begin, towns_end),
As for castles I tried but I could not get it to work without problems.
When I change simple trigger as I said above, recruitment menu dont appear in castle menu.
If I change it to "walled_centers_begin, walled centers_end" it gives me menu but when I recruit regulars and when I exit on strategic map I dont have souldiers in party and few more bugs.
If I use code as it is on first page, it gives menu, gives recruits it is all fine, but than village recruits appear in taverns instead of mercenary troops.
So, either you can recruit in towns only or use old code for recruit troops in towns and in castles for vanilla.
 
That's because there are slot overlaps between mercenaries (used in towns) and npc recruits (used in villages). By calling both scripts, the value of those slots are overwritten.
 
I have the same problem with regular recruits taking mercenaries place in taverns. I have been assuming that the red part below has been causing the problem but I do not have the coding knowledge to understand what is wrong or why you have to change that part to begin with. It would be cool if 'Somebody'(see what I did there? :lol:) could fix that part.  :roll:
# 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),
    ]),
 
I'm using the NMC and I did exactly as the tutorial instructed. I ran the build_module and everything worked fine except, after game_menus I get these to lines.

Error: Unable to find object:script_town_recruit_nobles_recruit
ERROR: Illegal Identifier:script_town_recruit_nobles_recruit

And then finishes the compiling normally. I went into the game just to test it. The "Recruit Nobles" shows up in castle and town menus but it's always just 2 of that factions highest tier units and when I click the recruit button, nothing happens (I don't get more troops, it doesn't change menu).

Now I'm guessing it's a problem in communcation between module_scripts and module_game_menus but, being new to modding, I don't know how to solve it. Can anyone help me please?
 
GunFred said:
Could you post the whole error build?

This? (Also, thanks for your help)

Getting Header Files .........
Getting ID Files .........
Getting Process Files .........
Start Processing...
______________________________

Initializing...
variables.txt not found. Creating new variables.txt file
Compiling all global variables...
variables.txt not found. Creating new variables.txt file
variable_uses.txt not found. Creating new variable_uses.txt file
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...
Error: Unable to find object:script_town_recruit_nobles_recruit
ERROR: Illegal Identifier:script_town_recruit_nobles_recruit
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
Exporting postfx_params...

All Finish ...
Cleaning up...
______________________________

Script processing has ended.
Press any key to exit. . .
 
My first guess is that the names of the red parts below does not match so double check that. If they do not match then the first recruit menu should not lead up to the actually recruiting. (If I am right that is, but I only have a very low understanding of WB coding myself.)

    ("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),
        ]),
(
    "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"),
      ]),
    ],
  ),
 
I checked it and they both match up (or at least there are the exact same as they are in your spoilers.)

I ran build_module again, got the same thing as before. In-game I had to wait 3 days for the changes again for some reason. When the changes did take effect, I got the same result. The "Recruit Nobles" option shows up in the town and castle menus at the top. I click on it and it brings me to the "2 troops volunteer to join you" (Always 2 by the way) screen with the "Recruit volunteers" and "Forget it" options.

If I click "Forget it", it brings me back to the town/castle menu but if I click "Recruit Volunteers", nothing happens.

The only difference this time was that the first town I tried (the one I started in) had brought up that "No one here seems willing to join you" screen
 
The 3 days wait can be removed by following the very first response to this thread and I recommend you use it. The number of troops should vary between settlements but if you go to the same settlement all the time then it may show 2 over and over again. As the problem seems to be the recruiting itself, the problem should be either that the recruit menu does not initiate the recruit script properly or the recruit script itself is incorrect or placed wrongly. I would offer to take a look at your codes but then it would have to be quick as I will leave for a few days tomorrow. Also, I recommend that you read all 4 pages unless you already have, as there may be hidden solutions and stuff there.
 
I removed the 3 day waiting and that's worked. I checked the code but I simply did a copy and paste job so there hasn't been any errors. In my limited modding experience, the only thing I could think of was that I had put it in the wrong place or inside a bracket I should have but I moved the first code in game_menus around and checked it and I can't see anything. I looked around this thread. The only thing I could see related to me was the "recruit_normales" problem people were having but I searched "recruit_normales" in every file and it's not there. This is it with the surrounding text for the first game_menus, but I can't see any wrong

    [
      ("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"),
        ]),

      ("town_castle",[
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
          (eq,"$entry_to_town_forbidden",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 castle{s1}.",
 
That one seems correct although mine is slightly different as I recruit different troops in castles and towns as done in part 2 of the tutorial.

If I understood the problem correctly then "mnu_recruit_nobles" should be the problem and you should check if "recruit_nobles" is placed correctly. Feel free to post that code but be quick if you want to.
 
GunFred said:
That one seems correct although mine is slightly different as I recruit different troops in castles and towns as done in part 2 of the tutorial.

If I understood the problem correctly then "mnu_recruit_nobles" should be the problem and you should check if "recruit_nobles" is placed correctly. Feel free to post that code but be quick if you want to.

Well I was doing some other modding and I got a flash of inspiration. "Can't find object"? You think I'd never modded a game before. I went to module_scripts and found that for some reason, "town_castle_recruit_nobles_recruit" was actually "town_recruit_nobles_recruit". So I changed that and compiled.

This time, I got no error in the compiler. In-game when I click on the "Recruit Nobles" it brings me to the "These troops volunteer....." screen as before. However, now when I click "Recruit Volunteers" it sends me back to the main town menu without recruiting the troops instead of before, where it just did nothing. Hopefully that's progress but I just have to find out why it doesn't recruit the troops now. Here's the "recruit_nobles" code

  (
    "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_castle_recruit_nobles_recruit"),
                     
  (jump_to_menu, "mnu_town"),
      ]),
   
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

I put it after the last piece of code in module_game_menus, but before the final ']'
 
It seems perfectly fine and the only remaining issue is that you do not get any actual recruits right? I guess this means that we can safely say that games_menu codes work as intended and the scripts are the ones not working properly.

If you have not already, start with checking that Script 1 and 2 in the tutorial are placed correctly. Also, tripple check that the script names that are called upon in game_menus fit the actual scripts.

 
GunFred said:
It seems perfectly fine and the only remaining issue is that you do not get any actual recruits right? I guess this means that we can safely say that games_menu codes work as intended and the scripts are the ones not working properly.

If you have not already, start with checking that Script 1 and 2 in the tutorial are placed correctly. Also, tripple check that the script names that are called upon in game_menus fit the actual scripts.

Ok so I did a bit of other modding and when I was done I sat down to play the game and, randomly, it just started working. I just recruited a Swadian Knight by pure accident.

Sorry for wasting your time but thanks a million for all your help.
 
First of all thanks for the tutorial.

After about 5 tries everything worked for me. (Compiling, and being able to recruit from towns and castles.)

But then I encountered a problem.
I can only recruit the normal recruits from towns and castles.

Even though when I go to a castle it tells me that I recruit "Vaegir Knights" I only get vaegir recruits.


I changed the troop trees in my mod, but I didn't delete any of the old native troops.
Does anybody know, if the problem are my troop trees or do I need to change something in the recruitment scripts?
 
Back
Top Bottom