SP Tutorial Module System Recruit your custom troops in your own Kingdom

Currently Viewing (Users: 0, Guests: 1)

Topper

Regular
Best answers
0
Since some people have requested this, I decided to start a new topic to explain how to do it.

What it does
In Warband it is possible to create your own Kingdom. You may want to create custom troops and being able to recruit them from the villages that are part of your Kingdom. This has been tested on version 1.113.
To maintain a common behaviour with the villages of other factions, this tweaks will give you recruits based on the faction that owns the village in that moment (even this feature has been asked by many members in this forum) and not based on the original culture of the village.


The fast method
If you added your custom recruit manually in the module system or with a txt editor, chances are that it has been added at the end the other troops already present in Native. If that is the case, then it is sufficient to do the following.

Open scripts.txt, look for "update_volunteer_troops_in_village" and substitute the next line with this one:

43 23 2 1224979098644774912 1 521 3 1224979098644774913 1224979098644774912 26 521 3 1224979098644774914 1224979098644774912 19 522 3 1224979098644774915 1224979098644774914 41 2204 2 1224979098644774916 1224979098644774912 4 0 33 3 1224979098644774916 432345564227567631 432345564227567637 522 3 1224979098644774915 1224979098644774916 41 5 0 31 2 1224979098644774916 432345564227567630 2133 2 1224979098644774915 360287970189640610 3 0 2133 2 1224979098644774917 1 2123 3 1224979098644774918 1224979098644774913 10 6 3 1224979098644774919 0 1224979098644774918 2136 3 1224979098644774920 0 100 2147483678 2 1224979098644774920 10 2136 3 1224979098644774920 0 2 1561 3 1224979098644774921 1224979098644774915 1224979098644774920 4 0 2147483680 2 1224979098644774921 0 1561 3 1224979098644774921 1224979098644774915 0 3 0 32 2 1224979098644774921 0 2105 2 1224979098644774917 1 2133 2 1224979098644774915 1224979098644774921 3 0 2133 2 1224979098644774922 7 4 0 30 2 1224979098644774913 5 2133 2 1224979098644774922 1224979098644774913 2108 2 1224979098644774922 2 2105 2 1224979098644774922 10 5 0 2147483678 2 1224979098644774913 0 2133 2 1224979098644774922 0 3 0 2107 2 1224979098644774922 3 2120 3 1224979098644774923 2 1224979098644774917 2108 2 1224979098644774922 1224979098644774923 2136 3 1224979098644774924 0 1224979098644774922 501 3 1224979098644774912 92 1224979098644774915 501 3 1224979098644774912 93 1224979098644774924

Let 72 hours pass and you can enjoy your troops in your villages.
Remember, this only works if your unit is added at the bottom of all other units.


Further details
360287970189640610 is the ID of the unit: it is one more of the last unit in native. Every unit is assigned a unique ID by the game, which is sequential, starting from the first one. The last unit present in Native has ID 360287970189640609. If you added two troops and you want to recruit the second one, use this ID: 360287970189640611. I hope it makes sense.

