Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile(getDataDir() .. 'npc/scripts/lib/greeting.lua')
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- -- OTServ event handling functions
- 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)
- -- interesting option for a module here
- -- get more creative as they get drunk?
- shopModule:addBuyableItem({'beer'}, 2006, 10, 3)
- shopModule:addBuyableItem({'wine'}, 2689, 10, 15)
- keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My ship is on the desert. It doesn\'t look well but still can sail. Of course if you know how to steer it."})
- function creatureSayCallback(cid, type, msg)
- if(npcHandler.focus ~= cid) then
- return false
- end
- cname = creatureGetName(cid)
- if talk_state == 0 then
- if msgcontains(msg, 'yes') then -- wanna go to mainland
- level = getPlayerLevel(cname)
- if level >= mainlevel then
- npcHandler:say('Great! Do you want to be a knight, a paladin, a sorcerer or a druid?')
- talk_state = 1
- else
- npcHandler:say('Sorry, you need level ' .. mainlevel .. ' to go to the mainland.')
- talk_state = 0
- end
- else
- npcHandler:say('Come back when you are ready then.')
- talk_state = 0
- end
- elseif talk_state == 1 then -- telling vocation
- talk_state = 2
- if msgcontains(msg, 'sorcerer') then
- npcHandler:say('A mighty sorcerer! Are you sure?')
- vocation = 1
- elseif msgcontains(msg, 'druid') then
- npcHandler:say('A mysterious druid! Are you sure?')
- vocation = 2
- elseif msgcontains(msg, 'paladin') then
- npcHandler:say('A nimble paladin! Are you sure?')
- vocation = 3
- elseif msgcontains(msg, 'knight') then
- npcHandler:say('A valorous knight! Are you sure?')
- vocation = 4
- else
- npcHandler:say('Sorry, there is no such vocation.')
- vocation = 0
- talk_state = 1
- end
- elseif talk_state == 2 then -- confirming vocation
- if msgcontains(msg, 'yes') then
- npcHandler:say('Great! I can send you to The City. Where do you want to go?')
- talk_state = 3
- else
- npcHandler:say('What vocation do you want then?')
- talk_state = 1
- end
- elseif talk_state == 3 then -- telling city name
- if msgcontains(msg, 'city') then
- npcHandler:say('Good luck, young adventurer!')
- setPlayerVocation(cid,vocation)
- setPlayerMasterPos(cid,160,54,7)
- npcHandler:say('/send ' .. cname .. ', 160 54 7')
- talk_state = 0
- focus = 0
- talk_start = 0
- else
- npcHandler:say('Sorry, there is no such city.')
- talk_state = 3
- end
- end
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement