Rare/common item determination

From Final Fantasy Hacktics Wiki
Revision as of 00:33, 6 September 2024 by RetroTypes (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#Parameters:
    #r4 = Unit pointer


00180230: 27bdffe0 addiu r29,r29,0xffe0
00180234: afb00010 sw r16,0x0010(r29)
00180238: 00808021 addu r16,r4,r0               r16 = unit pointer
0018023c: afbf0018 sw r31,0x0018(r29)
00180240: afb10014 sw r17,0x0014(r29)
00180244: 92040047 lbu r4,0x0047(r16)           r4 = X coordinate
00180248: 96060048 lhu r6,0x0048(r16)           r6 = Y coordinate ++ other position info
0018024c: 92050048 lbu r5,0x0048(r16)           r5 = Y coordinate
00180250: 0c0600b2 jal 0x001802c8               Set map Item/trap data - move-find item check call (X, Y, is_high)
00180254: 000633c2 srl r6,r6,0x0f               r6 = is high elevation
00180258: 34040064 ori r4,r0,0x0064
0018025c: 34050064 ori r5,r0,0x0064
00180260: 92030024 lbu r3,0x0024(r16)           load Brave
00180264: 00408821 addu r17,r2,r0               r17 = move-find item
00180268: 0c017833 jal 0x0005e0cc               Check if Random is greater/equal to Chance - r2 = roll(100, 100 - Brave)
0018026c: 00a32823 subu r5,r5,r3                ^ roll for rare
00180270: 14400004 bne r2,r0,0x00180284         branch if common
00180274: 34040033 ori r4,r0,0x0033             r4 = 0x33 (variable 0x33 = Current map)

if rare:
00180278: 92220002 lbu r2,0x0002(r17)               r2 = rare item
0018027c: 080600a2 j 0x00180288
00180280: 00000000 nop                         

if common:
00180284: 92220003 lbu r2,0x0003(r17)               r2 = common item


00180288: 3c108019 lui r16,0x8019 
0018028c: 2610f8a4 addiu r16,r16,0xf8a4         r16 = 0x8018f8a4 (ID of found item)
00180290: 0c04ed64 jal 0x0013b590               Get Script Variable - load map ID
00180294: a2020000 sb r2,0x0000(r16)            store found item ID
00180298: 00402021 addu r4,r2,r0                r4 = map ID
0018029c: 92250001 lbu r5,0x0001(r17)           r5 = trap flags
001802a0: 0c060131 jal 0x001804c4               Move find item flag calculation - r2, trapflags,itemfound=True
001802a4: 34060001 ori r6,r0,0x0001             r6 = finding item??
001802a8: 2602fffc addiu r2,r16,-0x0004         
001802ac: ae00fffc sw r0,-0x0004(r16)           clear ?? at 0x8018f89c?
001802b0: 8fbf0018 lw r31,0x0018(r29)
001802b4: 8fb10014 lw r17,0x0014(r29)
001802b8: 8fb00010 lw r16,0x0010(r29)
001802bc: 27bd0020 addiu r29,r29,0x0020
001802c0: 03e00008 jr r31
001802c4: 00000000 nop

Return Locations

00072168: Main Post Movement