AsianBorn

Warper
Member
Joined
Aug 20, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
N/A
I am unsure if this is the correct place to post this enquiry, sorry if its not.

I want skills to be able to deal both attack damage and magic attack damage rather than just one or the other, however I do not know how to implement this properly.

How would I combine these - (a.atk * x - b.def * x) as well (a.mat * x - b.mdf * x) but not have the overall damage lowered if one of the defense values is greater than the corresponding attack values.

Example - (a.atk * 1 - b.def * 1) + (a.mat * 1 - b.mdf * 1)
if my actor had 50 attack and 50 magic attack but the target had 20 defense and 80 magic defense, then the actor would deal 0 damage to the target because of the excess magic defense. How would I make it so that this example formula would deal the 30 attack damage that it logically should no matter how high the magic defense is.

Would very much appreciate any assistance thank you :)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,423
Reaction score
2,518
First Language
English
Primarily Uses
RMMZ
Use Math.max to avoid negative contributions to the calculation.

Math.max(a.atk * x - b.def * x, 0) + Math.max(a.mat * x - b.mdf * x, 0)
 

AsianBorn

Warper
Member
Joined
Aug 20, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
N/A
Use Math.max to avoid negative contributions to the calculation.

Math.max(a.atk * x - b.def * x, 0) + Math.max(a.mat * x - b.mdf * x, 0)
I had no idea this was a thing, thank you, I appreciate the reply :)
 

Latest Threads

Latest Posts

Latest Profile Posts

Pretty much stopped posting in the progress thread cuz it feels like talking to the void, lol, so I've just been posting on IG instead. But someone finally liked my post there, lol. Dunno if I'll continue tho. Probably not xD

My game's progressing quite well. Just kinda stuck on mapping right now. Decided to go the side, slightly top down view route. I'm drawing everything from scratch for a personal touch uwu
Stomach isn't feeling too good last time. Perhaps something I ate
Phew! logged back. Seems I was too occupied with 3D learning (yeah for RPGM purposes) creating IRL space, trying to grow catnip, dealing with health and DC is good. (so MrC) ^^
Tyler.stewart wrote on Cherry's profile.
I was wondering if you've heard anything about the patch that allows you to show text anywhere on the screen utilizing pictures being upgraded to work with the official 2k3 release? Your work with 2k3 is awesome dude, keep it alive. I'm 33 and am still playing with 2k3 largely thanks to your work with the game engine. I appreciate the official patch updates you post. Please continue posting
Currently trying to add items in the same style as Kyrise's excellent icons. I like having a large variety of items :3 KyriseandMe.PNG

Forum statistics

Threads
112,333
Messages
1,067,468
Members
145,973
Latest member
Arcanica
Top