OSP Kit QoL Customize troops feature for your mod

Users who are viewing this thread

fisheye

Grandmaster Knight
http://www.mbrepository.com/file.php?id=1041

This is the updated code for the customizable troops feature.

To test, go to a village and recruit volunteers, then select "recruit as personal recruit". Talk to them to customize their equipment.

To merge into your mod, just search for the string:

# Custom Troops

This will mark all the module system addition locations. Essentially just a new set of dialog options, two new constants, some new scripts, and the relevant troop entries. And also the extra game_menu option for village recruitment. Very easy.

Good luck!

PS. Full playable mod version is here for those who can't compile Python but want to playtest:
http://www.mbrepository.com/file.php?id=1042

 
HA HA HA!!! Fisheye your a champion. Thank you, this is EXACTLY what i needed!  :mrgreen:
 
Glad you find it useful, let me know if you need assistance merging it or understanding how it works. Basically it's just a bit of copying troops inventories back and forth.
 
Nice, I've always wanted the ability to customise the equipment of all my troops not just the heroes.

I'd be grateful if you could give me a bit of a run through on how it works and how the code relates to the two different inventories displayed on screen.
 
For each custom troop there are three troop entries.

A. The actual troop itself
B. A backup of its current equipment (this is where you put in the "default" equipment selection for the troop before customization)
C. The big list from which you get to select its equipment

There is also a troop called "inventory_backup" for the player.

To customize, the script does this:

1. Copy player inventory to inventory_backup
2. Copy troop equipment selection (C) to player
3. Allow player to loot the troop (i.e., change its equipment)
4. Copy inventory_backup back to player
5. Copy troop inventory to its own backup (B).

The backup (B) is necessary because non-hero troops don't get their equipment list saved in savegames. To get around this, the game checks a trigger so that if it detects that non-hero troop inventories were reset, then it restores the backup (copy from B to A).
 
Thanks for that fisheye.

Given that there are backups, do you believe it would be possible to utilise these to have the troops inventory restored after an upgrade. The ultimate goal would be to have to supply all equipment for a troop without getting 'free' stuff at each upgrade point.
 
fisheye said:
https://www.mbrepository.com/file.php?cid=4&id=1041

This is the updated code for the customizable troops feature.

To test, go to a village and recruit volunteers, then select "recruit as personal recruit". Talk to them to customize their equipment.

To merge into your mod, just search for the string:

# Custom Troops

This will mark all the module system addition locations. Essentially just a new set of dialog options, two new constants, some new scripts, and the relevant troop entries. And also the extra game_menu option for village recruitment. Very easy.

Good luck!

PS. Full playable mod version is here for those who can't compile Python but want to playtest:
https://www.mbrepository.com/file.php?cid=10&id=1042

Well done! :smile:
 
cfnz said:
Thanks for that fisheye.

Given that there are backups, do you believe it would be possible to utilise these to have the troops inventory restored after an upgrade. The ultimate goal would be to have to supply all equipment for a troop without getting 'free' stuff at each upgrade point.

Yup, there's a number of ways to implement player-buying of equipment for regulars but I'll leave that as an exercise for the reader. :wink:
 
Thanks again fisheye. Don't worry my next question wasn't going to be 'can you make it for me?'  :wink: .
 
Basically there's a number of balance issues regarding buying equipment for troops that is best left to personal modder preference. But yeah the current custom selection method totally works for everything I can think of.
 
Great job fisheye!

Man I wish I had time to go though and learn the coding for this stuff.  I have a bunch of ideas that I would implement.  Does this mean you can remove the cost of the troops since you are supplying their gear?  I haven't tried it yet, does it mean that you can supply 1 sword to the whole list of say farmers?
 
jik said:
Great job fisheye!

Man I wish I had time to go though and learn the coding for this stuff.  I have a bunch of ideas that I would implement.  Does this mean you can remove the cost of the troops since you are supplying their gear?  I haven't tried it yet, does it mean that you can supply 1 sword to the whole list of say farmers?

Hey, very good to see you back, jik!

You have to do a lot of extra jiggery-pokery to make the whole "buy equipment for troops" thing work. I have a favourite approach for this, I'll post it later.

 
fisheye said:
jik said:
Great job fisheye!

Man I wish I had time to go though and learn the coding for this stuff.  I have a bunch of ideas that I would implement.  Does this mean you can remove the cost of the troops since you are supplying their gear?  I haven't tried it yet, does it mean that you can supply 1 sword to the whole list of say farmers?

Hey, very good to see you back, jik!

