Author Topic: [Tutorial] How to make troops recruitable from castle/towns.  (Read 4428 times)

0 Members and 1 Guest are viewing this topic.

laszers

  • Veteran
  • *
    • View Profile
  • Faction: Nord
  • M&BWBWF&S
[Tutorial] How to make troops recruitable from castle/towns.
« on: November 08, 2011, 04:27:30 AM »
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
(click to show/hide)

below or above this
 
(click to show/hide)
just search it

scripts 2;
place this code
(click to show/hide)

below or above this
(click to show/hide)

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
(click to show/hide)

past this over the existing, script_update_mercenary_units_of_towns

next is one of the most confusing.

module Game menu's 1;
(click to show/hide)
put below "go to lords hall" in castle_castle menu, just search it.

(click to show/hide)

module game Menu's 2;

 
(click to show/hide)

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,
(click to show/hide)
     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.

(click to show/hide)
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.

(click to show/hide)
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.
(click to show/hide)
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.
(click to show/hide)
you can place this code below the noble.


Now for the last game menus.
(click to show/hide)


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.
« Last Edit: December 13, 2011, 06:19:42 PM by laszers »

Ritter Dummbatz

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Khergit
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #1 on: November 08, 2011, 11:28:01 PM »
To get rid of 3 days of waiting


Code: [Select]
(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.

laszers

  • Veteran
  • *
    • View Profile
  • Faction: Nord
  • M&BWBWF&S
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #2 on: November 09, 2011, 02:25:57 AM »
was the tutorial clear enough for you ritter?

Ritter Dummbatz

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Khergit
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #3 on: November 10, 2011, 04:01:05 AM »
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.

ImThatGuy

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #4 on: November 21, 2011, 04:53:25 PM »
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.
« Last Edit: November 21, 2011, 05:41:24 PM by ImThatGuy »

laszers

  • Veteran
  • *
    • View Profile
  • Faction: Nord
  • M&BWBWF&S
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #5 on: November 22, 2011, 03:44:12 AM »
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.

Sef OK b

  • Squire
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #6 on: November 24, 2011, 03:56:39 PM »
Ah thanks for this  :D 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?

Sef OK b

  • Squire
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #7 on: November 25, 2011, 03:54:52 PM »
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
(click to show/hide)


Now here is the bit you put at the end
(click to show/hide)

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?

SKY6A

  • Veteran
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #8 on: November 27, 2011, 04:41:37 AM »
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: [Select]
    [
      ("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!
« Last Edit: November 28, 2011, 06:11:18 AM by SKY6A »

SKY6A

  • Veteran
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #9 on: November 28, 2011, 06:14:37 AM »
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!

Seek n Destroy

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: SnD
  • WBWF&S
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #10 on: December 08, 2011, 04:24:15 PM »
Exactly what I was looking for! I really hope you will add the separate troop trees bit
Thanks for the tutorial
(click to show/hide)

celestialred

  • Knight at Arms
  • *
  • At night we're conspiring by candlelight
    • View Profile
    • My Facebook Profile
  • Faction: Vaegir
  • M&BWBWF&SNW
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #11 on: December 26, 2011, 10:15:55 PM »
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.
(click to show/hide)

The called scripts from module_scripts.py
(click to show/hide)

From module_game_menus.py
(click to show/hide)

At the end of module_game_menus.py
(click to show/hide)

My build_module.bat is this
(click to show/hide)

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

« Last Edit: December 26, 2011, 11:14:26 PM by celestialred »

celestialred

  • Knight at Arms
  • *
  • At night we're conspiring by candlelight
    • View Profile
    • My Facebook Profile
  • Faction: Vaegir
  • M&BWBWF&SNW
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #12 on: December 26, 2011, 11:15:39 PM »
I think discovered the source of the error, but I'm still not getting any option to recruit nobles or volunteers.
(click to show/hide)

Did I put something in wrong?

Thanks again,

CR

laszers

  • Veteran
  • *
    • View Profile
  • Faction: Nord
  • M&BWBWF&S
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #13 on: December 27, 2011, 05:41:53 AM »
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.

celestialred

  • Knight at Arms
  • *
  • At night we're conspiring by candlelight
    • View Profile
    • My Facebook Profile
  • Faction: Vaegir
  • M&BWBWF&SNW
Re: [Tutorial] How to make troops recruitable from castle/towns.
« Reply #14 on: December 27, 2011, 05:52:19 AM »
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 :)

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

Thanks :)

CR