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,864
Reaction score
6,671
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 Posts

Latest Profile Posts

oneOfUs.jpg
Streaming more Poppet Quest game even in about 12 minutes.
Some dog owners really impress me. I'm pushing 2-3 metric tons of garbage containers that destroy everything they hit. What do you think is going to happen to your tiny dog when I run it over? And why are you crossing my path to argue with me? Have you never been hit by 200kgs of garbage?

Lesson for you folks. Never mess with an angry garbage container. Or its driver.
I didn't dispose of a file properly and now my whole game won't start: I get a script error in the Scene Manager stage of game launch. What to do? Transfer it all to a new project? That's going to be tedious. Fortunately I am only nine workdays into it.

Forum statistics

Threads
131,680
Messages
1,222,173
Members
173,426
Latest member
sleepykitsune
Top