You have to do a lot of extra jiggery-pokery to make the whole "buy equipment for troops" thing work. I have a favourite approach for this, I'll post it later.

You shuold give merchants more space and make things abundant like unrare and loot very rich lol
 
fisheye said:
You have to do a lot of extra jiggery-pokery to make the whole "buy equipment for troops" thing work. I have a favourite approach for this, I'll post it later.
This interests me greatly. I've got it working using a very minor tweak but it's far from perfect and creates other issues. It’ll be good to see how someone that knows what they are doing approaches it.
 
Ok. There are several problems:

[list type=decimal]
[*]All troops have the same equipment. Problem: give one thing to a troop type, they all get it in perpetuity.
[*]Upgrading is currently free and experience-based. Camp in a castle with high level companions with lots of training skill and your ragged recruits turn into knights with plate armor -- from where??
[*]If you make it so that there is a charge per individual, tremendous value is lost on troop death.
[/list]

So my approach would be thus:

[list type=decimal]
[*]Let the player custom-select a few different loadouts of different cost, e.g. armor: recruit, basic, equipped, armored, plated, mounted, heavy, etc. This needs to be done in one shot at a command HQ or something.
[*]Each troop only upgrades into a more experienced version of the troop with the exact same (custom-selected) equipment. eg. armored infantry recruit -> armored infantryman -> exp. armored infantryman -> vet. armored infantryman
[*]You can upgrade a troop from one equipment setting to another from a menu, but you have to pay the difference in equipment cost. Equipment cost is calculated based on the custom selection you chose. E.g. armored infantry recruit -> plated infantry recruit (yes, you can give plate armor to farmerboys... but then you're the one paying for it if they get killed. It's a benefit of being rich.)
[*]You can change troop functions via the same menu but only to lower-level or entry-level troops, e.g. E.g. armored infantry recruit -> armored archer recruit; armored vet. infantryman -> armored archer recruit (note that both these guys turn into green recruits on account of their inexperience with the new role. So maybe you can turn a knight into an ordinary archer, but you pay the price in experience.)
[*]When your own party troops die, you get to loot their equipment just like the enemy. This is quite easy to code.
[*]You can change your custom selections at the command HQ but if you have any troops existing that are affected you immediately have to pay the difference in equipment cost (or, if you downgraded, you can actually get the money back).
[/list]

Hope this makes sense.
 
Very interesting fisheye.

This is what I've done to enable me to personally equip my troops, the rest of your code remains in place. I've also modified the troops to remove all their starting equipment (except recruits). For me it results in a different set of problems.

Code:
# Custom Troops begin
  [anyone|plyr,"regular_member_talk", [(is_between,"$g_talk_troop",customizable_troops_begin, customizable_troops_end),], "I'd like to select your equipment.", "customize_troop_equipment_requested",[]],
  [anyone,"customize_troop_equipment_requested", [], "Aye {sir/madam}. Here is all the gear we have currently equipped. Your inventory will show the gear that you can assign to us.", "finish_custom_troop",[(change_screen_equip_other)]],
##[(call_script, "script_start_customizing", "$g_talk_troop")]],
  [anyone,"finish_custom_troop", [], "Very good {sir/madam}. I will put on the new gear now.", "finish_custom_response",[]],
  [anyone|plyr,"finish_custom_response", [], "Carry on.", "close_window",[]],
##[(call_script, "script_finish_customizing", "$g_talk_troop")]],
# Custom Troops end

It works pretty much the same as equipping a hero, what I found interesting was that how the troops equipment was defined (e.g. tf_guarantee flags) in the module_troops.py file still had an impact. In practice this meant that for example, if I only guarantee boots and armour but also give the troops gloves and a helmet, neither the gloves nor helmet are displayed when you go back into the equipping screen (obvious problem) but they are still randomly assigned to the troops. So you can to a degree create variation in how your troops are equipped using the tf_guarantee flag, provided you don't want the equipment back (useful for low level troops).

What was also interesting is that the equipment is saved to the troops profile and not lost. If I upgrade the last footman to a horseman or he is killed, the next time a promote someone to footman he is already equiped with whatever the last footman had. This is something I see as a problem because I'd much rather see the equipment lost if the troop is killed (unless you enable looting)., or taken with the troop to the next level (e.g. in this case the horseman).[Edit: this won't work as troops are often upgraded at different times]. As it stands all troops start out with no equipment as I prefer this to them magically getting new stuff on promotion but I'd much rather, as I mentioned have equipment carry across promotions.

The other obvious problem with this method is that item requirements are not taken into account when equipped, so I could if I wanted equip my recruits with plate armour and Heavy Chargers even if they had no strength or riding skills. A rather large flaw.

