[FE8] Set weapon to consume durability even upon a miss

So, in vanilla Fire Emblem after a certain point (not sure exactly what game started this; I know it wasn’t FE1), whenever a character attacks using a magic tome (or a ballista), durability is consumed even if the attack misses, while misses with physical weapons do not consume durability.

How does the game determine which weapons handle misses which way? I can only assume some kind of separate internal list, because I’m not seeing any flag in FEBuilder that’s labeled as having that effect (and checking if at least one out of “Attacks res” and “Uncounterable” is set feels clumsy to me, although that could be the way it’s implemented, I suppose)

I’m looking to set the “decrement durability even if attack misses” property on Bows and give them higher total durability to compensate, but I’m not sure how to actually go about doing that.

…Actually, I’d be fine with “While at least one of [WEAPON TYPE = TOME] and [COMBAT RANGE ≥ 2] is true, decrement weapon durability even if unit’s attack misses” as a solution, too, since that property also makes sense to apply to throwing weapons like Javelins and Hand Axes.

At any rate, what I’m really looking for is to learn how to alter this, if it’s known! I would love to and in fact want to learn how to do it myself.

1 Like

That is exactly how it’s implemented. The check is at 2B80C.

1 Like

Oh, sick.

I don’t suppose I could trouble you for a brief run-through of how to change it so that it checks just Ability 3 flag 7 (the first “??” ability flag in FEBuilderGBA), instead? That way there could be a dedicated flag for it that doesn’t overlap with other stuff. I’d imagine it’d just be a matter of changing two values to get it done super fast, even if that ends up with it technically checking that same flag twice when it doesn’t need to.

FE8J has a patch like this one.
It doesn’t seem to translate very correctly.

NAME=弓とかは外しても減る
TYPE=EA
TAG=#ENGINE

//既に適応されたかどうか
PATCHED_IF:0x2B74C=0x00 0x4B 0x9F 0x46
EA=EA.txt

INFO=弓などの間接武器を、ミスして外した場合も、耐久を1つ減らすように変更します。

AUTHOR=aera
NAME.en=Even if you remove the bow, it will be reduced
INFO.en=Even if you mistake and remove an indirect weapon such as a bow, change it to reduce durability by one.

This patch will also make the bow, like the magic book, reduce its durability if you make a mistake.
However, it was not ported to FE8U.
Perhaps they didn’t port it because it conflict with SkillSystems.
This patch hooks up 0x2B74C(FE8J) , 0x2B804(FE8U).
However, I don’t think it works well because it starts hooking SkillSystems from 0x0802B7F8 (FE8U).

1 Like

Sure.

Here’s the original code, starting at 2B804

ldr r0,[r5,#0x4C] @ r5 = battle struct, +0x4C is the item's "ability word"
mov r1,#0x82 @ 0x80 (uncounterable flag) + 0x2 (magic)
and r0,r1 @ remove all other bits
cmp r0,#0 @ are either of those bits set?
beq #0x802B828 @ if they're not, go to 2B828 (which skips the item decrementing bit)

We want to change the mov r1,#0x82 to mov r1,#0x400000 (at least, I think this is the right one?). However, we can’t do that directly, because mov only takes arguments up to 1 byte, and 0x400000 is bigger than a byte. So we’re going to do use mov r1,#0x40 and left shift by 0x10 to get 0x400000. Unfortunately, that takes up an extra opcode, which there isn’t room for. But wait, we can substitute tst r0,r1 for and r0,r1; cmp r0,#0!

ldr r0,[r5,#0x4C] @ r5 = battle struct, +0x4C is the item's "ability word"
mov r1,#0x40
lsl r1,r1,#0x10 @ now we have 0x400000 in r1
tst r0,r1
beq #0x802B828

Now we turn this into byte code using the debugger. The first and last lines are identical, so all you have to do is write 40 21 09 04 08 42 to 2B806, and update tomes and ballistae to use that flag (because now we’re not checking for magic/uncounterable flags anymore).

If you want to understand more about what I did here, check out Assembly for Dummies.

2 Likes

Thanks a bunch! This was precisely what I was looking for!

And hey, with this, I also know how to make it check any flag I want, which is cool, too!

I really appreciate the help!

You’re quite welcome!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.