• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
May 01, 2024, 05:35:30 am

News:

Don't be hasty to start your own mod; all our FFT modding projects are greatly understaffed! Find out how you can help in the Recruitment section or our Discord!


ASM Collective BATTLE.BIN Map

Started by formerdeathcorps, January 06, 2011, 05:09:33 am

Pickle Girl Fanboy

When this is done, will we be able to give all status effects charge times?

formerdeathcorps

April 13, 2011, 06:59:35 am #61 Last Edit: April 21, 2011, 08:56:10 pm by formerdeathcorps
That's tangentially covered by this hack when I rewrite how unit RAM is read and written (but that's likely much later, once I get a handle of how the AI reads unit RAM data).  However, the lower hanging fruit (i.e. simply getting 2 statii to share 1 timer as long as they are mutually canceling), is certainly within my reach.

Just finished my elemental resistance/weakness hack.  Onwards to equipment break/steal!
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

formerdeathcorps

April 17, 2011, 05:29:27 am #62 Last Edit: April 17, 2011, 06:01:35 am by formerdeathcorps
OK, here's some AI unit RAM stuff:

0x19F3C4 (RAM byte)
This is the current skill set of the move being considered by the AI.

0x19F3C6 (RAM halfword)
This is the current move being considered by the AI.

0x19F3C8 (RAM byte)
This is the range of the current move being considered by the AI.

0x19F3C9 (RAM byte)
This is the AoE of the current move being considered by the AI.

0x19F3CA (RAM byte)
This is the item destroyed/stolen by the current move being considered by the AI.

0x19F3D0 (RAM 3 bytes)
Here's where the AI behavior bytes for the move currently under consideration are stored.

0x19F3E0 (RAM byte)
Byte = the Yth unit on the map, though units 0x10 and above are player units

0x19F3E1 (RAM byte)
A copy of 0x19FEC4.

0x19F3E2 (RAM halfword)
A copy of 0x19FEC6, except that if the move isn't usable, it won't be copied.

0x19F3E8 (RAM byte)
A copy of 0x19FECA.

0x19FEF5 (RAM byte)
Here's where the base accuracy is stored for the AI.

0x1A02B4 + 0x88*Y (RAM...sequence of words starts here...Y refers to the Yth unit on the map...though units 0x10 and above are player units)
Here are the moves of the target the AI commanded unit wants to attack---order is:
1) Halfword for the Ability/R/S/M (meaning getting the AI to consider reactions shouldn't be hard...Byte 2 can take any value that leaves a remainder of 0 or 1 when divided by 4)
2) Halfword for ??? (job of the target in byte 1 [default skillset for the basic ATTACK move 0x16F is A9, but move 0x00 is also ATTACK, with a job class 0xFF, which defaults to job class 0x1, which is named "Attack"] and priority of use in byte 2?...Byte 1 gets copied to 0x19F3C4; Byte 2 gets copied to 0x19F3D3...Byte 2 gains 0x80 if checked already by the routine that checks all the moves [which is reset to lose the 0x80s when the same routine checks the data again]; during the final check, only the move that the AI will actually use will get the 0x80 flag at 0x19F3D3, everything else won't, moves that do not have the first Unknown trigger under "Learn on Hit" will never be written into 0x19F3E2 and thus will not be considered during this final check)
3) The spacing implies a unit can't have more than 0x22 or 34 independent moves (between a primary/secondary + 00 Attack + 0x16F attack).  It also is the primary reason why the AI can't check for counters...insufficient space, though since the AI shouldn't need that redundancy for attack, we might as well take that space for reactions.

Routine Process:
1) Check all moves of all units on map (includes self)
2) Check self moves at least twice (last time seems to actually determine what moves to use)
3) Act
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

pokeytax

Wow, that's fantastic, good stuff.
  • Modding version: PSX

formerdeathcorps

April 21, 2011, 08:54:44 pm #64 Last Edit: May 26, 2011, 03:29:26 am by formerdeathcorps
This is the latest version, which should have no more pipeline hazard and signed/unsigned problems, as well as float nulling earth (I forgot this) and my notation on the hit byte (0x2 means your formula was a % formula).  Another bug fixed was one AI flag being used in two separate routines.

Another fixed bug is that weapon elemental on weapon strike weapon wasn't being considered for elemental boost/halve, and float was nulling wind, not earth.

lui r1, 0x8019
lbu r3, 0x38F9 (r1) Loads X
lw r2, 0x2D94 (r1) Loads the attacker's stats
addiu r6, r1, 0x38CE r6 = XA1's address
addiu r7, r1, 0x38D0 r7 = XA2's address
andi r3, r3, 0x000F r3 = the last 4 bits of X
(LS) sltiu r4, r3, 0x0004
bne r4, r0, (*) If r3 < 4, GOTO (*)
lbu r5, 0x0036 (r2) r5 = Attacker PA
sltiu r4, r3, 0x0008
bne r4, r0, (*) If r3 < 8, GOTO (*)
lbu r5, 0x0037 (r2) r5 = Attacker MA
sltiu r4, r3, 0x000C
bne r4, r0, (*) If r3 < 12, GOTO (*)
lbu r5, 0x0038 (r2) r5 = Attacker SP
nop
lbu r5, 0x3902 (r1) r5 = Attacker WP
(*) beq r6, r7, (E) If r6 = r7, GOTO End.
sb r5, 0x0000 (r6) Stores r5 at the address of r6
andi r3, r3, 0x0003
sll r3, r3, 0x0002
addiu r3, r3, 0x0001 The purpose of these r3 manipulations is to put r3 in a form that the previous loop can understand.
j (LS) Jumps back to the Loop's Start.
addiu r6, r6, 0x0002 r6 = r6 + 2 = r7 = XA2's address
(E) jr 31 Returns to the Main Formula Routine.
nop


lbu r6, 0x3904 (r1) r6 = Weapon Elemental
lbu r4, 0x38F3 (r1) r4 = Ability Flags Byte 1
lbu r5, 0x38F7 (r1) r5 = Ability Elemental
andi r7, r4, 0x0004
beq r7, r0 (E) If Weapon Strike is not flagged, GOTO (E)
nop
or r5, r5, r6 ELSE, Ability Elemental = Weapon Elemental + Ability Elemental
(E) jr 31 Returns to the Main Formula Routine.
sb r5, 0x38F7 (r1) Store new Ability Elemental


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x0071 (r2) Loads elements strengthened
lhu r6, 0x38D0 (r1) Loads XA2
and r4, r4, r5 Checks ability element against elements strengthened
beq r4, r0, (E) If ability element isn't a boosted element, GOTO (E)
srl r5, r6, 0x02 If ability element is boosted, r5 = [XA2/4]
addu r6, r6, r5 XA2 = XA2 + [XA2/4]
(E)  jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2


lw r5, 0x2D98 (r1) Load target address.
ori r4, r0, 0x0005
beq r3, r4, (E) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If XA2 is MA, GOTO (E)
lbu r6, 0x005C (r5) Load Status Byte 5.
lbu r7, 0x0058 (r5) Load Status Byte 1.
lbu r5, 0x005A (r5) Load Status Byte 3.
andi r6, r6, 0x0010
bne r6, r0, (Mult) If target is asleep, GOTO (Mult)
andi r7, r7, 0x0008
bne r7, r0, (Mult) If target is charging, GOTO (Mult)
andi r5, r5, 0x0006
beq r5, r0, (E) If target isn't chickened/frogged, GOTO (E)
(Mult) lhu r4, 0x38D0 (r1) Load XA2.
nop
srl r5, r4, 0x01 r5 = [XA2/2]
addu r4, r4, r5 XA2 = XA2 + [XA2/2]
sh r4, 0x38D0 (r1) Store XA2.
(E) jr 31 Return to Main Routine
nop

ori r4, r0, 0x0005
beq r4, r3, (MA) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If r3 is MA, GOTO (MA)
addu r7, r31, r0 Stores the return address in r7 because it'll be modified by the jal commands below.
ori r4, r0, 0x000D
bne r4, r3, (PA/SP) If r3 isn't WP, GOTO (PA/SP)
lbu r5, 0x38D9 (r1)  Loads the "Two Hands" byte.
jal (WP-UP) If WP, GOTO (WP-UP)
lbu r4, 0x38FF (r1) Loads weapon characteristic byte.
(PA/SP) jal (P-UP) If PA/SP, GOTO (P-UP)
lbu r3, 0x38D8 (r1) Loads Weapon Type byte.
j (E1) GOTO (E1)
nop
(MA) jal (M-UP) If MA, GOTO (M-UP)
lbu r3, 0x0090 (r2) Loads Support Byte 4.
(E1) jr 7 Return to Main Routine
nop

(WP-UP) lhu r6, 0x38D0 (r1) Loads XA2 = WP
beq r5, r0, (E2) If not using two-hands, GOTO (E2)
andi r3, r4, 0x0001
bne r3, r0, (E2) If weapon is forced two-hands, GOTO (E2)
andi r5, r4, 0x0004
beq r5, r0, (E2) If weapon is not two-handable, GOTO (E2)
sll r6, r6, 0x01
sh r6, 0x38D0 (r1) If 2H is used and XA2 is WP, XA2 = XA2 * 2.
(E2) jr 31
nop
(P-UP) lbu r4, 0x0091 (r1) Loads Support Byte 5.
bne r3, r0, (A-UP)  If equipping a weapon, GOTO (A-UP)
lhu r5, 0x38D0 (r1) Loads XA2 = PA or SP.
andi r4, r4, 0x0020
beq r4, r0, (A-UP) If Martial Arts isn't used, GOTO (A-UP)
srl r6, r5, 0x01
addu r6, r5, r6
sh r6, 0x38D0 (r1) If Martial Arts is used and XA2 is PA or SP, XA2 = XA2 + [XA2/2].
(A-UP) lbu r3, 0x0090 (r2) Loads Support Byte 4.
lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0010
beq r5, r0, (E3)  If Attack Up isn't used, GOTO (E3)
lhu r3, 0x38D0 (r1) Loads XA2.
(Mult) addiu r4, r4, 0x5556 r4 = 55555556 as a multiplier against FFFFFFFF.  In simple terms, this is 1/3.
sll r3, r3, 0x02
mult r4, r3 Term on HI is XA2 * 4 * 1/3.
sra r3, r3, 0x1F r3 = 0.
mfhi r4
nop
subu r4, r4, r3 r4 = r4 - 0.
sh r4, 0x38D0 (r1)  If ATTACK or MAGIC ATTACK UP is flagged, XA2 = XA2 * 4/3.
(E3) jr r31
nop

(M-UP) lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0004
beq r5, r0, (E3) If Magic Attack Up isn't used, GOTO (E3)
lhu r3, 0x38D0 (r1)  Loads XA2.
j (Mult) GOTO (Mult)
nop


addu r2, r31, r0 r2 = Return Address, because r31 will be modified below by the jal commands.
lw r3, 0x2D98 (r1) Load target address.
lhu r5, 0x38D6 (r1) r5 = Used Ability ID
lui r4, 0x8006
sll r5, r5, 0x03 r5 = r5 * 8
addu r4, r4, r5
lbu r5, -0x140A (r4) r5 = AI Byte 4
lbu r6, 0x005B (r3) r6 = Status Byte 4
andi r4, r5, 0x0002
beq r4, r0 (Prot) If AI flag Magic Defense Up is not checked, GOTO (Prot)
andi r7, r6, 0x0010
beq r7, r0 (Prot) If target does not have Shell, GOTO (Prot)
nop
jal (Mult) If target has Shell and skill is blocked by Shell, GOTO (Mult)
nop
(Prot) andi r4, r5, 0x0001
beq r4, r0 (MADEF) If AI flag Defense Up is not checked, GOTO (MADEF)
andi r7, r6, 0x0020
beq r7, r0 (MADEF) If target does not have Protect, GOTO (MADEF)
nop
jal (Mult) If target has Protect and skill is blocked by Protect, GOTO (Mult)
(MADEF) lbu r6, 0x0090 (r3) r6 = Support Byte 2
andi r4, r5, 0x0002
beq r4, r0 (DEFUP) If AI flag Magic Defense Up is not checked, GOTO (DEFUP)
andi r7, r6, 0x0002
beq r7, r0 (DEFUP) If target does not have Magic Defense Up, GOTO (DEFUP)
nop
jal (Mult) If target has Magic Defense Up and skill is blocked by Shell, GOTO (Mult)
(DEFUP) andi r5, r5, 0x0001
beq r5, r0 (E) If AI flag Defense Up is not checked, GOTO (E)
andi r6, r6, 0x0008
beq r6, r0 (E) If target does not have Defense Up, GOTO (E)
nop
jal (Mult) If target has Defense Up and skill is blocked by Protect, GOTO (Mult)
nop
(E) jr r2 Return to Main Routine
nop

(Mult) lui r4, 0xAAAA
lhu r7, 0x38D0 (r1) r7 = XA2
addiu r4, r4, 0xAAAB r4 = AAAAAAAB
multu r7, r4
mfhi r7 r7 = XA2 * 2/3
nop
jr 31 Return to Protect/Shell/MADEF/DEFUP Routine
sh r7, 0x38D0 (r1) XA2 = XA2 * 2/3


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x006F (r3) Loads elements halved
lhu r6, 0x38D0 (r1) Load XA2
and r4, r4, r5 Checks ability element against elements halved
beq r4, r0, (E) If ability element isn't a halved element, GOTO (E)
lw r2, 0x2D94 (r1) Loads attacker address
srl r6, r6, 0x01 If ability element is halved, XA2 = [XA2/2]
(E) jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2


