[BETA] Natural Healing v2

Post » Wed Jul 13, 2011 9:55 pm

I'm looking for a bit of testing, etc, for my mod Natural Healing.

The mod is designed to let you regain health naturally over time, this new version is a complete rewrite, and uses willpower, and other factors to determine how quickly you regain health. A new feature is a self adjusting update interval, which makes sure that you regain health more quickly with minor injuries, and much slower with large injuries. (It's scaled between 3-30 seconds by default.)

It has two modifiers intended for users, which allow you to customize the amount of health regained at each update, and to tweak the interval itself.

Modifiers

float HealthModifier
float UpdateModifier

These can be adjusted in the console.

// This controls the amount of health you will regenerate.
Set aaaNaturalHealing.HealthModifier to 0.05

// This scales between the number you set, and it's value times by 10 (5-50)
Set aaaNaturalHealing.UpdateModifier to 5

I'm mainly looking to get it balanced enough, that most anyone would feel comfortable using it. (I may try factoring other things in, like Endurance, etc,. Feel free to make suggestions on what you feel would make most sense, etc,.)

-----

Download (Be sure to get v2 it's listed as "Optional" and not the "Main" file, which is v1.)
http://www.tesnexus.com/downloads/file.php?id=39369

Requires: Tribunal or Bloodmoon (Uses "Start Script" in the CS.)

-------

Here is the source code, see what you think of the formula, etc, let me know if you see any obvious issues, etc,.

Updated: Added bottomlimit for setting a cut off range, and a workaround that attempts to detect combat, and adjusted the values a bit.

Spoiler

Begin aaaNaturalHealing; First Runshort DoOnce; Timerfloat Timerfloat UpdateInterval; Healthfloat HealthPercentagefloat CurrentHealthfloat MaxHealth; Willpowerfloat WillPercentagefloat CurrentWill; Modifiersfloat BottomLimitfloat HealthModifierfloat UpdateModifier; Combat Detection ( Workaround: Detecting Combat )float LastHealth; Heal Valuefloat HealValue; First Runif ( DoOnce == 0 )	Set BottomLimit to 0	Set HealthModifier to 0.025	Set UpdateModifier to 5	Set DoOnce to -1endif; MenuMode Check ( Stop Processing )if ( MenuMode == 1 )	returnendif; Get Current Health PercentageSet HealthPercentage to ( Player->GetHealthGetRatio ); Fully Healed ( Stop Processing )if ( HealthPercentage >= 1.0 )	returnendif; Bottom Limitif ( HealthPercentage < BottomLimit )	returnendif; Increment TimerSet Timer to ( Timer + GetSecondsPassed ); Calculate Update IntervalSet UpdateInterval to ( UpdateModifier / HealthPercentage ); Updateif ( Timer >= UpdateInterval )	; Current Health	Set CurrentHealth to ( Player->GetHealth )	; Taking Damage ( Workaround: Combat Detection )	if ( CurrentHealth < LastHealth )		Set Timer to 0		Set LastHealth to ( CurrentHealth )		return	else		Set LastHealth to ( CurrentHealth )	endif	; Max Health	if ( HealthPercentage > 0 )		Set MaxHealth to ( CurrentHealth / HealthPercentage )	else		Set MaxHealth to 0	endif	; Current Willpower	Set CurrentWill to ( Player->GetWillpower )	; Calculate Willpower Percentage	Set WillPercentage to ( CurrentWill / 100 )	; Calculate Heal Value	Set HealValue to ( MaxHealth * HealthModifier * WillPercentage )	; Add HealValue	Player->ModCurrentHealth HealValue	; Reset Timer	Set Timer to 0.00endifEnd


User avatar
Lewis Morel
 
Posts: 3431
Joined: Thu Aug 16, 2007 7:40 pm

Post » Wed Jul 13, 2011 4:13 pm

This isn't really my cup 'o tea, but I'll let you know if it works for me anyway. Source code I can't comment on, I'm not that computer-savvy. :)
User avatar
TWITTER.COM
 
Posts: 3355
Joined: Tue Nov 27, 2007 3:15 pm

Post » Wed Jul 13, 2011 8:15 pm

This isn't really my cup 'o tea, but I'll let you know if it works for me anyway. Source code I can't comment on, I'm not that computer-savvy. :)


Thanks, I appreciate it. :)

I'm hoping to strike a balance where it might become something even the hardcoe type may choose to use.

I think it needs to stop during combat, but, I forget if that is even possible in MW scripting. ?
User avatar
kiss my weasel
 
Posts: 3221
Joined: Tue Feb 20, 2007 9:08 am

Post » Wed Jul 13, 2011 6:46 am

First off, I wish every script was commented as well as yours! And actually, I've been looking for a mod that does exactly this for awhile now.

Couple of things:

  • The message box in the doOnce may be OK for testing purposes, but isn't necessary for distribution of your final product. There are enough mods that already generate too many messageboxes, and whether or not the mod is working should be self-evident based on if you're regaining health or not.
  • Using some back of the envelope math, let's say I have 100 Health out of 150 (66.66% of the total), and 40 Willpower. So, my Health per tick would be (150 * 0.05 * 0.4), or about 3 Health / tick. That sounds pretty fair, but I don't see how this is based on my injuries (major or minor). This math works out no matter how much health I actually have.


I'm going to have to actually play it in game to give any more feedback. But from the look of it, it looks simple, efficient, and lightweight. Great work! :foodndrink:

edit:

I think it needs to stop during combat, but, I forget if that is even possible in MW scripting. ?


It is not. It's a problem I've been http://www.gamesas.com/index.php?/topic/1203380-relz-automw-improved-morrowind-enhanced-new-autosave-system-and-more/, but as of right now I don't have a good way of bringing combat state information into Morrowind reliably. All my program does is check to see if any of the battle music .mp3 files are in use by Morrowind to determine whether or not the player is in combat. But unfortunately, there is no internal script function to determine this.
User avatar
Albert Wesker
 
Posts: 3499
Joined: Fri May 11, 2007 11:17 pm

Post » Wed Jul 13, 2011 3:04 pm

First off, I wish every script was commented as well as yours! And actually, I've been looking for a mod that does exactly this for awhile now.


Thanks, I try to keep my code clean, and well commented, for my sanity, and for anyone else who may end up checking it out. :)

