OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Artak on 03 Jan 2003, 13:09:31

Title: random in between
Post by: Artak on 03 Jan 2003, 13:09:31
Hello folks!

I'm trying to make some randomnes to a mission.

Got some weapon crates I want to move randomly from place a to b or even c.

Now I need to know how to state numbers in between.. umm.. like this

?_wpnrnd3 > 34 <= 66: goto "weaponry3place2"

if a random 100 _wpnrnd3 is bigger than 34 but smaller than 66 then.. blah blah.. what's the syntax to use in that?!?

Here's the whole thing to get 1 random place out of 3


;random VC weapon placement

_wpnrnd1 = random 100
_wpnrnd2 = random 100
_wpnrnd3 = random 100

;----------------------------------------

#weaponry1
?_wpnrnd1 =< 33: goto "weaponry1place1"
;?_wpnrnd1 > 34 <= 66: goto "weaponry1place2"
?_wpnrnd1 > 67: goto "weaponry1place3"

#weaponry2
?_wpnrnd2 =< 33: goto "weaponry2place1"
;?_wpnrnd2 > 34 <= 66: goto "weaponry2place2"
?_wpnrnd2 > 67: goto "weaponry2place3"

#weaponry3
?_wpnrnd3 =< 33: goto "weaponry3place1"
;?_wpnrnd3 > 34 <= 66: goto "weaponry3place2"
?_wpnrnd3 > 67: goto "weaponry3place3"

;-----------------------------------------

#weaponry1place1
crate1 setpos [10211.68,6421.76,0.1]
crate2 setpos [10211.68,6424.39,0.1]
goto "weaponry2"

........ and this continues like this.


I'd also like to know if random 3 includes 0. It would be so much easier to use random 3 instead of 100 because I could state

?_wpnrnd1 == 1 ....
?_wpnrnd2 == 2 ....
?_wpnrnd3 == 3 ....


Thanks in advance  ;)
Title: Re:random in between
Post by: Black_Feather on 03 Jan 2003, 13:34:12
I think you can get 0 with random so try that, but you could try this

;random VC weapon placement

_wpnrnd1 = random 100
_wpnrnd2 = random 100
_wpnrnd3 = random 100

;----------------------------------------

#weaponry1
?_wpnrnd1 =< 33: goto "weaponry1place1"
?_wpnrnd1 > 67: goto "weaponry1place3"
#weaponry1place2
crate1 setpos [10211.68,6421.76,0.1]
crate2 setpos [10211.68,6424.39,0.1]
goto "weaponry2"


#weaponry2
?_wpnrnd2 =< 33: goto "weaponry2place1"
?_wpnrnd2 > 67: goto "weaponry2place3"
#weaponry2place2
crate1 setpos [10211.68,6421.76,0.1]
crate2 setpos [10211.68,6424.39,0.1]
goto "weaponry3"


#weaponry3
?_wpnrnd3 =< 33: goto "weaponry3place1"
?_wpnrnd3 > 67: goto "weaponry3place3"
#weaponry3place2
crate1 setpos [10211.68,6421.76,0.1]
crate2 setpos [10211.68,6424.39,0.1]
exit
;-----------------------------------------

#weaponry1place1
crate1 setpos [10211.68,6421.76,0.1]
crate2 setpos [10211.68,6424.39,0.1]
goto "weaponry2"

........ and this continues like this.


because if a number isn't <33 and it isn't >66 it must be between 34 & 65 so it will go through the loop and set the crate in weapon place 2.

Here's a way to round numbers though

_number = Random 10
? ((_number mod 1) >= 0.5): _number = _number + 1
_number = _number - (_number mod 1)

taught to me by Sui long ago
Title: Re:random in between
Post by: Artak on 03 Jan 2003, 15:43:47
Excellent!  :D

Thank you very much Black_Feather  :-*