Users browsing this thread: 1 Guest(s)
Looking for a Poach Command

Posts: 19
Threads: 9
Thanks Received: 4
Thanks Given: 15
Joined: May 2019
Reputation: 2
Hi everyone! Long time no see!

My thief character for my hack is looking to add a Poach command to his arsenal. My plan is to use Metamorph (Ragnarok's esper spell) as the command. I'd like to make it so the command checks how many remaining HP the target has, and fail if it is not below a certain threshold. The threshold can be a set value (seems a lot easier than using a percentage). How/where can I add that check? Here's what the vanilla C2 disassembly has for us:


C2/3A3C: C0 08        CPY #$08       (Checks if target is monster)
C2/3A3E: 90 4A        BCC $3A8A      (branch if not)
C2/3A40: B9 94 3C     LDA $3C94,Y    (Metamorph info: Morph chance in bits 5-7,
                                     and Morph pack in bits 0-4)
C2/3A43: 48           PHA
C2/3A44: 29 1F        AND #$1F       (isolate pack #)
C2/3A46: 20 53 4B     JSR $4B53      (Random number 0 or 1)
C2/3A49: 2A           ROL
C2/3A4A: 20 53 4B     JSR $4B53      (Random number 0 or 1)
C2/3A4D: 2A           ROL
C2/3A4E: AA           TAX            (now we have the Metamorph pack # in bits 2-6,
                                     and a random 0-3 index into that pack in bits 0-1)
C2/3A4F: BF 40 7F C4  LDA $C47F40,X  (get the item we're attempting to Metamorph
                                     the enemy into)
C2/3A53: 8D 35 2F     STA $2F35      (save it in message parameter 1, bottom byte)
C2/3A56: A9 02        LDA #$02
C2/3A58: 8D 28 3A     STA $3A28      (temporary byte 1 for ($76) animation buffer)
C2/3A5B: A9 1D        LDA #$1D
C2/3A5D: 8D 29 3A     STA $3A29      (temporary byte 2 for ($76) animation buffer)
C2/3A60: 20 BE 35     JSR $35BE      (Update a previous entry in ($76) animation buffer
                                     with data in $3A28 - $3A2B)
C2/3A63: 20 AD 35     JSR $35AD      (Write data in $B4 - $B7 to current slot in ($76)
                                     animation buffer, and point $3A71 to this slot)
C2/3A66: 68           PLA
C2/3A67: 4A           LSR
C2/3A68: 4A           LSR
C2/3A69: 4A           LSR
C2/3A6A: 4A           LSR
C2/3A6B: 4A           LSR            (isolate 0-7 Metamorph Chance index)
C2/3A6C: AA           TAX            (copy it to X)
C2/3A6D: 20 5A 4B     JSR $4B5A      (Random number 0 to 255)
C2/3A70: DF C5 3D C2  CMP $C23DC5,X  (compare to actual Metamorph Chance)
C2/3A74: B0 14        BCS $3A8A      (if greater than or equal, branch and fail to
C2/3A76: A3 05        LDA $05,S
C2/3A78: AA           TAX
C2/3A79: AD 35 2F     LDA $2F35      (get ID of Metamorphed item)
C2/3A7C: 9D F4 32     STA $32F4,X    (save it in this character's
                                     "Item to add to inventory" variable)
C2/3A7F: BD 18 30     LDA $3018,X
C2/3A82: 0C 8C 3A     TSB $3A8C      (flag this character to have their inventory
                                     variable checked when the turn ends)
C2/3A85: A9 80        LDA #$80
C2/3A87: 4C 32 0E     JMP $0E32      (Mark death status to be set)
C2/3A8A: 4C 1B 3B     JMP $3B1B      (flag Miss message)

Any suggestions would be greatly appreciated. Thanks!

Posts: 242
Threads: 19
Thanks Received: 101
Thanks Given: 105
Joined: Dec 2018
Reputation: 18
Poach? Like, poaching an egg?

Huh, doesn't matter.

The success/fail check in the code you shared is between C2/3A67 and C2/3A74... it checks certain bits in the A that's restored from earlier and then decides to skip the actual transformation code if the roll fails. This'd be where you want to start; you'll want to change it to check something else instead of rolling.

A good place to start might be checking if the monster has the "Near Fatal" status, and using that as the success condition. The game already has code in place to set/remove Near Fatal when a target is at 1/8th HP.
That has the advantage of being relatively simple to implement. You load Status Byte 2 relative to the target "Y" (that's RAM address $3EE5 I think), run a bit test for bit 2 (that's the Near Fatal status), and then branch accordingly. A BEQ command will skip code if the bit is clear, which is what you'd want.

My best guess (untested)...
B9 E5 3E       LDA $3EE5,Y
89 02            BIT $#02
F0 ??            BEQ skip ?? bytes to go to exit at C2/3A8A, if bit 2 was clear


B9 E5 3E       LDA $3EE5,Y
89 02            BIT $#02
D0 03            BNE skip next line if bit 2 was set
4C 76 3A       JMP $3A76       Continue Metamorph code
4C 1B 3B       JMP $3B1B       or mark as a miss

Both will fit in line, but I'm wary of the relative value load to A after the branch in the original code, since I don't understand what it does.
Try it, but I give no guarantees.

Using Near Fatal as the failure condition does have the disadvantage of being tied to the status, though... which means if you want to tweak the proportion of HP that makes the move work, you're also tweaking when Desperation Attacks become available and when character animate as 'hurt'.
[-] The following 1 user says Thank You to C-Dude for this post:
  • Morendo (09-03-2020)

Posts: 19
Threads: 9
Thanks Received: 4
Thanks Given: 15
Joined: May 2019
Reputation: 2
Poach, as in killing an animal for its tusks, etc. FFXII renamed "Morph" to "Poach", and I like it. Smile

Thanks for the help! I'll check it out over the next couple days and let you know how it works out!

Update: Your code appears to have worked! Victory

Forum Jump:

Users browsing this thread: 1 Guest(s)

Theme by Madsiur2017Custom Graphics by JamesWhite