Post subject: Final Fantasy 2 (FC) - Determining Max HP/Vitality increases
Joined: 12/17/2014
Posts: 1
Hi there, I'm Golden. I'm looking into routing FF2 for the Famicom, and I'm stumbling over exactly how stat upgrades work. Specifically, I would like to know what causes your max HP and vitality to level up. As it stands, there doesn't seem to be any pattern to when one of them levels up over the other; both of them appear to level up when you take a decent amount of damage from a fight. Sometimes they level up together, other times one levels up but not the other. When your maximum HP increases, it increases by a number of points equal to your vitality. Thus, for a speedrun, it would be extremely beneficial if it was possible to consistently level up both stats at the same time, as it would mean significantly fewer encounters required for the early game grind. So far, I have the memory addresses for Firion's current HP (6108 and 6109), max HP (610A and 610B), and vitality (6112). While in battle, Firion's current HP is tracked at addresses 7D84 and 7D85. Aside from these addresses, I've tried looking at the assembly, but with the little knowledge I have I wasn't able to find anything conclusive. I was hoping to find values it might be comparing against your HP at the end of a battle. I do have a save state of the frame before your vitality increases, but beyond that I wasn't able to find any sort of comparison being made in the assembly. Could someone maybe point me in the right direction as to what I might look for next? I don't expect anyone to just jump in and do the work, but I've gotten as far with it as I think I can.
Joined: 7/2/2007
Posts: 3960
You'll probably want to set a breakpoint that triggers when the vitality memory is read, so you can see what bits of assembly code access it. Ideally there'd be some code that looks like
if (some value compares to vitality):
  increase vitality
Then you'd be able to figure out a) what the comparison operator is, and b) what that "some value" is, and possibly where it comes from. However, it's entirely possible that the rule for gaining vitality is something simple like "if you lose a lot of HP and a random number is passed, then gain vitality". In other words, the vitality number might not be used directly in a comparison anywhere. This would be somewhat consistent with other behaviors in FF2 -- for example, Agility isn't looked at directly for determining agility gains; the game only cares about your evasion score. So you'd probably be best off setting a breakpoint on when the vitality value is modified, and then trace backwards from there to try to figure out what the rules for modifying it are.
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
ALAKTORN
He/Him
Former player
Joined: 10/19/2009
Posts: 2527
Location: Italy
Are you sure those addresses are 2 consecutive ones instead of just 1 with a bigger data size? Maybe Firion’s HP is just 6108 with 2 bytes data size.