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

voxet

Villager
Member
Joined
May 25, 2022
Messages
11
Reaction score
7
First Language
english
Primarily Uses
RMMV
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?
 
Last edited:

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
675
Reaction score
78
First Language
English
Primarily Uses
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
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,524
Reaction score
2,888
First Language
English
Primarily Uses
RMMV
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.
 

Anastasius

Veteran
Veteran
Joined
Feb 7, 2022
Messages
51
Reaction score
37
First Language
English
Primarily Uses
RMMV
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.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,524
Reaction score
2,888
First Language
English
Primarily Uses
RMMV
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 :wink:

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.
 

Anastasius

Veteran
Veteran
Joined
Feb 7, 2022
Messages
51
Reaction score
37
First Language
English
Primarily Uses
RMMV
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 :wink:
THAT IS A FRINGE SCENARIO! :eek: 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. o_O

I should have said it wouldn't work properly rather than it wouldn't work at all. :kaoswt2: 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. :kaohi:
  • 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. :biggrin:
You on the other hand try to solve almost all support threads the moment they're posted while playing video games on the side. :eek:

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

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!" :stickytongue:

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.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,524
Reaction score
2,888
First Language
English
Primarily Uses
RMMV
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.
 

voxet

Villager
Member
Joined
May 25, 2022
Messages
11
Reaction score
7
First Language
english
Primarily Uses
RMMV
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.png1654002664965.png1654002704376.png1654002733539.png
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,524
Reaction score
2,888
First Language
English
Primarily Uses
RMMV
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.
 

voxet

Villager
Member
Joined
May 25, 2022
Messages
11
Reaction score
7
First Language
english
Primarily Uses
RMMV
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
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,524
Reaction score
2,888
First Language
English
Primarily Uses
RMMV
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 :wink: 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
 

voxet

Villager
Member
Joined
May 25, 2022
Messages
11
Reaction score
7
First Language
english
Primarily Uses
RMMV
yo it worked, thank you so much!
You need to make sure you always read the instructions for plugins you install :wink: 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
 

Latest Threads

Latest Posts

Latest Profile Posts

The main game of my trilo/saga 50%OFF on Steam..... its now or never more
I swap between Ace and MZ so I can stay fresh but - what do you mean you can use subfolders in the plugin's folder for easier organization!?
Did some new music again, praise be. To the next song!
Watch Studio Blue play Numina by starlit in our latest RPG Maker Games Critique stream starting NOW!

Forum statistics

Threads
123,139
Messages
1,154,243
Members
161,474
Latest member
nugogo555
Top