Recruiting different Troops for each Town

Users who are viewing this thread

MarcosPZero

Regular
So, I wanted to know how can I recruit a different troop in each Town. I know it's possible cause I saw it in some mods before. I know of this code that allows the player to recruit Troops in Town :

https://forums.taleworlds.com/index.php?threads/recruit-in-towns.359247/

It's possible to alterate it so instead of recruiting a generic troop in towns depending on the faction I could recruit a diferent troop for each Town not depending of the faction ? or to do that I gonna need a completely different code ?
 
Solution
Are you using the code linked in the OP, by DarkNord? If so, it's an easy change. Something like this should work:


Python:
("recruit_nobles",
        [(troop_get_slot,"$player_noble_renown","trp_player",slot_troop_renown),
         (party_get_free_companions_capacity, "$player_nobles_capacity", "p_main_party"),
        # (store_faction_of_party,"$nobles_faction","$current_town"), #tells in which faction you are, but for party based recruitment, you don't need it; if you want to combine the two methods, you will need it   
         (try_begin), #begins assigning nobles to variables determined by faction
          # (eq,"$nobles_faction",fac_kingdom_1), #NOT needed for a party based check
           (eq,"$current_town","p_town_1")...
@Eärendil Ardamírë, Ok, thanks, but I am not knowledgeable of mount and blade variables, so when you say I should make a check for the town I understand that, but that check should be writen like what? I imagine that would be like : party_get_something or store_something
Code:
("recruit_nobles",
        [(troop_get_slot,"$player_noble_renown","trp_player",slot_troop_renown),
         (party_get_free_companions_capacity, "$player_nobles_capacity", "p_main_party"),
         (store_faction_of_party,"$nobles_faction","$current_town"), #tells in which faction you are -replace it with something else- 
        -or put that check here-
         (try_begin), #begins assigning nobles to variables determined by faction
           (eq,"$nobles_faction",fac_kingdom_1), replace this "fac_kindom_1" with "p_town_1" right?
           (assign,"$nobles","trp_swadian_man_at_arms"), #you can change trp_swadian_man_at_arms,trp_vaegir_horseman...with wahtever you want.
         (else_try),
Well, thats is what I was thinking of doing. I am right ?
 
Last edited by a moderator:
Upvote 0
If you want to create new scripts and mechanics you need to gather knowledge at how to read MaBL, our Warband coding syntax. You can find an introduction into the syntax here:
and a documentation of the operations here:

Since there might be an easier way to achieve what you want than editing that OSP, I am going to ping @Antonis since he might have a solution at hand for you, he worked already with regional recruitment before. So take a look at the stuff I linked and wait for a response of him ^^
 
Upvote 0
i-have-been-summoned.jpg


Ok, there are a lot of ways to go about implementing this feature. Primarily, what Earendil said is true. You need a fairly good grasp of the M&B module system.
Now, it depends on what you want to do. If you want to do the basic recruitment thingie with different troops per faction, then I would advise agains doing that sort of complicated thing, with try ends etc. What I did (again, just for that simple thing), is make a constant for noble troops, which I store the noble troops for each faction, in the scripts, in that block:

Python:
      (faction_set_slot, "fac_culture_6", slot_faction_tier_1_troop, "trp_sarranid_recruit"),
      (faction_set_slot, "fac_culture_6", slot_faction_tier_2_troop, "trp_sarranid_footman"),
      (faction_set_slot, "fac_culture_6", slot_faction_tier_3_troop, "trp_sarranid_archer"),
      (faction_set_slot, "fac_culture_6", slot_faction_tier_4_troop, "trp_sarranid_horseman"),
      (faction_set_slot, "fac_culture_6", slot_faction_tier_5_troop, "trp_sarranid_mamluke"),
      (faction_set_slot, "fac_culture_6", slot_faction_tier_noble_troop, "trp_your_noble_troop"),

Of course, for each faction. Then, in the recruitment script for the noble troops or your own script (I kinda did my own thing, based on native vilage recruitment, but converted it to use with towns, works pretty well) you just use the constant.

That's way more words than it needs, really. :grin:
 
Upvote 0
@Antonis, Thank you, but that's not what I was aiming for. What I really was talking about was Town recruitment in a way that every Town has their own special troop that can be recruited, which means it does not depend on the faction the town belongs to. but the Town itself. Like for example : in Sargoth you can recruit Sargoth warriors, in Rivacheg you can recruit Rivacheg warriors,...So faction don't really has something to do with it. Hope I managed to explain it in a better way.
 
Upvote 0
Basically like the villages in Native, yes? The recruits are always the same, no matter which faction controlls them.
Yes, in that way you are right. But from what I understood, what Antonis did was create a new troop that will be in every town of that faction. This is not what I'm aiming for, which is every Town offers their unique troops.

That's why I thought on the code of the Noble Troops OSP could work by simple changing the fac_kingdom_1 with a party code like p_town_1, but to do that I need to replace the faction check for the town check and assign a troop according to that, like you said, But I don't know how to do that.
 
Upvote 0
Well, yeah, ok, a bit of a misunderstanding. But you are right. Instead of checking the faction ownership, you can just check if $current_town is p_town_1 etc. and have one (or more) troop for each town and even castle. It is up to you. The way I described is indeed aimed at faction checks, but with just changing the check, you can convert it to anything you want.
 
Upvote 0
@Antonis Exactly, so how is going to be the new code ? What line do I need to rewrite to make it work?

I imagine that is going to be this one :
(store_faction_of_party,"$nobles_faction","$current_town"),
but I don't know if this is the only one, because I guess it won't be that simple.
 
Upvote 0
Are you using the code linked in the OP, by DarkNord? If so, it's an easy change. Something like this should work:


Python:
("recruit_nobles",
        [(troop_get_slot,"$player_noble_renown","trp_player",slot_troop_renown),
         (party_get_free_companions_capacity, "$player_nobles_capacity", "p_main_party"),
        # (store_faction_of_party,"$nobles_faction","$current_town"), #tells in which faction you are, but for party based recruitment, you don't need it; if you want to combine the two methods, you will need it   
         (try_begin), #begins assigning nobles to variables determined by faction
          # (eq,"$nobles_faction",fac_kingdom_1), #NOT needed for a party based check
           (eq,"$current_town","p_town_1"),
           (assign,"$nobles","trp_swadian_man_at_arms"), #you can change trp_swadian_man_at_arms,trp_vaegir_horseman...with wahtever you want.
         (else_try),
           (eq,"$current_town","p_town_2"),
           (assign,"$nobles","trp_another_troop"),
         (else_try),
           (eq,"$current_town","p_town_3"),
           (assign,"$nobles", "trp_and_another_troop"),
        
         etc.
 
Upvote 0
Solution
Back
Top Bottom