Trouble with healing formula

Status
Not open for further replies.

Sword_of_Dusk

Keyblade Master
Veteran
Joined
Sep 13, 2015
Messages
247
Reaction score
290
First Language
English
Primarily Uses
RMMV
My problem is a simple one. I want my healing spell to work within a certain range. To be specific, I want it to heal between 35-45 HP a cast. I currently have the formula set as the following:

Math.randomInt(45)+35

This is not working as intended, however. I've seen healing numbers go beyond my desired limit of 45. Does anyone know where I've gone wrong?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,602
First Language
English
Primarily Uses
RMMV
Well, you're saying take a random number between 0 and 45, and add 35 to it. So if the random number happens to be 40, you're going to get 75.

Math.randomInt(11) will give you a number between 0 and 10,
so Math.randomInt(11) + 35 will give you a number between 35 (35 + 0) and 45 (35 + 10)


However ... can't you just set the damage to 40, with a variance of 5?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,497
First Language
Indonesian
Primarily Uses
RMVXA
Use shaz's solution above then set variance to 0
 

Sword_of_Dusk

Keyblade Master
Veteran
Joined
Sep 13, 2015
Messages
247
Reaction score
290
First Language
English
Primarily Uses
RMMV
Shaz, your formula worked. Had a feeling I was ignoring something obvious.

And yeah, I probably could've just relied on the variance, but I wanted to make absolutely sure. Anyway, can an admin close this thread when they get the chance?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,602
First Language
English
Primarily Uses
RMMV
If your question is resolved, just report your first post and ask the mods to close the thread.
 

Sword_of_Dusk

Keyblade Master
Veteran
Joined
Sep 13, 2015
Messages
247
Reaction score
290
First Language
English
Primarily Uses
RMMV
So that's how you do it. Thanks again, Shaz.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,610
Reaction score
5,153
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I'm a bit conflicted. One the one hand, it's quite visually cool to make bodies of water that the player can interact with by going into it. However obscuring the player character from a gameplay perspective is pretty bad. Hmm... There's the option to make the area around the player visible, but then that kind of defeats the purpose of submerging them. :unsure:
Stream will be live shortly with some Darkest Dungeon! Feel free to drop by!
Another two plugins done! One being an on map grid inventory.
busy with my newborn child, can't even touch pc at all ;_;
Make a Game in RPG Maker MZ: Episode 6 Starts NOW! Let's map some caves!

Forum statistics

Threads
104,295
Messages
1,005,352
Members
135,811
Latest member
napax
Top