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

Veteran
Veteran
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
Veteran
Joined
Jul 2, 2014
Messages
8,875
Reaction score
6,677
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

imgur sure is getting weird, one day I lose gradually all my images, the other I get them back randomly and then again they disappear again.
Despite OPT2 praise it still has some strange stories in it. Lady Mikka is trying to work herself to death because of guilt. Guilt over what? ¯\_(ツ)_/¯ So instead of finding a NPC to have a heart to heart with her they decide the cure is a new kimono. So when she drops dead she'll at least be well dressed. I haven't even got to the strange part yet.
Did so much work on the game today. I wish I could post it all in this status update but there is a character limit of course haha. I thought about making a topic for updates, though... maybe.
The most recent sign that I am old. I have done martial arts for over 4 decades. Never HAD to stretch out. Good, of course, but never required. Was doing some kicks in the kitchen because, why not, and I felt a pop in the back of my thigh. Now I am limping around. Gotta love getting old.
One of the biggest perks of being fluent in English is how many new and interesting recipes I am able to find and try out that I would have hardly come across if I just spoke my mothertounge :3

Forum statistics

Threads
131,683
Messages
1,222,229
Members
173,435
Latest member
TheAmplifier
Top