Difference between revisions of "Non-Specific AI AutoBattle (Enemies)"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Undo revision 28087 by Orkney (talk))
Tag: Undo
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<font face='Courier New'>
+
'''BATTLE.BIN''' :  -  Non-Specific AI AutoBattle (Enemies)
Non-Specific AI AutoBattle (Enemies) <font face='Courier New'>
+
Test any combination of [Ability / Destination /Targeted Tile] and store selected action data in AI 0x17fc
 
+
------------------------------------------------------------------------------------------
  0019619c: 3c02801a lui r2,0x801a
+
Parameter : Nothing
  001961a0: 90420d7b lbu r2,0x0d7b(r2) load skillset/usage byte
+
Return : r2 = 0x00 (default)
  001961a4: 27bdffe8 addiu r29,r29,0xffe8
+
          r2 = -0x01 (Abort on Vsync alert ?)
  001961a8: afb00010 sw r16,0x0010(r29)
+
------------------------------------------------------------------------------------------
  001961ac: 3c10801a lui r16,0x801a
+
0019619c: 3c02801a lui r2,0x801a             |
  001961b0: 2610f3c4 addiu r16,r16,0xf3c4
+
001961a0: 90420d7b lbu r2,0x0d7b(r2)         |{{f/load|Load AI 0x19b7}} {{f/std|Flag to return where the code stops after a V_Sync alert (refresh animation on screen ?)}}
  001961b4: 1040000a beq r2,r0,0x001961e0 branch if none set
+
001961a4: 27bdffe8 addiu r29,r29,-0x0018    |
  001961b8: afbf0014 sw r31,0x0014(r29)
+
001961a8: afb00010 sw r16,0x0010(r29)       |
  001961bc: 3c03801a lui r3,0x801a
+
001961ac: 3c10801a lui r16,0x801a           |
  001961c0: 90630299 lbu r3,0x0299(r3) loda ??
+
001961b0: 2610f3c4 addiu r16,r16,-0x0c3c    |{{f/adr|8019f3c4}}
  001961c4: 34020004 ori r2,r0,0x0004
+
  001961c8: 10620008 beq r3,r2,0x001961ec
+
{{f/sec|<nowiki>=== Return to where the code left off ===</nowiki>}}
  001961cc: 34020002 ori r2,r0,0x0002
+
001961b4: 1040000a beq r2,r0,0x001961e0     {{f/Cond|If AI 0x19b7 <> 0x00 - Read Control variable}}
  001961d0: 1062000f beq r3,r2,0x00196210
+
001961b8: afbf0014 sw r31,0x0014(r29)           |
  001961d4: 00000000 nop
+
001961bc: 3c03801a lui r3,0x801a                 |
  001961d8: 08065894 j 0x00196250
+
001961c0: 90630299 lbu r3,0x0299(r3)             |{{f/load|AI 0xe5d (this routine memory variable)}} {{f/std| 0x801a0299}}
  001961dc: 00000000 nop
+
001961c4: 34020004 ori r2,r0,0x0004             |
  no skillset usage set
+
001961c8: 10620008 beq r3,r2,0x001961ec         {{f/Cond|<nowiki>if AI 0xe5d = 0x04</nowiki>}} {{f/loc|Return to Evaluate best destination}}
  001961e0: 34020001 ori r2,r0,0x0001
+
001961cc: 34020002 ori r2,r0,0x0002             |
  001961e4: 3c01801a lui r1,0x801a
+
001961d0: 1062000f beq r3,r2,0x00196210         {{f/Cond|<nowiki>if AI 0xe5d = 0x02</nowiki>}} {{f/loc|Return to Evaluate best destination if Caster is charging}}
  001961e8: a02201f1 sb r2,0x01f1(r1)
+
001961d4: 00000000 nop                           |
 
+
001961d8: 08065894 j 0x00196250                 {{f/Cond|<nowiki>Else (AI 0xe5d = 0x7) </nowiki>}} {{f/loc|Return to Abilities evaluation}}
  001961ec: 0c0658e3 jal 0x0019638c [[Map movement decision/data setting]]
+
001961dc: 00000000 nop                           |
  001961f0: 00000000 nop
