• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

random integer number (detecting that number)

Status
Not open for further replies.
Level 4
Joined
Oct 15, 2008
Messages
77
Would it be possible to detect what integer was selected? say if i have 4 types of building, and 4 types of research/tech centers to go along with that building. is there any way to detect what integer the computer has chosen so i can create the allocating research/tech centers along with said randomly chosen building?
 
Level 25
Joined
Jun 5, 2008
Messages
2,573
You could store the value of the integer in a temporary second integer like:
  • Set *your integer* = random values from 1 to 4
  • Set Temp_integer[x] = *your integer value*
Then just check the value of Temp_integer[x] and that is that.
Suggestion: you can put the [x] value to something like Player number or anything that won't get overwritten the next time you check the value.
If anybody got a better suggestion give him.
 
Level 4
Joined
Oct 15, 2008
Messages
77
just exactly how do you do that though, that's what im asking :) i mean like how would the trigger look

basically im running things off from dialogs. 5 seconds into the game a dialog shows to select a race theres 5 diaglons
random
human
orc
undead
night elf

for each of those races there is a tech center

20 seconds into the game if u dont select a race, a random race will be selected for you. what im trying to do is to get the right tech center to be place on the map when u select random. or the random race is selected for you.


EDIT:
wait i think i got it. so like this?
  • random race team 1
    • Events
      • Dialog - A dialog button is clicked for race_select_dialog
    • Conditions
      • (Clicked dialog button) Equal to random_race_select_button
      • Or - Any (Conditions) are true
        • Conditions
          • (Triggering player) Equal to Player 1 (Red)
          • (Triggering player) Equal to Player 2 (Blue)
          • (Triggering player) Equal to Player 3 (Teal)
          • (Triggering player) Equal to Player 4 (Purple)
          • (Triggering player) Equal to Player 5 (Yellow)
          • (Triggering player) Equal to Player 6 (Orange)
    • Actions
      • Set random = (Random integer number between 1 and 4)
      • Set Random_tech[1] = Blacksmith
      • Set Random_tech[2] = War Mill
      • Set Random_tech[3] = Graveyard
      • Set Random_tech[4] = Hunter's Hall
      • For each (Integer A) from (random + 1) to 4, do (Actions)
        • Loop - Actions
          • Unit - Create 1 random_race[(Integer A)] for (Triggering player) at (starting_location[(Player number of (Triggering player))] offset by (-400.00, 0.00)) facing Default building facing (270.0) degrees
          • Unit - Create 1 Random_tech[(Integer A)] for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing (270.0) degrees
 
Last edited by a moderator:
Level 12
Joined
Apr 15, 2008
Messages
1,063
  • For each (Integer A) from (random + 1) to 4, do (Actions)
    • Loop - Actions
      • Unit - Create 1 random_race[(Integer A)] for (Triggering player) at (starting_location[(Player number of (Triggering player))] offset by (-400.00, 0.00)) facing Default building facing (270.0) degrees
      • Unit - Create 1 Random_tech[(Integer A)] for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing (270.0) degrees
this part is wrong, it shoul be just
  • Unit - Create 1 random_race[random] for (Triggering player) at (starting_location[(Player number of (Triggering player))] offset by (-400.00, 0.00)) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_tech[random] for (Triggering player) at (Center of (Playable map area)) facing Default building facing (270.0) degrees
Also, you should change the position of the tech center, it now spawns at Centre of map, which is propably wrong.
And the Random_tech array should be initialised somwhere else, maybe at the same place as the random_race array.
The trigger leaks like this (the position), but since it's one-time trigger, you can let it be
 
Level 4
Joined
Oct 15, 2008
Messages
77
yea morte. i was just throwing all that out there and eventually lastnight i figured out i didnt need the for each integer A or anything.i just set my own random number variable so i didnt need to loop. thanks though!

+rep
 
Status
Not open for further replies.
Top