Facing Evade Calculation

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
No Parameters - Returns Nothing

Compare X and Y coordinates difference to determine which direction is the more relevant
If X = Y Facing is Front or Side (back only if Same coordinates (?))

If Attacked from side : Class Evade is nullified (0x801938e1)
If Attacked from back : Class Evade, Right and Left Hands Evade are nullified (0x801938e1, 0x801938df, 0x801938e0)
------------------------------------------------------------------------------------------------------------------------
001854fc: 3c058019 lui r5,0x8019            |
00185500: 8ca52d98 lw r5,0x2d98(r5)         |r5 = Target data pointer
00185504: 3c048019 lui r4,0x8019            |
00185508: 8c842d94 lw r4,0x2d94(r4)         |r4 = Attacker data pointer
0018550c: 90a30047 lbu r3,0x0047(r5)        |r3 = Target X coordinate
00185510: 90820047 lbu r2,0x0047(r4)        |r2 = Attacker X coordinate
00185514: 00000000 nop                      |
00185518: 00624023 subu r8,r3,r2            |r8 = Delta X (Target - Attacker)
0018551c: 90820048 lbu r2,0x0048(r4)        |r2 = Attacker Y coordinate
00185520: 05010002 bgez r8,0x0018552c       #If Delta X < 0x00 
00185524: 01002021 addu r4,r8,r0            |r4 = Delta X
00185528: 00042023 subu r4,r0,r4                |r4 = Delta X (positive value)
0018552c: 90a30048 lbu r3,0x0048(r5)        |r3 = Target Y Coordinate
00185530: 308400ff andi r4,r4,0x00ff        |r4 = Delta X (positive byte)
00185534: 00623823 subu r7,r3,r2            |r7 = Delta Y (Target - Attacker)
00185538: 04e10002 bgez r7,0x00185544       #If Delta Y < 0x00
0018553c: 00e01021 addu r2,r7,r0            |r2 = Delta Y
00185540: 00021023 subu r2,r0,r2                |r2 = Positive value of Delta Y
00185544: 304300ff andi r3,r2,0x00ff        |r3 = Delta Y (positive byte)
00185548: 0064102b sltu r2,r3,r4            |r2 = 0x01 if Delta Y < Delta X
0018554c: 1040001d beq r2,r0,0x001855c4     #If Delta X > Delta Y  (delta X has more weight to determine facing)
00185550: 34060001 ori r6,r0,0x0001         |r6 = 0x01 (default is side attack)

---  Delta X  has more weight --- 
00185554: 1900000c blez r8,0x00185588           #If raw Delta X > 0x00 (Target is eastward) /Else branch to Westward check)
00185558: 00000000 nop                              |
0018555c: 94a20048 lhu r2,0x0048(r5)                |r2 = Target Y + Facing/Elevation
00185560: 00000000 nop                              |
00185564: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing
00185568: 34020100 ori r2,r0,0x0100                 |r2 = 0x0100 (Facing West)
0018556c: 14620003 bne r3,r2,0x0018557c             #If Target is facing West
00185570: 34020300 ori r2,r0,0x0300                 |r2 = 0x0300 (Facing East)
00185574: 08061562 j 0x00185588                         >>Jump to Westward check (will branch to evade calculation)
00185578: 00003021 addu r6,r0,r0                        |r6 = 0x00 (Frontal Attack)
0018557c: 14620002 bne r3,r2,0x00185588             #If Target is facing East
00185580: 00000000 nop                                  |
00185584: 34060002 ori r6,r0,0x0002                     |r6 = 0x02 (Attack from Back)
00185588: 05010058 bgez r8,0x001856ec           #If raw Delta X < 0x00 (Target is Westward) /Else branch to Evade Calculation
0018558c: 00000000 nop                              |
00185590: 3c028019 lui r2,0x8019                    |
00185594: 8c422d98 lw r2,0x2d98(r2)                 |r2 = Target data pointer
00185598: 00000000 nop                              |
0018559c: 94420048 lhu r2,0x0048(r2)                |r2 = Target Y + Facing/Elevation
001855a0: 00000000 nop                              |
001855a4: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing only
001855a8: 34020300 ori r2,r0,0x0300                 |r2 = 0x0300 (Facing East)
001855ac: 10620048 beq r3,r2,0x001856d0             #If Target is not facing East /If Facing East branch - r6 will be set to 0x00 and jump to  Evade Calculation
001855b0: 34020100 ori r2,r0,0x0100                     |r2 = 0x0100 (Facing West)
001855b4: 1462004d bne r3,r2,0x001856ec                 #If Target is facing West
001855b8: 00000000 nop                                      |
001855bc: 080615bb j 0x001856ec                             >>Jump to  Evade Calculation  r6 = 0x02 (Attack from Back)
001855c0: 34060002 ori r6,r0,0x0002                         |r6 = 0x02 (Attack from Back)
001855c4: 0083102b sltu r2,r4,r3            |r2 = 0x01 if Delta X < Delta Y
001855c8: 1040001c beq r2,r0,0x0018563c     #If Delta Y > Delta X (delta Y has more weight to determine facing)
001855cc: 00000000 nop                          |

