[Discussion]Physical Damage Formula

If you are stuck in the Dunan Unification Wars; or wish for more details on the gameplay systems, this is the place.
Post Reply
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

[Discussion]Physical Damage Formula

Post by like2h »

I'm trying to understand more about the physical damage formula in S2. Any insights are appreciated.
Omnigamer wrote: Thu Feb 26, 2015 2:47 pm Thus I think the actual physical attack formula is something like:

DAMAGE = (((Offense_ATK * FURY_MOD) + RAND(3:8)) - Defense_PROT ) * ATTACK_MOD

Consider the Mist Shade case. His listed PROT is 10, meaning any incoming attacks should have a flat reduction of 10. A level 2 Riou will have either 16 or 17 STR and a WPN bonus of 5, giving his total ATK of about 21. By most logic, he should do 11 damage against the Shade.

However, out of 7-8 attempts for this, Riou managed to deal damage in the range of 14 to 17 damage pretty consistently. One case is that the Mist Shade's listed PROT is slightly off, but the variation range still implies that some randomness affects the final damage. I think I remember seeing something like this when I was debugging some other battle formulas, but I didn't pay much heed to it. This is also backed up by similar tests with Bolgan; with an ATK of 32, Bolgan would do between 26 and 30 damage.

Unite attacks also get an odd treatment in this regard. I had one case where the Circus Attack Unite did 132 damage against the Mist Shade. On a different use, it did 164. A swing of 32 damage is pretty huge; normal calculations say the attack should do 152 damage with all the characters' strengths taken into account. For this to happen, the random extra damage would need to cover a range of at least 6 and apply to each character individually before the 2x multiplier is applied. This makes the damage fairly unpredictable.

It should be noted that this doesn't happen at the high end. For example, using Kindness Rune glitch to get 999 ATK causes that character to always hit for the same amount of damage, at least from what I've seen. The damage exactly matches what it should be according to the given formula too. So this means that the 999 cap is applied after any additional random damage is added to the attack. This is also true for specialty rune attacks, like Shin's Spider Slay.
I feel this theory seems solid, except the RAND range may be 1-9 instead of 3-8. I'll run some more tests to check.
User avatar
wataru14
Guide Writer
Posts: 724
Joined: Thu Aug 05, 2010 10:37 am
Location: Las Vegas

Re: [Discussion]Physical Damage Formula

Post by wataru14 »

From what I've seen, United attacks calculate each participant's damage individually, combines the result, and then adjusts for the multiplier. So I think you're onto something.
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

I've found that using rand(1:9) works well with unite attacks like the Circus Attack and physical rune attacks such as Fire Breath Rune. For instance, with Circus Attack, rand(1:9) eventually yields rand(6:54).
I've developed a growing interest in understanding the formulas on the enemy's side, which seem more mysterious since we lack the specific attack and magic power values for each enemy.
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

For Riou and Nanami,
If their final damage is 2n + 1, then each hit is (n) and (n+1). If it's 2n, then each hit is (n) and (n) respectively.
Julian
Posts: 87
Joined: Wed Jan 29, 2014 9:17 pm

Re: [Discussion]Physical Damage Formula

Post by Julian »

I haven't done much research on S2 formulas yet.

In S1, unite damage was literally calculate individual damage for each character, sum, then multiply by the multiplier.

Looking at what I've found in S2, the base formula seems to be:

