Home   Help Search Login Register  

Author Topic: Random explosions at predefined places  (Read 1031 times)

0 Members and 1 Guest are viewing this topic.

seanver

  • Guest
Random explosions at predefined places
« on: 22 Sep 2002, 20:56:22 »
I'm making (or trying to make) a script to create random explosions at predefined game logics. The code is this:

Code: [Select]
#loop
_ran = random 8

? (_ran == 1) : goto "one"
? (_ran == 2) : goto "two"
? (_ran == 3) : goto "three"
? (_ran == 4) : goto "four"
? (_ran == 5) : goto "five"
? (_ran == 6) : goto "six"
? (_ran == 7) : goto "seven"
? (_ran == 8) : goto "eight"

#one

bomb = "heat120" camcreate (getpos g1)

goto "end"

#two

bomb2 = "heat120" camcreate (getpos g2)

goto "end"

#three

bomb3 = "heat120" camcreate (getpos g3)

goto "end"

#four

bomb4 = "heat120" camcreate (getpos g4)

goto "end"

#five

bomb5 = "heat120" camcreate (getpos g5)

goto "end"

#six

bomb6 = "heat120" camcreate (getpos g6)

goto "end"

#seven

bomb7 = "heat120" camcreate (getpos g7)

goto "end"

#eight

bomb8 = "heat120" camcreate (getpos g8)

goto "end"

#end

~5

goto "loop"

But it doesn't work. The explosion is always created at the first game logic's position so the conditions with the random number are not working. What's wrong?

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Random explosions at predefined places
« Reply #1 on: 22 Sep 2002, 21:06:53 »
Trouble with a random number is that it could be 3.19583, which is not on your list.  Your script only working if the number is a whole number.  Change the "==" to be equalities.

So this line;

? (_ran == 1) : goto "one"

Should be changed to;

? (_ran <= 1) : goto "one"

And this line;

? (_ran == 2) : goto "two"

Should be;

? (_ran <= 2) : goto "two"

And so on.  This way, if the number randomly chosen is 0.384, which is less than 1, it goes to "one".  If the number is 1.381 then this isnt less than 1, so it goes to the next line which it realises it less than 2, so it goes to "two"


seanver

  • Guest
Re:Random explosions at predefined places
« Reply #2 on: 22 Sep 2002, 21:24:03 »
Thanks now it worked. And now that issue of the random numbers explains why I never could do anything with that command  :-[