4
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

125 lines
3.3 KiB

Scriptname _00E_Smoking_WallMarkerScript extends activemagiceffect
visualeffect property _00E_Smoking_PipeSmokingSmokeExhaleEffect auto
Spell Property _00E_Smoking_WallMarkerSP Auto
Package Property CQJ02_SC02_JesparSitLedge02 Auto
Actor Target
Int AnimationStage
Bool bIsFinished
Event OnEffectStart(Actor akTarget, Actor akCaster)
; Debug.Trace(self + ": OnEffectStart, " + akTarget)
Target = akTarget
AnimationStage = 0
RegisterForSingleUpdate(1.5)
RegisterForSleep()
EndEvent
Event OnUpdate()
if bIsFinished
UnregisterForUpdate()
UnregisterForSleep()
return
endif
_LockAnimationUpdates()
If AnimationStage == 0 && Target.GetSitState() != 3
; Debug.Trace(self + ": OnUpdate, " + Target + ", stage " + AnimationStage + ", waiting...")
RegisterForSingleUpdate(1.0)
Else
AnimationStage += 1
; Debug.Trace(self + ": OnUpdate, " + Target + ", stage " + AnimationStage)
If AnimationStage == 1
Target.SetHeadtracking(False)
Debug.SendAnimationEvent(Target, "WallPipeSmokingEnter")
RegisterForSingleUpdate(2.5)
ElseIf AnimationStage == 2
Debug.SendAnimationEvent(Target, "WallPipeSmokingSmokeLoop")
_00E_Smoking_PipeSmokingSmokeExhaleEffect.Play(Target, -1 as Float, none)
EndIf
EndIf
_UnlockAnimationUpdates()
EndEvent
Event OnPackageChange(Package akOldPackage)
; Debug.Trace(self + ": OnPackageChange, " + Target + ", old package " + akOldPackage)
if akOldPackage != CQJ02_SC02_JesparSitLedge02
; Force exit of the furniture on package change
; A workaround for the magic effect having no IsPathing == 0 condition
; (with that condition NPCs get stuck in a enter-exit loop after fleeing combat from the furniture)
Target.RemoveSpell(_00E_Smoking_WallMarkerSP)
EndIf
EndEvent
Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)
; Debug.Trace(self + ": OnSleepStart, " + Target)
if bIsFinished
UnregisterForSleep()
UnregisterForUpdate()
return
endif
; Force reset of the animations to make the NPC re-enter the furniture (if it wishes).
; Fixes NPCs creeping away from the furniture while the player is sleeping in the same location.
_LockAnimationUpdates()
UnregisterForUpdate()
StopAnimations(True)
Target.RemoveSpell(_00E_Smoking_WallMarkerSP)
_UnlockAnimationUpdates()
EndEvent
Event OnEffectFinish(Actor akTarget, Actor akCaster)
; Debug.Trace(self + ": OnEffectFinish, " + Target)
bIsFinished = True
Target.RemoveSpell(_00E_Smoking_WallMarkerSP)
_LockAnimationUpdates()
StopAnimations(Target.GetParentCell() != (Game.GetForm(0x14) as Actor).GetParentCell())
_UnlockAnimationUpdates()
Target = None
EndEvent
Function StopAnimations(Bool bQuickStop)
If AnimationStage > 0
If AnimationStage > 1
_00E_Smoking_PipeSmokingSmokeExhaleEffect.Stop(Target)
EndIf
Target.SetHeadtracking(True)
If bQuickStop
Debug.SendAnimationEvent(Target, "IdleForceDefaultState")
Else
Debug.SendAnimationEvent(Target, "WallPipeSmokingExit")
Utility.Wait(1.75)
Debug.SendAnimationEvent(Target, "IdleForceDefaultState")
EndIf
AnimationStage = 0
EndIf
EndFunction
Bool _bAnimationUpdatesLocked = False
Function _LockAnimationUpdates()
While _bAnimationUpdatesLocked
Utility.Wait(0.1)
EndWhile
_bAnimationUpdatesLocked = True
EndFunction
Function _UnlockAnimationUpdates()
_bAnimationUpdatesLocked = False
EndFunction