MV Making an item that recovers both HP and MP if actor is inflicted with a certain state.

The goal: If actor has state [NICOTINE ADDICTION] then using the MP recovery item [CIGARETTE] will additionally recover HP along with MP.

The formula I'm using for the item is: [b.isStateAffected(190) ? b.gainHp(5) : 5]
The battlelog shows "5 HP recovered | 5 MP recovered" yet doesn't seem to actually work. I'm guessing that trying to do this through the item's formula box isn't the right approach?
ciggy.png


Additionally, the call for the actor's MP using SRD Hudmaker returns as NaN after using the item and the actor is unable to ATTACK or DEFEND the next round.


Is there an error with the formula? Alternative solutions? Thanks!
Given the way your formula is structured, you can just change the "type" of the formula to HP recover and change the code to the following:

Code:
b.isStateAffected(190) ? 5 : 0

The formula box will apply the final numerical value as the type indicated (hp in the case described).

As for why your character's MP is showing as NaN, is Castiel your party leader?
Given the way your formula is structured, you can just change the "type" of the formula to HP recover and change the code to the following:

Code:
b.isStateAffected(190) ? 5 : 0

The formula box will apply the final numerical value as the type indicated (hp in the case described).

As for why your character's MP is showing as NaN, is Castiel your party leader?
Thanks for the solution!

And my bad, I forgot to include that it returned as NaN after using the item but it all works now!
The formula I'm using for the item is: b.isStateAffected(190) ? b.gainHp(5) : 5
This isn't correct - if the target has state 190, then the only thing you do is call the gainHp() function. That function does not return a value, which means your actual damage formula ends up not producing a number.

That's why your MP is then seen as not a number.

Since you always want to have the value 5 at the end for MP recovery, this is not correctly a ternary statement. Ternary means if-then-else. You have no "else," you always want the 5.

So just do: if (b.isStateAffected(190)) b.gainHp(5); 5

Original thread: https://forums.rpgmakerweb.com/threads/making-an-item-that-recovers-both-hp-and-mp-if-actor-is-inflicted-with-a-certain-state.156093/