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

Lua TFS 1.2 Looking for Bless Npc

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
526
Reaction score
54
Hi im looking for bless npc that protectes you from losing experience when you die for example if u get blessed you will lose 50% less exp when you die
 
You know that there are at least 4 such npc on this forum.
You can handle the npc XML file yourself, right?

here you have bless.lua

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?'})

local node6 = keywordHandler:addKeyword({'sixth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the twist of fate blessing for 10000 gold?'})
    node6:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 6, premium = true, cost = 10000})
    node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

-- 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({'blessings'}, StdModule.say, {npcHandler = npcHandler, text = 'There are five blessings available: the spiritual shielding, the spark of the phoenix, the embrace of world, the fire of the suns and the wisdom of solitude. Additionally, you can receive the twist of fate here. Just say: {first bless}, {second bless} etc...'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, young |PLAYERNAME|! If you are heavily wounded or poisoned, I can {heal} you for free. Or need {blessings}.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Remember: If you are heavily wounded or poisoned, I can heal you for free.')
npcHandler:setMessage(MESSAGE_FAREWELL, 'May the gods bless you, |PLAYERNAME|!')

npcHandler:addModule(FocusModule:new())
 
You know that there are at least 4 such npc on this forum.
You can handle the npc XML file yourself, right?

here you have bless.lua

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?'})

local node6 = keywordHandler:addKeyword({'sixth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the twist of fate blessing for 10000 gold?'})
    node6:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 6, premium = true, cost = 10000})
    node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

