Question About Formulas

Status
Not open for further replies.

flerbergerber

Villager
Member
Joined
Jun 3, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
I'm making an attack that's supposed to be weak, but applies a poison affect. I want the attack to do half the user's attack divided by the defender's defense. I'm using the formula "(a.atk / 2) / b.def)", but I'm not sure if formulas pay attention to parenthesis. Anyone know if they do?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Yes, they do, but yours is wrong. You've got two closing parentheses, but only one opening. Also, you don't need them when you're doing division in both cases anyway, because the order of events is that multiple division operations will be done from left to right.


Also, if a.atk / 2 is going to end up less than 1, it's going to truncate it to 0, and your result will be 0.


There is a pinned thread around on the battle formula and the many different ways you can use it (including applying effects).
 

flerbergerber

Villager
Member
Joined
Jun 3, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
Yes, they do, but yours is wrong. You've got two closing parentheses, but only one opening. Also, you don't need them when you're doing division in both cases anyway, because the order of events is that multiple division operations will be done from left to right.

Also, if a.atk / 2 is going to end up less than 1, it's going to truncate it to 0, and your result will be 0.

There is a pinned thread around on the battle formula and the many different ways you can use it (including applying effects).
Ok, thank you. Honestly, I just realized how derpy this thread was. I completely forgot about order of operations. And I could've tested this easily enough. But I assumed that if it resulted in 0, there would just be no damage, but still apply an effect. But I will check out that thread you speak of, thanks.

A mod can close this.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Yes, I think it will. You'll get 0 shown as damage though.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

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,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top