Making the same item have an opposite effect on different party members

Hey everyone. I'm rather new to MV (been using VX Ace before) and I'm wondering if I can have an item have a different effect on two party members.

Let me explain. I'm working on a fantasy game. In this game, party members recover health from food, and mana through drinks. The amount varies depending on what they ate/drank, with characters recovering more from their favorite food. One of these items is plain water, an item that recovers mana, which is what the lizardman prefers, while other party members recover less from it. However, another party member is a fire elemental, and we all know fire and water don't mix well. Therefore, I wanted to make it so that they instead take damage from it.

I know this is an issue because this item is focused on recovering mana, and I've been aiming to make the fire elemental take health damage if drinking it. I tried setting up a custom formula for it, and while other party members recover mana just fine, nothing happens if the fire elemental drinks it.

Any advice?
You might find this thread useful.


It gives you the format for conditional statements and tells you the script call for getting an actor's ID as well as gaining/losing HP.
I looked at that and tried the following formula:

b.actorId() === 2 ? gainHp((b.mhp / 2) * -1) : 200

Fire Elemental being the second actor. From what I imagined, it's supposed to deal half of their max HP of damage if the target the actor #2, but restore 200 MP otherwise. The damage type is set to MP Recover, as that is the primary function of the item.

Same thing happens, if all other party members drink it, they recover the estimated amount of MP, but nothing happens with the Fire Elemental.
gainHp((b.mhp / 2) * -1)
Per the thread above, gainHp() is attached to a battler (he calls it a parameter, the correct word is method, not really relevant). The point is you can't just say gainHp() any more than you can just say atk. You need to tell the game which battler is gaining HP.

b.actorId() === 2 ? gainHp((b.mhp / 2) * -1) : 200
Second problem is that gainHp() does not return a value.

Per the thread,
But only last number in the formula deals damage.
with the corollary being that something which isn't a number will cause the damage formula to fail entirely.

If you want your fire elemental to heal 0 MP, you need to say that.

So the correct formula for you would be:
Code:
if (b.actorId() == 2) {b.gainHp(Math.round(b.mhp / 2) * -1); 0;} else 200

I used Math.round(), mentioned in that thread, to make sure you don't try to damage the elemental by a decimal value. And then the 0 is the result of the damage formula, making it restore 0 MP.
Oooh, I see now. I guess I didn't read that part correctly.

Thanks for the help, now it works just fine.

Original thread: https://forums.rpgmakerweb.com/threads/making-the-same-item-have-an-opposite-effect-on-different-party-members.170019/