# Formula for random MP recovery between 100-1000 but only in the values of 100, 500, 750, and 1000

#### MoltresRider

##### Moltres Rider/Dragon Whisperer
I want to create an item that recovers a random amount of MP ranging from 100 to 1000. However, I only want the numbers 100, 500, 750, and 1000 to be generated and nothing in between.

I know how to use rand. However, if I set up my formula like this: "(rand(1000) + 100)", I could get numbers like 350, 800, 643, 146, 250, 887, the list goes on. I just want 100, 500, 750, and 1000.

100-1000 is the betting amount at The 2020 is Vegas Stakes for SNES and NPCs at the Poker table there use 100, 500, 750, and 1000 and I want this item to be a homage to that.

Also, the world in my game where this item is obtained from, is very RNG based as other items from this world rely on RNG.

Is there a way to set up a formula using rand to make sure only 100, 500, 750, and 1000 are generated?

I am already aware that I would need variance 0.

#### ScorchedGround

##### Blizzards most disappointed fan (They keep going)
Going with the basic 'damage formula' approach, you could use this:
(put this directly into the damage formula)

JavaScript:
``var a = [100,500,750,1000]; a[Math.floor(Math.random()*a.length)];``

Edit: Oh sorry, I just saw that this is for VXAce, so the syntax would be different.

Edit 2: So after a quick research on ruby, maybe this works for you?
Ruby:
``[100,500,750,1000].sample``

Last edited:

#### MoltresRider

##### Moltres Rider/Dragon Whisperer
Why do so many people on this forums fail to pay attention to what board that they are responding to? I see this a lot on here.

What is the VX Ace version of that?

[100,500,750,1000].sample
I believe that ruby needs "rand" somewhere in there for randomness.

#### AquaEcho

##### Script Kitty
Why do so many people on this forums fail to pay attention to what board that they are responding to? I see this a lot on here.
Even if he posted the wrong language the programming concept is correct and it wouldn't be hard to look up the Ruby version of that Javascript snippet.

#### ScorchedGround

##### Blizzards most disappointed fan (They keep going)
Well did you test it ?

I quickly put this into a test project in vxace and it worked for me in a battle test.

#### MoltresRider

##### Moltres Rider/Dragon Whisperer
Well did you test it ?

I quickly put this into a test project in vxace and it worked for me in a battle test.
No I have not and I apologize. I am trying to do five things at once including RPG Maker. I am also helping a friend with something so I am very hasty right now.

#### Roninator2

##### Gamer
ScorchedGround is correct with the basic method for doing what you want.
The only thing is how are you using this?
Is it in a script or an event?
using a variable and use the script function for it you can do exactly what ScorchedGround said.
[100,500,750,1000].sample

#### kyonides

##### Reforged is laughable
I think this is what the flying bird was actually expecting to get from you guys:

Ruby:
``````list = [1, 25, 43,100]
list[rand(list.size)]``````

list.sample seems to do the same job there. This might mean that it's just a wrapper method that simplify things for working with Arrays in Ruby.

#### ScorchedGround

##### Blizzards most disappointed fan (They keep going)
@kyonides
That's probably the more clean and proper method.

But I just thought that for the sake jamming it into a damage formula, something more short and basic might work better.

#### kyonides

##### Reforged is laughable
I wouldn't deny that but few people are used to Array#sample method so it's not really that intuitive for game devs as one would expect.

#### MoltresRider

##### Moltres Rider/Dragon Whisperer
Edit 2: So after a quick research on ruby, maybe this works for you?
Ruby:
``[100,500,750,1000].sample``

Now what if I want to combine something like that with something more?

What if I wanted 50, 250, 375, 500 as the sample but I want to factor in a.mat and b.mdf in there?

Would I need to do something like?:
[50,250,375,300].sample + a.mat * 3 - b.mdf * 1.7?
What if I wanted the sample as a multiplier? Is this right?:
[1,5,7,10].sample * a.mat - b.mdf * (rand(5) + 1)
What about a sample and mat multiplier together? Is this right?
([20,100,150,200].sample + a.mat) * 3 - b.mdf * 2

Will any of these work? or do I need to format these formulas differently to achieve what I want?

#### ScorchedGround

##### Blizzards most disappointed fan (They keep going)
@MoltresRider

That should work since something like [50,250,375,300].sample returns a numeric value just as something like a.atk*2 would.
If you find some time for testing, you can just try out different formulas yourself and look if the math checks out.

I mean if you want even more randomness, or more delicate randomness, you could for example also combine two different sample structures:

[50,250,375,300].sample * [0.5, 1, 1.25, 1.5, 2].sample

In this example you take a random base value and multiply it by a random modifier.

#### MoltresRider

##### Moltres Rider/Dragon Whisperer
([20,100,150,200].sample + a.mat) * 3 - b.mdf * 2
My main concern now is if the parenthesis are right for this one.

#### ScorchedGround

##### Blizzards most disappointed fan (They keep going)
@MoltresRider

I mean it looks fine syntaxically, so it really depends on whether or not this how you want
the formula to play out.

#### kyonides

##### Reforged is laughable
As you know now, sample will return a single value. This means that it would get summed up to that addition before being multiplied by 3 and then getting subtracted whatever the double of MDF actually is.

#### MoltresRider

##### Moltres Rider/Dragon Whisperer
As you know now, sample will return a single value. This means that it would get summed up to that addition before being multiplied by 3 and then getting subtracted whatever the double of MDF actually is.
Which can offset a weaker character who cannot do much damage. It allows for him to actually contribute.

Also it could be used as a boss ultimate move.

Say, MAT is 150 and the sample returns a 200, it acts as his MAT is 350 as I was intending.

### Latest Profile Posts

Looooooonnnnggg maaaaannnnn
Yknow what? Im seriously considering recruiting a manager to oversee my games development.
Because I cannot focus or complete these tasks by myself. I need someone to give me orders, without having them be my boss.

Remember my latest plugin for rpg maker mz:

Acknowledgement Window is now available!

Take a look here:

Got my focus back, 9/59 maps have the door fix in place now.
Making a small RMMV project has made me realize that I've never actually made a credits sequence for a game.