Modifying NPC heroes using troops.txt

Users who are viewing this thread

Lady Dreya

Recruit
I got sick of getting Rolf with all of his skills wasted, so I decided to modify troops.txt to make the NPC heroes start the way I wanted.  I did search on this topic but most of the threads are old (from 2005 or so) and refer to an older version of M&B and troops.txt.

Here is an example from the native troops.txt

Code:
trp_rolf Rolf Rolf 16 0 0 1 0 0
  133 0 96 0 210 0 -1 0 -1 0 -1 0 ...
  7 5 4 4 29
 172 181 173 180 188 174 0
274 131072 0 1 0 0 
  820224 142075201747342602 0 0

Attributes and Level:
7 5 4 4 29

Weapon Proficiencies:
172 181 173 180 188 174 0

However, I can't figure out how the skills are determined.  I think it must be in hex or something, but I still can't decipher it.

I'm not concerned with their gear or where they spawn at... just their attributes, level, and skills.

Can anyone help by giving me a breakdown of what skill numbers would result from this example?

 
I was kind of hoping for a "quick and dirty" method of modifying the startup file...

But I'll give the module system a shot, maybe it will be easier?  :???:

I am still interested in a breakdown of what skill numbers would result from the example above...
 
Lady Dreya said:
I was kind of hoping for a "quick and dirty" method of modifying the startup file...

But I'll give the module system a shot, maybe it will be easier?  :???:
It's much easier.
 
Well, I got my NPCs modified using the python scripts (module system).

I still think it might have been faster to just change the troops.txt.  BUT... the module system was certainly much more straight forward!  And there is more documentation on the module system.  Good for modding noobs like me.  :mrgreen:
 
Lady Dreya said:
I got sick of getting Rolf with all of his skills wasted, so I decided to modify troops.txt to make the NPC heroes start the way I wanted.
I felt the same way and used the mod system to change it.

If you have trouble dealing with the mod system, but feel comfortable editing troops.txt then you can try pasting in the following sections that I've thrown together to produce lower level but skilled heroes:

Code:
trp_borcha Borcha Borcha 16 0 0 1 0 0
  120 0 95 0 161 0 298 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 
  11 10 9 4 2
 47 53 47 46 46 54 0
17 3211264 2 12338 262144 0 
  33609 136359878950015339 0 0 
trp_marnid Marnid Marnid 16 0 0 1 0 0
  122 0 92 0 308 0 83 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 
  10 11 10 3 2
 50 60 56 50 58 61 0
19 1179680 0 12354 196608 0 
  25985 127884702832879824 0 0 
trp_ymira Ymira Ymira 17 0 0 1 0 0
  121 0 97 0 301 0 80 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 
  9 12 10 3 2
 54 54 65 59 62 59 0
16 16921088 0 12354 196608 0 
  266245 134303837273605401 0 0 
trp_rolf Rolf Rolf 16 0 0 1 0 0
  123 0 96 0 159 0 246 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 
  12 9 9 4 2
 46 52 43 47 44 44 0
16 50401282 0 12338 262144 0 
  13707 138360166550561516 0 0
By the way, their appearance and clothing have also been changed a bit so look closely at who's in the tavern before deciding that there aren't any heroes around.

Almost forgot, I also modified the "kidnapped girl" who is encountered during a rescue quest.  I've given her the name "Lianna" and boosted her stats quite a bit just in case I decide to keep her as a hero:

Code:
trp_kidnapped_girl Lianna Kidnapped_Girls 17 0 0 1 0 0
  118 0 297 0 188 0 98 0 87 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 
  8 13 9 4 2
 89 80 91 84 81 88 0
0 33619968 268435456 16450 135184 0 
  274436 131484080304374080 0 0
 
A KON_Air public safety announcement;

Code:
  ["kidnapped_girl","Kidnapped Girl","Kidnapped Girls",tf_hero|tf_female,0,reserved,fac_commoners,
   [itm_dress,itm_leather_boots],
   def_attrib|level(2),wp(50),knows_common|knows_riding_2,0x0000000000100104000011970c848592],

versus

Code:
trp_kidnapped_girl Kidnapped_Girl Kidnapped_Girls 17 0 0 1 0 0
  116 0 98 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 
  7 5 4 4 2
 60 59 50 54 61 59 0
274 131072 0 3 0 0 
  1048836 19340447745426 0 0

Learn Python, don't waste your precious time. Don't make me mad.
 
KON_Air said:
A KON_Air public safety announcement;

Code:
blah blah blah
Learn Python, don't waste your precious time. Don't make me mad.
Heh I'm flattered if you think I created the above modifications without using Python.  However, if the original poster decides not to invest precious time learning Python merely for the sake of having lower level heroes then replacing with the excerpts I've posted above will work just fine.
 
Wading through the binary values is more time consuming then installing python, changing directories in a batch and py file and editing stuff in notepad/IDLE. You don't need to know anything about coding at all if you just want to change stats/equipment. Just don't encourage people how to do it the absurd way.
 
If you want to edit skills in the text file you look at 5th line for that character in troops.txt.  For example, Marnid's 5th line in Native looks like:

