Jump to content

[LE] how get player max health with buff in oldrim


Recommended Posts

 

As a workaround for this without SKSE I once considered doing some madness like this, which in theory should work but it's less than ideal, didn't got to use it iirc.

Float Function GetMaximumActorValue(Actor akActor, String asValueName, Float fInfinite = 9999.9)
  Float Base = akActor.GetActorValue(asValueName)
  akActor.RestoreActorValue(asValueName, fInfinite)
  Utility.Wait(0.1); to make sure we are fully healed
  Float Max = akActor.GetActorValue(asValueName)
  akActor.DamageActorValue(asValueName, Max - Base)
  Return Max
EndFunction

This is a really REALLY good solution, but it's only practical for a few situations.

If you need the max HP during a battle to heal the player by 10% of he's max HP - it could be really bad...

But then again I can't offer any non-SKSE solutions so who am I to talk right? :D

Link to comment
Share on other sites

 

As a workaround for this without SKSE I once considered doing some madness like this, which in theory should work but it's less than ideal, didn't got to use it iirc.

Float Function GetMaximumActorValue(Actor akActor, String asValueName, Float fInfinite = 9999.9)
  Float Base = akActor.GetActorValue(asValueName)
  akActor.RestoreActorValue(asValueName, fInfinite)
  Utility.Wait(0.1); to make sure we are fully healed
  Float Max = akActor.GetActorValue(asValueName)
  akActor.DamageActorValue(asValueName, Max - Base)
  Return Max
EndFunction

i am not expert,

but it have "Utility.Wait(0.1); to make sure we are fully healed",

so the game will "wait" to get the "fully healed",

why i will use "wait" to calculate "value" to restore if the "wait" it self will restore the "value"

Link to comment
Share on other sites

 

 

As a workaround for this without SKSE I once considered doing some madness like this, which in theory should work but it's less than ideal, didn't got to use it iirc.

Float Function GetMaximumActorValue(Actor akActor, String asValueName, Float fInfinite = 9999.9)
  Float Base = akActor.GetActorValue(asValueName)
  akActor.RestoreActorValue(asValueName, fInfinite)
  Utility.Wait(0.1); to make sure we are fully healed
  Float Max = akActor.GetActorValue(asValueName)
  akActor.DamageActorValue(asValueName, Max - Base)
  Return Max
EndFunction

i am not expert,

but it have "Utility.Wait(0.1); to make sure we are fully healed",

so the game will "wait" to get the "fully healed",

why i will use "wait" to calculate "value" to restore if the "wait" it self will restore the "value"

 

 

The Wait function doesn't do anything except delay the execution of the rest of the script, to make sure the game engine has enough time to process the RestoreAV function, which does the actual 'healing'.

Link to comment
Share on other sites

 

 

 

As a workaround for this without SKSE I once considered doing some madness like this, which in theory should work but it's less than ideal, didn't got to use it iirc.

Float Function GetMaximumActorValue(Actor akActor, String asValueName, Float fInfinite = 9999.9)
  Float Base = akActor.GetActorValue(asValueName)
  akActor.RestoreActorValue(asValueName, fInfinite)
  Utility.Wait(0.1); to make sure we are fully healed
  Float Max = akActor.GetActorValue(asValueName)
  akActor.DamageActorValue(asValueName, Max - Base)
  Return Max
EndFunction

i am not expert,

but it have "Utility.Wait(0.1); to make sure we are fully healed",

so the game will "wait" to get the "fully healed",

why i will use "wait" to calculate "value" to restore if the "wait" it self will restore the "value"

 

 

The Wait function doesn't do anything except delay the execution of the rest of the script, to make sure the game engine has enough time to process the RestoreAV function, which does the actual 'healing'.

 

so the game really "wait" and health will be 100% ?

Link to comment
Share on other sites

Basically It should store your current health, heal an "infinite" amount, then the script execution will halt for a tenth of a second to make sure that has happened (it doesn't affect anything external to that script), then get the value which would be the maximum and lastly undo the healing, that's the theoretical idea at least, I didn't got to test it, or I can't remember.

I guess I added the wait because I'm not certain if you run RestoreActorValue and immediately after GetActorValue it will get the healed one, i.e. max. I'm not certain it is required either, maybe it's safe to call getav immediately after restoreav and you get the correct value, I don't know. So, tldr, maybe the wait is not actually needed.

Edited by FrankFamily
Link to comment
Share on other sites

If you want to use this value during a battle, for example, why not do this:

 

1) Use FrankFamily's nice function and store the Max Health value as a global variable. Do this intermittently; perhaps on equipping items, leveling up, or just every so often (or some combination thereof).

2) Instead of calling this function every time you want to get the max health, use the stored global variable. It may not be 100% accurate but it will be faster and, depending upon how often you update the global (#1 above), should be accurate enough for most situations.

 

Just spitballing here..

Link to comment
Share on other sites

If you want to use this value during a battle, for example, why not do this:

Â

1) Use FrankFamily's nice function and store the Max Health value as a global variable. Do this intermittently; perhaps on equipping items, leveling up, or just every so often (or some combination thereof). Â

2) Instead of calling this function every time you want to get the max health, use the stored global variable. It may not be 100% accurate but it will be faster and, depending upon how often you update the global (#1 above), should be accurate enough for most situations. Â

Â

Just spitballing here..

This post is just to throw some ideas based on my experience (not a pro, but you'll see...)

 

First of all let me say that I agree with you on this because I actually do something like this on another mod I'm making.

I have though this through and the only times that you should run the script to update that global variable (updating the current max HP/other AV) is during the 3 following occasions:

1) Equipping an item - OnObjectEquipped event.

2) Unequipping an item - OnObjectUnequipped event.

3) Closing the stats menu - OnMenuClose: StatsMenu.

P.S: If anyone can think of another occasion - PLEASE let me know!

 

Now I'll explain a small problem:

The entire idea behind doing this with what you suggested is to mainly avoid the use of SKSE, this is where the problem shows itself - checking when the menu closes is also an SKSE function.

 

A way to avoid this is another idea you suggested - doing it periodically. But this negates the whole idea of only checking when necessary.

 

So here's my final suggestion and how I solved this problem:

Use the SKSE line I provided (that gets the MaxAV without fully restoring it) during the 3 occasions I wrote but still also do it periodically, but much less often (maybe every 10-30 seconds), just in case of a debuff or something like that.

 

Good luck!!!

Link to comment
Share on other sites

@DMan1629: I would suggest including a listen for magic effects. In the base game, there's blessings (Arkay, Julianos, Kynareth), potions, and diseases (Bone Break, Brain Rot, Sanguinare Vampiris) that will impact it. This will also help catch stuff from need mods or similar things as well. This might be able to supersede the OnEquip/UnEquip listen. If not, something would need to be done to avoid race conditions.

Edited by foamyesque
Link to comment
Share on other sites

  • 2 years later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...