Jump to content

MWSE State-Based Health


Necrolesian
 Share

Recommended Posts

MWSE State-Based Health


MWSE State-Based Health


Description
 
This is a state-based health mod implemented in MWSE. Your health will now be calculated based on your current endurance, strength and level.
 
The formula is:
 
(strength + endurance) / 2 + (level - 1) * fLevelUpHealthEndMult * endurance
 
This is basically the same as the vanilla health formula, but based only on your current stats. You no longer need to start with endurance as high as possible, or increase it as quickly as possible, in order to maximize health. Any increases (or decreases) to endurance or strength will be immediately reflected in your new max health.
 
Health is calculated based on your *current* endurance and strength, not your "base" stats. This means anything that influences your end/str, such as any fortify or drain effects (or attribute damage) will influence your health accordingly. This makes Fortify Endurance (and, to a lesser extent, Fortify Strength) effects more useful because they will also increase your health. It also makes Drain or Damage End/Str effects more dangerous.
 
This mod respects the value of the fLevelUpHealthEndMult GMST. In vanilla Morrowind, this GMST is set to 0.1, which means 1/10 of your endurance is added to your health for each level above level 1. If you're playing a mod that changes this GMST, the modded value will be used in health calculations.
 
It also takes into account any Fortify Health effects you're under, and whether you're using the Morrowind Code Patch feature that causes Fortify Health to affect max in addition to current health, so you'll have the correct health both before and after the Fortify Health effect wears off.
 
Configuration
 
There are three configurable settings in the Mod Config Menu. The first relates to how to handle changes to current health when you're not at full health.
 
By default, the mod will maintain the ratio of your current and max health. For example, if your health is currently 23/73 (a ratio of about 31.5%), and your max health increases by 8 (say, because of a level increase), your health will now be about 25.52/81, the same ratio. (Morrowind displays health as an integer, but it uses fractional values behind the scenes).
 
Note that this also takes into account any Fortify Health effect you're under. Fortify Health changes the ratio of current to max health. The ratio that's maintained is the ratio you *would* have if you weren't under a Fortify Health effect, so when the effect wears off, you'll have the same ratio as before.
 
However, if you prefer, you can configure the mod in the MCM to maintain the *difference* between your max and current health rather than the ratio. Using the above example (health 23/73 and your max health increases by 8), the difference is 50. When your max health increases to 81, your current health will be set to 31, maintaining that difference.
 
This is beneficial when your health increases, but can be dangerous when your health decreases. Let's say instead of increasing, your max health decreases by 30 (say, because of a Drain Endurance effect). In this case, your new health will be -7/43 (maintaining the difference of 50), resulting in game over. The most likely cause of this kind of event is the disease Black-Heart Blight, which in vanilla Morrowind drains both strength and endurance by up to 40 points each.
 
The second setting in the MCM specifies a minimum value for max health; the mod will never set your max health below this value. By default, this value is 0, but it can be set as high as 20. This can serve to protect you from being killed outright by a bad attribute drain (though if you're maintaining difference rather than ratio, you can still be killed if you've taken enough damage to be lethal with your new max health).
 
Finally, there's a setting that enables logging to MWSE.log.

Interop

This mod allows other mods to pass along health modifiers that this mod will apply.
 
For Players
 
If you're using a mod that takes advantage of this functionality, you don't need to do anything special; just have both mods installed and any health bonuses or penalties assigned by the other mod will be applied by this mod. If you uninstall the other mod, its health modifiers will go away.
 
For Modders
 
To establish the interface, do something like:
 
local stateBasedHealth = include("StateBasedHealth.interop")
 
The health modifiers are located in stateBasedHealth.extraHealth. This is a table of key-value pairs. The values are numbers to be applied to max health. The keys are strings which should contain a unique descriptor of the modifier (e.g. the name of your mod).
 
For example, if you want to apply a health bonus of 20, do something like:
 
stateBasedHealth.extraHealth["my mod"] = 20
 
These values can be negative to apply a health penalty, and you can create multiple modifiers to be applied. You can change existing modifiers, or remove them by setting them to 0 or nil (however, don't set the whole table to an empty table unless you really intend to eliminate all modifiers from all mods).
 
Adding or changing modifiers does not automatically trigger a health recalculation. To tell this mod to recalculate health immediately (rather than waiting until the next time endurance, strength or level changes), do this:
 
stateBasedHealth.recalcHealth = true
 
This mod will then recalculate health, taking into account any health modifiers, at the beginning of the next frame.
 
Note that the extraHealth table is empty each time Morrowind is started, so any health modifiers will need to be set on each game session (i.e. they do not persist across game sessions). However, they do persist when the player loads a savegame - this mod does not clear them on game load - so if you don't want that you'll need to clear or reset them.
 
Requirements
 
This mod requires MGE XE and the latest version of MWSE 2.1. Just install MGE XE and run MWSE-Update.exe to download the latest build.

Recommendations

I recommend using the "Fortify Maximum Health" feature of Morrowind Code Patch, both with this mod and in general, since it makes Fortify Health not suck so much.

Compatibility

This mod will generally be incompatible with other mods that manage health. CCCP, as of version 2.0.5, is an exception. CCCP has its own health system, but if you prefer the way this mod handles health calculations, you can disable CCCP's health management and use this mod to manage health. (Do not disable health management in CCCP unless you're using this mod or another mod that manages health.)
 
This mod will also generally override any other mod that makes scripted changes to health; MWSE-lua mods can use this mod's interop functionality to have this mod apply health modifiers instead.
 
Version History
 
Version 1.3 - 2021-07-13
   - Removed "current health safety net" option, as it was highly exploitable.
   - Changed the "max health safety net" option in the MCM to a slider allowing you to configure a minimum value for max health.
   - Added the ability for other mods to tell this mod to apply health modifiers.
   - Fixed a bug where weird things could happen when health would be 0 or negative if not for a Fortify Health effect, and was then recalculated.
   - Fixed a bug where Fortify Health abilities (which always affect max health even without the related MCP feature) were not properly taken into account.
   - Added option for extensive logging to MWSE.log.
   - Various coding improvements.

Version 1.2 - 2020-07-11
   - Fixed a known issue where, if the mod was set to maintain health ratio and the player was under a Fortify Health effect when health was updated, the ratio was different after the Fortify Health effect expired than it would have been had there been no Fortify Health.
   - Maintaining current/max health ratio, rather than the difference between max and current health, is now the default setting, now that the above issue has been fixed.
   - The "current health safety net" setting now will not work at all if the mod is maintaining ratio, as it's not useful in that case.

Version 1.1 - 2020-06-17
   - Fixed a bug that was causing warnings in mwse.log about an event being registered twice.
   - The "health safety net" setting is now two settings, one for max health and one for current health.
   - Improved the MCM.

Version 1.0 - 2020-05-25
   - Initial release.
 
Contact
 
Feel free to contact me on the Nexus or Moddinghall with any comments or suggestions. You can also find me on Discord as Necrolesian#9692.


 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...