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

Users who are viewing this thread

this is implemented and seems to be working fine....  However, there is always a standard faction troop in the taverns now instead of the mercenary types.

If you want the mercenaries in the tavern to remain, but have the town's menu option to still give you faction troops, what would be the fix?



 
Hello

Let me start by saying thanks s posting this tut, i was able to adapt it to recruit squires and men at arms in castles and villagers in towns.

BUT

i must also say that it is probably the worst explained tutorial i have ever read, seriously needs to be reconstructed, if i was a noob there is no way in hell i could follow it.

But again, no offence intended, thanks for posting it, all the data is there just to restructured.

thanks again, was just what i was looking for
 
Yes! I finally got this to work thanks to laszers and Muffin Raider. I can confirm that this works for Warband 1.154/Diplomacy 4.2.  :grin:

If someone wants my help then you can ask for it here or by sending me an email.
 
A few of my working codes. The red text parts might be note worthy and I might have made some slight changes. If something is confusing then compare to the older posts and let me know if there are any questions or something is wrong with my codes.

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

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

  ("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_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"),
      ]),
    ],
  ),
  (
      "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 would appreciate if someone could show how you can tweak the codes so that you have to be part of a town's/castle's faction to be able to recruit from it.
 
I must have python to instal this mod my my scripts.txt look like this

game_start -1
670 502 3 432345564227567630 21 2 2133 2 144115188075856755 200 500 3 360287970189639680 2 2 2136 3 1224979098644774912 648518346341351631 648518346341351636 1623 3 648518346341351424 1224979098644774912 3 2322 2 5 360287970189639680 1669 2 648518346341351424 5 1 1 936748722493063291 2133 2 144115188075856756 -1 6 3 1224979098644774913 0 360287970189640143 1073741855 2 1224979098644774913 360287970189639680 33 3 1224979098644774913 360287970189639874 360287970189640143 500 3 1224979098644774913 31 -1 500 3 1224979098644774913 32 -1 500 3 1224979098644774913 33 -1 500 3 1224979098644774913 30 -1 500 3 1224979098644774913 34 -1 500 3 1224979098644774913 8 -1 500 3 1224979098644774913 38 -1 500 3 1224979098644774913 154 -1 2136 3 1224979098644774914 0 10000 500 3 1224979098644774913 48 1224979098644774914 500 3 1224979098644774913 49 1224979098644774914 3 0 2133 2 144115188075856757 0 1 1 936748722493063217 1 1 936748722493063215 1 1 936748722493063212 1 1 936748722493063585 2133 2 144115188075856758 0 6 3 1224979098644774915 432345564227567630 432345564227567637 2136 3 1224979098644774916 0 312 2107 2 1224979098644774916 -1 502 3 1224979098644774915 94 1224979098644774916 3 0 2121 3 1224979098644774917 648518346341351467 648518346341351445 2133 2 1224979098644774918 1224979098644774917 6 3 1224979098644774919 0 1224979098644774917 500 3 360287970189639685 1224979098644774919 -1 3 0 21
 
Somewhat new to this, first I would like to say thanks for this tutorial. I wont be putting this in but i will be using some of it in a different way. My question is does this restrict the recruitment to only showing up after the player has a certain relation with the town ( I believe it is set to 5 currently if im reading it right) if so how can this be changed to only showing up after you have a certain relation with a specific faction? (I don't mean the same faction as the town just a single specific faction ie: fac_kingdom_1) any help greatly appreciated!
 
sirscott said:
Somewhat new to this, first I would like to say thanks for this tutorial. I wont be putting this in but i will be using some of it in a different way. My question is does this restrict the recruitment to only showing up after the player has a certain relation with the town ( I believe it is set to 5 currently if im reading it right) if so how can this be changed to only showing up after you have a certain relation with a specific faction? (I don't mean the same faction as the town just a single specific faction ie: fac_kingdom_1) any help greatly appreciated!
The script as it is does not require any relations with a faction but I would bet that a decent script modder could easily make a certain relationship necessary for recruiting troops. If you do find a way to make relation needed, please let me know as I would very much like that for my mod.
 
Posted by: sirscott
« on: Today at 05:59:57 AM » Insert Quote
...if so how can this be changed to only showing up after you have a certain relation with a specific faction? (I don't mean the same faction as the town just a single specific faction ie: fac_kingdom_1) any help greatly appreciated!


What would be more useful is checking to make sure you have a certain relation with the towns faction before u can recruit. Not quite sure where I was going with a specific faction lol.
 
Has anyone been able to explain this without using the module system...always seemed to botch things when trying to use it...liked that '(?)Mage's manual implementations from the early M&B days...whatever was wrong with expplaining things that way?
 
If you are making your own mod you should probably use the MS anyway and I cannot imagine how to do it without it. If you are just adding this to another mod I doubt it is worth the effort unless it turns out to be really simple.
 
I've properly installed this into my mod, but I want the troops that are recruited to be my own "noble recruits".  How do I change what type of troop is recruited?

Also, I would like to change where the option is available at.  Having it be available via seneschal, instead of in the primary town/castle menu.
 
Vades said:
I've properly installed this into my mod, but I want the troops that are recruited to be my own "noble recruits".  How do I change what type of troop is recruited?

Also, I would like to change where the option is available at.  Having it be available via seneschal, instead of in the primary town/castle menu.
In the new codes you have to change tier_# to match your desired recruit.

You also have to find the script below and assign your recruit as a tier_#

      (faction_set_slot, "fac_culture_1",  slot_faction_tier_1_troop, "trp_swadian_villager"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_2_troop, "trp_swadian_townsman"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_3_troop, "trp_swadian_nobleman"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_4_troop, "trp_swadian_priest"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_5_troop, "trp_swadian_paladin"),

tier_1 = swadian_villager is the regular village recruit.
tier_2 = swadian_townsman is a new town recruit.
tier_3 = swadian_nobleman is a new castle recruit.
tier_4 = swadian_priest is a secondary town recruit.
tier_5 = swadian_paladin is a secondary castle recruit.

Example:      (faction_set_slot, "fac_culture_1",  slot_faction_tier_1_troop, "trp_vades_noble_recruit"),


About the seneschal thing, I have not done it myself but try finding the part of the codes which places the recruiting option in a town/castle menu and move it to the seneschal's main conversation menu. It may not be that simple but you could always try.
 
After some tinkering I got it to give the unit I wanted, I was getting the Swabian messenger for some reason.

I search game menus for the seneschal and was unable to locate it. Under what module file do you think I should try to place the information in?
 
Vades said:
After some tinkering I got it to give the unit I wanted, I was getting the Swabian messenger for some reason.

I search game menus for the seneschal and was unable to locate it. Under what module file do you think I should try to place the information in?
module_dialogs got the conversation with the seneschal and somehow you have to add a conversation option where you can get recruits. I suspect that would require completely new or heavily modified codes rather than the ones in this thread. A decent modder might be able to create a simple script that simply trades money for a recruit in a dialog but I doubt I could help with that. Are you sure you can not be satisfied with traditional recruiting through a menu in a fief?
 
Unfortunately no, I'm too ocd and I know what I want the system to be like.  I'd like to try and emulate Prophesy of Pendor's knightly order system, but I don't know where to find the information to accomplish that.

This is by far the closest thing I have found to that system.

Thanks for the info again, I appreciate you letting me pick your brain.
 
Back
Top Bottom