EDIT: I just checked the 2nd screenshot, and noticed that you seem to want to make each picked hero unavailable to every player in the game, so you can completely ignore my post...
There are 14 heroes but the way you have set it up the AI can only randomize one of the first 7. Did you intend that?
The problem is that while you do reduce the max number by 1 every time a hero gets chosen, you don't specifically eliminate that hero from the pool. You need to use this sort of logic (not gonna type a trigger because your variable names are arcane):
- Pick random number between 1 and N, call it X.
- Make a HeroType[X] for the computer.
- Set HeroType[X] = HeroType[N] (this makes it so even if the next ai gets the same random number it will be a different hero)
- Set N = N-1 (reduces the total number of heroes to random from)
I have a better idea, it is good to store hero types in "unit type" arrays but you can use "unit group".
By creating hero at a hidden part of the map and hiding them, (Hide, pause and make invulnerable), then add them into a unit group for A.I hero pick.
Next, use "select random 1 unit from unit group" and then use "remove unit from unit group" and "remove unit from the game".
This will then allow the A.I to pick a random unit (hero) from the unit group.
Either one of these would work, but you'd need to make some changes or it won't work for more than one AI player (unless you don't want any of the AI players to pick the same heroes)
I think the easiest or at least most reasonable way (besides using hashtable) would be to create a second variable array for unit type (or integer if you're using jass), and instead of deindexing or removing the units from the unit group you would simply save the unit type(s) to the new variable.
If we're assuming that it's like in melee and you can have 3 heroes max, you'd need 3 indexes/slots dedicated to each player, e.g. 0-1-2 for player 1, 3-4-5 for player 2, 6-7-8 etc.
That way you can make a sort of 2d array, so you don't have to create another variable for every player.
Anyway, so the easiest/laziest way would be to just choose a random one from the pool, loop through the 3 indexes dedicated to the triggering player, and if the random unit type is the same as one of the 3 unit types the player already has, re-roll the dice again.
Otherwise, just temporarily remove the relevant unit types from the pool so it would be impossible for it to roll a unit type that the AI already has. It would be a bit more work, but it's better since if the dice kept rolling unit types that the AI already picked it could technically go on forever...
Oh and by the way, I don't see anyone mentioning this, but is the hero pool to choose from exactly the same for every player?
In other words, it's not some kind of melee map or something where you have your own race with some exclusive heroes? Cause then you'd probably need to make some further modifications. (It doesn't seem like this is the case, but I'm just making sure to bring this up just in case.)