3 131072 0 2 0 0

The first 5 numbers separated by a space represent his skills.  The 6th number may be reserved for future skill enhancements.  To change the starting skills, you must convert each number to hex.  Make it 8 digit hex, because each number can hold 8 skills.  So, the line above converted is:

00000003 00020000 00000000 00000002 00000000

Each digit is a skill, and can be 0-A.  Well, you could try 0-F, but F is 15, and I think the max for each skill is 10 (hex A), so F might break the game.

So which digit is which skill?  Here is a mapping in form x:y where x is the number and y is the digit from left to right:
1:1 Persuasion
1:2 <unused>
1:3 <unused>
1:4 <unused>
1:5 <unused>
1:6 Prisoner Management
1:7 Leadership
1:8 Trade
2:1 Tactics
2:2 Pathfinding
2:3 Spotting
2:4 Inventory Management
2:5 Wound Treatment
2:6 Surgery
2:7 First Aid
2:8 Engineering
3:1 Horse Archery
3:2 <unused>
3:3 <unused>
3:4 <unused>
3:5 <unused>
3:6 <unused>
3:7 Trainer
3:8 Tracking
4:1 <unused>
4:2 <unused>
4:3 <unused>
4:4 <unused>
4:5 Weapon Master
4:6 Shield
4:7 Athletics
4:8 Riding
5:1 <unused>
5:2 <unused>
5:3 <unused>
5:4 Iron Flesh
5:5 Power Strike
5:6 Power Throw
5:7 Power Draw
5:8 <unused>

You can see that Marnid has 3 Trade, 2 Inventory Management, and 2 Riding.  If you want to give him 10 Athletics, and 9 Horse Archery, you would need to change the hex to:
00000003 00020000 90000000 000000A2 00000000
Then convert it back to decimal:
3 131072 2415919104 162 0

If you replace Marnid's 5th line with the above and start a new game, he will have 10 Athletics and 9 Horse Archery. 

I figured this out because I'm thinking of writing a GUI for the Troops.txt similar to my item_kinds1.txt editor.
 
KON_Air said:
Wading through the binary values is more time consuming then installing python, changing directories in a batch and py file and editing stuff in notepad/IDLE.
Just in case your 15-word description isn't enough, the original poster can also find Armagan's detailed instructions on this page
KON_Air said:
Just don't encourage people how to do it the absurd way.
Nobody has "encouraged" anything like that.

jordan said:
If you replace Marnid's 5th line with the above and start a new game...
Don't forget that the original poster wants to edit Rolf whose only skill is knows_common.
 
godot said:
Lady Dreya said:
I got sick of getting Rolf with all of his skills wasted, so I decided to modify troops.txt to make the NPC heroes start the way I wanted.
I felt the same way and used the mod system to change it.

Thanks much.  Inspired me to install 9.03.  Going to try it out.
 
godot said:
jordan said:
If you replace Marnid's 5th line with the above and start a new game...
Don't forget that the original poster wants to edit Rolf whose only skill is knows_common.
The instructions are the same for Rolf.  Knows_common is just a variable equaling a combination of normal skills:
"knows_common = knows_riding_1|knows_trade_2|knows_inventory_management_2|knows_prisoner_management_1|knows_leadership_1"

 
aGorilla said:
Thanks much.  Inspired me to install 9.03.  Going to try it out.
As the saying goes, sometimes less is more.  :smile:

Btw, I've just modified my post replacing the quote tags with code tags to avoid introducing line breaks while copy/pasting.

jordan said:
The instructions are the same for Rolf.  Knows_common is just a variable equaling a combination of normal skills:
"knows_common = knows_riding_1|knows_trade_2|knows_inventory_management_2|knows_prisoner_management_1|knows_leadership_1"
Oh I see.  I didn't realise that knows_common is only a Python variable that gets represented by the actual set of skills in the troop.txt specification.

Thanks for the insight.
 
Thanks Jordan, for the breakdown of the troops.txt skills, that was very informative!  If you had a gui for editing the file I think it would be useful to many who don't want to mess with python.

As I said in my previous post (5th post in the thread), I ended up using the python scripts, which was not difficult at all considering all of the forum documentation.  I have background in programming so it was easy enough anyway.

I did end up ditching knows_common for Rolf and the others because leader skills are pretty useless on NPCs as far as I can tell...  If anyone else looking to do this is interested, here are the modifications I made to my companions.  Mainly, they all start at level 1, Borcha is my tracker, Marnid is my trader/engineer, Ymira is the surgeon, and Rolf is a warrior.  Their stats and skills are tweaked.  I probably made them slightly overpowered stat-wise, but it's my game, so I can do what I like!  :razz:

