- Joined
- Jul 21, 2019
- Messages
- 100
- Reaction score
- 23
- First Language
- English
- Primarily Uses
- RMMV
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:
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:
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?
Code:
m = Math.min(a.mat - b.mdf * 2, b.mp); a.gainMp(m); b.gainMp(-m); a.atk * 6 - b.def * 2
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