--- Delta Y  has more weight ---
001855d0: 18e0000b blez r7,0x00185600           #If Raw Delta Y > 0x00 (Target is to the North)
001855d4: 00000000 nop                              |
001855d8: 94a20048 lhu r2,0x0048(r5)                |r2 = Target Y + Facing/Elevation
001855dc: 00000000 nop                              |
001855e0: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing
001855e4: 14600003 bne r3,r0,0x001855f4             #If Target is facing South
001855e8: 34020200 ori r2,r0,0x0200                 |r2 = 0x200 (Facing North ?)
001855ec: 08061580 j 0x00185600                         >>Jump to Southward check (will branch to Evade calculation)
001855f0: 00003021 addu r6,r0,r0                        |r6 = 0x00 (front)
001855f4: 14620002 bne r3,r2,0x00185600             #If Target is facing North
001855f8: 00000000 nop                                  |
001855fc: 34060002 ori r6,r0,0x0002                     |r6 = 0x02 (Attack from Back)
00185600: 04e1003a bgez r7,0x001856ec           #If Raw Delta Y < 0x00 (Target is Southward)
00185604: 00000000 nop                              |
00185608: 3c028019 lui r2,0x8019                    |
0018560c: 8c422d98 lw r2,0x2d98(r2)                 |r2 = Target data pointer
00185610: 00000000 nop                              |
00185614: 94420048 lhu r2,0x0048(r2)                |r2 = Target Y + Facing/Elevation
00185618: 00000000 nop                              |
0018561c: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing
00185620: 34020200 ori r2,r0,0x0200                 |r2 = 0x200 (Facing North)
00185624: 1062002a beq r3,r2,0x001856d0             #If Target is not Facing North /If Facing North branch - r6 will be set to 0x00 and jump to  Evade Calculation
00185628: 00000000 nop                                  |
0018562c: 1460002f bne r3,r0,0x001856ec                 #If Target is Facing South
00185630: 00000000 nop                                      |
00185634: 080615bb j 0x001856ec                             >>Jump to  Evade Calculation  r6 = 0x02 (Attack from Back)
00185638: 34060002 ori r6,r0,0x0002                         |r6 = 0x02 (Attack from Back)

