SP Tutorial Module System How to Add New Troops

Users who are viewing this thread

cwr

This tutorial is for beginners who wish to learn how to make new troops using the module system.

Here is a very good tutorial on how to set up to module system, if you haven't already.


Start with module_troops.py, and let's start by looking at the code for farmers:
Code:
  ["farmer","Farmer","Farmers",tf_guarantee_armor,no_scene,reserved,fac_commoners,
   [itm_cleaver,itm_knife,itm_pitch_fork,itm_sickle,itm_club,itm_stones,itm_leather_cap,itm_felt_hat,itm_felt_hat,itm_linen_tunic,itm_coarse_tunic,itm_nomad_boots,itm_wrapping_boots],
   def_attrib|level(4),wp(60),knows_common,man_face_middle_1, man_face_old_2],
 
Now its time for a tuple examination:

*farmer = troop ID: Troop ID is used for referencing the troop in other files. So if you want create a new party (more on that later) that has farmers in it, the game looks to the troop ID to see what troop your talking about.

*Farmer = Troop Name: This simply the name that will appear in-game.

*Farmers = Plural Troop Name: This is the name that appears when there's multiple of that troop.

*tf_guarantee_armor = Troop Flag: Guarantees that the troop will wear body armor. Below is a list of helpful starter troop flags (a full list can be found in header_troops).
tf_male = Self Explanatory
tf_female = Self Explanatory
tf_undead = Would not recommend using: Been known to cause crashes
tf_hero = Marks the troop as special a special NPC (non-playable-character). Health will shown as a percentage instead of simply showing as wounded or not wounded (e.g companions and lords)
tf_allways_fall_dead = Cannot be knocked unconscious, will always be killed
tf_mounted = Will not slow down world party map movement speed
tf_randomize_face = Randomizes faces at the beginning of the game
tf_guarantee_boots = Self Explanatory
tf_guarantee_armor = Self Explanatory
tf_guarantee_helmet = Self Explanatory
tf_guarantee_gloves = Self Explanatory
tf_guarantee_horse = Self Explanatory
tf_guarantee_shield = Self Explanatory
tf_guarantee_ranged = Guarantees archers and crossbowmen their respective ranged weapons
tf_unmoveable_in_party_window = Can't be placed in garrisons

*no_scene = Only used for NPCs: This troop will not appear in a scene unless specifically dictated by scripts or a mission template.

*reserved = Not used: Don't worry about it

*fac_commoners = The Troops Faction: Used for determining what faction the troop will appear in. (Check Module_Factions for a list of factions)

*[itm_blablabla] = Troop Inventory: Used for determining what items will be used on the troop. It is selected randomly but adding a troop flag will guarantee a troop a particular item (adding the same item multiple times will increase the chance of the troop receiving that item). Its recommended that you work with module_items to dress your soldiers.

*str_5|agi_5|int_5|cha_5 = Custom Attributes: This tuple is not used on the farmer but is essential for creating your own troops, its fairly straight forward. The number goes from a minimum of 4 to a maximum of 30. Below explains what each attribute does.
str = Strength: Each point of strength gives one hitpoint.
agi = Agility: Each point of agility increases weapon speed by 0.5 percent
int = Intelligence: Each point of intelligence gives one extra skill point. Not necessary for regular soldiers.
cha = Charisma: Each point of charisma allows you to command one extra troop. Not necessary for regular soldiers.

*def_attrib = Preassigned Attributes: in this case str_7 | agi_5 | int_4 | cha_4

*level(4) = Troop level: one of three major factors that determines advantage in autoresolve (every battle that your not a part of).