lhu r7, 0x38CE (r1) Loads XA1
lbu r4, 0x38E5 (r1) Loads Formula
lbu r3, 0x38FA (r1) Loads Y
addiu r5, r0, 0x0008
beq r5, r4, (F8) If Formula 8 (I'll change this to some other number later), GOTO (F8).
addiu r6, r0, 0x0009
beq r6, r4, (F9) If Formula 9 (I'll change this to some other number later), GOTO (F9).
addiu r5, r0, 0x000A
beq r5, r4, (FA) If Formula A (I'll change this to some other number later), GOTO (FA).
addiu r6, r0, 0x000B
beq r6, r4, (FB) If Formula B (I'll change this to some other number later), GOTO (FB).
addu r7, r7, r3 r7 = XA1 + Y
lhu r4, 0x38D0 (r1) r4 = XA2
nop
addu r4, r7, r4
jr 31 Return to Main Routine
sb r4, 0x38D0 (r1) XA2 = XA1 + XA2 + Y
(FB) srl r7, r7, 0x01 XA1 = (XA1 + Y) / 2
j (E)
(FA) srl r6, r3, 0x03 r6 = [Y/8]
andi r3, r3, 0x0007 r3 = last 3 bits of Y
beq r3, r0, (Calc)
lbu r5, 0x0036 (r2) r5 = PA if r3 = 0
addiu r4, r0, 0x0001
beq r3, r4, (Calc)
lbu r5, 0x0037 (r2) r5 = MA if r3 = 1
addiu r4, r0, 0x0002
beq r3, r4, (Calc)
lbu r5, 0x0038 (r2) r5 = SP if r3 = 2
addiu r4, r0, 0x0003
beq r3, r4, (Calc)
lbu r5, 0x3902 (r1) r5 = WP if r3 = 3
addiu r4, r0, 0x0004
beq r3, r4, (Div4)
lbu r5, 0x0022 (r2) r5 = LVL if r3 = 4
addiu r4, r0, 0x0005
beq r3, r4, (Check)
addu r5, r2, 0x003E Readies the check where r5 = WEV1 if r3 = 5
addiu r4, r0, 0x0006
beq r3, r4, (Check)
addu r5, r2, 0x0045 Readies the check where r5 = SMEV1 if r3 = 6
addu r5, r2, 0x0041 Readies the check where r5 = SPEV1 if r3 = 7
(Check) lbu r4, 0x0000 (r5) r4 = RH equipment evasion.
bne r4, r0, (DivCheck) Checks RH equipment for evasion.
sltiu r3, r3, 0x0007 r3 = 1 if r3 < 7. r3 = 0 if r3 = 7.
lbu r4, 0x0001 (r5) r4 = LH equipment evasion.
(DivCheck) beq r3, r0 (Div3) If r3 = 0 (original r3 = 7), GOTO (Div3)
addu r5, r4, r0 r5 = r4
j (Calc)
srl r5, r5, 0x01 r5 = r5 / 2...this allows the SM-EV and W-EV used in formulas to cap at 25-30 in vanilla.
(Div3) lui r4, 0x5555
addu r4, r4, 0x5556
mult r5, r4
mfhi r5 r5 = r5 / 3...this allows the SP-EV used in formulas to cap at 25 in vanilla.
j (Calc)
nop
(Div4) j (Calc)
srl r5, r5, 0x02 r5 = r5 / 4...this allows the LVL used in formulas to cap at 25 in vanilla.
(Calc) bne r5, r0 (Nonzero) If r5 is not zero, GOTO (Nonzero)
nop
addiu r5, r0, 0x0001
(Nonzero) addu r7, r7, r5 r7 = XA1 + r5 (which we'll now call YA3)
srl r7, r7, 0x01 r7 = (XA1 + YA3) / 2
j (E)
addu r7, r7, r6 XA1 = (XA1 + YA3) / 2 + [Y/8]
(F9) andi r5, r3, 0x0008 r5 = first bit of Y
beq r5, r0 (Sorter)
srl r6, r3, 0x04 r6 = [Y/16]
lw r2, 0x2D98 (r1) Load the target's stats.
(Sorter) andi r5, r3, 0x0003 r5 = last 2 bits of Y
andi r3, r3, 0x0004 r3 = second bit of Y
beq r5, r0 (Divider1)
addiu r4, r2, 0x0028 Readies the check where r4 = curHP if r5 = 0
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider1)
addiu r4, r2, 0x002C Readies the check where r4 = curMP if r5 = 0 (original r5 = 1).
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider2)
lbu r4, 0x0024 (r2) r4 = Br of target or caster if r5 = 0 (original r5 = 2)
lbu r5, 0x005C (r2) r5 = Status Byte 5 on target or caster if r5 = 1 (original r5 = 3)
lbu r4, 0x0026 (r2) r4 = Fa of target or caster if r5 = 1 (original r5 = 3)
andi r5, r5 0x00C0
beq r5, r0 (Divider2) If not Innocent or Faith, GOTO (Divider2)
nop
sltiu r5, r5, 0x0080 r5 = 1 if Innocent.  r5 = 0 if Faith.
beq r5, r0 (Divider2) If Faith, GOTO (Divider2)
addiu r4, r0, 0x0064 r4 = 100
addiu r4, r0, 0x0000 ELSE, r4 = 0
(Divider2) beq r3, r0 (Div100) If r3 = 0 (normal), GOTO (Div100)
addiu r5, r0, 0x0064 r5 = 100
subu r4, r5, r4 If r3 = 1 (reversed stats), r4 = 100 - (BR or Adjusted FA)
(Div100) mult r7, r4
mflo r4 r4 = XA1 * BR/FA/UnBr/UnFa
lui r5, 0x028F
addiu r5, r5, 0x5C29
mult r4, r5
mfhi r5 r5 = XA1 * Br/Fa/UnBr/UnFa / 100
nop
j (E)
addu r7, r5, r6 XA1 = (XA1 * Br/Fa/UnBr/UnFa / 100) + [Y/16]
(Divider1) lhu r5, 0x0000 (r4) r5 = curHP or curMP
beq r3, r0 (OverMax) If r3 = 0 (normal), GOTO (OverMax)
lhu r4, 0x0002 (r4) r4 = maxHP or maxMP
subu r5, r4, r5 If r3 = 1 (reversed stats), r4 = max-cur HP/MP
(OverMax) mult r7, r5
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP
nop
nop
div r5, r4
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP / maxHP/MP
nop
j (E)
addu r7, r5, r6 XA1 = (XA1 * curHP/max-curHP/curMP/max-curMP / maxHP/MP) + [Y/16]
(F8) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...XA1-1}
nop
addiu r7, r7, 0x0001 r7 = {1...XA1}
addu r7, r7, r3 XA1 = {1...XA1}+Y
(E) jr 31 Return to Main Routine
sb r7, 0x38CE (r1) Store modified XA1.


lw r2, 0x2D94 (r1) Loads the attacker's stats
lw r3, 0x2D98 (r1) Loads the defender's stats
lui r7, 0x8006
lhu r6, 0x38D6 (r1) r6 = Used Ability ID
lbu r4, 0x0009 (r2) Loads the attacker's Zodiac Sign Byte
sll r6, r6, 0x03 r6 = r6 * 8
addu r7, r7, r6
lbu r7, -0x140D (r7) r7 = AI Byte 1 for attack
addiu r6, r0, 0x000C
andi r7, r7, 0x0010 Checks if the currently unused flag under "Learn on Hit" is flagged.
bne r7, r0, (E) If flagged, GOTO (E)
lbu r5, 0x0009 (r3) Loads the defender's Zodiac Sign Byte
srl r4, r4, 0x04 Gets the attacker byte's upper 4 bits.
beq r4, r6, (E) If Attacker sign is Ophiuchus, GOTO (E)
srl r5, r5, 0x04 Gets the defender byte's upper 4 bits.
beq r5, r6, (E) If Defender sign is Ophiuchus, GOTO (E)
andi r7, r4, 0x0003 r7 = the lower 2 bits of attacker sign
andi r6, r5, 0x0003 r6 = the lower 2 bits of defender sign
beq r6, r7, (Good) If attacker and defender signs differ by 4, GOTO (Good)
lbu r1, 0x38D0 (r1) r1 = XA2
addiu r7, r0, 0x0002
addiu r6, r0, 0x0006
(MOD) div r4, r6
mfhi r4 r4 = r4 MOD r6...MOD means you take the remainder of the division.
nop
nop
div r5, r6
mfhi r5 r5 = r5 MOD r6
nop
beq r4, r5 (Diff) If attacker and defender signs form a square or its diagonal, GOTO (Diff)
addiu r7, r7, 0xFFFF r7 = r7 - 1
bne r7, r0, (MOD) If r7 isn't zero, GOTO (MOD)
addiu r6, r0, 0x0003
(E) jr 31 Return to Main Routine
lui r1, 0x8019 Resets r1 = 0x80190000.
(Diff) beq r7, r0 (Bad) If r7 = 0 (when r6 = 3), GOTO (Bad)
lbu r6, 0x0006 (r2) r6 = attacker gender
lbu r7, 0x0006 (r3) r7 = defender gender
or r4, r6, r7
andi r4, r4, 0x0020
bne r4, r0, (Bad) If either combatant is a monster, GOTO (Bad)
andi r6, r6, 0x00C0
andi r7, r7, 0x00C0
beq r6, r7 (EndBranch) If the genders are the same, GOTO (EndBranch)
srl r4, r1, 0x01 XA2 = [XA2/2]
(+) addu r4, r1, r4 XA2 = XA2 + r4
(EndBranch) lui r7, 0x8019
j (E)
sb r4, 0x38D0 (r7) Store r1 as XA2
(Good) j (+)
(Bad) srl r4, r1, 0x02 r4 = [XA2/4]
j (EndBranch)
subu r4, r1, r4 XA2 = XA2 - [XA2/4]


lhu r4, 0x38D0 (r1) Loads r4 as XA2
lhu r5, 0x38CE (r1) Loads r5 as XA1
beq r4, r0 (Set1) If XA2 is 0, GOTO (Set1)
nop
(Mult) mult r4, r5
mflo r4 XA2 = XA1 * XA2
nop
jr 31 Return to Main Routine
sh r4, 0x38D0 (r1) Stores new XA2

(Set1) j (Mult) GOTO (Mult)
addiu r4, r0, 0x0001 If XA2 = 0, XA2 is now 1.


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r5, r5, r4
lbu r6, -0x1409 (r5) r6 = AI Byte 5
lbu r7, -0x140A (r5) r7 = AI Byte 4
lbu r5, -0x140B (r5) r5 = AI Byte 3
andi r6, r6, 0x0004
bne r6, r0, (Un) If 3rd blank AI flag under the Third Unknown under Learn on Hit is flagged, GOTO (Un)
(Check) andi r7, r7, 0x0080
bne r7, r0, (Br) If the blank AI flag above Direct Attack is flagged, GOTO (Br)
andi r5, r5, 0x0004
bne r5, r0, (Fa) If the Unknown AI flag under Random Hits is flagged, GOTO (Fa)
nop
jr 31 ELSE, GOTO Main Routine
nop

(Un) addiu r6, r0, 0x0064
j (Check) r6 = 100, r4 = Yes, GOTO (Check)
addiu r4, r0, 0x0001

(Br) bne r4, r0, (UnBr) If UnBrave/UnFaith is flagged, GOTO (UnBr)
lbu r7, 0x0024 (r2) r7 = Attacker Brave
j (Mult) ELSE, GOTO (Mult)
(UnBr) lbu r4, 0x0024 (r3) r4 = Defender Brave
subu r7, r6, r7 r7 = 100 - Attacker Brave if UnBrave/UnFaith is flagged
subu r4, r6, r4 r4 = 100 - Defender Brave if UnBrave/UnFaith is flagged
(Mult) lhu r6, 0x38D0 (r1) r6 = XA2
nop
mult r6, r7
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa)
nop
nop
mult r6, r4
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa)
lui r4, 0x0006
addu r4, r4, 0x8DB8
mult r6, r4
mfhi r6 XA2 = [XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa) / 10000]
nop
jr 31 GOTO Main Routine
sh r6, 0x38D0 (r1) Stores new XA2
(Fa) lbu r5, 0x005C (r2) r5 = Attacker Status Byte 5
lbu r7, 0x005C (r3) r7 = Defender Status Byte 5
andi r5, r5, 0x00C0
beq r5, r0, (Load-AFa) If attacker does not have innocent or faith, GOTO (Load-AFa)
andi r7, r7, 0x00C0
sltiu r5, r5, 0x0080
beq r5, r0, (A-Inn) If attacker has Innocent, GOTO (A-Inn)
nop
j (CheckTar) If attacker has Faith, r5 = 100 and GOTO (CheckTar)
addiu r5, r0, 0x0064
(A-Inn) j (CheckTar) If attacker has Innocent, r5 = 0 and GOTO (CheckTar)
addiu r5, r0, 0x0000
(Load-AFa) lbu r5, 0x0026 (r2) If attacker has neither, r5 = Attacker Faith
(CheckTar) beq r7, r0, (Load-DFa) If defender does not have innocent or faith, GOTO (Load-DFa)
nop
sltiu r7, r7, 0x0080
beq r7, r0, (D-Inn) If defender has Innocent, GOTO (D-Inn)
nop
j (CheckUn) If defender has Faith, r7 = 100 and GOTO (CheckUn)
addiu r7, r0, 0x0064
(D-Inn) j (CheckUn) If defender has Innocent, r7 = 0 and GOTO (CheckUn)
addiu r7, r0, 0x0000
(Load-DFa) lbu r7, 0x0026 (r3) If defender has neither, r7 = Defender Faith
(CheckUn) beq r4, r0, (Normal) If UnBrave/UnFaith isn't flagged, GOTO (Normal)
nop
subu r5, r6, r5 r5 = 100 - Attacker Faith if UnBrave/UnFaith is flagged
subu r7, r6, r7 r7 = 100 - Defender Faith if UnBrave/UnFaith is flagged
(Normal) addu r4, r7, r0 r4 = r7 = Defender Faith
j (Mult) GOTO (Mult)
addu r7, r5, r0 r7 = r5 = Attacker Faith


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r4, r5, r4
lbu r9, -0x1409 (r4) r9 = AI Byte 5
addu r8, r31, r0 Sends r31 into r8 because r31 will be modified by jal commands below.
andi r4, r9, 0x0010
beq r4, r0, (KB Check) If the first blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (KB Check)
sb r0, 0x38CC (r1) Reset Higher Tile Flag
jal (RNG) ELSE, GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0004
sub r4, r4, r7 r4 = 4 - RN from 0 to 99
bltz r4 (KB check) If RN > 4, GOTO (KB check)
addiu r5, r0, 0x0001
sb r5, 0x018D (r2) Flag attack as critical.
jal (RNG) GOTO (RNG)
lhu r7, 0x38D0 (r1) r7 = Base Damage
lhu r6, 0x38D0 (r1) r6 = Base Damage
addiu r7, r7, 0x0001 r7 = {1...Base Damage}
addu r6, r6, r7 New Damage = Base Damage + {1...Base Damage}
sh r6, 0x38D0 (r1) Store New Damage
(KB check) andi r4, r9, 0x0008
beq r4, r0, (E) If the second blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (E)
sb r0, 0x38EE (r1) Reset Knockback Height
jal (RNG) GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0031
sub r4, r4, r7 r4 = 49 - RN from 0 to 99
bltz r4 (E) If RN > 49, GOTO (E)
(KB) lbu r5, 0x0182 (r3)
beq r2, r3, (E) If you are targeting yourself with knockback, GOTO (E)
lbu r4, 0x0005 (r3)
lbu r6, 0x0047 (r2) r6 = Attacker X Coordinate
andi r4, r4, 0x0004
bne r4, r0, (E) If target is immortal, GOTO (E)
lbu r7, 0x0047 (r3) r7 = Defender X Coordinate
bne r5, r0, (E) If target is riding a chocobo or in 2h+ water, GOTO (E)
lui r4, 0x800E
lbu r5, 0x4E9C (r4) r5 = Map Maximum X
beq r7, r0 (CheckEdge1) If Defender X Coordinate = 0, GOTO (CheckEdge1)
sb r0, 0x38EC (r1) Reset Knockback Flag
beq r7, r5 (CheckEdge2) If Defender X Coordinate = Map Maximum X, GOTO (CheckEdge2)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker X - Defender X
j (YChecks) Store Byte 1 of XA1 and GOTO (YChecks)
sb r5, 0x38CE (r1)
(CheckEdge1) beq r6, r0 (YChecks) If Defender and Attacker X Coordinate = 0, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
(E) jr r8 ELSE, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge2) beq r6, r5 (YChecks) If Defender and Attacker X Coordinate = Maximum, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
jr r8 If Defender X Coordinate = Maximum, but Attacker X coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(YChecks) lbu r6, 0x0048 (r2) r6 = Attacker Y Coordinate
lbu r7, 0x0048 (r3) r7 = Defender Y Coordinate
lbu r5, 0x4EA0 (r4) r5 = Map Maximum Y
beq r7, r0, (CheckEdge3) If Defender Y Coordinate = 0, GOTO (CheckEdge3)
nop
beq r7, r5, (CheckEdge4) If Defender Y Coordinate = Maximum Y, GOTO (CheckEdge4)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker Y - Defender Y
j (NewXY) Store Byte 2 of XA1 and GOTO (NewXY)
sb r5, 0x38CF (r1)
(CheckEdge3) beq r6, r0 (NewXY) If Defender and Attacker Y Coordinate = 0, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = 0, while Attacker Y Coordinate isn't, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge4) beq r6, r5 (NewXY) If Defender and Attacker Y Coordinate = Maximum, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = Maximum, but Attacker Y coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(NewXY) lb r4, 0x38CE (r1) r4 = Attacker X - Defender X
lb r5, 0x38CF (r1) r5 = Attacker Y - Defender Y
bgez r4 (+X) If r4 is greater than or equal to 0, GOTO (+X)
addiu r7, r0, 0x0100
addiu r6, r0, 0x0001 If r4 < 0, r6 = 1
j (YDiff) Make r4 positive and GOTO (YDiff)
subu r4, r7, r4 If r4 < 0, r4 = 0x100 - r4 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+X) bne r4, r0 (YDiff) If r4 > 0, r6 = 2 and GOTO (YDiff)
addiu r6, r0, 0x0002
addiu r6, r0, 0x0000 ELSE, r6 = 0
(YDiff) bgez r5 (+Y) If r5 is greater than or equal to 0, GOTO (+Y)
addiu r7, r0, 0x0100
ori r6, r6, 0x0004 If r5 < 0, r6 = r6 OR 0x4 = r6 + 4 (because r6 = 0, 1, or 2)
j (CoordChange) Make r5 positive and GOTO (CoordChange)
subu r5, r7, r5 If r5 < 0, r5 = 0x100 - r5 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+Y) beq r5, r0 (CoordChange) If r5 = 0, r6 = r6 and GOTO (CoordChange)
ori r6, r6, 0x0000
ori r6, r6, 0x0008 ELSE, r6 = r6 OR 0x8 = r6 + 8 (because r6 = 0, 1, or 2)
(CoordChange) jal (RNG) r7 = r4 + r5 = Distance Attacker is from Defender and GOTO (RNG)
addu r7, r4, r5
sub r7, r4, r7 r7 = |Attacker X - Defender X| - {0...|Attacker X - Defender X| + |Attacker Y - Defender Y| - 1}
bgtz r7 (ChangeX) If r7 > 0, GOTO (Change X)
lbu r5, 0x0048 (r3) r5 = Defender Y
andi r6, r6, 0x0008
beq r6, r0, (+1Y) If Attacker Y < Defender Y, GOTO (+1Y)
nop
j (NewCoord) If Attacker Y > Defender Y, Defender Y = Defender Y - 1 and GOTO (NewCoord)
addiu r5, r5, 0xFFFF
(+1Y) j (NewCoord) If Attacker Y < Defender Y, Defender Y = Defender Y + 1 and GOTO (NewCoord)
addiu r5, r5, 0x0001
(ChangeX) lbu r4, 0x0047 (r3) r4 = Defender X
andi r6, r6, 0x0002
beq r6, r0, (+1X) If Attacker X < Defender X, GOTO (+1X)
nop
j (NewCoord) If Attacker X > Defender X, Defender X = Defender X - 1 and GOTO (NewCoord)
addiu r4, r4, -0xFFFF
(+1X) addiu r4, r4, 0x0001 If Attacker X < Defender X, Defender X = Defender X + 1
(NewCoord) lui r6, 0x800E
lbu r6, 0x4E9C (r6) r6 = Map Maximum X
sb r4, 0x38CE (r1) Store Defender X as XA1 Byte 1
sb r5, 0x38CF (r1) Store Defender Y as XA1 Byte 2
lhu r5, 0x0048 (r3) r5 = Pre-Attack Defender Y + Unit Facing
lbu r4, 0x0047 (r3) r4 = Pre-Attack Defender X
andi r7, r5, 0x8000
jal (TileOffset) GOTO (TileOffset)
andi r5, r5, 0x00FF r5 = Pre-Attack Defender Y
bne r7, r0, (HigherTile) If the defender stood on a higher tile, GOTO (HigherTile)
nop
j (NewHeight) ELSE, r7 = Height of Lower Tile and GOTO (NewHeight)
lbu r7, -0x0732 (r4)
(HigherTile) lbu r7, 0x00CE (r4) r7 = Height of Higher Tile
(NewHeight) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r9, 0x005A (r3) r9 = Current Status Byte 3
lbu r5, 0x0093 (r3) r5 = Movement Status Byte 1
andi r9, r9. 0x0040
bne r9, r0, (SCheckFail) If target has float status, GOTO (SCheckFail)
lbu r2, 0x0095 (r3) r2 = Movement Status Byte 3
andi r5, r5, 0x0002
bne r5, r0, (SCheckFail) If target has ignore height, GOTO (SCheckFail)
andi r2, r2, 0x000C
beq r2, r0, (SCheckGood) If target doesn't have float/fly, GOTO (SCheckGood)
addu r9, r0, r0 If target doesn't have float/fly/ignore height, r9 = 0
(SCheckFail) addiu r9, r0, 0x0001 ELSE, r9 = 1
(SCheckGood) lbu r5, -0x0732 (r4) r5 = Height of Current Lower Tile
lbu r2, -0x072E (r4) r2 = Byte 7 of Current Lower Tile Data
sltu r4, r7, r5
bne r4, r0 (E) IF r7 < r5, GOTO (E)
andi r2, r2, 0x0001
bne r2, r0, (HigherTile) ELSE IF lower tile is impassable, GOTO (HigherTile)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageL) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageL)
nop
sb r4, 0x38EE (r1) ELSE, Store r4 as knockback height
(NoFallDamageL) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(HigherTile) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r5, 0x00CE (r4) r5 = Height of Current Higher Tile
lbu r2, 0x00D2 (r4) r2 = Byte 7 of Current Higher Tile Data
beq r5, r0 (E2) IF r5 = 0, GOTO (E2)
sltu r4, r7, r5
bne r4, r0 (E2) ELSE IF r7 < r5, GOTO (E2)
andi r2, r2, 0x0001
bne r2, r0, (E) ELSE IF higher tile is impassable, GOTO (E)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageH) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageH)
addu r6, r0, r0 r6 = 0
sb r4, 0x38EE (r1) ELSE, store r4 as Knockback Height.
(NoFallDamageH) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(E2) lbu r4, 0x38EC (r1) r4 = Knockback flag.
nop
beq r4, r0, (E) If Knockback is not flagged, GOTO (E)
nop
bne r6, r0, (LowerFlag) ELSE If r6 = Map Maximum X (and not 0), GOTO (LowerFlag)
addiu r7, r0, 0x0001 r7 = 1
sb r7, 0x38CC (r1) ELSE, flag Higher Tile
(LowerFlag) lbu r5, 0x38C1 (r1) r5 = The Xth unit on map (target)
lbu r4, 0x38CE (r1) r4 = Target X (current)
sb r5, 0x38EF (r1) Store r5.
lbu r5, 0x38CF (r1) r5 = Target Y (current)
sb r4, 0x38CA (r1) Store r4.
lbu r4, 0x019D (r3) r4 = Attack Elemental Modifier Flags vs. Target
sb r5, 0x38CB (r1) Store r5.
ori r4, r4, 0x0040 r4 = r4 OR 0x40
jr r8 GOTO Main Routine
sb r4, 0x019D (r3) Store r4, which now has a knockback on attack flag

