Preventing character death in Skyrim is not very difficult, but requires some work. Here is a snippet of my code that
should help you, along with links to my resources.
This snippet is used for my Dark Souls mod. I cut out the information that does not relate to this article.
;set the flags that prevent death and prevent kill moves
Game.GetPlayer().StartDeferredKill() ;This prevents death
Game.GetPlayer().IsProtected(true) ;This prevents the killmoves and death, but the line above is NEEDED
;Debug.MessageBox("Player is now in the 'StartDeferredKill()' state") ;this lets me know that the flags are set, when
the game starts
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked )
;This section will allow us to know we lost by checking to see if our health is below 0.1% when we are hit.
PercentHealth = PlayerRef.GetAVPercentage("Health")
"If PercentHealth <= 0.1"
PlayerRef.moveto(Bonfire) ;move the player to the last used bonfire on death
Debug.MessageBox("You have died") ;let the player know they died. just in case :D
The Two most important things about this code is the Game.GetPlayer().StartDeferredKill(). What this does
is it makes your character unkillable, however their hp will still drop to 0.
One of the problems you can face now is that your character can get stuck in those annoying "kill cam/ kill move"
scenarios. For me, whenever this happened, my character would still have 15% of his health and the move would happen,
then my character would not take damage. This kinda cheats the game, do you agree?
So what you need to do is set the character to either essential or protected to prevent the kill moves. Normally, setting one of those
causes the character to drop down into a bleedout state instead of dying, where they drop to one knee until their health returns above
a certain percentage. I have found the IsProtected() method to be more efficient that the IsEssential() method, however that is up to
However, with the StartDeferredKill() method, our character cannot die, which should prevent the bleedout state from working.
So to sum it up, StartDeferredKill() prevents death, and Essential/Protected prevents kill moves.
There are several problems that I have noticed with these methods IF the player is moved while knocked down:
- The camera is stuck in 3rd person and does not follow the character
- The character has his/her face stuck in a certain expression
- their head will be stuck in a ragdoll mode. Kinda funny
to be unprofessionally honest
To fix these above issues, you just need to.....