HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

help with assigning items to random hero select

03-30-2004, 12:25 AM#1
xtacb
i have a random hero selection in my map that picks heros for the players in the beginning at random
each hero is supposed to get a specifc item though, like if u got naga sea witch then she should be carrying a claw of attack +15

the random hero selection works perfectly, picking a random hero for each player and removes that hero from other selections so there are no doubles

the thing is, sometimes an item will be given to two heros when each item is supposed to correspond to a certain hero , like naga sea witch got the claw of attack +15 but players 5's Priestess hero got the claw +15 also instead of the item shes supposed to get

this is the trigger for player 1, and its basically same structure for the other players (the player 1-8 are changed of course)

Player1
Events
Time - Elapsed game time is 0.02 seconds
Conditions
Actions
Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
Loop - Actions
Set rnd[1] = (Random integer number between 1 and N)
Unit - Create 1 hero[rnd[1]] for (Picked player) at (Center of location1) facing Default building facing degrees
Set playerleaving[1] = (Last created unit)
Hero - Create item[rnd[1]] and give it to playerleaving[1]
Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: strings[rnd[1]]
Set hero[rnd[1]] = hero[N]
Set N = (N - 1)

why does sometimes an item will be given to a hero thats not supposed to get it? (why are there doubles of items sometimes) and how do i fix it?
03-30-2004, 02:36 AM#2
Pyrus
Create 2 arrays. 1 with the hero types auto defined and the other with the corresponding item. So herotype[3] = naga sea witch and itemtype[3] = claws

Have a variable called X and set it to random 0 to N
Then create herotype[X] and give it itemtpye[X]

To remove multiple heroes have another array that stores the already picked numbers. Then have a loop that checks that the randomly picked number not= those in the array.
03-30-2004, 05:34 PM#3
xtacb
i know how to do that, thats what i have , i am using three arrays actually to keep purposely keep each player as separate as possible

UNit array
Item array
integer array (each player will use a different index for rnd(1-8) to select random)

i already said heros was not the problem, it is the items getting doubled some times

player 1 uses integer variable rnd[1] in all player 1 functions
player 2 uses integer variable rnd[2] in all player 2 functions
and so on

so why does the item (and strings) sometimes show to another unit?
04-02-2004, 08:25 PM#4
xtacb
ok i changed the N integer into array also

Player1
Events
Time - Elapsed game time is 0.02 seconds
Conditions
Actions
Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
Loop - Actions
Set rnd[1] = (Random integer number between 1 and N[1])
Unit - Create 1 hero[rnd[1]] for (Picked player) at (Center of location1) facing Default building facing degrees
Set playerleaving[1] = (Last created unit)
Hero - Create item[rnd[1]] and give it to playerleaving[1]
Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: strings[rnd[1]]
Set hero[rnd[1]] = hero[N[1]]
Set N[1] = (N[1] - 1)
Set N[2] = N[1]

The other players are basically same structure (just the array indexes are different corresponding to the player)

When i did this, item would still be doubled (another player would recieve the item also)
each player basically uses its own set of arrays indexes so why does it do this?