(TileOffset) mult r5, r6
mflo r5 r5 = Map Maximum X * Defender Y (pre-attack or current)
nop
addiu r5, r5, r4 r5 = Map Maximum X * Defender Y + Defender X (pre-attack or current)
sll r5, r5, 0x03 r5 = r5 * 8
lui r4, 0x8019
jr 31  Return to Critical/Knockback Routine
addu r4, r4, r5

(RNG) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...value(r7)-1}
jr 31 Return to Critical/Knockback Routine
nop

BATTLE.BIN
0x123EB0
00000000

BATTLE.BIN
0x11408C
00000000
00000000

BATTLE.BIN
0x1140FC
00000000
00000000

BATTLE.BIN
0x115FD8
EC

BATTLE.BIN
0x115FE0
01

BATTLE.BIN
0x124420
EC

BATTLE.BIN
0x124428
01

BATTLE.BIN
0x116250
EC

BATTLE.BIN
0x1162AC
EC

BATTLE.BIN
0x1162B4
01

BATTLE.BIN
0x1162C4
EC

BATTLE.BIN
0x123E50
EC

BATTLE.BIN
0x119EB8
lui r18, 0x8019 or 1980123C
0x119EC4
lbu r18, 0x38CC (r18) or CC385292


lw r2, 0x2D94 (r1) r2 = Attacker Offset
lhu r4, 0x38D6 (r1) r4 = Ability ID
lbu r7, 0x38F7 (r1) r7 = Ability Elemental
lui r6, 0x8006
sll r4, r4, 0x03 r4 = Ability ID * 8
addu r6, r6, r4 r6 = r6 + Ability ID * 8
lbu r4, 0x005A (r3) r4 = Target Status Bytes 3
lbu r8, 0x006E (r3) r8 = Target Elemental Nullification Byte
andi r4, r4, 0x0040
beq r4, r0, (NullCompare) If target is does not have float, GOTO (NullCompare)
nop
ori r8, r8, 0x0008 ELSE, Target is now nulls earth.
(NullCompare) andi r8, r8, r7
bne r8, r0, (ENull) If element is Nulled, GOTO (ENull)
lbu r6, -0x140B (r6) r6 = AI Flags Byte 3
lhu r4, 0x0058 (r3) ELSE, r4 = Target Status Bytes 1 and 2
lbu r8, 0x0070 (r3) r8 = Target Elemental Weakness Byte
andi r4, r4, 0x0410
beq r4, r0, (CheckOil) If target is not undead or vampire (has blood suck), GOTO (CheckOil)
addiu r9, r0, 0x0001
ori r8, r8, 0x0002 ELSE, Target is now weak against holy
(CheckOil) lbu r4, 0x005A (r3) r4 = Target Status Bytes 3
sb r9, 0x018C (r3) Flag attack as hit.
andi r4, r4, 0x0080
beq r4, r0 (NoStatusWeak) If target does not have oil, GOTO (NoStatusWeak)
nop
ori r8, r8, 0x0080 ELSE, Target is now weak against fire
(NoStatusWeak) lhu r4, 0x38D0 (r1) r4 = Base Damage
andi r6, r6, 0x0020
beq r6, r0, (EWeak) If AI Undead Reverse Flag is not flagged, r9 = 1 and GOTO (EWeak)
addiu r9, r0, 0x0001
andi r9, r5, 0x0080 ELSE r9 = 0, if the first blank flag under Player Abilities isn't flagged (healing), or 80 if it is (drain)
(EWeak) lbu r5, 0x38D6 (r1) r5 = Ability ID
lui r6, 0x8006
sll r5, r5, 0x03 r5 = Ability ID * 8
addu r6, r6, r5 r6 = r6 + Ability ID * 8
lbu r5, -0x140C (r6) r5 = AI Flags Byte 2
and r8, r8, r7
beq r8, r0, (SetupDMG) If the target is not weak against the spell's element, GOTO (SetupDMG)
addiu r9, r9, 0xFFFF
sll r4, r4, 0x01 ELSE, r4 = r4 * 2
(SetupDMG) andi r5, r5, 0x00A0
beq r5, r0, (EAbsorb) If the AI HP and MP flags are unflagged, GOTO (EAbsorb)
addu r6, r4, r0 r6 = r4
andi r6, r5, 0x0080
beq r6, r0 (-MP) ELSE, r6 = 0 or 0x80 and if AI flag HP is not flagged (r6 = 0), GOTO (-MP)
nop
andi r6, r5, 0x0040
beq r6, r0 (-HP) ELSE, If AI flag MP is not flagged, GOTO (-HP)
sh r4, 0x0190 (r3) Stores HP Damage as 2x Base Damage
srl r4, r4, 0x01
(-MP) sh r4, 0x0194 (r3) Stores r4 as MP Damage
(-HP) lbu r4, 0x019D (r3) r4 = Elemental Resistance Byte
beq r8, r0, (EAbsorb) If the target is not weak against the spell's element, GOTO (EAbsorb)
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r4, r4, 0x0008 ELSE, r4 includes damage is elemental weakness
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r4, 0x019D (r3) Store r4 as elemental resistance byte
bgtz r9, (DrainFlags) If attack is supposed to drain, GOTO (DrainFlags)
sb r6, 0x01B1 (r3) Store r6 as attack type byte
j (EAbsorb) ELSE, GOTO (EAbsorb)
nop
(DrainFlags) lhu r4, 0x0194 (r3) r4 = MP Damage Dealt
lhu r5, 0x002C (r3) r5 = Target MP
lhu r6, 0x002C (r3) r6 = Target MP
sub r5, r5, r4
bltz r5, (ExcessMPDMG) If target MP < MP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (HPDrain) GOTO (HPDrain)
sh r4, 0x0196 (r2) ELSE, Set MP restored to MP Damage Dealt.
(ExcessMPDMG) sh r6, 0x0196 (r2) If target MP < MP Damage Dealt, set MP restored as target MP.
(HPDrain) lhu r4, 0x0190 (r3) r4 = HP Damage Dealt
lhu r5, 0x0028 (r3) r5 = Target HP
lhu r6, 0x0028 (r3) r6 = Target HP
sub r5, r5, r4
bltz r5, (ExcessHPDMG) If target HP < HP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (SelfFlags) GOTO (SelfFlags)
sh r4, 0x0192 (r2) ELSE, Set HP restored to HP Damage Dealt.
(ExcessHPDMG) sh r6, 0x0192 (r2) If target HP < HP Damage Dealt, set HP restored as target HP.
(SelfFlags) ori r4, r0, 0x0001
lbu r5, 0x01B1 (r2) r5 = Attack Type Byte of caster.
sb r4, 0x018C (r2) Drain will affect caster.
ori r5, r5, 0x0050 r5 includes HP/MP Healing
sb r5, 0x01B1 (r2) r5 is stored as the caster attack type byte.
ori r6, r0, 0x0100 r6 = 0x100
beq r9, r6, (E) If r9 = 0x100 (only possible if drain attack has no elemental modifiers), GOTO (E)
(EAbsorb) lbu r4, 0x0058 (r3) r4 = Target Status Bytes 1
lbu r8, 0x006D (r3) r8 = Target Elemental Absorption Byte
andi r4, r4, 0x0010
beq r4, r0, (NoUndead) If the target isn't undead, GOTO (NoUndead)
nop
ori r8, r8, 0x0001 ELSE, the target absorbs dark attacks.
(NoUndead) and r8, r8, r7
beq r8, r0, (Normal) If the target does not absorb the spell's element, GOTO (Normal)
lhu r4, 0x0190 (r3) r4 = HP Damage
bne r5, r0 (NotStatus) If the attack deals damage, drain, or healing, GOTO (NotStatus)
sll r6, r6, 0x01 Double hit chance of non-damage attack if target absorbs element.
addiu r9, r0, 0x0002
sb r9, 0x018C (r3) ELSE, Store 0x2 into target hit byte.
j (E) GOTO (E)
sh r6, 0x01B6 (r3) r6 = Hit Chance
(NotStatus) lhu r5, 0x0194 (r3) r5 = MP Damage
(HealSetup) sh r0, 0x0190 (r3) HP Damage is 0
bgtz r9, (DrainReversalFlags) If attack is supposed to drain, GOTO (DrainReversalFlags)
sh r0, 0x0194 (r3) MP Damage is 0
sh r4, 0x0192 (r3) r4 = HP Healing
sh r5, 0x0196 (r3) r5 = MP Healing
(EAbsorbFlags) lbu r5, 0x019D (r3) r5 = Elemental Resistance Byte
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r5, r5, 0x0004 r5 includes healing is elemental absorption
andi r6, r6, 0x005F r6 no longer includes HP/MP damage.
ori r6, r6, 0x0050 r6 includes HP/MP Healing
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
jr 31 Return to Main Formula Routine
sb r6, 0x01B1 (r3) Store r6 as attack type byte
(DrainReversalFlags) sh r4, 0x0190 (r2) r4 = HP Damage on Caster
lbu r6, 0x002C (r2) r6 = Caster MP
sh r5, 0x0194 (r2) r5 = MP Damage on Caster
sub r6, r6, r5
bltz r6, (ExcessMPHeal) If caster MP < MP Damage Dealt, GOTO (ExcessMPHeal)
sh r0, 0x0196 (r2) MP Healing on Caster is 0
j (HPReversal) GOTO (HPReversal)
sh r5, 0x0196 (r3) ELSE, Target MP Healing = Caster MP Damage
(ExcessMPHeal) add r6, r6, r5
sh r6, 0x0196 (r3) If Caster MP < MP Damage Dealt, Target MP Healing = Caster MP
(HPReversal) lbu r6, 0x0028 (r2) r6 = Caster HP
nop
sub r6, r6, r4
bltz r6, (ExcessHPHeal) If caster HP < HP Damage Dealt, GOTO (ExcessHPHeal)
sh r0, 0x0192 (r2) HP Healing on Caster is 0
j (SelfReverseFlags) GOTO (SelfReverseFlags)
sh r4, 0x0192 (r3) ELSE, Target HP Healing = Caster HP Damage
(ExcessMPHeal) add r6, r6, r4
sh r6, 0x0192 (r3) If Caster HP < HP Damage Dealt, Target MP Healing = Caster MP
(SelfReverseFlags) lbu r6, 0x01B1 (r2) r6 = Caster Attack Type Byte
ori r5, r0, 0x0001
andi r6, r6, 0x00AF r6 no longer includes HP/MP healing.
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r5, 0x018C (r2) Caster is affected by drain reversal.
j (EAbsorbFlags) GOTO (EAbsorbFlags)
sb r6, 0x01B1 (r2) Store r6 as attack type byte
(Normal) bne r5, r0 (NotStatus2) If the attack deals damage, drain, or healing, GOTO (NotStatus2)
nop
addiu r9, r0, 0x0002
sb r9, 0x018C (r3) ELSE, Store 0x2 into target hit byte.
j (E) GOTO (E)
sh r6, 0x01B6 (r3) r6 = Hit Chance
(NotStatus2) bltz r9, (Healing) If r9 < 0 (if the AI flags are set as healing), GOTO (Healing)
lhu r5, 0x0194 (r3) r5 = MP Damage
lbu r6, 0x01B1 (r3) ELSE, r6 = Attack Type Byte
nop
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
bgtz r9, (Drain) If r9 > 0 (if the AI flags are set as drain), GOTO (Drain)
sb r6, 0x01B1 (r3) Store r6 as Attack Type Byte
jr 31 ELSE (if attack is not drain/healing), return to Main Formula Routine
nop
(Healing) addu, r7, r31, r0 r7 = Return address
jal (HealSetup) Save offset into r31 and GOTO (HealSetup)
nop
andi r5, r5, 0x00FB r5 no longer includes healing as elemental absorption
jr r7 Return to Main Formula Routine
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
(Drain) j (DrainFlags) GOTO (DrainFlags)
addiu r9, r0, 0x0100 r9 = 0x100 (for comparison purposes above)
(E) jr r31 Return to Main Formula Routine
nop