Interested in your comments.
 
fisheye said:
So my approach would be thus:

[list type=decimal]
[*]Let the player custom-select a few different loadouts of different cost, e.g. armor: recruit, basic, equipped, armored, plated, mounted, heavy, etc. This needs to be done in one shot at a command HQ or something.
[*]Each troop only upgrades into a more experienced version of the troop with the exact same (custom-selected) equipment. eg. armored infantry recruit -> armored infantryman -> exp. armored infantryman -> vet. armored infantryman
[*]You can upgrade a troop from one equipment setting to another from a menu, but you have to pay the difference in equipment cost. Equipment cost is calculated based on the custom selection you chose. E.g. armored infantry recruit -> plated infantry recruit (yes, you can give plate armor to farmerboys... but then you're the one paying for it if they get killed. It's a benefit of being rich.)
[*]You can change troop functions via the same menu but only to lower-level or entry-level troops, e.g. E.g. armored infantry recruit -> armored archer recruit; armored vet. infantryman -> armored archer recruit (note that both these guys turn into green recruits on account of their inexperience with the new role. So maybe you can turn a knight into an ordinary archer, but you pay the price in experience.)
[*]When your own party troops die, you get to loot their equipment just like the enemy. This is quite easy to code.
[*]You can change your custom selections at the command HQ but if you have any troops existing that are affected you immediately have to pay the difference in equipment cost (or, if you downgraded, you can actually get the money back).
[/list]

Hope this makes sense.

GOGO fisheye!  :mrgreen:
 
cfnz said:
Very interesting fisheye.

This is what I've done to enable me to personally equip my troops, the rest of your code remains in place. I've also modified the troops to remove all their starting equipment (except recruits). For me it results in a different set of problems.

Code:
# Custom Troops begin
  [anyone|plyr,"regular_member_talk", [(is_between,"$g_talk_troop",customizable_troops_begin, customizable_troops_end),], "I'd like to select your equipment.", "customize_troop_equipment_requested",[]],
  [anyone,"customize_troop_equipment_requested", [], "Aye {sir/madam}. Here is all the gear we have currently equipped. Your inventory will show the gear that you can assign to us.", "finish_custom_troop",[(change_screen_equip_other)]],
##[(call_script, "script_start_customizing", "$g_talk_troop")]],
  [anyone,"finish_custom_troop", [], "Very good {sir/madam}. I will put on the new gear now.", "finish_custom_response",[]],
  [anyone|plyr,"finish_custom_response", [], "Carry on.", "close_window",[]],
##[(call_script, "script_finish_customizing", "$g_talk_troop")]],
# Custom Troops end

It works pretty much the same as equipping a hero, what I found interesting was that how the troops equipment was defined (e.g. tf_guarantee flags) in the module_troops.py file still had an impact. In practice this meant that for example, if I only guarantee boots and armour but also give the troops gloves and a helmet, neither the gloves nor helmet are displayed when you go back into the equipping screen (obvious problem) but they are still randomly assigned to the troops. So you can to a degree create variation in how your troops are equipped using the tf_guarantee flag, provided you don't want the equipment back (useful for low level troops).

What was also interesting is that the equipment is saved to the troops profile and not lost. If I upgrade the last footman to a horseman or he is killed, the next time a promote someone to footman he is already equiped with whatever the last footman had. This is something I see as a problem because I'd much rather see the equipment lost if the troop is killed (unless you enable looting)., or taken with the troop to the next level (e.g. in this case the horseman).[Edit: this won't work as troops are often upgraded at different times]. As it stands all troops start out with no equipment as I prefer this to them magically getting new stuff on promotion but I'd much rather, as I mentioned have equipment carry across promotions.

The other obvious problem with this method is that item requirements are not taken into account when equipped, so I could if I wanted equip my recruits with plate armour and Heavy Chargers even if they had no strength or riding skills. A rather large flaw.

Interested in your comments.

Like I said, your method is totally unbalanced because it makes no sense that if you buy a single item you can equip a whole army with it. Not only that but you can only equip ONE troop type with it, when that troop upgrades they lose the item, which is ridiculous. My proposal does not have that problem. In essence you are just designing an equipment template for your troops, but you still have to pay cash to equip each troop into that template.

Also, the issue with item requirements is simple, you only allow equipment to be selected that is appropriate for a given troop line, e.g. veteran archers get access to longbow, recruit archers get access to hunting bow. Player is not allowed to select longbow for customizing recruit archers.
 
Back
Top Bottom