Im trying to make it so if my MP hits 0 the HP goes down but idk how

Im trying to make it so if my MP hits 0 the HP goes down by a specific amount (not percent) but I cant think of how to do this and I dont think any of the plugins i have will help

any ideas?
Im trying to make it so if my MP hits 0 the HP goes down by a specific amount (not percent) but I cant think of how to do this and I dont think any of the plugins i have will help

any ideas?

Would something like this work?

Control Variables : 0001 A.1_MP = MP of Harold
If : A.1_MP = 0
Change HP : Harold, -1
It should be pretty simple to do with Yanfly's Auto Passive States. Just put a state on whichever actors you want this to apply to - check if they have MP at the beginning of their turn, then again after their action, and if they lost MP to 0 do damage.

Code:
<Custom Turn Start Effect>
user.hadMp=user.mp>0 ? true : false;
</Custom Turn Start Effect>

<Custom Action End Effect>
if (user.hadMp && user.mp==0)
    user.gainHp(-X);
</Custom Action End Effect>
where X is how much hp you want them to lose.
Im trying to make it so if my MP hits 0 the HP goes down by a specific amount (not percent) but I cant think of how to do this and I dont think any of the plugins i have will help

any ideas?
The solution posted above by ATT_Turan should work in most cases. But there are scenarios when that wouldn't work such as:
  • user acts more than once per turn
  • MP is reduced through being hit by a skill e.g. MP draining skill
  • MP is reduced through a state e.g. negative MP regeneration
The most exhaustive solution would be to alias gainMp or setMp. You can use @ct_bolt's Custom Script Anywhere if you're not familiar with aliasing. Unfortunately, this would implement HP reduction everytime MP goes from positive to zero. So you'll possibly have to deal with a lot of conditionals.

Alternatively, you can use Yanfly's Buffs & States Core's <Custom Respond Effect> and <Custom Regenerate Effect> notetags to account for being hit with an MP draining skill or an MP draining state, respectively.

If you restrict the HP reduction from zero MP scenarios (skill usage only and skill users act at most only once per turn) then ATT_Turan's solution should suffice.
user acts more than once per turn
Why wouldn't it work then? Unless you're suggesting they start the turn with 0 MP, do something to restore it with their first action, then exhaust it to 0 again with their second...which is technically possible, but seems a fringe scenario to me 😉

Although, come to think of it, if the first action reduced MP to 0 then they'd get smacked both times, as I have it written. But it's a lot of work to try to anticipate every scenario involved in a given thing...I don't have that many brain meats.
The most exhaustive solution would be to alias gainMp or setMp.
Very true.
Why wouldn't it work then? Unless you're suggesting they start the turn with 0 MP, do something to restore it with their first action, then exhaust it to 0 again with their second...which is technically possible, but seems a fringe scenario to me 😉
THAT IS A FRINGE SCENARIO! 😮 Your code shouldn't allow that. Remember, your code has a check at turn start. So if you start the turn with 0 MP then the hp reduction won't activate at all.
Although it is technically possible to circumvent the checks... you will need to go through a lot of hoops to do that. 😳

I should have said it wouldn't work properly rather than it wouldn't work at all. 😅 What I was actually envisioning was for the first action the actor uses a skill that would exhaust his remaining MP then for the second action he does something that doesn't cost MP e.g. default attack, guard, skills costing 0 MP, item use, etc. The HP reduction would occur twice in this case.

Although, come to think of it, if the first action reduced MP to 0 then they'd get smacked both times, as I have it written.
Actually, your code will work just fine in this case. 👋
  • Assumptions: One character party (or for that turn all companions either dead or disabled), actor can act twice per turn, actor has just enough MP to cast Skill X, actor uses Skill X on target TWICE.
  • Action 1: Skill X activates; MP reduced to 0. HP reduced.
  • Action 2: Actor just stands there looking stupid. No HP reduction.
But it's a lot of work to try to anticipate every scenario involved in a given thing.
In fairness to you, I get to cherrypick which threads I want to solve. 😀
You on the other hand try to solve almost all support threads the moment they're posted while playing video games on the side. 😮

