See if any unit decided to use an ability

From Final Fantasy Hacktics Wiki
Revision as of 15:34, 24 April 2024 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN :  - See if any unit decided to use an ability
check usefulness of an Ability on All Potential Targets from AI List at 0x8019f3c4 + 0xc78
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = 0x01 if There is at least one Valid Target for this ability
         r2 = 0x00 if no valid Targets
------------------------------------------------------------------------------------------
0019e540: 27bdffd8 addiu r29,r29,-0x0028     |
0019e544: afb20018 sw r18,0x0018(r29)        |
0019e548: 00009021 addu r18,r0,r0            |Initialize Valid Target flag
0019e54c: afb40020 sw r20,0x0020(r29)        |
0019e550: 3c14801a lui r20,0x801a            |
0019e554: 2694f3c4 addiu r20,r20,0xf3c4      |0x8019f3c4
0019e558: afb00010 sw r16,0x0010(r29)        |
0019e55c: 00008021 addu r16,r0,r0            |Initialize Unit Counter
0019e560: afb3001c sw r19,0x001c(r29)        |
0019e564: 34130001 ori r19,r0,0x0001         |
0019e568: afbf0024 sw r31,0x0024(r29)        |
0019e56c: afb10014 sw r17,0x0014(r29)        |
0019e570: 02908821 addu r17,r20,r16          |AI Data + Unit offset (1 byte)
                                            @LOOP - All Units
0019e574: 92220c8d lbu r2,0x0c8d(r17)            |This Unit Targetable Flag 0x8019f3c4 + 0xcd8 + Unit offset
0019e578: 00000000 nop                           |
0019e57c: 10400008 beq r2,r0,0x0019e5a0          #if unit is not an elligible Taget branch to Next Unit
0019e580: 02002021 addu r4,r16,r0                    |
0019e584: 0c067976 jal 0x0019e5d8                |-->AI_Ability_Use_Decisions
0019e588: 34050001 ori r5,r0,0x0001              |Bypass reflect
0019e58c: 14530003 bne r2,r19,0x0019e59c         #If Ability is usable or usefull on this Target
0019e590: 00000000 nop                               |
0019e594: 08067968 j 0x0019e5a0                      >>Keep Unit in Potential Target List 
0019e598: 34120001 ori r18,r0,0x0001                 |Enable Valid target flag
                                                 Else : Ability could/should not be used on this Target
0019e59c: a2200c8d sb r0,0x0c8d(r17)                 |Disable Unit in potential target list
0019e5a0: 26100001 addiu r16,r16,0x0001          |Unit Counter + 1
0019e5a4: 2a020015 slti r2,r16,0x0015            |
0019e5a8: 1440fff2 bne r2,r0,0x0019e574      Λ do for each unit
0019e5ac: 02908821 addu r17,r20,r16              |Apply unit offset on AI pointer
0019e5b0: 02401021 addu r2,r18,r0            |r2 = 1 if any unit found
0019e5b4: 8fbf0024 lw r31,0x0024(r29)
0019e5b8: 8fb40020 lw r20,0x0020(r29)
0019e5bc: 8fb3001c lw r19,0x001c(r29)
0019e5c0: 8fb20018 lw r18,0x0018(r29)
0019e5c4: 8fb10014 lw r17,0x0014(r29)
0019e5c8: 8fb00010 lw r16,0x0010(r29)
0019e5cc: 27bd0028 addiu r29,r29,0x0028
0019e5d0: 03e00008 jr r31
0019e5d4: 00000000 nop

Return locations

BATTLE.BIN
 0019b08c: AI_ability_use_control_routine
 0019b0dc: AI_ability_use_control_routine
 0019bdf4: Math_Skill_Targeting