Hello everybody!
I was trying to make a skill that uses 1/8 of your MP to transfer damage based on 1/8 of the target's MP but if you have less than 1/8 MP it will use what's left of your MP for an equivalent damage of that MP.
The MP cost gave me trouble but eventually I made it work, but right now I have trouble with the formula because when I cast it with less than 1/8 MP it does nothing. I realized that for some reason the script calculates the MP I have after already consuming the MP, so it uses 0 and that's why it does nothing.
How do I make it use what's left of my MP?
I was trying to make a skill that uses 1/8 of your MP to transfer damage based on 1/8 of the target's MP but if you have less than 1/8 MP it will use what's left of your MP for an equivalent damage of that MP.
The MP cost gave me trouble but eventually I made it work, but right now I have trouble with the formula because when I cast it with less than 1/8 MP it does nothing. I realized that for some reason the script calculates the MP I have after already consuming the MP, so it uses 0 and that's why it does nothing.
How do I make it use what's left of my MP?
<Custom MP Cost>
cost = Math.floor(user.mmp / 8);
if (user.mp < Math.floor(user.mmp / 8)) {
var RemainingMp = user.mp
cost = RemainingMp
}
</Custom MP Cost>
<Damage Formula>
value = target.mmp / 8
if (user.mp < Math.floor(user.mmp / 8)) {
var RemainingMpValue = user.mp / user.mmp
value = target.mmp * RemainingMpValue
}
</Damage Formula>
cost = Math.floor(user.mmp / 8);
if (user.mp < Math.floor(user.mmp / 8)) {
var RemainingMp = user.mp
cost = RemainingMp
}
</Custom MP Cost>
<Damage Formula>
value = target.mmp / 8
if (user.mp < Math.floor(user.mmp / 8)) {
var RemainingMpValue = user.mp / user.mmp
value = target.mmp * RemainingMpValue
}
</Damage Formula>