• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Random Button

Status
Not open for further replies.
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 7
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 19
Joined
Feb 25, 2009
Messages
2,004
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 14
Joined
Aug 31, 2009
Messages
774
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.
 
Status
Not open for further replies.
Top