Page **1** of **1**

### Random Subtraction

Posted:

**Sat Mar 19, 2011 1:09 pm**
by **briggybros**

I'm making a shooting game and all I need to know is how to set the damage (which is a private variable) of the bullet to be randomly chosen between two numbers.

eg. I want my pistol to deal damage anywhere between 1 and 10 how would I do this?

### Re: Random Subtraction

Posted:

**Sat Mar 19, 2011 1:38 pm**
by **DravenX**

Use this at the subtract on your pvt variable

random(10)

Then to keep it from going lower

Compare pvt variable : less or equal to 0 / set pvt variable to 1

### Re: Random Subtraction

Posted:

**Sat Mar 19, 2011 1:41 pm**
by **linkman2004**

You can use the Random(x) expression to get a random number. To get a number within that range, you would subtract from your private variable -- using the subtract from private variable action -- this expression:

Random(10) + 1

One thing to know about the Random(x) expression is that it returns one of x possible numbers, from 0 up to, but not including, x. So Random(10) will return a value in the range of 0-9. Thus, adding 1 to this will bring the minimum up to 1 and the maximum to 10.

### Re: Random Subtraction

Posted:

**Sat Mar 19, 2011 1:53 pm**
by **DravenX**

Aah i forgot about the +1 at the end.