Difference between revisions of "Set AI flags for target consideration"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Uploading Routine - Didn't document yet)
 
(Added Documentation)
Line 6: Line 6:
 
  00194728: afb00010 sw r16,0x0010(r29)
 
  00194728: afb00010 sw r16,0x0010(r29)
 
  0019472c: 3c10801a lui r16,0x801a
 
  0019472c: 3c10801a lui r16,0x801a
  00194730: 8e1001f8 lw r16,0x01f8(r16)
+
  00194730: 8e1001f8 lw r16,0x01f8(r16) Load Acting Unit's AI Decision Pointer
 
  00194734: afb10014 sw r17,0x0014(r29)
 
  00194734: afb10014 sw r17,0x0014(r29)
 
  00194738: 3c11801a lui r17,0x801a
 
  00194738: 3c11801a lui r17,0x801a
  0019473c: 2631f3c4 addiu r17,r17,0xf3c4
+
  0019473c: 2631f3c4 addiu r17,r17,0xf3c4 Load AI Data Pointer
  00194740: 1440000e bne r2,r0,0x0019477c
+
  00194740: 1440000e bne r2,r0,0x0019477c
 
  00194744: afbf0018 sw r31,0x0018(r29)
 
  00194744: afbf0018 sw r31,0x0018(r29)
 
  00194748: 3c03801a lui r3,0x801a
 
  00194748: 3c03801a lui r3,0x801a
  0019474c: 8c630bbc lw r3,0x0bbc(r3)
+
  0019474c: 8c630bbc lw r3,0x0bbc(r3) Load Acting Unit Data Pointer
 
  00194750: 00000000 nop
 
  00194750: 00000000 nop
  00194754: 90620005 lbu r2,0x0005(r3)
+
  00194754: 90620005 lbu r2,0x0005(r3) Load ENTD Flags
 
  00194758: 00000000 nop
 
  00194758: 00000000 nop
 
  0019475c: 30420008 andi r2,r2,0x0008
 
  0019475c: 30420008 andi r2,r2,0x0008
  00194760: 10400006 beq r2,r0,0x0019477c
+
  00194760: 10400006 beq r2,r0,0x0019477c Branch if unit is under Player Control
 
  00194764: 00000000 nop
 
  00194764: 00000000 nop
  00194768: 906201b8 lbu r2,0x01b8(r3)
+
  00194768: 906201b8 lbu r2,0x01b8(r3) Load Auto Battle Flag (From Current Action Data)
 
  0019476c: 3c01801a lui r1,0x801a
 
  0019476c: 3c01801a lui r1,0x801a
  00194770: a0220d7a sb r2,0x0d7a(r1)
+
  00194770: a0220d7a sb r2,0x0d7a(r1) Save to
  00194774: 0806523d j 0x001948f4
+
  00194774: 0806523d j 0x001948f4 Jump to Exit
 
  00194778: 00000000 nop
 
  00194778: 00000000 nop
  0019477c: 92220e2e lbu r2,0x0e2e(r17)
+
  0019477c: 92220e2e lbu r2,0x0e2e(r17) Load ? Pointer
 
  00194780: 00000000 nop
 
  00194780: 00000000 nop
  00194784: 02221021 addu r2,r17,r2
+
  00194784: 02221021 addu r2,r17,r2 Add Pointer to AI Data Pointer
  00194788: 904219a1 lbu r2,0x19a1(r2)
+
  00194788: 904219a1 lbu r2,0x19a1(r2) Load AutoBattle Flags
 
  0019478c: 00000000 nop
 
  0019478c: 00000000 nop
  00194790: a22219b6 sb r2,0x19b6(r17)
+
  00194790: a22219b6 sb r2,0x19b6(r17) Save Current Unit AutoBattle Flags
  00194794: 92030004 lbu r3,0x0004(r16)