Glad to hear there is a market for it, the first version was well received, but not the "most popular mod ever" on PES.

  • The message box in the doOnce may be OK for testing purposes, but isn't necessary for distribution of your final product. There are enough mods that already generate too many messageboxes, and whether or not the mod is working should be self-evident based on if you're regaining health or not.


Point taken, and it makes sense, though this message only appears the first time you run the mod, and never again. (But, removing it's no big deal.)


  • Using some back of the envelope math, let's say I have 100 Health out of 150 (66.66% of the total), and 40 Willpower. So, my Health per tick would be (150 * 0.05 * 0.4), or about 3 Health / tick. That sounds pretty fair, but I don't see how this is based on my injuries (major or minor). This math works out no matter how much health I actually have.



  • The update interval is what manages that portion of the illusion. :)

    It scales itself so that by default if you are nearly dead, those ticks are 30 seconds apart, but with less severe injuries(80% health or more), it's probably closer to 3 seconds. (This way minor falls, etc, heal quickly, while near fatal ones can take quite awhile. I can always add a gate, that way it won't run unless you are below X percent of your max health. (Another modifier perhaps.))

    I'm going to have to actually play it in game to give any more feedback. But from the look of it, it looks simple, efficient, and lightweight. Great work! :foodndrink:


    Looking forward to the results, feel free to play around with values, and suggest defaults that feel balanced.

    Edit:

    It is not. It's a problem I've been trying to get around with AutoMW, but as of right now I don't have a good way of bringing combat state information into Morrowind reliably. All my program does is check to see if any of the battle music .mp3 files are in use by Morrowind to determine whether or not the player is in combat. But unfortunately, there is no internal script function to determine this.


    Well, that svcks, it would've helped to balance it out.

    Nice project btw, I bookmarked it, I'll check it all out later, from what I saw it looked intriguing. :)
    User avatar
    Ebou Suso
     
    Posts: 3604
    Joined: Thu May 03, 2007 5:28 am

    Post » Wed Jul 13, 2011 6:25 am

    I'd hold off until I get v1.2 out. There is a major bug with Auto-Quicksaving that I need to get sorted out (game crashes on load), as well as a few other minor things.

    The update interval is what manages that portion of the illusion.


    I see it now! Ok, that makes more sense. This is pretty balanced; it doesn't negate the need for potions, since at low enough values of health, your self-healing essentially stops working.

    re: combat state, something you could do is check to see if the player's CurrentHealth went down since the last cycle, and if so, pause healing for some static amount of time (say, 5 or 10 seconds). That way, as long as they're taking damage, their self-healing won't function.
    User avatar
    Prohibited
     
    Posts: 3293
    Joined: Tue Jun 12, 2007 6:13 am

    Post » Wed Jul 13, 2011 9:03 am

    I see it now! Ok, that makes more sense. This is pretty balanced; it doesn't negate the need for potions, since at low enough values of health, your self-healing essentially stops working.


    Yeah, I used a bit of backwards logic there. :)

    I honestly didn't trust it to work properly the other way, since the game deals with floats behind the scenes, and whole numbers in the UI, etc,.

    So that way just seemed a safer bet. (Probably fine either way, but meh, this works well enough.)

    re: combat state, something you could do is check to see if the player's CurrentHealth went down since the last cycle, and if so, pause healing for some static amount of time (say, 5 or 10 seconds). That way, as long as they're taking damage, their self-healing won't function.


    Maybe, I'll have to see if I can make it work, something like this would probably do the trick.

    Edit: This seems to be working. (Though, if  the intervals passes without a hit landing, it breaks the fix, but with consistent damage being taken, it works as expected.)	; Current Health	Set CurrentHealth to ( Player->GetHealth )	; Taking Damage	if (CurrentHealth < LastHealth)		Set Timer to 0		Set LastHealth to ( CurrentHealth )		return	else		Set LastHealth to ( CurrentHealth )	endif


    So long as it runs once successfully, it should work fine after that, I think...
    User avatar
    Kitana Lucas
     
    Posts: 3421
    Joined: Sat Aug 12, 2006 1:24 pm

    Post » Wed Jul 13, 2011 8:46 pm

    Remember that your script is executing entirely once per frame, so you'll need to add a second timer. So something like...

    Spoiler
    float LastHealthfloat damTimerCounterfloat damTimerDurationshort damTimerToggleshort damWaitOnshort doOnceif ( doOnce )else     set doOnce to 1     set damTimerDuration to 5endifif ( CurrentHealth < LastHealth )     set damTimerToggle to 1     set damWaitOn to 1endif;Timer gates the rest of the codeif ( damTimerToggle )     set damTimerCounter to damTimerCounter + GetSecondsPassed     if ( damTimerCounter >= damTimerDuration )          set damTimerToggle to 0          set damTimerCounter to 0.00          set damWaitOn to 0     endifendifif ( damWaitOn )   ;if True, then     return              ;do nothingelse     ;the rest of your code's execution goes hereendif

    User avatar
    yermom
     
    Posts: 3323
    Joined: Mon Oct 15, 2007 12:56 pm

    Post » Wed Jul 13, 2011 6:18 pm

    Remember that your script is executing entirely once per frame, so you'll need to add a second timer. So something like...

    ..snip..


    Yeah, that would probably work better.

    	; Current Health	Set CurrentHealth to ( Player->GetHealth )	; Taking Damage	if (CurrentHealth < LastHealth)		Set Timer to 0		Set LastHealth to ( CurrentHealth )		return	else		Set LastHealth to ( CurrentHealth )	endif


    This works, but, if the attacks aren't landing consistently enough, it breaks, and let's it heal during combat.

    Your code would be much more accurate since I would basically have a cool down timer. (Though, at intervals of 5-10 on my existing UpdateModifier, it wouldn't be an issue. Perhaps do that, and increase the HealthModifier.)
    User avatar
    Jah Allen
     
    Posts: 3444
    Joined: Wed Jan 24, 2007 2:09 am

    Post » Wed Jul 13, 2011 10:05 pm

    This sounds pretty cool for minor injuries. I'm not sure I want near-death injuries to heal on their own though. How would I go about changing that so I don't heal if I'm below 50 percent of my health?
    User avatar
    Beulah Bell
     
    Posts: 3372
    Joined: Thu Nov 23, 2006 7:08 pm

    Post » Wed Jul 13, 2011 1:42 pm

    This sounds pretty cool for minor injuries. I'm not sure I want near-death injuries to heal on their own though. How would I go about changing that so I don't heal if I'm below 50 percent of my health?


    I can probably add some method of allowing for custom limiting into the script later on, for now you can use this code.

    ; Heal Minor Injuries Onlyif ( HealthPercentage >= 0 && HealthPercentage <= 0.5 )        returnendif


    Just add that after the "Fully Healed" code block.

    That should do the trick.

    ---

    I'm kinda tired, about to go to sleep, so if that doesn't work, it's probably cus' my brains done sleeping.. (I'll post an updated script tomorrow that supports setting custom limits, has a bit better balance, and combat detection integrated.)


    ----

    Edit:

    Grr.. Obsessive personality wouldn't let me leave it at this... Here ya go. :snoring:

    Just change the bottom limit to 0.5 from the console.

    Set aaaNaturalHealing.BottomLimit to 0.5

    Spoiler

    Begin aaaNaturalHealing; First Runshort DoOnce; Timerfloat Timerfloat UpdateInterval; Healthfloat HealthPercentagefloat CurrentHealthfloat MaxHealth; Willpowerfloat WillPercentagefloat CurrentWill; Modifiersfloat BottomLimitfloat HealthModifierfloat UpdateModifier; Combat Detection ( Workaround: Detecting Combat )float LastHealth; Heal Valuefloat HealValue; First Runif ( DoOnce == 0 )	Set BottomLimit to 0	Set HealthModifier to 0.025	Set UpdateModifier to 5	Set DoOnce to -1endif; MenuMode Check ( Stop Processing )if ( MenuMode == 1 )	returnendif; Get Current Health PercentageSet HealthPercentage to ( Player->GetHealthGetRatio ); Fully Healed ( Stop Processing )if ( HealthPercentage >= 1.0 )	returnendif; Bottom Limitif ( HealthPercentage < BottomLimit )	returnendif; Increment TimerSet Timer to ( Timer + GetSecondsPassed ); Calculate Update IntervalSet UpdateInterval to ( UpdateModifier / HealthPercentage ); Updateif ( Timer >= UpdateInterval )	; Current Health	Set CurrentHealth to ( Player->GetHealth )	; Taking Damage ( Workaround: Combat Detection )	if ( CurrentHealth < LastHealth )		Set Timer to 0		Set LastHealth to ( CurrentHealth )		return	else		Set LastHealth to ( CurrentHealth )	endif	; Max Health	if ( HealthPercentage > 0 )		Set MaxHealth to ( CurrentHealth / HealthPercentage )	else		Set MaxHealth to 0	endif	; Current Willpower	Set CurrentWill to ( Player->GetWillpower )	; Calculate Willpower Percentage	Set WillPercentage to ( CurrentWill / 100 )	; Calculate Heal Value	Set HealValue to ( MaxHealth * HealthModifier * WillPercentage )	; Add HealValue	Player->ModCurrentHealth HealValue	; Reset Timer	Set Timer to 0.00endifEnd


    User avatar
    JERMAINE VIDAURRI
     
    Posts: 3382
    Joined: Tue Dec 04, 2007 9:06 am

    Post » Wed Jul 13, 2011 11:07 am

    oh. Thank you for the fast response :)
    User avatar
    Sian Ennis
     
    Posts: 3362
    Joined: Wed Nov 08, 2006 11:46 am

    Post » Wed Jul 13, 2011 2:39 pm

    This looks sweet! Great for those of us that roleplay as insomniacs (or can't be bothered with sleeping schedules). :hehe: But, really, it is awesome. I didn't read everything, but is there a feature where health-regen is halted during combat? Just a thought.I can't remember what game I played that had that feature, but HP healed over time when the character was idle (not in combat). Or maybe HP regain slows and eventually stops as Fatigue drops. Kinda makes sense, your body can't heal itself well if it is under stress!

    Oooh, you know what else is neat? If the HP regen was turned off for when the character becomes a vampire. That would really underscore the need-to-feed...

    Uh, don't mind me though, I'm just babbling. ^_^
    User avatar
    Blessed DIVA
     
    Posts: 3408
    Joined: Thu Jul 13, 2006 12:09 am

    Post » Wed Jul 13, 2011 9:41 pm

    Thanks, I appreciate it. :)

    I'm hoping to strike a balance where it might become something even the hardcoe type may choose to use.

    I think it needs to stop during combat, but, I forget if that is even possible in MW scripting. ?


    You could make it so it would stop whenever the PC has a weapon drawn or spell readied. like in Witcher 2 I guess. natural regeneration slows down if you draw swords
    User avatar
    Jessica Phoenix
     
    Posts: 3420
    Joined: Sat Jun 24, 2006 8:49 am


    Return to III - Morrowind