-- 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({'blessings'}, StdModule.say, {npcHandler = npcHandler, text = 'There are five blessings available: the spiritual shielding, the spark of the phoenix, the embrace of world, the fire of the suns and the wisdom of solitude. Additionally, you can receive the twist of fate here. Just say: {first bless}, {second bless} etc...'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, young |PLAYERNAME|! If you are heavily wounded or poisoned, I can {heal} you for free. Or need {blessings}.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Remember: If you are heavily wounded or poisoned, I can heal you for free.')
npcHandler:setMessage(MESSAGE_FAREWELL, 'May the gods bless you, |PLAYERNAME|!')

npcHandler:addModule(FocusModule:new())
well blessing doesnt work. Tried sixth bless and lost exact the same amount of levels like without it.
 
And any error in console? here you got another one.

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({'The Spark of the Phoenix'}, 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({'The Embrace of Tibia'}, 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({'The Spiritual Shielding'}, 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({'The Fire of the Suns'}, 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({'The Wisdom of Solitude'}, 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())

Amount of % you can change in the Lib > Core > Player.lua

Lua:
function Player.getLossPercent(self)
    local blessings = 0
    local lossPercent = {
        [0] = 100,
        [1] = 70,
        [2] = 45,
        [3] = 25,
        [4] = 10,
        [5] = 0
    }

    for i = 1, 5 do
        if self:hasBlessing(i) then
            blessings = blessings + 1
        end
    end
    return lossPercent[blessings]
end
 
Last edited:
And any error in console? here you got another one.

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({'The Spark of the Phoenix'}, 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({'The Embrace of Tibia'}, 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({'The Spiritual Shielding'}, 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({'The Fire of the Suns'}, 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({'The Wisdom of Solitude'}, 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())

Amount of % you can change in the Lib > Core > Player.lua

Lua:
function Player.getLossPercent(self)
    local blessings = 0
    local lossPercent = {
        [0] = 100,
        [1] = 70,
        [2] = 45,
        [3] = 25,
        [4] = 10,
        [5] = 0
    }

    for i = 1, 5 do
        if self:hasBlessing(i) then
            blessings = blessings + 1
        end
    end
    return lossPercent[blessings]
end
This one is even worse doesnt respond to any messages. No errors in these two solutions tho. And yea i have this in player.lua
Lua:
local lossPercent = {
    [0] = 100,
    [1] = 70,
    [2] = 45,
    [3] = 25,
    [4] = 10,
    [5] = 0
}

function Player.getLossPercent(self)
    local blessings = 0
    for i = 1, 5 do
        if self:hasBlessing(i) then
            blessings = blessings + 1
        end
    end
    return lossPercent[blessings]
end
 
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Alice" script="bless.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="139" head="20" body="39" legs="45" feet="7" addons="0" />
</npc>
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

npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I need your help and I'll reward you with nice Blessing if you help me! Just say { first bless : second bless : third bless : fourth bless : fifth bless }You must buy the whole blessing to work well .")

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())
working well
 
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Alice" script="bless.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="139" head="20" body="39" legs="45" feet="7" addons="0" />
</npc>
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

npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I need your help and I'll reward you with nice Blessing if you help me! Just say { first bless : second bless : third bless : fourth bless : fifth bless }You must buy the whole blessing to work well .")

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())
working well
Idk for some reason it doesnt protect my experience at all, npc works tho no errors, tried using fifth bless which means i should lose any exp pretty much but lost like there was no bless
 
Check player.cpp
lossPercent
i have commented skill loss so ignore it because didnt wanted to lose skills when player dies.

and
C++:
double Player::getLostPercent() const
{
    int32_t blessingCount = std::bitset<5>(blessings).count();
    int32_t deathLosePercent = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT);
    if (deathLosePercent != -1) {
        if (isPromoted()) {
            deathLosePercent -= 3;
        }
        deathLosePercent -= blessingCount;
        return std::max<int32_t>(0, deathLosePercent) / 100.;
    }
    double lossPercent;
    if (level >= 25) {
        double tmpLevel = level + (levelPercent / 100.);
        lossPercent = static_cast<double>((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
    }
    else {
        lossPercent = 10;
    }
    if (isPromoted()) {
        lossPercent *= 0.7;
    }
    return lossPercent * pow(0.92, blessingCount) / 100;
}
 
i have commented skill loss so ignore it because didnt wanted to lose skills when player dies.

and
C++:
double Player::getLostPercent() const
{
    int32_t blessingCount = std::bitset<5>(blessings).count();
    int32_t deathLosePercent = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT);
    if (deathLosePercent != -1) {
        if (isPromoted()) {
            deathLosePercent -= 3;
        }
        deathLosePercent -= blessingCount;
        return std::max<int32_t>(0, deathLosePercent) / 100.;
    }
    double lossPercent;
    if (level >= 25) {
        double tmpLevel = level + (levelPercent / 100.);
        lossPercent = static_cast<double>((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
    }
    else {
        lossPercent = 10;
    }
    if (isPromoted()) {
        lossPercent *= 0.7;
    }
    return lossPercent * pow(0.92, blessingCount) / 100;
}
The player must lose levels and skill upon death
I do not agree with you. You can use !bless instead of npc
And you will keep more skill/level
Lua:
        <talkaction words="!bless" script="bless.lua"/>
Code:
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(120000, 36000 + (player:getLevel() - 50) * 1200)
        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 True
end
 
The player must lose levels and skill upon death
I do not agree with you. You can use !bless instead of npc
And you will keep more skill/level
Lua:
        <talkaction words="!bless" script="bless.lua"/>
Code:
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(120000, 36000 + (player:getLevel() - 50) * 1200)
        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 True
end
[/QUOTE]
I cant allow people lose skills thats why it have to stay commented no matter what.
 
I know, maybe you already checked this, but, its better to comment...

did you already checked your config.lua?
May you need to change some values there, because when is 0-10, the config lua takes control, no matter what "core/player.lua" says.

Lua:
-- Deaths
-- NOTE: Leave deathLosePercent as -1 if you want to use the default death penalty formula.
-- For the old formula, set it to 10.
-- For no skill/experience loss, set it to 0.

deathLosePercent = -1
 
I know, maybe you already checked this, but, its better to comment...

did you already checked your config.lua?
May you need to change some values there, because when is 0-10, the config lua takes control, no matter what "core/player.lua" says.

Lua:
-- Deaths
-- NOTE: Leave deathLosePercent as -1 if you want to use the default death penalty formula.
-- For the old formula, set it to 10.
-- For no skill/experience loss, set it to 0.

deathLosePercent = -1
its at -1. What value should it be?
 
:( it needs to be on: -1, but, It's working fine for me, but I didn't use npc blessing, I use Talkaction...

Lua:
function getCost(level)
    if level <= 30 then
        return 2000*5
    elseif level >= 120 then
        return 10000*5
    else
        return ((level - 20) * 200 * 5)
    end
end

function onSay(cid, words, param)
    local p = Player(cid)
    local cost = getCost(getPlayerLevel(cid))
    if(not(isPlayerPzLocked(cid))) then
        if(p:hasBlessing(1) and p:hasBlessing(2) and p:hasBlessing(3) and p:hasBlessing(4) and p:hasBlessing(5) and p:hasBlessing(6)) then
            p:sendCancelMessage("You have already been blessed by the gods.")
            return false
        end
        if(p:removeMoney(cost)) then
            for b = 1,6 do
                p:addBlessing(b)
            end
            p:getPosition():sendMagicEffect(50)
            p:sendTextMessage(19, "You have been blessed by the gods!")
        else
            p:sendCancelMessage("You need "..cost.." gold coins to buy all blessings.")
        end
    else
        p:sendCancelMessage("You can't buy bless, when you are in a battle.")
    end
return false
end

try it, and ill await for response
 
:( it needs to be on: -1, but, It's working fine for me, but I didn't use npc blessing, I use Talkaction...

Lua:
function getCost(level)
    if level <= 30 then
        return 2000*5
    elseif level >= 120 then
        return 10000*5
    else
        return ((level - 20) * 200 * 5)
    end
end

function onSay(cid, words, param)
    local p = Player(cid)
    local cost = getCost(getPlayerLevel(cid))
    if(not(isPlayerPzLocked(cid))) then
        if(p:hasBlessing(1) and p:hasBlessing(2) and p:hasBlessing(3) and p:hasBlessing(4) and p:hasBlessing(5) and p:hasBlessing(6)) then
            p:sendCancelMessage("You have already been blessed by the gods.")
            return false
        end
        if(p:removeMoney(cost)) then
            for b = 1,6 do
                p:addBlessing(b)
            end
            p:getPosition():sendMagicEffect(50)
            p:sendTextMessage(19, "You have been blessed by the gods!")
        else
            p:sendCancelMessage("You need "..cost.." gold coins to buy all blessings.")
        end
    else
        p:sendCancelMessage("You can't buy bless, when you are in a battle.")
    end
return false
end

try it, and ill await for response
I think it works because im losing only two levels instead of three being level 520+
 
Back
Top