;'PZ - Blood Fever' Skill script

MinimumBloodCost = 20
Effect = 24

If GetUserAccess(#USERID) < 5
	;Only Plague Zombies can use this skill
	If GetUserClass(#USERID) <> 4
		Goto END
	EndIf
	If GetMapType(#MAPID) = #MAPTYPE_FRIENDLY
		SendCombatMessage(#USERID,"You cannot use this here ")
		GoTo END
	EndIf
	If GetUserMaxMana(#USERID) < MinimumBloodCost
		SendCombatMessage(#USERID,"You don't have enough blood ")
		GoTo END
	EndIf
	If GetUserMana(#USERID) < GetUserMaxMana(#USERID)
		SendCombatMessage(#USERID,"You don't have enough blood ")
		GoTo END
	EndIf
	
	SetUserMana(#USERID,GetUserMana(#USERID) - GetUserMaxMana(#USERID))
EndIf

SendMessageToMap(#MAPID,GetUserName(#USERID)+" releases a plume of spores...",#MSG_EMOTE)
CreateEffect(Effect,500,0,#DIR_RIGHT,GetUserMap(#USERID),GetUserX(#USERID),GetUserY(#USERID),0,#USERID,0)

ID = GetNextMapUser(0,#MAPID)
While ID > 0
  If ID <> #USERID
	If GetUserClass(ID) <> 4
		Chance = GetUserAgilityTotal(ID) - GetUserAgilityTotal(#USERID)
		If Chance < 3
			Chance = 3
		EndIf
		If Random(0,Chance) = 0
			If GetUserFlag(ID,7)<>2
				SendMessageToUser(ID,"You have contracted Blood Fever!",#MSG_CRITICAL)
				SendMessageToUser(ID,"You will die soon...",#MSG_CRITICAL)
				SetUserFlag(ID,7,1)
				;60000
				Timer(133,120000,ID,0,0)
			EndIf
		EndIf
	EndIf
  EndIf
	ID = GetNextMapUser(ID,#MAPID)
Wend

Label END

Continue = 1

