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,536
Reaction score
4,991
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

I always told my DA fans how much I hate slot machines. They're fine in games as a risk-and-reward system. But when you're spending REAL MONEY in a Vegas casino to try and hit the jackpot (which very, very few people will), it can really hurt your budget. Gambling is a bad habit, and I don't like wasting my money on a slim chance. Go to Vegas for the experience, not the jackpot.
Took the kids to a corn maze. They gave us a map and had lights at certain points in the maze. Not overwhelming... or underwhelming... just... whelming.
Okay, vacuuming fruit flies out of the air is surprisingly effective.
Finally finished my menu redesign after like a month of coding! I hate designing menus... Good news though - I thought of a complete redesign for it now, so yay...
Still no scam calls all day... also I got a quick gig designing a mascot drawing for a small business, so I might actually make some green of my own after all. That would be a perfect job for me, since I love art and digital design.

Forum statistics

Threads
104,388
Messages
1,006,031
Members
135,917
Latest member
kingrifer
Top