Set Specific Unit Animation Value When Battle Init

From Final Fantasy Hacktics Wiki
Revision as of 03:02, 22 April 2022 by Glain (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: SET SPECIFIC UNIT ANIMATION VALUE WHEN BATTLE INIT
#       Sets a specific animation value to a unit if the battle initialization variable (0x1FD) is set, otherwise sets animation based on unit's status and mount/rider state.
#       Parameters:
#           r4 = (unitMiscID) Unit Misc ID
#           r5 = (animationValue) Animation value to apply to the unit

8012da0c: 27bdffe0 addiu r29,r29,-0x0020
8012da10: afb10014 sw r17,0x0014(r29)
8012da14: 00808821 addu r17,r4,r0                   #   unitMiscID
8012da18: afb20018 sw r18,0x0018(r29)
8012da1c: 00a09021 addu r18,r5,r0                   #   animationValue
8012da20: 340401fd ori r4,r0,0x01fd
8012da24: afbf001c sw r31,0x001c(r29)
8012da28: 0c04ed64 jal 0x8013b590                   #   isInitialization = Get Script Variable (0x1fd);
8012da2c: afb00010 sw r16,0x0010(r29)
8012da30: 1440002a bne r2,r0,0x8012dadc             #   if (!isInitialization) {            // Not initialization
8012da34: 02202021 addu r4,r17,r0
8012da38: 0c04ed64 jal 0x8013b590                   #       shopAvailabilityValue = Get Script Variable (0x6f);
8012da3c: 3404006f ori r4,r0,0x006f
8012da40: 10400026 beq r2,r0,0x8012dadc             #       if (shopAvailabilityValue != 0) {
8012da44: 02202021 addu r4,r17,r0
8012da48: 0c023374 jal 0x8008cdd0                   #           battleUnitIndex = Get Battle Unit Index By Unit Misc ID (unitMiscID);
8012da4c: 02202021 addu r4,r17,r0
8012da50: 00402021 addu r4,r2,r0                    #           battleUnitIndex
8012da54: 04800020 bltz r4,0x8012dad8               #           if (battleUnitIndex >= 0) {
8012da58: 2e4201f4 sltiu r2,r18,0x01f4
8012da5c: 1040001e beq r2,r0,0x8012dad8             #               if (animationValue < 0x1f4) {
8012da60: 00000000 nop
8012da64: 0c0602bf jal 0x80180afc                   #                   battleUnit = Get Unit's Data Pointer (battleUnitIndex);
8012da68: 00000000 nop
8012da6c: 34040004 ori r4,r0,0x0004                 #                   4
8012da70: 00408021 addu r16,r2,r0                   #                   battleUnit
8012da74: 90450047 lbu r5,0x0047(r2)                #                   battleUnit.X
8012da78: 96070048 lhu r7,0x0048(r16)
8012da7c: 92060048 lbu r6,0x0048(r16)               #                   battleUnit.Y
8012da80: 0c061007 jal 0x8018401c                   #                   depth = Return Various Tile Data (4, battleUnit.X, battleUnit.Y, battleUnit.HigherElevation);
8012da84: 00073bc2 srl r7,r7,0x0f                   #                   battleUnit.HigherElevation
8012da88: 92030182 lbu r3,0x0182(r16)               #                   battleUnit.mountInfo
8012da8c: 00000000 nop
8012da90: 306300c0 andi r3,r3,0x00c0                #                   mountRiderValue = battleUnit.mountInfo & 0xC0
8012da94: 10600005 beq r3,r0,0x8012daac
8012da98: 304200ff andi r2,r2,0x00ff                #                   depth
                                                    #                   if (mountRiderValue != 0) {
8012da9c: 3c028009 lui r2,0x8009
8012daa0: 2442be54 addiu r2,r2,-0x41ac              #                       routineToRun = 0x8008be54 (Set Animation Based On Unit Status From Unit Misc ID);
8012daa4: 0804b6b0 j 0x8012dac0
8012daa8: 00000000 nop                              #                   } else if (depth >= 2) {
8012daac: 28420002 slti r2,r2,0x0002
8012dab0: 1440000a bne r2,r0,0x8012dadc
8012dab4: 02202021 addu r4,r17,r0
8012dab8: 3c028009 lui r2,0x8009                    #                       routineToRun = 0x8008be04 (Set Animation Based On Unit Mounted State From Unit Misc ID);
8012dabc: 2442be04 addiu r2,r2,-0x41fc
                                                    #                   } else { skipRoutineRun = true; }
                                                    #                   if (!skipRoutineRun) {
8012dac0: 3c018017 lui r1,0x8017
8012dac4: ac223ca8 sw r2,0x3ca8(r1)                 #                       routine = routineToRun
8012dac8: 0c0533ad jal 0x8014ceb4                   #                       Call Inner Subroutine (unitMiscID);
8012dacc: 02202021 addu r4,r17,r0
8012dad0: 0804b6b9 j 0x8012dae4
8012dad4: 00000000 nop                              #                   }
                                                    #               }
                                                    #           }
                                                    #       }
                                                    #   } else {
8012dad8: 02202021 addu r4,r17,r0
8012dadc: 0c022f9f jal 0x8008be7c                   #       Set Specific Animation Value From Unit Misc ID (unitMiscID, animationValue);
8012dae0: 02402821 addu r5,r18,r0
                                                    #   }
8012dae4: 8fbf001c lw r31,0x001c(r29)
8012dae8: 8fb20018 lw r18,0x0018(r29)
8012daec: 8fb10014 lw r17,0x0014(r29)
8012daf0: 8fb00010 lw r16,0x0010(r29)
8012daf4: 27bd0020 addiu r29,r29,0x0020
8012daf8: 03e00008 jr r31
8012dafc: 00000000 nop