;'Decaying Touch' - Skill script

BloodCost = 15

PlusX = 0
PlusY = 0

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

UserID = GetUserAtXY(#MAPID,#XPOS+PlusX,#YPOS+PlusY)

If UserID = #USERID
	SendMessageToUser(#USERID,"What, so now you're attacking yourself?",#MSG_EMOTE)
	GoTo END
EndIf

If UserID = 0
	SendMessageToUser(#USERID,"No player within reach...",#MSG_EMOTE)
	GoTo END
EndIf

If GetUserAccess(UserID) > 5
	SendMessageToUser(#USERID,"You can't attack this player, he'd cream you!",#MSG_CRITCAL)
	GoTo END
EndIf

If GetUserMana(#USERID) < BloodCost
	SendMessageToUser(#USERID,"You don't have the 15 blood required to use this skill.",#MSG_CRITICAL)
	GoTo END
EndIf

If GetMapType(#MAPID) = #MAPTYPE_FRIENDLY 
	SendMessageToUser(#USERID,"You can't use this skill here.",#MSG_EMOTE)
	GoTo END
ElseIf GetMapType(#MAPID) = #MAPTYPE_NEUTRAL
	If GetUserGuild(#USERID) = 0
		SendMessageToUser(#USERID,"You can't use this skill here.",#MSG_EMOTE)
		GoTo END
	ElseIf GetUserGuild(UserID) = 0
		SendMessageToUser(#USERID,"You can't use this skill here.",#MSG_EMOTE)
		GoTo END
	ElseIf GetUserGuild(#USERID) = GetUserGuild(UserID)
		SendMessageToUser(#USERID,"No player within reach...",#MSG_EMOTE)
		GoTo END
	EndIf
EndIf

SetUserMana(#USERID,GetUserMana(#USERID) - BloodCost)

SendMessageToUser(#USERID,"You inflict Decaying Touch upon "+GetUserName(UserID)+".",#MSG_CRITICAL)
SendMessageToUser(UserID,"You have been inflicted by "+GetUserName(#USERID)+"'s Decaying Touch!",#MSG_CRITICAL)

Damage = 0

Damage = GetUserWisdom(#USERID)
Damage = Damage - GetUserWisdom(UserID)

If Damage < 3
	Damage = 3
ElseIf Damage > 10
	Damage = 10
EndIf

Loops = 5

;Warning: This is also the Blood Fever flag
If GetUserFlag(#USERID,7) <> 0
	SetUserFlag(#USERID,7,1)
EndIf

i = 0
While i < Loops
	i=i+1
	If Mod(i,3) = 1
		Timer(226,3000*i,UserID,Damage+1,"You are damaged by Decaying Touch!")
	Else
		Timer(226,3000*i,UserID,Damage,"0")
	EndIf
Wend

Label END

Continue = 1