AshPtMods Posted December 1, 2021 Share Posted December 1, 2021 (edited) Hi folks! I was hoping to get some help on a mod i'm working on. I would like to have an npc resurrect (as hostile) every time it is killed. So far I have only managed to make an npc resurrect Once (Similar to the skeletons of Dark Souls) but unfortunately if it is killed a second time, It remains dead.The effect is applied through a perk entry (Apply Combat hit spell) This is the script i'm currently using: (Copied from the Soul tear magic effect "DLC01_SoulTearWaitForDeathFX") Scriptname DLC1MagicSoulRendScript extends ActiveMagicEffect {This script is used to reanimate an actor after it is killed} Import Game ;======================================================================================;; PROPERTIES /;=============/ Spell property SpellRef auto{The name of the Reanimate Spell. (REQUIRED!)}MagicEffect Property ReanimateEffect Auto{We need this effect to prevent killing and reanimating an already reanimated actor} ;======================================================================================;; VARIABLES /;=============/actor CasterActoractor Victimbool bIsCastYet = Falsebool bIsReanimatedAlready = Falsebool bIsReadyToGo = FalsebooL bIsDying = False;======================================================================================;; EVENTS /;=============/ Event OnEffectStart(Actor Target, Actor Caster)victim = targetCasterActor = Casterif (victim.HasMagicEffect(ReanimateEffect))bIsReanimatedAlready = TrueSelf.Dispel()endIfbIsReadyToGo = trueutility.wait(0.5)if (bIsDying) == FalseSelf.Dispel()endifEndEvent Event OnDying(Actor Killer)bIsDying = trueEndEvent ;/ Event OnDying(Actor Killer)while (bIsReadyToGo == False)Utility.Wait(0.1)endwhile; debug.trace("Victem is Dead is returning: " + Victim.IsDead())While Victim.IsDead() == FalseUtility.Wait(0.1)EndWhileCastTheSpell()EndEvent /; ;/ Event OnDying(Actor Killer)While bIsReadyToGo == FalseUtility.Wait(0.25)EndWhileUtility.Wait(1.0)CastTheSpell()EndEvent /; Event OnDeath(Actor Killer); debug.trace("The OnDeath Event Fired, returning: " + Victim.IsDead() + "For Victim.IsDead.")While bIsReadyToGo == FalseUtility.Wait(0.1)EndWhileCastTheSpell()Self.Dispel()EndEvent Function CastTheSpell()If bIsReanimatedAlready == FalseIf bIsCastYet == FalsebIsCastYet = Trueif victim.IsDead()SpellRef.Cast(CasterActor,Victim)endifEndIfEndIfEndFunction I have tried playing around with the "IsReanimatedAlready" lines but to no avail. So, Two things I'd like to know and have help with is:1. How would I make the target resurrect every time it is killed.2. How would I increase the wait time before it is resurrected (Right now they reanimate immediately after being killed. I would like to extend this time to about 10-15 seconds) Thanks for your help folks! UPDATE: Applied the script which dylbill suggested directly to a draugr actor using the "dunReanimateSelf" spell and it works. The draugr reanimated itself and began attacking me once more. Just need to figure out a way for the script to repeat itself. Update 2: Cracked it! After a couple of hours of tweaking I have found that all I needed to do was change the "OnDeath" Event to "OnDying" and Voila. Dylbill, I can't thank you enough! Edited December 2, 2021 by ashpt Link to comment Share on other sites More sharing options...
dylbill Posted December 1, 2021 Share Posted December 1, 2021 I would keep it simple and put a new script directly on your NPC. Something like this: Scriptname TM_ActorScript extends Actor Spell property SpellRef auto {The name of the Reanimate Spell. (REQUIRED!)} Float Property WaitTime Auto {Set amount of time in seconds after death to reanimate} Event OnDeath(Actor akKiller) Utility.Wait(WaitTime) SpellRef.Cast(self, self) ;this actor casts the reanimate spell on themself EndEventChange the scriptname to something else. Link to comment Share on other sites More sharing options...
AshPtMods Posted December 2, 2021 Author Share Posted December 2, 2021 Thanks for the quick response. The script is working like a charm! The only problem I have now is that it only fires once. I would like for it to trigger every time the target is killed. Any Ideas on that one? Thanks again, you've been a great help. Link to comment Share on other sites More sharing options...
dylbill Posted December 2, 2021 Share Posted December 2, 2021 If that's the case, I suppect the OnDeath event isn't firing for the reanimated actor. To get around this, also try putting the resurrect function in the script: Spell property SpellRef auto {The name of the Reanimate Spell. (REQUIRED!)} Float Property WaitTime Auto {Set amount of time in seconds after death to reanimate} Event OnDeath(Actor akKiller) Utility.Wait(WaitTime) SpellRef.Cast(self, self) ;this actor casts the reanimate spell on themself Utility.Wait(2) Self.Resurrect() EndEvent Link to comment Share on other sites More sharing options...
AshPtMods Posted December 2, 2021 Author Share Posted December 2, 2021 If that's the case, I suppect the OnDeath event isn't firing for the reanimated actor. To get around this, also try putting the resurrect function in the script: Spell property SpellRef auto {The name of the Reanimate Spell. (REQUIRED!)} Float Property WaitTime Auto {Set amount of time in seconds after death to reanimate} Event OnDeath(Actor akKiller) Utility.Wait(WaitTime) SpellRef.Cast(self, self) ;this actor casts the reanimate spell on themself Utility.Wait(2) Self.Resurrect() EndEventAll done Thanks my friend! All I did was change the OnDeath to OnDying and I've got the result I wanted. The Draugr kept reviving. Thank you again! Link to comment Share on other sites More sharing options...
dylbill Posted December 3, 2021 Share Posted December 3, 2021 No problem, glad it's working :) Link to comment Share on other sites More sharing options...
Recommended Posts