Jump to content

Recommended Posts

Posted (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 CasterActor
actor Victim
bool bIsCastYet = False
bool bIsReanimatedAlready = False
bool bIsReadyToGo = False
booL bIsDying = False
;======================================================================================;
; EVENTS /
;=============/
Event OnEffectStart(Actor Target, Actor Caster)
victim = target
CasterActor = Caster
if (victim.HasMagicEffect(ReanimateEffect))
bIsReanimatedAlready = True
Self.Dispel()
endIf
bIsReadyToGo = true
utility.wait(0.5)
if (bIsDying) == False
Self.Dispel()
endif
EndEvent
Event OnDying(Actor Killer)
bIsDying = true
EndEvent
;/ Event OnDying(Actor Killer)
while (bIsReadyToGo == False)
Utility.Wait(0.1)
endwhile
; debug.trace("Victem is Dead is returning: " + Victim.IsDead())
While Victim.IsDead() == False
Utility.Wait(0.1)
EndWhile
CastTheSpell()
EndEvent /;
;/ Event OnDying(Actor Killer)
While bIsReadyToGo == False
Utility.Wait(0.25)
EndWhile
Utility.Wait(1.0)
CastTheSpell()
EndEvent /;
Event OnDeath(Actor Killer)
; debug.trace("The OnDeath Event Fired, returning: " + Victim.IsDead() + "For Victim.IsDead.")
While bIsReadyToGo == False
Utility.Wait(0.1)
EndWhile
CastTheSpell()
Self.Dispel()
EndEvent
Function CastTheSpell()
If bIsReanimatedAlready == False
If bIsCastYet == False
bIsCastYet = True
if victim.IsDead()
SpellRef.Cast(CasterActor,Victim)
endif
EndIf
EndIf
EndFunction

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 by ashpt
Posted

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 
EndEvent

Change the scriptname to something else.

Posted

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.

Posted

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
Posted

 

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

All 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!

  • Recently Browsing   0 members

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