Get Longest Range Ability or Move

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
BATTLE.BIN :  - Get Longest Range Ability or Move
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = Closest Harmfull Ability if Unit is Targeting an Enemy (Acting Unit AI 0x182c 0x0e)
         r2 = Closest Helpfull Ability if Unit is Targeting an Ally (Acting Unit AI 0x182c + 0x0f)
         r2 = Acting Unit move if not focusing a Unit
------------------------------------------------------------------------------------------
001962a0: 3c03801a lui r3,0x801a                 |
001962a4: 8c6301f8 lw r3,0x01f8(r3)              |Acting Unit AI Decision data pointer (8019f3c4 + 0x182c)
001962a8: 00000000 nop                           |
001962ac: 90620004 lbu r2,0x0004(r3)             |Acting unit decision byte 0x04
001962b0: 3c04801a lui r4,0x801a                 |
001962b4: 2484f3c4 addiu r4,r4,0xf3c4            |0x8019f3c4
001962b8: 30420040 andi r2,r2,0x0040             |
001962bc: 1040000f beq r2,r0,0x001962fc          #If Acting Unit has a Target (to focus)
001962c0: 00000000 nop                               |
001962c4: 90620005 lbu r2,0x0005(r3)                 |Targeted Unit ID
001962c8: 00000000 nop                               |
001962cc: 00021100 sll r2,r2,0x04                    |
001962d0: 00441021 addu r2,r2,r4                     |AI pointer + Unit offset (0x10)
001962d4: 90421834 lbu r2,0x1834(r2)                 |load enemy flag 0x182c + 0x08
001962d8: 00000000 nop                               |
001962dc: 10400004 beq r2,r0,0x001962f0              #If Targeted unit is an Enemy
001962e0: 00000000 nop                                   |
001962e4: 9062000e lbu r2,0x000e(r3)                     |Load and returns  range of closest Harmfull Ability
001962e8: 080658c1 j 0x00196304                          |Exit routine
001962ec: 00000000 nop                                   |
                                                    Else : Targeting an Ally
001962f0: 9062000f lbu r2,0x000f(r3)                     |Load and returns  range of closest Helpfull Ability
001962f4: 080658c1 j 0x00196304                          |Exit routine
001962f8: 00000000 nop                                   |
                                                Else : Acting Unit is not targeting a Unit
001962fc: 3c02801a lui r2,0x801a                     |
00196300: 904201fc lbu r2,0x01fc(r2)                 |load and returns Acting Unit move  8019f3c4 + 0x0e38
00196304: 03e00008 jr r31
00196308: 00000000 nop

Return locations

BATTLE.BIN
 00196578: Map_movement_decision/data_setting
 00198378: 001982d8_-_001984e8