Using GetHealth <= 0 instead of GetDeadCount?

Post » Fri Jan 27, 2017 5:35 am

So I'm currently playtesting the newly released version of UL and documenting any bugs I find to send back to Stuporstar. I noticed in the update log that instances of GetDeadCount in UL had been changed to GetHealth when trying to see if a particular NPC is dead, which I gather was to increase performance since GetDeadCount can be taxing. However, a particular NPC that was supposed to appear once another (Gothren) was dead did not appear for me. I took a look at the script and my saved game, and realized that more than 72 hours had passed since I killed Gothren. I typed "gothren"->GetHealth into the console and it returned 272, his max health. This led me to believe that his health reset once he had been garbage collected after 72 hours.

Has this been a confirmed issue that I just haven't known about? As in, once 72 hours have passed since an NPC's death, using GetHealth to check if they are "dead" will no longer work correctly?

User avatar
Posts: 3379
Joined: Mon Sep 25, 2006 11:28 am

Post » Fri Jan 27, 2017 2:53 am

I suspect that GetDeadCount is one of those functions you don't want to be calling repeatedly but single calls wouldn't be a problem. Replacing it with one that could give the wrong result doesn't appear to be a good idea.

However, if you're looping round repeatedly checking a character's health until he dies, (say after casting a slow-acting spell) then the change would make sense.

And yes, that issue has been reported before, and it's apparently worse than you think. A character can die while being healed, (e.g. while wearing a continuous effect item) and will end up dead with positive health, because he died at zero but received some health after death.

User avatar
Kevan Olson
Posts: 3402
Joined: Tue Oct 16, 2007 1:09 am

Post » Thu Jan 26, 2017 10:11 pm

I just confirmed this behavior much to my initial surprise. Details such as health and disposition ordinarily should not be (are not) reset by the 72-hour effect. However, if the NPC is dead it appears that the engine assumes there is no need to keep track of those references and removes them with the trash. As a result, any check of those values defaults to the values set in the construction set since the saved data is lost. It makes sense in that special circumstance, but this behavior needs to be understood by modders if we need to refer to such data after the NPC is killed.

User avatar
Posts: 3556
Joined: Wed Sep 05, 2007 8:25 pm

Post » Fri Jan 27, 2017 4:27 am

Yeah it looks like all the instances of GetDeadCount that Stuporstar changed to GetHealth might have to be changed to GetDeadCount again unfortunately :/

User avatar
Kira! :)))
Posts: 3496
Joined: Fri Mar 02, 2007 1:07 pm

Post » Fri Jan 27, 2017 8:40 am

if you want a faster getdeadcount, you store the death as a variable or global instead after GetHealth, or a journal entry. I remember this discussed awhile back. is there any instances where an npc has died with positive health? i thought the engine sets health to 0 when it's 1 or less.

User avatar
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am

Post » Thu Jan 26, 2017 10:28 pm

I think it depends on health restoration on that NPC e.g. dead event + constant health restoration 3 points may result in 2 points health dead

maybe use something like this

short dead

if ( dead )



if ( GetHealth <= 0 )

set dead to 1 ; flag to fix if health restored after 72Hours



if ( GetHealthGetRatio < 0.03 ) ; try forcing NPC health <= 0

ModCurrentHealth -3 ; health subtracted may vary depending on expected NPC constant healing


User avatar
Taylor Tifany
Posts: 3555
Joined: Sun Jun 25, 2006 7:22 am

Return to III - Morrowind