(ENull) sb r0, 0x018C (r3) Attack will miss.
sh r0, 0x0190 (r3) HP Damage is 0.
sh r0, 0x0192 (r3) MP Damage is 0.
sh r0, 0x0194 (r3) HP Healing is 0.
sh r0, 0x0196 (r3) MP Healing is 0.
sh r0, 0x019C (r3) Set the elemental resistance byte to 0
sb r0, 0x01B1 (r3) Set the attack type byte to 0
sh r0, 0x01B6 (r3) Set the accuracy to 0
ori r4, r0, 0x0005
sb r4, 0x018E (r3) Display on missed attack is "Nullified"
lbu r4, 0x38ED (r1) r4 = Target Terrain Byte
sh r0, 0x38C8 (r1) Spell/Status Flags = 0
sh r0, 0x38C6 (r1) Status/Spell ID = 0
andi r4, r4, 0x0080
beq r4, r0 (E2) If target isn't above the terrain because of fly/float/chicken/frog, GOTO (E2)
nop
sb r0, 0x38ED (r1) ELSE, r4 = 0
(E2) jr r31 Return to Main Formula Routine
nop
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

RavenOfRazgriz

Do I need to re-write or reorganize any of the summaries at all?

It doesn't look like anything was added besides the unfinished Steal/Break code and Element modification, which I'll probably sum up both at once when the Steal/Break is done, and hell if I can tell if anything integral to the way I simplified things down was changed in the code without comparing it all side by side.

formerdeathcorps

April 25, 2011, 05:34:07 pm #66 Last Edit: May 13, 2011, 06:06:28 pm by formerdeathcorps
No, you don't have to rewrite anything, Raven.

It should be noted that the following routine is not vanilla's because I want to better consolidate ability space.  Instead:
1) If you steal a slot that has nothing equipped, you steal gil instead.
2) If you break helm, but no helmet's equipped, you lower MA by 1.
3) If you break shield, but no shield's equipped, you lower PA by 1.
4) If you break armor, but no armor's equipped, you lower CT by 20.
5) Maintenance blocks breaks, steals, stat downs from break, and steal gil.  It does not set accuracy to 0 as it did in vanilla.
6) Divine Knight can deal damage to all units, unless the unit has maintenance.
7) All attacks that don't use Ability X for other purposes (like % hit or % HP damage or determining which stat is reduced/by how much) can now have break as an added effect.  Essentially, you check the unequip AI flag and then specify:
0x0? (No steal or break...note, if you specify this on the formula XA1+XA2+Y, then that Hit% is then applied towards inflicting status/inflicting proc...also, if you want to use that formula for break/steal, DO NOT use the default FFTP HP flag on steal/break armor/helm because the hit chance will then be assumed to be damage and you will have 100% break/steal if the attack hits.)
0x1?/0x2?/0x3?/0x4?/0x5? (Break Helm/Armor/Accessory/Weapon/Shield)
0x6?/0x7?/0x8?/0x9?/0xA? (Steal Helm/Armor/Accessory/Weapon/Shield)
0xB? (Steal Gil, i.e. Mug Skill)
Anything Else (Steal EXP)
8) Steal Gil is now SP * (20 + LVL) so it's better early, but you can now only steal from humans and only once per each enemy human.
9) Steal EXP is now min{20, target EXP}.
10) All of the above are hackable.

I'm posting my break routine here because I just hit the character limit on my previous post; I couldn't fit in the break routine.


lbu r4, 0x0091 (r3) r4 = Target Support Byte 3
lbu r5, 0x38D6 (r1) r5 = Used Ability ID
andi r4, r4, 0x0004
bne r4, r0, (SetZero) If target has Maintenance, GOTO (SetZero)
sll r5, r5, 0x03 r5 = r5 * 8
lui r4, 0x8006
addu r4, r4, r5
lbu r5, -0x140C (r4) ELSE, r5 = AI Byte 2
addu r9, r31, r0 r9 = r31 since it will be modified later in this routine.
andi r5, r5, 0x0004
beq r5, r0, (E) If Unequip is not flagged, GOTO (E)
lbu r8, 0x018C (r3) r8 = Target Hit Byte
ori r5, r0, 0x0002 ELSE, r5 = 2
bne r8, r5, (MissCheck) If target hit byte is not 2, GOTO (MissCheck)
nop
jal (RNG) If target hit byte is 2, GOTO (RNG)
ori r7, r0, 0x0064
lbu r4, 0x01B6 (r3) r4 = Hit Chance
addiu r7, r7, 0x0001
sub r4, r4, r7 r4 = Hit Chance - {1...100}
bltz r4, (E) If Hit Chance < {1...100}, GOTO (E)
sb r0, 0x018C (r3) Target Hit Byte is 0.
addiu r4, r0, 0x0001
sb r4, 0x018C (r3) ELSE, Target Hit Byte is 1.
(MissCheck) beq r8, r0, (E) If target hit byte is 0, GOTO (E)
lbu r4, 0x38F9 (r1) r4 = Ability X
nop
srl r4, r4, 0x04 ELSE, r4 = r4 / 0x10
beq r4, r0, (E) If the upper 4 bits of Ability X is 0, GOTO (E)
sltiu r5, r4, 0x0006
bne r5, r0, (Break) If 0 < r4 < 6, GOTO (Break)
sltiu r6, r4, 0x000B
bne r6, r0, (Steal) If 5 < r4 < 11, GOTO (Steal)
addiu r5, r0, 0x000B
beq r5, r4 (StealGil) If r4 = 11, GOTO (StealGil)
nop
j (StealEXP) ELSE, GOTO (StealEXP)
nop
(E) jr r9 Return to Main Formula Routine
nop

(Break) jal (SlotDeterm) GOTO (SlotDeterm)
nop
ori r5, r0, 0x00FF
beq r7, r5 (StatDown) If (human) equips "Nothing" in the selected slot, GOTO (StatDown)
lui r1, 0x8019 r1 is changed back to 0x80190000
beq r7, r0, (StatDown) ELSE, if (monster) equips "None", GOTO (StatDown)
nop
lbu r4, 0x019C (r3) r4 = Special Effect Byte
sb r7, 0x018F (r3) ELSE, set equipment lost byte to the hex value (r7) of equipment destroyed
ori r4, r4, 0x0004
jr r9 Return to Main Formula Routine
sb r4, 0x019C (r3) Set special effect byte to include break.