Very true.
On the other hand, figuring out the exclusions in this case sounds like a lot of work too. 😳

I envision these scenarios because I don't want the OP to start a new thread complaining in the opening post "These guys' codes suck!" 😛

Edit:
As an aside, to be fair to OPs, most of them aren't trolls.
I'm not sure if you remember @ATT_Turan, that guy who used to make threads and lead posters on wild goosechases. You know, the guy who trolled Shaz in the latter's own profile page.
I'm not sure if you remember...
Sadly, I remember a couple of them. Although the working hypothesis was that it was the same person remaking an account.
It should be pretty simple to do with Yanfly's Auto Passive States. Just put a state on whichever actors you want this to apply to - check if they have MP at the beginning of their turn, then again after their action, and if they lost MP to 0 do damage.

Code:
<Custom Turn Start Effect>
user.hadMp=user.mp>0 ? true : false;
</Custom Turn Start Effect>

<Custom Action End Effect>
if (user.hadMp && user.mp==0)
    user.gainHp(-X);
</Custom Action End Effect>
where X is how much hp you want them to lose.

The code doesn't seem to be working for me, did I do something wrong? (I also made a test project to make sure it wasn't because of any conflicting plugins), in general I've been having issues with specifically the yep auto states plugin in the past when it came to state notetags (actor and enemy notetags work just fine)

1654002633279.png
1654002664965.png
1654002704376.png
1654002733539.png
The code doesn't seem to be working for me, did I do something wrong?
Yes, but it's my fault for not explicitly describing it properly.

You need to put the code in a state that is a passive state for your scenario (or not, if you don't want it to happen all the time, I don't know what you're trying to do); but those actual notetags come from Yanfly's Buffs and States Core. So you'll need both of those plugins for this to function.
Yes, but it's my fault for not explicitly describing it properly.

You need to put the code in a state that is a passive state for your scenario (or not, if you don't want it to happen all the time, I don't know what you're trying to do); but those actual notetags come from Yanfly's Buffs and States Core. So you'll need both of those plugins for this to function.
this feels like a really stupid question but how do i turn it into a passive state, ive installed yanflys buffs and states core aswell with no real luck on makin anything work

and to clarify what im trying to do, i want it so that when the users mp reaches 0 they will lose health for every turn until there mp is above 0
this feels like a really stupid question but how do i turn it into a passive state, ive installed yanflys buffs and states core aswell with no real luck on makin anything work
You need to make sure you always read the instructions for plugins you install 😉 The documentation for Auto Passive States tells you how to put a passive state onto your actors via a notetag.
and to clarify what im trying to do, i want it so that when the users mp reaches 0 they will lose health for every turn until there mp is above 0
Okay...that is not how I read your original request. So the only notetag you need in your passive state is this:
Code:
<Custom Action End Effect>
if (user.mp==0 && user.hp>1)
    user.gainHp(-1);
</Custom Action End Effect>

That will make them lose 1 HP (per your post #2) at the end of their action if they have 0 MP. I wrote it so this damage can't kill them - if you want it to be able to, take out the && user.hp>1
yo it worked, thank you so much!
You need to make sure you always read the instructions for plugins you install 😉 The documentation for Auto Passive States tells you how to put a passive state onto your actors via a notetag.

Okay...that is not how I read your original request. So the only notetag you need in your passive state is this:
Code:
<Custom Action End Effect>
if (user.mp==0 && user.hp>1)
    user.gainHp(-1);
</Custom Action End Effect>

That will make them lose 1 HP (per your post #2) at the end of their action if they have 0 MP. I wrote it so this damage can't kill them - if you want it to be able to, take out the && user.hp>1
You need to make sure you always read the instructions for plugins you install 😉
@Shaz, I think you should put this under item #0 in your thread.
@Shaz, I think you should put this under item #0 in your thread.
What a good idea!

Original thread: https://forums.rpgmakerweb.com/threads/im-trying-to-make-it-so-if-my-mp-hits-0-the-hp-goes-down-but-idk-how.147947/