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

casteco

Villager
Member
Joined
Feb 13, 2023
Messages
28
Reaction score
13
First Language
english
Primarily Uses
RMMV
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!
 
Last edited:

caseorogue

Regular
Regular
Joined
Feb 21, 2022
Messages
50
Reaction score
29
First Language
English
Primarily Uses
RMMV
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?
 

casteco

Villager
Member
Joined
Feb 13, 2023
Messages
28
Reaction score
13
First Language
english
Primarily Uses
RMMV
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!
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,198
Reaction score
9,164
First Language
English
Primarily Uses
RMMV
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
 

Latest Threads

Latest Profile Posts


Main theme for a Start/Continue/Options screen after Title card
28 notifications, and like 30 emails. And I was only gone for six hours. Yeah, I think I'm done for the day.
Also, I think I have a not secret admirer. Hooray...
Working on a battle cutscene, needs some polishing, but I'm liking the result:

spriteMedalConfraternate.png
spriteMedalVulpis.png

Forum statistics

Threads
134,975
Messages
1,252,477
Members
177,844
Latest member
WayneF
Top