Random Button

Level 9
Joined
Oct 17, 2009
Messages
370
Your standard random selection trigger.

Create an integer array and fill it with the hero types available.
Then just choose a random index from it and ceate that hero type.

That easy.

For finite choice of heroes, simply remove them from the array.

ive noticed one thing when i did like this... if i in the first map choose random FIRST of all players, and i get for example blademaster, i will get blademaster if i pick random first too the next time i play,
or if i use the random integer to just set a integer variable to a number, it will be the same number every game i play...
 
Level 6
Joined
Jul 11, 2008
Messages
104
Your standard random selection trigger.

Create an integer array and fill it with the hero types available.
Then just choose a random index from it and ceate that hero type.

That easy.

For finite choice of heroes, simply remove them from the array.

I want to do this for units, not heroes.

Also, how do I form it into a trigger (GUI) after I create the variable?
 
Level 18
Joined
Feb 25, 2009
Messages
2,006
ive noticed one thing when i did like this... if i in the first map choose random FIRST of all players, and i get for example blademaster, i will get blademaster if i pick random first too the next time i play,
or if i use the random integer to just set a integer variable to a number, it will be the same number every game i play...

To prevent that, simply test the map, quit the game, save the map, close WE, open WE, open your map, test again.
 
Level 9
Joined
Oct 17, 2009
Messages
370
OFFTOPIC WARNING: didnt work, in my map i was using random spawn places for all players when he choosed his hero, like this
event:
A unit enters Herochosen <gen>
condition:
Triggering unit is a hero equal to true
actions:
Set temppoint = random point in playable map area
Move entering unit to temppoint
call Removelocation( temppoint )


I tested alone and the first hero i created was going into a river unable to move (sadly enough but it doesnt matter now) and the second one almost in the middle of the map. the next time i tested it (the next day so i restarted) the first one spawned in the river again and the second one in the middle
 
Level 13
Joined
Aug 31, 2009
Messages
734
There's an option in the editor called "Used Fixed Random Seed". I'm not entirely sure, but I was always told to turn this option off, and I've never encountered this 'same value from a random generator' problem since I turned it off.

It's in the Editor Preferences I think.
 
Top