Check target type

From Final Fantasy Hacktics Wiki
Revision as of 12:11, 1 May 2023 by Orkney (talk | contribs)
Jump to navigation Jump to search
BATTLE.BIN : Check target type
--------------------------------------------------------------------------------------------------
Parameters : r4 is Focused Unit ID

Returns : r2 = 0x01 if Unit is Target is not targetable (from AI targeting flag)
          r2 = 0x01 if Unit is Dead without reraise (dead for good)
          r2 = 0x01 if Unit is Petrified
          r2 = 0x00 if non of above are true (worth to be considered ?)
--------------------------------------------------------------------------------------------------
00196c8c: 00041100 sll r2,r4,0x04           |Unit ID * 16
00196c90: 3c01801a lui r1,0x801a            |
00196c94: 00220821 addu r1,r1,r2            |801a0000 + Unit offset
00196c98: 90230bf7 lbu r3,0x0bf7(r1)        |Load AI Targeting Flags/Settings  8019f3c4 + 0x182c + 0x07 + Unit Offset (Flags come from Unit Battle stats 0x16a)
00196c9c: 00000000 nop                      |
00196ca0: 00031102 srl r2,r3,0x04           |Left nibble
00196ca4: 30420001 andi r2,r2,0x0001        |Check [Can't be Targeted]
00196ca8: 1440000d bne r2,r0,0x00196ce0     #If Focused Unit is Targetable /Else : branch to END
00196cac: 34020001 ori r2,r0,0x0001         |returns 0x01
00196cb0: 00031142 srl r2,r3,0x05               |
00196cb4: 30420001 andi r2,r2,0x0001            |Check [Dead Unit without reraise]
00196cb8: 14400009 bne r2,r0,0x00196ce0         #If Unit is not Dead (or dead with reraise) /Else : branch to END
00196cbc: 34020001 ori r2,r0,0x0001             |Returns 0x01
00196cc0: 000410c0 sll r2,r4,0x03                   |
00196cc4: 00441023 subu r2,r2,r4                    |
00196cc8: 00021180 sll r2,r2,0x06                   |Unit ID * 0x1c0
00196ccc: 3c018019 lui r1,0x8019                    |
00196cd0: 00220821 addu r1,r1,r2                    |
00196cd4: 90220925 lbu r2,0x0925(r1)                |Load Unit Current Status 2nd Set 0x801908cc + 0x59 + Unit offset
00196cd8: 00000000 nop                              |
00196cdc: 000211c2 srl r2,r2,0x07                   |r2 = 0x1 if Unit is petrified
00196ce0: 03e00008 jr r31                   END
00196ce4: 00000000 nop

Return Locations

BATTLE.BIN
00194618: Some_targetability_setting
00194808: Set_AI_flags_for_target_consideration
00194ec0: Set_AI_ability_considerations_for_all_units_and_self
0019736c: Set_chosen_ability/target_for_AI_status
00198078: Fight_for_Life_-_Auto_Battle_(00197ff4)
00199754: Check_for_good_units_to_target_(based_on_distance,status,coordinate)