Scriptname _00E_MeditationHotkeyAlias extends ReferenceAlias Hidden 

int function _GetScriptVersion() Global
	return 1
endFunction

Function UpdateKeyRegistration()
	RegisterForKey(iMeditateKeycode)
EndFunction

Function SetMeditateKey(int iNewMeditateKeycode)
	UnregisterForKey(iMeditateKeycode)
	iMeditateKeycode = iNewMeditateKeycode
	UpdateKeyRegistration()
EndFunction

Event OnInit()
	UpdateKeyRegistration()
EndEvent

Event OnPlayerLoadGame()
	UpdateKeyRegistration()
EndEvent

Event OnKeyDown(Int KeyCode)

	Spell meditateSpell = _00E_Class_Meditate.GetNthSpell(0)
	Actor PlayerREF = GetReference() as Actor

	If ! Utility.IsInMenuMode() && PlayerREF.HasSpell(_00E_Class_Meditate) && ! UI.IsTextInputEnabled() && ! PlayerRef.IsOnMount() && ! PlayerRef.IsSwimming() && Game.IsLookingControlsEnabled() && ! UI.IsMenuOpen("Dialogue Menu") && PlayerREF.GetCurrentLocation() != _00E_Dreamworld_Location
		meditateSpell.Cast(PlayerREF, PlayerREF)
	EndIf

EndEvent

Int Property iMeditateKeycode = 21 Auto  ; 21 (Y on QWERTY, Z on QWERTZ)

Shout Property _00E_Class_Meditate  Auto  

Location Property _00E_Dreamworld_Location  Auto