#===============================================================#
#   )      (\_     | WOLFPACK 13.0.0 Scripts                    #
#  ((    _/{  "-;  | Created by: DarkStorm                      #
#   )).-' {{ ;'`   | Revised by:                                #
#  ( (  ;._ \\ ctr | Last Modification: Created                 #
#===============================================================#
# Script for Recall (Magic)										#
#===============================================================#

from recall_rune import isrune
from wolfpack.utilities import fizzle

def onSpellSuccess( char, spell, type, target ):
	# Check the target
	if not isrune( target.item ):
		char.socket.sysmessage( "This is not a rune." )
		fizzle( char )
		return

	item = target.item

	if item.gettag( 'marked' ) != 1:
		char.socket.sysmessage( 'This rune is not marked.' )
		return 1

	if item.gettag( 'target_map' ) != char.pos.map:
		char.socket.sysmessage( "You can't move between the world using a rune." )
		return 1
	
	char.soundeffect( 0x1FC )
	char.removefromview()
	char.moveto( item.gettag( 'target_x' ), item.gettag( 'target_y' ), item.gettag( 'target_z' ) )
	char.update()
	char.soundeffect( 0x1FC )
	
	# We moved so resync us
	char.socket.resendworld()
