Jump to content

How to figure out when an essential NPC has been "killed"


Recommended Posts

Here is an interesting question for any scripting experts that read this: What is the best way to find out when an essential NPC has been "killed"?

This is what I have found so far:

  • OnDeath event handler and block type never fire. The GetDead function never becomes true.
  • Health never drops to 0
  • GetKnockedState is equal to 1 when an essential character dies but also returns 1 if an NPC is paralysed or fatigue is lower than 0.
  • OnKnockout block type runs when an essential character dies but, once again, also when paralysed/fatigued.
  • I haven't found any other functions which could help.

 

If anyone has any suggestions for how I can go about this, I would love to hear them.

Link to comment
Share on other sites

Have you tried GetUnconscious yet?

https://cs.elderscrolls.com/index.php?title=GetUnconscious

 

Also, now that I think about it, there has to be something in the vanilla coding that forces the message "NPC has been knocked out" (or whatever the message says when essential NPC's "die"). If you can't find a command that works for you, I would recommend trying to track down where that message is generated from and then using similar syntax to achieve what you are looking for.

Edited by kingtitan
Link to comment
Share on other sites

Unfortunately, GetUnconscious doesn't work either. It only returns true for NPCs that have had the "SetUnconscious" command used on them, which doesn't happen when an essential character dies.

 

The display of that message is hardcoded into the game. Hooking into that particular process would require writing an OBSE extension which I don't have the knowledge to do. Another option would be to check for when the game displays the message but I have no idea how to check for that, assuming it's even possible.

Link to comment
Share on other sites

I believe that essential NPCs fall down when knocked out (I use some mods that would affect that somewhat, but if memory serves even vanilla has them drop when unconscious). I've never thought to look at whether the game perhaps just reduces the NPC fatigue to below zero to get them to drop (again my mods would possibly cloud any tests I could do with my current load order).

 

I'm thinking/wondering if a check for fatigue plus whether or not an actor is essential would suffice?

Link to comment
Share on other sites

@Striker879

I just did some tests and, unfortunately, your suggestions don't solve the problem. Essential NPCs do drop when essential but I checked the fatigue of my test NPC and his fatigue was still full after getting knocked out. I also reduced his fatigue to 0 then killed him to see if getting knocked out resets fatigue but it doesn't. Fatigue doesn't get changed when knocked out. The only thing that changes is that fatigue regeneration seems to stop while "dead".

 

If you are using Vortex as your mod manager, temporarily uninstalling all of your mods can be accomplished by creating and switching to a new blank profile. You can then install your mods again by switching back to your main profile.

 

 

@Moktah

Basically, I am trying to make a bugfix mod that changes how the game stops the player from dying during certain parts of it because I see some shortcomings in the vanilla approach. My current method of doing so is to create an OnHealthDamage event handler that compares how much health the player has left verses the amount of damage they just received. When the latter is greater, I run some scripting to prevent death from occurring. I have found that this only seems to work around 98% of the time and in around 2% of my tests, death was not prevented. As a result, I want to set the player as essential as a backup solution. To make this work though, I need to know when the essential player has "died", hence my question.

 

If you want to propose an alternative solution to making the player essential, I would recommend reading this if you haven't already: https://en.uesp.net/wiki/Tes4Mod:Resurrecting_the_Player

Of the three methods proposed there, setting the player essential has the fewest drawbacks (especially with EngineBugFixes fixing the camera problem associated with Resurrect and SetEssential).

Link to comment
Share on other sites

Well that does align with my observations ... if you try to restore health to an essential but unconcious NPC your spell doesn't do anything until just before they get up.

 

Thanks for the suggestion, but I'm one of the few remaining Manual Install Dinosaurs. Maybe I miss out on a couple of modern day possibilities but in return I learn a lot about mod installing and troubleshooting.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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