+
  00194794: 92030004 lbu r3,0x0004(r16) Load AutoBattle Flag (From AI Decision Flags)
 
  00194798: 00000000 nop
 
  00194798: 00000000 nop
 
  0019479c: 30620008 andi r2,r3,0x0008
 
  0019479c: 30620008 andi r2,r3,0x0008
  001947a0: 10400023 beq r2,r0,0x00194830
+
  001947a0: 10400023 beq r2,r0,0x00194830 Branch if Cowardly not set
 
  001947a4: 00000000 nop
 
  001947a4: 00000000 nop
  001947a8: 8e2217f8 lw r2,0x17f8(r17)
+
  001947a8: 8e2217f8 lw r2,0x17f8(r17) Load Acting Unit's Data Pointer
 
  001947ac: 00000000 nop
 
  001947ac: 00000000 nop
  001947b0: 90420059 lbu r2,0x0059(r2)
+
  001947b0: 90420059 lbu r2,0x0059(r2) Load Current Status 2
 
  001947b4: 00000000 nop
 
  001947b4: 00000000 nop
  001947b8: 30420040 andi r2,r2,0x0040
+
  001947b8: 30420040 andi r2,r2,0x0040
  001947bc: 14400018 bne r2,r0,0x00194820
+
  001947bc: 14400018 bne r2,r0,0x00194820 Branch unless Unit has Invite
 
  001947c0: 00000000 nop
 
  001947c0: 00000000 nop
  001947c4: 92020007 lbu r2,0x0007(r16)
+
  001947c4: 92020007 lbu r2,0x0007(r16) Load AI Targeting Flags 2
 
  001947c8: 00000000 nop
 
  001947c8: 00000000 nop
 
  001947cc: 30420004 andi r2,r2,0x0004
 
  001947cc: 30420004 andi r2,r2,0x0004
  001947d0: 14400048 bne r2,r0,0x001948f4
+
  001947d0: 14400048 bne r2,r0,0x001948f4 Branch unless Save CT/Protect Self
 
  001947d4: 00000000 nop
 
  001947d4: 00000000 nop
  001947d8: 922219b6 lbu r2,0x19b6(r17)
+
  001947d8: 922219b6 lbu r2,0x19b6(r17) Load AutoBattle Flags
 
  001947dc: 00000000 nop
 
  001947dc: 00000000 nop
  001947e0: 14400044 bne r2,r0,0x001948f4
+
  001947e0: 14400044 bne r2,r0,0x001948f4 Branch unless AutoBattle Flags are set
 
  001947e4: 30620040 andi r2,r3,0x0040
 
  001947e4: 30620040 andi r2,r3,0x0040
  001947e8: 10400009 beq r2,r0,0x00194810
+
  001947e8: 10400009 beq r2,r0,0x00194810 Branch if Focus on Target not set
 
  001947ec: 00000000 nop
 
  001947ec: 00000000 nop
  001947f0: 92040005 lbu r4,0x0005(r16)
+
  001947f0: 92040005 lbu r4,0x0005(r16) Load Load Main Target ID
 
  001947f4: 0c067ca9 jal 0x0019f2a4
 
  001947f4: 0c067ca9 jal 0x0019f2a4
  001947f8: 02002821 addu r5,r16,r0
+
  001947f8: 02002821 addu r5,r16,r0 r4 = Acting Unit's AI Decision Pointer
  001947fc: 92040005 lbu r4,0x0005(r16)
+
  001947fc: 92040005 lbu r4,0x0005(r16) Load Main Target ID
 
  00194800: 0c065b23 jal 0x00196c8c
 
  00194800: 0c065b23 jal 0x00196c8c
 
  00194804: 00000000 nop
 
  00194804: 00000000 nop
 
  00194808: 08065205 j 0x00194814
 
  00194808: 08065205 j 0x00194814
 
  0019480c: 00000000 nop
 
  0019480c: 00000000 nop
  00194810: 922219bb lbu r2,0x19bb(r17)
