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,718
Reaction score
6,537
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

Ooops ended up trying out making my own A2 tile page instead of testing doors everywhere. Went well so far I think.
I guess I'm done making a blue squirrel's life difficult for posting new threads on different forums.
That's just for today so don't get used to this, squirrel-ish friend! :p
Got new hard drive, now trying to install the softwares I lost to the dead drive, and more than half of them won't install because they're already installed on the dead drive, and uninstallers won't run because they can't find where their programs are installed. So I take it having a drive die on you screws you in more ways than just data loss. >:\
PC got fixed finally. Back online again. Turns out I have no business trying to self repair pcs because it was getting to like 176F / 80C. Shop installed a totally new cooling system and now it runs fine and is super quiet.
When you're making major progress, but have to stop to go to work.

Forum statistics

Threads
131,484
Messages
1,220,206
Members
173,225
Latest member
ZecaVn
Top