I made a terrible mistake

truthHarbinger

Villager
Member
Joined
Feb 8, 2018
Messages
20
Reaction score
0
First Language
English
Primarily Uses
RMXP
When I first started making my game, one of the first things I did was nerf critical hits -- they're far too powerful in the base program -- and I did that by changing this value from 2.0 to 1.5.upload_2019-1-6_1-46-29.png
This caused a horrifying problem - decimal health; sometimes my characters would have up to 3 digits after the decimal on their health (a playtester said they got around 7 or 8 digits but I don't have evidence of this).
upload_2019-1-6_1-48-25.png
At this point I tried removing critical hits altogether by changing those values further:
upload_2019-1-6_1-50-35.png
I assumed this would prevent critical hits from happening, but now regular attacks still seem to show up as criticals, just without the word "critical" under the damage. And they still do decimal point damage.

At this point it should be clear I have no idea how the script here works. I'm perfectly fine either with a way to round the number to avoid decimals or a way to remove critical hits entirely. Can anyone help me do either of these?
 

Attachments

Tw0Face

Master Strategist
Veteran
Joined
Nov 12, 2018
Messages
430
Reaction score
370
First Language
German
Primarily Uses
RMVXA
There's a simple solution for disabling Critical Hits but you have to do it for each Skill you use. Check your Database and then go to Skills. Under the Damage Calculation Formula (next to the Variance option), there's an option called Allow Criticals. Set it to No.

Greetings,
Tw0Face
 

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
You can replace that line with this to round the damage
Code:
self.damage = (self.damage * 1.5).round
 

truthHarbinger

Villager
Member
Joined
Feb 8, 2018
Messages
20
Reaction score
0
First Language
English
Primarily Uses
RMXP
You can replace that line with this to round the damage
Code:
self.damage = (self.damage * 1.5).round
I put that in... my character's critical hit did around 8 times the normal damage for some reason... trying to fix this
 

truthHarbinger

Villager
Member
Joined
Feb 8, 2018
Messages
20
Reaction score
0
First Language
English
Primarily Uses
RMXP
Update: I found out the problem.upload_2019-1-6_4-34-31.png
I removed this little asterisk next to the = sign here. Seems to have completely fixed the issue!
 

Attachments

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@truthHarbinger I'm not sure that removing that asterisk won't have problems further down the line. You could try this:
self.damage = (self.damage * 1.5).i

That .i makes it a full integer, rather than a decimal.
 

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
Update: I found out the problem.View attachment 106426
I removed this little asterisk next to the = sign here. Seems to have completely fixed the issue!
*= is basically multiplying itself with a value
so this
Code:
self.damage *= (self.damage * 1.5).round
equal to this
Code:
self.damage = self.damage * (self.damage * 1.5).round
@truthHarbinger I'm not sure that removing that asterisk won't have problems further down the line. You could try this:
self.damage = (self.damage * 1.5).i

That .i makes it a full integer, rather than a decimal.
I think what you mean is .to_i, there's no .i method.
 

truthHarbinger

Villager
Member
Joined
Feb 8, 2018
Messages
20
Reaction score
0
First Language
English
Primarily Uses
RMXP
Thank you all for your help, hopefully I won't run into any further problems!
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
You're right, that's what I get for doing this on my phone. It should indeed be .to_i
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,634
Reaction score
5,114
First Language
English
Primarily Uses
RMVXA
I think the .to_i will fix your problem (assuming you didn't do anything elsewhere that will muck stuff up) but I always just used the same level of precision that I would want the result to be. So I'd do self.damage = (self.damage * 15 / 10) or similar.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
It originally was a *=1.0 (multiply a by 1.0 and put the new value into a)
If you turn it into a =1.0 you achieved nothing and you will probably cause many problems for the future. (set the new value of a to be 1.0)

*= is an operator, like +, or - so in order for us to understand it better...
a *=1.0 is eqivalent to a = a * 1.0

But when we say in math a * 1 (a times 1) it gives us a as a result. Right? So why do did the coders made that line here?
It is different to tell
a *=1
than
a *=1.0
because a *= 1 will return a result of the same kind "a" is. If operand "a" is an integer, it will return an integer. If operand "a" is a decimal it will return a decimal.
By multiplying by 1.0 ( a literal decimal that does not change the original value of "a") you make sure that what will be returned will be an integer.
a *= 1.0 always returns a decimal.

This can cause you problems hard to solve in the future, when you will be trying to balance damage and stuff.
It wasn't decimal for no reason. You should follow @Kes suggestion, it's safer.

What you actually did, was instead of setting a to a decimal, you now set it equal to 1.0
That means if operand "a" was 40, now it is set to 1. That line meant to turn 40 into 40.0 so it can have decimals that can be rounded in the future for more accurate formulas I suppose.
You will ruin all the damage system that way. I will pass if that's what you wanna happen though. :p
 
Last edited:

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

Latest Threads

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,992
Messages
1,018,189
Members
137,771
Latest member
evoque
Top