local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = true, cost = 10000})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = true, cost = 10000})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = true, cost = 10000})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = true, cost = 10000})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local player = Player(cid)
local blessings = 0
for i = 1, 5 do
if(player:hasBlessing(i)) then
blessings = blessings + 1
end
end
if(msgcontains(msg, 'protecoes')) then
npcHandler:say("Existem cinco tipos diferentes de bencaos disponiveis nos {lugares sagrados}. Essas bencaos sao: a {sabedoria de Mithrandir}, a {centelha de Gruumsh}, o {abraco de Melora}, o {fortaleza de Kurul} e o {destino de Bran}. Voce tem " .. blessings .. " de 5 bencaos. Tambem posso lhe fornecer {todas} as bencaos de uma so vez. Alem disso, voce pode receber a {reviravolta do destino} aqui.", cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'lugares sagrados')) then
npcHandler:say("Sao locais para se conectar com o divino. Basta perguntar em qual das cinco bencaos voce esta interessado.", cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'todas')) then
if(player:hasBlessing(5)) then
npcHandler:say("Voce ja possui todas as bencaos.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Gostaria de receber todas as bencaos?", cid)
talkState[talkUser] = 1
end
elseif(msgcontains(msg, 'fortaleza de Kurul')) then
if(player:hasBlessing(4)) then
npcHandler:say("Vejo que voce ja recebeu a bencao da fortaleza de Kurul.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Gostaria de receber a bencao da fortaleza de Kurul?", cid)
talkState[talkUser] = 2
end
elseif(msgcontains(msg, 'centelha de Gruumsh')) then
if(player:hasBlessing(2)) then
npcHandler:say("Vejo que voce ja recebeu a bencao da centelha de Gruumsh.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Gostaria de receber a bencao da centelha de Gruumsh?", cid)
talkState[talkUser] = 3
end
elseif(msgcontains(msg, 'destino de Bran')) then
if(player:hasBlessing(5)) then
npcHandler:say("Vejo que voce ja recebeu a bencao do destino de Bran.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Gostaria de receber a bencao do destino de Bran?", cid)
talkState[talkUser] = 4
end
elseif(msgcontains(msg, 'abraco de Melora')) then
if(player:hasBlessing(3)) then
npcHandler:say("Vejo que voce ja recebeu a bencao do abraco de Melora.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Gostaria de receber a bencao do abraco de Melora?", cid)
talkState[talkUser] = 5
end
elseif(msgcontains(msg, 'sabedoria de Mithrandir')) then
if(player:hasBlessing(1)) then
npcHandler:say("Vejo que voce ja recebeu a bencao da sabedoria de Mithrandir.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Gostaria de receber a bencao da sabedoria de Mithrandir?", cid)
talkState[talkUser] = 6
end
elseif(msgcontains(msg, 'reviravolta do destino')) then
if(player:hasBlessing(6)) then
npcHandler:say("Voce ja possui a bencao da reviravolta do destino.", cid)
talkState[talkUser] = 0
else
npcHandler:say(
{"This is a special blessing I can bestow upon you once you have obtained at least one of the other blessings and which functions a bit differently. ...",
"It only works when you're killed by other adventurers, which means that the last damage that is the cause of your death was caused by others, not by monsters or the environment. ...",
"The twist of fate will not reduce the death penalty like the other blessings, but instead prevent you from losing your other blessings as well as the amulet of loss, should you wear one. It costs the same as the other blessings. ...",
"Would you like to receive that protection for a sacrifice of 28000 gold, child?"}, cid)
talkState[talkUser] = 7
end
elseif(msgcontains(msg, 'sim')) then
if(talkState[talkUser] == 1) then
if(player:getMoney() >= ((player:getLevel()) * 5)) then
for i = 1, 5 do
player:addBlessing(i)
end
npcHandler:say("Voce recebeu todas as bencaos!", cid)
else
npcHandler:say("Voce nao pode pagar essa bencao!", cid)
end
talkState[talkUser] = 0
elseif(talkState[talkUser] == 2) then
if(player:getMoney() >= (player:getLevel())) then
npcHandler:say("Voce recebeu a bencao da fortaleza de Kurul!", cid)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:addBlessing(4)
else
npcHandler:say("Voce nao pode pagar essa bencao!", cid)
end
talkState[talkUser] = 0
elseif(talkState[talkUser] == 3) then
if(player:getMoney() >= (player:getLevel())) then
npcHandler:say("Voce recebeu a bencao da centelha de Gruumsh!", cid)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:addBlessing(2)
else
npcHandler:say("Voce nao pode pagar essa bencao!", cid)
end
talkState[talkUser] = 0
elseif(talkState[talkUser] == 4) then
if(player:getMoney() >= (player:getLevel())) then
npcHandler:say("Voce recebeu a bencao do destino de Bran!", cid)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:addBlessing(5)
else
npcHandler:say("Voce nao pode pagar essa bencao!", cid)
end
talkState[talkUser] = 0
elseif(talkState[talkUser] == 5) then
if(player:getMoney() >= (player:getLevel())) then
npcHandler:say("Voce recebeu a bencao do abraco de Melora!", cid)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:addBlessing(3)
else
npcHandler:say("Voce nao pode pagar essa bencao!", cid)
end
talkState[talkUser] = 0
elseif(talkState[talkUser] == 6) then
if(player:getMoney() >= (player:getLevel())) then
npcHandler:say("Voce recebeu a bencao da sabedoria de Mithrandir!", cid)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:addBlessing(1)
else
npcHandler:say("Voce nao pode pagar essa bencao!", cid)
end
talkState[talkUser] = 0
elseif(talkState[talkUser] == 7) then
if(player:getMoney() >= getPvpBlessingCost(player:getLevel())) then
npcHandler:say("Voce recebeu a bencao da reviravolta do destino!", cid)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:addBlessing(6)
else
npcHandler:say("Voce nao pode pagar essa bencao!", cid)
end
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'nao')) then
npcHandler:say("Tudo bem.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())