Using Math.floor on All Damage Formulas

darkmatter404

Villager
Member
Joined
Feb 2, 2014
Messages
28
Reaction score
4
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
193
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
4
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 Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,062
Members
137,575
Latest member
akekaphol101
Top