;Bloodfever Epidemic - Per-user damage tick

userID = #PARAM1

ticksLeft = GetUserFlag(userID, 56)
ticksLeft = ticksLeft + 1
SetUserFlag(userID, 56, ticksLeft)

if ticksLeft < 25
	plagueLevel = GetUserFlag(userID,55)
	
	if plagueLevel = 3
		SendCombatMessage(userID,"You cough up blood and your insides burn wildly! ")
		if Random(0,7) = 0
			SpawnItem(GetUserMap(userID), 720,GetUserX(userID),GetUserY(userID))
			SendMessageToMap(GetUserMap(userID),GetUserName(userID)+" coughs up a piece of his insides.",#MSG_CRITICAL)
		endif
	else if plagueLevel = 2
		SendCombatMessage(userID,"Your stomach twists violently inside you! ")
	else
		SendCombatMessage(userID,"You feel a stab of pain in your chest! ")
	endif
	
	damage = Ceiling(GetUserMaxHP(userID) / 10)
	damage = damage + Random(0, damage)
	damage = damage * plagueLevel
	
	if getuseraccess(#USERID) < 6
		if GetUserHP(userID) < damage+1
			SetUserFlag(userID, 55, 0)
			SendMessageToAll(GetUserName(userID)+" has become a casualty of the Bloodfever plague!",#MSG_CRITICAL)
			SetUserFlag(0, 55, GetUserFlag(0,55)+1)
		endif
		DamageUser(userID, damage)
	endif

	CreateEffect(48,500,0,GetUserDir(userID),GetUserMap(userID),GetUserX(userID),GetUserY(userID),0,userID,0)
else
	SetUserFlag(userID, 56, 0)
	
	plagueLevel = GetUserFlag(userID,55)
	
	increasePlague = Random(-1,1)
	plagueLevel = plagueLevel + increasePlague
	if plagueLevel > 3
		plagueLevel = 3
	endif
	
	SetUserFlag(userID, 55, plagueLevel)
	
	if increasePlague = -1
		SendMessageToUser(userID,"You feel the Bloodfever weaken inside of you.",#MSG_CRITICAL)
	else if increasePlague = 1
		SendMessageToUser(userID,"You feel the Bloodfever strengthen inside of you.",#MSG_CRITICAL)
	else
		;Don't do anything
		temp = 0
	endif
	
	if plagueLevel = 3
		SendMessageToAll(GetUserName(userID)+"'s Bloodfever infection is at it's highest! He's very contagious and deadly.",#MSG_CRITICAL)
	else if plagueLevel = 2
		SendMessageToAll(GetUserName(userID)+"'s Bloodfever infection is at a high level. He's contagious and should be avoided.",#MSG_CRITICAL)
	else if plagueLevel = 1
		SendMessageToAll(GetUserName(userID)+"'s Bloodfever infection is at a mild level. He's not contagious.",#MSG_CRITICAL)
	else
		SendMessageToAll(GetUserName(userID)+"'s Bloodfever infection has passed.",#MSG_CRITICAL)
	endif
endif

label END

Continue = 1