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

MoltresRider

Moltres Rider/Dragon Whisperer
Regular
Joined
Apr 16, 2023
Messages
433
Reaction score
68
First Language
English
Primarily Uses
RMVXA
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)
Regular
Joined
Apr 12, 2020
Messages
826
Reaction score
1,298
First Language
German
Primarily Uses
RMMV
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
Regular
Joined
Apr 16, 2023
Messages
433
Reaction score
68
First Language
English
Primarily Uses
RMVXA
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
Regular
Joined
Sep 20, 2021
Messages
2,227
Reaction score
1,643
First Language
English
Primarily Uses
RMMV
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)
Regular
Joined
Apr 12, 2020
Messages
826
Reaction score
1,298
First Language
German
Primarily Uses
RMMV
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
Regular
Joined
Apr 16, 2023
Messages
433
Reaction score
68
First Language
English
Primarily Uses
RMVXA
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
Regular
Joined
May 22, 2016
Messages
5,230
Reaction score
1,560
First Language
English
Primarily Uses
RMVXA
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
Regular
Joined
Nov 17, 2019
Messages
1,892
Reaction score
961
First Language
English
Primarily Uses
RMXP
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)
Regular
Joined
Apr 12, 2020
Messages
826
Reaction score
1,298
First Language
German
Primarily Uses
RMMV
@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
Regular
Joined
Nov 17, 2019
Messages
1,892
Reaction score
961
First Language
English
Primarily Uses
RMXP
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
Regular
Joined
Apr 16, 2023
Messages
433
Reaction score
68
First Language
English
Primarily Uses
RMVXA
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)
Regular
Joined
Apr 12, 2020
Messages
826
Reaction score
1,298
First Language
German
Primarily Uses
RMMV
@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.
 

ScorchedGround

Blizzards most disappointed fan (They keep going)
Regular
Joined
Apr 12, 2020
Messages
826
Reaction score
1,298
First Language
German
Primarily Uses
RMMV
@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
Regular
Joined
Nov 17, 2019
Messages
1,892
Reaction score
961
First Language
English
Primarily Uses
RMXP
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
Regular
Joined
Apr 16, 2023
Messages
433
Reaction score
68
First Language
English
Primarily Uses
RMVXA
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 Threads

Latest Posts

Latest Profile Posts

Mike Final Breaker.png
that time I drew Mike doing Hugo from Street Fighter 3's Shootdown Backbreaker...
So I was thinking about putting in Weapon Synthesis like the Cooking system I got going but after all these recipes I've been putting in the item log and common events for the past week and a half I'ma say no on that one chief

those shops and chests are working just fine lmao
Just watched Godzilla Minus One.
As a Godzilla fan, I loved it. Acting was a little rough, and I thought the ending was cheap, but overall, great!
Could have used more plot.
Plot. I demand more fanservice!
giphy-downsized.gif
I should do a Photoshop with "Everyone Loves Reimond" and just stick Rei in the middle where Raymond's face would be.
Non-rare second status post but we closed the Third and Final Cameo Battle
Reveal_3&4_F.png

Forum statistics

Threads
136,637
Messages
1,268,272
Members
180,322
Latest member
ArcanaDev
Top