Current Action Ability Data Setting / Multi Hit Formulas

From Final Fantasy Hacktics Wiki
Revision as of 20:20, 12 November 2022 by Orkney (talk | contribs)
Jump to navigation Jump to search
0017d4a0 - 0017d704 Notes

Parameters: r4 = Acting unit's data pointer

Clear/Reset some Current ability byte
Store Ability number of Hits ( 0x801938c2 )
Store Ability Primary and secondary weapons ( 0x801938c4 0x801938c5 )
Might store Ability data 2 flag 1 at 0x8018f7ec
------------------------------------------------------------------------
0017d4a0: 27bdffe8 addiu r29,r29,-0x0018    |
0017d4a4: 3c038019 lui r3,0x8019            |
0017d4a8: 8c63f5f0 lw r3,-0x0a10(r3)        |r3 = Type of action   8018f5f0 / 8018f5f0
0017d4ac: 34020001 ori r2,r0,0x0001         |r2 = 0x01
0017d4b0: afbf0014 sw r31,0x0014(r29)       |
0017d4b4: afb00010 sw r16,0x0010(r29)       |
0017d4b8: 3c018019 lui r1,0x8019            |
0017d4bc: a02238c2 sb r2,0x38c2(r1)         |Store default number of hits = 0x01 at 0x801938c2  801938c2
0017d4c0: 3c018019 lui r1,0x8019            |
0017d4c4: a02038c3 sb r0,0x38c3(r1)         |Clear strike counter at 0x801938c3  801938c3
0017d4c8: 3c018019 lui r1,0x8019            |
0017d4cc: a42038c8 sh r0,0x38c8(r1)         |clear 0x801938c8  Set to 0x01 if an ability proc  - 801938c8
0017d4d0: 3c018019 lui r1,0x8019            |
0017d4d4: a02038ed sb r0,0x38ed(r1)         |clear 0x801938ed  Fall related - 801938ed
0017d4d8: 14600009 bne r3,r0,0x0017d500     #If Action is not a reaction
0017d4dc: 00002821 addu r5,r0,r0            |r5 = 0x00
0017d4e0: 3c018019 lui r1,0x8019                 |r1 = 0x80190000
0017d4e4: a02038e8 sb r0,0x38e8(r1)              |Clear 0x801938e8 - can learn experience  801938e8
0017d4e8: 3c018019 lui r1,0x8019                 |
0017d4ec: a02038e7 sb r0,0x38e7(r1)              |Clear 0x801938e7 - experience earned  801938e7
0017d4f0: 3c018019 lui r1,0x8019                 |
0017d4f4: a020390c sb r0,0x390c(r1)              |clear 0x8019390c - ability type ?  8019390c
0017d4f8: 3c018019 lui r1,0x8019                 |
0017d4fc: a020390d sb r0,0x390d(r1)              |clear 0x8019390d - ability element ?  8019390d
0017d500: 9082016f lbu r2,0x016f(r4)        |r2 = Acting unit last used skillset
0017d504: 3c018006 lui r1,0x8006            |
0017d508: 00220821 addu r1,r1,r2            |r1 = 0x80060000 + skillset offset
0017d50c: 90265cb4 lbu r6,0x5cb4(r1)        |r6 = Acting unit last used action menu  0x80065cb4 / 80065cb4
0017d510: 3c018019 lui r1,0x8019            |
0017d514: a020f7ec sb r0,-0x0814(r1)        |clear used ability flag 1 at 0x8018f7ec  0x8018f7ec
0017d518: 9082001d lbu r2,0x001d(r4)        |r2 = Acting unit's right hand weapon
0017d51c: 3c018019 lui r1,0x8019            |
0017d520: a02238c4 sb r2,0x38c4(r1)         |Store right hand weapon ID in 0x801938c4 - Current ability primary weapon  0x801938c4
0017d524: 9082001f lbu r2,0x001f(r4)        |r2 = Acting unit's left hand weapon
0017d528: 3c038019 lui r3,0x8019            |
0017d52c: 906338c4 lbu r3,0x38c4(r3)        |r3 = Acting unit's  right hand weapon
0017d530: 3c018019 lui r1,0x8019            |
0017d534: a02238c5 sb r2,0x38c5(r1)         |store left hand weapon ID at 0x801938c5 - Current ability secondary weapon
0017d538: 340200ff ori r2,r0,0x00ff         |r2 = 0x0ff
0017d53c: 14620008 bne r3,r2,0x0017d560     #If Acting unit's right hand weapon doesn't exist (= 0xff) - swap weapons
0017d540: 30c300ff andi r3,r6,0x00ff        |r3 = Used Action menu byte
0017d544: 9083001f lbu r3,0x001f(r4)             |r3 = Acting unit's left hand weapon
0017d548: 340200ff ori r2,r0,0x00ff              |r2 = 0xff
0017d54c: 3c018019 lui r1,0x8019                 |
0017d550: a02238c5 sb r2,0x38c5(r1)              |Store no secondary weapon at 0x801938c5
0017d554: 3c018019 lui r1,0x8019                 |
0017d558: a02338c4 sb r3,0x38c4(r1)              |Store left hand weapon ID in primary weapon at 0x801938c4
0017d55c: 30c300ff andi r3,r6,0x00ff             |r3 = Used Action menu byte
0017d560: 34020002 ori r2,r0,0x0002         |r2 = 0x02
0017d564: 14620006 bne r3,r2,0x0017d580     #If Used action menu is Weapon Inventory
0017d568: 00000000 nop                           | 
0017d56c: 90820176 lbu r2,0x0176(r4)             |r2 = Acting unit's used item/equip ID
0017d570: 3c018019 lui r1,0x8019                 |
0017d574: a02238c4 sb r2,0x38c4(r1)              |store used item as primary weapon at 0x801938c4
0017d578: 0805f5bd j 0x0017d6f4                  >>jump to END
0017d57c: 00000000 nop                           |
0017d580: 10600003 beq r3,r0,0x0017d590     #If Used action menu is not default (<> 0x00)
0017d584: 34020006 ori r2,r0,0x0006              |r2 = 0x06
0017d588: 1462002b bne r3,r2,0x0017d638          #If Used action menu is Monster
0017d58c: 30c300ff andi r3,r6,0x00ff             |r3 = Used Action menu byte
0017d590: 84830170 lh r3,0x0170(r4)         #E       | r3 = Acting unit's used Ability ID
0017d594: 00000000 nop                               |
0017d598: 04610004 bgez r3,0x0017d5ac                #If Used Ability ID < 0x00 /WTF ? (if > 0x00 branch without checking potion ?)
0017d59c: 000310c0 sll r2,r3,0x03                    |r2 = Ability ID * 8
0017d5a0: 28620170 slti r2,r3,0x0170                     |r2 = 0x01 if ability ID < 0x170 (?)
0017d5a4: 1040000b beq r2,r0,0x0017d5d4                  #If Ability < Potion /Else skip ability data 2 section (inneficient check ??)
0017d5a8: 000310c0 sll r2,r3,0x03                        |r2 = Ability ID * 8
0017d5ac: 00431023 subu r2,r2,r3                     |r2 = Ability ID * 7
0017d5b0: 00021040 sll r2,r2,0x01                    |r2 = Ability ID * 14
0017d5b4: 3c038006 lui r3,0x8006                     |
0017d5b8: 2463fbf0 addiu r3,r3,0xfbf0                |r3 = Start of Ability data 2  0x8006fbf0 
0017d5bc: 00431021 addu r2,r2,r3                     |r2 = Start of Used Ability data 2 
0017d5c0: 90430003 lbu r3,0x0003(r2)                 |r3 = Used ability Flags 1
0017d5c4: 3c018019 lui r1,0x8019                     |
0017d5c8: a023f7ec sb r3,-0x0814(r1)                 |Store used ability flags 1 at 0x8018f7ec
0017d5cc: 90500009 lbu r16,0x0009(r2)                |r16 = Used ability X
0017d5d0: 90450008 lbu r5,0x0008(r2)                 |r5 = Used Ability Formula
0017d5d4: 00000000 nop                               |
0017d5d8: 24a2ffe2 addiu r2,r5,-0x001e               |r2 = Ability formula - 0x1e                          
0017d5dc: 2c420002 sltiu r2,r2,0x0002                |r2 = 0x01 if formula is 0x1e pr 0x1f
0017d5e0: 10400010 beq r2,r0,0x0017d624              #If Used Ability's formula is 0x1e or 0x1f #branch if not
0017d5e4: 30a300ff andi r3,r5,0x00ff                 |r3 = ability formula
0017d5e8: 3c028019 lui r2,0x8019                         | 
0017d5ec: 8c42f5fc lw r2,-0x0a04(r2)                     |r2 = Action State
0017d5f0: 00000000 nop                                   |
0017d5f4: 1440000c bne r2,r0,0x0017d628                  #If Action is been executed
0017d5f8: 3402005e ori r2,r0,0x005e                      |r2 = 0x5e 
0017d5fc: 0c0088c3 jal 0x0002230c                        |-->Random_Number_Generator  Return r2 between 0 and 0x7fff
0017d600: 00000000 nop                                   |
0017d604: 02020018 mult r16,r2                           |Ability X*Random
0017d608: 00001012 mflo r2                               |r2 = Ability X*Random
0017d60c: 04410002 bgez r2,0x0017d618                    #If r2 < 0x00
0017d610: 00000000 nop                                       | 
0017d614: 24427fff addiu r2,r2,0x7fff                        |r2 = positive value
0017d618: 000213c3 sra r2,r2,0x0f                        |r2 = Random between 0 and X-1 (X * Rand / (Max Rand +1))
0017d61c: 0805f5bb j 0x0017d6ec                          >>jump to store number of hits
0017d620: 24420001 addiu r2,r2,0x0001                    |r2 = number of hits (random +1)
0017d624: 3402005e ori r2,r0,0x005e                  |r2 = 0x5e
0017d628: 14620003 bne r3,r2,0x0017d638              #If Used ability formula is 0x5e
0017d62c: 30c300ff andi r3,r6,0x00ff                 |r3 = ability formula
0017d630: 0805f5bb j 0x0017d6ec                          >>jump to store number of hits (X+1)
0017d634: 26020001 addiu r2,r16,0x0001                   |r2 = ability X + 1
0017d638: 34020009 ori r2,r0,0x0009         |r2 = 0x09
0017d63c: 1062002d beq r3,r2,0x0017d6f4     #If Used action menu is not Jump /If action = jump, branch to END
0017d640: 34020008 ori r2,r0,0x0008              |r2 = 0x08
0017d644: 10620009 beq r3,r2,0x0017d66c          #If Used action menu is not Attack /If Action menu = Attack branch to frog/2 swords check
0017d648: 3402000a ori r2,r0,0x000a                  | 
0017d64c: 10620007 beq r3,r2,0x0017d66c              #If Used action menu is not charge /If Action menu = Charge branch to frog/2 swords check
0017d650: 00000000 nop                                   | 
0017d654: 3c028019 lui r2,0x8019                         |r2 = 0x80190000
0017d658: 9042f7ec lbu r2,-0x0814(r2)                    |r2 = used ability flags 1
0017d65c: 00000000 nop                                   |
0017d660: 30420020 andi r2,r2,0x0020                     |r2 = 0x20 if Ability is weapon ranged
0017d664: 10400023 beq r2,r0,0x0017d6f4                  #If Ability is weapon ranged /Else jump to END
0017d668: 00000000 nop                                       | 
0017d66c: 9082005a lbu r2,0x005a(r4)             #E   #E     |r2 = Acting unit current status 3
0017d670: 90850091 lbu r5,0x0091(r4)                         |r5 = Acting unit support 3
0017d674: 30420002 andi r2,r2,0x0002                         |r2 = 0x02 if Acting unit is frogged
0017d678: 14400006 bne r2,r0,0x0017d694                      #If Not frogged /If frogged branch to weapon nullification
0017d67c: 340200ff ori r2,r0,0x00ff                              | 
0017d680: 90820006 lbu r2,0x0006(r4)                             |r2 = Acting unit gender
0017d684: 00000000 nop                                           |
0017d688: 30420020 andi r2,r2,0x0020                             |r2 = 0x20 if acting unit is a monter
0017d68c: 10400005 beq r2,r0,0x0017d6a4                          #If acting unit is a monster /Else branch avoiding weapon nullification
0017d690: 340200ff ori r2,r0,0x00ff                                  |r2 = 0x0ff
0017d694: 3c018019 lui r1,0x8019                             #E      | r1 = 0x80190000
0017d698: a02238c4 sb r2,0x38c4(r1)                                  |store no right hand weapon (0xff)
0017d69c: 3c018019 lui r1,0x8019                                     |
0017d6a0: a02238c5 sb r2,0x38c5(r1)                                  |store no left hand weapon (0xff)
0017d6a4: 3c048019 lui r4,0x8019                             |r4 = 0x80190000
0017d6a8: 248438c4 addiu r4,r4,0x38c4                        |r4 = 0x801938c4
0017d6ac: 94830000 lhu r3,0x0000(r4)                         |r3 =  right & left hand weapon ID
0017d6b0: 3402ffff ori r2,r0,0xffff                          |r2 = 0xffff
0017d6b4: 1062000a beq r3,r2,0x0017d6e0                      #If there's at least one weapon /No weapons ID (fist) branch to 2 swords check
0017d6b8: 340300ff ori r3,r0,0x00ff                              |r3 = 0x0ff
0017d6bc: 90820000 lbu r2,0x0000(r4)                             |r2 = right hand weapon ID
0017d6c0: 00000000 nop                                           |
0017d6c4: 1043000b beq r2,r3,0x0017d6f4                          #If right hand weapon exists /Else branch to END
0017d6c8: 00000000 nop                                               | 
0017d6cc: 3c028019 lui r2,0x8019                                     |r2 = 0x80190000
0017d6d0: 904238c5 lbu r2,0x38c5(r2)                                 |r2 = left hand weapon ID
0017d6d4: 00000000 nop                                               |
0017d6d8: 10430006 beq r2,r3,0x0017d6f4                              # if left hand weapon exists /Else branch to END
0017d6dc: 00000000 nop                                                   | 
0017d6e0: 30a20001 andi r2,r5,0x0001                         #E          | r2 = 0x01 if Unit has Two Swords in support
0017d6e4: 10400003 beq r2,r0,0x0017d6f4                                  #If Two swords is active /Else branch to END
0017d6e8: 34020002 ori r2,r0,0x0002                                          |r2 = 0x02
0017d6ec: 3c018019 lui r1,0x8019                                             |
0017d6f0: a02238c2 sb r2,0x38c2(r1)                              |store number of hits at 0x801938c2
0017d6f4: 8fbf0014 lw r31,0x0014(r29)                            
0017d6f8: 8fb00010 lw r16,0x0010(r29)                            
0017d6fc: 27bd0018 addiu r29,r29,0x0018                          
0017d700: 03e00008 jr r31                                        
0017d704: 00000000 nop

