Ir para conteúdo

Fibula - Simon the Beggar


Poccnn

Posts Recomendados

Simon the Beggar.xml

<?xml version="1.0"?>
<npc name="Simon the Beggar" script="data/npc/scripts/Fibula/beggar.lua" walkinterval="2000">
  <health now="200" max="200" />
  <look type="153" head="116" body="123" legs="123" feet="40" addons="3"/>
  <parameters>
    <parameter key="message_greet" value="Hello |PLAYERNAME|. I am a poor man. Please {help} me." />
	<parameter key="message_farewell" value="Have a nice day." />
	
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="job;beggar;gold;name;Simon;Tibia;dermot;village;Fibula;Dungeon;Timur;jetty;ship;monster;giant spider;" />
        <parameter key="keyword_reply1" value="I have no job. I am a {beggar}." />
        <parameter key="keyword_reply2" value="I have no {gold} and no {job}, so I am a beggar." />
        <parameter key="keyword_reply3" value="I need gold. I love gold. I need {help}!" />
        <parameter key="keyword_reply4" value="My name is {Simon}. I am a very poor man." />
        <parameter key="keyword_reply5" value="I am Simon. The poorest human all over the continent." />
        <parameter key="keyword_reply6" value="Hehe, do you have a shovel? I can sell you a shovel if you want to return to Tibia." />
        <parameter key="keyword_reply7" value="The magistrate of the village. I heard he is selling something for the Fibula {Dungeon}." />
        <parameter key="keyword_reply8" value="To the north is the village {Fibula}. A very small village." />		
        <parameter key="keyword_reply9" value="I hate Fibula. Too many wolves are here." />		
        <parameter key="keyword_reply10" value="I heard a lot about the Fibula Dungeon. But I never was there." />		
        <parameter key="keyword_reply11" value="I hate Timur. He is too expensive. But sometimes I find maces and hatchets. Timur is buying these items." />		
        <parameter key="keyword_reply12" value="I hate this jetty. I have never seen a ship here." />		
        <parameter key="keyword_reply13" value="There is a large sea-monster outside. I think there is no gritty captain to sail in this quarter." />
        <parameter key="keyword_reply14" value="The strongest monster I know is the giant spider." />		
        <parameter key="keyword_reply15" value="I know that terrible monster. It killed the fishers on the isle on north." />	
		
        <parameter key="module_shop" value="1"/>
        <parameter key="shop_buyable" value="shovel,2554,50;" />
  </parameters>
</npc>

Beggar.lua

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

local talkState,talkUser = {}, 0
local function say(npc,text,cid,talk)
	if not(npcHandler:isFocused(cid)) then return false end
	if talk and not(talkState[talkUser] == talk) then return false end
	doCreatureSay(npc,text,TALKTYPE_PRIVATE_NP,cid)
end
local function changeTalk(talk)
	talkState[talkUser] = talk	
end

