• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved TFS 1.1 Npc Quentin that sells Blessings (Thais temple)

danne3131

Active Member
Joined
Jun 26, 2008
Messages
390
Solutions
1
Reaction score
48
Ive seen some requests on this but no one answered, ive tried to manage this on my own by taking some code from Henricus but i dont succed..
if someone could help me write something for him i would appreciate it very much! Or explain where i should add the code of Henricus! Thanks!
Code:
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 function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msgcontains(msg, "heal") then
        if player:getHealth() >= 50 then
            npcHandler:say("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.", cid)
            return true
        end

        player:addHealth(50 - player:getHealth())
        local conditions = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_BLEEDING, CONDITION_PARALYZE, CONDITION_DROWN, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED}
        for i = 1, #conditions do
            if player:getCondition(conditions[i]) then
                player:removeCondition(conditions[i])
            end
        end
        npcHandler:say("You are hurt, my child. I will heal your wounds.", cid)

    elseif msgcontains(msg, "twist of fate") then
        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 at least half of the damage leading to 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 " .. getPvpBlessingCost(player:getLevel()) .. " gold, child?"
        }, cid)
        npcHandler.topic[cid] = 1

    elseif msgcontains(msg, "wooden stake") then
        if player:getStorageValue(Storage.FriendsandTraders.TheBlessedStake) < 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. ...",
                "However, this prayer needs the combined energy of ten priests. Each of them has to say one line of the prayer. ...",
                "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. ...",
                "Is this stake really important enough to you so that you are willing to take this burden?"
            }, cid)
            npcHandler.topic[cid] = 2

        elseif player:getStorageValue(Storage.FriendsandTraders.TheBlessedStake) == 2 then
            if player:getItemCount(5941) > 0 then
                npcHandler:say("Ah, I see you brought a stake with you. Are you ready to receive my line of the prayer then?", cid)
                npcHandler.topic[cid] = 3
            end
        end

    elseif msgcontains(msg, "adventurer") and msgcontains(msg, "stone") then
        if player:getItemById(18559, true) then
            npcHandler:say("Keep your adventurer's stone well.", cid)
        elseif player:getStorageValue(Storage.AdventurersGuild.FreeStone.Quentin) ~= 1 then
            npcHandler:say("Ah, you want to replace your adventurer's stone for free?", cid)
            npcHandler.topic[cid] = 4
        else
            npcHandler:say("Ah, you want to replace your adventurer's stone for 30 gold?", cid)
            npcHandler.topic[cid] = 5
        end

    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "yes") then
            if player:hasBlessing(6) then
                npcHandler:say('You already possess this blessing.', cid)
                return true
            end

            if player:getBlessings() == 0
                    and not player:getItemById(2173, true) then
                npcHandler:say('You don\'t have any of the other blessings nor an amulet of loss, so it wouldn\'t make sense to bestow this protection on you now. Remember that it can only protect you from the loss of those!', cid)
                return true
            end

            if not player:removeMoney(getPvpBlessingCost(player:getLevel())) then
                npcHandler:say('Oh. You do not have enough money.', cid)
                return true
            end

            player:addBlessing(6)
            npcHandler:say('So receive the protection of the twist of fate, pilgrim.', cid)
        elseif msgcontains(msg, "no") then
            npcHandler:say("Fine. You are free to decline my offer.", cid)
        end
        npcHandler.topic[cid] = 0

    elseif npcHandler.topic[cid] == 2 then
        if msgcontains(msg, "yes") then
            player:setStorageValue(Storage.FriendsandTraders.TheBlessedStake, 1)
            player:setStorageValue(Storage.FriendsandTraders.DefaultStart, 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)
        elseif msgcontains(msg, "no") then
            npcHandler:say("Fine. You are free to decline my offer.", cid)
        end
        npcHandler.topic[cid] = 0

    elseif npcHandler.topic[cid] == 3 then
        if msgcontains(msg, "yes") then
            if player:getItemCount(5941) > 0 then
                player:setStorageValue(Storage.FriendsandTraders.TheBlessedStake, 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)
            end
        elseif msgcontains(msg, "no") then
            npcHandler:say("Fine. You are free to decline my offer.", cid)
        end
        npcHandler.topic[cid] = 0

    elseif npcHandler.topic[cid] == 4 then
        if msgcontains(msg, "yes") then
            player:addItem(18559, 1)
            player:setStorageValue(Storage.AdventurersGuild.FreeStone.Quentin, 1)
            npcHandler:say("Here you are. Take care.", cid)
        end
        npcHandler.topic[cid] = 0

    elseif npcHandler.topic[cid] == 5 then
        if msgcontains(msg, "yes") then
            if not player:removeMoney(30) then
                npcHandler:say("Sorry, you don't have enough money.", cid)
                return true
            end

            player:addItem(18559, 1)
            npcHandler:say("Here you are. Take care.", cid)
        else
            npcHandler:say("No problem.", cid)
        end
        npcHandler.topic[cid] = 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.'})
