An item converting hp to mp

I'm back for my 40th problem. ^^'
I would like to create an infinitely usable item that converts 10% MP into 10% HP.

So I created this item, with this damage formula:

if b.mp >= b.mmp / 20;if b.hp != b.mhp;b.hp += b.mhp / 10 and b.mp -= b.mmp / 10;end;end

The problem I have is that this item is only usable for the first member of the team.
It just doesn't work for the others.

Is there any way to solve this problem?
Your syntax just doesn't seem right to me, and I'm not sure how that would work for ANY party member. and is a logical operator, it doesn't mean do this and that.

Try this:

(b.mp >= b.mmp * 0.05 && b.hp < b.mhp) ? (b.hp += b.mhp * 0.1; b.mp -= b.mmp * 0.1) : 0
It made the HP and the MP decimal. I changed it to that:
(b.mp >= b.mmp / 10 && b.hp < b.mhp) ? (b.hp += b.mhp / 10; b.mp -= b.mmp / 10) : 0

And it only work on the first character of the team. That's the problem I have. When I try this on another character,
the result is different depending on the type of damage done by the formula.
For example, when the formula does MP absorption, and I use the item on the second character, the first character's MPs go to 0, the second character gains 10% of his HP and loses 10% of his MP.

The effects vary depending on the type, but the item never just applies the formula. There is always an unwanted side effect.

Thank you for helping me 🙂
Well what you've got in the damage formula just affects the person the item is being used on, and based on what you said, it's working correctly.

You didn't say what you wanted to happen to the first person.


So, what should happen to the target? Should they lose 10% of their MP? Should they gain 10% of their HP?

What should happen to the user? Should they gain or lose anything? What? 10% of their MP or HP, or 10% of the target's MP or HP?

Have you set it up so it's only usable in battle? User has no meaning when you use an item from the menu.

There is nothing in the formula at all to make it only work for one person and not others. So if that's happening, it's something else you're setting up on the item, or a script you've added.
I tried it on a empty project and the problem is the same.
It will be more comprehensive with a video.



Everytime I change the type of the damage formula, the result change, but it will never just change 10% MP into 10% HP and allow the player to do it for every characters. Is there something to do to just force the formula to apply?

There is no healing spell in my game, the purpose of this item is to allow you to heal yourself even when you run out of items to do so.
That second one looked to work correctly.

You shouldn't change the damage type to anything else. The damage formula should handle it all correctly.

The first time, before you changed the damage type, it took ALL of the MP from actor 2 the first time the item was used. So it wouldn't work after that because there was no more MP.

Please copy the formula from your item and paste here so I can see exactly what you've got. And add a screenshot of the item tab. Set the damage type to HP damage and just leave it at that. Hard to try and troubleshoot if you keep changing things around and don't stick to just one approach.
The second didn't work. To heal 100% of your HP you have to take 100% of your MP.
When I put it on HP Damage, I heal ~70% of the HP using all my MP and the number of healed HP is progressive.

I haven't changed the formula, this is the last one I posted here.
(b.mp >= b.mmp / 10 && b.hp < b.mhp) ? (b.hp += b.mhp / 10; b.mp -= b.mmp / 10) : 0
Please show a complete screenshot of the Item tab.
Here's what I've got. Works in my end.
Code:
h = b.mp_rate >= 0.1 ? (b.mhp*0.1).round : 0; h > 0 ? b.mp -= (b.mmp*0.1).round : 0;h
Screenshot_23.jpg
Thank you a lot Theo, this is exactly what I wanted ^^
Thank you too Shaz.
Everything there was to see on my item tab was shown in the video, I didn't edit anything else. The problem was my formula.
@CuddleFox If your problem is solved, please report this post and this thread will 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/an-item-converting-hp-to-mp.116956/