RPG Maker Forums

Hi there! I'm making a skill that drains HP and MP at the same time, which is requiring me to use a somewhat complex equation. For now the formula is marked as HP Drain in the dropdown box, and has this formula:

Code:
m = Math.min(a.mat - b.mdf * 2, b.mp); a.gainMp(m); b.gainMp(-m); a.atk * 6 - b.def * 2
It does drain both correctly, the one problem I'm having is that the variance on the skill only applies to the HP drain part of the formula. Is there a way to put in a variance for the MP Drain as part of the formula?

For example, without variance, a given use of the Skill does exactly 24 MP Drain. I want it to instead have a 20% variance and do between 20 and 27 MP Drain. I tried using math formulas to do it, but since the formula only seems to handle integers, I tried multiplying the percent variance by 100 and then divide the whole thing by 100 afterward. It ended up looking like this:

Code:
m = Math.round((Math.min((a.mat - b.mdf * 2) * (Math.floor(Math.random() * 140) + 80)) / 100, b.mp)); a.gainMp(m); b.gainMp(-m); a.atk * 6 - b.def * 2
For the example given above, instead of landing between 20 and 27 like I want, it does 184 without any variance. So either my math is way off, or I'm not using the formulas correctly. Could anyone help me with this?

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top