Is it possible to Script Maximum Damage Taken?

General discussion regarding the OpenMW project.
For technical support, please use the Support subforum.
Post Reply
Hazmy
Posts: 1
Joined: 19 Jun 2017, 22:26

Is it possible to Script Maximum Damage Taken?

Post by Hazmy »

Hello guys I am fairly new to modding Elder Scrolls games and I have recently started putting together a lot of mods in Morrowind to make the game fit my style more.

I am having a lot of problems balancing damage of enemies especially with higher numbers as the Difficulty slider just increases everything exponentially.

For this reason, the question I'd like to ask is:

Is it possible to have a script that only allows the PC to take 30% of it's maximum HP?

The logical process I mean is : If player damage taken is greater than 30% of maximum HP, then damage taken equals 30% of player's maximum HP.

In case this is not possible, a simpler version : If player damage taken is greater than 30, then damage taken equals 30.

Thank you for the help in advance, I hope it is possible, sorry for being a newb.
User avatar
Greywander
Posts: 119
Joined: 04 Dec 2014, 07:01

Re: Is it possible to Script Maximum Damage Taken?

Post by Greywander »

Yes and no. The way I can immediately think of to do this is to check the player's health every frame (GetHealthGetRatio is your friend here), and if it decreases by more than 30%, you would restore some health to balance it out. One problem is that this won't work if the damage was enough to kill the player, but there's another, bigger issue in play here.

The major problem here is that a lot of damage effects like spells are not instantaneous but dealt over time. You could, for example, have a spell that deals 10 fire damage every second for 6 seconds. If you only have 100 health, that will take off 60% of your health. With the check-every-frame method, we can't actually figure out how much damage an individual attack is doing (theoretically, if the player got hit by two or more attacks on the same frame, our method would limit the combined damage to 30% max), and this goes completely out the door with a damage over time attack. To make things even worse, a lot of "instant" effects may actually happen over 1 second, so our frame-by-frame method doesn't see them as a single attack.

You could broaden the window, for example by checking every 10 frames instead of every frame, or every second, or every 2 seconds, but the wider you make that window, the more likely you are to accidentally catch two or more attacks instead of a single attack. As far as I know, there's no function that tells if you the player has been hit with a weapon or spell. You can test if the player is under the effects of a spell (for example, if the player is taking fire damage), but there's no way to determine the magnitude of the spell.

If you're only worried about weapons and instant effect spells, though, then this should work.

I'd recommend downloading Morrowind Scripting For Dummies, as it will help you out a lot with making mods.
Post Reply