Qhimm.com Forums
Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: Sebanisu 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.
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?
-
well changing percent_mod to a double and 99.62335216572505 got the right answer but unsure if that's correct. :P
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.
-
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 (http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609)
I can take another look when I get some time.
-
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
-
Seems fine to me.
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
-
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