[WiP] State-Based HP Update

Post » Tue Sep 14, 2010 6:40 am

Hey Everyone!

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!
User avatar
Vahpie
 
Posts: 3447
Joined: Sat Aug 26, 2006 5:07 pm

Post » Tue Sep 14, 2010 8:27 am

Here's a quick summary of the issues I've discovered with State-Based HP:

? Advancing to level 2 provides twice the endurance-based health gain that it should. The script, which is supposed to give you endurance/10 health per level up, instead just gives you endurance/10 health per level (counting the first). It only does this after you move past level one, though.

? Stat gains provided by birthsigns will not count towards your "base" health (the average value of your strength and endurance stats) at level one. Combined with the above issue, expect to see a large health increase upon reaching level 2.

? The mod's calculation for "base" health is supposed to ignore the game's default health bonus for a high starting strength stat. However, this bonus will remain with a newly-created character throughout the game unless you go back to adjust anything at the final confirmation before your papers are stamped at the census office. Electing to alter your name, race, class, or birthsign - even if you don't actually make a change - will remove the bonus. Again, this bug only affects new characters.

---------------------------------------------------------------------------------------------------------

Additionally, three more issues arise if you're using this mod in conjunction with the "Character" portion of my own BTB's Game Improvements mod. This is due to the inclusion of the Level Up Birthsign Remover script in my mod, which State-Based Hit Points seems to have a hard time getting along with.

The additional issues are as follows:

? The "base" health for characters with The Lord birthsign (which grants an Endurance boost in my mod) will always be slightly (and inconsistently) off. The cumulative health gains per level remain correct, however.

