;Bloodlink - Warp  
;Skill #5

If #MAPID > 996
	If #MAPID < 1000
		SendMessageToUser(#USERID,"Protective energy forbids you from using this here.",#MSG_SERVER)
		GoTo END
	EndIf
EndIf

;Amount of blood needed to cast this spell
BloodCost = 10

;The WarpPoint # to warp to, stored in UserFlag 49
WarpPoint = GetUserFlag(#USERID, 49)

PointA = Floor(WarpPoint % 100000)
PointB = Floor(WarpPoint / 100000)

WarpPoint = PointA

;The map coordinates to warp to
Map = 0
X = 0
Y = 0

;User's mana at time of using skill
Blood = GetUserMana(#USERID)

;For Blood spectre cycling
NumberOfWarpPoints = 10

;WarpPoint data
Label GETMAP

;Churchgrounds
If WarpPoint = 0 
	Map = 159
	X = 3
	Y = 13
;Enlivened Clearing
Elseif WarpPoint = 1 
	Map = 128
	X = 10
	Y = 8
;Oisvo City
Elseif WarpPoint = 2 
	Map = 177
	X = 17
	Y = 7
;Small Town
Elseif WarpPoint = 3 
	Map = 398
	X = 12
	Y = 15
;Altus Vicus
Elseif WarpPoint = 4 
	Map = 375
	X = 10
	Y = 16
;Bergville/Mountian pass
Elseif WarpPoint = 5 
	Map = 305
	X = 3
	Y = 16
;Outpost in desert
Elseif WarpPoint = 6 
	Map = 738
	X = 15
	Y = 16
;Oisvo Deeps
Elseif WarpPoint = 7 
	Map = 1135
	X = 10
	Y = 14
;Gavae Merchant Camp
Elseif WarpPoint = 8 
	Map = 628
	X = 16
	Y = 3
;Tunnel between High Plains and Eastern Grasslands
Elseif WarpPoint = 9 
	Map = 602
	X = 14
	Y = 16
;Underground Caverns near Noctem
Elseif WarpPoint = 10 
	Map = 30
	X = 14
	Y = 7
Else
	SendMessageToUser(#USERID,"Error... No linked spot",#MSG_EMOTE)
	Goto END
Endif

;Blood Spectres can cycle through all portals without linking
CanCycleWarp = 0
If GetUserClass(#USERID) = 2
	BloodCost = 0
	If GetUserWisdom(#USERID) > 34
		CanCycleWarp = 1
	EndIf
EndIf
If GetUserAccess(#USERID) > 5
	CanCycleWarp = 1
EndIf

If CanCycleWarp = 1
	If Map = #MAPID
		WarpPoint=WarpPoint+1
		If WarpPoint = NumberOfWarpPoints
			WarpPoint = 0
		EndIf
		SetUserFlag(#USERID, 49, WarpPoint)
		GoTo GETMAP
	EndIf
;Two linked locations can be stored at once.
Else
	If Map = #MAPID
		If WarpPoint = PointB
			GoTo END
		EndIf
		
		WarpPoint = PointB
		
		GoTo GETMAP
	EndIf
EndIf

If Blood < BloodCost
	SendMessageToUser(#USERID,"You do not have the required blood for such a warp.",#MSG_CRITICAL)
	Goto END
Else
	Blood = Blood - BloodCost
	SetUserMana(#USERID, Blood)
	CreateEffect(1,500,0,#DIR_RIGHT,GetUserMap(#USERID),GetUserX(#USERID),GetUserY(#USERID),0,#USERID,0)
	SendMessageToUser(#USERID, "You return to where your blood flows.", #MSG_CRITICAL)
	WarpUser(#USERID, Map, X, Y)
	CreateEffect(1,500,0,#DIR_RIGHT,GetUserMap(#USERID),GetUserX(#USERID),GetUserY(#USERID),0,#USERID,0)
Endif

Label END

Continue = 0

