Author Topic: FF8 correct HP formula?  (Read 2616 times)

Sebanisu

  • *
  • Posts: 171
    • View Profile
FF8 correct HP formula?
« on: 2019-05-09 23:45:31 »
I put in the formula for max hp from doomtrain and i'm getting a different number than the one in game.

Squall has 529 max hp. At level 8 with no junctions.

Code: [Select]
            public int HP(byte lvl, byte magic_J_val=0,byte magic_count=0, byte stat_bonus=0, byte percent_mod=100)
            {
                return (int)((magic_J_val * magic_count + stat_bonus + lvl * _HP[0] - (10 * lvl ^ 2) / _HP[1] + _HP[2]) * percent_mod) / 100;
            }
the formula gives me 531

I used the formula that pops up if you click the button.

I have the 3 hp vars in an array. Well there are four but I think the fourth is always zero.

Anyone have an idea?
« Last Edit: 2019-05-09 23:49:55 by Sebanisu »

Sebanisu

  • *
  • Posts: 171
    • View Profile
Re: FF8 correct HP formula?
« Reply #1 on: 2019-05-09 23:49:26 »
well changing percent_mod to a double and 99.62335216572505 got the right answer but unsure if that's correct. :P

Code: [Select]

            public int HP(byte lvl, byte magic_J_val=0,byte magic_count=0, byte stat_bonus=0, double percent_mod= 99.62335216572505)
            {
                return (int)((magic_J_val * magic_count + stat_bonus + lvl * _HP[0] - (10 * lvl ^ 2) / _HP[1] + _HP[2]) * percent_mod) / 100;
            }

probably not right as it only worked for squall and unsure if it'd continue to work because all my saves are him at lvl 8 pretty much heh.
« Last Edit: 2019-05-10 00:14:17 by Sebanisu »

JWP

  • *
  • Posts: 194
    • View Profile
Re: FF8 correct HP formula?
« Reply #2 on: 2019-05-10 08:34:31 »
I can tell you that the game uses integers and there's a little more info here: http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609

I can take another look when I get some time.

Sebanisu

  • *
  • Posts: 171
    • View Profile
Re: FF8 correct HP formula?
« Reply #3 on: 2019-05-10 16:27:34 »
That post will help a lot. Ty. Alot of those formulas in one place I gotta make them into functions.

Sent from my Pixel XL using Tapatalk


JWP

  • *
  • Posts: 194
    • View Profile
Re: FF8 correct HP formula?
« Reply #4 on: 2019-05-10 16:50:00 »
Seems fine to me.
Code: [Select]
default for Squall:
_HP[0] = 44
_HP[1] = 255
_HP[2] = 179
((magic_J_val * magic_count + stat_bonus + lvl * _HP[0] - (10 * lvl ^ 2) / _HP[1] + _HP[2]) * percent_mod) / 100;
part1 = magic_J_val * magic_count + stat_bonus = 0
part2 = lvl * _HP[0] = 8 * 44 = 352
part3 = (10 * lvl ^ 2) / _HP[1] = (10 * 64)/255 = 640/255 = 2 (truncated because of integer arithmetic)
percent_mod = 100
((0 + 352 - 2 + 179)*100)/100 = 529

Sebanisu

  • *
  • Posts: 171
    • View Profile
Re: FF8 correct HP formula?
« Reply #5 on: 2019-05-10 23:16:59 »
Odd. I must have something wrong. Thanks for checking.

-- update --

I thought lvl^2 was squaring lvl. I'm not sure what it's doing but lvl^2 = 10; I had to use (int)Math.Pow(lvl,2) or lvl*lvl

A quick google I guess the ^ is an xor operator in c# lol
https://www.dotnetperls.com/xor
« Last Edit: 2019-05-11 01:16:42 by Sebanisu »