Help - Search - Members - Calendar
Full Version: Damage Formula
RPG RPG Revolution Forums > Game Engines > RPG Maker VX Ace Discussion
Pillanious
Hey, everyone!

I'm playing around with a damage formula I saw that I really liked in terms of functionality - but it isn't working properly in vxace.

I wonder if someone with a little understanding of the mechanics behind the engine might be able to explain something for me.

The formula I'm playing around with is:

((a.atk+(a.atk/10*2))*(100/(100+b.def))+(a.atk-b.def))*5

When I plug in 86 attack and 20 Defense, I should come out with a result of 760

Instead, it comes out with a result of 330, which is only about 43% of what it should be. (and, coincidentally, only the (a.atk-b.def) portion of the formula)

Is there something I'm missing in terms of how ace's attack formulae work?

Edit: I think I kind of get it... the editor doesn't recognize parenthesis. Not sure what to do in terms of making this formula work without them ><
Tsukihime
So when you change the formula does the result also change?
If parentheses aren't recognized, then (a.atk - b.def)*5 would be evaluated as a.atk - (b.def * 5)

EDIT: here's your problem:

CODE
100/(100+b.def)


That evaluates to 0 since it's integer division.
It is standard ruby math operations.
Pillanious
QUOTE (Tsukihime @ Jun 5 2012, 03:33 PM) *
So when you change the formula does the result also change?
If parentheses aren't recognized, then (a.atk - b.def)*5 would be evaluated as a.atk - (b.def * 5)

EDIT: here's your problem:

CODE
100/(100+b.def)


That evaluates to 0 since it's integer division.
It is standard ruby math operations.


I didn't realize it was integer division.

Is there a means of getting around this in Ruby so that it's standard division?
Thallion
Just change it to this:

CODE
100.to_f/(100 + b.def)


It should work.
Tsukihime
CODE
100.0 / (100 + b.def)


Explicitly writing it as a float would also work.
Pillanious
QUOTE (Thallion @ Jun 5 2012, 04:02 PM) *
Just change it to this:

CODE
100.to_f/(100 + b.def)


It should work.



That fixed it all - Thanks guys smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.