In case you are interested, the code in the module system is this:
After line :
Code:
     (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
Insert: 
Code:
       # MOD begin
       (store_faction_of_party, ":center_faction", ":center_no"),
       (try_begin),
         (is_between, ":center_faction", "fac_kingdom_1", "fac_kingdoms_end"),
         (faction_get_slot, ":volunteer_troop", ":center_faction", slot_faction_tier_1_troop),
       (else_try),
         (eq, ":center_faction", "fac_player_supporters_faction"),
         (assign, ":volunteer_troop", "trp_topper_recruit"),
       (try_end),       
       # MOD end
   
Substitute "trp_topper_recruit" with the name you used for your own troop.

If you want everyone else to be able to recruit the same units from your villages, do the same for "update_npc_volunteer_troops_in_village". If you don't like to use the module system, go to scripts.txt, find "update_npc_volunteer_troops_in_village" and substitute the next line with this one:

31 23 2 1224979098644774912 1 521 3 1224979098644774913 1224979098644774912 19 522 3 1224979098644774914 1224979098644774913 41 2204 2 1224979098644774915 1224979098644774912 4 0 33 3 1224979098644774915 432345564227567631 432345564227567637 522 3 1224979098644774914 1224979098644774915 41 5 0 31 2 1224979098644774915 432345564227567630 2133 2 1224979098644774914 360287970189640610 3 0 2133 2 1224979098644774916 1 6 3 1224979098644774917 0 5 2136 3 1224979098644774918 0 100 2147483678 2 1224979098644774918 10 2136 3 1224979098644774918 0 2 1561 3 1224979098644774919 1224979098644774914 1224979098644774918 4 0 2147483680 2 1224979098644774919 0 1561 3 1224979098644774919 1224979098644774914 0 3 0 32 2 1224979098644774919 0 2105 2 1224979098644774916 1 2133 2 1224979098644774914 1224979098644774919 3 0 2133 2 1224979098644774920 12 2120 3 1224979098644774921 2 1224979098644774916 2108 2 1224979098644774920 1224979098644774921 2136 3 1224979098644774922 0 1224979098644774920 501 3 1224979098644774912 90 1224979098644774914 501 3 1224979098644774912 91 1224979098644774922

To know if your recruit has been added correctly for the tweak above to work, check troops.txt and see if it is after the entry for "trp_relative_of_merchants_end".

If, however, your recruit has not been added at the end, or you don't know how to do it, there are tutorials in the forum that can help you. I'll just briefly explain the steps.

In the module system, open module_troops.py find this:
Code:
  ["swadian_recruit","Swadian Recruit","Swadian Recruits",tf_guarantee_armor,0,0,fac_kingdom_1,
   [itm_scythe,itm_hatchet,itm_pickaxe,itm_club,itm_stones,itm_tab_shield_heater_a,itm_leather_cap,itm_felt_hat,itm_felt_hat,
    itm_shirt,itm_coarse_tunic,itm_leather_apron,itm_nomad_boots,itm_wrapping_boots],
   def_attrib|level(4),wp(60),knows_common,swadian_face_younger_1, swadian_face_middle_2],
Copy it and paste it way down in the file, after the entry of the last unit, that is:

Code:
  ["relative_of_merchants_end","relative_of_merchants_end","relative_of_merchants_end",tf_hero, 0,0, fac_commoners,[],def_attrib|level(2),wp(20),knows_inventory_management_10,0],
 
Then you modify it as you prefer, example:
Code:
  ["topper_recruit","Topper Recruit","Topper Recruits",tf_guarantee_armor,0,0,fac_player_supporters_faction,
   [itm_scythe,itm_hatchet,itm_pickaxe,itm_club,itm_stones,itm_tab_shield_heater_a,itm_leather_cap,itm_felt_hat,itm_felt_hat,
    itm_shirt,itm_coarse_tunic,itm_leather_apron,itm_nomad_boots,itm_wrapping_boots],
   def_attrib|level(4),wp(60),knows_common,swadian_face_younger_1, swadian_face_middle_2],
You set the attributes, the level, the skils, the item, etc...

You can also design an upgrade tree: add more units and make your recruit upgrade into the second one, the second into the third, and so on... I'll give you an example by adding one more unit (you can add as many as you want).

Take the previous code of the "Topper Recruit", copy it and paste it in the line below, then modify as you prefer. Example:
Code:
  ["topper_badass","Topper Badass","Topper Badasses",tf_guarantee_boots,0,0,fac_player_supporters_faction,
   [itm_battle_fork,itm_hide_boots],
   str_30|agi_30|level(1),wp(400),knows_common,swadian_face_younger_1, swadian_face_middle_2],
Then, at the very end of "module_troops.py" you add the following line:
Code:
upgrade(troops, "topper_recruit", "topper_badass")
 

dzorro

Knight at Arms
Best answers
0
So if i get this right, your lords or companion that has been converted to lords now also be able to recruit your units with this code ??
 

Topper

Regular
Best answers
0
dzorro said:
So if i get this right, your lords or companion that has been converted to lords now also be able to recruit your units with this code ??
Good question. :grin:
I haven't tested it and from the module system it seems like the way other lords get their units is not so straightforward. For now, until I do more testing, or until someone provides the answer, let's put it this way:
  • If you do not edit "update_npc_volunteer_troops_in_village" then you are sure nobody will recruit your units, apart from you.
  • If you edit it, it may be that other lords will be able to do it.
 

dzorro

Knight at Arms
Best answers
0
Well it will be cool if you start a new kingdom your new lords and companion all get the same new unit like you can. :mrgreen: Will have to try it.
 

Dibuk

Regular
Best answers
0
I tried to test this but it wont let me recruit from any village at all... I must have done something wrong, I'll try again.

Edit: This don't look exactly as your code it noticed but I'm pretty sure that's the right spot, no?

update_volunteer_troops_in_village -1
39 23 2 1224979098644774912 1 521 3 1224979098644774913 1224979098644774912 26 2204 2 1224979098644774914 1224979098644774912 4 0 31 2 1224979098644774914 432345564227567629 521 3 1224979098644774914 1224979098644774912 19 3 0 522 3 1224979098644774915 1224979098644774914 41 2133 2 1224979098644774916 1 2123 3 1224979098644774917 1224979098644774913 10 6 3 1224979098644774918 0 1224979098644774917 2136 3 1224979098644774919 0 100 2147483678 2 1224979098644774919 10 2136 3 1224979098644774919 0 2 1561 3 1224979098644774920 1224979098644774915 1224979098644774919 4 0 2147483680 2 1224979098644774920 0 1561 3 1224979098644774920 1224979098644774915 0 3 0 32 2 1224979098644774920 0 2105 2 1224979098644774916 1 2133 2 1224979098644774915 360287970189640612 3 0 2133 2 1224979098644774921 7 4 0 30 2 1224979098644774913 5 2133 2 1224979098644774921 1224979098644774913 2108 2 1224979098644774921 2 2105 2 1224979098644774921 12 5 0 2147483678 2 1224979098644774913 0 2133 2 1224979098644774921 0 3 0 2107 2 1224979098644774921 3 2120 3 1224979098644774922 2 1224979098644774916 2108 2 1224979098644774921 1224979098644774922 2136 3 1224979098644774923 0 1224979098644774921 501 3 1224979098644774912 92 1224979098644774915 501 3 1224979098644774912 93 1224979098644774923
 

Topper

Regular
Best answers
0
Dibuk said:
I tried to test this but it wont let me recruit from any village at all... I must have done something wrong, I'll try again.

Edit: This don't look exactly as your code it noticed but I'm pretty sure that's the right spot, no?
That is the right spot, but as you said, the code is different, so you cannot expect it to work. Try to paste my code and see if it works.
 

Dibuk

Regular
Best answers
0
Topper said:
Dibuk said:
I tried to test this but it wont let me recruit from any village at all... I must have done something wrong, I'll try again.

Edit: This don't look exactly as your code it noticed but I'm pretty sure that's the right spot, no?
That is the right spot, but as you said, the code is different, so you cannot expect it to work. Try to paste my code and see if it works.
I did, but it behaves exactly the same. I can't recruit from anyone at all with your code... Odd.
can you copy everything from "update_volunteer_troops_in_village" to just over "update_companion_candidates_in_taverns -1" and I'll paste that, and see what happends.

I do like your code a lot though, Just what this game needs!
 

Ruarz

Regular
Best answers
0
I get an "RGL ERROR" saying: "Unexpected End of File while reading file: Modules\Native\troops.txt". This occurs after the title screen and as soon as I try and load a savegame, or start a new game. Can anybody shed some light? :grin:
 

Topper

Regular
Best answers
0
Dibuk said:
I did, but it behaves exactly the same. I can't recruit from anyone at all with your code... Odd.
can you copy everything from "update_volunteer_troops_in_village" to just over "update_companion_candidates_in_taverns -1" and I'll paste that, and see what happends.

I do like your code a lot though, Just what this game needs!
Here:
update_volunteer_troops_in_village -1
43 23 2 1224979098644774912 1 521 3 1224979098644774913 1224979098644774912 26 521 3 1224979098644774914 1224979098644774912 19 522 3 1224979098644774915 1224979098644774914 41 2204 2 1224979098644774916 1224979098644774912 4 0 33 3 1224979098644774916 432345564227567631 432345564227567637 522 3 1224979098644774915 1224979098644774916 41 5 0 31 2 1224979098644774916 432345564227567630 2133 2 1224979098644774915 360287970189640610 3 0 2133 2 1224979098644774917 1 2123 3 1224979098644774918 1224979098644774913 10 6 3 1224979098644774919 0 1224979098644774918 2136 3 1224979098644774920 0 100 2147483678 2 1224979098644774920 10 2136 3 1224979098644774920 0 2 1561 3 1224979098644774921 1224979098644774915 1224979098644774920 4 0 2147483680 2 1224979098644774921 0 1561 3 1224979098644774921 1224979098644774915 0 3 0 32 2 1224979098644774921 0 2105 2 1224979098644774917 1 2133 2 1224979098644774915 1224979098644774921 3 0 2133 2 1224979098644774922 7 4 0 30 2 1224979098644774913 5 2133 2 1224979098644774922 1224979098644774913 2108 2 1224979098644774922 2 2105 2 1224979098644774922 10 5 0 2147483678 2 1224979098644774913 0 2133 2 1224979098644774922 0 3 0 2107 2 1224979098644774922 3 2120 3 1224979098644774923 2 1224979098644774917 2108 2 1224979098644774922 1224979098644774923 2136 3 1224979098644774924 0 1224979098644774922 501 3 1224979098644774912 92 1224979098644774915 501 3 1224979098644774912 93 1224979098644774924
update_npc_volunteer_troops_in_village -1
23 23 2 1224979098644774912 1 521 3 1224979098644774913 1224979098644774912 19 522 3 1224979098644774914 1224979098644774913 41 2133 2 1224979098644774915 1 6 3 1224979098644774916 0 5 2136 3 1224979098644774917 0 100 2147483678 2 1224979098644774917 10 2136 3 1224979098644774917 0 2 1561 3 1224979098644774918 1224979098644774914 1224979098644774917 4 0 2147483680 2 1224979098644774918 0 1561 3 1224979098644774918 1224979098644774914 0 3 0 32 2 1224979098644774918 0 2105 2 1224979098644774915 1 2133 2 1224979098644774914 1224979098644774918 3 0 2133 2 1224979098644774919 12 2120 3 1224979098644774920 2 1224979098644774915 2108 2 1224979098644774919 1224979098644774920 2136 3 1224979098644774921 0 1224979098644774919 501 3 1224979098644774912 90 1224979098644774914 501 3 1224979098644774912 91 1224979098644774921
update_companion_candidates_in_taverns -1

Are you using Native. Is your version 1.113?
 

Dibuk

Regular
Best answers
0
Topper said:
Dibuk said:
I did, but it behaves exactly the same. I can't recruit from anyone at all with your code... Odd.
can you copy everything from "update_volunteer_troops_in_village" to just over "update_companion_candidates_in_taverns -1" and I'll paste that, and see what happends.

I do like your code a lot though, Just what this game needs!
Here:

Are you using Native. Is your version 1.113?
Yes, but I have added troops (naturally), and yes.


EDIT: With the new paste you gave me it worked  :mrgreen: Thank you!
 

Lord Hamster

Regular
WB
Best answers
0
Topper said:
Dibuk said:
I did, but it behaves exactly the same. I can't recruit from anyone at all with your code... Odd.
can you copy everything from "update_volunteer_troops_in_village" to just over "update_companion_candidates_in_taverns -1" and I'll paste that, and see what happends.

I do like your code a lot though, Just what this game needs!
Here:
update_volunteer_troops_in_village -1
43 23 2 1224979098644774912 1 521 3 1224979098644774913 1224979098644774912 26 521 3 1224979098644774914 1224979098644774912 19 522 3 1224979098644774915 1224979098644774914 41 2204 2 1224979098644774916 1224979098644774912 4 0 33 3 1224979098644774916 432345564227567631 432345564227567637 522 3 1224979098644774915 1224979098644774916 41 5 0 31 2 1224979098644774916 432345564227567630 2133 2 1224979098644774915 360287970189640610 3 0 2133 2 1224979098644774917 1 2123 3 1224979098644774918 1224979098644774913 10 6 3 1224979098644774919 0 1224979098644774918 2136 3 1224979098644774920 0 100 2147483678 2 1224979098644774920 10 2136 3 1224979098644774920 0 2 1561 3 1224979098644774921 1224979098644774915 1224979098644774920 4 0 2147483680 2 1224979098644774921 0 1561 3 1224979098644774921 1224979098644774915 0 3 0 32 2 1224979098644774921 0 2105 2 1224979098644774917 1 2133 2 1224979098644774915 1224979098644774921 3 0 2133 2 1224979098644774922 7 4 0 30 2 1224979098644774913 5 2133 2 1224979098644774922 1224979098644774913 2108 2 1224979098644774922 2 2105 2 1224979098644774922 10 5 0 2147483678 2 1224979098644774913 0 2133 2 1224979098644774922 0 3 0 2107 2 1224979098644774922 3 2120 3 1224979098644774923 2 1224979098644774917 2108 2 1224979098644774922 1224979098644774923 2136 3 1224979098644774924 0 1224979098644774922 501 3 1224979098644774912 92 1224979098644774915 501 3 1224979098644774912 93 1224979098644774924
update_npc_volunteer_troops_in_village -1
23 23 2 1224979098644774912 1 521 3 1224979098644774913 1224979098644774912 19 522 3 1224979098644774914 1224979098644774913 41 2133 2 1224979098644774915 1 6 3 1224979098644774916 0 5 2136 3 1224979098644774917 0 100 2147483678 2 1224979098644774917 10 2136 3 1224979098644774917 0 2 1561 3 1224979098644774918 1224979098644774914 1224979098644774917 4 0 2147483680 2 1224979098644774918 0 1561 3 1224979098644774918 1224979098644774914 0 3 0 32 2 1224979098644774918 0 2105 2 1224979098644774915 1 2133 2 1224979098644774914 1224979098644774918 3 0 2133 2 1224979098644774919 12 2120 3 1224979098644774920 2 1224979098644774915 2108 2 1224979098644774919 1224979098644774920 2136 3 1224979098644774921 0 1224979098644774919 501 3 1224979098644774912 90 1224979098644774914 501 3 1224979098644774912 91 1224979098644774921
update_companion_candidates_in_taverns -1

Are you using Native. Is your version 1.113?
I'm going to test this out, but does this do anything else to the troop recruitment script? I ask because that section of the scripts file is now incompatible with TweakMB after I pasted this in.
 

Topper

Regular
Best answers
0
Lord Hamster said:
I'm going to test this out, but does this do anything else to the troop recruitment script? I ask because that section of the scripts file is now incompatible with TweakMB after I pasted this in.
I forgot to completely explain what the script does: I fixed the main post now.
The script will make you get recruits based on the faction that owns the village in that moment. So if the village is under your own kingdom you recruit you custom troops. If it is owned by a Khergit lord, you will recruit Khergit troops. And so on...

This is what has changed, the rest of the recruitment is as the original.
 

Topper

Regular
Best answers
0
Ruarz said:
I get an "RGL ERROR" saying: "Unexpected End of File while reading file: Modules\Native\troops.txt". This occurs after the title screen and as soon as I try and load a savegame, or start a new game. Can anybody shed some light? :grin:
You have messed up the troops file. Since I don't know how you changed it, I cannot help. Be sure that you have added the troops correctly. Use a modding tool if you are not confident in coding.

One thing can comes to my mind is this: if you add troops directly in the troops.txt file by copy and paste, remember to update accordingly the number at the beginning of the file, on the second line. That number is 930 in the original game. For example, if you add 3 troops you have to ensure that the number is 933.
 

Ruarz

Regular
Best answers
0
Understood, but I have use M&B Warband TXT Tools and checked the file over multiple times to make sure nothing is wrong with it, and it appears to be fine. Its just a little annoying after spending two hours making a faction. Is there any way I get get up her for you to have a look. No worries if you can't. :grin:
 

kirinelf

Sergeant
WB
Best answers
0
That's strange. I used Morgh's tool for mine as well and it worked no problems.

Thanks for taking the time to do this, Topper! It's really fun running around with your own troops, isn't it? xD

Rangers! Bring down the angel in the sky! >=D
 

Ruarz

Regular
Best answers
0
I was using an older version of Morgh's tool, for 1.05 or something. I now have my faction just about up and running :grin: thanks Topper for the code :razz:
 

LOLLord Ben

Recruit
Best answers
0
Alright, just downloaded Module Sys 1.113 and did this:

Under
Code:
  (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
insert:
Code:
	 # MOD begin
       (store_faction_of_party, ":center_faction", ":center_no"),
       (try_begin),
         (is_between, ":center_faction", "fac_kingdom_1", "fac_kingdoms_end"),
         (faction_get_slot, ":volunteer_troop", ":center_faction", slot_faction_tier_1_troop),
         (assign, ":volunteer_troop", "trp_swadian_sergeant"),
       (try_end),       
	 # MOD end
That gives ya always your troop, in my case it is "trp_swadian_sergeant", but you can try all other troops to put behind "assign", WOOT! Thx for the script Topper, now with 1.113 we can go hog wild lmfao. :mrgreen:
 

VianeyLover

Sergeant at Arms
Best answers
0
LOLLord Ben said:
Alright, just downloaded Module Sys 1.113 and did this:
God ! where did you got it ??  :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock:

I have been looking for it since ages

Could you please post a link or just tell me where the hell it is ??

Thank you !  :cool:

Forget it...

I just went to the main page & there it was !!! :oops: :oops: :oops: :oops: :oops: :oops:

:lol: :lol: :lol: :lol: :lol: :lol:
 

kuriherbaarius

Regular
Best answers
0
  Very cool, thanks a lot, Topper!

  Can you hint which values in your compiled code corresponding to values, which are used to determine number of recruits? I mean this part from module system
     
Code:
(assign, ":upper_limit", 7),
       (try_begin),
         (ge, ":player_relation", 5),
         (assign, ":upper_limit", ":player_relation"),
         (val_div, ":upper_limit", 2),
         (val_add, ":upper_limit", 10),
       (else_try),
         (lt, ":player_relation", 0),
         (assign, ":upper_limit", 0),
       (try_end),
is it possible to tweak recruitable troops values in your compiled txt without using module system?