Deal Damage based on HP Consumption?

Hi guys,

Started using MV for the first time in a while, and I was wondering how I could set up the following HP Cost skill.
  • Cost is the user's current HP - 1
  • You must have more than 1 HP to use it
  • The damage inflicted to enemies increases based on the amount of HP consumed
Using Yanfly's Skill Core:
Code:
<Custom Requirement>
value = user.hp > 1;
</Custom Requirement>

<Cost Display Eval>
user.hpLost = user.hp - 1;
</Cost Display Eval>

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

Then you just use a.hpLost in your damage formula.
Using Yanfly's Skill Core:
Code:
<Custom Requirement>
value = user.hp > 1;
</Custom Requirement>

<Cost Display Eval>
user.hpLost = user.hp - 1;
</Cost Display Eval>

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

Then you just use a.hpLost in your damage formula.
It worked, thank you very much! Now I'm trying to do something similar with MP instead of HP. I tried doing it the same way as the last one, but the skill isn't doing any damage.
You would have to actually show us what you've done.
You would have to actually show us what you've done.
Here are my notetags for the skill:
JavaScript:
<Custom Requirement>
value = user.mp > 75;
</Custom Requirement>

<Custom HP Cost>
cost = user.mp;
</Custom HP Cost>

And I have a.mp in the damage formula. But when I use the skill in the battle test, it doesn't deal any damage. My guess is that it's taking the amount of MP after I cast the skill, but it doesn't deal damage even if I add a constant to the formula (i.e. 6000 + a.mp).
Those notetags look weird.

You're making it have an HP cost equal to their MP, but then the requirement to use it is that their MP is greater than 75. So if they use it when their HP is 75 or less, they'd die - that's what you want?

What is the MP cost? What is the entire damage formula? There's too little information to tell you what's going wrong.
Those notetags look weird.

You're making it have an HP cost equal to their MP, but then the requirement to use it is that their MP is greater than 75. So if they use it when their HP is 75 or less, they'd die - that's what you want?

What is the MP cost? What is the entire damage formula? There's too little information to tell you what's going wrong.
Oh, whoops. I forgot to change HP to MP in the cost tag

Anyway, I want to design a skill that consumes all the user's MP as a cost, and the more MP is used, the more damage the move inflicts.

At least, that's the idea, but like I said, it's not dealing any damage in battle testing.

Damage formula:
6000 + a.mp

Notetags:
<Custom Requirement> value = user.mp > 75; </Custom Requirement> <Custom MP Cost> cost = user.mp; </Custom MP Cost>
I don't see any reason why that would do no damage.

But you can't reference the mp in your damage formula after you've just spent it all to pay the cost of the skill.

That's why my first reply to you showed how to create a variable on the actor and reference that variable in your damage formula.
I don't see any reason why that would do no damage.

But you can't reference the mp in your damage formula after you've just spent it all to pay the cost of the skill.

That's why my first reply to you showed how to create a variable on the actor and reference that variable in your damage formula.
I didn't quite realize how that worked before, but it works now. Thanks! Didn't quite realize how that worked before.

I just thought you had to include the word "var" before declaring the name of the variable, but it looks like you can just stick the name of the variable in the notetags to initialize it, and then you can use that variable in the damage formula. Have I got that right?
You use var (which is one of several possible terms) to declare a new variable.

In this case, we already have an object - the current battler (referred to as user in the notetag), so we can simply add a property to it. You do not need to use var or any other term to declare a new property, you can just add and use it.

In my first reply to you, I did this via user.hpLost in the custom cost eval, which runs before the cost is actually paid - thus, the value is whatever HP/MP you're looking at before paying costs.

Then it can be referenced in the damage formula later and it still has the pre-cost value.
You use var (which is one of several possible terms) to declare a new variable.

In this case, we already have an object - the current battler (referred to as user in the notetag), so we can simply add a property to it. You do not need to use var or any other term to declare a new property, you can just add and use it.

In my first reply to you, I did this via user.hpLost in the custom cost eval, which runs before the cost is actually paid - thus, the value is whatever HP/MP you're looking at before paying costs.

Then it can be referenced in the damage formula later and it still has the pre-cost value.
I'll try to remember that. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/deal-damage-based-on-hp-consumption.165606/