July 28, 2021, 07:12:29 pm

## Looking for Linear PA damage formulas (switching punch formulas)

Started by Ansehelm, February 24, 2021, 11:33:15 pm

#### Ansehelm

##### February 24, 2021, 11:33:15 pm
I'm going to standardize damage in my mod by switching punch abilities to linear damage. AFAIK there aren't any straight PA*X abilities that don't also involve WP, so I'm looking for an ASM that changes a formula to PA*X.  Also, how does one change the standard punch/barehanded attack formula (not the individual punch art abilities)?
• Modding version: PSX

#### nitwit

##### February 25, 2021, 12:47:48 pm #1
There are a few ASM hacks and spreadsheets related to that, but nothing that does that specific thing.

Start here:
https://ffhacktics.com/wiki/Base_XA_Calculation

Ctrl f XA here:
https://ffhacktics.com/wiki/Routine_Locations

You'll reference this in whatever formulas you use:
https://ffhacktics.com/wiki/Battle_Stats

The simplest way to make unarmed linear is to make it use base PA instead of current PA for one of the operands in the unarmed formula.

Back to the Base XA calculation, look at this part:
`00185ae0: 14600014 bne r3,r0,0x00185b34        Branch if a weapon is equipped //if no weapon, execute following code00185ae4: 00b00018 mult r5,r16                 Brave * PA00185ae8: 00001812 mflo r3                     r3 = Brave * PA00185aec: 3c0251eb lui r2,0x51eb00185af0: 3442851f ori r2,r2,0x851f00185af4: 00620018 mult r3,r2                  Brave * PA * 0.3200185af8: 3c018019 lui r1,0x801900185afc: a43038ce sh r16,0x38ce(r1)           Store XA = PA00185b00: 00031fc3 sra r3,r3,0x1f00185b04: 00001010 mfhi r2                     r2 = Brave * PA * 0.3200185b08: 00021143 sra r2,r2,0x05              Brave * PA * 0.32 / 32 (or Brave *  PA / 100)00185b0c: 00431823 subu r3,r2,r300185b10: 00031400 sll r2,r3,0x10              Brave * PA / 100 * 6553600185b14: 3c018019 lui r1,0x801900185b18: a42338d0 sh r3,0x38d0(r1)            Store YA = Brave * PA / 10000185b1c: 14400058 bne r2,r0,0x00185c80        Branch if YA > 000185b20: 24620001 addiu r2,r3,0x0001          r2 = YA + 1 (minimum of 1 YA)00185b24: 3c018019 lui r1,0x801900185b28: a42238d0 sh r2,0x38d0(r1)            Store YA = 100185b2c: 08061720 j 0x00185c80                Jump to end00185b30: 00000000 nop`
You'll need to make room for another load like this, but for base PA:
`00185ad4: 90500036 lbu r16,0x0036(r2)          Load Attacker's PA`
I don't know what you could condense/remove to accomplish that, but there's probably something in there that bears removing or could be simplified.
• Modding version: PSX