Starting 19 Sep 2014, I've been working to derive formulas for damage dealt and damage received. Until these formulas are known, one cannot optimally assign stat points. [snip] Thanks, Imper1um for help getting to the source code. Reading source is much easier than derivation!

The computation for damage received:

Let eneatk = the enemy's attack

Let mydef = the player's defense

Let R = (eneatk/mydef)

if R < 6/91 (roughly .066) : baseDmg = (eneatk*449/480 - mydef/112) / 8

else if R < 30/119 (roughly .252) : baseDmg = eneatk*113/480 - mydef/112

else if R < 10/21 (roughly .476) : baseDmg = eneatk*33/80 - mydef*3/56

else if R < 6/7 (roughly .857) : baseDmg = eneatk*3/4 - mydef*3/14

else: baseDmg = eneatk - mydef*3/7

damage = baseDmg * randomInRange(.9,1.1) + (eneatk/400) * randomInRange(1,10) + randomInRange(-2,2)

if(dmg <= 0)

___ if(myMaxHP < 100){ //How is that even possible???

______ damage = Math.random() * myMaxHP * 0.09 + 1;

___ }else{

______ damage = randomInRange(1,11)

___ }

The take-away comes from looking at those R values (the ratio of atk/def). Each time you boost your defense past the next threshold, the value of points spent on defense diminishes.

So, at low def values, each extra def point decreases damage by 0.43.

Once def > 1.17*atk, each extra def point decreases damage by 0.21.

At def > 2.1*atk, each extra def point decreases damage by 0.054.

At def > 4*atk, each extra def point decreases damage by 0.0089.

If you ever bother to boost def > 15.17*atk, each extra def point decreases damage by only 0.0011

So, if you're trying to optimize your stat point distribution, it's important to know roughly how much attack the enemies will have in the areas you're fighting, and consider whether it's better to invest in def, HP, or perhaps just atk/agi/luc.

#### Additional Infomation Edit

If you have a recovery amulet (3.9%), it is always better to stop putting points in def at 2.1x, because beyond that one point in attack will give nearly as much effective defense.

When your def is 1x enemy attack, you take 58% damage

When your def is 2.1x enemy attack, you take 32% damage

when your def is 3.2x enemy attack, you take 25% damage

When your def is 4x enemy attack, you take 21% damage

When your def is 10x enemy attack, you take 16% damage

When your def is 25x enemy attack, you take 10% damage

As shown above, 4x enemy attack is a very important cutoff. After that cutoff, it takes nearly 5 points in def to get the same percentage reduction as one point did before.

Here's some simple targets for the game. The first number is a good target for everyone. The second number takes 2x points for 50% more defense and are an option if you choose to do a defensive build. Note that these are total defense, not base defense.

Jousting Fox - min: 3000 def. max: 6000

Eye Boss - 14,300 def. max: 27,200

Orochi - 162,000 def. max: 308,000

Black Mother - 256,000 def. max: 488,000

Suzaku - 605,000 def. max: 1,152,000

Genbu - 1,000,000 def. max: 1,904,000

*Note- For hard mode, multiply these numbers by 11.*

## Player Damage to Enemies Edit

Enemies also have a def value of sorts. The enemy's Point Value is used as its def. It's not a basic stat but rather is derived from a variety of factors, including the enemy's other stats as well as the level of the zone it is found in. However, it can be fairly well approximated as def = HP/30.

The damage formula is then basically

(atk - def*0.3) * 0.88

and then some random variation is added. ±10%

However, before this formula is applied, def is adjusted. If atk > def, all that happens is def is increased randomly by about 6-13%

But if def > atk, it is capped. The cap check is done twice. once before and once after the random increase.

First, it is capped to atk*1.07

Then the % increase is done based on the original def value

Then a cap of atk*1.47 is enforced.

So even with very high def (or very low atk) enemy's def can't reduce the player's damage by more than 44%.

_{Notes:
Crits increase atk before def is applied.
The caps are not true caps. It actually reduces the portion of def that exceeds the cap by 99% or 99.5%. In the case of extremely low atk such that damage would be zero or negative, damage is set to a random value from 1 to 10.}