Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Random (RND) Command Question

Author
Message
Rwilson
21
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 28th Jul 2003 19:10
I am trying to use the random command in the following question
MaxDamage=25
MinDamage=50
Damage=rnd(MaxDamage to MinDamage)
PlayerHealth=PlayerHealth-Damage

My question is, what do I use in the Rnd command to define both a low and high range. I know it's not To, since the compiler refuses to compile the program, so what is it? And if the the rnd command cannot have a low range defined, How could I go about doing so?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 28th Jul 2003 19:32
just do this

lowest=10
highest=100
value=highest-lowest
number=rnd(value)
final_number=number+lowest

since rnd in DB just gives a number from 0 to the number in the brackets, if you want a (almost) truly random number then do

randomise timer()

before you use rnd, otherwise you get the same sequence of numbers every time (which is useful if you want a level to play the same every time so the player can learn it rather than get wiped at random)

Mentor.

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 28th Jul 2003 19:33
You want something like :




Its better than a poke in the eye...

Login to post a reply

Server time is: 2024-09-20 17:37:37
Your offset time is: 2024-09-20 17:37:37