Add price of item / 4 to total gil

From Final Fantasy Hacktics Wiki
(Redirected from 0018ea98 - 0018eb4c)
Jump to navigation Jump to search
Parameters : r4 = Unit data pointer
             r5 = 0x00 if Break/Steal - Gil Amount (if r6 = 0x00)
             r6 = Item ID (0x00 for steal gil)
Returns : r2 = Item price / 4
          r2 = 0x00 if Imput value <> 0x00 or Unit is not in player Team
--------------------------------------------------------------------------------
0018ea98: 3c028019 lui r2,0x8019            |
0018ea9c: 8c42f5fc lw r2,-0x0a04(r2)        |Action state
0018eaa0: 27bdffe8 addiu r29,r29,-0x0018    |
0018eaa4: afb00010 sw r16,0x0010(r29)       |
0018eaa8: 00a08021 addu r16,r5,r0           |r16 = Input Value
0018eaac: 14400006 bne r2,r0,0x0018eac8     #If Action is being executed
0018eab0: afbf0014 sw r31,0x0014(r29)           |
0018eab4: 90820005 lbu r2,0x0005(r4)            |r2 = Targeted Unit ENTD flags
0018eab8: 00000000 nop                          |
0018eabc: 30420030 andi r2,r2,0x0030            |r2 <> 0x00 if Targeted Unit is not in Player Team
0018eac0: 10400003 beq r2,r0,0x0018ead0         #If Targeted Unit is not in player Team
0018eac4: 30c600ff andi r6,r6,0x00ff            |r6 = Item ID
0018eac8: 08063acf j 0x0018eb3c             #E      >>Jump to  END (r2 = 0x00)
0018eacc: 00001021 addu r2,r0,r0                    |r2 = 0x00
                                            #Else (Action executed and Targeted Unit is in player Team)
0018ead0: 10c00009 beq r6,r0,0x0018eaf8     #If Item ID is <> 0x00
0018ead4: 00061040 sll r2,r6,0x01               |r2 = Item ID * 2
0018ead8: 00461021 addu r2,r2,r6                |r2 = Item ID * 3
0018eadc: 00021080 sll r2,r2,0x02               |r2 = Item ID * 12 (size of item data)
0018eae0: 3c018006 lui r1,0x8006                |
0018eae4: 00220821 addu r1,r1,r2                |
0018eae8: 94222ec0 lhu r2,0x2ec0(r1)            |r2 = Item price  0x80062eb8 + 0x08 + Item Offset
0018eaec: 00000000 nop                          |
0018eaf0: 00021082 srl r2,r2,0x02               |r2 = Item price/4
0018eaf4: 02028021 addu r16,r16,r2              |r16 = Input Value + Item price/4
0018eaf8: 0c04ed64 jal 0x0013b590           |-->Get_Script_Variable  Returns r2 = War funds
0018eafc: 3404002c ori r4,r0,0x002c         |r4 = 0x2c (War Funds Variable)
0018eb00: 00502821 addu r5,r2,r16           |r5 = War funds + Item price/4
0018eb04: 3c0205f5 lui r2,0x05f5            |r2 = 0x05f50000
0018eb08: 3442e0ff ori r2,r2,0xe0ff         |r2 = 0x05f5e0ff
0018eb0c: 0045102a slt r2,r2,r5             |r2 = 0x01 If  0x05f5e0ff < War funds  99 999 999 gils !!!
0018eb10: 10400004 beq r2,r0,0x0018eb24     #If War funds > 99 999 999 gils
0018eb14: 00000000 nop                          |
0018eb18: 3c0505f5 lui r5,0x05f5                |
0018eb1c: 08063acc j 0x0018eb30                 >>jump to store new war funds = 99 999 999 gils
0018eb20: 34a5e0ff ori r5,r5,0xe0ff             |r5 = 0x05f5e0ff
0018eb24: 04a10002 bgez r5,0x0018eb30       #If War funds < 0 Gils
0018eb28: 00000000 nop                          |
0018eb2c: 00002821 addu r5,r0,r0                |r5 = 0x00 ( 0 gils)
0018eb30: 0c04ed91 jal 0x0013b644           |-->Set_r5_as_New_Variable_Value Store new War Funds value
0018eb34: 3404002c ori r4,r0,0x002c         |r4 = 0x2c (War Funds Variable)
0018eb38: 02001021 addu r2,r16,r0           |r2 = Item price/4
0018eb3c: 8fbf0014 lw r31,0x0014(r29)       
0018eb40: 8fb00010 lw r16,0x0010(r29)       
0018eb44: 27bd0018 addiu r29,r29,0x0018     
0018eb48: 03e00008 jr r31                   
0018eb4c: 00000000 nop                      

Return locations

Battle.bin
0018c1f4: Attack_Finalisation_&_Reaction_Flagging
0018ea80: Item_quantity_increment_for_steal/break?