MV Mana Berserker

Hello,

I'm trying to use Yanfly's Berserker example from his tips and tricks video

JavaScript:
<Custom Confirm Effect>
// Check if the damage dealt deals physical HP damage.
if (this.isPhysical() && this.isHpEffect() && value > 0) {
  // Base the bonus damage off of the user's HP rate.
  value *= 2.00 - user.hpRate();
  // Add bonus damage equal to the user's missing HP.
  value += (user.mhp - user.hp) * 0.50;
  // Round up the calculations.
  value = Math.ceil(value);
}
</Custom Confirm Effect>


However I want to make it so the player gains damage based on how low their MP is. I am using Mana Shields, so each hit to the player will reduce MP. I tried using the code below and it doesn't work. Would anyone be able to help me find the correct solution?


JavaScript:
<Custom Confirm Effect>
// Check if the damage dealt is physical and if MP lost is more than 0.
if (this.isPhysical() && this.isMpEffect() && value > 0) {
  // Base the bonus damage off of the user's MP rate.
  value *= 2.00 - user.mpRate();
  // Add bonus damage equal to the user's missing MP.
  value += (user.mmp - user.mp) * 0.50;
  // Round up the calculations.
  value = Math.ceil(value);
}
</Custom Confirm Effect>
I'm not sure how you ended up with tags saying ISPOILER, but you want to use CODE for code, so that it preserves indents and the contents of brackets 😉 (the </> icon)

When you say you're "using Mana Shields," can you explain that more? Is it another plugin, or something you wrote?

I don't know how your mana shields are set up, but I suspect the problem is with the initial conditional:
Code:
if (this.isPhysical() && this.isMpEffect() && value > 0)

the isMpEffect is going to be true if that's the actual setting in the skill in your database, it was selected from the drop-down list to do MP damage. It is most extremely likely that your mana shields do not change that (I'd have to look at the code, that may come from a $data entry and you can't change it) - rather, they'd just reroute the damage to MP someplace in the middle.

So if you can explain how you have your mana shields set up, we should be able to help you configure this state properly.
Sorry about the formatting, I'm using a phone, I'll try to clean that up when I'm on my PC

I'm using Alastair's AP mana shield https://alistairengine.wordpress.com/2015/11/01/alistair-plugins-mana-shield/

I guess thinking about it bit more, maybe I don't need it to work exactly with Mana Shields

I can try looking at that condition.

I guess maybe I just need to compare current mp vs max mp, maybe not pass a value into there.
I listened to what you said about the condition. I changed it to the following and this seems to be working now for me:



JavaScript:
<Custom Confirm Effect>

// Check if the attack is physical or magical.

if (this.isPhysical() || this.isMagical()) {

  // Base the bonus damage off of the user's MP rate.

  value *= 2.00 - user.mpRate();

  // Add bonus damage equal to the user's missing MP.

  value += (user.mmp - user.mp) * 0.50;

  // Round up the calculations.

  value = Math.ceil(value);

}

</Custom Confirm Effect>

This seems to work from what I can see with my brief testing. Would there be any problems with using "(this.isPhysical() || this.isMagical()" ? Or is there a better condition?
This seems to work from what I can see with my brief testing. Would there be any problems with using "(this.isPhysical() || this.isMagical()" ? Or is there a better condition?
Well, do you have any enemy skills that are set to Certain Hit? It would cause your state to not trigger then.

I should think you'd want it to go off any time they're taking damage, in which case you'd do simply
if (this.isDamage())
That seems to work perfectly, I was also able to add "&& value > 0" back to the condition and it works!


JavaScript:
<Custom Confirm Effect>

// Check if damage is dealt.

if (this.isDamage() && value > 0) {

  // Base the bonus damage off of the user's HP rate.

  value *= 2.00 - user.mpRate();

  // Add bonus damage equal to the user's missing HP.

  value += (user.mmp - user.mp) * 0.50;

  // Round up the calculations.

  value = Math.ceil(value);

}

</Custom Confirm Effect>


Thank you very much for your help!
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/mana-berserker.142217/