| 10-31-2004, 09:17 PM | #1 |
hi. a quick question. if i use the random integer in 3 places in the same trigger. Does it use the same number or does it make up a new one each time? atm i want it to randomly create 3 diffrent units depending on the number if (random integer number between 1 and 100) > 66) then create fire guardian else if random integer number between 1 and 100) > 33) then create ice guardian else create lightning guardian |
| 10-31-2004, 09:32 PM | #2 |
If you want to have it be the same random number you have to make a interger varible and set it to a random # and use the varible in place of were you have random numbers in your trigger. Right now its using a new random number each time you use (random number between 1 and 100) |
| 11-01-2004, 02:10 AM | #3 |
Instead of creating a totally new Global, just use Local Variables. My mind has been plagued with VB and VBS so I don't know how to declare Locals in JASS. Sorry. =[ |
| 11-01-2004, 06:48 AM | #4 |
yeah i figured it out. I came to think of a way to do it without making a variable. if(random integer number between 1 and 100 > 66) then create fire guardian else if(random integer number between 1 and 100 > 50) then create ice guardian else create lightning guardian since it makes a new number on the "else if", this should give the same results as declearing a variable |
| 11-01-2004, 11:59 AM | #5 |
Else ifs work in JASS? |
| 11-01-2004, 08:09 PM | #6 |
only without a space elseif not else if and declaring locals is local <variable type> <variable name> |
| 11-01-2004, 10:50 PM | #7 |
That seems rather inconvenient. Why not rewrite the trigger like this instead? (And I'm typing this off the top of my head) Make an integer variable called RandomUnit. Event - Periodic Event (Every __ seconds) Conditions - None OR a check of how units are alive owned by player. Action: Set Variable (RandomUnit) = (Math - Random number between 1 and 100) And the rest of it, just put in ifs like.. sample would be If (Randomunit) = X (put your own number) then create 1 Blah unit for player (BLAH) at random location or wutever u want. Its more efficient than to continue making random variables. |
