Using Math.floor on All Damage Formulas

darkmatter404

Villager
Member
Joined
Feb 2, 2014
Messages
28
Reaction score
3
First Language
English
Primarily Uses
I checked out this thread earlier today: https://rpgmakermv.co/threads/damage-formulas-101-mv-edition.2172/

My game uses low damage numbers, and after a bit of testing, I found out that any decimal .5 or over rounds damage values up, while I want all non-whole numbers to round down. Damage values scale on a .2, .25, .33 and .5 basis (5 points for 1 extra damage, 4 points, 3, 2, etc). Armor works in a similar way- every 10 points of def is supposed to give one flat Armor that reduces all damage taken by 1. If you have 9 def, you're not supposed to get it- but having 5 - 10 def gives you the armor anyway since it rounds up.

As such, all my damage formulas look like some variation on this basic setup: (a.atk * 0.33) - (b.def / 10). My question: How can I integrate Math.floor into my damage formulas to ensure all non-whole numbers are rounded down? I tinkered with it and read above linked threat and couldn't find a clear way to integrate it.
 

mathmaster74

just...John
Veteran
Joined
Jun 12, 2016
Messages
285
Reaction score
192
First Language
English
Primarily Uses
RMMV
@darkmatter404 To use the current functionality of the damage formula and get the desired result, simply put a minus 0.5 at the end of every formula.
Examples:
formula produced .9 ending, which would have rounded up, now produces .4 ending, which rounds down.
formula produced .75 ending, would have rounded up, now produces .25 ending, which rounds down.
formula produced .5 ending, would have rounded up, now produces .0 ending, which rounds down.
formula produced 1.0 ending, would have been 1, now produces 0.5, which rounds back to 1, so...you're good. :smile:
 

darkmatter404

Villager
Member
Joined
Feb 2, 2014
Messages
28
Reaction score
3
First Language
English
Primarily Uses
Oh my god. That's honestly so clever. How did I not see that. Thank you!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

It's raining non stop since yesterday. The sound of the rain is so soothing.
I really miss the old style disney animated movies. I guess the last one was The Princess and the Frog from 2009. Now I am trying to collect every single one I can get on BD or DVD.
What I've seen from the MZ tiles looks pretty inconsistent, bleh. Every plant seems to be drawn in a different style.
Recently posted a demo of my game online. Now I have no idea what to do with myself o_O What is the reason for my existence now...
I'm feeling a lot better this week. Some of the rules in my country for isolation changed a little, so I was able to see friends in person again, which was a huge relief. Thanks everyone for giving me some sympathy last week when I was having a rough time!

Forum statistics

Threads
99,287
Messages
963,880
Members
130,899
Latest member
Densuki
Top