kt0's troop script: the return of BLAM

Users who are viewing this thread

Many people have asked for a script that takes troops.txt and converts it back into module system code.  You can now find such a script at the repository:  http://www.mbrepository.com/file.php?id=1398.  This will allow you to hack up your troops.txt file and bring the data back into your module system code with a minimum of effort.  As a test of effectiveness, I successfully decompiled a Native module, re-compiled the resulting code, and diffed the results against the original txt data. 

Caveats:
- If you have stats higher than 30, you'll need to add new stat lines in header_troops.py to get things to compile again.  Note that Native has one troop with a stat at that level (the fugitive has strength of 31)
- Aliasing of flag values, especially skills, is not guaranteed to come out 100% like your original module system code.  Many of the skill macros (like knight_skills_5 and knows_common) overlap and it's impossible to tell from the txt files what the original code looked like.  Face codes also have value collisions.
- Weapon proficiencies as produced by the module system have a random component of 10+10%.  Rather than try to approximate this value, I assume that anyone using the unofficial editor to hack this stuff up is going to continue to do so and I kept the literal values.  Anyone intending to only use the script once should go through and tidy up their proficiency values with the expected macros.

To use:
- Install Ruby.
- Edit the script to look at your data files (look near the top of the script).
- Pop open a command window.
- run the script.
- Copy & paste the tuples from the destination file to your module_troops.py.  Fight with all your might, the urge to make the destination output the same as your module_troops.py.  I don't replace macro and alias values. 

And since I haven't in a while:  BLAM
 
Do you see this stuff in the output?
# kt0:  these are needed for stats over 30
str_1_base = 0x00000001
agi_1_base = 0x00000100
int_1_base = 0x00010000
cha_1_base = 0x01000000

If you don't, you've either copied & pasted incorrectly or you're running the wrong script.  You can also modify your header_troops.py to have the correct str_* values as I mentioned in the original post:
- If you have stats higher than 30, you'll need to add new stat lines in header_troops.py to get things to compile again.  Note that Native has one troop with a stat at that level (the fugitive has strength of 31)

Strengths lower than 3 you'll have to patch yourself.
 
This tool is very useful for me, thanks kt0! You wouldn't have any plans of doing something similar for party_templates.py, would you? (hint, hint)  :smile:
 
Sorry to bump this thread, but a quick question -- can I modify this so it can preserve Firearms proficiency values, and how do I do it?  I'm using it on a mod that has arquebusiers.

Thanks!
 
YOU sir, are a scholar and a gentleman.  I wasted two days converting by hand before discovering these converters, but you saved me another two, so thank you.
 
i cant get it to work..

i changed the directories..
it found the files it needed




for the other files.. troops, factions, scenes, i made a txt file but blank inside..

im testing out to convert 2 items in item_kinds.txt

and yeah it wrote, 2 items found
parsing troops data... 0 troops  parsed!
writing tuples file (D:/test.txt)...0 troops written to the output file.

and theres nothing on the file i want..
what went wrong..


 
I have one more custom faction in my mod, and lots of new items.
I get the correct values of stats, but upgrade paths, inventories, factions, are complately screwed up. Any ideas why? and Suggestions to fix it?
 
Troops.txt gives troops inventories based on item number.  So if the item sequence changes, like if you inserted a new item in between two older items, the inventory can get screwed up. 

When I use this script in a mod, I take first the files from Native, run the script, then delete all troop inventories leaving only the [].  Then I copy only the troop entries into my module_troops.py file.  Then I equip the troops the way I want.
I leave the upgrade definitions commented out until I have all the troops ready.  (I keep a copy of the file edited with kt0's script so if I want to start a new mod I can do so easily with the troops already prepped for modding).

Since you have a new faction, be sure to edit the factions of all kingdom lords and knights to their correct factions in your mod.
 
is this still working for current versions?
is there any other tool to use or method of compiling a module .py file back from a troops.txt file?
also is there a similar tool to do the same thing for item_kinds1.txt ??
 
Back
Top Bottom