anco’s blog

My assumptions were wrong

this is part 2 of a series of devlogs trying to improve Monster Hunter 4 Ultimate's quality of life.
Check out part 1

On my previous post, I wrote:

I'm in a place were I should be able to edit the entire crafting table

Uh-oh, that's not entirely correct. Turns out, I was kinda lucky.

## The assumptions

Mimicking Monster Hunter World/Rise crafting ingredients and results Yeah, not quite. Let's get out of the way the fact that I'm not crafting from a single item (1x Herb = 1x Potion), but rather from two of the same items (2x Herbs = 2x Potions). But that's not even the issue.

I had a specific result in mind, so I was happily editing precious hex values. Default crafting is Herb + Blue Mushroom and I want it to be Herb + Herb, simple right? Just change the value stored somewhere that contains the item ID for Blue Mushroom, and patch in the Herb's item ID.
I had reached a point where I thought I could do that, easy peasy. And making the change, it worked! I was so happy.

That's the part where I got a bit lucky.

Them hacks

Here's an excerpt of the items we want to change

Item Name Item ID (hex) Item ID (decimal)
Herb B1 177
Blue Mushroom BD 189
Potion 08 8

I included the item IDs as decimal values even though I've been dealing with hexadecimals for a while now, because it makes the explanation easier. The change I did can be described as replacing 189 for 177 somewhere important.
What we have is
item 1 (177) + item 2 (189) = result (08).
And I want:
item 1 (177) + item 2 (177) = result (08)

I you're thinking "Huh, luckily the new value (177) is not less than the item 1's ID." then you're onto something.
If you attempt to change so that item 2 is something lower than 177, suddenly nothing works. And by nothing works I mean the game can crash. Oopsies.

Also, the fact that here I'm attempting to change the second item in the equation is also a lucky bit. If I wanted to change the first item (or item 1 as mentioned before), I would have been in trouble. To explain why I would have to explain how the values are laid out in memory, but that's for another time.

Conclusions

We don't have to edit the value in a single place in order for it to work, so I'm still trying to figure out if there's something else I'm missing that I must change, or if it's not supported due how the game is programmed.
My hunch for now is the latter, since they may be doing some fancy arithmetics to get the items required and the combination result, and that allows them to run some assumptions. If I break those assumptions hacking values in, the game does not know what to do and can't show you what to combine at best, and crashes at worst.

That said, I still think I'm on may way to edit the entire crafting list. I just need to figure out some details. Worst case scenario I would have to patch in an entirely new function that calculates the combos, but hopefully I can get by without.

Note: the game does not crash1 in emulators, which can be useful to debug sometimes. That's expected, since emulators tend to leave more leeway for things to break. Still, in this case the game not crashing is not that useful, other than not having to restart my 3DS :).


  1. I mean this specific crash, not any crash.

#devlog #mh4u_qol