Author Topic: Level-up stat increases  (Read 2315 times)

kerihobo

  • *
  • Posts: 6
    • View Profile
Level-up stat increases
« on: 2019-05-29 13:08:03 »
Hi, I'm hoping someone can shed some light on how I'm misunderstanding the formulae described in Section 1.4 of the following guide:
https://gamefaqs.gamespot.com/pc/130791-final-fantasy-vii/faqs/36775
I think I have the primary and luck stat growth working just fine, however I am very confused about how HP/MP is calculated.

I am not getting very predictable results, which is a problem because according to the following wiki article:
https://finalfantasy.fandom.com/wiki/Final_Fantasy_VII_stats
The stats should be completely predictable (give or take).

Here is my specific C# code as I try to replicate it, my problem is I have no idea how to check where my steps are wrong because in the above guide, it doesn't really say what numbers to expect from different parts of the function...

Code: [Select]
int lv = 7;     // The level we JUST achieved.
int hp = 314;   // Our unchanged HP from level 6.
int b = 200;    // Base from the current rank curve.
int g = 19;     // Gradient from the current rank curve.

void IncrementPointsBase() {
    // This seems to get my FROMLevel's HP just fine...
    int baseline = b + ((lv - 1) * g);
   
    // I don't know what sort of number I'm hoping to get from this...
    int difference = Random.Range(1, 8) + (100 * baseline / hp) - 100;

    // The guide says to cap the difference between 0% & 11%... of what? The difference? The current HP?
    // I really don't understand this particular step.
    int cappedDifference = (int)Mathf.Clamp(difference, 0, hp * 0.11f);
« Last Edit: 2019-05-30 02:10:48 by kerihobo »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Level-up stat increases
« Reply #1 on: 2019-05-29 18:20:02 »
Don't do any floating point calculations. I'm not sure how it works in C#, but by default in VB.NET it seems to want to do floating point divisions. I have to explicitly state I'm doing integer divisions. This can introduce rounding errors that will build up as you increase the level.

As for the difference, you already have it.

Code: [Select]
  int difference = Random.Range(1, 8) + (100 * baseline / hp) - 100;
That value will tell you what you need to know. It should be between 0 and 11, not whatever the .11 you're multiplying it as. Truncate the decimal points from this value and cap it at 11. Then use the HP Stat Gain table to get the HP gain for that level. The calculated percentage multiplied by whatever the curve's gradient is at the level you're moving to.

Code: [Select]
  int increaseHP = Math.Floor((bonusHP[cappedDifference] * g) / 100);
  int newHP = hp + increaseHP;

Any particular reason you're using Unity to calculate this?

kerihobo

  • *
  • Posts: 6
    • View Profile
Re: Level-up stat increases
« Reply #2 on: 2019-05-29 22:55:55 »
Thank you so much for your reply. I trial/errored 0-11 instead of 0-11% (AKA val*.11) and it seems to be in range of the numbers I expect. The guide DOES describe expected outcomes for primary stats but not for HP/MP so I guess I've had trouble being sure of the results. 

The reason I multiplied by .11 is because the guide specifically says:

Quote
The Difference is then capped between 0 and 11%, and the Stat Gain is looked
up on the following tables:

                      HP                                MP
            Difference   Stat Gain            Difference   Stat Gain
                 0%         40%                    0%         20%
                 1%         50%                    1%         30%
                 2%         50%                    2%         30%
                 3%         60%                    3%         50%
                 4%         70%                    4%         70%
                 5%         80%                    5%         80%
                 6%         90%                    6%         90%
                 7%        100%                    7%        100%
                 8%        110%                    8%        110%
                 9%        120%                    9%        120%
                10%        130%                   10%       140%
                11%        150%                   11%       160%

So I see it is not 0%-11%, but rather 0-11 eh? Perhaps an error in the way the guide was written. C# rounds down after converting floats to ints, basically truncation, I can floor it but no need. That's great, though. It answers another question I had about how frequently I should be turning to floats, so it seems the answer is somewhere along the lines of 'never'?

As for why I'm using Unity, it's just my weapon of choice I guess. I've never developed in any other environments, to my detriment. I'm not making a calculator so much as attempting to faithfully rebuild the opening bombing mission for funzies and also to learn and gain insights from the process overall. I love the game so much, I'd consider my life lived by doing this lol.
« Last Edit: 2019-05-30 02:28:08 by kerihobo »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Level-up stat increases
« Reply #3 on: 2019-05-30 04:19:47 »
You don’t need to defend your choice of unity. I just didn’t understand the scope of what you are trying to accomplish. If you only wanted a level/stat calculator then a 3D environment  builder seems to be the wrong direction for an interface. :) Nowadays I’d probably pick something more “universal” like HTML5 or so.

kerihobo

  • *
  • Posts: 6
    • View Profile
Re: Level-up stat increases
« Reply #4 on: 2019-05-30 14:22:49 »
Weird, my HP seems to work fine but my MP not so much... I swear I'm following the GameFAQs guide perfectly...

According to the stat brackets on the wiki, my logged results are not correct:


I'll post an image of my code instead of text for syntax highlighting:


My logs are... correct... most of the time????? 0_o
« Last Edit: 2019-05-30 14:27:41 by kerihobo »