OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: SEAL84 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:
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.
-
try this out...
_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
?(_num == 0): your commands here
?(_num == 1): your commands here
?(_num == 2): your commands here
.........
.......
.....
and so on...
-
Works perfectly. Thanks.