(ASM) Help with implementing FE5 steal mechanics in FE7 (Solved)

So I’m trying to make it so players can steal any item so long as the Thief’s STR is higher than the item’s weight and I’ve ALMOST got it working perfectly, but there is one problem with my hack at the moment: Is a player unit moves next to an enemy it can steal from, but that enemy has no items weighing less than the unit’s STR, the game resets. I’m wondering if anyone can help pinpoint the error.

In the vanilla game, at 0x8016D50 is the part of the code that checks if each item in the enemy inventory is an item, which is as follows:

ldrb r1, [r1, #0x7]
mov r0, #0x0
cmp r1, #0x9
bne $08016d5a
mov r0, #0x1
bx lr (this is what the BNE links to)

So I replaced that with:

ldr r0, =0x08D00301
bx r0

And then at 0x8D00301 is the new code I wrote:

	push {r2}
	ldrb r1, [r1, #23]
	mov r0, #0x0
	ldr r2, =0x3004690
	ldr r2, [r2]	
	add r2, #20
	ldrb r2, [r2]
	cmp r2, r1
	blt fails
	mov r0, #0x1
	pop {r2}
	bx lr

So I’m wondering if I accidentally wound up whatever tells the game not to give the Steal command if there’s nothing to steal or whatever. Any help with this would be appreciated as I’ve always wanted to change the steal mechanic to something more fun :slight_smile:


Thanks, Brendor!

…Wait, what’s the deal with the original code? byte 7 of the item struct isn’t the ID is it? because my chart says item id 9 is Rapier… why would that be specially excluded from listing for stealing while everything else shows up?

weapon struct index 7 is weapon type; it’s so you can’t steal weapons

the first jump that checks if the ID is 0 jumps to the bx r0
so just change 8016D3E to bx lr


Thank you very much! It works great now.

just a side note but I’d suggest using the total strength function that adds the weapon boost, otherwise it’ll return false even if the total strength is higher