*wp(60) = Weapon Proficiency: Weapon proficiency determines weapon speed and damage for melee weapons and accuracy for ranged weapons. wp(60) means that all weapons proficiencies will be approximately 60.
Or if you want a more precise control of weapon proficiencies use this
wpex(60,59,58,57,56,55,54)
One Handed Equals (60)
Two Handed Equals (59)
Polearms Equals (5:cool:
Archery Equals (57)
Crossbows Equals (56)
Throwing Equals (55)

*knows_common = Preassigned Skills: In this case knows_riding_1|knows_trade_2|knows_inventory_management_2|knows_prisoner_management_1|knows_leadership_1
You can also assign your own skills like this. Type knows_ironflesh_4 and modify the skill that you want and the desired strength of skill on a scale of 1 to 10.

man_face_middle_1, man_face_old_2 = Premade face codes: below is a full list of premade face codes. If put in two faces the game will randomly choose between them.
swadian_face_younger_1 = 0x0000000000000001124000000020000000000000001c00800000000000000000
swadian_face_young_1  = 0x0000000400000001124000000020000000000000001c00800000000000000000
swadian_face_middle_1  = 0x0000000800000001124000000020000000000000001c00800000000000000000
swadian_face_old_1    = 0x0000000d00000001124000000020000000000000001c00800000000000000000
swadian_face_older_1  = 0x0000000fc0000001124000000020000000000000001c00800000000000000000

swadian_face_younger_2 = 0x00000000000062c76ddcdf7feefbffff00000000001efdbc0000000000000000
swadian_face_young_2  = 0x00000003c00062c76ddcdf7feefbffff00000000001efdbc0000000000000000
swadian_face_middle_2  = 0x00000007c00062c76ddcdf7feefbffff00000000001efdbc0000000000000000
swadian_face_old_2    = 0x0000000bc00062c76ddcdf7feefbffff00000000001efdbc0000000000000000
swadian_face_older_2  = 0x0000000fc00062c76ddcdf7feefbffff00000000001efdbc0000000000000000

vaegir_face_younger_1 = 0x0000000000000001124000000020000000000000001c00800000000000000000
vaegir_face_young_1  = 0x0000000400000001124000000020000000000000001c00800000000000000000
vaegir_face_middle_1  = 0x0000000800000001124000000020000000000000001c00800000000000000000
vaegir_face_old_1    = 0x0000000d00000001124000000020000000000000001c00800000000000000000
vaegir_face_older_1  = 0x0000000fc0000001124000000020000000000000001c00800000000000000000

vaegir_face_younger_2 = 0x000000003f00230c4deeffffffffffff00000000001efff90000000000000000
vaegir_face_young_2  = 0x00000003bf00230c4deeffffffffffff00000000001efff90000000000000000
vaegir_face_middle_2  = 0x00000007bf00230c4deeffffffffffff00000000001efff90000000000000000
vaegir_face_old_2    = 0x0000000cbf00230c4deeffffffffffff00000000001efff90000000000000000
vaegir_face_older_2  = 0x0000000ff100230c4deeffffffffffff00000000001efff90000000000000000

khergit_face_younger_1 = 0x0000000009003109207000000000000000000000001c80470000000000000000
khergit_face_young_1  = 0x00000003c9003109207000000000000000000000001c80470000000000000000
khergit_face_middle_1  = 0x00000007c9003109207000000000000000000000001c80470000000000000000
khergit_face_old_1    = 0x0000000b89003109207000000000000000000000001c80470000000000000000
khergit_face_older_1  = 0x0000000fc9003109207000000000000000000000001c80470000000000000000

khergit_face_younger_2 = 0x000000003f0061cd6d7ffbdf9df6ebee00000000001ffb7f0000000000000000
khergit_face_young_2  = 0x00000003bf0061cd6d7ffbdf9df6ebee00000000001ffb7f0000000000000000
khergit_face_middle_2  = 0x000000077f0061cd6d7ffbdf9df6ebee00000000001ffb7f0000000000000000
khergit_face_old_2    = 0x0000000b3f0061cd6d7ffbdf9df6ebee00000000001ffb7f0000000000000000
khergit_face_older_2  = 0x0000000fff0061cd6d7ffbdf9df6ebee00000000001ffb7f0000000000000000

nord_face_younger_1 = 0x0000000000000001124000000020000000000000001c00800000000000000000
nord_face_young_1  = 0x0000000400000001124000000020000000000000001c00800000000000000000
nord_face_middle_1  = 0x0000000800000001124000000020000000000000001c00800000000000000000
nord_face_old_1    = 0x0000000d00000001124000000020000000000000001c00800000000000000000
nord_face_older_1  = 0x0000000fc0000001124000000020000000000000001c00800000000000000000

nord_face_younger_2 = 0x00000000310023084deeffffffffffff00000000001efff90000000000000000
nord_face_young_2  = 0x00000003b10023084deeffffffffffff00000000001efff90000000000000000
nord_face_middle_2  = 0x00000008310023084deeffffffffffff00000000001efff90000000000000000
nord_face_old_2    = 0x0000000c710023084deeffffffffffff00000000001efff90000000000000000
nord_face_older_2  = 0x0000000ff10023084deeffffffffffff00000000001efff90000000000000000

rhodok_face_younger_1 = 0x0000000009002003140000000000000000000000001c80400000000000000000
rhodok_face_young_1  = 0x0000000449002003140000000000000000000000001c80400000000000000000
rhodok_face_middle_1  = 0x0000000849002003140000000000000000000000001c80400000000000000000
rhodok_face_old_1    = 0x0000000cc9002003140000000000000000000000001c80400000000000000000
rhodok_face_older_1  = 0x0000000fc9002003140000000000000000000000001c80400000000000000000

rhodok_face_younger_2 = 0x00000000000062c76ddcdf7feefbffff00000000001efdbc0000000000000000
rhodok_face_young_2  = 0x00000003c00062c76ddcdf7feefbffff00000000001efdbc0000000000000000
rhodok_face_middle_2  = 0x00000007c00062c76ddcdf7feefbffff00000000001efdbc0000000000000000
rhodok_face_old_2    = 0x0000000bc00062c76ddcdf7feefbffff00000000001efdbc0000000000000000
rhodok_face_older_2  = 0x0000000fc00062c76ddcdf7feefbffff00000000001efdbc0000000000000000

man_face_younger_1 = 0x0000000000000001124000000020000000000000001c00800000000000000000
man_face_young_1  = 0x0000000400000001124000000020000000000000001c00800000000000000000
man_face_middle_1  = 0x0000000800000001124000000020000000000000001c00800000000000000000
man_face_old_1    = 0x0000000d00000001124000000020000000000000001c00800000000000000000
man_face_older_1  = 0x0000000fc0000001124000000020000000000000001c00800000000000000000

man_face_younger_2 = 0x000000003f0052064deeffffffffffff00000000001efff90000000000000000
man_face_young_2  = 0x00000003bf0052064deeffffffffffff00000000001efff90000000000000000
man_face_middle_2  = 0x00000007bf0052064deeffffffffffff00000000001efff90000000000000000
man_face_old_2    = 0x0000000bff0052064deeffffffffffff00000000001efff90000000000000000
man_face_older_2  = 0x0000000fff0052064deeffffffffffff00000000001efff90000000000000000

merchant_face_1    = man_face_young_1
merchant_face_2    = man_face_older_2

woman_face_1    = 0x0000000000000001000000000000000000000000001c00000000000000000000
woman_face_2    = 0x00000003bf0030067ff7fbffefff6dff00000000001f6dbf0000000000000000

swadian_woman_face_1 = 0x0000000180102006124925124928924900000000001c92890000000000000000
swadian_woman_face_2 = 0x00000001bf1000061db6d75db6b6dbad00000000001c92890000000000000000

khergit_woman_face_1 = 0x0000000180103006124925124928924900000000001c92890000000000000000
khergit_woman_face_2 = 0x00000001af1030025b6eb6dd6db6dd6d00000000001eedae0000000000000000

refugee_face1 = woman_face_1
refugee_face2 = woman_face_2
girl_face1    = woman_face_1
girl_face2    = woman_face_2

mercenary_face_1 = 0x0000000000000000000000000000000000000000001c00000000000000000000
mercenary_face_2 = 0x0000000cff00730b6db6db6db7fbffff00000000001efffe0000000000000000

vaegir_face1  = vaegir_face_young_1
vaegir_face2  = vaegir_face_older_2

bandit_face1  = man_face_young_1
bandit_face2  = man_face_older_2
You can also make your own facecodes. Open Mount&Blade, Go to configure, enable edit mode, start the game and to the face generator (you can do this by creating a new character or go to the character screen and click the avatar) make the desired face and press ctrl~E, copy the face code and paste it in that field.

Now, copy the farmer code to a new troop, and make that troop, using that code arrangement.


For now, I'll assume that this is the troop you made:
Code:
["village_militia","Village Militiaman","Villiage Militiamen",tf_guarantee_armor,no_scene,reserved,fac_commoners,
   [itm_club,itm_hatchet,itm_wooden_shield,itm_leather_cap,itm_gambeson,itm_nomad_boots],
   def_attrib|level(8),wp(80),knows_common|knows_ironflesh_1|knows_power_strike_1,man_face_middle_1, man_face_old_2],

And, we want farmers to upgrade into this new troop, right? So, we would then go to the bottom of module troops, and find this:
Code:
upgrade(troops,"farmer", "watchman")
We still want farmers to be able to upgrade to watchmen, but we also want the player to have a choice to upgrade their farmers to Village Militiamen, right? :smile: Well this is what we will replace that with:
Code:
upgrade2(troops,"farmer", "watchman","village_militia")

And voila! The new troop is created! :smile:


Now exit and save module_troops.py compile the module. (double click on build_module.bat)


Now, if you want village farmers to have a few guards with them, then you need to add the to the party template, found in module_party_templates.py.
Code:
  ("village_farmers","Village Farmers",icon_peasant|pf_civilian,0,fac_innocents,merchant_personality,[(trp_farmer,5,10),(trp_peasant_woman,3,8)]),
And we would add the village militia to the party template:
Code:
  ("village_farmers","Village Farmers",icon_peasant|pf_civilian,0,fac_innocents,merchant_personality,[(trp_farmer,5,10),(trp_peasant_woman,3,8),(trp_village_militia,1,4)]),


Now compile again, and now village farmers will be joined by village militia.


I hope I provided you with a clear tutorial and all the tools you'll need to make your very own troops. Good Luck :grin:


Credit goes to Cunobelin who edited this tutorial for me when I was too lazy to. :smile:
 
Please learn some more before trying to post tutorials.

cwr said:
Feel free to use this code, just make sure you credit me when you publish your mod.

Please report any bugs so I can edit this post to fix them.
Are you serious? Sorry to burst your bubble, but this is trivial and everyone can do it without special knowledge.
 
MadVader said:
Please learn some more before trying to post tutorials.

cwr said:
Feel free to use this code, just make sure you credit me when you publish your mod.

Please report any bugs so I can edit this post to fix them.
Are you serious? Sorry to burst your bubble, but this is trivial and everyone can do it without special knowledge.

He meaned the Tutorial in a good way I think...but mate (cwr) this is really not a special and ultra compilcated Tutorial...so if you want that the people take you serious don't expect Credits if anyone use your tutorial... .Have you ever saw a tutorial where you have to give the credits when you use this?

I take this as a little joke from you but if you meaned that serious pls give also credits to the tutorials you looked at before you wrote this :wink:


 
well, I miss some stuff. If you want to make a tutorial on the basics, lets make it a complete one shall we?

what I miss is how to make archers  actuall ingame archers, not just weapon wise, But like the classes for in battle,
when you select them you know?

also you might want to show where to get the items from, (Ye I know it.... but not everyone does, and since this is begginer friendly might as well show everything.)

also maybe show some diffrent examples with flags,
like heroes
and females.

also in your explenation for ID, might as well tell, they are suppost to be uniqe and without Capitals, and spaces.
 
Dion/Folcwar said:
well, I miss some stuff. If you want to make a tutorial on the basics, lets make it a complete one shall we?

what I miss is how to make archers  actuall ingame archers, not just weapon wise, But like the classes for in battle,
when you select them you know?

also you might want to show where to get the items from, (Ye I know it.... but not everyone does, and since this is begginer friendly might as well show everything.)

also maybe show some diffrent examples with flags,
like heroes
and females.

also in your explenation for ID, might as well tell, they are suppost to be uniqe and without Capitals, and spaces.

Ok I'll add it to the original post.
 
Dion/Folcwar said:
It looks better, but its rather messy at the moment,
Might want to orginise it better,

Will do. Its my first tutorial, so I don't have much experience with making it.

But yeah, I'll do it.


Edit: I'm done editing the first post; couldn't see any other problems.
 
You aren't saying why we're making this specific troop, you're not saying where regular army soldiers should be placed, you're not saying anything about NPCs, be it the factions' aristocrats, the settlements' unique service characters, or random unique characters one could make. You're also mentioning nothing about where companions should reside (in the file, that is) and what line of code must also be changed when adding new companions.
:razz:


EDIT: I'm sorry for my nonsensical wording, but it's late, so my English is starting to morph to Garbagelish yet again.
 
Lumos said:
You aren't saying why we're making this specific troop,
The specific troop was created because I felt like it, and because there is no bandit troop tree and this could be the start of one.

Lumos said:
you're not saying where regular army soldiers should be placed,
The reinforcement templates!!! Yes thats a good idea I'll put that in the original post.

Lumos said:
you're not saying anything about NPCs, be it the factions' aristocrats, the settlements' unique service characters, or random unique characters one could make. You're also mentioning nothing about where companions should reside (in the file, that is) and what line of code must also be changed when adding new companions.
This tutorial is for non-NPC troops.

Lumos said:
:razz:

Lumos said:
EDIT: I'm sorry for my nonsensical wording, but it's late, so my English is starting to morph to Garbagelish yet again.
:lol: Its not that bad. besides, you were helpful and reminded me of something I left out. :grin:
 
Daethikus said:
Haha was just trying to be funny, but I'm sure someone will learn something from this so good job.  :razz:
You didn't see my laughing smiley? :lol:
cwr said:


Somebody said:
If you want to make troop trees and not just troop sticks you'll want to make use of the upgrade2 mechanism.
Wow I'm stupid for not putting that in. Thanks!!! :smile:
 
bowlie said:
Dosent matter, forgot to build before editing party template

Just delete the troop from the party template, build the module, then put the troop back in the party template and build again.
 
cwr said:
bowlie said:
Dosent matter, forgot to build before editing party template

Just delete the troop from the party template, build the module, then put the troop back in the party template and build again.
That's voodoo?
Just build twice if you change troops. There's a reason why this happens, but the explanation is complicated.
 
MadVader said:
That's voodoo?
Just build twice if you change troops. There's a reason why this happens, but the explanation is complicated.

It doesn't work when I do it that way- I always have to build with the troops first then party templates. But if that works for you then thats great! :grin:
 
Let's say you are adding a new troop, and you add it to some party template as well.
If you try to build that, you'll get errors "the troop is not defined blabla". That's fine.
Build it again, and all will be well.

There's no magic involved and it works the same for everyone.
 
MadVader said:
Let's say you are adding a new troop, and you add it to some party template as well.
If you try to build that, you'll get errors "the troop is not defined blabla". That's fine.
Build it again, and all will be well.

There's no magic involved and it works the same for everyone.

Oh, OK. Thanks for helping! :grin:
The original post has been changed to show this solution.
 
Hello, I am getting an error saying this
("steppe_bandits","Steppe Bandits",icon_khergit|carries_goods(2),0,fac_outlaws,bandit_personality,[(trp_steppe_bandit,4,4:cool:,(steppe_barbarian,2,15)]),
NameError: name 'steppe_barbarian' is not defined

Did I type something wrong?
 
Back
Top Bottom