(Steal) jal (SlotDeterm) GOTO (SlotDeterm)
addiu r4, r4, 0xFFFB r4 = r4 - 5 (since all the steals are 5 + break)
ori r5, r0, 0x00FF
beq r7, r5 (StealGil) If (human) equips "Nothing" in the selected slot, GOTO (StealGil)
lui r1, 0x8019 r1 is changed back to 0x80190000
beq r7, r0, (StealGil) ELSE, if (monster) equips "None", GOTO (StealGil)
nop
lbu r4, 0x019C (r3) r4 = Special Effect Byte
sb r7, 0x018F (r3) ELSE, set equipment lost byte to the hex value (r7) of equipment destroyed
ori r4, r0, 0x0010
jr r9 Return to Main Formula Routine
sb r4, 0x019C (r3) Set special effect byte to include steal.

(SlotDeterm) addiu r5, r0, 0x0001
addiu r6, r3, 0x001A
ori r8, r0, 0x0004
ori r1, r0, 0x0100
(LoopStart) bne r4, r5, (LoopCheck) If r4 isn't r5, GOTO (LoopCheck)
srl r1, r1, 0x01
sb r1, 0x01A5 (r3) ELSE, Defender Lost Equipment Byte is the corresponding slot.
jr 31 Return to Break or Steal and r7 = target head/body/accessory.
lbu r7, 0x0000 (r6)
(LoopCheck)  addiu r5, r5, 0x0001
bne r8, r5, (LoopStart) If r5 < 4, GOTO (LoopStart)
addiu r6, r6, 0x0001
beq r4, r5 (CheckHands) If r4 = 4, GOTO (CheckHands)
srl r1, r1, 0x01 r1 = 0x10
addiu r6, r6, 0x0001 If r4 = 5, r6 is target shield byte.
srl r1, r1, 0x01 r1 = 0x8
(CheckHands) lbu r7, 0x0000 (r6) r7 = Weapon/Shield
ori r5, r0, 0x00FF
beq r7, r5 (LoopCheck2) If (human) equips "Nothing", GOTO (LoopCheck2)
addiu r8, r8, 0xFFFE r8 = r8 - 2 (r8 starts at 4, due to the previous loop)
beq r7, r0, (LoopCheck2) ELSE, if (monster) equips "None", GOTO (LoopCheck2)
nop
jr 31 ELSE, return to Break or Steal and r7 = target weapon/shield.
sb r1, 0x01A5 (r3) Defender Lost Equipment Byte is the corresponding slot.
(LoopCheck2) srl r1, r1, 0x02 r1 = 0x4/0x2
bne r8, r0, (CheckHands) If r8 > 0, GOTO (CheckHands)
addiu r6, r6, 0x0002
jr 31 ELSE, return to Break or Steal and r7 = 0

(StatDown) ori r7, r0, 0x0014 r7 = 20
ori r5, r0, 0x0002
beq r4, r5, (StatBreak) If r4 = 2 (break armor, but no armor is equipped), GOTO (StatBreak)
addiu r6, r3, 0x019F r6 = CT add/reduce byte
ori r7, r0, 0x0001 r7 = 1
ori r5, r0, 0x0001
beq r4, r5, (StatBreak) If r4 = 1 (break helm, but no helm is equipped), GOTO (StatBreak)
addiu r6, r3, 0x01A1 r6 = MA add/reduce byte
ori r5, r0, 0x0005
beq r4, r5, (StatBreak) If r4 = 5 (break shield, but no shield is equipped), GOTO (StatBreak)
addiu r6, r3, 0x01A0 r6 = PA add/reduce byte
jr r9 ELSE, return to Main Formula Routine
(StatBreak) lbu r5, 0x01B1 (r3) r5 = Attack Type Byte
sb r7, 0x0000 (r6) Set PA/MA/CT reduction byte as decrement
ori r5, r5, 0x0001
jr r9 Return to Main Formula Routine
sb r5, 0x01B1 (r3) Store Attack Byte as including Psuedo-Status [0x01] bit.

(StealGil) lbu r4, 0x0006 (r3) r4 = Defender Type
lbu r5, 0x0049 (r3) r5 = Defender Elevation/Facing Byte
andi r4, r4, 0x0020
bne r4, r0, (E) If Defender is a monster, GOTO (E)
andi r6, r5, 0x0040
bne r6, r0, (E) ELSE, if Defender has already been mugged, GOTO (E)
lbu r4, 0x0022 (r2) r4 = Attacker LVL
lbu r6, 0x0038 (r2) r5 = Attacker SP
addiu r4, r4, 0x0014
mult r4, r6
mflo r6 ELSE, r6 = SP * (20 +  LVL)
lbu r4, 0x01B1 (r2) r4 = Attacker Attack Type Byte
ori r5, r5, 0x0040
ori r4, r4, 0x0001
ori r7, r0, 0x0001
sh r6, 0x0198 (r2) Gain gil by the amount of r6.
sb r4, 0x01B1 (r2) Attacker Attack Type includes "pseudo-status" [0x01] bit.
sb r7, 0x018C (r2) Gil gain "hits" the attacker.
lbu r4, 0x01B1 (r3) r4 = Defender Attack Type Byte
subu r6, r0, r6
ori r4, r4, 0x0001
sb r5, 0x0049 (r3) Defender Elevation Byte includes "has been mugged" bit.
sh r6, 0x0198 (r3) Defender loses gil by the amount of r6.
jr r9 Return to Main Formula Routine
sb r4, 0x01B1 (r3) Defender Attack Type includes "pseudo-status" [0x01] bit.

(StealEXP) lbu r5, 0x0021 (r3) r5 = Target EXP
ori r4, r0, 0x0014 r4 = 20
beq r5, r0, (E) If Target EXP = 0, GOTO (E)
slt r6, r4, r5
beq r6, r0, (EXPChange) If 20 < Target EXP, GOTO (EXPChange) with r7 = 20.
addu r7, r4, r0
addu r7, r5, r0 ELSE, r7 = Target EXP
(EXPChange) sb r7, 0x01B4 (r2) Attacker gains r7 EXP.
addiu r7, r7, 0x0080
sb r7, 0x01B4 (r3) Defender loses r7 EXP.
lbu r4, 0x01B1 (r2) r4 = Attacker Attack Type Byte.
lbu r5, 0x01B1 (r3) r5 = Defender Attack Type Byte.
ori r4, r4, 0x0001
ori r5, r5, 0x0001
sb r4, 0x01B1 (r2) Attacker Attack Type Byte includes "pseudo-status" [0x01] bit.
sb r5, 0x01B1 (r3) Defender Attack Type Byte includes "pseudo-status" [0x01] bit..
ori r7, r0, 0x0001
jr r9 Return to Main Formula Routine
sb r7, 0x018C (r2) EXP gain "hits" the attacker.

(Set Zero) sb r0, 0x01B4 (r3) Defender loses 0 EXP.
sb r0, 0x01B4 (r2) Attacker gains 0 EXP.
sh r0, 0x0198 (r3) Defender loses 0 Gil.
lbu r4, 0x019C (r3) r4 = Special Effect Byte
sh r0, 0x0198 (r2) Attacker gains 0 Gil.
andi r4, r4, 0x00EB
sb r4, 0x019C (r3) Target Special Effect Byte does not include break or steal.
addiu r6, r3, 0x019E
addiu r5, r0, 0x0001
ori r7, r0, 0x0006
(PositiveLoop) beq r5, r7 (End) IF r5 = 6, GOTO (End)
lbu r4, 0x0000 (r6) r4 = Target SP/CT/PA/MA/BR Change Byte
addiu r5, r5, 0x0001 IF r5 < 6, r5 = r5 +1.
andi r4, r4, 0x0080
bne r4, r0, (CheckNext) If Stat Change Byte is Stat Gain, GOTO (CheckNext)
nop
sb r4, 0x0000 (r6) ELSE, Stat Change Byte is 0.
(CheckNext) j (PositiveLoop) GOTO (PositiveLoop)
addiu r6, r6, 0x0001
(End) jr 31 Return to Main Formula Routine and Defender faith gain/loss is 0.
sb r0, 0x01A3 (r3)

(RNG) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...value(r7)-1}
jr 31 Return to Break/Steal Routine
nop
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

Pride

May 12, 2011, 09:34:24 pm #67 Last Edit: May 18, 2011, 10:37:18 pm by Pride
Might as well post some of notes on reactions while I continue to try and rebuild some of my lost asm information

Reaction Stuff

0018d384: 3c028019 lui r2,0x8019      
0018d388: 8c42f5fc lw r2,-0x0a04(r2)      Load ???
0018d38c: 27bdffe8 addiu r29,r29,0xffe8      
0018d390: 14400006 bne r2,r0,0x0018d3ac      
0018d394: afbf0010 sw r31,0x0010(r29)      
0018d398: 90850024 lbu r5,0x0024(r4)      Load Brave
0018d39c: 0c017833 jal 0x0005e0cc      Random Process
0018d3a0: 34040064 ori r4,r0,0x0064      r4 = 100
0018d3a4: 080634ec j 0x0018d3b0         
0018d3a8: 00000000 nop            
0018d3ac: 00001021 addu r2,r0,r0      
0018d3b0: 8fbf0010 lw r31,0x0010(r29)      
0018d3b4: 27bd0018 addiu r29,r29,0x0018      
0018d3b8: 03e00008 jr r31         
0018d3bc: 00000000 nop   



0018cb00: 27bdffe8 addiu r29,r29,0xffe8      
0018cb04: 3c038019 lui r3,0x8019
0018cb08: 906338e5 lbu r3,0x38e5(r3)      Load Attack Formula ?
0018cb0c: 34020007 ori r2,r0,0x0007      
0018cb10: 10620044 beq r3,r2,0x0018cc24      Branch if using the "Healing" Weapon Formula ?
0018cb14: afbf0010 sw r31,0x0010(r29)      
0018cb18: 3c048019 lui r4,0x8019      
0018cb1c: 8c842d98 lw r4,0x2d98(r4)      Load Target's Stats
0018cb20: 0c063248 jal 0x0018c920      ???
0018cb24: 00000000 nop            
0018cb28: 1440003e bne r2,r0,0x0018cc24      
0018cb2c: 00000000 nop            
0018cb30: 3c048019 lui r4,0x8019      
0018cb34: 8c842d98 lw r4,0x2d98(r4)      Load Target's Stats
0018cb38: 00000000 nop
0018cb3c: 9083008b lbu r3,0x008b(r4)      Load first set of Reactions
0018cb40: 00000000 nop            
0018cb44: 30620010 andi r2,r3,0x0010      
0018cb48: 10400003 beq r2,r0,0x0018cb58      Branch if not using Sunken State
0018cb4c: 34050010 ori r5,r0,0x0010      r5 = 10
0018cb50: 08063307 j 0x0018cc1c         
0018cb54: 340401a9 ori r4,r0,0x01a9      Load Attack's Status Inflict
0018cb58: 30620008 andi r2,r3,0x0008      
0018cb5c: 10400003 beq r2,r0,0x0018cb6c      Branch if not using Caution
0018cb60: 30620004 andi r2,r3,0x0004      r2 = 4
0018cb64: 08063307 j 0x0018cc1c         
0018cb68: 340401aa ori r4,r0,0x01aa      Load Attack's Status Inflict
0018cb6c: 10400003 beq r2,r0,0x0018cb7c      Branch if not using Dragon Spirit
0018cb70: 34050010 ori r5,r0,0x0010      r5 = 10
0018cb74: 08063307 j 0x0018cc1c         
0018cb78: 340401ab ori r4,r0,0x01ab      Load Attack's Status Inflict
0018cb7c: 30620001 andi r2,r3,0x0001      
0018cb80: 10400003 beq r2,r0,0x0018cb90      Branch if not using Brave Up
0018cb84: 00000000 nop            
0018cb88: 08063307 j 0x0018cc1c         
0018cb8c: 340401ad ori r4,r0,0x01ad      Load Attack's Stats Removal
0018cb90: 9083008c lbu r3,0x008c(r4)      Load Second set of Reactions
0018cb94: 00000000 nop            
0018cb98: 30620080 andi r2,r3,0x0080      
0018cb9c: 10400005 beq r2,r0,0x0018cbb4      Branch if not using Faith (Face) up
0018cba0: 30620002 andi r2,r3,0x0002      r2= 2
0018cba4: 0c0633dd jal 0x0018cf74      
0018cba8: 340401ae ori r4,r0,0x01ae      
0018cbac: 08063309 j 0x0018cc24         
0018cbb0: 00000000 nop         
0018cbb4: 10400003 beq r2,r0,0x0018cbc4      Branch if not using Counter Tackle
0018cbb8: 34050010 ori r5,r0,0x0010      r5 = 10
0018cbbc: 08063307 j 0x0018cc1c         
0018cbc0: 340401b4 ori r4,r0,0x01b4      
0018cbc4: 30620001 andi r2,r3,0x0001      
0018cbc8: 10400003 beq r2,r0,0x0018cbd8      Branch if not using Counter Flood
0018cbcc: 34050080 ori r5,r0,0x0080      Prepare Counter Flood Flag Check
0018cbd0: 08063307 j 0x0018cc1c         
0018cbd4: 340401b5 ori r4,r0,0x01b5      
0018cbd8: 9084008d lbu r4,0x008d(r4)      Load 3rd set of Reactions
0018cbdc: 00000000 nop            
0018cbe0: 30820080 andi r2,r4,0x0080      
0018cbe4: 10400005 beq r2,r0,0x0018cbfc      Branch if not using Absorb Used Mp
0018cbe8: 30820008 andi r2,r4,0x0008      r2 = 8
0018cbec: 0c0633dd jal 0x0018cf74      
0018cbf0: 340401b6 ori r4,r0,0x01b6      Hit % for Attack on Self
0018cbf4: 08063309 j 0x0018cc24         
0018cbf8: 00000000 nop            
0018cbfc: 10400003 beq r2,r0,0x0018cc0c      Branch if not using Counter
0018cc00: 340401ba ori r4,r0,0x01ba      
0018cc04: 08063307 j 0x0018cc1c         
0018cc08: 34050010 ori r5,r0,0x0010      
0018cc0c: 30620004 andi r2,r3,0x0004      
0018cc10: 10400004 beq r2,r0,0x0018cc24      Branch if not using Counter Magic?!
0018cc14: 340401b3 ori r4,r0,0x01b3
0018cc18: 34050040 ori r5,r0,0x0040      Prepare for Counter Magic Flag Check
0018cc1c: 0c063381 jal 0x0018ce04      Chance to React
0018cc20: 00000000 nop
0018cc24: 8fbf0010 lw r31,0x0010(r29)
0018cc28: 27bd0018 addiu r29,r29,0x0018
0018cc2c: 03e00008 jr r31
0018cc30: 00000000 nop



