Difference between revisions of "04 Magic Gun"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
m
Line 1: Line 1:
  [04] Magic Guns
+
  Chooses and casts a Magic Ability :
  00188c24: 27bdffe8 addiu r29,r29,0xffe8
+
- Fire if gun element is Fire (Tier is random : 60% Fire 1 / 30% Fire 2 / 10% Fire 3)
  00188c28: afbf0010 sw r31,0x0010(r29)
+
- Bolt if element is thunder
  00188c2c: 0c061dcc jal 0x 00187730            ;  [[Magic Gun Ability Decision]]
+
- Ice if element is Ice (in fact, Ice if not fire nor thunder)
  00188c30: 00000000 nop
+
  00188c34: 3c028019 lui r2,0x8019
+
Weapon Power is used instead of Attacker's Magic Attack
  00188c38: 90423902 lbu r2,0x3902(r2)           ;  Load WP
+
-------------------------------------------------------------------------------------------
  00188c3c: 3c038019 lui r3,0x8019
+
  00188c24: 27bdffe8 addiu r29,r29,-0x0018   
  00188c40: 906338fa lbu r3,0x38fa(r3)           ;  Load Ability Power
+
  00188c28: afbf0010 sw r31,0x0010(r29)      
  00188c44: 3c018019 lui r1,0x8019
+
  00188c2c: 0c061dcc jal 0x00187730          |{{f/jal|Magic Gun Ability Decision|Magic Gun Ability Decision}}  Weapon Element determines type of spell, Tier is randomly chosen
  00188c48: a42238ce sh r2,0x38ce(r1)           ;  XA = WP
+
  00188c30: 00000000 nop                     |
  00188c4c: 3c018019 lui r1,0x8019
+
  00188c34: 3c028019 lui r2,0x8019           |
  00188c50: a42338d0 sh r3,0x38d0(r1)           ;  YA = Ability Power
+
  00188c38: 90423902 lbu r2,0x3902(r2)       |{{f/load|<nowiki>r2 = Current Ability Weapon Power</nowiki>}} {{f/std|        0x80193902 / 80193902}}
  00188c54: 0c0617e0 jal 0x 00185f80            ;  [[Charge Calculation]]
+
  00188c3c: 3c038019 lui r3,0x8019           |
  00188c58: 00000000 nop
+
  00188c40: 906338fa lbu r3,0x38fa(r3)       |{{f/load|<nowiki>r3 = Current Ability : Ability Y</nowiki>}} {{f/std|        0x801938fa / 801938fa}}
  00188c5c: 0c0617e9 jal 0x 00185fa4            ;  [[Weapon Element Strengthen]]
+
  00188c44: 3c018019 lui r1,0x8019           |
  00188c60: 00000000 nop
+
  00188c48: a42238ce sh r2,0x38ce(r1)         |{{f/store|Store WP as Ability XA}}
  00188c64: 0c0621d1 jal 0x 00188744            ;  [[Magical Support/Status/Compat]]
+
  00188c4c: 3c018019 lui r1,0x8019           |
  00188c68: 00000000 nop
+
  00188c50: a42338d0 sh r3,0x38d0(r1)         |{{f/store|Store Ability Y as YA}}
  00188c6c: 0c0621df jal 0x 0018877c            ;  [[Elemental XA * YA]]
+
  00188c54: 0c0617e0 jal 0x00185f80          |{{f/jal|Charge Calculation |Charge Calculation }}  Add Power Charge to XA
  00188c70: 00000000 nop
+
  00188c58: 00000000 nop                     |
  00188c74: 14400005 bne r2,r0,0x 00188c8c      ;  Branch if element was nullified
+
  00188c5c: 0c0617e9 jal 0x00185fa4          |{{f/jal|Weapon Element Strengthen|Weapon Element Strengthen}} XA + 25% if Weapon Element is strengthened
  00188c78: 00000000 nop
+
  00188c60: 00000000 nop                     |
  00188c7c: 0c061c54 jal 0x 00187150            ;  [[Faith Calculation]]
+
  00188c64: 0c0621d1 jal 0x00188744          |{{f/jal|Magical Support/Status/Compat|Magical Support/Status/Compat}} Modify Ability XA (Status / Support / Compatibility)
  00188c80: 00000000 nop
+
  00188c68: 00000000 nop                     |
  00188c84: 0c061c3f jal 0x 001870fc            ;  [[Elemental Absorption]]
+
  00188c6c: 0c0621df jal 0x0018877c          |{{f/jal|Elemental XA * YA|Elemental XA * YA}} Turns XA and YA in HP damage / Modify Damage based on Elements / Returns r2 = 0x00 if Attack hits
  00188c88: 00000000 nop
+
  00188c70: 00000000 nop                     |
  00188c8c: 8fbf0010 lw r31,0x0010(r29)
+
  00188c74: 14400005 bne r2,r0,0x00188c8c    {{f/Cond|If Attack hits}}
  00188c90: 27bd0018 addiu r29,r29,0x 0018