+
  00194810: 922219bb lbu r2,0x19bb(r17) Load Unit Targetable Flag
 
  00194814: 00000000 nop
 
  00194814: 00000000 nop
  00194818: 10400036 beq r2,r0,0x001948f4
+
  00194818: 10400036 beq r2,r0,0x001948f4 Branch if Unit is Untargetable
 
  0019481c: 00000000 nop
 
  0019481c: 00000000 nop
  00194820: 92020004 lbu r2,0x0004(r16)
+
  00194820: 92020004 lbu r2,0x0004(r16) Load AutoBattle Flag (From AI Decision Flags)
 
  00194824: 00000000 nop
 
  00194824: 00000000 nop
 
  00194828: 304200f7 andi r2,r2,0x00f7
 
  00194828: 304200f7 andi r2,r2,0x00f7
  0019482c: a2020004 sb r2,0x0004(r16)
+
  0019482c: a2020004 sb r2,0x0004(r16) Remove Cowardly Flag
  00194830: 92220e39 lbu r2,0x0e39(r17)
+
  00194830: 92220e39 lbu r2,0x0e39(r17) Load Acting Unit's Team
 
  00194834: 00000000 nop
 
  00194834: 00000000 nop
  00194838: 14400015 bne r2,r0,0x00194890
+
  00194838: 14400015 bne r2,r0,0x00194890 Branch unless Team is set
 
  0019483c: 00000000 nop
 
  0019483c: 00000000 nop
  00194840: 8e2317f8 lw r3,0x17f8(r17)
+
  00194840: 8e2317f8 lw r3,0x17f8(r17) Load Acting Unit's Data Pointer
  00194844: a22019b6 sb r0,0x19b6(r17)
+
  00194844: a22019b6 sb r0,0x19b6(r17) Empty AI/Autobattle setting
  00194848: 94620028 lhu r2,0x0028(r3)
+
  00194848: 94620028 lhu r2,0x0028(r3) Load CurHP
  0019484c: 9463002a lhu r3,0x002a(r3)
+
  0019484c: 9463002a lhu r3,0x002a(r3) Load MaxHP
  00194850: 000211c0 sll r2,r2,0x07
+
  00194850: 000211c0 sll r2,r2,0x07 CurHP * 80
  00194854: 0043001a div r2,r3
+
  00194854: 0043001a div r2,r3 (CurHP * 80) / MaxHP
  00194858: 00001012 mflo r2
+
  00194858: 00001012 mflo r2 Get CurHP%
 
  0019485c: 00000000 nop
 
  0019485c: 00000000 nop
 
  00194860: 2842002d slti r2,r2,0x002d
 
  00194860: 2842002d slti r2,r2,0x002d
  00194864: 1440001c bne r2,r0,0x001948d8
+
  00194864: 1440001c bne r2,r0,0x001948d8 Branch if CurHP < 35.5%
 
  00194868: 34040005 ori r4,r0,0x0005
 
  00194868: 34040005 ori r4,r0,0x0005
 
  0019486c: 34040001 ori r4,r0,0x0001
 
  0019486c: 34040001 ori r4,r0,0x0001
 
  00194870: 34020014 ori r2,r0,0x0014
 
  00194870: 34020014 ori r2,r0,0x0014
 
  00194874: 26230014 addiu r3,r17,0x0014
 
  00194874: 26230014 addiu r3,r17,0x0014
  00194878: a0640c8d sb r4,0x0c8d(r3)
+
  00194878: a0640c8d sb r4,0x0c8d(r3) Set unit as targetable in Targetable Unit List
 
  0019487c: 2442ffff addiu r2,r2,0xffff
 
  0019487c: 2442ffff addiu r2,r2,0xffff
  00194880: 0441fffd bgez r2,0x00194878
+
  00194880: 0441fffd bgez r2,0x00194878 Set all units as targetable
 
  00194884: 2463ffff addiu r3,r3,0xffff
 
  00194884: 2463ffff addiu r3,r3,0xffff
  00194888: 08065236 j 0x001948d8
