Jump to content

[LE] NPC Werewolf Transformation


Recommended Posts

A couple posts down someone was asking something similar. I developed a script that works for either the player or an NPC target that has a werewolf transformation. I'm in Mobile ATM so I can't really post code format, but here's the snippet I posted before:

 

;-- Properties --------------------------------------

race property TargetsOriginalRace auto

imagespacemodifier property ChangeFX auto

race property WerewolfBeastRace auto

 

;-- Variables ---------------------------------------

 

;-- Functions ---------------------------------------

function OnEffectFinish(Actor Target, Actor Caster)

utility.Wait(5 as Float)

ChangeFX.Apply(1.00000)

Target.SetRace(TargetsOriginalRace)

endFunction

 

function OnEffectStart(Actor Target, Actor Caster)

TargetsOriginalRace = Target.GetActorBase().GetRace()

self.RegisterForAnimationEvent(Target as objectreference, "SetRace")

utility.Wait(5 as Float)

self.UnRegisterForAnimationEvent(Target as objectreference, "SetRace")

Target.SetRace(WerewolfBeastRace)

endIf

endFunction

Link to comment
Share on other sites

Just in case someone is reading that in the future, I want to give a bit more details here.

 

xyz_BeastTransformScript

 

Scriptname xyz_BeastTransformScript extends ActiveMagicEffect
; Skyrim Creation Kit and Modders --> "NPC Werewolf Transformation"
; for more details see "WerewolfTransformVisual.psc", "C01QuestScript.psc"

; https://forums.nexusmods.com/index.php?/topic/6858232-npc-werewolf-transformation/
; SeraphimKensai posted code snippets

  Race PROPERTY WerewolfBeastRace   auto         ; use autofill within CK
  Race PROPERTY TargetsOriginalRace auto Hidden  ; race holder only

  ImageSpaceModifier PROPERTY ChangeFX auto      ; effect to mask transformation, "WerewolfChangeFX"


;-- EVENTs --

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
    myF_Transform(akTarget)
ENDEVENT


EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
    Utility.Wait(5.0)                                                            ; wait some time before using

IF ( TargetsOriginalRace )
    ChangeFX.Apply(1.0)                                                          ; FX to hide race transformation
    akTarget.SetRace(TargetsOriginalRace)                                        ; back to original stored race if available
ENDIF
ENDEVENT


EVENT OnAnimationEvent(ObjectReference akSource, String asEventName)
; "Animation event, sent when an object we are listening to hits one of the events we are listening for"

;    IF (asEventName == "SetRace")
;        Debug.Trace("AnimationEvent 'SetRace' has been called.. " + self)
;    ENDIF
ENDEVENT

EVENT OnAnimationEventUnregistered(ObjectReference akSource, String asEventName)
; "Event sent when you have been unregistered from receiving an animation event because the target object's animation graph has been unloaded"

;    IF (asEventName == "SetRace")
;        Debug.Trace("AnimationEvent 'SetRace' has been unregistered.. " + self)
;    ENDIF
ENDEVENT


; -- FUNCTION --

;-------------------------------------
FUNCTION myF_Transform(Actor akTarget)
;-------------------------------------
    TargetsOriginalRace = akTarget.GetActorBase().GetRace()                       ; store current race

IF (TargetsOriginalRace == WerewolfBeastRace)                        ; already of werewolf race
    TargetsOriginalRace = None
    self.Dispel()
ELSE
    self.RegisterForAnimationEvent(akTarget as Objectreference, "SetRace")        ; OnAnimationEvent()
    Utility.Wait(5.0)
    self.UnRegisterForAnimationEvent(akTarget as Objectreference, "SetRace")      ; OnAnimationEventUnregistered()

    akTarget.SetRace(WerewolfBeastRace)                                           ; tranform target of magiceffect into werewolf
ENDIF

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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