;'BS - Blood Drench' - Blood Spectre class only skill

;This skill regenerates blood at a faster rate than normal.
;This skill is usable on others if facing them.
;This skill is Blood Spectre only.

OrbItem = 36

UserID = #USERID
TargetID = 0

;How many 'ticks' of blood regeneration does the skill have.
SkillDuration = 50 + Floor(GetUserWisdomTotal(UserID) * 2)


;If GetUserAccess(#USERID) < 5
;	;Only Blood Spectre can use this skill
;	If GetUserClass(#USERID) <> 2
;		Goto END
;	EndIf
;EndIf

If HasItem(#USERID,OrbItem) = 0
	SendMessageToUser(#USERID,"You need a "+GetItemName(OrbItem)+" to use this skill.",#MSG_CRITICAL)
	GoTo END
EndIf
TakeItem(#USERID,OrbItem)

Xpos = #XPOS
Ypos = #YPOS
UserDirection = GetUserDirection(UserID) 
If UserDirection = #DIR_UP
     Ypos = Ypos - 1
ElseIf UserDirection = #DIR_DOWN
     Ypos = Ypos + 1
ElseIf UserDirection = #DIR_LEFT
     Xpos = Xpos - 1
ElseIf UserDirection = #DIR_RIGHT
     Xpos = Xpos + 1
EndIf

;If no player is standing in front of the user, the user is casting it on himself.
TargetID = GetUserAtXY(#MAPID, Xpos, Ypos)
If TargetID = 0
	TargetID = UserID
EndIf

If GetUserName(TargetID)="Comrade"
	;SendMessageTouser(TargetID,"Skill: "+GetUserFlag(TargetID, 37),#MSG_EMOTE)
EndIf

;Keeps blood regen skills from stacking on one player.
;The newest cast overwrites the previous ones.
SetUserFlag(TargetID, 37, GetUserFlag(TargetID, 37) + 1)

SendCombatMessage(UserID,"You use 'Blood Drench' ")

If TargetID <> UserID
	SendCombatMessage(TargetID,""+GetUserName(UserID)+" uses the 'Blood Drench' skill on you! ")
EndIf
SendMessageToUser(TargetID,"You feel blood run over you, and your veins flow full of deep crimson.",#MSG_CRITICAL)

Timer(578, 3000, TargetID, SkillDuration, 0)

Label END

Continue = 1