keywordHandler:addKeyword({'blessings'}, StdModule.say, {npcHandler = npcHandler, text = 'There are five blessings available in five sacred places: the {spiritual} shielding, the spark of the {phoenix}, the {embrace} of Tibia, the fire of the {suns} and the wisdom of {solitude}. Additionally, you can receive the {twist of fate} here.'})
keywordHandler:addKeyword({'spiritual'}, StdModule.say, {npcHandler = npcHandler, text = 'You can ask for the blessing of spiritual shielding in the whiteflower temple south of Thais.'})
keywordHandler:addKeyword({'phoenix'}, StdModule.say, {npcHandler = npcHandler, text = 'The spark of the phoenix is given by the dwarven priests of earth and fire in Kazordoon.'})
keywordHandler:addKeyword({'embrace'}, StdModule.say, {npcHandler = npcHandler, text = 'The druids north of Carlin will provide you with the embrace of Tibia.'})
keywordHandler:addKeyword({'suns'}, StdModule.say, {npcHandler = npcHandler, text = 'You can ask for the blessing of the two suns in the suntower near Ab\'Dendriel.'})
keywordHandler:addKeyword({'solitude'}, StdModule.say, {npcHandler = npcHandler, text = 'Talk to the hermit Eremo on the isle of Cormaya about this blessing.'})

npcHandler:setMessage(MESSAGE_GREET, "Welcome to the world of Neloria |PLAYERNAME|! If you are heavily wounded or poisoned, I can {heal} you for free.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "May the gods of Neloria bless you, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_FAREWELL, "May the gods of Neloria bless you, |PLAYERNAME|!")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

@Limos Lua guru? :D
 
Last edited:
Here try this one, edited 3 mins ago. Hopefully i didnt mess up on something :p
Let me know if u get any errors on console, so i can fix.
Ill take a double look at it in awhile
Code:
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 function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 1.1
   
   
    if msgcontains(msg, "blessing") or msgcontains(msg, "bless") then
            npcHandler:say("Do you want to receive every bless - which means all five available blessings - for " .. totalBlessPrice .. " gold?", cid)
            npcHandler.topic[cid] = 1
        end
       
        elseif msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 1 then
            if player:getBlessings() == 5 then
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by all of five gods!, |PLAYERNAME|.", cid)
                for b = 1, 5 do
                    player:addBlessing(b)
                end
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
            npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "no") then
        if npcHandler.topic[cid] > 0 then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, "Greetings,|PLAYERNAME|, i can sell you {all blessing}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Be careful out there, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Fine just walk away..")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@Slaying World Ohh thats great! :) where should i add this in the script i posted above? =)

I want it to sell every blessing invidually, and you can also ask him for all and he will provide you all blessings.. And since twist of fate already is supported by quentin its not needed! :)

But i want this script inserted with quentin ! :)

I want it to sell every blessing invidually, and you can also ask him for all and he will provide you all blessings.. And since twist of fate already is supported by quentin its not needed! :)

But i want this script inserted with quentin ! :)
Anyone able to make the last step here? =D @Printer maybe? =d
 
Last edited by a moderator:
Code:
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 function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    local oneBlessingPrice = getBlessingsCost(player:getLevel()) * 1.1
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 1.1
    local allfive = "Do you want to receive every bless - which means {all} five available blessings - for " .. totalBlessPrice .. " gold?"
    local onebless = "\nOr I can sell you {one} at a time for "..oneBlessingPrice.." gold each?"
 
    if msgcontains(msg, "blessing") or msgcontains(msg, "bless") then
            -- i hate long strings
            npcHandler:say(allfive..onebless, cid)
            npcHandler.topic[cid] = 1
        end
     
        elseif msgcontains(msg, "all") then
        if npcHandler.topic[cid] == 1 then
            -- player:getBlessings() returns the total amount of blessings the player has
            if player:getBlessings() == 5 then
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by all of five gods!, |PLAYERNAME|.", cid)
                for b = 1, 5 do
                    -- add all 5 blessings
                    player:addBlessing(b)
                end
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, "one") then
        if npcHandler.topic[cid] == 1 then
            -- player:getBlessings() returns the total amount of blessings the player has
            if player:getBlessings() == 5 then
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(oneBlessingPrice) then
                npcHandler:say("You have been blessed by one of the five gods!, |PLAYERNAME|.", cid)
                -- add 1 blessing to the player
                player:addBlessing(1)
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
            npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "no") then
        if npcHandler.topic[cid] > 0 then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, "Greetings,|PLAYERNAME|, i can sell you {all blessing}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Be careful out there, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Fine just walk away..")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
I want it to sell every blessing invidually, and you can also ask him for all and he will provide you all blessings..

People are so funny some times...
Not sure if this fully works, was a while ago I wrote this..
http://paste.ots.me/562457
The message was over 10k letters.
 
I copy-pasted Slaying World Code and added invidual blessings. Havent tested the code though.

