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,707
Reaction score
2,809
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 Profile Posts

I've decided to try and be more social and less nervous about engaging. I'm always over thinking things - from now on when I'm worried or don't get something I'll just ask.
Sometimes a mechanic that is meant to add challenge is just annoying. Even the Final Fantasy games did not completely escape this pitfall of design. (FF8 draw system I'm looking at you - grrrr)
starting working on the sprites for one of my games major antagonists finally. here's the first frame of his chanting motion in battle.
Have spent too much time hammering out with a friend just how to make a reoccurring enemy that permanently learns skills you use against her.
I know what I want in a loose sense. Maybe I should just make a post asking for opinions and suggestions.

Forum statistics

Threads
113,737
Messages
1,077,062
Members
147,762
Latest member
Bad_At_Scripting
Top