Hey Everyone!
Recently, I have been anolyzing HotFusion's State-Based HP Mod because I find that it's design is just not adequate for what I want in the game. The script causes incompatibility with Fortify Health and Fortify Endurance and Fortify Strength effects, resulting in all kinds of strange and detrimental permanent effects on your maximum health points.
So, not knowing how to contact HotFusion, I took the liberty to modify his script. I believe that I have sorted out all of the problems, and hope that some of you more experienced guys could help proof read my changes and look for any kind of loopholes or problems I may have missed!
This that I added are in BLUE. I didn't bother to show the things that I removed. I will post his original in GREEN. The problems that his original one causes are rather obvious by the way, or so I think.
By the way, I've never written a script before in my life, but I find this all so similar to simple mathematics and logic you learn in college, that I had no problems picking it up in just a couple of hours!
Thanks in advance!
Begin HF_StateBasedHP
float CurrentHP
float MaxHP
float Test
float Check
float Damage
short Endur
short Level
short FirstLevelHPBonus
short Str
short DoOnce
If ( DoOnce == 0 )
set CurrentHP to ( Player -> GetHealth )
set MaxHP to ( CurrentHP / Player -> GetHealthGetRatio )
set Check to MaxHP
set DoOnce to 1
Endif
If ( Player -> GetHealthGetRatio == 0 )
return
Endif
If ( Endur == Player -> GetEndurance )
If ( Str == Player -> GetStrength )
return
Endif
Endif
set Test to ( Player -> GetHealth )
set Test to ( Test / Player -> GetHealthGetRatio )
set HF_ExtraHP to ( HF_ExtraHP + ( Test - Check ) )
set Endur to ( Player -> GetEndurance )
set Str to ( Player -> GetStrength )
set CurrentHP to ( Player -> GetHealth )
set MaxHP to ( CurrentHP / PLayer -> GetHealthGetRatio )
set Damage to ( Player -> GetHealth )
set Damage to ( Damage - MaxHP )
set Level to ( Player -> GetLevel )
set MaxHP to ( Endur / 10 )
set MaxHP to ( MaxHP * ( Level - 1 ) )
set FirstLevelHPBonus to ( Endur + Str )
set FirstLevelHPBonus to ( FirstLevelHPBonus / 2 )
set MaxHP to ( MaxHP + FirstLevelHPBonus + HF_ExtraHP )
Player -> SetHealth, MaxHP
Player -> ModCurrentHealth, damage
set Check to MaxHP
End
I ran many numerical tests using different character conditions such as different combinations of Fortify effects and levels of damage, etc. It all came out correct, so for now, I don't see any errors with my script and it seems to be completely superior to HotFusion's old script.
The original:
Begin HF_StateBasedHP
float CurrentHP
float MaxHP
float damage
float test
short Endur
short level
short FirstLevelHPBonus
short Str
short DoOnce
If ( DoOnce == 0 )
set CurrentHP to Player -> GetHealth
set DoOnce to 1
set MaxHP to ( CurrentHP / PLayer -> GetHealthGetRatio )
Endif
If ( Player -> GetHealthGetRatio == 0 )
return
Endif
set CurrentHP to Player -> GetHealth
set test to ( CurrentHP / PLayer -> GetHealthGetRatio )
If ( test != MaxHP )
set HF_ExtraHP to ( test - MaxHP )
set MaxHP to test
set damage to ( Player -> getHealth )
set damage to ( damage - MaxHP )
Player -> SetHealth, MaxHP
PLayer -> ModCurrentHealth, damage
Endif
If ( endur == Player -> GetEndurance )
If ( Str == Player -> GetStrength )
return
Endif
Endif
set Endur to ( PLayer -> GetEndurance )
set Str to ( Player -> GetStrength )
set CurrentHP to Player -> GetHealth
set MaxHP to ( CurrentHP / PLayer -> GetHealthGetRatio )
set damage to ( Player -> getHealth )
set damage to ( damage - MaxHP )
set level to ( Player -> GetLevel )
set MaxHP to ( Endur / 10 )
set MaxHP to ( MaxHP * ( level - 1 ) )
set FirstLevelHPBonus to ( Endur + Str )
set FirstLevelHPBonus to ( FirstLevelHPBonus / 2 )
set MaxHP to ( MaxHP + FirstLevelHPBonus + HF_ExtraHP )
set test to MaxHP
Player -> SetHealth, MaxHP
PLayer -> ModCurrentHealth, damage
End
I found many things in his original to be very silly, inefficient and redundant.
Thanks!