0018ce04: 27bdffe8 addiu r29,r29,0xffe8      
0018ce08: afb00010 sw r16,0x0010(r29)      
0018ce0c: 00808021 addu r16,r4,r0      
0018ce10: 3c038019 lui r3,0x8019      
0018ce14: 906338d4 lbu r3,0x38d4(r3)      ???
0018ce18: 34020015 ori r2,r0,0x0015      
0018ce1c: 10620015 beq r3,r2,0x0018ce74      
0018ce20: afbf0014 sw r31,0x0014(r29)      
0018ce24: 3c028019 lui r2,0x8019      
0018ce28: 904238f6 lbu r2,0x38f6(r2)      Ability flags 4
0018ce2c: 00000000 nop
0018ce30: 00451024 and r2,r2,r5         
0018ce34: 1040000f beq r2,r0,0x0018ce74      Branch if ability is not using specific ability flag (counter magic/flood/etc.)
0018ce38: 00000000 nop            
0018ce3c: 3c048019 lui r4,0x8019      
0018ce40: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018ce44: 0c0634e1 jal 0x0018d384      Chance to react
0018ce48: 00000000 nop            
0018ce4c: 14400009 bne r2,r0,0x0018ce74      
0018ce50: 00000000 nop            
0018ce54: 3c038019 lui r3,0x8019      
0018ce58: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018ce5c: 00000000 nop            
0018ce60: a470000e sh r16,0x000e(r3)      Reaction ID ?
0018ce64: 3c028019 lui r2,0x8019      
0018ce68: 944238d6 lhu r2,0x38d6(r2)      Used Ability ID
0018ce6c: 00000000 nop            
0018ce70: a4620026 sh r2,0x0026(r3)      
0018ce74: 8fbf0014 lw r31,0x0014(r29)      
0018ce78: 8fb00010 lw r16,0x0010(r29)      
0018ce7c: 27bd0018 addiu r29,r29,0x0018      
0018ce80: 03e00008 jr r31         
0018ce84: 00000000 nop      


      
0018cf74: 27bdffe0 addiu r29,r29,0xffe0      
0018cf78: afb10014 sw r17,0x0014(r29)      
0018cf7c: 3c118019 lui r17,0x8019      
0018cf80: 263138eb addiu r17,r17,0x38eb      Load MP Used
0018cf84: afbf0018 sw r31,0x0018(r29)      
0018cf88: afb00010 sw r16,0x0010(r29)      
0018cf8c: 92220000 lbu r2,0x0000(r17)      Load MP used into R2
0018cf90: 00000000 nop            
0018cf94: 1040000e beq r2,r0,0x0018cfd0      Branch to end if No MP was used
0018cf98: 00808021 addu r16,r4,r0      
0018cf9c: 3c048019 lui r4,0x8019      
0018cfa0: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cfa4: 0c0634e1 jal 0x0018d384      Chance to React
0018cfa8: 00000000 nop            
0018cfac: 14400008 bne r2,r0,0x0018cfd0      Branch if Reaction Failed
0018cfb0: 00000000 nop            
0018cfb4: 3c038019 lui r3,0x8019      
0018cfb8: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018cfbc: 00000000 nop            
0018cfc0: a470000e sh r16,0x000e(r3)      Store Reaction ID
0018cfc4: 92220000 lbu r2,0x0000(r17)      lol
0018cfc8: 00000000 nop            
0018cfcc: a4620026 sh r2,0x0026(r3)      Store Last Attack on Self?
0018cfd0: 8fbf0018 lw r31,0x0018(r29)      
0018cfd4: 8fb10014 lw r17,0x0014(r29)      
0018cfd8: 8fb00010 lw r16,0x0010(r29)      
0018cfdc: 27bd0020 addiu r29,r29,0x0020      
0018cfe0: 03e00008 jr r31         
0018cfe4: 00000000 nop   

It appears any ability with MP will trigger Face/Faith Up.... Didn't know that



0018cc34: 27bdffe8 addiu r29,r29,0xffe8      
0018cc38: 3c038019 lui r3,0x8019      
0018cc3c: 906338e5 lbu r3,0x38e5(r3)      
0018cc40: 34020007 ori r2,r0,0x0007      
0018cc44: 10620020 beq r3,r2,0x0018ccc8      
0018cc48: afbf0010 sw r31,0x0010(r29)      
0018cc4c: 3c048019 lui r4,0x8019      
0018cc50: 8c842d98 lw r4,0x2d98(r4)      
0018cc54: 0c063248 jal 0x0018c920      
0018cc58: 00000000 nop            
0018cc5c: 1440001a bne r2,r0,0x0018ccc8      
0018cc60: 00000000 nop            
0018cc64: 3c048019 lui r4,0x8019      
0018cc68: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cc6c: 00000000 nop            
0018cc70: 9083008d lbu r3,0x008d(r4)      Load 3rd set of Reactions
0018cc74: 00000000 nop            
0018cc78: 30620001 andi r2,r3,0x0001      
0018cc7c: 10400005 beq r2,r0,0x0018cc94      Branch if not using MP switch
0018cc80: 30620002 andi r2,r3,0x0002      r2 = 2
0018cc84: 0c06346e jal 0x0018d1b8      MP Switch Calc
0018cc88: 00000000 nop            
0018cc8c: 08063332 j 0x0018ccc8         End
0018cc90: 00000000 nop            
0018cc94: 10400005 beq r2,r0,0x0018ccac      Branch if not using Distrubute
0018cc98: 00000000 nop            
0018cc9c: 0c0634aa jal 0x0018d2a8      Distribute Calc
0018cca0: 00000000 nop            
0018cca4: 08063332 j 0x0018ccc8         End
0018cca8: 00000000 nop            
0018ccac: 9082008e lbu r2,0x008e(r4)      Load 4th set of Reactions
0018ccb0: 00000000 nop            
0018ccb4: 30420080 andi r2,r2,0x0080      
0018ccb8: 10400003 beq r2,r0,0x0018ccc8      Branch if not using Damage Split
0018ccbc: 00000000 nop            
0018ccc0: 0c0634c6 jal 0x0018d318      
0018ccc4: 00000000 nop            
0018ccc8: 8fbf0010 lw r31,0x0010(r29)      
0018cccc: 27bd0018 addiu r29,r29,0x0018      
0018ccd0: 03e00008 jr r31         
0018ccd4: 00000000 nop            



0018d1b8: 3c028019 lui r2,0x8019      
0018d1bc: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018d1c0: 27bdffe8 addiu r29,r29,0xffe8      
0018d1c4: afbf0010 sw r31,0x0010(r29)      
0018d1c8: 84420004 lh r2,0x0004(r2)      HP Damage
0018d1cc: 00000000 nop            
0018d1d0: 10400031 beq r2,r0,0x0018d298      Branch if no damage was dealt
0018d1d4: 00000000 nop            
0018d1d8: 3c048019 lui r4,0x8019      
0018d1dc: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018d1e0: 00000000 nop            
0018d1e4: 9482002c lhu r2,0x002c(r4)      Load Current MP
0018d1e8: 00000000 nop            
0018d1ec: 1040002a beq r2,r0,0x0018d298      Branch if no MP
0018d1f0: 00000000 nop            
0018d1f4: 0c0634e1 jal 0x0018d384      Chance to React
0018d1f8: 00000000 nop            
0018d1fc: 14400026 bne r2,r0,0x0018d298      Branch if did not react
0018d200: 00000000 nop            
0018d204: 3c028019 lui r2,0x8019      
0018d208: 8c42f5fc lw r2,-0x0a04(r2)      ???
0018d20c: 00000000 nop            
0018d210: 14400021 bne r2,r0,0x0018d298      
0018d214: 00000000 nop            
0018d218: 3c048019 lui r4,0x8019      
0018d21c: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer
0018d220: 00000000 nop            
0018d224: 94820008 lhu r2,0x0008(r4)      Load HP Damage
0018d228: 94830004 lhu r3,0x0004(r4)      Load MP Damage
0018d22c: 00000000 nop            
0018d230: 00431021 addu r2,r2,r3      
0018d234: a4820008 sh r2,0x0008(r4)      Store as MP Damage
0018d238: 00021400 sll r2,r2,0x10      ...
0018d23c: 00021403 sra r2,r2,0x10      ...
0018d240: 284203e8 slti r2,r2,0x03e8      
0018d244: 14400002 bne r2,r0,0x0018d250      
0018d248: 340203e7 ori r2,r0,0x03e7      
0018d24c: a4820008 sh r2,0x0008(r4)      Store as MP Damage
0018d250: 3c038019 lui r3,0x8019      
0018d254: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018d258: 00000000 nop            
0018d25c: 90620025 lbu r2,0x0025(r3)      Attack Flags
0018d260: 00000000 nop            
0018d264: 3042007f andi r2,r2,0x007f      Not HP Damage...
0018d268: a0620025 sb r2,0x0025(r3)      Store...
0018d26c: 3c048019 lui r4,0x8019      
0018d270: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer >_>
0018d274: a4600004 sh r0,0x0004(r3)      0 HP Damage
0018d278: 90820025 lbu r2,0x0025(r4)      
0018d27c: 00000000 nop            
0018d280: 34420020 ori r2,r2,0x0020      
0018d284: a0820025 sb r2,0x0025(r4)      Store Attack Flag as MP Damage
0018d288: 3c038019 lui r3,0x8019      
0018d28c: 8c632d90 lw r3,0x2d90(r3)      CUrrent Action Data Pointer
0018d290: 340201bd ori r2,r0,0x01bd      
0018d294: a462000e sh r2,0x000e(r3)      Reaction ID?
0018d298: 8fbf0010 lw r31,0x0010(r29)
0018d29c: 27bd0018 addiu r29,r29,0x0018
0018d2a0: 03e00008 jr r31
0018d2a4: 00000000 nop


               
0018d2a8: 3c058019 lui r5,0x8019      
0018d2ac: 8ca52d98 lw r5,0x2d98(r5)      Load Defender's Stats
0018d2b0: 3c048019 lui r4,0x8019      
0018d2b4: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer
0018d2b8: 27bdffe8 addiu r29,r29,0xffe8      
0018d2bc: afbf0014 sw r31,0x0014(r29)      
0018d2c0: afb00010 sw r16,0x0010(r29)      
0018d2c4: 94a2002a lhu r2,0x002a(r5)      Load Max HP
0018d2c8: 94a30028 lhu r3,0x0028(r5)      Load Current HP
0018d2cc: 84840006 lh r4,0x0006(r4)      HP Recovery
0018d2d0: 00431023 subu r2,r2,r3      Max HP - Current HP
0018d2d4: 00828023 subu r16,r4,r2      
0018d2d8: 1a00000a blez r16,0x0018d304      Branch if r16 on less then or equal to zero
0018d2dc: 00000000 nop            
0018d2e0: 0c0634e1 jal 0x0018d384      Chance to Counter
0018d2e4: 00a02021 addu r4,r5,r0      
0018d2e8: 14400006 bne r2,r0,0x0018d304      Branch if didn't react
0018d2ec: 340201bc ori r2,r0,0x01bc      
0018d2f0: 3c038019 lui r3,0x8019      
0018d2f4: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018d2f8: 00000000 nop            
0018d2fc: a4700026 sh r16,0x0026(r3)      Last Attack on Self?
0018d300: a462000e sh r2,0x000e(r3)      Reaction ID?
0018d304: 8fbf0014 lw r31,0x0014(r29)      
0018d308: 8fb00010 lw r16,0x0010(r29)      
0018d30c: 27bd0018 addiu r29,r29,0x0018      
0018d310: 03e00008 jr r31         
0018d314: 00000000 nop         



0018d318: 3c028019 lui r2,0x8019      
0018d31c: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018d320: 27bdffe8 addiu r29,r29,0xffe8      
0018d324: afbf0014 sw r31,0x0014(r29)      
0018d328: afb00010 sw r16,0x0010(r29)      
0018d32c: 94500004 lhu r16,0x0004(r2)      Load Damage?
0018d330: 00000000 nop            
0018d334: 1200000e beq r16,r0,0x0018d370   Branch if no Damage?
0018d338: 00000000 nop            
0018d33c: 3c048019 lui r4,0x8019      
0018d340: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018d344: 0c0634e1 jal 0x0018d384      Chance to React
0018d348: 00000000 nop            
0018d34c: 14400008 bne r2,r0,0x0018d370      
0018d350: 26100001 addiu r16,r16,0x0001      
0018d354: 3202ffff andi r2,r16,0xffff      
0018d358: 00028042 srl r16,r2,0x01      Damage / 2 ?
0018d35c: 3c038019 lui r3,0x8019      
0018d360: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018d364: 340201be ori r2,r0,0x01be      
0018d368: a4700026 sh r16,0x0026(r3)      
0018d36c: a462000e sh r2,0x000e(r3)      
0018d370: 8fbf0014 lw r31,0x0014(r29)      
0018d374: 8fb00010 lw r16,0x0010(r29)      
0018d378: 27bd0018 addiu r29,r29,0x0018      
0018d37c: 03e00008 jr r31
0018d380: 00000000 nop      