--- Delta X = Delta Y (45° Attack) --- 
0018563c: 19000006 blez r8,0x00185658       #If raw delta X >0x00 (Target is Eastward)
00185640: 34030100 ori r3,r0,0x0100             |r3 = 0x100 (Facing West)
00185644: 94a20048 lhu r2,0x0048(r5)            |r2 = Target Y + Facing/Elevation
00185648: 00000000 nop                          |
0018564c: 30420f00 andi r2,r2,0x0f00            |r2 = Target facing only
00185650: 1043001f beq r2,r3,0x001856d0         #If Target is not facing West /Branch if facing West (r6 will be set to 0x00 - front Attack)
00185654: 00000000 nop                              |
00185658: 05010009 bgez r8,0x00185680               #If raw delta X < 0x00 (Target is Westward)
0018565c: 34030300 ori r3,r0,0x0300                     |r3 = 0x300 (facing East)
00185660: 3c028019 lui r2,0x8019                        |
00185664: 8c422d98 lw r2,0x2d98(r2)                     |r2 = Target data pointer
00185668: 00000000 nop                                  |
0018566c: 94420048 lhu r2,0x0048(r2)                    |r2 = Target Y + Facing/Elevation
00185670: 00000000 nop                                  |
00185674: 30420f00 andi r2,r2,0x0f00                    |r2 = Target facing only
00185678: 10430015 beq r2,r3,0x001856d0                 #If Target is not facing East /Branch if facing East (r6 will be set to 0x00 - front Attack)
0018567c: 00000000 nop                                      |
00185680: 18e00009 blez r7,0x001856a8                       #If Raw delta Y > 0x00 (Target is Northward)
00185684: 00000000 nop                                          |
00185688: 3c028019 lui r2,0x8019                                |
0018568c: 8c422d98 lw r2,0x2d98(r2)                             |r2 = Target data pointer
00185690: 00000000 nop                                          |
00185694: 94420048 lhu r2,0x0048(r2)                            |r2 = Target Y + Facing/Elevation
00185698: 00000000 nop                                          |
0018569c: 30420f00 andi r2,r2,0x0f00                            |r2 = Target facing only
001856a0: 1040000b beq r2,r0,0x001856d0                         #If Target is not facing South /Branch if facing South (r6 will be set to 0x00 - front Attack)
001856a4: 00000000 nop                                              |
001856a8: 04e1000b bgez r7,0x001856d8                       #E      #If Delta Y < 0x00 (Target is Southward)
001856ac: 34030200 ori r3,r0,0x0200                                     |r3 = 0x200 (Facing North)
001856b0: 3c028019 lui r2,0x8019                                        |
001856b4: 8c422d98 lw r2,0x2d98(r2)                                     |r2 = Target data pointer
001856b8: 00000000 nop                                                  |
001856bc: 94420048 lhu r2,0x0048(r2)                                    |r2 = Target Y + Facing/Elevation
001856c0: 00000000 nop                                                  |
001856c4: 30420f00 andi r2,r2,0x0f00                                    |r2 = Target facing only
001856c8: 14430003 bne r2,r3,0x001856d8                                 #If Target is facing North
001856cc: 00000000 nop                                                      |
001856d0: 080615bb j 0x001856ec                         #E     #E           >>Jump to  Evade Calculation  r6 = 0x00 (Attack from Front)
001856d4: 00003021 addu r6,r0,r0                                            |r6 = 0x00
001856d8: 15000004 bne r8,r0,0x001856ec                             #If Delta X = 0x00 /Else Branch to Evade calculation (Side Attack)
001856dc: 00000000 nop                                                  |
001856e0: 14e00002 bne r7,r0,0x001856ec                                 #If Delta Y = 0x00 /Else Branch to Evade calculation (Side Attack)
001856e4: 00000000 nop                                                      |
001856e8: 34060002 ori r6,r0,0x0002                                         |r6 = 0x02 (Never true ? Delta X = Delta Y = 0 ? - Attack from same tile different elevation ??)

--- Evasion Calculation --- 
001856ec: 3c038019 lui r3,0x8019                                            |
001856f0: 246338e2 addiu r3,r3,0x38e2       |r3 = 0x801938e2 (Current ability Facing mod pointer)
001856f4: a0660000 sb r6,0x0000(r3)         |Store r6 as Current ability facing modifier
001856f8: 90620000 lbu r2,0x0000(r3)        |r2 = Facing modifier
001856fc: 00000000 nop                      |
00185700: 10400003 beq r2,r0,0x00185710     #If Facing modifier <> 0x00 (not frontal attack)
00185704: 00000000 nop                          |
00185708: 3c018019 lui r1,0x8019                |
0018570c: a02038e1 sb r0,0x38e1(r1)             |Nullify Current Ability Class Evade ( 0x801938e1 )
00185710: 90630000 lbu r3,0x0000(r3)        |r3 =  Facing Mod
00185714: 34020002 ori r2,r0,0x0002         |
00185718: 14620005 bne r3,r2,0x00185730     #If Facing modifier = 0x02 (Back Attack)
0018571c: 00000000 nop                          |
00185720: 3c018019 lui r1,0x8019                |
00185724: a02038df sb r0,0x38df(r1)             |Nullify Current Ability Weapon Evade ( 0x801938df )
00185728: 3c018019 lui r1,0x8019                |
0018572c: a02038e0 sb r0,0x38e0(r1)             |Nullify Current Ability Shield Evade  ( 0x801938e0 )
00185730: 03e00008 jr r31                       |
00185734: 00000000 nop                          |


Return Locations

Battle.bin
00188550: Physical Evade Calculation
001885A0: Physical Evade Calculation(Charge)