### Author Topic: Main Damage Formula - Type and Subtype explained  (Read 2462 times)

#### DLPB_

• Banned
• Posts: 11006
##### Main Damage Formula - Type and Subtype explained
« on: 2018-05-13 14:39:50 »
Damage formula is split into 2 parts [Use tool Wallmarket to have a better idea].  Let's use Conformer as an example.

First, the type of attack. Conformer uses A

A is Physical.  Check accuracy, Critical, and Ultimate Weapon formula (only used for the 9 ally Ultimate Weapons)

Next, the sub type.  Conformer uses 3.

3 sets the power value to be the average of enemy level.
3 is a subtype of A - so it HAS to be used with A.

The byte in full is thus A3, in the game, at Attacker's Data (99E308) + 40.

The game actually splits this back up into A and 3 in function 5D17C7 and places these values in Attacker's Data (99E308) + A0 and Attacker's Data (99E308) + A4.

From here, for some reason, it assigns another value for the type and subtype based on these values.

Conformer ends up with a Type of 5 (from table 8FF068) and a Subtype of D (from table 7B7720).

From here, 5 and D (for Conformer) are also used for other functions and to set certain conditions.

The alternate SubType value is placed in Attacker's Data (99E308) + BC

The alternate Type value is used (in function 5D17C7) to set other conditions (3 total).

If a Physical attack is set, it will set an unknown flag to Attacker's Data (99E308) + 6C.

If Special Formula (Type 7) is set, it does a meaningless(?) check to make sure that the Subtype lies within a range.

If Ultimate Weapon formula is set (A), it will assign a Subtype flag to Attacker's Data (99E308) + BC. As stated above, for Conformer, this is D.

The Ultimate Weapon power is calculated from hardcoded data at function 5DC880.
Since Yuffie's Conformer is set to use Subtype  03 (changed by engine, remember, to 0D) the jump at 5DC901 will be to 5DCD83 [Set power value to Enemy average level].

And there you go.  Funnily enough, the engine does something strange there and sets eax to 1 and then tests if it is 0.  lmao. Not sure why?

So, the function 5DC880 deals with the 9 Ultimate Weapon calcs. It uses jumps 0A, 0B, 0C, 0D, 1E, 1F, 20, 21, 22.

It's likely many more of the core calculations are done in this same function, and I will be testing that soon.

« Last Edit: 2018-05-13 15:39:46 by DLPB »

#### nfitc1

• Posts: 3006
• I just don't know what went wrong.
##### Re: Main Damage Formula - Type and Subtype explained
« Reply #1 on: 2018-05-14 03:16:16 »
No, the damage formula is really one part. The actual damage consideration is a single byte with two distinct nybbles. The upper nybble (X) determines a few considerations, but not damage directly. The lower nybble (Y) is what actually chooses which damage function to use.

Accuracy Checks are a two-stage look-up process. There's an array at 0x7B7700 that defines which accuracy checks to use with which accuracy consideration. The values range between 0 and 8 with 8 being the terminator of the sequence. These check methods are located at 0x7B77A8. There are 8 of them with three of them being pointers even though they are called. They determine three other things: whether the action is physical or magical, whether to use the special formulae (or stat-independent formulae if you want to be really specific about it, but that's a mouthful), and whether to apply the ultimate weapon modifiers. These are determined by a bit mask located at 0x8FF068. There is a single byte for each accuracy value and it follows this mask:

Code: [Select]
`0x0=Magical0x1=Physical0x2=Secondary Formulae0x4=Multipliers`
There IS an entry for a magical action that uses the special formulae, but it is unused. Seems a shame to me. Due to some weird memory handling, secondary formulae cannot be combined with the multipliers.

Check out the look up table at 0x8FF1F8. That's where the pointers to the different damage calculations are. It even has the special formulae starting at 0x8FF238.

The AY accuracy function has a secondary effect of setting a special effect to the action based on the damage value provided (this array is located at 0x7B7720) then uses the standard X1 damage formula.
« Last Edit: 2018-05-14 03:34:02 by NFITC1 »

#### DLPB_

• Banned
• Posts: 11006
##### Re: Main Damage Formula - Type and Subtype explained
« Reply #2 on: 2018-05-14 10:37:36 »
Oh yeah I get that   It's just the game splits up the two, as you have in Wallmarket - and then assigns flags and functions based on one part and the other.

I also saw the look up table at 8FF1F8, but the function that contains the Ultimate Weapon formulas seems to hold a lot more besides.  Haven't looked into what other stuff it has.

8FF238  seems to hold the Special formula (not Ultimate Weapons)
« Last Edit: 2018-05-14 10:40:03 by DLPB »

#### nfitc1

• Posts: 3006
• I just don't know what went wrong.
##### Re: Main Damage Formula - Type and Subtype explained
« Reply #3 on: 2018-05-14 14:00:17 »
... the function that contains the Ultimate Weapon formulas seems to hold a lot more besides.  Haven't looked into what other stuff it has.

If you're talking about what I think you're talking about then that's the Additional Effects handler function.