• 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 0.X Bless System - Improved

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,397
Solutions
17
Reaction score
148
Location
Brazil
Hello everyone, everything good?

I have a bless system on my server that works normally (by talkaction). I would like to put in an improved system of blessing, where the original would stay and put another one, which would lower the death penalties. It's possible? Could you help me create it? If possible I would like to place it on an NPC.

My original bless MOD:

XML:
    <config name="bless-system-config"><![CDATA[
        blessSystem = {}
        blessSystem.needPremium = getBooleanFromString(getConfigValue('blessingsOnlyPremium'))
        blessSystem.config = {
            baseCost = 2000,
            levelCost = 200,
            startLevel = 30,
            endLevel = 120
        }
    ]]></config>

    <lib name="bless-system-lib"><![CDATA[
        domodlib('bless-system-config')

        function blessSystem.buyAllBlessings(cid)
            local price = blessSystem.config.baseCost
            if(getPlayerLevel(cid) > blessSystem.config.startLevel) then
                price = (price + ((math.min(blessSystem.config.endLevel, getPlayerLevel(cid)) - blessSystem.config.startLevel) * blessSystem.config.levelCost))
            end

            price = price * 5 * 1.2
            if(blessSystem.needPremium and not isPremium(cid)) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to use blessings.")
                return false
            end

            for i = 1, 5 do
                if(getPlayerBlessing(cid, i)) then
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have all blessings.")
                    return false
                end
            end

            if(not doPlayerRemoveMoney(cid, price)) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enough money for blessings. (You need " .. price .. " gp's)")
                return false
            end

            for i = 1, 5 do
                doPlayerAddBlessing(cid, i)
            end

            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have been blessed by the gods!")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
            return true
        end
    ]]></lib>

    <talkaction words="!blesscheck;!blesstest" event="script"><![CDATA[
        domodlib('bless-system-config')

        local BLESSINGS = {"Wisdom of Solitude", "Spark of the Phoenix", "Fire of the Suns", "Spiritual Shielding", "Embrace of Tibia"}
        function onSay(cid, words, param)
            local result = ""
            for i = 1, (table.maxn(BLESSINGS) - 1) do
                result = (getPlayerBlessing(cid, i) and result .. (result:len() > 0 and ", " or "") .. BLESSINGS[i] or result)
            end

            return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result:len() > 0 and "Currently you have the following blessings: " .. result .. "." or "You do not have any blessing.")
        end
    ]]></talkaction>

    <talkaction words="!bless;/bless" event="script"><![CDATA[
        domodlib('bless-system-config')
        domodlib('bless-system-lib')

        function onSay(cid, words, param, channel)
            blessSystem.buyAllBlessings(cid)
            return true
        end
    ]]></talkaction>
 
just limit your talkaction blessing, change all loops to
Code:
for i = 1, 2 do
and price
Lua:
price = price * 2 * 1.2
copy buyAllBlessings function to npc and change it to bless from 3 to 5, now trigger that function after saying some words to npc
 
just limit your talkaction blessing, change all loops to
Code:
for i = 1, 2 do
and price
Lua:
price = price * 2 * 1.2
copy buyAllBlessings function to npc and change it to bless from 3 to 5, now trigger that function after saying some words to npc
Can you show me how to do it? I didn't understand how this new blessing would lower the exp and skill penalties.
 
blessing by definition lower the exp and skill penalties so what different about your "new blessing" would be? Increase your basic blessing in config.lua
Code:
    blessingReductionBase = 30
    blessingReductionDecrement = 5
    eachBlessReduction = 8
npc lua
Lua:
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 buyAllBlessings(cid)
        local blessSystem.config = {
            baseCost = 2000,
            levelCost = 200,
            startLevel = 30,
            endLevel = 120
        }
            local price = blessSystem.config.baseCost
            if(getPlayerLevel(cid) > blessSystem.config.startLevel) then
                price = (price + ((math.min(blessSystem.config.endLevel, getPlayerLevel(cid)) - blessSystem.config.startLevel) * blessSystem.config.levelCost))
            end

            price = price * 3 * 1.2
            if(blessSystem.needPremium and not isPremium(cid)) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to use blessings.")
                return false
            end

            for i = 3, 5 do
                if(getPlayerBlessing(cid, i)) then
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have all blessings.")
                    return false
                end
            end

            if(not doPlayerRemoveMoney(cid, price)) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enough money for blessings. (You need " .. price .. " gp's)")
                return false
            end

            for i = 3, 5 do
                doPlayerAddBlessing(cid, i)
            end

            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have been blessed by the gods!")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
            return true
        end
function say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            addEvent(say, delay, param)
        end
    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
if msgcontains(msg, 'bless') then
buyAllBlessings()
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
in your talkaction mod change all
Lua:
for i = 1, 5 do
to
Lua:
for i = 1, 2 do
and price
Code:
price = price * 2 * 1.2
 
blessing by definition lower the exp and skill penalties so what different about your "new blessing" would be? Increase your basic blessing in config.lua
Code:
    blessingReductionBase = 30
    blessingReductionDecrement = 5
    eachBlessReduction = 8
npc lua
Lua:
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 buyAllBlessings(cid)
        local blessSystem.config = {
            baseCost = 2000,
            levelCost = 200,
            startLevel = 30,
            endLevel = 120
        }
            local price = blessSystem.config.baseCost
            if(getPlayerLevel(cid) > blessSystem.config.startLevel) then
                price = (price + ((math.min(blessSystem.config.endLevel, getPlayerLevel(cid)) - blessSystem.config.startLevel) * blessSystem.config.levelCost))
            end

            price = price * 3 * 1.2
            if(blessSystem.needPremium and not isPremium(cid)) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to use blessings.")
                return false
            end

            for i = 3, 5 do
                if(getPlayerBlessing(cid, i)) then
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have all blessings.")
                    return false
                end
            end

            if(not doPlayerRemoveMoney(cid, price)) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enough money for blessings. (You need " .. price .. " gp's)")
                return false
            end

            for i = 3, 5 do
                doPlayerAddBlessing(cid, i)
            end

            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have been blessed by the gods!")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
            return true
        end
function say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            addEvent(say, delay, param)
        end
    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
if msgcontains(msg, 'bless') then
buyAllBlessings()
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
in your talkaction mod change all
Lua:
for i = 1, 5 do
to
Lua:
for i = 1, 2 do
and price
Code:
price = price * 2 * 1.2
What I want is to have two blessings: a standard one (the one I sent in the script) and another one, sold by NPC, more expensive which reduces the penalty for deaths.
 
Back
Top