AI Target Unit for Direct vs Arc Attack (0019cd9c)

From Final Fantasy Hacktics Wiki
Revision as of 01:16, 9 March 2017 by Dokurider (talk | contribs) (Updated documentation)
Jump to navigation Jump to search
0019cd9c: 3c02801a lui r2,0x801a
0019cda0: 90420d7b lbu r2,0x0d7b(r2)
0019cda4: 27bdffb8 addiu r29,r29,0xffb8
0019cda8: afb10034 sw r17,0x0034(r29)
0019cdac: 3c11801a lui r17,0x801a
0019cdb0: 2631f3c4 addiu r17,r17,0xf3c4
0019cdb4: afbf0044 sw r31,0x0044(r29)
0019cdb8: afb40040 sw r20,0x0040(r29)
0019cdbc: afb3003c sw r19,0x003c(r29)
0019cdc0: afb20038 sw r18,0x0038(r29)
0019cdc4: 10400015 beq r2,r0,0x0019ce1c
0019cdc8: afb00030 sw r16,0x0030(r29)
<If already set>
0019cdcc: 3c02801a lui r2,0x801a
0019cdd0: 90420036 lbu r2,0x0036(r2)
0019cdd4: 00000000 nop
0019cdd8: 10400010 beq r2,r0,0x0019ce1c				Branch if Unit Priorities haven't been set yet
0019cddc: 00000000 nop
0019cde0: 3c10801a lui r16,0x801a
0019cde4: 9610f3ec lhu r16,-0x0c14(r16)
0019cde8: 3c13801a lui r19,0x801a
0019cdec: 9673f3ee lhu r19,-0x0c12(r19)
0019cdf0: 3c12801a lui r18,0x801a
0019cdf4: 9652f3f0 lhu r18,-0x0c10(r18)
0019cdf8: 001310c0 sll r2,r19,0x03
0019cdfc: 00531021 addu r2,r2,r19
0019ce00: 00021080 sll r2,r2,0x02
0019ce04: 00511021 addu r2,r2,r17
0019ce08: 00121840 sll r3,r18,0x01
0019ce0c: 00431021 addu r2,r2,r3
0019ce10: 94540b4c lhu r20,0x0b4c(r2)
0019ce14: 0806744f j 0x0019d13c						Jump to <Check/Set Highest Priority>
0019ce18: 00000000 nop
0019ce1c: 0c0076ea jal 0x0001dba8					Get Frame RNG
0019ce20: 34040001 ori r4,r0,0x0001
0019ce24: 284201b9 slti r2,r2,0x01b9
0019ce28: 14400003 bne r2,r0,0x0019ce38				Branch because the RNG said so
0019ce2c: 2402ffff addiu r2,r0,0xffff
0019ce30: 0806747d j 0x0019d1f4							Exit and return -1
0019ce34: a2200c72 sb r0,0x0c72(r17)					No units are in range
0019ce38: 92220014 lbu r2,0x0014(r17)					Load AI Targeting Flags Set?
0019ce3c: 00000000 nop
0019ce40: 10400003 beq r2,r0,0x0019ce50					Branch if Targeting Flags aren't set yet
0019ce44: a22019b7 sb r0,0x19b7(r17)
0019ce48: 08067395 j 0x0019ce54
0019ce4c: 26300e30 addiu r16,r17,0x0e30
0019ce50: 26300018 addiu r16,r17,0x0018
0019ce54: 0c067c96 jal 0x0019f258						Store units coordinates
0019ce58: 02002021 addu r4,r16,r0
0019ce5c: 92220004 lbu r2,0x0004(r17)					Load Range
0019ce60: 00000000 nop
0019ce64: 1040000b beq r2,r0,0x0019ce94					Branch if no Range (set yet?)
0019ce68: 00002021 addu r4,r0,r0
0019ce6c: 0c05ea30 jal 0x0017a8c0						Calculate ability range based on action menu byte
0019ce70: 2624001c addiu r4,r17,0x001c
0019ce74: 34030003 ori r3,r0,0x0003
0019ce78: 14430023 bne r2,r3,0x0019cf08					Branch if any result besides no units in range (r2 = 3)
0019ce7c: 00009821 addu r19,r0,r0
0019ce80: 0806747d j 0x0019d1f4							Exit and return false because no units in range
0019ce84: 00001021 addu r2,r0,r0
0019ce88: a2220c72 sb r2,0x0c72(r17)					Save # of units in range
0019ce8c: 0806747d j 0x0019d1f4							Exit and return -1
0019ce90: 2402ffff addiu r2,r0,0xffff
<Remove Targeting from all tiles>
0019ce94: 3c038019 lui r3,0x8019
0019ce98: 2463f8d1 addiu r3,r3,0xf8d1				Load Target Tile (18f8cc + 5)
0019ce9c: 90620000 lbu r2,0x0000(r3)
0019cea0: 24840001 addiu r4,r4,0x0001
0019cea4: 304200bf andi r2,r2,0x00bf
0019cea8: a0620000 sb r2,0x0000(r3)					Remove Targeting from Tile
0019ceac: 28820200 slti r2,r4,0x0200
0019ceb0: 1440fffa bne r2,r0,0x0019ce9c				Do for all tiles
0019ceb4: 24630008 addiu r3,r3,0x0008
0019ceb8: 92030002 lbu r3,0x0002(r16)
0019cebc: 92220e3a lbu r2,0x0e3a(r17)
0019cec0: 00000000 nop
0019cec4: 00620018 mult r3,r2
0019cec8: 92020001 lbu r2,0x0001(r16)
0019cecc: 92040000 lbu r4,0x0000(r16)
0019ced0: 00021200 sll r2,r2,0x08
0019ced4: 00001812 mflo r3
0019ced8: 00641821 addu r3,r3,r4
0019cedc: 00621821 addu r3,r3,r2
0019cee0: 000318c0 sll r3,r3,0x03
0019cee4: 3c018019 lui r1,0x8019
0019cee8: 00230821 addu r1,r1,r3
0019ceec: 9022f8d1 lbu r2,-0x072f(r1)				Load Target Tile
0019cef0: 00000000 nop
0019cef4: 34420040 ori r2,r2,0x0040
0019cef8: 3c018019 lui r1,0x8019
0019cefc: 00230821 addu r1,r1,r3
0019cf00: a022f8d1 sb r2,-0x072f(r1)				Target This Tile
0019cf04: 00009821 addu r19,r0,r0
0019cf08: 02204021 addu r8,r17,r0
0019cf0c: 92220e3b lbu r2,0x0e3b(r17)
0019cf10: 00000000 nop
0019cf14: 1840002e blez r2,0x0019cfd0
0019cf18: 00009021 addu r18,r0,r0
0019cf1c: 00134a00 sll r9,r19,0x08
0019cf20: 25050b4c addiu r5,r8,0x0b4c
0019cf24: 25060bdc addiu r6,r8,0x0bdc
0019cf28: 94d40000 lhu r20,0x0000(r6)
0019cf2c: 00000000 nop
0019cf30: 3282ffff andi r2,r20,0xffff
0019cf34: 10400020 beq r2,r0,0x0019cfb8
0019cf38: a4a00000 sh r0,0x0000(r5)
0019cf3c: 92230e3a lbu r3,0x0e3a(r17)
0019cf40: 00000000 nop
0019cf44: 1060001c beq r3,r0,0x0019cfb8
0019cf48: 00008021 addu r16,r0,r0
0019cf4c: 00403821 addu r7,r2,r0
0019cf50: 00a02021 addu r4,r5,r0
0019cf54: 02071004 sllv r2,r7,r16
0019cf58: 30428000 andi r2,r2,0x8000
0019cf5c: 10400011 beq r2,r0,0x0019cfa4
0019cf60: 02430018 mult r18,r3
0019cf64: 00001012 mflo r2
0019cf68: 00501021 addu r2,r2,r16
0019cf6c: 00491021 addu r2,r2,r9
0019cf70: 000210c0 sll r2,r2,0x03
0019cf74: 3c018019 lui r1,0x8019
0019cf78: 00220821 addu r1,r1,r2
0019cf7c: 9022f8d1 lbu r2,-0x072f(r1)				Load Target Tile
0019cf80: 00000000 nop
0019cf84: 00021182 srl r2,r2,0x06					Target Data / 80
0019cf88: 30420001 andi r2,r2,0x0001
0019cf8c: 10400005 beq r2,r0,0x0019cfa4				Branch if not in AoE (Yellow Square)
0019cf90: 34028000 ori r2,r0,0x8000
0019cf94: 94830000 lhu r3,0x0000(r4)
0019cf98: 02021007 srav r2,r2,r16
0019cf9c: 00621825 or r3,r3,r2
0019cfa0: a4830000 sh r3,0x0000(r4)
0019cfa4: 92230e3a lbu r3,0x0e3a(r17)
0019cfa8: 26100001 addiu r16,r16,0x0001
0019cfac: 0203102a slt r2,r16,r3
0019cfb0: 1440ffe9 bne r2,r0,0x0019cf58
0019cfb4: 02071004 sllv r2,r7,r16
0019cfb8: 24a50002 addiu r5,r5,0x0002
0019cfbc: 92220e3b lbu r2,0x0e3b(r17)
0019cfc0: 26520001 addiu r18,r18,0x0001
0019cfc4: 0242102a slt r2,r18,r2
0019cfc8: 1440ffd7 bne r2,r0,0x0019cf28
0019cfcc: 24c60002 addiu r6,r6,0x0002
0019cfd0: 26730001 addiu r19,r19,0x0001
0019cfd4: 2a620002 slti r2,r19,0x0002
0019cfd8: 1440ffcc bne r2,r0,0x0019cf0c
0019cfdc: 25080024 addiu r8,r8,0x0024
0019cfe0: 00009821 addu r19,r0,r0
0019cfe4: 92220e3b lbu r2,0x0e3b(r17)
0019cfe8: 00000000 nop
0019cfec: 1840007d blez r2,0x0019d1e4
0019cff0: 00009021 addu r18,r0,r0
0019cff4: 001310c0 sll r2,r19,0x03
<Y Loop>
0019cff8: 00531021 addu r2,r2,r19
0019cffc: 00021080 sll r2,r2,0x02
0019d000: 00511021 addu r2,r2,r17
0019d004: 00121840 sll r3,r18,0x01
0019d008: 00431021 addu r2,r2,r3
0019d00c: 94540b4c lhu r20,0x0b4c(r2)
0019d010: 00000000 nop
0019d014: 1280006e beq r20,r0,0x0019d1d0
0019d018: 00000000 nop
0019d01c: 92220e3a lbu r2,0x0e3a(r17)
0019d020: 00000000 nop
0019d024: 1840006a blez r2,0x0019d1d0
0019d028: 00008021 addu r16,r0,r0
0019d02c: 02141004 sllv r2,r20,r16
<X Loop>
0019d030: 30428000 andi r2,r2,0x8000
0019d034: 10400061 beq r2,r0,0x0019d1bc
0019d038: 34020006 ori r2,r0,0x0006
0019d03c: 92230026 lbu r3,0x0026(r17)
0019d040: a6300028 sh r16,0x0028(r17)
0019d044: a632002c sh r18,0x002c(r17)
0019d048: 10620006 beq r3,r2,0x0019d064
0019d04c: a633002a sh r19,0x002a(r17)
<Arc/Direct>
0019d050: 8e23000c lw r3,0x000c(r17)				Load AI Usage
0019d054: 3c0200c0 lui r2,0x00c0
0019d058: 00621824 and r3,r3,r2
0019d05c: 10600008 beq r3,r0,0x0019d080				Branch if not Arc/Direct
0019d060: 00000000 nop
0019d064: 0c067486 jal 0x0019d218
0019d068: 00000000 nop
0019d06c: a2220027 sb r2,0x0027(r17)
0019d070: 304200ff andi r2,r2,0x00ff
0019d074: 34030015 ori r3,r0,0x0015
0019d078: 10430039 beq r2,r3,0x0019d160				Branch if no units found
0019d07c: 00000000 nop
<Arc>
0019d080: 8e23000c lw r3,0x000c(r17)
0019d084: 3c020080 lui r2,0x0080
0019d088: 00621024 and r2,r3,r2
0019d08c: 10400007 beq r2,r0,0x0019d0ac				<Item> if not Arc
0019d090: 3c020040 lui r2,0x0040
0019d094: 92240e2e lbu r4,0x0e2e(r17)
0019d098: 92250027 lbu r5,0x0027(r17)
0019d09c: 0c06bf64 jal 0x001afd90
0019d0a0: 00000000 nop
0019d0a4: 08067445 j 0x0019d114
0019d0a8: 00000000 nop
<Item>
0019d0ac: 00621024 and r2,r3,r2
0019d0b0: 1040001a beq r2,r0,0x0019d11c				Branch if not Direct
0019d0b4: 00000000 nop
0019d0b8: 92220000 lbu r2,0x0000(r17)
0019d0bc: 3c018006 lui r1,0x8006
0019d0c0: 00220821 addu r1,r1,r2
0019d0c4: 90235cb4 lbu r3,0x5cb4(r1)				Load Action Menu
0019d0c8: 34020001 ori r2,r0,0x0001
0019d0cc: 1462000d bne r3,r2,0x0019d104				Branch if not Item
0019d0d0: 00000000 nop
0019d0d4: 92220027 lbu r2,0x0027(r17)
0019d0d8: 8e2417f8 lw r4,0x17f8(r17)
0019d0dc: 000228c0 sll r5,r2,0x03
0019d0e0: 00a22823 subu r5,r5,r2
0019d0e4: 00052980 sll r5,r5,0x06
0019d0e8: 3c028019 lui r2,0x8019
0019d0ec: 244208cc addiu r2,r2,0x08cc
0019d0f0: 0c0664db jal 0x0019936c					Calculate Distance Between Units
0019d0f4: 00a22821 addu r5,r5,r2
0019d0f8: 28420002 slti r2,r2,0x0002
0019d0fc: 14400007 bne r2,r0,0x0019d11c
0019d100: 00000000 nop
0019d104: 92240e2e lbu r4,0x0e2e(r17)
0019d108: 92250027 lbu r5,0x0027(r17)
0019d10c: 0c06c1b4 jal 0x001b06d0					Determine if no obstacles are in the way
0019d110: 00000000 nop
0019d114: 10400029 beq r2,r0,0x0019d1bc				<X++> if something's in the way
0019d118: 00000000 nop
0019d11c: 8e230cb4 lw r3,0x0cb4(r17)				Load AI Usage Copy?
0019d120: 3c020200 lui r2,0x0200
0019d124: 00621824 and r3,r3,r2
0019d128: 10600003 beq r3,r0,0x0019d138				Set False if not Physical Follow Target
0019d12c: 34020001 ori r2,r0,0x0001
0019d130: 0806744f j 0x0019d13c						
0019d134: a2220e4e sb r2,0x0e4e(r17)				Set True
0019d138: a2200e4e sb r0,0x0e4e(r17)				Set False
<Check/Set Highest Unit Priority>
0019d13c: 0c0674c2 jal 0x0019d308					Check against and Set Highest Unit Priority
0019d140: 00000000 nop
0019d144: 2403ffff addiu r3,r0,0xffff
0019d148: 1043ff4f beq r2,r3,0x0019ce88				Branch back if not the highest Unit Priority/RNG said no
0019d14c: 34020001 ori r2,r0,0x0001
0019d150: 922219bc lbu r2,0x19bc(r17)
0019d154: 00000000 nop
0019d158: 10400026 beq r2,r0,0x0019d1f4				Exit and return false if false
0019d15c: 00001021 addu r2,r0,r0
0019d160: 92220e4e lbu r2,0x0e4e(r17)
0019d164: 00000000 nop
0019d168: 10400014 beq r2,r0,0x0019d1bc				<X++> if false
0019d16c: 001310c0 sll r2,r19,0x03
0019d170: 00531021 addu r2,r2,r19
0019d174: 00021080 sll r2,r2,0x02
0019d178: 00511021 addu r2,r2,r17
0019d17c: 24420bdc addiu r2,r2,0x0bdc
0019d180: 00122040 sll r4,r18,0x01
0019d184: 00822021 addu r4,r4,r2
0019d188: 34028000 ori r2,r0,0x8000
0019d18c: 94830000 lhu r3,0x0000(r4)
0019d190: 02021007 srav r2,r2,r16
0019d194: 00621826 xor r3,r3,r2
0019d198: a4830000 sh r3,0x0000(r4)
0019d19c: 92220cbb lbu r2,0x0cbb(r17)
0019d1a0: 00000000 nop
0019d1a4: 2442ffff addiu r2,r2,0xffff
0019d1a8: a2220cbb sb r2,0x0cbb(r17)
0019d1ac: 92220cbb lbu r2,0x0cbb(r17)
0019d1b0: 00000000 nop
0019d1b4: 10400006 beq r2,r0,0x0019d1d0				<Y++> if false
0019d1b8: 00000000 nop
<X++>
0019d1bc: 92220e3a lbu r2,0x0e3a(r17)
0019d1c0: 26100001 addiu r16,r16,0x0001
0019d1c4: 0202102a slt r2,r16,r2
0019d1c8: 1440ff99 bne r2,r0,0x0019d030
0019d1cc: 02141004 sllv r2,r20,r16
<Y++>
0019d1d0: 92220e3b lbu r2,0x0e3b(r17)
0019d1d4: 26520001 addiu r18,r18,0x0001
0019d1d8: 0242102a slt r2,r18,r2
0019d1dc: 1440ff86 bne r2,r0,0x0019cff8
0019d1e0: 001310c0 sll r2,r19,0x03
<Map Level++>
0019d1e4: 26730001 addiu r19,r19,0x0001
0019d1e8: 2a620002 slti r2,r19,0x0002
0019d1ec: 1440ff7d bne r2,r0,0x0019cfe4
0019d1f0: 00001021 addu r2,r0,r0					Return False
0019d1f4: 8fbf0044 lw r31,0x0044(r29)
0019d1f8: 8fb40040 lw r20,0x0040(r29)
0019d1fc: 8fb3003c lw r19,0x003c(r29)
0019d200: 8fb20038 lw r18,0x0038(r29)
0019d204: 8fb10034 lw r17,0x0034(r29)
0019d208: 8fb00030 lw r16,0x0030(r29)
0019d20c: 27bd0048 addiu r29,r29,0x0048
0019d210: 03e00008 jr r31
0019d214: 00000000 nop