? A level 1 character with The Lord or The Warrior birthsigns will have their maximum health incorrectly calculated to a value of 30 after either leaving the excise office or saving/reloading the game (I'm still unsure as to what exactly triggers it). This problem goes away after reaching level 2.

? Changing your birthsign too much during the character creation process (specifically to and from The Lord or The Warrior) causes something to zero out in the process, causing you to die immediately after signing your release papers. You die from filling out paperwork, basically.



That being said, I don't know enough about scripting to say whether or not your edits fix any or all of these issues. Any input?
User avatar
Melanie Steinberg
 
Posts: 3365
Joined: Fri Apr 20, 2007 11:25 pm

Post » Tue Sep 14, 2010 7:28 am

Here's a quick summary of the issues I've discovered with State-Based HP:

? Advancing to level 2 provides twice the endurance-based health gain that it should. The script, which is supposed to give you endurance/10 health per level up, instead just gives you endurance/10 health per level (counting the first). It only does this after you move past level one, though.

? Stat gains provided by birthsigns will not count towards your "base" health (the average value of your strength and endurance stats) at level one. Combined with the above issue, expect to see a large health increase upon reaching level 2.

? The mod's calculation for "base" health is supposed to ignore the game's default health bonus for a high starting strength stat. However, this bonus will remain with a newly-created character throughout the game unless you go back to adjust anything at the final confirmation before your papers are stamped at the census office. Electing to alter your name, race, class, or birthsign - even if you don't actually make a change - will remove the bonus. Again, this bug only affects new characters.

---------------------------------------------------------------------------------------------------------

Additionally, three more issues arise if you're using this mod in conjunction with the "Character" portion of my own BTB's Game Improvements mod. This is due to the inclusion of the Level Up Birthsign Remover script in my mod, which State-Based Hit Points seems to have a hard time getting along with.

The additional issues are as follows:

? The "base" health for characters with The Lord birthsign (which grants an Endurance boost in my mod) will always be slightly (and inconsistently) off. The cumulative health gains per level remain correct, however.

? A level 1 character with The Lord or The Warrior birthsigns will have their maximum health incorrectly calculated to a value of 30 after either leaving the excise office or saving/reloading the game (I'm still unsure as to what exactly triggers it). This problem goes away after reaching level 2.

? Changing your birthsign too much during the character creation process (specifically to and from The Lord or The Warrior) causes something to zero out in the process, causing you to die immediately after signing your release papers. You die from filling out paperwork, basically.



That being said, I don't know enough about scripting to say whether or not your edits fix any or all of these issues. Any input?


Hey BTB! I'm the guy who corrosponded with you by e-mail a while back about fixing the problems with the weapons compilation mod! I still love your list of mods, by the way! I think they add just the right touch to Morrowind without changing the original gameplay too much. Just balance and bug fixes plus a dash and a pinch of variety! :)

I discovered some problems with my script, however, and so I am going to make some more edits, and I am even considering a complete rewrite of his original script. However, I still plan on giving him credit for writing the original.

I should have a post with my updated work soon.
User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am

Post » Tue Sep 14, 2010 1:08 am

OK! I finally finished the script! I did many tests, and will include a link to a seperate text file that includes the test results. I changed the script mainly to include support for Fortified HP AND HotFusion's original support for Mod's that add HP directly to the character. The only feasible way to make these two things compatible was to force the player to manually edit the HF_ExtraHP variable in the console each time he plays his game. Should'nt be too much of a hassle, as it is a global variable. No worries though, I don't think many mods use this silly feature anyway.

Here is the final draft and the link to the test results. If you guys can give me some input, and don't find any potential glitches or loopholes, then I will upload the final product for download. :)

Final Draft + Test Results ( The formatting on the forums ruins my test result layout):

Link: http://www.2shared.com/document/rh2OCAlN/Script.html

And just the Final Draft:


Begin HF_StateBasedHP


float CurrentHP
float MaxHP
float BasicLife
float Damage
float FortHP
float LeveledHP
float FirstLevelHPBonus
float Test
float Check
short Level
short Endur
short Str
short DoOnce


if ( DoOnce == 0 )
set Endur to ( Player->GetEndurance )
set Str to ( Player->GetStrength )
set Level to ( Player->GetLevel )
set CurrentHP to ( Player->GetHealth )
set MaxHP to ( CurrentHP / Player->GetHealthGetRatio )
set Damage to ( CurrentHP - MaxHP )
set LeveledHP to ( ( Endur / 10 ) * ( Level - 1 ) )
set FirstLevelHPBonus to ( ( Endur + Str ) / 2 )
set BasicLife to ( LeveledHP + FirstLevelHPBonus )
set FortHP to ( MaxHP - BasicLife )
set MaxHP to ( BasicLife + FortHP + HF_ExtraHP)
Player->SetHealth, MaxHP
Player->ModHealth, Damage
set Check to BasicLife
set DoOnce to 1
endif


if ( Player->GetHealthGetRatio == 0 )
return
endif


set CurrentHP to ( Player->GetHealth )
set Test to ( CurrentHP / Player->GetHealthGetRatio )
set FortHP to ( Test - Check )


if ( Endur == Player->GetEndurance )
if( Str == Player->GetStrength )
return
endif
endif


set Endur to ( Player->GetEndurance )
set Str to ( Player->GetStrength )
set Level to ( Player->GetLevel )
set CurrentHP to ( Player->GetHealth )
set MaxHP to ( CurrentHP / Player->GetHealthGetRatio )
set Damage to ( CurrentHP - MaxHP )
set LeveledHP to ( ( Endur / 10 ) * ( Level - 1 ) )
set FirstLevelHPBonus to ( ( Endur + Str ) / 2 )
set BasicLife to ( LeveledHP + FirstLevelHPBonus )
set MaxHP to ( BasicLife + FortHP + HF_ExtraHP)
Player->SetHealth, MaxHP
Player->ModHealth, Damage
set Check to BasicLife


End

User avatar
Sammykins
 
Posts: 3330
Joined: Fri Jun 23, 2006 10:48 am

Post » Tue Sep 14, 2010 11:49 am

Hey BTB! I'm the guy who corrosponded with you by e-mail a while back about fixing the problems with the weapons compilation mod!


Yeah, I recognized you.

I still love your list of mods, by the way! I think they add just the right touch to Morrowind without changing the original gameplay too much. Just balance and bug fixes plus a dash and a pinch of variety! :)


Well, thanks. That was my aim.

I discovered some problems with my script, however, and so I am going to make some more edits, and I am even considering a complete rewrite of his original script. However, I still plan on giving him credit for writing the original.

I should have a post with my updated work soon.


M'kay, well... I'll be here. Good luck.
User avatar
Hella Beast
 
Posts: 3434
Joined: Mon Jul 16, 2007 2:50 am


Return to III - Morrowind