[SOLVED] RPG MAKER MV : HP cost skill customization issue

Hello,

I'm doing a skill dealing damages depending on current HP
I'm using YEP_SkillCore

This is my Skill damage formula and customization added

dmg :
Code:
a.hp+a.atk*3

custom :
Code:
<Custom Requirement>
   if (user.hp > 1) {
     value = true;
   } else {
     value = false;
   }
</Custom Requirement>

<Custom HP Cost>
      cost+= user.hp - 1
</Custom HP Cost>


My skill is working well, it's taking my current HP to deal the damage BUT instead of dealing the damages then losing the HP, it's losing the HP then dealing the damages

if i'm not clear enough :
if i have 200hp left, it should do 199 + atk *3

but since it's losing the HP before the damage calculation, it's doing : 1 + atk*3

any idea on how i could solve this please?

thx 🙂
Fairly certain it's because you're using the damage formula box. When I sought out help to make a skill that converted remaining TP into MP, I was instructed to use Yanfly's Damage Core to set up a custom formula, rather than setting up my formula through the formula box.

It has to do with the order the box will utilize, I think. It'll always apply the skill cost before the actual formula comes into play.
Try this. No guarantee, but it should work in theory:

Code:
<Custom HP Cost>
  user._hpSnapshot = user.hp;
  cost += user.hp - 1
</Custom HP Cost>

<After Eval>
  delete user._hpSnapshot;
</After Eval>

Then, change your damage formula to:

Code:
(a._hpSnapshot || 0) + a.atk * 3
Fairly certain it's because you're using the damage formula box. When I sought out help to make a skill that converted remaining TP into MP, I was instructed to use Yanfly's Damage Core to set up a custom formula, rather than setting up my formula through the formula box.

It has to do with the order the box will utilize, I think. It'll always apply the skill cost before the actual formula comes into play.

I forgot about that, I'll keep that in mind for other skills, thanks 🙂


Try this. No guarantee, but it should work in theory:

Code:
<Custom HP Cost>
  user._hpSnapshot = user.hp;
  cost += user.hp - 1
</Custom HP Cost>

<After Eval>
  delete user._hpSnapshot;
</After Eval>

Then, change your damage formula to:

Code:
(a._hpSnapshot || 0) + a.atk * 3

Works perfectly, thanks a lot !


Thread can be closed.

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.

Original thread: https://forums.rpgmakerweb.com/threads/solved-rpg-maker-mv-hp-cost-skill-customization-issue.117360/