Knockback Calculation

From Final Fantasy Hacktics Wiki
Revision as of 13:54, 27 November 2012 by Choto (talk | contribs)
Jump to navigation Jump to search
Knockback Calculation:
001843ec: 27bdffe0 addiu r29,r29,0xffe0
001843f0: 3c038019 lui r3,0x8019
001843f4: 906338ec lbu r3,0x38ec(r3)		Knockback flag?
001843f8: 34020001 ori r2,r0,0x0001		r2 = 1
001843fc: afbf001c sw r31,0x001c(r29)
00184400: afb2 0018 sw r18,0x 0018(r29)
00184404: afb10014 sw r17,0x0014(r29)
00184408: 1462007a bne r3,r2,0x 001845f4		Branch if Knockback Flag? is not 1 (Can't be knocked back)
0018440c: afb00010 sw r16,0x0010(r29)
00184410: 3c058019 lui r5,0x8019
00184414: 8ca52d98 lw r5,0x2d98(r5)		Load Target's Data Pointer
00184418: 00000000 nop
0018441c: 90a30005 lbu r3,0x0005(r5)		Load Target's Battle-Specific Flags
00184420: 00000000 nop
00184424: 30620004 andi r2,r3,0x0004
00184428: 14400072 bne r2,r0,0x 001845f4		Branch if Target is Immortal
0018442c: 30630003 andi r3,r3,0x0003
00184430: 34020003 ori r2,r0,0x0003		r2 = 3
00184434: 1062006f beq r3,r2,0x 001845f4		Branch if ? = 3
00184438: 00000000 nop
0018443c: 3c048019 lui r4,0x8019
00184440: 8c842d94 lw r4,0x2d94(r4)		Load Attacker's Data Pointer
00184444: 00000000 nop
00184448: 10a4006a beq r5,r4,0x 001845f4		Branch if Target is Attacker
0018444c: 00000000 nop
00184450: 90a20182 lbu r2,0x0182(r5)		Load Chocobo Byte
00184454: 00000000 nop
00184458: 14400066 bne r2,r0,0x 001845f4		Branch if Riding a Chocobo/in Deep Water
0018445c: 00000000 nop
00184460: 90a90047 lbu r9,0x0047(r5)		Load Target's X
00184464: 90830047 lbu r3,0x0047(r4)		Load Attacker's X
00184468: 90a60048 lbu r6,0x0048(r5)		Load Target's Y + Facing
0018446c: 90820048 lbu r2,0x0048(r4)		Load Attacker's Y + Facing
00184470: 01234023 subu r8,r9,r3		r8 = TX - AX
00184474: 00c23823 subu r7,r6,r2		r7 = TY - AY
00184478: 05010002 bgez r8,0x 00184484		Branch if TX >= AX
0018447c: 01002021 addu r4,r8,r0		r4 = TX - AX
00184480: 00042023 subu r4,r0,r4		r4 = -(TX - AX) (makes it positive)
00184484: 04e10002 bgez r7,0x 00184490		Branch if TY >= AY
00184488: 00e01821 addu r3,r7,r0		r3 = TY - AY
0018448c: 00031823 subu r3,r0,r3		r3 = -(TY - AY) (makes it positive)
00184490: 00831021 addu r2,r4,r3		r2 = (TX - AX) + (TY - AY)
00184494: 10400057 beq r2,r0,0x 001845f4		Branch if Target is on the same X/Y (above or below)
00184498: 01208021 addu r16,r9,r0		r16 = TX
0018449c: 0064102a slt r2,r3,r4
001844a0: 10400008 beq r2,r0,0x 001844c4		Branch if Y Diff < X Diff
001844a4: 00c08821 addu r17,r6,r0		r17 = TY
001844a8: 19000003 blez r8,0x 001844b8		Branch if TX <= AX
001844ac: 34040003 ori r4,r0,0x0003		r4 = 3 (Knocked Right)
001844b0: 08061137 j 0x 001844dc
001844b4: 26100001 addiu r16,r16,0x0001		TX += 1
001844b8: 34040001 ori r4,r0,0x0001		r4 = 1 (Knocked Left)
001844bc: 08061137 j 0x 001844dc
001844c0: 2610ffff addiu r16,r16,0xffff		TX -= 1
001844c4: 18e00003 blez r7,0x 001844d4		Branch if TY <= AY
001844c8: 34040002 ori r4,r0,0x0002		r4 = 2 (Knocked Up :3)
001844cc: 08061137 j 0x 001844dc
001844d0: 26310001 addiu r17,r17,0x0001		TY += 1
001844d4: 00002021 addu r4,r0,r0		r4 = 0 (Knocked Down)
001844d8: 2631ffff addiu r17,r17,0xffff		TY -= 1
001844dc: 02002821 addu r5,r16,r0		r5 = new TX
001844e0: 0c061184 jal 0x 00184610
001844e4: 02203021 addu r6,r17,r0		r6 = new TY
001844e8: 00409021 addu r18,r2,r0
001844ec: 06400041 bltz r18,0x 001845f4
001844f0: 00000000 nop
001844f4: 3c02800e lui r2,0x800e
001844f8: 90424e9c lbu r2,0x4e9c(r2)
001844fc: 00000000 nop
00184500: 0222 0018 mult r17,r2
00184504: 00121200 sll r2,r18,0x08
00184508: 00 001812 mflo r3
0018450c: 00431021 addu r2,r2,r3
00184510: 00501021 addu r2,r2,r16
00184514: 000210c0 sll r2,r2,0x03
00184518: 3c038019 lui r3,0x8019
0018451c: 2463f8cc addiu r3,r3,0xf8cc
00184520: 00432021 addu r4,r2,r3
00184524: 90830000 lbu r3,0x0000(r4)           load tile type
00184528: 90820006 lbu r2,0x0006(r4)           load tile flags
0018452c: 00000000 nop
00184530: 30420002 andi r2,r2,0x0002
00184534: 1440002f bne r2,r0,0x 001845f4       branch if untargetable
00184538: 3063003f andi r3,r3,0x003f           
0018453c: 90820003 lbu r2,0x0003(r4)           load slope height
00184540: 00000000 nop
00184544: 304200e0 andi r2,r2,0x00e0
00184548: 1440002a bne r2,r0,0x 001845f4       branch if slope height 
0018454c: 00000000 nop
00184550: 90820003 lbu r2,0x0003(r4)           load height
00184554: 00000000 nop
00184558: 3042001f andi r2,r2,0x001f
0018455c: 28420003 slti r2,r2,0x0003
00184560: 10400024 beq r2,r0,0x 001845f4       branch if slope height/depth? < 0x03
00184564: 306300ff andi r3,r3,0x00ff
00184568: 34020012 ori r2,r0,0x0012
0018456c: 10620021 beq r3,r2,0x 001845f4        branch if terrain = lava
00184570: 3402001c ori r2,r0,0x001c
00184574: 1062001f beq r3,r2,0x 001845f4       branch if terrain = obstacle
00184578: 00000000 nop
0018457c: 3c048019 lui r4,0x8019
00184580: 8c842d98 lw r4,0x2d98(r4)            load target data
00184584: 0c05fc08 jal 0x0017f020              float/float/fly movements (returns in r2)
00184588: 00000000 nop
0018458c: 30420080 andi r2,r2,0x0080
00184590: 1040000a beq r2,r0,0x 001845bc       branch if fly not present?
00184594: 34020081 ori r2,r0,0x0081            store 0x81
00184598: 3c028019 lui r2,0x8019
0018459c: 8c422d98 lw r2,0x2d98(r2)
001845a0: 00000000 nop
001845a4: 9042005a lbu r2,0x005a(r2)
001845a8: 00000000 nop
001845ac: 30420006 andi r2,r2,0x0006
001845b0: 14400002 bne r2,r0,0x 001845bc        branch if frog/chicken
001845b4: 34020081 ori r2,r0,0x0081             store 0x81
001845b8: 34020082 ori r2,r0,0x0082             store 0x82
001845bc: 3c018019 lui r1,0x8019
001845c0: a02238ed sb r2,0x38ed(r1)             store 0x81
001845c4: 3c038019 lui r3,0x8019
001845c8: 8c632d90 lw r3,0x2d90(r3)
001845cc: 3c018019 lui r1,0x8019
001845d0: a03038ca sb r16,0x38ca(r1)            store new X
001845d4: 3c018019 lui r1,0x8019
001845d8: a03138cb sb r17,0x38cb(r1)            store new Y
001845dc: 3c018019 lui r1,0x8019
001845e0: a03238cc sb r18,0x38cc(r1)            store new map level
001845e4: 94620010 lhu r2,0x0010(r3)
001845e8: 00000000 nop
001845ec: 34424000 ori r2,r2,0x4000
001845f0: a4620010 sh r2,0x0010(r3)             enable knockback flag
001845f4: 8fbf001c lw r31,0x001c(r29)
001845f8: 8fb2 0018 lw r18,0x 0018(r29)
001845fc: 8fb10014 lw r17,0x0014(r29)
00184600: 8fb00010 lw r16,0x0010(r29)
00184604: 27bd0020 addiu r29,r29,0x0020
00184608: 03e00008 jr r31
0018460c: 00000000 nop


Return Locations

00186550: Critical Hit Calculation
001869d4: