Ir para conteúdo

Rookgaard - Lily


Poccnn

Posts Recomendados

Lily.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Lily" script="data/npc/scripts/Rookgaard/Lily.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="138" head="78" body="119" legs="105" feet="115" addons="0"/>	
    <parameters>
        <parameter key="message_greet" value="Welcome |PLAYERNAME|! You look a little stressed today. If you like to view my offers of potions, just ask me for a trade. In case you're looking for the marketplace and dungeons, just follow the path to the east!/>
        <parameter key="message_farewell" value="Take care, |PLAYERNAME|."/>
        <parameter key="module_keywords" value="1" />
		
        <parameter key="keywords" value="monsters;job;name;Lily;mainland;druid;tibia;Hyacinth;Crunor;" />
        <parameter key="keyword_reply1" value="Sadly, our little village of Rookgaard is invaded by monsters. From the dungeons they creep to the surface and attack the city. We always need adventurers helping us to fight them." />
        <parameter key="keyword_reply2" value="I'm a druid, bound to the spirit of nature. My potions will help you if you feel bad. I also buy blueberries and cookies. Just ask me for a trade." />
        <parameter key="keyword_reply3" value="My name is Lily, like the flower. It also stands for purity, just like my potions are!" />
        <parameter key="keyword_reply4" value="Yes?" />
        <parameter key="keyword_reply5" value="The main continent is huge! The gods of Tibia created everything from great seas, deep jungles and large deserts." />
        <parameter key="keyword_reply6" value="Being a druid is a wonderful profession. You control the forces of nature and can heal others." />
        <parameter key="keyword_reply7" value="Tibia is our beautiful world, created by the gods. Being a druid, I'm a worshipper of Crunor." />
        <parameter key="keyword_reply8" value="Hyacinth also sells small health potions. He lives outside the village, in a hidden place." />		
        <parameter key="keyword_reply9" value="Crunor is the great lord of trees and the creator of all plants. Despite what some people believe, he didn't create the monsters, though." />		
		
        <parameter key="module_shop" value="1"/>
		<parameter key="shop_buyable" value="antidote potion,8474,50;small health potion,8704,20;"/>
		<parameter key="shop_sellable" value="cookie,2687,1;empty potion flask,7636,5;vial,2006,5;"/>
    </parameters>
</npc>

Lily.lua

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local tipo,count,item,price,more
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

function tibiaTime(min, sec)
    suffix = ''
    varh = (min*60+sec)/150
    tibH = math.floor(varh)
    tibM = math.floor(60*(varh-tibH))
    if tonumber(tibH) > 11 then
		tibH = tonumber(tibH) - 12
		suffix = ' pm'
    else
		suffix = ' am'
    end
    if tibH == 0 then
		tibH = 12
    end
    if (tibH < 10) then
        tibH = '0'..tibH
    end
    if (tibM < 10) then
        tibM = '0'..tibM
    end
    return (tibH..':'..tibM..suffix)
end

function creatureSayCallback(cid, type, msg)
	tipo,count,item = msg:trade()
	if(not npcHandler:isFocused(cid)) then		return false	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
    if msgcontains(msg, 'time') then
		npcHandler:say("It is about "..tibiaTime(os.date('%M'), os.date('%S'))..". But does it really matter? Don't rush yourself and enjoy all these little moments.", cid)
   elseif msgcontains(msg, 'blueberry')then
		npcHandler:say("how many blueberry do you have?", cid)
		talkState[talkUser] = 1
	elseif(talkState[talkUser] == 1)then
		if(count >= 5)then
			npcHandler:say('I pay '..math.proxInteger(count/5)..' gps on '..count..' blueberry. accepted?', cid)
			talkState[talkUser] = 2
		elseif(count > 100)then
			npcHandler:say('Tell me counter equal or less than 100.', cid)
		else
			npcHandler:say('I pay 1 gp for every 5 blueberry.', cid)
		end
	elseif(talkState[talkUser] == 2)then
		if msgcontains(msg, 'yes') then
			if(doPlayerRemoveItem(cid,2677,count) == true)then
				npcHandler:say('thank you very much!',cid)
				doPlayerAddMoney(cid,math.proxInteger(count/5))
			else
				npcHandler:say('Hummm...',cid)
			end
		else
			npcHandler:say('Sorry for my bad offer.',cid)
		end	
		talkState[talkUser] = 0
	elseif not(foodSayString(msg))then
		npcHandler:say('sorry but I do not know what they wanted.', cid)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Editado por Poccnn
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...