• 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.

[Trigger] Not so random..

Status
Not open for further replies.
Level 5
Joined
Sep 13, 2008
Messages
165
I'm making a short easy trigger that creates a random unit that then is assigned to a player through variables. I HAVE FIXED RANDOM SEED OFF.
UnitType[1] = Footman
UnitType[2] = Knight
UnitType[3] = Rifleman
UnitType[4] = Priest
However it isn't so random, the trigger always creates.
Player1 gets Rifleman
Player2 gets Priest
Player3 gets Rifleman
Player4 gets Priest
ALWAYS. So i them limited the range to random number between 1 and 2
and then all the players got Knights, not one footman.

Originally i had a trigger that created a unit one by one assigned to a player, but i decided i could create a loop to do that. So i did

  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • Set Point = (Center of Player Spawn <gen>)
      • Unit - Create 1 UnitType[(Random integer number between 1 and 4)] for (Player((Integer A))) at Point facing 90.00 degrees
      • Set HeroID[(Integer A)] = (Last created unit)
      • Set Point = (Center of CimMoveRegion[(Integer A)])
      • Unit - Order (Last created unit) to Move To Point
      • Wait 0.50 seconds
But when i did that, it only created a rifleman for player 1, not the rest.

So i want to make this random unit spawn more random.. and make the units for players 2,3 and 4 spawn.
 
Level 5
Joined
Sep 13, 2008
Messages
165
I have Fixed Random Seed turned off, so that isn't the problem.
The Leak gets cleaned up after the loop and that random unit for unit group isn't necessary

So i played around and copied and pasted the trigger twice (for a total of three) and then it creates.
1 Footman (Player1)
1 Footman (Player1)
1 Knight (Player2)
1 Rifleman (Player3)
1 Priest (Player4)
... whats going on?
 
Level 18
Joined
Sep 27, 2005
Messages
2,069
set 1 = rifleman
set 2 = knight
set 3 = priest
set 4 =knight

set x = random number betwen 1 and 4

condition y = false
if x = 1 then create 1 rifleman for p1
set y = true
else
condition z = true
if x = 2 create 1 knight
set z = true

And do that for all the players till the end using arrays. It would give a player a random unit. The x = true allows that a player can't get the same unit twice
 
Level 5
Joined
Sep 13, 2008
Messages
165
...
I don't care about leaks, if I did, the title will be called 'Leaks! Help me solve them' >.> but it isn't. I don't care if two people get the same unit either.
I want to solve this random thing. I read up on another person who has had this problem, and he said he turned off cinematic mode (I didn't tell you it was on because I thought it wasn't a problem), I then tried that, but it still gave out the same order of units.
 
Level 3
Joined
Jun 6, 2007
Messages
48
Would something like this be what you're looking for?:

  • Roulette
    • Set u[1] = Footman
    • Set u[2] = Knight
    • Set u[3] = Rifleman
    • Set u[4] = Priest
    • Set x = (Random integer number between 1 and 4)
    • For each (Integer A) from 1 to (Number of players), do (Actions)
      • Loop - Actions
        • Unit - Create 1 u[x] for (Player((Integer A))) at Point facing 90.00
 
Level 1
Joined
Nov 22, 2008
Messages
7
I had the same problem which I was about to post.

In world editor, go to File->Preferences
Go to the Test Map tab
Uncheck "use fixed random seed"

This fixed my problem.
 
Level 5
Joined
Sep 13, 2008
Messages
165
@ darkrider and PaulSchnider: The thing is, if you read my first post, its already off.
@ Xzalious: Ive already got the Footman, Knight, etc. set, and my trigger just re-randomizes the number each loop, however i will try to set the 'x' to a random number then make the trigger spawn 1 Unit[x]

EDIT: ok, it doesn't work. all it did was change the types of units that spawned for each player (It worked, only once but).
 
Last edited:
Status
Not open for further replies.
Top