• 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!

TFS 1.X+ Problem with blessing

Nefre

Member
Joined
May 17, 2012
Messages
41
Reaction score
11
Hello. I use TFS 1.4 8.6 Downgrade by Nekiro. I have the following problem. When I buy bless by bless talkaction or at npc Alice in database i can see 1638480444203.pngbut when i click on ceremonial ankh in game i see 1638480485284.png so in result i have only 3 bless?
Additionally i noticed that after buying blessing and without save when I die I lose my bp but when I relog or there will be global save Im not losing anything.

Bless talkaction:
Lua:
-- 5 or 6 [twist of fate] ?
local totalBlessCount = 5

function onSay(player, words, param)
    if player:hasBlessing(1) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are already blessed.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    else
        local playerBlessCost
        if player:getLevel() < 50 then
            -- under level 50 it's free
            playerBlessCost = 0
        else
            -- from level 50 cost 36k + 200 gold coins for each level
            -- limit to maximum 120k
            playerBlessCost = math.min(1000000, 36000 + (player:getLevel() - 50) * 600)
        end

        if player:removeMoney(playerBlessCost) then
            for blessId = 1, totalBlessCount do
                player:addBlessing(blessId)
            end

            player:sendCancelMessage("You received all blessings for " .. playerBlessCost .. " gold coins.")
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You do not have enough money. Bless on your level costs " .. playerBlessCost .. " gold coins.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
        end
    end

    return false
end

Npc Alice:
Lua:
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 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?'})

npcHandler:addModule(FocusModule:new())

Ceremonial ankh:
Lua:
local blessings = {
    "Spiritual Shielding",
    "Embrace of Tibia",
    "Fire of the Suns",
    "Spark of the Phoenix",
    "Wisdom of Solitude",
    "Twist of Fate"
}

local checkBless = Action()

function checkBless.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local message = {"Received blessings:"}
    for i, blessing in pairs(blessings) do
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, tostring(i))
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, tostring(player:hasBlessing(i)))
        if player:hasBlessing(i) then
            message[#message + 1] = blessing
        end
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, #message == 1 and "No blessings received." or table.concat(message, '\n'))
    return true
end

checkBless:id(12424, 6561)
checkBless:register()
 
Having the same issue, i'm not sure if twist of fate is working on 8.6 because the bless storage marks "7". Already tested by killing a character on PVP but it doesn't maintain the blessings after dying, it just loose them all.

Saw this posts that are related to it

But I start thinking that the twist of fate is not working since you can set value from 1 to 7 in "blessings" table and the player still will loose all his blessings (changing blessing value to force a solution can be a mistake since I don't know how all this is set-up). A possible solution can be done by making a separate value in mySQL for the twist of fate blessing? For example, pvpblessing = 0 and pvpblessing = 1 where 0 will do nothing and 1 will protect player from loosing blessings on PVP fights.

Ex.
Lua:
function onDeath
if player is killed and table.players.pvpblessing = 1 then
player doesn't loose blessings (no idea how to do this)
table.players.pvpblessing = 0 ---- change mysql value to make player loose blessing
end

Then script all the twist of fate stuff on .lua

"When you die, at least 5% of the damage dealt within the last 5 minutes, or the last fatal strike must have been made by a character or its summons. If that criterion is fulfilled and you have the Twist of Fate, you will only lose the Twist of Fate blessing. All other blessings and AoL will stay. If you bought the Twist of Fate blessing but do not have any regular blessings and no AoL then you will not lose the Twist of Fate either. And finally, if you die to monsters, then you’ll loose all regular blessings but this one stays." [/SIZE]If a character has all five blessings and the Twist of Fate blessing, they will not lose any equipment if they die in a PvP fight.


If someone can do all this or reply back if this is a good solution do not hesitate to say
Regards!!
 
Last edited:
Hi @Nefre here's the solution, did my best to solve it with lot of help c: the explaination of it is in the post

Regards!
 
Thanks @ralke So here its bless script talkaction:
Lua:
local totalBlessCount = 5

function onSay(player, words, param)
    if player:hasBlessing(1) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are already blessed.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    else
        local playerBlessCost
        if player:getLevel() < 50 then
            -- under level 50 it's free
            playerBlessCost = 0
        else
            -- from level 50 cost 36k + 200 gold coins for each level
            -- limit to maximum 120k
            playerBlessCost = math.min(1000000, 36000 + (player:getLevel() - 50) * 600)
        end

        if player:removeMoney(playerBlessCost) then
            for blessId = 1, totalBlessCount do
                player:addBlessing(32)
            end

            player:sendCancelMessage("You received all blessings for " .. playerBlessCost .. " gold coins.")
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You do not have enough money. Bless on your level costs " .. playerBlessCost .. " gold coins.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
        end
    end

    return false
end
 
Back
Top