001882f8: 3c048019 lui r4,0x8019            
001882fc: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
00188300: 27bdffe8 addiu r29,r29,0xffe8      
00188304: afbf0010 sw r31,0x0010(r29)      
00188308: 0c063248 jal 0x0018c920      ???
0018830c: 00000000 nop            
00188310: 14400022 bne r2,r0,0x0018839c      
00188314: 00000000 nop            
00188318: 3c058019 lui r5,0x8019      
0018831c: 8ca52d98 lw r5,0x2d98(r5)      Load Defender's Stats....
00188320: 00000000 nop            
00188324: 90a2008e lbu r2,0x008e(r5)      Load 4th set of Reactions
00188328: 00000000 nop            
0018832c: 30420020 andi r2,r2,0x0020      Branch if not equiped with Finger Guard
00188330: 1040001a beq r2,r0,0x0018839c
00188334: 34020064 ori r2,r0,0x0064      R2=100
00188338: 90a30024 lbu r3,0x0024(r5)      
0018833c: 3c048019 lui r4,0x8019      
00188340: 8c842d90 lw r4,0x2d90(r4)      Load Current Action Data Pointer
00188344: 00431023 subu r2,r2,r3      100 - Brave
00188348: 1040000a beq r2,r0,0x00188374      Branch if Brave > 100?
0018834c: a482002a sh r2,0x002a(r4)      Store Hit %
00188350: 0c0634e1 jal 0x0018d384      chance to React
00188354: 00a02021 addu r4,r5,r0      
00188358: 14400010 bne r2,r0,0x0018839c      
0018835c: 00000000 nop            
00188360: 3c028019 lui r2,0x8019      
00188364: 8c42f5fc lw r2,-0x0a04(r2)      Load Something to do with Damage Display?
00188368: 00000000 nop            
0018836c: 1440000b bne r2,r0,0x0018839c      
00188370: 00000000 nop            
00188374: 3c028019 lui r2,0x8019      
00188378: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018837c: 00000000 nop            
00188380: a0400000 sb r0,0x0000(r2)      Change hit flag to miss
00188384: 3c038019 lui r3,0x8019      
00188388: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer...
0018838c: 340201c0 ori r2,r0,0x01c0      
00188390: a462000e sh r2,0x000e(r3)      Store Reaction ID
00188394: 3402000b ori r2,r0,0x000b      
00188398: a0620002 sb r2,0x0002(r3)      Store Evade type?
0018839c: 8fbf0010 lw r31,0x0010(r29)      
001883a0: 27bd0018 addiu r29,r29,0x0018      
001883a4: 03e00008 jr r31         
001883a8: 00000000 nop            




001883ac: 3c048019 lui r4,0x8019      
001883b0: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
001883b4: 27bdffe8 addiu r29,r29,0xffe8      
001883b8: afbf0010 sw r31,0x0010(r29)      
001883bc: 0c063248 jal 0x0018c920      ???
001883c0: 00000000 nop            
001883c4: 1440002c bne r2,r0,0x00188478      
001883c8: 00000000 nop            
001883cc: 3c028019 lui r2,0x8019      
001883d0: 8c422d94 lw r2,0x2d94(r2)      Load Attacker's Stats
001883d4: 00000000 nop            
001883d8: 90430003 lbu r3,0x0003(r2)      Load Attacker's Job
001883dc: 3402005d ori r2,r0,0x005d      
001883e0: 10620025 beq r3,r2,0x00188478      Branch to end if Attacker is a mime?
001883e4: 00000000 nop            
001883e8: 3c058019 lui r5,0x8019      
001883ec: 8ca52d98 lw r5,0x2d98(r5)      Load Defender's Stats
001883f0: 00000000 nop            
001883f4: 90a2008e lbu r2,0x008e(r5)      Load Defender's 4th set of Reactions
001883f8: 00000000 nop            
001883fc: 30420008 andi r2,r2,0x0008      
00188400: 1040001d beq r2,r0,0x00188478      Branch to end if user is not equiped with Catch
00188404: 34020064 ori r2,r0,0x0064      R2 = 100
00188408: 90a30024 lbu r3,0x0024(r5)      Load Brave
0018840c: 3c048019 lui r4,0x8019      
00188410: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer
00188414: 00431023 subu r2,r2,r3      100 - Brave
00188418: 1040000a beq r2,r0,0x00188444      Branch if Brave > 100 ?
0018841c: a482002a sh r2,0x002a(r4)      Store Hit % for Attack on self?
00188420: 0c0634e1 jal 0x0018d384      Chance to React
00188424: 00a02021 addu r4,r5,r0      
00188428: 14400013 bne r2,r0,0x00188478      Branch to end if Reaction failed
0018842c: 00000000 nop            
00188430: 3c028019 lui r2,0x8019      
00188434: 8c42f5fc lw r2,-0x0a04(r2)      Load something to do with Damage Display?
00188438: 00000000 nop            
0018843c: 1440000e bne r2,r0,0x00188478      
00188440: 00000000 nop            
00188444: 3c028019 lui r2,0x8019      
00188448: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018844c: 00000000 nop            
00188450: a0400000 sb r0,0x0000(r2)      Change hit flag to miss
00188454: 3c038019 lui r3,0x8019      
00188458: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018845c: 340201c2 ori r2,r0,0x01c2      
00188460: a462000e sh r2,0x000e(r3)      Store Reaction ID?
00188464: 3c048019 lui r4,0x8019      
00188468: 908438d8 lbu r4,0x38d8(r4)      Load Used Weapon ID
0018846c: 3402000d ori r2,r0,0x000d      
00188470: a0620002 sb r2,0x0002(r3)      Store Miss type?
00188474: a4640026 sh r4,0x0026(r3)      Store Used Weapon ID to something?
00188478: 8fbf0010 lw r31,0x0010(r29)      
0018847c: 27bd0018 addiu r29,r29,0x0018      
00188480: 03e00008 jr r31         
00188484: 00000000 nop            




0018ccd8: 27bdffe8 addiu r29,r29,0xffe8      
0018ccdc: 3c038019 lui r3,0x8019      
0018cce0: 906338e5 lbu r3,0x38e5(r3)      Load Attack formula ?
0018cce4: 34020007 ori r2,r0,0x0007      
0018cce8: 10620042 beq r3,r2,0x0018cdf4      Branch if used Formula is the "Healing" Weapon Formula?
0018ccec: afbf0010 sw r31,0x0010(r29)      
0018ccf0: 3c048019 lui r4,0x8019      
0018ccf4: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018ccf8: 0c063248 jal 0x0018c920      ???
0018ccfc: 00000000 nop            
0018cd00: 1440003c bne r2,r0,0x0018cdf4      
0018cd04: 00000000 nop            
0018cd08: 3c048019 lui r4,0x8019      
0018cd0c: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cd10: 00000000 nop            
0018cd14: 9083008b lbu r3,0x008b(r4)      Load Defender's 1st Set of Reactions
0018cd18: 00000000 nop            
0018cd1c: 30620080 andi r2,r3,0x0080      
0018cd20: 10400003 beq r2,r0,0x0018cd30      Branch if PA Save is not equiped
0018cd24: 30620040 andi r2,r3,0x0040      R2 = 40
0018cd28: 0806337b j 0x0018cdec         
0018cd2c: 340401a6 ori r4,r0,0x01a6      Prepares Reaction ID check?
0018cd30: 10400003 beq r2,r0,0x0018cd40      Branch if MA Save is not equiped
0018cd34: 30620020 andi r2,r3,0x0020      R2 = 20
0018cd38: 0806337b j 0x0018cdec         
0018cd3c: 340401a7 ori r4,r0,0x01a7      Prepares Reaction ID check?
0018cd40: 10400003 beq r2,r0,0x0018cd50      Branch if Speed Save is not equiped
0018cd44: 30620002 andi r2,r3,0x0002      R2 = 2
0018cd48: 0806337b j 0x0018cdec         
0018cd4c: 340401a8 ori r4,r0,0x01a8      Prepares Reaction ID check?
0018cd50: 10400003 beq r2,r0,0x0018cd60      Branch if Regenerator is not equiped
0018cd54: 00000000 nop            
0018cd58: 0806337b j 0x0018cdec         
0018cd5c: 340401ac ori r4,r0,0x01ac      Prepares Reaction ID Check?
0018cd60: 9083008c lbu r3,0x008c(r4)      Load Defender's 2nd set of Reactions
0018cd64: 00000000 nop            
0018cd68: 30620040 andi r2,r3,0x0040      
0018cd6c: 10400005 beq r2,r0,0x0018cd84      Branch if HP Restore is not equiped
0018cd70: 30620020 andi r2,r3,0x0020      R2 = 20
0018cd74: 0c0633bd jal 0x0018cef4      
0018cd78: 340401af ori r4,r0,0x01af      Prepares Reaction ID Check?
0018cd7c: 0806337d j 0x0018cdf4         
0018cd80: 00000000 nop            
0018cd84: 10400005 beq r2,r0,0x0018cd9c      Branch if MP Restore is not equiped
0018cd88: 30620010 andi r2,r3,0x0010      R2 = 10
0018cd8c: 0c0633bd jal 0x0018cef4      
0018cd90: 340401b0 ori r4,r0,0x01b0      Prepares Reaction ID Check?
0018cd94: 0806337d j 0x0018cdf4         
0018cd98: 00000000 nop            
0018cd9c: 10400005 beq r2,r0,0x0018cdb4      Branch if Critical Quick is not equiped
0018cda0: 30620008 andi r2,r3,0x0008      R2 = 8
0018cda4: 0c0633bd jal 0x0018cef4      
0018cda8: 340401b1 ori r4,r0,0x01b1      Prepares Reaction ID Check?
0018cdac: 0806337d j 0x0018cdf4         
0018cdb0: 00000000 nop            
0018cdb4: 10400005 beq r2,r0,0x0018cdcc      Branch if Meatbone Slash is not equiped
0018cdb8: 00000000 nop            
0018cdbc: 0c0633bd jal 0x0018cef4      
0018cdc0: 340401b2 ori r4,r0,0x01b2      Prepares Reaction ID Check?
0018cdc4: 0806337d j 0x0018cdf4         
0018cdc8: 00000000 nop            
0018cdcc: 9083008d lbu r3,0x008d(r4)      Load Defender's 3th Set of Reactions
0018cdd0: 00000000 nop            
0018cdd4: 30620040 andi r2,r3,0x0040      
0018cdd8: 14400004 bne r2,r0,0x0018cdec      Branch if unit is not equiped with Gilgame Heart
0018cddc: 340401b7 ori r4,r0,0x01b7      Prepares Reaction ID Check?
0018cde0: 30620010 andi r2,r3,0x0010      
0018cde4: 10400003 beq r2,r0,0x0018cdf4      Branch if unit is not equiped with Auto Potion
0018cde8: 340401b9 ori r4,r0,0x01b9      Prepares Reaction ID CHeck?
0018cdec: 0c0633a2 jal 0x0018ce88      
0018cdf0: 00000000 nop            
0018cdf4: 8fbf0010 lw r31,0x0010(r29)      
0018cdf8: 27bd0018 addiu r29,r29,0x0018      
0018cdfc: 03e00008 jr r31         
0018ce00: 00000000 nop            




0018ce88: 3c028019 lui r2,0x8019      
0018ce8c: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018ce90: 27bdffe8 addiu r29,r29,0xffe8      
0018ce94: afbf0014 sw r31,0x0014(r29)      
0018ce98: afb00010 sw r16,0x0010(r29)      
0018ce9c: 90420025 lbu r2,0x0025(r2)      Load Attack Type
0018cea0: 00000000 nop            
0018cea4: 30420080 andi r2,r2,0x0080      
0018cea8: 1040000d beq r2,r0,0x0018cee0      Branch if Attack was not HP Damage
0018ceac: 00808021 addu r16,r4,r0      
0018ceb0: 3c048019 lui r4,0x8019      
0018ceb4: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats   
0018ceb8: 0c0634e1 jal 0x0018d384      Load Chance to React
0018cebc: 00000000 nop            
0018cec0: 14400007 bne r2,r0,0x0018cee0      Branch if Reaction Failed
0018cec4: 00000000 nop            
0018cec8: 3c028019 lui r2,0x8019      
0018cecc: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018ced0: 00000000 nop            
0018ced4: 94430004 lhu r3,0x0004(r2)      Load HP Damage
0018ced8: a450000e sh r16,0x000e(r2)      Store Reaction ID
0018cedc: a4430026 sh r3,0x0026(r2)      Store Last Attack on Self?
0018cee0: 8fbf0014 lw r31,0x0014(r29)      
0018cee4: 8fb00010 lw r16,0x0010(r29)      
0018cee8: 27bd0018 addiu r29,r29,0x0018      
0018ceec: 03e00008 jr r31         
0018cef0: 00000000 nop         



0018cef4: 27bdffe8 addiu r29,r29,0xffe8      
0018cef8: afb00010 sw r16,0x0010(r29)      
0018cefc: 00808021 addu r16,r4,r0      
0018cf00: 3c048019 lui r4,0x8019      
0018cf04: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cf08: afbf0014 sw r31,0x0014(r29)      
0018cf0c: 9082005a lbu r2,0x005a(r4)      Load Target's 3rd set of Current Status
0018cf10: 00000000 nop            
0018cf14: 30420001 andi r2,r2,0x0001      
0018cf18: 10400011 beq r2,r0,0x0018cf60      Branch if Target is not in Critical
0018cf1c: 00000000 nop            
0018cf20: 3c028019 lui r2,0x8019      
0018cf24: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018cf28: 00000000 nop            
0018cf2c: 90420025 lbu r2,0x0025(r2)      Attack Type Flag
0018cf30: 00000000 nop            
0018cf34: 30420080 andi r2,r2,0x0080      
0018cf38: 10400009 beq r2,r0,0x0018cf60      Branch if Attack was not HP Damage
0018cf3c: 00000000 nop            
0018cf40: 0c0634e1 jal 0x0018d384      Chance to React
0018cf44: 00000000 nop            
0018cf48: 14400005 bne r2,r0,0x0018cf60      Branch if did not react
0018cf4c: 00000000 nop            
0018cf50: 3c028019 lui r2,0x8019      
0018cf54: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018cf58: 00000000 nop            
0018cf5c: a450000e sh r16,0x000e(r2)      Store Reaction ID
0018cf60: 8fbf0014 lw r31,0x0014(r29)      
0018cf64: 8fb00010 lw r16,0x0010(r29)      
0018cf68: 27bd0018 addiu r29,r29,0x0018      
0018cf6c: 03e00008 jr r31         
0018cf70: 00000000 nop   


