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 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 BlessPriceAll = getBlessingsCost(player:getLevel()) * 5 local BlessPriceEach = getBlessingsCost(player:getLevel()) local BlessPricePvp = getPvpBlessingCost(player:getLevel()) local blessings = 0 for i = 1, 5 do if(player:hasBlessing(i)) then blessings = blessings + 1 end end -- Healing local function addHealKeyword(text, condition, effect) keywordHandler:addKeyword({'heal'}, StdModule.say, {npcHandler = npcHandler, text = text}, function(player) return player:getCondition(condition) ~= nil end, function(player) player:removeCondition(condition) player:getPosition():sendMagicEffect(effect) end ) end addHealKeyword('You are burning. Let me quench those flames.', CONDITION_FIRE, CONST_ME_MAGIC_GREEN) addHealKeyword('You are poisoned. Let me soothe your pain.', CONDITION_POISON, CONST_ME_MAGIC_RED) addHealKeyword('You are electrified, my child. Let me help you to stop trembling.', CONDITION_ENERGY, CONST_ME_MAGIC_GREEN) keywordHandler:addKeyword({'heal'}, StdModule.say, {npcHandler = npcHandler, text = 'You are hurt, my child. I will heal your wounds.'}, function(player) return player:getHealth() < 40 end, function(player) local health = player:getHealth() if health < 40 then player:addHealth(40 - health) end player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) end ) keywordHandler:addKeyword({'heal'}, StdModule.say, {npcHandler = npcHandler, text = 'You aren\'t looking that bad. Sorry, I can\'t help you. But if you are looking for additional protection you should go on the {pilgrimage} of ashes or get the protection of the {twist of fate} here.'}) if(msgcontains(msg, 'bless')) then npcHandler:say("There are five different blessings available in five {sacred places}. These blessings are: the {spiritual shielding,} the {spark of the phoenix}, the {embrace of tibia}, the {fire of the suns} and the {wisdom of solitude}. You have " .. blessings .. " out of 5 blessings. I can also provide you with {all} blessings at once. Additionally, you can receive the {twist of fate} here.", cid) talkState[talkUser] = 0 elseif(msgcontains(msg, 'sacred places')) then npcHandler:say("Just ask in which of the five blessings you are interested in.", cid) talkState[talkUser] = 0 elseif(msgcontains(msg, 'all')) then if(player:hasBlessing(5)) then npcHandler:say("You already possess all blessings.", cid) talkState[talkUser] = 0 else npcHandler:say("For "..BlessPriceAll.." gold, I will bless you with all the blessings you don't already have. Is that okay?", cid) talkState[talkUser] = 1 end elseif(msgcontains(msg, 'spiritual')) then if(player:hasBlessing(4)) then npcHandler:say("I see you received the spiritual shielding in the whiteflower temple south of Thais.", cid) talkState[talkUser] = 0 else npcHandler:say("Would you like to receive the spiritual shielding blessing for "..BlessPriceEach.." gold?", cid) talkState[talkUser] = 2 end elseif(msgcontains(msg, 'phoenix')) then if(player:hasBlessing(2)) then npcHandler:say("I can sense that the spark of the phoenix already was given to you by the dwarven priests of earth and fire in Kazordoon.", cid) talkState[talkUser] = 0 else npcHandler:say("Would you like to receive the spark of the phoenix blessing for "..BlessPriceEach.." gold?", cid) talkState[talkUser] = 3 end elseif(msgcontains(msg, 'embrace')) then if(player:hasBlessing(5)) then npcHandler:say("I can sense the druids north of Carlin provided you with the embrace of tibia.", cid) talkState[talkUser] = 0 else npcHandler:say("Would you like to receive the embrace of tibia blessing for "..BlessPriceEach.." gold?", cid) talkState[talkUser] = 4 end elseif(msgcontains(msg, 'suns')) then if(player:hasBlessing(3)) then npcHandler:say("I can see you recieved the blessing of the two suns in the suntower near Ab'Dendriel.", cid) talkState[talkUser] = 0 else npcHandler:say("Would you like to receive the fire of the suns blessing for "..BlessPriceEach.." gold?", cid) talkState[talkUser] = 5 end elseif(msgcontains(msg, 'wisdom')) then if(player:hasBlessing(1)) then npcHandler:say("I can sense you already talked to the hermit Eremo on the isle of Cormaya and recieved this blessing.", cid) talkState[talkUser] = 0 else npcHandler:say("Would you like to receive the wisdom of solitude blessing for "..BlessPriceEach.." gold?", cid) talkState[talkUser] = 6 end elseif(msgcontains(msg, 'twist')) then if(player:hasBlessing(6)) then npcHandler:say("You already possess this blessing.", 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 "..BlessPricePvp.." gold, child?"}, cid) talkState[talkUser] = 7 end elseif(msgcontains(msg, "wooden stake")) then if(player:getStorageValue(87) < 1) then npcHandler:say("A blessed stake to defeat evil spirits? I do know an old prayer which is said to grant sacred power and to be able to bind this power to someone, or something. ...", cid) npcHandler:say("However, this prayer needs the combined energy of ten priests. Each of them has to say one line of the prayer. ...", cid) npcHandler:say("I could start with the prayer, but since the next priest has to be in a different location, you probably will have to travel a lot. ...", cid) npcHandler:say("Is this stake really important enough to you so that you are willing to take this burden?", cid) talkState[talkUser] = 7 elseif(player:getStorageValue(87) == 2) then if(player:getItemCount(5941) >= 1) then npcHandler:say("Ah, I see you brought a stake with you. Are you ready to receive my line of the prayer then?", cid) talkState[talkUser] = 8 end end elseif(msgcontains(msg, 'yes')) then if(talkState[talkUser] == 1) then if(player:removeMoney(getBlessingsCost(player:getLevel()) *5)) then for i = 1, 5 do player:addBlessing(i) end npcHandler:say("You received all five blessings for "..BlessPriceAll.." gold!", cid) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 2) then if(player:removeMoney(getBlessingsCost(player:getLevel()))) then npcHandler:say("You received the spiritual shielding blessing!", cid) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) player:addBlessing(4) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 3) then if(player:removeMoney(getBlessingsCost(player:getLevel()))) then npcHandler:say("You received the spark of the phoenix blessing!", cid) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) player:addBlessing(2) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 4) then if(player:removeMoney(getBlessingsCost(player:getLevel()))) then npcHandler:say("You received the embrace of tibia blessing!", cid) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) player:addBlessing(5) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 5) then if(player:removeMoney(getBlessingsCost(player:getLevel()))) then npcHandler:say("You received the fire of the suns blessing!", cid) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) player:addBlessing(3) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 6) then if(player:removeMoney(getBlessingsCost(player:getLevel()))) then npcHandler:say("You received the wisdom of solitude blessing!", cid) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) player:addBlessing(1) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 6) then if(player:removeMoney(getBlessingsCost(player:getLevel()))) then npcHandler:say("You received the wisdom of solitude blessing!", cid) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) player:addBlessing(1) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 7) then if(player:getMoney() >= getPvpBlessingCost(player:getLevel())) then npcHandler:say("You received the twist of fate blessing!", cid) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) player:addBlessing(6) else npcHandler:say("You can not afford this blessing!", cid) end talkState[talkUser] = 0 elseif(talkState[talkUser] == 7) then player:setStorageValue(87, 1) npcHandler:say("Alright, I guess you need a stake first. Maybe Gamon can help you, the leg of a chair or something could just do. Try asking him for a stake, and if you have one, bring it back to me.", cid) talkState[talkUser] = 0 elseif(talkState[talkUser] == 8) then if(player:getItemCount(5941) >= 1) then player:setStorageValue(87, 3) npcHandler:say("So receive my prayer: 'Light shall be near - and darkness afar'. Now, bring your stake to Tibra in the Carlin church for the next line of the prayer. I will inform her what to do. ", cid) talkState[talkUser] = 0 end end elseif(msgcontains(msg, 'no')) then npcHandler:say("Okay then.", cid) talkState[talkUser] = 0 end return true end keywordHandler:addKeyword({'pilgrimage'}, StdModule.say, {npcHandler = npcHandler, text = 'Whenever you receive a lethal wound, your vital force is damaged and there is a chance that you lose some of your equipment. With every single of the five {blessings} you have, this damage and chance of loss will be reduced.'}) npcHandler:setMessage(MESSAGE_GREET, "Welcome, adventurer |PLAYERNAME|! If you are new in Tibia, ask me for {help}. If you need {healing} or {blessings} I can help you with that.") npcHandler:setMessage(MESSAGE_WALKAWAY, "May the gods of Neloria be with you, |PLAYERNAME|!") npcHandler:setMessage(MESSAGE_FAREWELL, "May the gods of Neloria be with you, |PLAYERNAME|!") npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())