Recruit your custom troops in villages

Users who are viewing this thread

I found a topic a bit similar to this, but I was suggested not to post there, but create a new one. But let's get to the point.

I switch from TXT files editing to module system programming and I need help.

I made my custom troops (merged into a tree) and now I want to change recruitment behavior, so the player can recruit those custom troops each time he starts recruitment in village instead of the village's faction's troops.

Let's say there is a tree of troops:
trp_custom1 for tier 1
trp_custom2 for tier 2
and so on.

Custom troops are marked as player_supporters_faction and they are NOT supposed to be recruited by lords or spawned for anyone except the player (but they can be given to a vassal)

Anyone could shed some light here? (as I'm new to module system, please do not post hints, just a code ready to be pasted into my .py file)

Thanks in advance.
 
Ok, everything is now tested and compiled.
There is still the bug mentioned above - if you recruit from the village you own, you get recruits depending on their original faction, as if there was no tweak.
I'm working on it, but my knowledge of python is poor, so do not expect to much.


Here's the code. The only thing you have to do is to open scripts.txt and paste it in proper place.

Just find this:
Code:
update_volunteer_troops_in_village -1
And this:
Code:
update_npc_volunteer_troops_in_village -1
And substitute all lines between them with:
41 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 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
(this code should have one space in the beginning and one in the end - last space doesn't show up)

Number marked green is troop's ID's number. By default I set it to the position right after last troop in troops.txt, so if you added a troop in the end of file, it will be recruited each time you use recruitment option in any village. Others (lords) will recruit as in normal version.
If you want other troop to be recruited, you can change this value. How?
Troop's ID is calculated like this:
ID=360287970189639680+troop's_position_in_file
(Note that we start counting them from 0, so trp_player is 0, trp_multiplayer_profile_troop_male is 1 and so on.)
Hint: In the second line of troops.txt there is a number which is number_of_all_troops+1 (unless you added some and didn't update it).
You can count your troops manually by yourself, or use M&B Warband Mod Tools (it displays troops with their numbers).

For your convinience here are the ID numbers for some troops:
360287970189639680 - 0 - trp_player (do not recruit yourself for God's sake!!!)
360287970189639724 - 44 - trp_swadian_knight (Swadian Knight)
360287970189639780 - 100 - trp_sarranid_footman (Sarranid Footman)
360287970189640609 - 929 - last position in file (trp_relative_of_merchants_end)
360287970189640610 - 930 - position of your troop if you add one in the end of file (and increment second line of file by 1)

All troops that there is sense to recruit are from between 360287970189639705 (25 - Farmer) and 360287970189639811 (131 - Sword Sister). This includes all factions' troops, mercenaries, peasant troops, slavers, bandits and more.

Be careful, as ID's number is too long to fit in Windows' Calculator (it's cut by 2 last positions). Calculate just 5 last positions, that's enough.

One more thing - TweakMB is super cautious while checking the files, so options that are set in "update_volunteer_troops_in_village" script will be grayed out. But you can still use those tweaks by setting them in non-modded Native and then comparing values and guessing on your own which numbers to change. It's quite easy after a while.
 
Back
Top Bottom