+
  00194888: 08065236 j 0x001948d8 Jump to
 
  0019488c: 34040004 ori r4,r0,0x0004
 
  0019488c: 34040004 ori r4,r0,0x0004
  00194890: 92020006 lbu r2,0x0006(r16)
+
  00194890: 92020006 lbu r2,0x0006(r16) Load AI Targeting Flags 1
 
  00194894: 00000000 nop
 
  00194894: 00000000 nop
 
  00194898: 30420004 andi r2,r2,0x0004
 
  00194898: 30420004 andi r2,r2,0x0004
  0019489c: 10400006 beq r2,r0,0x001948b8
+
  0019489c: 10400006 beq r2,r0,0x001948b8 Branch if Unit doesn't have largest # of usable abilities
 
  001948a0: 34040001 ori r4,r0,0x0001
 
  001948a0: 34040001 ori r4,r0,0x0001
  001948a4: 92020007 lbu r2,0x0007(r16)
+
  001948a4: 92020007 lbu r2,0x0007(r16) Load AI Targeting Flags 2
 
  001948a8: 00000000 nop
 
  001948a8: 00000000 nop
 
  001948ac: 30420008 andi r2,r2,0x0008
 
  001948ac: 30420008 andi r2,r2,0x0008
  001948b0: 1040000f beq r2,r0,0x001948f0
+
  001948b0: 1040000f beq r2,r0,0x001948f0 Branch if target is not Allied
 
  001948b4: 34020010 ori r2,r0,0x0010
 
  001948b4: 34020010 ori r2,r0,0x0010
  001948b8: a22019b6 sb r0,0x19b6(r17)
+
  001948b8: a22019b6 sb r0,0x19b6(r17) Empty AI/Autobattle setting
 
  001948bc: 34020014 ori r2,r0,0x0014
 
  001948bc: 34020014 ori r2,r0,0x0014
 
  001948c0: 26230014 addiu r3,r17,0x0014
 
  001948c0: 26230014 addiu r3,r17,0x0014
  001948c4: a0640c8d sb r4,0x0c8d(r3)
+
  001948c4: a0640c8d sb r4,0x0c8d(r3) Set unit as targetable in Targetable Unit List
 
  001948c8: 2442ffff addiu r2,r2,0xffff
 
  001948c8: 2442ffff addiu r2,r2,0xffff
  001948cc: 0441fffd bgez r2,0x001948c4
+
  001948cc: 0441fffd bgez r2,0x001948c4 Set all units as targetable
 
  001948d0: 2463ffff addiu r3,r3,0xffff
 
  001948d0: 2463ffff addiu r3,r3,0xffff
 
  001948d4: 34040004 ori r4,r0,0x0004
 
  001948d4: 34040004 ori r4,r0,0x0004
Line 118: Line 118:
 
  001948e8: 0806523d j 0x001948f4
 
  001948e8: 0806523d j 0x001948f4
 
  001948ec: 00000000 nop
 
  001948ec: 00000000 nop
  001948f0: a22219b6 sb r2,0x19b6(r17)
+
  001948f0: a22219b6 sb r2,0x19b6(r17) Set target as Cowardly in AI/Autobattle settings
 
  001948f4: 8fbf0018 lw r31,0x0018(r29)
 
  001948f4: 8fbf0018 lw r31,0x0018(r29)
 
  001948f8: 8fb10014 lw r17,0x0014(r29)
 
  001948f8: 8fb10014 lw r17,0x0014(r29)

Revision as of 10:15, 12 July 2020

Setting AI Flags for Target Consideration

