;'Restore Skillbook(s)' - Item use scripts

;What book this is
SkillBook = GetItemFlag4(#TARGETID)

;Which books the player has read
Book1 = 0
Book2 = 0
Book3 = 0

SkillFlag = GetUserSkill(#USERID, 40)
If SkillFlag > 3
	SkillFlag = SkillFlag - 4
	Book3 = 1
EndIf
If SkillFlag > 1
	SkillFlag = SkillFlag - 2
	Book2 = 1
EndIf
If SkillFlag > 0
	SkillFlag = SkillFlag - 1
	Book1 = 1
EndIf

If SkillBook = 1
	If Book1 = 0
		Book1 = 1
	EndIf
ElseIf SkillBook = 2
	If Book2 = 0
		Book2 = 1
	EndIf
ElseIf SkillBook = 3
	If Book3 = 0
		Book3 = 1
	EndIf
EndIf

SkillFlag = 0
SkillLevel = 0
If Book3 = 1
	SkillFlag = SkillFlag + 4
	Book3 = 3
	SkillLevel = SkillLevel +1
EndIf
If Book2 = 1
	SkillFlag = SkillFlag + 2
	SkillLevel = SkillLevel +1
EndIf
If Book1 = 1
	SkillFlag = SkillFlag + 1
	SkillLevel = SkillLevel +1
EndIf

If SkillFlag <> GetUserSkill(#USERID, 40)
	If SkillLevel = 1
		SendMessageToUser(#USERID,"Your now know the Restore skill. It will prove of great use.",#MSG_CRITICAL)
	ElseIf SkillLevel = 2
		SendMessageToUser(#USERID,"Your knowledge in Restore has increased, and you can heal greater wounds.",#MSG_CRITICAL)
	ElseIf SkillLevel = 3
		SendMessageToUser(#USERID,"You are now a master in Restore. It cannot be increased further.",#MSG_CRITICAL)
	EndIf
	SetUserSkill(#USERID, 40, SkillFlag)
EndIf

Continue = 1