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,699
Reaction score
2,800
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

The snowy mountains in my game are finally done... what a crazy journey.
I participated in the official video event collection!
Well I am infinitely upset that I finally got a good idea... after the Touch the Stars game jam is pretty much over.

Gather resources to build a spaceship to escape the apocalypse! It would have been cool....
Thinking that if I get MZ, I'll work on a new Project. How about instead of just an RPG, I make it episodic, like an anime? You might even get fanservice. Oh, but I need the right costume for the character.
"but what even is an API??"

Forum statistics

Threads
113,606
Messages
1,076,169
Members
147,612
Latest member
UnInconnu
Top