AI Targeting Matrix Analysis (0019b7b8)

From Final Fantasy Hacktics Wiki
(Redirected from 0019b7b8 - 0019bb1c)
Jump to navigation Jump to search
0019b7b8: 3c02801a lui r2,0x801a
0019b7bc: 90420d7b lbu r2,0x0d7b(r2)				If Unit Acted this Turn
0019b7c0: 27bdffe0 addiu r29,r29,0xffe0
0019b7c4: afb10014 sw r17,0x0014(r29)
0019b7c8: 3c11801a lui r17,0x801a
0019b7cc: 2631f3c4 addiu r17,r17,0xf3c4				r17 = Unit AI Pointer
0019b7d0: afbf001c sw r31,0x001c(r29)
0019b7d4: afb20018 sw r18,0x0018(r29)
0019b7d8: 1440009e bne r2,r0,0x0019ba54				Branch if acted already?
0019b7dc: afb00010 sw r16,0x0010(r29)
0019b7e0: 3c04fdff lui r4,0xfdff
0019b7e4: 3484ffff ori r4,r4,0xffff					r4 = -02000000
0019b7e8: 3c03801a lui r3,0x801a
0019b7ec: 8c630078 lw r3,0x0078(r3)					r3 = Load ? (Tracking?)
0019b7f0: 34020001 ori r2,r0,0x0001					r2 = True
0019b7f4: 3c01801a lui r1,0x801a
0019b7f8: a022f3d9 sb r2,-0x0c27(r1)				? = True
0019b7fc: 3c01801a lui r1,0x801a
0019b800: a020020d sb r0,0x020d(r1)					Clear ?
0019b804: 00641824 and r3,r3,r4						Modify ?				
0019b808: 3c01801a lui r1,0x801a
0019b80c: ac230078 sw r3,0x0078(r1)					Save Tracking?
<Y Loop>
0019b810: 92250e49 lbu r5,0x0e49(r17)				r5 = Unit ID
0019b814: 3c048019 lui r4,0x8019
0019b818: 248408cc addiu r4,r4,0x08cc				r4 = Unit Data
0019b81c: 000518c0 sll r3,r5,0x03					Unit ID * 8
0019b820: 00651823 subu r3,r3,r5					Unit ID * 7
0019b824: 00031980 sll r3,r3,0x06					Unit ID * 0x1c0
0019b828: 00051100 sll r2,r5,0x04					Unit ID * 0x10
0019b82c: 2442182c addiu r2,r2,0x182c				Unit ID + 182c
0019b830: 02228021 addu r16,r17,r2					r16 = Unit AI Decision Data
0019b834: 92020007 lbu r2,0x0007(r16)				Get Unit AI Vulnerablity status flags	
0019b838: 00000000 nop
0019b83c: 30420010 andi r2,r2,0x0010
0019b840: 144000a2 bne r2,r0,0x0019bacc				Branch if Target is untargetable
0019b844: 00649021 addu r18,r3,r4					r18 = Unit Data Pointer
0019b848: 92220e2e lbu r2,0x0e2e(r17)				Get Caster ID
0019b84c: 00000000 nop
0019b850: 10a2009e beq r5,r2,0x0019bacc				Branch if Caster = Target
0019b854: 02402821 addu r5,r18,r0					r5 = Unit Data Pointer
0019b858: 92240001 lbu r4,0x0001(r17)				r4 = CT
0019b85c: 0c067bc9 jal 0x0019ef24					Check if Status Should/Can be Added
0019b860: 34060026 ori r6,r0,0x0026					Check for Reflect
0019b864: 10400099 beq r2,r0,0x0019bacc				Y++ if unit doesn't have Reflect
0019b868: 00000000 nop
0019b86c: 92240e49 lbu r4,0x0e49(r17)				Load Inflictable Statuses
0019b870: 0c067c36 jal 0x0019f0d8					Check if statuses can be inflicted in time
0019b874: 00000000 nop
0019b878: 14400094 bne r2,r0,0x0019bacc				Branch if none can be inflicted in time
0019b87c: 00000000 nop
0019b880: 92020007 lbu r2,0x0007(r16)				Get Unit AI Vulnerablity status flags
0019b884: 00000000 nop
0019b888: 30420020 andi r2,r2,0x0020
0019b88c: 10400007 beq r2,r0,0x0019b8ac				Branch if Unit is Dead without Reraise
0019b890: 26250c74 addiu r5,r17,0x0c74				r5 = Point to Coordinates
0019b894: 92300001 lbu r16,0x0001(r17)				r16 = CT
0019b898: 0c066722 jal 0x00199c88					Check if Spell CT can land before target's turn?
0019b89c: 02402021 addu r4,r18,r0					r4 = Unit Data Pointer
0019b8a0: 0050102a slt r2,r2,r16
0019b8a4: 14400089 bne r2,r0,0x0019bacc				Branch if Spell CT is too high
0019b8a8: 26250c74 addiu r5,r17,0x0c74				r5 = Point to Coordinates
0019b8ac: 92240e49 lbu r4,0x0e49(r17)				Load Inflictable Statuses
0019b8b0: 34020005 ori r2,r0,0x0005					r2 = 0x0005
0019b8b4: 0c067ca9 jal 0x0019f2a4					Transfer Unit Coordinates to AI
0019b8b8: a2220026 sb r2,0x0026(r17)				This is either Inflicted Statuses or Animations
0019b8bc: 92230026 lbu r3,0x0026(r17)				Load ?
0019b8c0: 34020006 ori r2,r0,0x0006
0019b8c4: 14620002 bne r3,r2,0x0019b8d0				Branch if 5 =/= 6?
0019b8c8: 34040001 ori r4,r0,0x0001
0019b8cc: 34040003 ori r4,r0,0x0003
0019b8d0: 0c06723b jal 0x0019c8ec		
0019b8d4: 00002821 addu r5,r0,r0
0019b8d8: 26240bdc addiu r4,r17,0x0bdc
0019b8dc: 26250b4c addiu r5,r17,0x0b4c
0019b8e0: 0c066ac2 jal 0x0019ab08						Transfer Halfword Values
0019b8e4: 34060048 ori r6,r0,0x0048
0019b8e8: a2200e4a sb r0,0x0e4a(r17)				Initialize Current Unit ID
<X Loop>
0019b8ec: 92240e4a lbu r4,0x0e4a(r17)				Load Current Unit ID
0019b8f0: 00000000 nop
0019b8f4: 02241021 addu r2,r17,r4					Current Unit AI Pointer
0019b8f8: 90420c8d lbu r2,0x0c8d(r2)				Load Targetable Unit List
0019b8fc: 00000000 nop
0019b900: 10400069 beq r2,r0,0x0019baa8				Next Unit if Current Unit is not targeting any unit? (This unit is fleeing?)
0019b904: 00000000 nop								
0019b908: 92220e49 lbu r2,0x0e49(r17)				Load ? Unit ID
0019b90c: 00000000 nop
0019b910: 10820065 beq r4,r2,0x0019baa8				Next Unit if Unit ID is targeting itself? (This unit is too injured?)
0019b914: 00000000 nop
0019b918: 92220e2e lbu r2,0x0e2e(r17)				Load Caster Unit ID
0019b91c: 00000000 nop
0019b920: 10820061 beq r4,r2,0x0019baa8				Skip Caster Unit (This unit is myself)
0019b924: 00000000 nop
0019b928: 0c067c36 jal 0x0019f0d8					Check if spell can be used in time
0019b92c: 00000000 nop
0019b930: 1440005d bne r2,r0,0x0019baa8				Next Unit if it cannot be used in time
0019b934: 00000000 nop
0019b938: 92240e4a lbu r4,0x0e4a(r17)				Reload Current Unit ID		
0019b93c: 0c067976 jal 0x0019e5d8					AI Ability Use
0019b940: 00002821 addu r5,r0,r0					Bypass Don't Use on Reflect Check
0019b944: 34030001 ori r3,r0,0x0001
0019b948: 14430057 bne r2,r3,0x0019baa8				Next Unit if Current Ability is not offensive
0019b94c: 00000000 nop
0019b950: 92230e4a lbu r3,0x0e4a(r17)				Reload Current Unit ID
0019b954: 92250e3a lbu r5,0x0e3a(r17)				Load Max Map X
0019b958: 000310c0 sll r2,r3,0x03					ID * 8
0019b95c: 00431023 subu r2,r2,r3					ID * 7
0019b960: 00021180 sll r2,r2,0x06					ID * 0x1c0
0019b964: 92430047 lbu r3,0x0047(r18)				Load Caster X
0019b968: 3c018019 lui r1,0x8019
0019b96c: 00220821 addu r1,r1,r2
0019b970: 90220913 lbu r2,0x0913(r1)				Load Current Unit X (1908cc + 47)
0019b974: 00031840 sll r3,r3,0x01					Caster X * 2
0019b978: 00621823 subu r3,r3,r2					Caster (X * 2) - Current X
0019b97c: a2230018 sb r3,0x0018(r17)				Save X distance
0019b980: 92440048 lbu r4,0x0048(r18)				Load Caster Y
0019b984: 92230e4a lbu r3,0x0e4a(r17)				Reload Current Unit ID
0019b988: 00042040 sll r4,r4,0x01					Caster Y * 2
0019b98c: 000310c0 sll r2,r3,0x03					ID * 8
0019b990: 00431023 subu r2,r2,r3					ID * 7
0019b994: 00021180 sll r2,r2,0x06					ID * 1c0
0019b998: 3c018019 lui r1,0x8019
0019b99c: 00220821 addu r1,r1,r2
0019b9a0: 90230914 lbu r3,0x0914(r1)				Load Current Y
0019b9a4: 92220018 lbu r2,0x0018(r17)				Load X Distance
0019b9a8: 00832023 subu r4,r4,r3					Caster (Y * 2) - Current Y
0019b9ac: 0045102b sltu r2,r2,r5					
0019b9b0: 1040003d beq r2,r0,0x0019baa8				Next Unit if X Distance is greater than Max X
0019b9b4: a224001a sb r4,0x001a(r17)				Save Y Distance
0019b9b8: 9222001a lbu r2,0x001a(r17)				Load Y Distance
0019b9bc: 92230e3b lbu r3,0x0e3b(r17)				Load Max Y
0019b9c0: 00000000 nop
0019b9c4: 0043102b sltu r2,r2,r3					
0019b9c8: 10400037 beq r2,r0,0x0019baa8				Next Unit if Y Distance is greater than Max Y
0019b9cc: 00000000 nop
0019b9d0: a2200e4b sb r0,0x0e4b(r17)				Initialize Map Level
<Map Level Loop>
0019b9d4: 92230e2d lbu r3,0x0e2d(r17)				Load ? ID
0019b9d8: 92220e4b lbu r2,0x0e4b(r17)				Load Map Level
0019b9dc: 000320c0 sll r4,r3,0x03					ID * 8
0019b9e0: 00832021 addu r4,r4,r3					ID * 9
0019b9e4: 000420c0 sll r4,r4,0x03					ID * 48
0019b9e8: 00912021 addu r4,r4,r17					? Unit AI Pointer
0019b9ec: 92230e4b lbu r3,0x0e4b(r17)				Load Secondary Target ID?
0019b9f0: 24840a74 addiu r4,r4,0x0a74				Point to Coordinates of Interest
0019b9f4: a2220019 sb r2,0x0019(r17)				Save Map Level
0019b9f8: 000310c0 sll r2,r3,0x03					ID * 8
0019b9fc: 00431021 addu r2,r2,r3					ID * 9
0019ba00: 00021080 sll r2,r2,0x02					ID * 24
0019ba04: 9223001a lbu r3,0x001a(r17)				Load Caster Y
0019ba08: 00441021 addu r2,r2,r4					Get Current Unit's Coordinates of Interest
0019ba0c: 00031840 sll r3,r3,0x01					Caster Y * 2
0019ba10: 00621821 addu r3,r3,r2					Pointer to Caster's Row on that map
0019ba14: 94620000 lhu r2,0x0000(r3)				Load Unit Row Coordinate Value
0019ba18: 92230018 lbu r3,0x0018(r17)				Load Caster X
0019ba1c: 00000000 nop
0019ba20: 00621004 sllv r2,r2,r3					Row Value * X
0019ba24: 30428000 andi r2,r2,0x8000
0019ba28: 10400016 beq r2,r0,0x0019ba84				Branch if not in Current Unit's Coordinates of Interest (You eyeballing me, son?)
0019ba2c: 00000000 nop								
0019ba30: 0c066ec8 jal 0x0019bb20					Units are where they are supposed to be/Unit Exists check
0019ba34: 00000000 nop
0019ba38: 34020001 ori r2,r0,0x0001
0019ba3c: a2220014 sb r2,0x0014(r17)				Targeting a Unit = True?
0019ba40: a2200ed8 sb r0,0x0ed8(r17)				Clear ?
<Mini Loop>
0019ba44: 0c066d3d jal 0x0019b4f4					Water Depth/Monster Skill/Elemental Check
0019ba48: 26240e30 addiu r4,r17,0x0e30				Point Unit AI to ?
0019ba4c: 10400006 beq r2,r0,0x0019ba68				Skip next routine if Routine was false
0019ba50: 00000000 nop
0019ba54: 0c067367 jal 0x0019cd9c
0019ba58: 00000000 nop
0019ba5c: 2403ffff addiu r3,r0,0xffff
0019ba60: 10430028 beq r2,r3,0x0019bb04				Break out of entire routine; exit and return -1 if routine failed
0019ba64: 2402ffff addiu r2,r0,0xffff
0019ba68: 92220ed8 lbu r2,0x0ed8(r17)				Load Mini Loop Counter
0019ba6c: 00000000 nop
0019ba70: 14400004 bne r2,r0,0x0019ba84				Branch if True
0019ba74: 34020001 ori r2,r0,0x0001
0019ba78: a2220ed8 sb r2,0x0ed8(r17)				Mini Loop Counter = True
0019ba7c: 08066e91 j 0x0019ba44						Loop back to...?
0019ba80: a2200014 sb r0,0x0014(r17)				Clear ?
</Mini Loop>
0019ba84: 92220e4b lbu r2,0x0e4b(r17)				Load Map Level Counter
0019ba88: 00000000 nop
0019ba8c: 24420001 addiu r2,r2,0x0001				Map Level Counter++
0019ba90: a2220e4b sb r2,0x0e4b(r17)				Save Counter
0019ba94: 92220e4b lbu r2,0x0e4b(r17)				Reload Map Level Counter
0019ba98: 00000000 nop
0019ba9c: 2c420002 sltiu r2,r2,0x0002
0019baa0: 1440ffcc bne r2,r0,0x0019b9d4				Once for Low Tiles, and once for High tiles
0019baa4: 00000000 nop
</Map Level Loop>
0019baa8: 92220e4a lbu r2,0x0e4a(r17)			Load X Counter
0019baac: 00000000 nop
0019bab0: 24420001 addiu r2,r2,0x0001			X Counter++
0019bab4: a2220e4a sb r2,0x0e4a(r17)			Save Counter
0019bab8: 92220e4a lbu r2,0x0e4a(r17)			Reload X Counter
0019babc: 00000000 nop
0019bac0: 2c420015 sltiu r2,r2,0x0015
0019bac4: 1440ff89 bne r2,r0,0x0019b8ec			Loop for each unit
0019bac8: 00000000 nop
</X Loop>
0019bacc: 92220e49 lbu r2,0x0e49(r17)			Load Y Row Counter
0019bad0: 00000000 nop
0019bad4: 24420001 addiu r2,r2,0x0001			Y Row Counter++
0019bad8: a2220e49 sb r2,0x0e49(r17)			Save Counter
0019badc: 92220e49 lbu r2,0x0e49(r17)			Reload Y Row Counter
0019bae0: 00000000 nop
0019bae4: 2c420015 sltiu r2,r2,0x0015			
0019bae8: 1440ff49 bne r2,r0,0x0019b810			Loop for each unit
0019baec: 00000000 nop
</Y Loop>
0019baf0: 0c067c96 jal 0x0019f258
0019baf4: 26240e30 addiu r4,r17,0x0e30
0019baf8: 0c065bf1 jal 0x00196fc4
0019bafc: a2200015 sb r0,0x0015(r17)
0019bb00: 00001021 addu r2,r0,r0
0019bb04: 8fbf001c lw r31,0x001c(r29)
0019bb08: 8fb20018 lw r18,0x0018(r29)
0019bb0c: 8fb10014 lw r17,0x0014(r29)
0019bb10: 8fb00010 lw r16,0x0010(r29)
0019bb14: 27bd0020 addiu r29,r29,0x0020
0019bb18: 03e00008 jr r31
0019bb1c: 00000000 nop