+
  00188c78: 00000000 nop                         |
  00188c94: 03e00008 jr r31
+
  00188c7c: 0c061c54 jal 0x00187150              |{{f/jal|Faith Calculation|Faith Calculation}} Damage becomes Damage*Target Faith/100 * Attacker Faith/100
  00188c98: 00000000 nop
+
  00188c80: 00000000 nop                         |
 
+
  00188c84: 0c061c3f jal 0x001870fc              |{{f/jal|Elemental Absorption|Elemental Absorption}} HP damage might becomes HP recovery - Changes Attack Type from 0x80 to 0x40 (HP recovery)
Magic Gun Ability Decision
+
  00188c88: 00000000 nop                         |
00187730: 27bdffe8 addiu r29,r29,0xffe8
+
  00188c8c: 8fbf0010 lw r31,0x0010(r29)       END
00187734: afb00010 sw r16,0x0010(r29)
+
  00188c90: 27bd0018 addiu r29,r29,0x0018   
00187738: 3c108019 lui r16,0x8019
+
  00188c94: 03e00008 jr r31                  
0018773c: 92103904 lbu r16,0x3904(r16)        ;  Load Weapon's Element
+
  00188c98: 00000000 nop                    
00187740: afbf0014 sw r31,0x0014(r29)
+
=== Return location ===
00187744: 0c063ba8 jal 0x 0018eea0            ;  Random Process
+
  '''Battle.bin'''
00187748: 00000000 nop
+
   8018b97c - [[Pre Formula Setup (FDC)|Pre Formula Setup]]
0018774c: 00021840 sll r3,r2,0x01              ;  Random * 2
 
00187750: 00621821 addu r3,r3,r2              ;  Random * 3
 
00187754: 000318c0 sll r3,r3,0x03              ;  Random * 24
 
00187758: 00621821 addu r3,r3,r2              ;  Random * 25
 
0018775c: 00031880 sll r3,r3,0x02              ;  Random * 100 (or mult r2, r3 with r3 = 64)
 
00187760: 04610002 bgez r3,0x 0018776c        ;  Branch if Random is Positive
 
00187764: 32020080 andi r2,r16,0x0080
 
00187768: 24637fff addiu r3,r3,0x7fff          ;  Random + 7fff
 
0018776c: 1040000b beq r2,r0,0x 0018779c      ;  Branch if Weapon doesn't have Fire
 
00187770: 00031bc2 srl r3,r3,0x0f              ;  Random / 8000 (rand 0..99)
 
00187774: 306400ff andi r4,r3,0x00ff
 
00187778: 2c82000a sltiu r2,r4,0x000a
 
0018777c: 10400003 beq r2,r0,0x 0018778c      ;  Branch if Random > a (90% chance to branch)
 
00187780: 2c820028 sltiu r2,r4,0x0028
 
00187784: 08061dfb j 0x 001877ec
 
00187788: 34030012 ori r3,r0,0x0012            ;  r3 = 12 (Firaga, 10% chance)
 
0018778c: 10400017 beq r2,r0,0x 001877ec      ;  Branch if Random > 28 (60% chance to branch)
 
00187790: 34030010 ori r3,r0,0x0010            ;  r3 = 10 (Fire, 60% chance)
 
00187794: 08061dfb j 0x 001877ec
 
00187798: 34030011 ori r3,r0,0x0011            ;  r3 = 11 (Fira, 30% chance)
 
0018779c: 32020040 andi r2,r16,0x0040
 
001877a0: 1040000a beq r2,r0,0x 001877cc      ;  Branch if Weapon doesn't have Lightning
 
001877a4: 306400ff andi r4,r3,0x00ff
 
001877a8: 2c82000a sltiu r2,r4,0x000a
 
001877ac: 10400003 beq r2,r0,0x 001877bc      ;  Branch if Ranfom > a
 
001877b0: 2c820028 sltiu r2,r4,0x0028
 
001877b4: 08061dfb j 0x 001877ec
 
001877b8: 34030016 ori r3,r0,0x0016            ;  r3 = 16 (Thundaga)
 
001877bc: 1040000b beq r2,r0,0x 001877ec      ;  Branch if Random > 28
 
001877c0: 34030014 ori r3,r0,0x0014            ;  r3 = 14 (Thunder)
 
  001877c4: 08061dfb j 0x 001877ec
 
001877c8: 34030015 ori r3,r0,0x0015            ;  r3 = 15 (Thundara)
 
001877cc: 2c82000a sltiu r2,r4,0x000a
 
001877d0: 10400003 beq r2,r0,0x 001877e0      ;  Branch if Random > a
 
001877d4: 2c820028 sltiu r2,r4,0x0028
 
001877d8: 08061dfb j 0x 001877ec
 
001877dc: 3403001a ori r3,r0,0x001a            ;  r3 = 1a (Blizzaga)
 
001877e0: 10400002 beq r2,r0,0x 001877ec      ;  Branch if Random > 28
 
