;Death Grasp - Skill


;SendMessageToUser(#USERID,"This skill is undergoing renovation - Comrade",#MSG_SERVER)
;Goto End

Effect = Random(15,17)

DamageAmount=Random(Floor(GetUserWisdomTotal(#USERID)*1.5),Floor(GetUserWisdomTotal(#USERID)*2.5))
ManaReq=Ceiling(GetUserMaxMana(#USERID)*0.33)

If GetUserMana(#USERID)<ManaReq
	BloodNeeded=ManaReq-GetUserMana(#USERID)
	SendMessageToUser(#USERID,"You need "+BloodNeeded+" more blood...",#MSG_SERVER)
	Goto End
Endif
SetUserMana(#USERID,GetUserMana(#USERID)-ManaReq)

PlusX = 0
PlusY = 0

PlayerDirection=GetUserDirection(#USERID)
If PlayerDirection=#DIR_LEFT 
	PlusX = -1
ElseIf PlayerDirection=#DIR_RIGHT 
	PlusX = 1
ElseIf PlayerDirection=#DIR_UP
	PlusY = -1
ElseIf PlayerDirection=#DIR_DOWN 
	PlusY = +1
Endif

MAPTYPE = GetMapType(#MAPID)

i = 0
While i < 8
	i=i+1
	XPos = #XPOS+i*PlusX
	YPos = #YPOS+i*PlusY
	
	TileType = GetTileType(#MAPID, XPos, YPos)
	If TileType = #TILE_WALL
		Goto END
	ElseIf TileType = #TILE_GODONLY 
		Goto END
	ElseIf TileType = #TILE_DOOR 
		Goto END
	EndIf
	
	CreateEffect(Effect, 100*i, 0, PlayerDirection, #MAPID, XPos, YPos,0,0,0)
	
	TargetID = GetUserAtXY(#MAPID, XPos, YPos)
	MonsterID = GetMonsterAtXY(#MAPID, XPos, YPos)
	
	If GetUserAccess(TargetID) > GetUserAccess(#USERID)
		TargetID = 0
	EndIf
	If MAPTYPE = #MAPTYPE_FRIENDLY
		TargetID = 0
	ElseIf MAPTYPE = #MAPTYPE_NEUTRAL
		If GetUserGuild(#USERID) = 0
			TargetID = 0
		ElseIf GetUserGuild(TargetID) = 0
			TargetID = 0
		ElseIf GetUserGuild(#USERID) = GetUserGuild(TargetID)
			TargetID = 0
		EndIf
	Else
		If GetUserGuild(#USERID) <> 0
			If GetUserGuild(#USERID) = GetUserGuild(TargetID)
				TargetID = 0
			EndIf
		EndIf
	EndIf
	
	If TargetID = #USERID
		TargetID = 0
	EndIf
	
	If MonsterID > -1
		UserDamageMonster(MonsterID,Floor(DamageAmount*1.5),#USERID)
		SetMonsterTarget(#MAPID,MonsterID,#USERID)
	Endif
	If TargetID > 0
		SendMessageToMap(#MAPID,GetUserName(#USERID)+" grasps "+GetUserName(TargetID)+" for "+DamageAmount+" damage!",#MSG_CRITICAL)
		UserDamageUser(#USERID,DamageAmount,TargetID)
	EndIf
Wend

Label END

Continue = 1