Notes

Clear : - 0x801938c3 (strike counter)
        - 0x801938c8 (proc ? post action event ?)
        - 0x801938ed (Fall related)
        - If Action is not a reaction
           - 0x801938e8 (can earn xp)
           - 0x801938e7 (exp earned)
           - 0x8019390c (?)
           - 0x8019390d (?)

0x8018f7ec (Ability data 2 flag 1)	
  - Set to 0x00 (default value)
  - Filled with ability data 2 flag 1 if used action menu is default or monster

0x801938c2 - Number of hits
  - Set to 0x01 (default)
  - Depending of formula if Used Action Menu is default or monster (there is an ability ID check that seems to be bad written)
          - Set to Random (1 to Ability X) if Ability Formula is 0x1e or 0x1f
          - Set to X+1 is formula is 0x5e
  - Else : - If Action menu is [Attack or Charge] or Ability is weapon ranged
           - AND if unit has two weapons and the 2 swords ability 
                   --> Set to 0x02
0x801938c4 (Ability primary weapon)
  - Filled with unit right hand weapon (default)
  - Filled with unit left hand weapon if no right hand weapon (0xff)
  - Filled with used item if action menu is katana inventory
  - Forced to 0xff if Unit is a frog or a monster

0x801938c5 (Ability secondary weapon) 
  - Filled with left hand weapon ID
  - Set to 0xff if there's no right hand weapon
  - Set to 0xff if Unit is a monster or a frog

Return locations

Battle.bin
0017caa0: Prep_Current_Action_Data
0017e100: Big..._Contains_Hamedo_check
0017e470: Main_reaction_routine?
0017f1cc: Calculate_Projected_Action_Effect