Reduce HP to 1 and convert amount of HP lost into damage applied to enemy

Hello,

I'm trying to create a custom skill that will reduce the user's HP to 1 and convert the lost HP

into damage.

I've attempted to use Yanfly's Skill Core for the HP cost, but the issue is the HP cost happens first,

then the damage calculation is processed.

Here's the example

Damage Formula:

a.hp - 1

HP Cost: 

<Custom HP Cost>

cost = user.hp - 1

</Custom HP Cost>

I was wondering if I can somehow process the damage formula before the HP Cost somehow.

Thank you,

Red
Hello! I havent tested this, but you can give it a try.

Damage formula:

user.hp - 1;

<Cost Display Eval>

var variableId = x;

var value = user.hp - 1;

$gameVariables.setValue(variableId, value);

</Cost Display Eval>

<Custom Cost Display>

\c[18]\v[x] HP\c[0]

</Custom Cost Display>

<Post-Damage Eval>

var value = user.hp - 1;

user.gainHp(-value);

user.startPopupDamage;

</Post-Damage Eval>

Make sure you change variable Id x to any free or temporary variables you use in your project.

Hope that helps! 🙂

- Riff
Hello! I havent tested this, but you can give it a try.

Damage formula:

user.hp - 1;

<Cost Display Eval>

var variableId = x;

var value = user.hp - 1;

$gameVariables.setValue(variableId, value);

</Cost Display Eval>

<Custom Cost Display>

\c[18]\v[x] HP\c[0]

</Custom Cost Display>

<Post-Damage Eval>

var value = user.hp - 1;

user.gainHp(-value);

user.startPopupDamage;

</Post-Damage Eval>

Make sure you change variable Id x to any free or temporary variables you use in your project.

Hope that helps! 🙂

- Riff
That worked perfectly thanks for the help out!
I've moved this thread to JS Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/reduce-hp-to-1-and-convert-amount-of-hp-lost-into-damage-applied-to-enemy.55097/