Equipment randomness not working well

Users who are viewing this thread

Piet

Recruit
I am aware about the way assigning armour to troops works in Warband, about all the flags and how soldiers treat the items you list in the modsys as more of an inventory to pick from. That being said, I can't explain this issue.

I have added two available body armours and two helmets, the first time I load a battle to test the randomness, it works, from 10 soldiers I get an average of 6 wearing the first on the list and 4 wearing the second item, totally acceptable. Yet all subsequent battles after, there's only ever one soldier wearing the second item on the list. This cant be a fluke.

I also made sure that both armours have the same exact stats so this cant be explained as the soldiers equipping the better set of armour. I don't know what is going on and if someone has even experienced this before.

Edit: Funnily enough, this issue only seems to be present with stuff I modded in, randomness works as it should with native items.
 
Last edited by a moderator:
At which place did you add your new items? At the same place at which the other armouries and helmets are or at the bottom of the list?
Originally when I made this post they were at the bottom, now I have put them with other armours and helmets and now the second item doesnt show up even once.

Edit: Im also using a separate inventory model and the main model is rigged, can that possibly effect the randomness? It is still weird that only one different soldier is spawned though.
 
Last edited:
Upvote 0
Does it change something if you change the order of the items at the troop tuple (given that they have still the same stats and prices etc.)? If you switch the item entries' position with each other, does that change something? (Always starting a new campaign which you probably do anyway).
I would be surprised if the rigging has an effect on the randomness.
 
Upvote 0
Does it change something if you change the order of the items at the troop tuple (given that they have still the same stats and prices etc.)? If you switch the item entries' position with each other, does that change something?
No nothing changes, the first item on the list appears on all troops but one of them who has the second list item.

I think I will move on from this, it is a bummer. The final thing I am going to test is replicating the same thing on maybe the VC modsys and see if it behaves differently and try to learn why. I thank you for the help and communication.

Edit: what is also silly is that the randomness seems to work fairly well with enemy armies, i will see if also works with friendly armies.
 
Upvote 0
I don't really know why it wouldn't work. You could try it with different item modifiers and integrate a worse/better armour with such a modifier at the regular item entry.

Something else which you could try to do would be having an empty base mesh with which they get equiped and then having a random armour mesh which gets added via trigger to the armour. Similar to how I add random little equipment to an armour here:
 
Upvote 0
Warband uses mission timer to generate the first random sequence as a seed. It is pseudorandom. For example if you start mission and roll random(10) 3 times then every time you reload mission the sequence will be the same.
1) 3, 0, 5
2) 3, 0, 5
3) 3, 0, 5
4) 3, 0, 5
.......

This pseudorandom function works for hardcoded engine and operands.
The first trigger with timer is always ti_on_agent_spawn.
So I have this workaround:
Python:
(ti_on_agent_spawn, 0, ti_once,[],[
    # Procedure to fix psevdorandom of troops equipment
    (try_for_range, ":i", 0, "$random_seed"), 
        (store_random_in_range, reg10, 0, 2),
    (try_end),
]),

You just need to generate random seed each time you finish the mission.
Python:
(store_mission_timer_a_msec, "$random_seed"),
(val_mod, "$random_seed", 100),

It maybe a big work to add this code to every mission but result is worth it.
Only the first agent equipment will not be randomised. So you can add code to reequip manually.
 
Upvote 0
Back
Top Bottom