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,467
Reaction score
2,588
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

Original Character Contest Winners Season 3 Pack! is now live!

I know it's a waste of time, but I decided to create a script that forces the RM2k game to always be in windowed mode. Just for fun anyway.
Rm2k.png
Coding some stuff. I just hope I'll be able to finish before school starts.
It's nice and breezy as well cool here, no AC needed! But keep you cozy

Forum statistics

Threads
112,438
Messages
1,068,308
Members
146,090
Latest member
dannyraymilligan
Top