enderalse/source/scripts/sprigganfxscript.psc

146 lines
3.1 KiB
Plaintext

Scriptname SprigganFXSCRIPT extends ActiveMagicEffect
{Attaches and controlss spriggan FX}
; Eddoursul 2024.01.27: Multi-stage dying, fixed the KillFX Papyrus warning
VisualEffect Property SprigganFXAttachEffect Auto
Spell Property crSprigganHeal01 Auto
Spell Property crSprigganCallCreatures Auto
Idle Property FFselfIdle Auto
bool bAnimEffects = true
;===============================================
auto state Alive
event OnEffectStart(Actor Target, Actor Caster)
If ! Target || Target == Game.GetForm(0x14)
GotoState("DoNothing")
Dispel()
return
EndIf
if bAnimEffects
bAnimEffects = false
SprigganFXAttachEffect.Stop(Target)
Target.PlaySubGraphAnimation("KillFX")
endif
If Target.IsDead()
GotoState("DoNothing")
Dispel()
EndIf
endevent
event OnCombatStateChanged(Actor akTarget, int aeCombatState)
Actor actorRef = GetTargetActor()
if ! actorRef || ! actorRef.Is3DLoaded()
return
endif
if aeCombatState == 0
if actorRef.IsDead()
GotoState("Dying")
return
endif
SprigganFXAttachEffect.Stop(actorRef)
return
endif
if aeCombatState == 1
if ! bAnimEffects
bAnimEffects = true
actorRef.PlaySubGraphAnimation("Revive")
endif
SprigganFXAttachEffect.Play(actorRef, -1)
actorRef.playIdle(FFselfIdle)
Utility.Wait(Utility.RandomFloat(1.0, 3.0))
if GetState() == "Alive"
crSprigganCallCreatures.cast(actorRef, actorRef)
endif
endif
endevent
event onDying(actor myKiller)
GotoState("Dying")
endevent
event onDeath(actor myKiller)
GotoState("Dying")
endevent
event OnEnterBleedout()
Actor actorRef = GetTargetActor()
SprigganFXAttachEffect.Stop(actorRef)
if actorRef.GetActorValue("Variable07")
RegisterForAnimationEvent(actorRef, "BleedoutStop")
return
endif
actorRef.SetActorValue("Variable07", 1)
Utility.Wait(Utility.RandomFloat(2.0, 3.5))
if GetState() == "Alive"
RegisterForAnimationEvent(actorRef, "BleedoutStop")
crSprigganHeal01.Cast(actorRef)
actorRef.EvaluatePackage()
endif
endevent
event OnAnimationEvent(ObjectReference akSource, string asEventName)
UnregisterForAnimationEvent(akSource, asEventName)
SprigganFXAttachEffect.Play(akSource)
endevent
endstate
state Dying
event OnBeginState()
RegisterForSingleUpdate(Utility.RandomFloat(2.0, 3.5))
UnregisterForAnimationEvent(GetTargetActor(), "BleedoutStop")
endevent
event OnCellAttach()
RegisterForSingleUpdate(1.0)
endevent
event OnCellDetach()
UnregisterForUpdate()
GotoState("Dead")
SprigganFXAttachEffect.Stop(GetTargetActor())
Dispel()
endevent
event OnUpdate()
SprigganFXAttachEffect.Stop(GetTargetActor())
GotoState("Dead")
RegisterForSingleUpdate(Utility.RandomFloat(3.0, 7.5))
endevent
endstate
state Dead
event OnUpdate()
Dispel()
endevent
event OnEffectFinish(Actor akTarget, Actor akCaster)
GotoState("DoNothing")
if bAnimEffects
bAnimEffects = false
akTarget.PlaySubGraphAnimation("KillFX")
endif
endevent
endstate
state DoNothing
endstate
; Compiler wants it here
event OnEnterBleedout()
endevent