Item distribution and multiple meshes

Users who are viewing this thread

kapusta_nz

Recruit
I've been working on an equipment mod with a friend for about three months now and we have been carefully selecting all the best items we could find. Basically all the items we consider realistic and well-made are being added, but that's not particularly important. The problem is, we are now at the item limit (915 IIRC) and since I don't know of a way to get around it (searched these forums, but noone seems to have a fix), I've turned to using multiple meshes for a single item in the item_kinds file. Now, after reading a few topics I understand how you can make an item use more than one model depending on its imodbits modifiers. However, after some experimentation, I found that it didn't work for AI-controlled units. Basically if one item has several meshes associated with it  (for example one helmet with 4 different models, so one model for a rusty helmet, another model for a reinforced one, etc), you will see those different meshes in the shops and will be able to buy them, but the AI units will still only be given the first one in the list. Could anyone confirm this, or am I doing something wrong here?

Another question: how exactly does the item distribution algorithm work when a unit is first generated? It is most certainly not fair and does not distribute equipment randomly, as I've found from a few tests. The price of an item seems to have an effect, as more expensive items are selected more often.
 
I am also curious to know if anyone has a tip to assign "imodbits" items to troops. Have you found something? Or anybody has a suggestion?
 
Well, that was a pretty old post. But troop_add_item contains an additional parameter, so you could do the following:
Code:
(troop_remove_item, "trp_swadian_knight", "itm_great_lance"),
(troop_add_item, "trp_swadian_knight", "itm_great_lance", imod_masterwork),
You can only give items with specific modifiers to troops, not an entire set imodbits. But you could do is add all those items with modifiers before battle and remove them before the loot screen shows up so it doesn't affect the distribution.

Edit:
Wrote a quick script to distribute one item for each modifier in an imodbits. Keep in mind that this is not the same distribution as you would find the items in shops (troops might prefer more expensive items or something) - and you might reach the inventory limit if you're not too careful.
Code:
    #script_distribute_imodbits
    #input: imodbits (see top of module_items.py), troop, item
    #output: none
    #result: troop gets items with modifiers
    ("distribute_imodbits",
    [
	 (store_script_param, ":imodbits", 1),
	 (store_script_param, ":troop", 2),
	 (store_script_param, ":item", 3),
	 (assign, ":bit", 1),
	 (try_for_range, ":imods", imod_plain, imod_large_bag + 1),
	   (store_and, ":result", ":imodbits", ":bit"),
	   (gt, ":result", 0),
	   (troop_add_item, ":troop", ":item", ":imods"),
	   (val_mul, ":bit", 2),
	 (try_end),
    ]),
 
kapusta_nz said:
Basically if one item has several meshes associated with it  (for example one helmet with 4 different models, so one model for a rusty helmet, another model for a reinforced one, etc), you will see those different meshes in the shops and will be able to buy them, but the AI units will still only be given the first one in the list. Could anyone confirm this, or am I doing something wrong here?
Not the first one, but the one with plain modifier. Yes, this is a problem in MB1.011. I'm more or less certain it carried over to Warband as well.
I was under impression that you can have different imodbits showing for hero troops, should check it though
 
So, Somebody, this script makes it so that the troops will have random selections of weapons with each imodbit? This is exactly what I was needing. Now I can use these!
rataxes.jpg

Where do you have to add the code? module_scripts? Forgive me, I haven't done much coding yet.
 
When I say random I mean the troop get one item for each item modifier included in the imodbit. The troops certainly won't use the items with the same frequency as you would find these items as merchandise.
Code:
imodbits_lance = imodbit_cracked | imodbit_bent | imodbit_balanced
Code:
(call_script, "script_distribute_imodbits", "trp_swadian_knight", "itm_great_lance", imodbits_lance),
The above code should give Swadian Knights Cracked, Bent, and Balanced Great Lances (along with the orginal plain Great Lance). So now the troop has 4 possible lances to choose from, but the exact mechanism with which agents are loaded from troop templates is not known (it is linked to dna/facecode though). You can get a 1 in 4 chance of getting any of these lances, or it might be sorted by price, or whatever results the RNG comes up with. To change that probability, you'll have to add more items - but if you are to approach a sensible model for every item modifier on each item, you'd soon run out of space in the troop's inventory. You cannot do this on the fly either, as agent_equip_item does not specify an item modifier.

For something like a set of retextured item, you could try the script, or just put three distinct items in the troop's inventory.
 
Back
Top Bottom