Code:
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 blesses = {[1]={t="first"},[2]={t="second"},[3]={t="third"},[4]={t="fourth"},[5]={t="Whi"}}

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 1.1
     
    for k, v in pairs(blesses) do
        if msg == "bless "..k or msg == "bless"..k then
            if player:getBlessings() = k then
                npcHandler:say("You already have been blessed with bless "..k.." !", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by "..blesses[k].t.." god, |PLAYERNAME|.", cid)
                player:addBlessing(k)
            else npcHandler:say("Come back when you have enough money.", cid)
            end
        end
    end
   
    if msg == "all bless"then
            npcHandler:say("Do you want to receive every bless - which means all five available blessings - for " .. totalBlessPrice .. " gold?", cid)
            npcHandler.topic[cid] = 1
        end
      
        elseif msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 1 then
            if player:getBlessings() == 5 then
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by all of five gods!, |PLAYERNAME|.", cid)
                for b = 1, 5 do
                    player:addBlessing(b)
                end
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
            npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "no") then
        if npcHandler.topic[cid] > 0 then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    else
        npcHandler:say("To bless invidually say: {bless} and the bless number, Exmaple: {Bless 1}", cid)
        return true
end

npcHandler:setMessage(MESSAGE_GREET, "Greetings,|PLAYERNAME|, i can sell you {all bless}ings or {bless}es invidually!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Be careful out there, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Fine just walk away..")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Worked great! :) thanks alot WibbenZ! Cheers!

Changed to solved!

@WibbenZ i saw the twist of fate isnt calculating correctly.. i will fix this and upload when im done :)

I copy-pasted Slaying World Code and added invidual blessings. Havent tested the code though.

Code:
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 blesses = {[1]={t="first"},[2]={t="second"},[3]={t="third"},[4]={t="fourth"},[5]={t="Whi"}}

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 1.1
    
    for k, v in pairs(blesses) do
        if msg == "bless "..k or msg == "bless"..k then
            if player:getBlessings() = k then
                npcHandler:say("You already have been blessed with bless "..k.." !", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by "..blesses[k].t.." god, |PLAYERNAME|.", cid)
                player:addBlessing(k)
            else npcHandler:say("Come back when you have enough money.", cid)
            end
        end
    end
  
    if msg == "all bless"then
            npcHandler:say("Do you want to receive every bless - which means all five available blessings - for " .. totalBlessPrice .. " gold?", cid)
            npcHandler.topic[cid] = 1
        end
     
        elseif msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 1 then
            if player:getBlessings() == 5 then
                npcHandler:say("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                npcHandler:say("You have been blessed by all of five gods!, |PLAYERNAME|.", cid)
                for b = 1, 5 do
                    player:addBlessing(b)
                end
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
            else
                npcHandler:say("Come back when you have enough money.", cid)
            end
            npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "no") then
        if npcHandler.topic[cid] > 0 then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    else
        npcHandler:say("To bless invidually say: {bless} and the bless number, Exmaple: {Bless 1}", cid)
        return true
end

npcHandler:setMessage(MESSAGE_GREET, "Greetings,|PLAYERNAME|, i can sell you {all bless}ings or {bless}es invidually!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Be careful out there, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Fine just walk away..")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
It did not work if u were woundering :) Cheers anyway mate!
 
Last edited by a moderator:
"Would you like to receive that protection for a sacrifice of 28000 gold, child?"}, cid)

urs not fixed, tough i have fixed it already and working on the "heal" process :)

Mine is using the functions 1.0 already has, you can change the rates in global.lua I think it is.
The price you got is the one they use on rl - same as the ones you showed in your script above.

Code:
From your script:
if not player:removeMoney(getPvpBlessingCost(player:getLevel())) then

From mine: 
if(player:removeMoney(getPvpBlessingCost(player:getLevel()))) then
 
Mine is using the functions 1.0 already has, you can change the rates in global.lua I think it is.
The price you got is the one they use on rl - same as the ones you showed in your script above.

Code:
From your script:
if not player:removeMoney(getPvpBlessingCost(player:getLevel())) then

From mine:
if(player:removeMoney(getPvpBlessingCost(player:getLevel()))) then


You dont understand what im saying. The script is telling the npc to say that the prize is 28 000 gold.

THIS=
Code:
"Would you like to receive that protection for a sacrifice of 28000 gold, child?"}, cid)
IS NOT ingame..

Its supposed to be like this
Code:
                "Would you like to receive that protection for a sacrifice of "..BlessPricePvp.." gold, child?"}, cid)

Also ur script doesnt remove money from player

Code:
            if(player:removeMoney(getBlessingsCost(player:getLevel()))) then
Useing this code will make it work tough..

Ive fixed heal and such only thing that i have to do now is when you ask him for all and u maybe got 2-3 bless. you are only buying the ones you dont have :)

Cheers anyway for the piece of code that worked!
 
Back
Top