function creatureSayCallback(cid, type, msg)
if not(npcHandler:isFocused(cid)) then return false end
local msg = string.lower(msg)
talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'help'))then
		npcHandler:say("I need gold. Can you spend me 100 gold pieces?", cid)
		talkState[talkUser] = 1
	elseif(talkState[talkUser] == 1)then
		if(msgcontains(msg, 'yes'))then
			if(getPlayerMoney(cid) >= 100)then
				doPlayerRemoveMoney(cid, 100)	
				npcHandler:say("Thank you very much. Can you spare 500 more gold pieces for me? I will give you a nice hint.",cid)
				talkState[talkUser] = 11
			else
				npcHandler:say("Hmm, I need 100 gold piece.",cid)
				talkState[talkUser] = 0				
			end
		else
			npcHandler:say("Hmm, maybe next time.",cid)
			talkState[talkUser] = 0
		end
	elseif(talkState[talkUser] == 11)then
		if(msgcontains(msg, 'yes'))then
			if(getPlayerMoney(cid) >= 500)then
				doPlayerRemoveMoney(cid, 500)	
				npcHandler:say("That's great! I have stolen something from Dermot. You can buy it for 200 gold. Do you want to buy it?",cid)
				talkState[talkUser] = 12			
			else
				npcHandler:say("Hmm, I need 500 gold piece.",cid)
				talkState[talkUser] = 0				
			end
		else
			npcHandler:say("Hmm, maybe next time.",cid)
			talkState[talkUser] = 0
		end	
	elseif(talkState[talkUser] == 12)then
		if(msgcontains(msg, 'yes'))then
			if(getPlayerMoney(cid) >= 200)then
			local key = doCreateItemEx(2087)
				doItemSetAttribute(key, "aid", 3940)
				doPlayerAddItemEx(cid, key)
				doPlayerRemoveMoney(cid, 200)	
				npcHandler:say("Now you own the hot key.",cid)
			else
				npcHandler:say("Hmm, I need 200 gold piece.",cid)
			end
		else
			npcHandler:say("Hmm, maybe next time.",cid)
		end	
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'outfit') or msgcontains(msg, 'beard'))then
		npcHandler:say("Haha, that beard is - well, not fake, but there's a trick behind it. I noticed people tend to be more generous towards a poor gramps. Want to know my trick?", cid)
		talkState[talkUser] = 2
	elseif(talkState[talkUser] == 2 and msgcontains(msg, 'yes'))then
		if(getPlayerSex(cid) == PLAYERSEX_MALE)then
			npcHandler:say("I can mix a secret potion which will increase your facial hair growth enormeously. I call it 'Instabeard'. However, it requires certain ingredients. ...",cid)
			addEvent(say,8000,getNpcCid(),"... For the small fee of 20000 gold pieces I will help you mix this potion. Just bring me 100 pieces of ape fur, which are necessary to create this potion. ...",cid,2)
			addEvent(say,14000,getNpcCid(),"... Do we have a deal?",cid,2)
			addEvent(changeTalk,14000,21)
		else
			npcHandler:say("I can mix a secret potion which increases facial hair growth enormeously. I call it 'Instabeard'. However, I fear it works only for men. ...",cid)
			addEvent(say,8000,getNpcCid(),"... Even if it worked on girls, I'd rather not be responsible for you ruining your pretty face. I have an idea though. If you help me brew one of these potions, I sell something nice to you. ...",cid,2)
			addEvent(say,14000,getNpcCid(),"... I still have a pretty gipsy dress and a pearl necklace somewhere, which you could wear instead of this ragged skirt. For the small fee of 20000 gold pieces, it'd be yours. ...",cid,2)
			addEvent(say,20000,getNpcCid(),"... You only have to bring me {100 pieces of ape fur}, so I can brew the potion. Do we have a deal?",cid,2)
			addEvent(changeTalk,20000,21)
		end	
	elseif(talkState[talkUser] == 21 and msgcontains(msg, 'yes'))then
		npcHandler:say("Great! Come back to me once you have the {100 pieces of ape fur} and I'll do my part of the deal.",cid)
		talkState[talkUser] = 0	
	elseif(msgcontains(msg, "100 pieces of ape fur") or msgcontains(msg, "100 ape fur"))then
		if(getPlayerItemCount(cid,5883) >= 100)then
			npcHandler:say("Have you brought me the 100 pieces of ape fur and 20.000 gold pieces?",cid)
			talkState[talkUser] = 22
		else
			npcHandler:say("Ah! you dont have all items.", cid)	
			talkState[talkUser] = 0		
		end
	elseif(talkState[talkUser] == 22 and msgcontains(msg, 'yes'))then
		if(getPlayerItemCount(cid,5883) >= 100 and getPlayerMoney(cid) >= 20000)then
			doPlayerRemoveItem(cid,2743,30, true)
			doPlayerRemoveMoney(cid, 20000)	
			if(getPlayerSex(cid) == PLAYERSEX_MALE)then
				doPlayerAddOutfit(cid,153,1) 
				npcHandler:say("Ahh! Very good. I will start mixing the potion immediately.", cid)
				addEvent(say,10000,getNpcCid(),"... Hmm, I'm not done yet with your potion. But here, let me sprinkle a few drops of my own potion on your face... there you go. Now you just have to wait.",cid)	
			else
				doPlayerAddOutfit(cid,157,2) 
				npcHandler:say(" Ahh! Very good. I will start mixing the potion immediately and sell it to some poor foo- eh, man. Goodbye", cid)				
			end
			talkState[talkUser] = 23	
		else
			npcHandler:say("Ah! you dont have all items or all money.", cid)	
			talkState[talkUser] = 0		
		end		
	elseif(talkState[talkUser] == 23)then
		if(msgcontains(msg, 'beard') or msgcontains(msg, 'addon') and getPlayerSex(cid) == PLAYERSEX_MALE)then
			npcHandler:say("Aha! I can see it! Now that you've waited patiently without shaving, your beard is perfect! All thanks to my, err, potion. Yes. Goodbye!", cid)	
		elseif(msgcontains(msg, 'Gypsy Dress') and getPlayerSex(cid) == PLAYERSEX_FEMALE)then
			npcHandler:say("Oh, I'm sorry... I almost forgot! Okay, okay... here is your promised dress. I'm sure it will look so much better on you than on me- I mean, my, err, sister.", cid)
		end
		talkState[talkUser] = 0			
	elseif(msgcontains(msg, 'staff'))then
		if(getPlayerItemCount(cid,6107) < 1)then
			doPlayerSetStorageValue(cid,1052,1) --1052
			npcHandler:say("I can give you the staff in case you find it and bring me my lost staff.", cid)
		else
			doPlayerRemoveItem(cid,6107,1, true)
			if(getPlayerSex(cid) == PLAYERSEX_MALE)then
				doPlayerAddOutfit(cid,153,2)
			else
				doPlayerAddOutfit(cid,157,1)
			end
			npcHandler:say("Thank you for recovering my lost staff. take yours as a reward.", cid)
		end
	else
		npcHandler:say('...?',cid)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...