Damage = Attacker STR - Target PDF (Note: I haven't done a ton of research here, I assume these have added the various weapon bonuses and other stuff)
If damage < 0, damage = 0

If damage > 5: damage = damage + rand(8) + 1 (so random range of 1 to 9)
If damage <= 5: damage = damage + rand(2) + 1 (so random range 1 to 3)

I'm seeing a few rune checks after the damage is calculated:

Hunter Rune, damage = 1
Double Strike, damage = damage * 2
Some status effect or flag on the target: damage = damage * 2
Some other status or flag effect on the target: damage = damage / 2

I assume any other rune or bonuses is done when calculating the battle "STR". That's all I got for now. S2 battle code is a looooooooooooooot more complicated than 1. lol
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

Thanks Julian, that helps a lot.
The rand() syntax can be confusing at times. When you said rand(8), you meant [0,1,2,...,8], not [0,1,2,...,7], right?
In S1, unite damage was literally calculate individual damage for each character, sum, then multiply by the multiplier.
It's highly possible they used the same method to calculate damage in S2.
If damage < 0, damage = 0
If damage <= 5: damage = damage + rand(2) + 1 (so random range 1 to 3)
Now, we have a better understanding of the low-end damage.
Double Strike, damage = damage * 2
This is interesting. It'd be great if someone could check the PS version to confirm if it's 1.5 or 2. From what I know, the PC version is 2, and Japanese sources, including the official guidebook, support this. However, I vaguely remember the PS version being 1.5.
Julian
Posts: 87
Joined: Wed Jan 29, 2014 9:17 pm

Re: [Discussion]Physical Damage Formula

Post by Julian »

Sorry, these games abuse the crap out of rand() and do some really weird shoot with it.

rand() is supposed to just give you a random number from 0 to max, and you usually write something like rand() % 50 to get a value 0-49.

S2 has two functions that use rand(). One of them, let's say rand_normal(int value) returns rand() % value, so 0 to value-1. The other, let's say, rand_plus_one(int value) returns rand() % (value + 1). So rand_plus_one(9) gives 0-9.

The attack function uses the latter, so it's 0 to 8. Normally using that syntax it woulda meant 0-7. My bad. Been looking at too much assembly.
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

I tested a lot against Double Head. It has three types of attacks - one physical and two magical, all of which target the whole party. Nice target for testing!

Using 'Defend' reduces physical damage taken by half, while magic damage is reduced to 2/3.

It was more difficult than expected to figure out the enemy's damage randomization range. I feel it's slightly lower than 9-1=8, maybe 7.

Additionally, the low end damage appears to function differently for the enemies. It seems that if their damage calculation results in 0 or less, it gets set to a small amount like [0, 1, 2] instead.
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

viewtopic.php?p=160854#p160854
HIT is like TECH, but defined separately for each enemy attack. Typically it's close to enemy's TECH, but if you need a precise calculation, you can't fully rely on the TECH value that is listed in the bestiary.
Can't believe they set separate power and hit rate for each enemy attack!
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

S2 has two functions that use rand(). One of them, let's say rand_normal(int value) returns rand() % value, so 0 to value-1. The other, let's say, rand_plus_one(int value) returns rand() % (value + 1). So rand_plus_one(9) gives 0-9.
Maybe it is like enemies use rand_normal(8), while characters use rand_plus_one(8).
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

As I push through the game, I found something interesting about the 'Boost' status:

Suikosource says it lasts 3 turns and doubles MAG stat. It also says STR is replaced by MAGx2, but I think they meant ATK not STR. After Boost ends, the user takes half damage inflicted during Boost, minus 15.

From my tests, I'd say Boost actually lasts 4 turns, counting the turn the character gets the status. And on the PSP version, the post-Boost damage taken is exactly half.

It seems characters already Berserked from the Fury Rune can't get Boost - maybe statuses don't stack?
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

On the PSP version, the double-strike rune is indeed 2x.
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

Exertion Rune
Weapon effect:
ATK * (1 + 0.20 * (number of battle rounds) ) until the multiplier reaches 2.2 (6th round). This means the user starts the battle with ATK x1.2.
After some tests, I think it is 0.17 instead of 0.20. Hope someone can check it out.

Edit: It seems 0.17 is still a little too big when the turns add up. So tricky!

Edit2: Maybe it is calculated by first multiplying 0.17 by atk, flooring that product, then multiplying it by the turn number. Ah, Flooring!

Edit3:1/6 seems a nice number. Need more tests.

Edit4: How stupid I was! It was just in the official guidebook. Could this also be a PSP difference?
戦闘中、毎ターンごとに攻撃力がアップ(攻撃力=基本攻撃力+基本攻撃力×ターン数/6 最高2倍までアップ)
KFCrispy
Global Admin
Posts: 6199
Joined: Wed Jun 30, 2004 3:29 pm

Re: [Discussion]Physical Damage Formula

Post by KFCrispy »

so does Exertion Rune's max multiplier start as 1 and 1/6th, ending with 2 and 1/6th?
like2h
Posts: 70
Joined: Fri Oct 09, 2015 12:09 am

Re: [Discussion]Physical Damage Formula

Post by like2h »

KFCrispy wrote: Thu Jan 04, 2024 3:04 pm so does Exertion Rune's max multiplier start as 1 and 1/6th, ending with 2 and 1/6th?
For Exertion Rune:

Attack = Attack × (1 + turn number/6)

It starts at (1+1/6) at the first turn and ends with (1+6/6=2) at the 6th turn.

I also found the Fury Rune's check is done after applying the Exertion Rune.

For example, with an initial Attack of 70:

Attack at the first turn is

70×7/6=81, 81×1.5=121

Not

70×1.5=105, 105×7/6=122
Post Reply