Scriptname SuH_spellES_teliRealm extends activemagiceffect  

SuH_Fun property _f auto
SuH_Status property _s auto

Event OnInit()
	_f = Game.GetFormFromFile(0x814, "Succubus Heart.esp") as SuH_Fun
	_s = Game.GetFormFromFile(0x16E496, "Succubus Heart.esp") as SuH_Status
endEvent

Event OnEffectStart(actor akTarget, actor akCaster)
	;if PlayerRef.GetParentCell() == SuH_realm
	if _s.PlayerRef.IsInCombat()
		debug.Notification("Can't use this spell while in combat.")
	else
		if _s.PlayerRef.GetWorldSpace() == _s.SuH_worldspace
			if _s.SuH_CHKdied && _s.SuH_SETrandomdeathspawn
				int rand = Utility.RandomInt(1, 8)
				if rand == 1
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn1)
				elseif rand == 2
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn2)
				elseif rand == 3
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn3)
				elseif rand == 4
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn4)
				elseif rand == 5
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn5)
				elseif rand == 6
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn6)
				elseif rand == 7
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn7)
				elseif rand == 8
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn8)
				else
					_s.PlayerRef.MoveTo(_s.SuH_sd_spawn1)
				endIf
			else
				Int i = _s.SuH_menu_teliWorld.Show()
				if i == 0
					_s.PlayerRef.MoveTo(_s.SuH_sd_returnpoint)
				elseif i == 1
					_s.PlayerRef.MoveTo(_s.SuH_sd_returnpointcell)
				elseif i == 2
					int rand = Utility.RandomInt(1, 8)
					if rand == 1
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn1)
					elseif rand == 2
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn2)
					elseif rand == 3
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn3)
					elseif rand == 4
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn4)
					elseif rand == 5
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn5)
					elseif rand == 6
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn6)
					elseif rand == 7
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn7)
					elseif rand == 8
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn8)
					else
						_s.PlayerRef.MoveTo(_s.SuH_sd_spawn1)
					endIf
				endIf		
			endIf
		else
			_s.SuH_sd_lostchest.RemoveItem(_s.Gold001, 999999)
			;SuH_sd_lostchest.RemoveAllItems(SuH_sd_goldchest)
			;SuH_actor_tali.RemoveItem(Gold001, -1)
			_s.SuH_sd_returnpoint.MoveTo(_s.PlayerRef)
			_s.PlayerRef.MoveTo(_s.SuH_sevaspawn)
			_s.SuH_CHKdied = 0
		endIf
	endIf
endEvent