Detecting a Player healing

So I am building a death system that mimic’s the 5th edition DnD death system.

In a nutshell when you die it starts rolling Death Saving Throws. 3 fails you die, 3 successes and you stabilize. It makes a check every X seconds, currently set to every 30 seconds.

Basic system is you drop and it starts making the saves and then delays a recursive call to the same script.

It’s working perfectly but for one little hiccough. If a player goes down, starts the saves, gets healed and then dropped again in that 30 second window then the check made is considered a “second” check rather than the first as it should.

I could add a hearbeat that will set the “results rolls” variables to 0 if the players HP are above zero but I really would like to avoid hearbeats because we all know how painful (and unreliable) they can be.

Anyone know a way to grab when a player is healed without using a heartbeat or editing every spell and item script?

Right now I think that my best solution is a hearbeat but I am hoping you all can pull me out of that particular hell. Another option would be to grab the time that the player “died” and started rolling saves and then to check to see if that was different maybe??

Very open to ideas here.

You can easily detect healing of anyone from spells (and potions, since they just cast spells) via spellhook. But regeneration is another source of HP to consider. You also cannot detect the usage of a medkit.

There is nothing wrong using pseudo-hearbeats, even with sub-second precision if you run just a couple of them and control their execution.

But if your delay is a multiple of 6 you can simply use the base HB with some counter.

What check? Once you’re dying, you keep rolling while HP is < 1. If PC goes up and down in the meantime the heartbeat shouldn’t even notice that. All you need to do is to keep a sentinel variable so you don’t start another heartbeat while one is already running.

Hey there.

Thanks for the reply. I was typing out a detailed post (with code) on where the problem was and I stumbled upon the “fix”.

My script fires on the “on_Death” and it only fires that once at the time you die and then the pseudo Hearbeat kicks in . The pseudo heartbeat has a release for the PC having more than 0 HP to reset and die. I already have the one running I didn’t want it to need others because of the potential performance / confusion factors.

In 5ed your “successes and failures” reset when you get back to 1 Hit point so that is the reason to worry about things there. Basically I could fail 2, be on deaths door and get healed for 1 single HP and I am no longer “dying” if, on the next action, I am immediately dropped to zero then I start the Death saves over. Those 2 failures are forgotten and I get a whole new lease on life.

Thus in my system the problem was coming up to positive hit points but being knocked back down to 0 before the heartbeat fired.

All I needed to do to fix the script was 2 things.

  1. OnDeath … reset before I call the “Death Saves” script This resolves the issue of popping up and going back down between checks. Glaringly obvious but I had started with this script working on the “onDying” event so I am going to blame that particular logic flaw of mine on that! :smiley:

  2. Add a variable for the time of death and make sure that was passed to the Pseudo heartbeat. If it doesn’t match what it’s running with then kick out as well, this stops multiple scripts rolling you out very quickly.

Pretty simple solution in the end but one I obviously needed to “talk out” here so thanks so much for the reply. I may look at packaging it up into a system that I can release but then I will need to figure out how to “fix” regeneration so that regeneration <> immortality. If there was a simple way to make it stop healing if you had less than 1 HP that would pretty much do it. :wink:

Thanks again.

I still don’t follow which approach you want. You can always let the HB run for a bit longer while the PC is up to merge such heal/death cycles into one run.

Use a 1-second pseudo-heartbeat and EffectDamage the player to the lowest HP it had since dying (i.e. it could have had 0 but then be hit to -3). Looks bad, but works.

Heartlib is the way to go if you need a fine-grained control over pseudo-heartbeats. And yes, it is my project. And yes, I should update it some day.

When you say “when you die”, I presume that you mean “dying” instead. And that your script is the module OnPlayerDying event. Is that correct?

You could use GetCurrentHitPoints to determine how many hit points a PC has, including negative hit points.

Your heartbeat script could be triggered as part of the OnPlayerDying event and reset when the PC has 1 or more hit points.

Yep … if the player dies outright the OnDeath script actually resses them (not visual effect) at 0 HP (well 1 hp and deals 1 damage) and then OnDying takes over from there. Everything runs out of triggers on the script for the OnDying event.

Basically this means you can’t die normally or outright. The system will “kill you” (transport you to the afterlife zone") if you fail 3 death saves but otherwise yeah you just lie on the ground waiting for a heal, stabalization or “death”.

You are just lying there at 0 HP basically so the issue with regeneration is that it pops you back up when it happens. I need them to stay at 0 HP because any healing brings the player back above 0 (a la 5th edition DnD).

In 5ed the regeneration spell basically makes you immortal while it’s running as you can’t be down long enough to fail 3 saves but items that have regeneration only function if you have at least 1 HP. So for me keeping in the regeneration spells is easy enough but I can’t really use any item regeneration property. What I can do (and will be doing) is code a unique property that does the same but only works if the player has >0 HP.

Since the property is hardcoded in NWN as far as I can tell there’s nothing I can do to modify it to only work with 1+ Hit Points which sucks in this case.

I thought about the 1 second heartbeat to keep you at 0 but the issue is the minute you are positive and go down again (even with that damage) it’s going to trigger the OnDying event and restart their saves instead of continuing on.

It’s just easier to build a new property for an item alas. What would be best if there was a way to detect if someone was healed and what the source was as I wouldn’t have to do so many work arounds but there we are.