;NPCs in "Dessert Hideaway" (map 129)

PlayerX = #XPOS 
PlayerY = #YPOS 

PlayerHasLetter = HasItem(#USERID,65)
PlayerHasDiamond = HasItem(#USERID,342)
PlayerHasLoveLetter = HasItem(#USERID,343)

PlayerCanTalk = 0

If GetUserClass(#USERID) = 0
	PlayerCanTalk = 1
ElseIf GetUserClass(#USERID) = 1
	PlayerCanTalk = 1
EndIf

If GetUserSprite(#USERID) = 4
	PlayerCanTalk = 1
EndIf

NPC = 0;

If PlayerX = 6
	If PlayerY = 6
	   NPC = 1
	EndIf
Elseif PlayerX = 9
	If PlayerY = 9
	   NPC = 2
	EndIf
Elseif PlayerX = 10
	If PlayerY = 8
	   NPC = 2
	EndIf
Elseif PlayerX = 11
	If PlayerY = 9
	   NPC = 2
	EndIf
Elseif PlayerX = 14
	If PlayerY = 6
	   NPC = 3
	ElseIf PlayerY = 12
	   NPC = 4
	EndIf
Elseif PlayerX = 15
	If PlayerY = 13
	   NPC = 4
	EndIf
EndIf

If NPC = 1
	If PlayerCanTalk = 1
		SendMessageToUser(#USERID,"Dessert Man says 'Oh, good. You're not a bloody zombie. I hate them! Why can't they just leave us alone?'",#MSG_SAY)
	Else
		SendMessageToUser(#USERID,"Dessert Man says 'Ugh, another undead jerk. Look, just leave us alone, alright?'",#MSG_SAY)
	EndIf
ElseIf NPC = 2
	If PlayerCanTalk = 1
		If PlayerHasLetter = 1
			SendMessageToUser(#USERID,"Dessert Woman says 'I miss my brother.'",#MSG_SAY)
		Else
			SendMessageToUser(#USERID,"Dessert Woman says 'I miss my brother, he was a famous blacksmith but now has gone into partial retirement. Give him this message if you ever need him to make you anything.'",#MSG_SAY)
			If IsInvFull(#USERID) = 0
				GiveItem(#USERID,65)
				SendMessageToUser(#USERID,"You got a 'Letter to Blacksmith'",#MSG_EMOTE)
			Else
				SendMessageToUser(#USERID,"Your inventory is full.",#MSG_EMOTE)
			EndIf
		EndIf
	Else
		SendMessageToUser(#USERID,"The Dessert Woman screams at the sight of you!",#MSG_EMOTE)
	EndIf
ElseIf NPC = 3
	If PlayerCanTalk = 1 
		SendMessageToUser(#USERID,"Junk Dealer says 'Hey, check out my wares!'",#MSG_SAY)
	Else
		SendMessageToUser(#USERID,"Junk Dealer says 'Well, a customer's a customer. Just don't touch anything you aren't going to buy.'",#MSG_SAY)
	EndIf
ElseIf NPC = 4
	If PlayerCanTalk = 1
		If PlayerHasDiamond  > 0
			TakeItem(#USERID, 342)
			SendMessageToUser(#USERID,"The Young Woman blushes",#MSG_EMOTE)
			SendMessageToUser(#USERID,"The Young Woman says 'A diamond? He shouldn't have spent so much on me! Here, take this letter back to him, and tell Kutfroat of my love for him.'",#MSG_SAY)
			GiveItem(#USERID, 343)
			SendMessageToUser(#USERID,"You got a Love Letter. How you became a mailman, you don't know.",#MSG_EMOTE)
		ElseIf PlayerHasLoveLetter > 0
			SendMessageToUser(#USERID,"The Young Woman says 'Please, hurry back to my dearest Kutfroat.'",#MSG_SAY)
		Else
			SendMessageToUser(#USERID,"The Young Woman says 'I miss my love back in Oisvo, I haven't heard from him in awhile.'",#MSG_SAY)
		EndIf
	Else
		SendMessageToUser(#USERID,"The Young Woman says 'Why must you come trouble us? It's becuase of creatures like you that we went into hiding!'",#MSG_SAY)
	EndIf
EndIf

Continue = 1