Random damage within a range?

Started by Bloodly, June 16, 2017, 02:14:37 AM

Previous topic - Next topic

Bloodly

Damage is usually a fixed single value.

damage = 100

If I wanted to make it a random value within a range, what would it look like?

My mind is telling me something along the lines of

damage=rand(1, 100)

But I feel I should check.
\"So you have chosen....death.\"-Saruman.

DarkWolf13

Are you trying to make an attack not deal the same amount of damage all the time?
Beware the Dark Wolf once more!

Bloodly

\"So you have chosen....death.\"-Saruman.

JustNoPoint


Bloodly

#4
Random percentage.  How do you set the minimum and maximum, then?

As I see that bit of code, you're rolling a random percentage between 1% and 100%.  I realise I might be being stupid here.
\"So you have chosen....death.\"-Saruman.

JustNoPoint

What range do you want?

86+random%14 This makes the lowest possible 86 and the highest 100

Bloodly

100 from 14?  Now it makes less sense.

The range is between 10 and 150.  Would the correct formation be

damage=10+random%150

?
\"So you have chosen....death.\"-Saruman.

Odb718

the random%X, the X is the max value that will be made. So 10+150 is a possibility.
You want random%140
Use Mugen Class. JNP didnt make it for shits-n-giggles :P
vVv Gouken718 vVv SabreTooth718 vVv


altoiddealer

random%150 will return a value of 0-149.

To set a range that the lowest value is anything but 0, you will use a number then add the random range to it.

If you want a number between 10 and 150, you'll start with 10 then add a random number from 0-140.

10+random%141