0019471c: 3c02801a lui r2,0x801a
00194720: 904201fd lbu r2,0x01fd(r2)
00194724: 27bdffe0 addiu r29,r29,0xffe0
00194728: afb00010 sw r16,0x0010(r29)
0019472c: 3c10801a lui r16,0x801a
00194730: 8e1001f8 lw r16,0x01f8(r16)			Load Acting Unit's AI Decision Pointer
00194734: afb10014 sw r17,0x0014(r29)
00194738: 3c11801a lui r17,0x801a
0019473c: 2631f3c4 addiu r17,r17,0xf3c4			Load AI Data Pointer
00194740: 1440000e bne r2,r0,0x0019477c		
00194744: afbf0018 sw r31,0x0018(r29)
00194748: 3c03801a lui r3,0x801a
0019474c: 8c630bbc lw r3,0x0bbc(r3)			Load Acting Unit Data Pointer
00194750: 00000000 nop
00194754: 90620005 lbu r2,0x0005(r3)		Load ENTD Flags
00194758: 00000000 nop
0019475c: 30420008 andi r2,r2,0x0008
00194760: 10400006 beq r2,r0,0x0019477c			Branch if unit is under Player Control
00194764: 00000000 nop
00194768: 906201b8 lbu r2,0x01b8(r3)			Load Auto Battle Flag (From Current Action Data)
0019476c: 3c01801a lui r1,0x801a
00194770: a0220d7a sb r2,0x0d7a(r1)				Save to
00194774: 0806523d j 0x001948f4			Jump to Exit
00194778: 00000000 nop
0019477c: 92220e2e lbu r2,0x0e2e(r17)		Load ? Pointer
00194780: 00000000 nop
00194784: 02221021 addu r2,r17,r2		Add Pointer to AI Data Pointer
00194788: 904219a1 lbu r2,0x19a1(r2)		Load AutoBattle Flags
0019478c: 00000000 nop
00194790: a22219b6 sb r2,0x19b6(r17)		Save Current Unit AutoBattle Flags
00194794: 92030004 lbu r3,0x0004(r16)		Load AutoBattle Flag (From AI Decision Flags)
00194798: 00000000 nop
0019479c: 30620008 andi r2,r3,0x0008
001947a0: 10400023 beq r2,r0,0x00194830		Branch if Cowardly not set
001947a4: 00000000 nop
001947a8: 8e2217f8 lw r2,0x17f8(r17)		Load Acting Unit's Data Pointer
001947ac: 00000000 nop
001947b0: 90420059 lbu r2,0x0059(r2)		Load Current Status 2
001947b4: 00000000 nop
001947b8: 30420040 andi r2,r2,0x0040		
001947bc: 14400018 bne r2,r0,0x00194820		Branch unless Unit has Invite
001947c0: 00000000 nop
001947c4: 92020007 lbu r2,0x0007(r16)		Load AI Targeting Flags 2
001947c8: 00000000 nop
001947cc: 30420004 andi r2,r2,0x0004
001947d0: 14400048 bne r2,r0,0x001948f4		Branch unless Save CT/Protect Self
001947d4: 00000000 nop
001947d8: 922219b6 lbu r2,0x19b6(r17)		Load AutoBattle Flags
001947dc: 00000000 nop
001947e0: 14400044 bne r2,r0,0x001948f4		Branch unless AutoBattle Flags are set
001947e4: 30620040 andi r2,r3,0x0040
001947e8: 10400009 beq r2,r0,0x00194810		Branch if Focus on Target not set
001947ec: 00000000 nop
001947f0: 92040005 lbu r4,0x0005(r16)		Load Load Main Target ID
001947f4: 0c067ca9 jal 0x0019f2a4
001947f8: 02002821 addu r5,r16,r0			r4 = Acting Unit's AI Decision Pointer
001947fc: 92040005 lbu r4,0x0005(r16)		Load Main Target ID
00194800: 0c065b23 jal 0x00196c8c
00194804: 00000000 nop
00194808: 08065205 j 0x00194814
0019480c: 00000000 nop
00194810: 922219bb lbu r2,0x19bb(r17)		Load Unit Targetable Flag
00194814: 00000000 nop
00194818: 10400036 beq r2,r0,0x001948f4		Branch if Unit is Untargetable
0019481c: 00000000 nop
00194820: 92020004 lbu r2,0x0004(r16)		Load AutoBattle Flag (From AI Decision Flags)
00194824: 00000000 nop
00194828: 304200f7 andi r2,r2,0x00f7
0019482c: a2020004 sb r2,0x0004(r16)		Remove Cowardly Flag
00194830: 92220e39 lbu r2,0x0e39(r17)		Load Acting Unit's Team
00194834: 00000000 nop
00194838: 14400015 bne r2,r0,0x00194890		Branch unless Team is set
0019483c: 00000000 nop
00194840: 8e2317f8 lw r3,0x17f8(r17)		Load Acting Unit's Data Pointer
00194844: a22019b6 sb r0,0x19b6(r17)		Empty AI/Autobattle setting
00194848: 94620028 lhu r2,0x0028(r3)		Load CurHP
0019484c: 9463002a lhu r3,0x002a(r3)		Load MaxHP
00194850: 000211c0 sll r2,r2,0x07			CurHP * 80
00194854: 0043001a div r2,r3			(CurHP * 80) / MaxHP
00194858: 00001012 mflo r2		Get CurHP%
0019485c: 00000000 nop
00194860: 2842002d slti r2,r2,0x002d
00194864: 1440001c bne r2,r0,0x001948d8		Branch if CurHP < 35.5%
00194868: 34040005 ori r4,r0,0x0005
0019486c: 34040001 ori r4,r0,0x0001
00194870: 34020014 ori r2,r0,0x0014
00194874: 26230014 addiu r3,r17,0x0014
00194878: a0640c8d sb r4,0x0c8d(r3)			Set unit as targetable in Targetable Unit List
0019487c: 2442ffff addiu r2,r2,0xffff
00194880: 0441fffd bgez r2,0x00194878		Set all units as targetable
00194884: 2463ffff addiu r3,r3,0xffff
00194888: 08065236 j 0x001948d8			Jump to
0019488c: 34040004 ori r4,r0,0x0004
00194890: 92020006 lbu r2,0x0006(r16)		Load AI Targeting Flags 1
00194894: 00000000 nop
00194898: 30420004 andi r2,r2,0x0004
0019489c: 10400006 beq r2,r0,0x001948b8		Branch if Unit doesn't have largest # of usable abilities
001948a0: 34040001 ori r4,r0,0x0001
001948a4: 92020007 lbu r2,0x0007(r16)		Load AI Targeting Flags 2
001948a8: 00000000 nop
001948ac: 30420008 andi r2,r2,0x0008
001948b0: 1040000f beq r2,r0,0x001948f0		Branch if target is not Allied
001948b4: 34020010 ori r2,r0,0x0010
001948b8: a22019b6 sb r0,0x19b6(r17)		Empty AI/Autobattle setting
001948bc: 34020014 ori r2,r0,0x0014
001948c0: 26230014 addiu r3,r17,0x0014
001948c4: a0640c8d sb r4,0x0c8d(r3)			Set unit as targetable in Targetable Unit List
001948c8: 2442ffff addiu r2,r2,0xffff
001948cc: 0441fffd bgez r2,0x001948c4		Set all units as targetable
001948d0: 2463ffff addiu r3,r3,0xffff
001948d4: 34040004 ori r4,r0,0x0004
001948d8: 0c066449 jal 0x00199124
001948dc: 00000000 nop
001948e0: 0c065243 jal 0x0019490c
001948e4: 00402021 addu r4,r2,r0
001948e8: 0806523d j 0x001948f4
001948ec: 00000000 nop
001948f0: a22219b6 sb r2,0x19b6(r17)		Set target as Cowardly in AI/Autobattle settings
001948f4: 8fbf0018 lw r31,0x0018(r29)
001948f8: 8fb10014 lw r17,0x0014(r29)
001948fc: 8fb00010 lw r16,0x0010(r29)
00194900: 27bd0020 addiu r29,r29,0x0020
00194904: 03e00008 jr r31
00194908: 00000000 nop