001877e4: 3403 0018 ori r3,r0,0x 0018          ;  r3 = 18 (Blizzard)
 
001877e8: 34030019 ori r3,r0,0x0019            ;  r3 = 19 (Blizzara)
 
001877ec: 3c058019 lui r5,0x8019
 
001877f0: 24a538d6 addiu r5,r5,0x38d6
 
001877f4: 000320c0 sll r4,r3,0x03              ;  Ability ID * 8
 
001877f8: 00832023 subu r4,r4,r3              ;  Ability ID * 7
 
001877fc: 00042040 sll r4,r4,0x01              ;  Ability ID * 14
 
00187800: a4a30000 sh r3,0x0000(r5)            ;  Store Used Ability ID
 
00187804: 24a5001a addiu r5,r5,0x001a          ;  r5 = 801938f0 (Current Action Ability Data start)
 
00187808: 3c028019 lui r2,0x8019
 
0018780c: 8c422d94 lw r2,0x2d94(r2)            ;  Load Attacker's Data Pointer
 
00187810: 3406000e ori r6,r0,0x000e            ;  r6 = e (Loop Limit)
 
00187814: a4430170 sh r3,0x0170(r2)            ;   Store Last Attack? = Ability ID
 
00187818: 3c028006 lui r2,0x8006
 
0018781c: 2442fbf0 addiu r2,r2,-0x0410        ;  r2 = 5fbf0 (Ability Data)
 
00187820: 0c017895 jal 0x0005e254              ;  Load X into Y (Ability Data -> Current Action Data)
 
00187824: 00822021 addu r4,r4,r2              ;  r4 = Ability Data Pointer
 
00187828: 8fbf0014 lw r31,0x0014(r29)
 
0018782c: 8fb00010 lw r16,0x0010(r29)
 
00187830: 27bd 0018 addiu r29,r29,0x 0018
 
00187834: 03e00008 jr r31
 
00187838: 00000000 nop
 

Revision as of 19:03, 11 April 2022

Chooses and casts a Magic Ability :
- Fire if gun element is Fire (Tier is random : 60% Fire 1 / 30% Fire 2 / 10% Fire 3)
- Bolt if element is thunder
- Ice if element is Ice (in fact, Ice if not fire nor thunder)

Weapon Power is used instead of Attacker's Magic Attack
-------------------------------------------------------------------------------------------
00188c24: 27bdffe8 addiu r29,r29,-0x0018    
00188c28: afbf0010 sw r31,0x0010(r29)       
00188c2c: 0c061dcc jal 0x00187730           |-->Magic Gun Ability Decision  Weapon Element determines type of spell, Tier is randomly chosen
00188c30: 00000000 nop                      |
00188c34: 3c028019 lui r2,0x8019            |
00188c38: 90423902 lbu r2,0x3902(r2)        |r2 = Current Ability Weapon Power          0x80193902 / 80193902
00188c3c: 3c038019 lui r3,0x8019            |
00188c40: 906338fa lbu r3,0x38fa(r3)        |r3 = Current Ability : Ability Y         0x801938fa / 801938fa
00188c44: 3c018019 lui r1,0x8019            |
00188c48: a42238ce sh r2,0x38ce(r1)         |Store WP as Ability XA
00188c4c: 3c018019 lui r1,0x8019            |
00188c50: a42338d0 sh r3,0x38d0(r1)         |Store Ability Y as YA
00188c54: 0c0617e0 jal 0x00185f80           |-->Charge Calculation   Add Power Charge to XA
00188c58: 00000000 nop                      |
00188c5c: 0c0617e9 jal 0x00185fa4           |-->Weapon Element Strengthen XA + 25% if Weapon Element is strengthened
00188c60: 00000000 nop                      |
00188c64: 0c0621d1 jal 0x00188744           |-->Magical Support/Status/Compat Modify Ability XA (Status / Support / Compatibility)
00188c68: 00000000 nop                      |
00188c6c: 0c0621df jal 0x0018877c           |-->Elemental XA * YA Turns XA and YA in HP damage / Modify Damage based on Elements / Returns r2 = 0x00 if Attack hits
00188c70: 00000000 nop                      |
00188c74: 14400005 bne r2,r0,0x00188c8c     #If Attack hits
00188c78: 00000000 nop                          |
00188c7c: 0c061c54 jal 0x00187150               |-->Faith Calculation Damage becomes Damage*Target Faith/100 * Attacker Faith/100
00188c80: 00000000 nop                          |
00188c84: 0c061c3f jal 0x001870fc               |-->Elemental Absorption HP damage might becomes HP recovery - Changes Attack Type from 0x80 to 0x40 (HP recovery)
00188c88: 00000000 nop                          |
00188c8c: 8fbf0010 lw r31,0x0010(r29)       END
00188c90: 27bd0018 addiu r29,r29,0x0018     
00188c94: 03e00008 jr r31                   
00188c98: 00000000 nop                      

Return location

Battle.bin
 8018b97c - Pre Formula Setup