Code:
#Companions
  ["borcha","Borcha","Borcha",tf_hero, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],str_9|agi_10|int_10|cha_3|level(1),wp(70),knows_weapon_master_5|knows_spotting_2|knows_pathfinding_2|knows_tracking_1|knows_riding_2,0x00000000000c524301c946981065126e],
  ["marnid","Marnid","Marnid", tf_hero, 0,reserved, fac_commoners,[itm_linen_tunic,itm_hide_boots,itm_club],str_5|agi_5|int_10|cha_12|level(1),wp(60),knows_weapon_master_5|knows_trade_3|knows_engineer_2|knows_riding_2,0x00000000000c600301c2510211a5b292],
  ["ymira","Ymira","Ymira",tf_female|tf_hero, 0, reserved, fac_commoners,[itm_dress,itm_knife],str_8|agi_9|int_12|cha_3|level(1),wp(20),knows_weapon_master_5|knows_wound_treatment_2|knows_first_aid_2|knows_surgery_2|knows_riding_1,0x000000000000000201c152351bab4558],
  ["rolf","Rolf","Rolf",tf_hero, 0, reserved,  fac_commoners,[itm_leather_jerkin,itm_nomad_boots, itm_sword],str_12|agi_9|int_8|cha_3|level(1),wp(165),knows_weapon_master_5|knows_power_strike_2|knows_shield_1|knows_trainer_2|knows_riding_2,0x00000000000c840001f8c0a4ab8ad50a],

All of them are roughly level 20 now, in my game, and I'm pretty happy with how they're working out.  In my previous games I kept wanting to restart because their skills sucked so much!  :lol:
 
Lady Dreya said:
I did end up ditching knows_common for Rolf because leader skills are pretty useless on NPCs as far as I can tell...
There was a time (perhaps years ago) when the player could leave the entire party someplace and they would remain there as an intact group as long as the hero at the top of the party member list had enough leadership (and possibly prisoner management) skill.

Lady Dreya said:
All of them are roughly level 20 now, in my game...
Hang on!!  How the heck did you manage to get both Rolf and Marnid to reach around level 20 at the same time when Marnid began with str_5|agi_5 when Rolf had str_12|agi_9 (not to mention Rolf starting out with nearly 3 times as much weapons proficiency)?   :shock:

By the way, was there any practical use in giving Marnid level 12 charisma or was that choice just for role playing?
 
godot said:
By the way, their appearance and clothing have also been changed a bit
Nice touch!  Spear Eye for the Staff Guy?  :mrgreen:

godot said:
Almost forgot, I also modified the "kidnapped girl" who is encountered during a rescue quest.  I've given her the name "Lianna" and boosted her stats quite a bit
Now I feel less guilty about kidnapping her, but it makes it a little tougher to remember to avoid her home town.

godot said:
Btw, I've just modified my post replacing the quote tags with code tags to avoid introducing line breaks while copy/pasting.
Worked fine here as it was.

Thanks again - particularly for giving them all some riding skill.  I kept forgetting to level that up until I was ready to buy them horses.  At that point, it was a bit late to think of it.
 
godot said:
Lady Dreya said:
I did end up ditching knows_common for Rolf because leader skills are pretty useless on NPCs as far as I can tell...
There was a time (perhaps years ago) when the player could leave the entire party someplace and they would remain there as an intact group as long as the hero at the top of the party member list had enough leadership (and possibly prisoner management) skill.

Lady Dreya said:
All of them are roughly level 20 now, in my game...
Hang on!!  How the heck did you manage to get both Rolf and Marnid to reach around level 20 at the same time when Marnid began with str_5|agi_5 when Rolf had str_12|agi_9 (not to mention Rolf starting out with nearly 3 times as much weapons proficiency)?  :shock:

By the way, was there any practical use in giving Marnid level 12 charisma or was that choice just for role playing?

I still leave one of my heroes behind when I need speed (to chase down runaway serfs, for example)... And I give them a big chunk of my army and all of the prisoners.  Even though they have no leadership or prisoner management skills, they don't seem to have a problem holding onto everything.  Perhaps that is something that should be fixed, since that doesn't really make sense.  Would provide a reason to invest in leadership skills for a "second in command" type of NPC.

I started all of them with 5 weapon master so I could drop in the weapon points without constantly adding skill points to WM.  But I equip all of them to fight and put them in the top of my list, so they get experience.  I think Rolf is the highest level one though.  They're all around 20, give or take a level or two.  Rolf in native comes with lots of weapon proficiency, so I just left that as it was.  But when he levels the new weapon points don't go very far...  thus, Marnid and the others were able to catch up a little bit with whatever weapon they're using.

Marnid has all that charisma because he does the trading skill for me.  You should see him now, I think he's up to 25 charisma and 8 trading.  :razz:

Anyway, just my preference to have clear cut roles for my NPCs, and level them up myself starting from level 1.
 
Lady Dreya said:
Marnid has all that charisma because he does the trading skill for me.  You should see him now, I think he's up to 25 charisma and 8 trading.   :razz:
Ah poop!!  [godot slaps forehead!!]  I completely forgot that Trading is governed by the CHA attribute.  And just when I was all proud of my little mod for not giving Heroes any skills that could not be justified by their attributes.

Glad you pointed that out.  Thx.  :cool:
 
Ya know, I noticed his 3 charisma, with his unexplainable 3 trade earlier, and forgot to mention it.

If you update that, can it be applied to 'live' game, or would it have to be started from scratch?
 
Back
Top Bottom