Does Unit Have Status In Set

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Duplicated here : Status_Checks_(r5_=_set_to_check)

#   ROUTINE: DOES UNIT HAVE STATUS IN SET
#       Checks if a unit has a status in the specified Status Set (from RAM location 0x800662d0).  Returns true (1) if so, and false (0) if not.
#       Parameters:
#           r4 = (unit) Unit in-battle data pointer
#           r5 = (statusSetIndex) Index of Status Set to check against
#               Sets:
#                   0 - KO (0x01 in 0x04)
#                       Crystal, Dead, Petrify, Invite, Blood Suck, Treasure
#                   1  - Team Loss (0x02 in 0x04)
#                       Crystal, Invite, Treasure
#                   2  - Team Loss (Ally?) (0x04 in 0x04)
#                       Crystal, Treasure
#                   3  - Freeze CT (0x80 in 0x04)
#                       Crystal, Petrify, Treasure, Stop, Sleep
#                   4  - (0x80 in 0x05) (unit is in water and isn't a monster?)
#                       Crystal, Dead, Jump, Petrify, Confusion, Blood Suck, Treasure,
#                       Berserk, Chicken, Frog, Stop, Sleep, Don't Act
#                   5  - Immortal Immunities (0x01 in 0x05)
#                       Crystal, Dead, Undead, Petrify, Invite, Confusion, Blood Suck.
#                       Treasure, Chicken, Frog, Charm, Sleep, Don't Act, Death Sentence
#                   6  - Guest Immunities (0x02 in 0x05)
#                       Crystal, Dead, Undead, Petrify, Invite, Blood Suck, Treasure,
#                       Chicken, Frog, Charm, Death Sentence
#                   7  - (0x04 in 0x05)
#                       Darkness, Confusion, Transparent, Berserk, Chicken, Frog, Stop,
#                       Charm, Sleep, Don't Move, Don't Act
#                   8  - (0x08 in 0x05)
#                       Crystal, Dead, Undead, Jump, Petrify, Invite, Treasure, Critical
#                   9  - (0x10 in 0x5)
#                       Confusion, Berserk, Poison, Stop, Sleep, Don't Move, Don't Act,
#                       Death Sentence
#                   10 - Unmountable (Job ID 5e-60, hardcoded statuses)
#                       Crystal, Dead, Petrify, Blood Suck, Treasure, Berserk, Chicken,
#                       Frog, Charm
#       Returns:
#           r2 = true (1) if unit has at least one status in the set, false (0) otherwise

8005e1b0: 00003021 addu r6,r0,r0                        #   index = 0
8005e1b4: 3c038006 lui r3,0x8006
8005e1b8: 246362d0 addiu r3,r3,0x62d0                   #   statusSets
8005e1bc: 00051080 sll r2,r5,0x02                       #   statusSetIndex * 4
8005e1c0: 00451021 addu r2,r2,r5                        #   statusSetIndex * 5
8005e1c4: 00432821 addu r5,r2,r3                        #   statusBytePtr = statusSets[statusSetIndex]
                                                        #   do {
8005e1c8: 00861021 addu r2,r4,r6                               
8005e1cc: 90420058 lbu r2,0x0058(r2)                    #       unit.currentStatues[index]
8005e1d0: 90a30000 lbu r3,0x0000(r5)                    #       statusByte = *statusBytePtr
8005e1d4: 00000000 nop
8005e1d8: 00431024 and r2,r2,r3
8005e1dc: 14400006 bne r2,r0,0x8005e1f8                 #       if ((unit.currentStatues[index] & statusByte) != 0) return true;
8005e1e0: 34020001 ori r2,r0,0x0001
8005e1e4: 24c60001 addiu r6,r6,0x0001                   #       index = index + 1
8005e1e8: 28c20005 slti r2,r6,0x0005
8005e1ec: 1440fff6 bne r2,r0,0x8005e1c8
8005e1f0: 24a50001 addiu r5,r5,0x0001                   #       statusBytePtr = statusBytePtr + 1
                                                        #   } while (index < 5);
8005e1f4: 00001021 addu r2,r0,r0                        #   return false;
8005e1f8: 03e00008 jr r31
8005e1fc: 00000000 nop

Return Locations

BATTLE.BIN
001743f0
001832ec
001833dc
00183454
0018c97c
0018dd80
0018e788
0019b600
0019cc2c
Could be moved exclusively to BATTLE.BIN