# [RMMV] DAMAGE NOT WORKING

## Posts

Pages: 1
I have a problem and the answer is one of three:
- I don't know how to calculate a log correctly; or
- RMMV doesn't know how to do it; or
- I'm inputing the formula wrong (this is probably the case).

This is the damage formula for a regular attack (20% variance):

`Math.log(a.atk * 2.0, b.def + 1.0) * 10.0`

So, I run the test battle...

Hero Attack is 11 (this includes equipment), Defense is 13 (including equipment); Enemy Attack is 13; Defense is 9.
If I'm not mistaken, the Hero should cause around 13.4 points of damage (10.7 to 16.1)... and the engine shows 28 or 29...

Where's the error here? And how to correct this?
Marrend
20691
I'm going off VX Ace here, but, it might be because the "log(X)" function uses a base of e. Unless MV's different than VX Ace in this matter, the function to use for base 10 logs is "log10(X)".
GreatRedSpirit
ski-ba-bop-ba-dop-bop
6419
Yeah, according to the documentation of Math.log Marrend is correct and it is using e as its base. It also doesn't take a second parameter so the defense isn't being used in this case.

ln(26) * 10 is 32.58 so getting 28 and 29 isn't unsurprising with that base value.

e: There is a Math.log10 function but it also doesn't have as widespread support as Math.log .
Ok, that explains a lot. Thank you both, Marrend and GreatRedSpirit. Time to think about a new formula. :-)

GreatRedSpirit
ski-ba-bop-ba-dop-bop
6419
We had a thread on damage algorithms a while back, there might be some ideas you like in it or inspiration for your own.
Thanks for the link. For now, I'm tinkering with:

(Atk^2 / Def) + Atk

It has a nice curve. :-)
I actually like logarithmic scaling, as it works well with a linear stat growth. In a logarithmic system, the difference between 10 and 20 is of the same magnitude as the one between 1010 and 1020.
author=LightningLord2
I actually like logarithmic scaling, as it works well with a linear stat growth. In a logarithmic system, the difference between 10 and 20 is of the same magnitude as the one between 1010 and 1020.
Yes, that was what I intended to do at first, but I need to think a bit more about how to implement the damage formula.
In the end, it's just a way to deplete resources (HP) on a quick race (the one who still has HP left wins)... I just need to define how I want this race to proceed. :-)

EDIT: Or, as an alternative:

` b.def - a.atk > 11 ? Math.exp(a.atk/b.def) * 3.5 : Math.pow(Math.log(20 + a.atk - b.def), 3)`
Pages: 1