Home   Help Search Login Register  

Author Topic: Random X and if/then  (Read 381 times)

0 Members and 1 Guest are viewing this topic.

Offline SEAL84

  • Members
  • *
  • Always lurking
Random X and if/then
« on: 27 Apr 2004, 01:40:52 »
So I have a guy I want to have run and hide, and I've picked several spots out where he'd (hopefully) be safe.  I'd like to randomize which spot he picks and I think I can do this with a randomized number feature, but I'm not sure how to set up the syntax properly.

Something like this:
Code: [Select]
if (x >= 0 and X < .1) then (guy move getpos spot 1)
if (x >= .1 and X < .2) then (guy move getpos spot 2)
so on and so forth through "spot 9"

where the range that the randomly generated number falls into determines where he goes.

'Cept obviously I don't know how to do it properly.

Could somebody show me how this would work?

And another thing....does anybody how many decimal places does OFP carry randomly generated numbers out to?  IE 1.4, 1.456, 1.4298234. etc.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Random X and if/then
« Reply #1 on: 27 Apr 2004, 01:48:19 »
try this out...

Code: [Select]
_rand = random 10
_num = _rand - (_rand mod 1)

the first line should give a random number between 0 and 10.
Second line should modify the number to no decimals.

you might have to play around but this code should work in general

:edit:
uhm...forgot to answer to the rest...
so, by using the above you just can make it look like this

Code: [Select]
?(_num == 0): your commands here
?(_num == 1): your commands here
?(_num == 2): your commands here
.........
.......
.....
and so on...
« Last Edit: 27 Apr 2004, 04:18:17 by myke13021 »

Offline SEAL84

  • Members
  • *
  • Always lurking
Re:Random X and if/then
« Reply #2 on: 27 Apr 2004, 23:22:43 »
Works perfectly.  Thanks.