Help with a sacrifice skill

Archlvt

Veteran
Veteran
Joined
Mar 8, 2019
Messages
65
Reaction score
5
First Language
English
Primarily Uses
RMMV
Hello,

I'm back with another mystery to solve. Actually, there is no issue with the game's functionality, but rather the display. I am creating an attack skill that sacrifices 10% of the user's mhp if they are under a condition. Here is what I have.


<Post-Damage Eval>
if (user.isStateAffected(25)){
user.gainHp(-user.mhp*0.10)
}
</Post-Damage Eval>

<target action>
perform start
wait for movement
motion attack: user
wait: 10
action animation
wait for animation
action effect
wait for animation
wait for movement
wait: 5
Add State 25: user
</target action>

It actually functions perfectly, the problem is the damage popup has a freakout and shoots out this infinitely long string of numbers. I tried disabling my damage popup plugin, but the classic display was the exact same way, so I know it's not that plugin. The problem DOES NOT happen if I change user.gainHp(-user.mhp*0.10) to user.gainHp(-1000) for example, it only happens when I use the -user.mhp*0.10) bit. I've also tried -0.10*user.mhp thinking that maybe the formula didn't like starting with letters.

I'd like the damage popup to reflect the true damage being taken, or to disappear altogether (I'd prefer the latter). Can anyone help me with this?
 

Attachments

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,604
Reaction score
5,067
First Language
English
Primarily Uses
RMVXA
My guess is that it happens because of rounding error. Try:
user.gainHp(Math.round(-user.mhp*0.10))
 

Archlvt

Veteran
Veteran
Joined
Mar 8, 2019
Messages
65
Reaction score
5
First Language
English
Primarily Uses
RMMV
My guess is that it happens because of rounding error. Try:
user.gainHp(Math.round(-user.mhp*0.10))
Dammit. That was a good guess. It was simultaneously very simple coupled with the fact that I never would have thought to do that myself since I don't actually know js, I just play with it. I never would have thought to look for that as a solution. Didn't even know math.round was a thing.

Thanks very much. Getting this to work wasn't just for this skill, but it was a domino effect to making my entire class function.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Accidentally zoomed the browser in on the forums page, here... and I think I'm going to just leave it. #OldPeopleProblems
Spooktober Spooktacular Game Jam Winners announcements start now! Live on stream! See who won!
so, I've begun the process of restructuring my game's base setup entirely after feeling disheartened with progress and talking to a friend. I think I'm headed in the right direction now.
Tomorrow is Thanksgiving, and I'm so excited! I've been exploring MZ a little, and I just downloaded Effekseer to make new animations. I have experience in 3D animation software, so I'll be pretty good at the whole "particle" thing. My first game on MZ will be Fantasy Force--starring a griffin, a dragon, and a pegasus fighting against the Dragon of Darkness.
currently listening to Driftwood Gaming streaming some MZ dev time and it's delightful! had no idea they were this entertaining, love it

Forum statistics

Threads
105,521
Messages
1,014,363
Members
137,202
Latest member
zbzikowany
Top