+
  001961f4: 2403ffff addiu r3,r0,0xffff
+
{{f/sec|<nowiki>=== Proceed to AI non specific auto battle (from beginning) ===</nowiki>}}
  001961f8: 1043001a beq r2,r3,0x00196264
+
                                              '''<nowiki>Else : AI 0x19b7 = 0x00</nowiki>'''
  001961fc: 34020004 ori r2,r0,0x0004
+
001961e0: 34020001 ori r2,r0,0x0001             |
  00196200: 0c0658c3 jal 0x0019630c [[0019630c - 00196388]]
+
001961e4: 3c01801a lui r1,0x801a                 |
  00196204: a2000e2d sb r0,0x0e2d(r16)
+
001961e8: a02201f1 sb r2,0x01f1(r1)             |{{f/store|Store 0x01 at 8019f3c4 + 0x0e2d}} {{f/std| Consider moving toward target}}
  00196208: 34020001 ori r2,r0,0x0001
+
  0019620c: a2020e2d sb r2,0x0e2d(r16)
+
                  {{f/sec|--- Evaluate best destination ---}}
 
+
001961ec: 0c0658e3 jal 0x0019638c               |{{f/jal|Map movement decision/data setting|Map movement decision/data setting}} {{f/std|Set best Tile to move on and store it in AI 0xcc4}}
  00196210: 0c0657e3 jal 0x00195f8c [[set current ability CT/status change]]
+
001961f0: 00000000 nop                           |
  00196214: 00000000 nop
+
001961f4: 2403ffff addiu r3,r0,-0x0001          |
  00196218: 00401821 addu r3,r2,r0
+
001961f8: 1043001a beq r2,r3,0x00196264         {{f/Cond|If returned value is -0x01}} {{f/loc|<nowiki>Set AI 0xed5 = 0x04 and Exit</nowiki>}} {{f/Returns|return -0x01}}
  0019621c: 2402ffff addiu r2,r0,0xffff
+
001961fc: 34020004 ori r2,r0,0x0004             |
  00196220: 10620010 beq r3,r2,0x00196264
+
00196200: 0c0658c3 jal 0x0019630c               |{{f/jal|Invert_Target_Priority_(0019630c)|Invert_Target_Priority_(0019630c)}} {{f/std|Store priority from considered Tile (at AI 0xcc4) and store it reverted at Table AI 0x154 + 0x1e}}
  00196224: 34020002 ori r2,r0,0x0002
+
00196204: a2000e2d sb r0,0x0e2d(r16)             |{{f/store|<nowiki>0xe2d = 0x0</nowiki>}} {{f/std|No Target consideration}}
  00196228: 34020001 ori r2,r0,0x0001
+
00196208: 34020001 ori r2,r0,0x0001             |
  0019622c: 10620017 beq r3,r2,0x0019628c
+
0019620c: a2020e2d sb r2,0x0e2d(r16)             |{{f/store|<nowiki>0xe2d = 0x1</nowiki>}} {{f/std| Consider moving closer to Target}}
  00196230: 00001021 addu r2,r0,r0
+
00196210: 0c0657e3 jal 0x00195f8c               |{{f/jal|Set_or_Remove_Charging_(00195f8c)|Set_or_Remove_Charging_(00195f8c)}} {{f/std|If Caster is Charging Simulate Movement, with or without charge}}
  00196234: 34020001 ori r2,r0,0x0001
+
00196214: 00000000 nop                           |
  00196238: a2020e2d sb r2,0x0e2d(r16)
+
00196218: 00401821 addu r3,r2,r0                 |
  0019623c: 00002021 addu r4,r0,r0
+
0019621c: 2402ffff addiu r2,r0,-0x0001          |
  00196240: 0c065f43 jal 0x00197d0c [[Find which units are active?]]
+
00196220: 10620010 beq r3,r2,0x00196264         {{f/Cond|If Returned value is -0x01 :}} {{f/loc|<nowiki>Set AI 0xed5 = 0x02  and Exit</nowiki>}} {{f/Returns|Returns -0x01}} {{f/std|V_Sync alert ?}}
  00196244: 00002821 addu r5,r0,r0
+
00196224: 34020002 ori r2,r0,0x0002             |
  00196248: 10400009 beq r2,r0,0x00196270
