AI Check if Unit is a Crystal/Treasure (0019bb20)

From Final Fantasy Hacktics Wiki
(Redirected from 0019bb20 - 0019bbb8)
Jump to navigation Jump to search
BATTLE.BIN - AI Check if Unit is a Crystal/Treasure
---------------------------------------------------------------------------------------
Parameters : Nothing 
Returns : Nothing

Set 0x801a0083 Value (0x8019f3c4 - 0xcbf)
 0x01 if Unit on Tile is a crystal
 0x02 if unit on Til is a treasure
 0x00 if not a crystal nor a treasure
---------------------------------------------------------------------------------------
0019bb20: 27bdffe8 addiu r29,r29,-0x0018    |
0019bb24: 3c04801a lui r4,0x801a            |
0019bb28: 2484f3dc addiu r4,r4,-0x0c24      |Pointer to AI Tile of interest coordinates 8019f3c4 - 0x18
0019bb2c: afbf0010 sw r31,0x0010(r29)       |
0019bb30: 3c01801a lui r1,0x801a            |
0019bb34: a0200083 sb r0,0x0083(r1)         |Nullify AI 0x0CBF  8019f3c4 - 0xcbf
0019bb38: 0c0674a5 jal 0x0019d294           |-->Get_unit_that_matches_coordinates returns Unit ID if tile occupied (0x15 if nobody)
0019bb3c: 00000000 nop                      |
0019bb40: 00401821 addu r3,r2,r0            |
0019bb44: 34020015 ori r2,r0,0x0015         |
0019bb48: 10620018 beq r3,r2,0x0019bbac     #If There is  a unit on the Tile
0019bb4c: 000310c0 sll r2,r3,0x03               |
0019bb50: 00431023 subu r2,r2,r3                |
0019bb54: 00021180 sll r2,r2,0x06               |
0019bb58: 3c038019 lui r3,0x8019                |
0019bb5c: 246308cc addiu r3,r3,0x08cc           |
0019bb60: 00432021 addu r4,r2,r3                |Pointer to Unit battle stats
0019bb64: 90830001 lbu r3,0x0001(r4)            |Unit ID
0019bb68: 340200ff ori r2,r0,0x00ff             |
0019bb6c: 1062000f beq r3,r2,0x0019bbac         #If Unit do not exist :   Exit routine 
0019bb70: 00000000 nop                              |
0019bb74: 90820058 lbu r2,0x0058(r4)            |Unit Current Status 1
0019bb78: 00000000 nop                          |
0019bb7c: 30420040 andi r2,r2,0x0040            |Check [Crystal]
0019bb80: 10400003 beq r2,r0,0x0019bb90         #If Unit is a Crystal
0019bb84: 34020001 ori r2,r0,0x0001                 |
0019bb88: 3c01801a lui r1,0x801a                    |
0019bb8c: a0220083 sb r2,0x0083(r1)                 |Store 0x01 at AI 0xcbf
0019bb90: 90820059 lbu r2,0x0059(r4)            |Unit Current Status 2
0019bb94: 00000000 nop                          |
0019bb98: 30420001 andi r2,r2,0x0001            |Check [Treasure]
0019bb9c: 10400003 beq r2,r0,0x0019bbac         #If Unit is a Treasure
0019bba0: 34020002 ori r2,r0,0x0002                 |
0019bba4: 3c01801a lui r1,0x801a                    |
0019bba8: a0220083 sb r2,0x0083(r1)                 |Store 0x02 at AI 0xcbf
0019bbac: 8fbf0010 lw r31,0x0010(r29)           END
0019bbb0: 27bd0018 addiu r29,r29,0x0018
0019bbb4: 03e00008 jr r31
0019bbb8: 00000000 nop

Return location

Battle.bin
0019604c: AI_ability_use_control_routine
00199af0: AI_Target_Priority_Super_Routine_(001999c8)
0019b04c: Set_or_Remove_Charging_(00195f8c)
0019b388: Check_if_any_units_are_in_range_(0019b30c)
0019ba38: AI_Targeting_Matrix_Analysis_(0019b7b8)
0019c270: 0019c20c_-_0019c27c