Scriptname bm_SimpleActionEffectScript extends activemagiceffect Hidden
ImageSpaceModifier Property FadeOut Auto
ImageSpaceModifier Property BlackScreen Auto
ImageSpaceModifier Property FadeIn Auto
Message Property SimpleActionPrompt Auto
Message Property SleepPrompt Auto
Spell Property SimpleActionAbility Auto
Furniture Property Bed Auto
ObjectReference Property BedRef Auto Hidden
Actor Target
bool returnToFirstPerson = false
Event OnEffectStart(Actor akTarget, Actor akCaster)
Target = akTarget
if(Target != Game.GetPlayer() || Target.GetCombatState() != 0)
self.Dispel()
return
endif
int r = SimpleActionPrompt.Show()
if(r == 0)
self.Dispel()
return
elseif(akTarget.IsWeaponDrawn())
akTarget.SheatheWeapon()
Utility.Wait(2.0)
endif
returnToFirstPerson = (Game.GetCameraState() == 0)
Game.ForceThirdPerson()
Game.DisablePlayerControls(1, 1, 1, 0, 0, 0, 0, 0, 0)
self.RegisterForKey(Input.GetMappedKey("Jump"))
if(r == 1) ; Meditating
self.GoToState("Meditating")
elseif(r == 2) ; Sitting
self.GoToState("Sitting")
elseif(r == 3) ; Sleeping
self.GoToState("EnterSleeping")
elseif(r == 4) ; Sleeping sideway
self.GoToState("EnterSleepingSideway")
endif
endEvent
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
self.Dispel()
endEvent
Event OnKeyDown(Int KeyCode)
; Debug.Notification("Pressed key in normal mode")
self.Dispel()
EndEvent
Event OnEffectFinish(Actor akTarget, Actor akCaster)
Game.EnablePlayerControls(1, 1, 1, 0, 0, 0, 0, 0, 0)
self.GoToState("")
endEvent
State EnterSleeping
Event OnBeginState()
Debug.SendAnimationEvent(Target, "idleLayDownEnter")
self.RegisterForSingleUpdate(4.0)
endEvent
Event OnUpdate() ; what happens if dispelled in the middle of this sequence?
int s = SleepPrompt.Show()
if(s == 0) ; yes
self.GoToState("Sleeping")
else
self.GoToState("ExitSleeping")
endif
endEvent
endState
State Sleeping
Event OnBeginState()
BedRef = Target.PlaceAtMe(Bed, 1)
FadeOut.Apply()
Utility.Wait(2.5) ; since Fadeout lasts exactly 3.0s, we need to allow some script delay
FadeOut.PopTo(BlackScreen)
Debug.SendAnimationEvent(Target, "IdleForceDefaultState")
Utility.Wait(0.3)
BedRef.Activate(Target, true) ; this spawns the sleep menu of the befref but it wouldn't work if called while the laying anim is playing.
self.RegisterForSingleUpdate(0.1)
endEvent
Event OnUpdate()
self.GoToState("ExitSleeping")
endEvent
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
endEvent
Event OnKeyDown(Int KeyCode)
; Debug.Notification("Pressed key in sleep mode")
EndEvent
Event OnEndState()
Debug.SendAnimationEvent(Target, "idleLayDownEnterInstant")
Utility.Wait(0.5)
BlackScreen.PopTo(FadeIn)
BedRef.Delete()
endEvent
endState
State ExitSleeping
Event OnBeginState()
self.RegisterForUpdate(0.5)
endEvent
Event OnUpdate()
if(Target.GetCombatState() != 0)
self.Dispel()
endif
endEvent
Event OnEndState()
Debug.SendAnimationEvent(Target, "idleChairExitStart")
endEvent
endState
State EnterSleepingSideway
Event OnBeginState()
Debug.SendAnimationEvent(Target, "idleBedRollRightEnterStart")
self.RegisterForSingleUpdate(6.0)
endEvent
Event OnUpdate() ; what happens if dispelled in the middle of this sequence?
int s = SleepPrompt.Show()
if(s == 0) ; yes
self.GoToState("SleepingSideway")
else
self.GoToState("ExitSleepingSideway")
endif
endEvent
endState
State SleepingSideway
Event OnBeginState()
BedRef = Target.PlaceAtMe(Bed, 1)
FadeOut.Apply()
Utility.Wait(2.5) ; since Fadeout lasts exactly 3.0s, we need to allow some script delay
FadeOut.PopTo(BlackScreen)
Debug.SendAnimationEvent(Target, "IdleForceDefaultState")
Utility.Wait(0.3)
BedRef.Activate(Target, true) ; this spawns the sleep menu of the befref but it wouldn't work if called while the laying anim is playing.
self.RegisterForSingleUpdate(0.1)
endEvent
Event OnUpdate()
self.GoToState("ExitSleepingSideway")
endEvent
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
endEvent
Event OnKeyDown(Int KeyCode)
; Debug.Notification("Pressed key in sleep mode")
EndEvent
Event OnEndState()
Debug.SendAnimationEvent(Target, "idleBedRollRightEnterInstant")
Utility.Wait(0.5)
BlackScreen.PopTo(FadeIn)
BedRef.Delete()
endEvent
endState
State ExitSleepingSideway
Event OnBeginState()
self.RegisterForUpdate(0.5)
endEvent
Event OnUpdate()
if(Target.GetCombatState() != 0)
self.Dispel()
endif
endEvent
Event OnEndState()
Debug.SendAnimationEvent(Target, "idleBedExitStart")
endEvent
endState
State Sitting
Event OnBeginState()
Debug.SendAnimationEvent(Target, "idleSitCrossLeggedEnter")
self.RegisterForUpdate(0.5)
endEvent
Event OnUpdate()
Target.RestoreActorValue("Stamina", 10)
if(Target.GetCombatState() != 0)
self.Dispel()
endif
endEvent
Event OnEndState()
Debug.SendAnimationEvent(Target, "idleChairExitStart")
endEvent
endState
State Meditating
Event OnBeginState()
Debug.SendAnimationEvent(Target, "idleGreyBeardMeditateEnter")
self.RegisterForUpdate(0.5)
endEvent
Event OnUpdate()
Target.RestoreActorValue("Magicka", 10)
if(Target.GetCombatState() != 0)
self.Dispel()
endif
endEvent
Event OnEndState()
Debug.SendAnimationEvent(Target, "idleChairExitStart")
endEvent
endState