+
00196228: 34020001 ori r2,r0,0x0001             |
  0019624c: 00000000 nop
+
0019622c: 10620017 beq r3,r2,0x0019628c         {{f/Cond|If returned value is 0x01}} {{f/loc|Exit}} {{f/Returns|Returns 0x00}} {{f/std|AI 0x14 Action data is better then AI 0x17fc Action data (move and cancel charged ability)}}
  00196250: 0c065f98 jal 0x00197e60 [[00197e60 - 00197f10]]
+
00196230: 00001021 addu r2,r0,r0                 |
  00196254: 00000000 nop
+
00196234: 34020001 ori r2,r0,0x0001             |
  00196258: 2403ffff addiu r3,r0,0xffff
+
00196238: a2020e2d sb r2,0x0e2d(r16)             |{{f/store|<nowiki>Set AI 0xe2d = 0x01</nowiki>}} {{f/std| Consider getting closer to Target}}
  0019625c: 14430004 bne r2,r3,0x00196270
+
0019623c: 00002021 addu r4,r0,r0                 |{{f/std|Set Look for any unit}}
  00196260: 34020007 ori r2,r0,0x0007
+
00196240: 0c065f43 jal 0x00197d0c               |{{f/jal|Find_which_units_are_active%3F|Find_which_units_are_active%3F}} {{f/std|Fill AI List 0xa78 with any targetable Units - returns Nb of unit in list}}
 
+
00196244: 00002821 addu r5,r0,r0                 |{{f/std|Set Look for self too}}
  00196264: a2020ed5 sb r2,0x0ed5(r16)
+
00196248: 10400009 beq r2,r0,0x00196270         {{f/Cond|If There is no Unit to Target  }} {{f/loc|Avoid Abilities evaluation}}
  00196268: 080658a3 j 0x0019628c
+
0019624c: 00000000 nop                           |
  0019626c: 2402ffff addiu r2,r0,0xffff
+
  00196270: 0c065c2f jal 0x001970bc [[001970bc - 001971b4]]
+
                  {{f/sec|--- Evaluate All possible actions ---}}
  00196274: 00000000 nop
+
00196250: 0c065f98 jal 0x00197e60               |{{f/jal|Chose_Move_from_Move_List%3F|Chose_Move_from_Move_List%3F}} {{f/std|Test All abilities in any situation - save best results in AI 0x54 to AI 0x134}}
  00196278: 14400004 bne r2,r0,0x0019628c
+
00196254: 00000000 nop                           |
  0019627c: 00001021 addu r2,r0,r0
+
00196258: 2403ffff addiu r3,r0,-0x0001          |
  00196280: 0c066526 jal 0x00199498 [[00199498 - 001994f4]]
+
0019625c: 14430004 bne r2,r3,0x00196270         {{f/Cond|If returned value is not  -0x01 :}} {{f/loc|Avoid routine abortion}}
  00196284: a2000e2d sb r0,0x0e2d(r16)
+
00196260: 34020007 ori r2,r0,0x0007             |
  00196288: 00001021 addu r2,r0,r0
+
                                                  '''<nowiki>Else : r2 = -0x01 </nowiki>'''
 
+
  0019628c: 8fbf0014 lw r31,0x0014(r29)
+
{{f/sec|<nowiki>=== Abort section ===</nowiki>}}
  00196290: 8fb00010 lw r16,0x0010(r29)
+
00196264: a2020ed5 sb r2,0x0ed5(r16)             |{{f/store|Update this routine control variable}}
  00196294: 27bd0018 addiu r29,r29,0x0018
+
00196268: 080658a3 j 0x0019628c                 |{{f/loc|Exit}} {{f/Returns|Return -0x01}}
  00196298: 03e00008 jr r31
+
0019626c: 2402ffff addiu r2,r0,-0x0001          |
  0019629c: 00000000 nop
+
  </font></font>
+
{{f/sec|<nowiki>=== Select best action and store it at AI 0x17fc ===</nowiki>}}
 +
00196270: 0c065c2f jal 0x001970bc               |{{f/jal|Randomly_Transfer_Data|Randomly_Transfer_Data}} {{f/std|Set selected action  in AI 0x17fc}}
 +
