YesNoOk
avatar

Random damage within a range? (Read 2623 times)

Started by Bloodly, June 16, 2017, 02:14:37 am
Share this topic:
Random damage within a range?
#1  June 16, 2017, 02:14:37 am
  • avatar
  • ***
  • Foolish, but learning.
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.
Re: Random damage within a range?
#2  June 16, 2017, 02:49:34 am
  • ****
  • Vs Style Debuts Tag Project CEO
  • The Dark Wolf Returns
    • USA
Are you trying to make an attack not deal the same amount of damage all the time?
Beware the Dark Wolf once more!
Re: Random damage within a range?
#3  June 16, 2017, 03:01:11 am
  • avatar
  • ***
  • Foolish, but learning.
Yes.
\"So you have chosen....death.\"-Saruman.
Re: Random damage within a range?
#4  June 16, 2017, 03:13:27 am
  • ******
    • www.justnopoint.com/
Damage =1+random%100
Re: Random damage within a range?
#5  June 16, 2017, 03:43:09 am
  • avatar
  • ***
  • Foolish, but learning.
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.
Last Edit: June 16, 2017, 04:28:33 am by Bloodly
Re: Random damage within a range?
#6  June 16, 2017, 04:30:31 am
  • ******
    • www.justnopoint.com/
What range do you want?

86+random%14 This makes the lowest possible 86 and the highest 100
Re: Random damage within a range?
#7  June 16, 2017, 06:42:50 am
  • avatar
  • ***
  • Foolish, but learning.
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.
Re: Random damage within a range?
#8  June 16, 2017, 11:12:37 am
  • *****
  • Shame on you!
    • USA
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 Ryuko718 Updated 10/31/22 vVv
Re: Random damage within a range?
#9  June 16, 2017, 04:34:31 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
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