MP Cost Section (Contains Half of MP check and calculation)

0017da20: 27bdffd8 addiu r29,r29,0xffd8      
0017da24: afb00018 sw r16,0x0018(r29)      
0017da28: 00808021 addu r16,r4,r0      Attacker's Data Pointer to r16?   
0017da2c: afbf0024 sw r31,0x0024(r29)      
0017da30: afb20020 sw r18,0x0020(r29)      
0017da34: afb1001c sw r17,0x001c(r29)      
0017da38: 9202016f lbu r2,0x016f(r16)      
0017da3c: 96110170 lhu r17,0x0170(r16)      
0017da40: 3c018006 lui r1,0x8006      
0017da44: 00220821 addu r1,r1,r2      
0017da48: 90325cb4 lbu r18,0x5cb4(r1)      Load Monster Skill Set?
0017da4c: 3c028019 lui r2,0x8019      
0017da50: 8c42f5f0 lw r2,-0x0a10(r2)      
0017da54: 3c018019 lui r1,0x8019      
0017da58: a02038eb sb r0,0x38eb(r1)      Used MP = 0 ?
0017da5c: 14400003 bne r2,r0,0x0017da6c      Branch if used MP is not 0
0017da60: 00000000 nop
0017da64: 0c0179ea jal 0x0005e7a8      
0017da68: 340500ff ori r5,r0,0x00ff      r5 = FF
0017da6c: 0c0604c3 jal 0x0018130c      MP Usability, Weapon Guard Usability, Reaction Usability
0017da70: 02002021 addu r4,r16,r0      Attacker's Data Pointer to r16?
0017da74: 9203005c lbu r3,0x005c(r16)      5th set of Current Status
0017da78: 00000000 nop            
0017da7c: 30630004 andi r3,r3,0x0004      
0017da80: 10600002 beq r3,r0,0x0017da8c      Branch if unit is not affected with Don't Act
0017da84: 00000000 nop            
0017da88: 34020001 ori r2,r0,0x0001      r2 = 1
0017da8c: 14400047 bne r2,r0,0x0017dbac      Branch to end if r2 > 0
0017da90: 24420006 addiu r2,r2,0x0006      r2 + 6
0017da94: 9202005a lbu r2,0x005a(r16)      Load 3rd set of Status
0017da98: 00000000 nop            
0017da9c: 30420002 andi r2,r2,0x0002      
0017daa0: 1040000e beq r2,r0,0x0017dadc      Branch if unit is not Frogged
0017daa4: 00111400 sll r2,r17,0x10      
0017daa8: 00021c03 sra r3,r2,0x10      
0017daac: 10600005 beq r3,r0,0x0017dac4      
0017dab0: 3402016f ori r2,r0,0x016f      
0017dab4: 10620003 beq r3,r2,0x0017dac4      
0017dab8: 3402001d ori r2,r0,0x001d      
0017dabc: 1462003b bne r3,r2,0x0017dbac      
0017dac0: 34020005 ori r2,r0,0x0005      
0017dac4: 324300ff andi r3,r18,0x00ff      
0017dac8: 3402000a ori r2,r0,0x000a      
0017dacc: 14620004 bne r3,r2,0x0017dae0      
0017dad0: 2e220170 sltiu r2,r17,0x0170      
0017dad4: 0805f6eb j 0x0017dbac         Jump to End
0017dad8: 34020005 ori r2,r0,0x0005      R2 = 5
0017dadc: 2e220170 sltiu r2,r17,0x0170      
0017dae0: 10400031 beq r2,r0,0x0017dba8      
0017dae4: 00111400 sll r2,r17,0x10      
0017dae8: 00021403 sra r2,r2,0x10      
0017daec: 000218c0 sll r3,r2,0x03      
0017daf0: 00621823 subu r3,r3,r2      
0017daf4: 00031840 sll r3,r3,0x01      
0017daf8: 3c028006 lui r2,0x8006      
0017dafc: 2442fbf0 addiu r2,r2,0xfbf0      
0017db00: 00622021 addu r4,r3,r2      
0017db04: 324300ff andi r3,r18,0x00ff      
0017db08: 10600003 beq r3,r0,0x0017db18      
0017db0c: 34020006 ori r2,r0,0x0006      
0017db10: 1462000b bne r3,r2,0x0017db40      
0017db14: 00000000 nop            
0017db18: 90820005 lbu r2,0x0005(r4)      Load Abilities 3rd set of Flags
0017db1c: 00000000 nop            
0017db20: 30420020 andi r2,r2,0x0020      
0017db24: 10400006 beq r2,r0,0x0017db40      Branch if ability is not affected by Silence (Ability Flag)
0017db28: 00000000 nop            
0017db2c: 92020059 lbu r2,0x0059(r16)      Load 2nd set of Status
0017db30: 00000000 nop            
0017db34: 30420008 andi r2,r2,0x0008      Branch if Silenced
0017db38: 1440001c bne r2,r0,0x0017dbac      
0017db3c: 34020002 ori r2,r0,0x0002      r2 = 2
0017db40: 1640001a bne r18,r0,0x0017dbac      
0017db44: 00001021 addu r2,r0,r0      r2 = 0
0017db48: 92030003 lbu r3,0x0003(r16)      Load Job
0017db4c: 3402005d ori r2,r0,0x005d      r2 = 5d
0017db50: 10620016 beq r3,r2,0x0017dbac      Branch if Job # is Mime
0017db54: 00001021 addu r2,r0,r0      r2 = 0
0017db58: 92020090 lbu r2,0x0090(r16)      Load secend set of Support
0017db5c: 9084000d lbu r4,0x000d(r4)      Abilities MP Cost
0017db60: 30420080 andi r2,r2,0x0080      
0017db64: 10400002 beq r2,r0,0x0017db70      Branch if not equiped with Half of MP
0017db68: 00000000 nop            
0017db6c: 00042042 srl r4,r4,0x01      Abilities MP Cost / 2      
0017db70: 3c018019 lui r1,0x8019      
0017db74: a02438eb sb r4,0x38eb(r1)      Store new Abilities MP Cost
0017db78: 8602002c lh r2,0x002c(r16)      Load Current MP
0017db7c: 00000000 nop            
0017db80: 00402821 addu r5,r2,r0      Current MP to r5
0017db84: 0044102a slt r2,r2,r4         Set r2 to 1 if Current MP is less than Ability Clost
0017db88: 14400008 bne r2,r0,0x0017dbac      If Current MP is less then Ability Cost Branch to end
0017db8c: 34020003 ori r2,r0,0x0003      r2 = 3
0017db90: 3c038019 lui r3,0x8019      
0017db94: 8c63f5fc lw r3,-0x0a04(r3)      ???
0017db98: 34020002 ori r2,r0,0x0002      r2 = 2
0017db9c: 10620002 beq r3,r2,0x0017dba8      
0017dba0: 00a41023 subu r2,r5,r4      Current MP - Used MP
0017dba4: a602002c sh r2,0x002c(r16)      Store new Current MP
0017dba8: 00001021 addu r2,r0,r0      r2 = 0
0017dbac: 8fbf0024 lw r31,0x0024(r29)
0017dbb0: 8fb20020 lw r18,0x0020(r29)
0017dbb4: 8fb1001c lw r17,0x001c(r29)
0017dbb8: 8fb00018 lw r16,0x0018(r29)
0017dbbc: 27bd0028 addiu r29,r29,0x0028
0017dbc0: 03e00008 jr r31
0017dbc4: 00000000 nop


Poison and Regen affect HP Section


0018d7c8: 27bdffe8 addiu r29,r29,0xffe8      
0018d7cc: afb00010 sw r16,0x0010(r29)      
0018d7d0: afbf0014 sw r31,0x0014(r29)      
0018d7d4: 0c063691 jal 0x0018da44      Check for Crystal, Dead, Jump, Petrify, or Treasure
0018d7d8: 00808021 addu r16,r4,r0      
0018d7dc: 1440001d bne r2,r0,0x0018d854      Branch to end if unit has Crystal, Dead, Jump, Petrify or Treasure
0018d7e0: 00001021 addu r2,r0,r0      r2 = 0
0018d7e4: 0c063681 jal 0x0018da04      
0018d7e8: 02002021 addu r4,r16,r0      
0018d7ec: 9203005b lbu r3,0x005b(r16)      Load Attacker's 4th set of Current status
0018d7f0: 00000000 nop            
0018d7f4: 30620080 andi r2,r3,0x0080      
0018d7f8: 10400008 beq r2,r0,0x0018d81c      Branch if unit isn't Poisoned
0018d7fc: 00000000 nop            
0018d800: 9602002a lhu r2,0x002a(r16)      Load Max HP
0018d804: 3c038019 lui r3,0x8019      
0018d808: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018d80c: 000210c2 srl r2,r2,0x03      Max HP / 8
0018d810: a4620004 sh r2,0x0004(r3)      Store has HP Damage
0018d814: 08063610 j 0x0018d840         
0018d818: 34020080 ori r2,r0,0x0080      Attack Flag (Damage)
0018d81c: 30620040 andi r2,r3,0x0040      
0018d820: 10400008 beq r2,r0,0x0018d844      Branch if unit doesn't have Regen
0018d824: 00000000 nop            
0018d828: 9602002a lhu r2,0x002a(r16)      Load Max HP
0018d82c: 3c038019 lui r3,0x8019      
0018d830: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018d834: 000210c2 srl r2,r2,0x03      Max HP / 8
0018d838: a4620006 sh r2,0x0006(r3)      Store has Healing
0018d83c: 34020040 ori r2,r0,0x0040      Attack Flag (Heal)
0018d840: a0620025 sb r2,0x0025(r3)      Store Attack Flag
0018d844: 3c028019 lui r2,0x8019      
0018d848: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018d84c: 00000000 nop            
0018d850: 90420025 lbu r2,0x0025(r2)      Load Attack Flag
0018d854: 8fbf0014 lw r31,0x0014(r29)      
0018d858: 8fb00010 lw r16,0x0010(r29)      
0018d85c: 27bd0018 addiu r29,r29,0x0018      
0018d860: 03e00008 jr r31         Return to Routine
0018d864: 00000000 nop   
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

RandMuadDib

sorry to hear you lost data :( glad to hear you're making progress though!
I will show you the power of SARDIIIIINES!!!!

Pride

  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

LastingDawn

Hmm about that "store weapon ID", the game gives the item to you right afterwards, is it preparing to give the item to the player with that?
"Moment's anger can revert to joy,
sadness can be turned to delight.
A nation destroyed cannot be restored,
the dead brought back to life."

Art of War

Beta & Gretchen Forever!!!!

Pride

That's probably it... I've just never gone through Throw really so its basically new territory for me...

Added more to my post with more reaction checks and their triggers.
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

Pride

Added a section on MP cost above
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

LastingDawn

How curious? Is this what we will need to disable for monsters to use MP in their attacks?
"Moment's anger can revert to joy,
sadness can be turned to delight.
A nation destroyed cannot be restored,
the dead brought back to life."

Art of War

Beta & Gretchen Forever!!!!

Pride

I can't say for certain but it does appear you may be able to enable monsters using mp here (the monster skill set being loaded into R18 suggest that). I won't know without testing it; which also wouldn't take long to test.
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

LastingDawn

Hmm, has any delving of the Poison Status and the Silence Status been done? I've just noticed something (that's likely been noticed and noted long ago) is that the Status Effects with CT are only the last 16 statii, if Poison and Silence aren't that complicated perhaps we can switch their two functionality, with Silence taking the spot of Poison and Poison being in the spot that Silence was. It is my experience that one of the first changes people make to their personal hacks is to get rid of the CT on Poison to make it possibly worthy using somewhere along the lines.
"Moment's anger can revert to joy,
sadness can be turned to delight.
A nation destroyed cannot be restored,
the dead brought back to life."

Art of War

Beta & Gretchen Forever!!!!

Pride

I only know where the HP damage (and HP recovery from Regen) is for Poison. I have very little knowledge on the CT of status. (I think fdc might have more knowledge on it)
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

Glain

May 18, 2011, 09:25:22 pm #77 Last Edit: May 18, 2011, 09:26:55 pm by Glain
So I was looking at some of the physical evasion stuff, and though it turns out SA had already documented most of what I looked at, I did find something fairly interesting. The last of the physical evade routines is the one that actually does the evasion roll, but my analysis of it would look like this:


00188488: 27bdffe8 addiu r29,r29,0xffe8
0018848c: afbf0010 sw r31,0x0010(r29)
00188490: 0c061605 jal 0x00185814               Combined evasion roll (Sets ability's hit status)
00188494: 00000000 nop
00188498: 3c028019 lui r2,0x8019
0018849c: 8c422d90 lw r2,0x2d90(r2)               
001884a0: 00000000 nop
001884a4: 90420000 lbu r2,0x0000(r2)            
001884a8: 00000000 nop
001884ac: 2c420001 sltiu r2,r2,0x0001            Find ability's evaded status (Why not just use 0x00185814's return value?)

001884b0: 8fbf0010 lw r31,0x0010(r29)
001884b4: 27bd0018 addiu r29,r29,0x0018
001884b8: 03e00008 jr r31                     RETURN r2 (Exactly the same as 0x00185814's return value)
001884bc: 00000000 nop                     


It looks like the entire call is worthless except for the call to another routine... they even return the same thing. I tried replacing the call to 0x188488 with a call to 0x185814 and everything still seemed to work fine, so this may free up some space to replace this code with something else.
  • Modding version: Other/Unknown

Pride

That's very interesting and nice find Glain (and unsurprising due to Square always wasting space) =P

Added the poison/regen affect hp routine above in my post.
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

LastingDawn

Hmm, seems pretty par for the course. I have a feeling that the Silence status will probably be a little more complicated than that. Good work.
"Moment's anger can revert to joy,
sadness can be turned to delight.
A nation destroyed cannot be restored,
the dead brought back to life."

Art of War

Beta & Gretchen Forever!!!!