00196274: 00000000 nop                           |
 +
00196278: 14400004 bne r2,r0,0x0019628c         {{f/Cond|If No Action selected}}
 +
0019627c: 00001021 addu r2,r0,r0                     |
 +
00196280: 0c066526 jal 0x00199498                   |{{f/jal|Tranfer_AI_Ability_Data_and_Set_Defend_flag_(00199498)|Tranfer_AI_Ability_Data_and_Set_Defend_flag_(00199498)}} {{f/std|Set Selected action to move and use Defend if possible}}
 +
00196284: a2000e2d sb r0,0x0e2d(r16)                 |{{f/store|<nowiki>AI 0xe2d = 0x00</nowiki>}} {{f/std| No target consideration}}
 +
00196288: 00001021 addu r2,r0,r0                 |{{f/Returns|Returns 0x00}}
 +
0019628c: 8fbf0014 lw r31,0x0014(r29)
 +
00196290: 8fb00010 lw r16,0x0010(r29)
 +
00196294: 27bd0018 addiu r29,r29,0x0018
 +
00196298: 03e00008 jr r31
 +
0019629c: 00000000 nop
 +
===Return locations===
 +
  '''BATTLE.BIN'''
 +
  00195f38: [[AI_Initial_Targeting_Selection]]
 +
  00198e44: [[Save_Fading_Life_-_Auto_Battle_(00198df0)]]

Latest revision as of 06:33, 11 July 2024

BATTLE.BIN :  -  Non-Specific AI AutoBattle (Enemies)
Test any combination of [Ability / Destination /Targeted Tile] and store selected action data in AI 0x17fc
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = 0x00 (default)
         r2 = -0x01 (Abort on Vsync alert ?)
------------------------------------------------------------------------------------------
0019619c: 3c02801a lui r2,0x801a             |
001961a0: 90420d7b lbu r2,0x0d7b(r2)         |Load AI 0x19b7 Flag to return where the code stops after a V_Sync alert (refresh animation on screen ?)
001961a4: 27bdffe8 addiu r29,r29,-0x0018     |
001961a8: afb00010 sw r16,0x0010(r29)        |
001961ac: 3c10801a lui r16,0x801a            |
001961b0: 2610f3c4 addiu r16,r16,-0x0c3c     |8019f3c4

=== Return to where the code left off ===
001961b4: 1040000a beq r2,r0,0x001961e0      #If AI 0x19b7 <> 0x00 - Read Control variable
001961b8: afbf0014 sw r31,0x0014(r29)            |
001961bc: 3c03801a lui r3,0x801a                 |
001961c0: 90630299 lbu r3,0x0299(r3)             |AI 0xe5d (this routine memory variable)  0x801a0299
001961c4: 34020004 ori r2,r0,0x0004              |
001961c8: 10620008 beq r3,r2,0x001961ec          #if AI 0xe5d = 0x04 Return to Evaluate best destination
001961cc: 34020002 ori r2,r0,0x0002              |
001961d0: 1062000f beq r3,r2,0x00196210          #if AI 0xe5d = 0x02 Return to Evaluate best destination if Caster is charging
001961d4: 00000000 nop                           |
001961d8: 08065894 j 0x00196250                  #Else (AI 0xe5d = 0x7)  Return to Abilities evaluation
001961dc: 00000000 nop                           |

=== Proceed to AI non specific auto battle (from beginning) ===
                                             Else : AI 0x19b7 = 0x00
001961e0: 34020001 ori r2,r0,0x0001              |
001961e4: 3c01801a lui r1,0x801a                 |
001961e8: a02201f1 sb r2,0x01f1(r1)              |Store 0x01 at 8019f3c4 + 0x0e2d  Consider moving toward target

                  --- Evaluate best destination ---
001961ec: 0c0658e3 jal 0x0019638c                |-->Map movement decision/data setting Set best Tile to move on and store it in AI 0xcc4
001961f0: 00000000 nop                           |
001961f4: 2403ffff addiu r3,r0,-0x0001           |
001961f8: 1043001a beq r2,r3,0x00196264          #If returned value is -0x01 Set AI 0xed5 = 0x04 and Exit return -0x01
001961fc: 34020004 ori r2,r0,0x0004              |
00196200: 0c0658c3 jal 0x0019630c                |-->Invert_Target_Priority_(0019630c) Store priority from considered Tile (at AI 0xcc4) and store it reverted at Table AI 0x154 + 0x1e
00196204: a2000e2d sb r0,0x0e2d(r16)             |0xe2d = 0x0 No Target consideration
00196208: 34020001 ori r2,r0,0x0001              |
0019620c: a2020e2d sb r2,0x0e2d(r16)             |0xe2d = 0x1  Consider moving closer to Target
00196210: 0c0657e3 jal 0x00195f8c                |-->Set_or_Remove_Charging_(00195f8c) If Caster is Charging Simulate Movement, with or without charge
00196214: 00000000 nop                           |
00196218: 00401821 addu r3,r2,r0                 |
0019621c: 2402ffff addiu r2,r0,-0x0001           |
00196220: 10620010 beq r3,r2,0x00196264          #If Returned value is -0x01 : Set AI 0xed5 = 0x02  and Exit Returns -0x01 V_Sync alert ?
00196224: 34020002 ori r2,r0,0x0002              |
00196228: 34020001 ori r2,r0,0x0001              |
0019622c: 10620017 beq r3,r2,0x0019628c          #If returned value is 0x01 Exit Returns 0x00 AI 0x14 Action data is better then AI 0x17fc Action data (move and cancel charged ability)
00196230: 00001021 addu r2,r0,r0                 |
00196234: 34020001 ori r2,r0,0x0001              |
00196238: a2020e2d sb r2,0x0e2d(r16)             |Set AI 0xe2d = 0x01  Consider getting closer to Target
0019623c: 00002021 addu r4,r0,r0                 |Set Look for any unit
00196240: 0c065f43 jal 0x00197d0c                |-->Find_which_units_are_active%3F Fill AI List 0xa78 with any targetable Units - returns Nb of unit in list
00196244: 00002821 addu r5,r0,r0                 |Set Look for self too
00196248: 10400009 beq r2,r0,0x00196270          #If There is no Unit to Target   Avoid Abilities evaluation
0019624c: 00000000 nop                           |

                  --- Evaluate All possible actions ---
00196250: 0c065f98 jal 0x00197e60                |-->Chose_Move_from_Move_List%3F Test All abilities in any situation - save best results in AI 0x54 to AI 0x134
00196254: 00000000 nop                           |
00196258: 2403ffff addiu r3,r0,-0x0001           |
0019625c: 14430004 bne r2,r3,0x00196270          #If returned value is not  -0x01 : Avoid routine abortion
00196260: 34020007 ori r2,r0,0x0007              |
                                                 Else : r2 = -0x01 

=== Abort section ===
00196264: a2020ed5 sb r2,0x0ed5(r16)             |Update this routine control variable
00196268: 080658a3 j 0x0019628c                  |Exit Return -0x01
0019626c: 2402ffff addiu r2,r0,-0x0001           |

=== Select best action and store it at AI 0x17fc ===
00196270: 0c065c2f jal 0x001970bc                |-->Randomly_Transfer_Data Set selected action  in AI 0x17fc
00196274: 00000000 nop                           |
00196278: 14400004 bne r2,r0,0x0019628c          #If No Action selected
0019627c: 00001021 addu r2,r0,r0                     |
00196280: 0c066526 jal 0x00199498                    |-->Tranfer_AI_Ability_Data_and_Set_Defend_flag_(00199498) Set Selected action to move and use Defend if possible
00196284: a2000e2d sb r0,0x0e2d(r16)                 |AI 0xe2d = 0x00  No target consideration
00196288: 00001021 addu r2,r0,r0                 |Returns 0x00
0019628c: 8fbf0014 lw r31,0x0014(r29)
00196290: 8fb00010 lw r16,0x0010(r29)
00196294: 27bd0018 addiu r29,r29,0x0018
00196298: 03e00008 jr r31
0019629c: 00000000 nop

Return locations

BATTLE.BIN
 00195f38: AI_Initial_Targeting_Selection
 00198e44: Save_Fading_Life_-_Auto_Battle_(00198df0)