• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Possible bug on TFS 1.1 or i fail to understand rates?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,454
Solutions
1
Reaction score
627
Location
Estonia
I opened ticket in github, but might aswell open thread here.

I used TFS 1.0 for a while and didn't have any problems with rates.
In the Config.Lua there is section called: Rates
When i set them to 0 it ment: you get no experience
(and it worked, when i hit monster or cast spells, i dont get experience points for skills)
BUT if i give experience with script it uses the multiplier from vocations.xml and therefor i got my experience.
(works perfectly, because in my server you only get skills by completing tasks and EXP when doing missions/quests)

Today i upgraded to TFS 1.1 #622
now i think that the value 0 in config.lua is being ignored..
When i change multipliers in vocation.xml it will change the skills gain, but when i turn it off there i wont get experience with scripts either.
Is this bug or there is some new scripts im missing?
(i only have taken over the NPC folder from forgottenserver/master/data and config.lua)
 
you need to update lots of files into data folder that were changed since 1.0, that is why you are having problem
yes, but most of the doesnt have anything to do with how experience is handled
or to be exact. none of tem (expect vocation.xml)
 
You should still update every file (merge them somehow if you have to), even if you think you don't need it, a lot of the new stuff are additions and fixes.
Anyways, this is a very confusing issue you have and I'm not saying you're terrible at English, but I wish you could explain it a lot more clearly.
 
not sure what dont you understand.
How about reproduce the problem:
Use latest TFS version.
open config.lua
Change these:
-- Rates
-- NOTE: rateExp is not used if you have enabled stages in data/XML/stages.xml
rateExp = 0
rateSkill = 0
rateLoot = 1
rateMagic = 0
rateSpawn = 1

go in game. and make a spell.
If you get skillpoints (manaspent) towards magic level. You are having same problem like me.
If you dont have same problem, then seems there is a script what is preventing me to get correct information from configManager

Tomorrow i will try to merge all the files with my current scripts. going sleep now.
 
I have made those changes in config.lua and tested it in-game, I'm not getting any skillpoints or manaspents.
 
Didn't someone post somewhere to update global.lua & compat.lua?

Red
 
I have made those changes in config.lua and tested it in-game, I'm not getting any skillpoints or manaspents.
I have merged my Scripts with the newest TFS 1.1
Finally was able to merge all the scripts without getting in errors for now (prolly gona find them while playing, if there is some methods what doesn't exist anymore)
RATES now don't give me skills or experience, but neither does this:
player:addManaSpent ( 160*1)

Edit:
this is my entire skill rewarding code, incase you want to see it:
This code works in TFS 1.0 when rates are 0 in config.lua
This code doesnt work in TFS 1.1 when rates are 0 in config.lua
This code DOES work in TFS 1.1 when rates are bigger than 0 in config.lua
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId) 
    local player = Player(cid)
    player:unregisterEvent("taskRewards")

    --deer, wolf, boar
    if modalWindowId == 1000 then
        if buttonId == 100 then
            if choiceId == 1 then
                player:addManaSpent    (                160*1)
            elseif choiceId == 2 then
                player:addSkillTries(SKILL_AXE,     20*1)
                player:addSkillTries(SKILL_SWORD,     20*1)
                player:addSkillTries(SKILL_CLUB,     20*1)
            elseif choiceId == 3 then
                player:addSkillTries(SKILL_DISTANCE,15*1)
            elseif choiceId == 4 then
                player:addSkillTries(SKILL_SHIELD,    40*1)
            elseif choiceId == 5 then
                player:addSkillTries(SKILL_FIST,     20*1)
               
            end           
        end
    end
end
 
Last edited:
Problematic Script has been found. question now is.. How to fix it? (if you came here to say "source code" then be more detailed, where and how)

events.xml
<event class="Player" method="onGainSkillTries" enabled="1" />
Enabled onGainSkillTries takes multiplier from config.lua
Disabled or deleted onGainSkillTries takes the default vocation.xml multipliers.


what i need is:
onGainSkillTries enabled, but with scripts it takes multipliers from vocation.xml
 
what i need is: when player hits monsters or does spell, his skillstries are multiplied with 0 , but if i give skilltries with script, then its multiplied with 1 (worked like that in TFS 1.0)


Code:
--spellscroll descriptions here

local spells = {
["Strike"] = {
actionID = 1100,
vocation = "knight",
minL = 2,
word = "!strike",
effect = "deals x damage",
formula = "does X damage!!",
mCost = 15,
cd = 2 -- seconds
},

["Heat"] = {
actionID = 1101,
vocation = "druid",
minL = 2,
word = "!heat",
effect = "Deals Fire damage",
formula = "L * 10 + mL * 40) + 100",
mCost = 10,
cd = 2 -- seconds
},

["Barrier"] = {
actionID = 1102,
vocation = "Sorcerer",
minL = 2,
word = "!barrier",
effect = "Absorbs Damage and reduces 50% damage reduction from all sources",
formula = "manacost = damage abosrbed",
mCost = 100,
cd = 20 -- seconds
}
}

function Player:onBrowseField(position)
    return true
end

function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
   
    if thing:getId() == 7696 then
        for k, v in pairs(spells) do
            if thing:getActionId() == spells[k].actionID then
                description = "Level "..spells[k].minL.." Spell for "..spells[k].vocation.." \n "..spells[k].word.." \n "..spells[k].effect.." \n Formula: "..spells[k].formula.." \n mana cost: "..spells[k].mCost.." \n exhaust time: "..spells[k].cd.." sec"
            end
        end
       
    elseif self:getGroup():getAccess() then
        if thing:isItem() then
            description = string.format("%s\nItemID: [%d]", description, thing:getId())

            local actionId = thing:getActionId()
            if actionId ~= 0 then
                description = string.format("%s, ActionID: [%d]", description, actionId)
            end

            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
            if uniqueId > 0 and uniqueId < 65536 then
                description = string.format("%s, UniqueId: [%d]", description, uniqueId)
            end

            description = description .. "."
            local itemType = thing:getType()

            local transformEquipId = itemType:getTransformEquipId()
            local transformDeEquipId = itemType:getTransformDeEquipId()
            if transformEquipId ~= 0 then
                description = string.format("%s\nTransformTo: [%d] (onEquip).", description, transformEquipId)
            elseif transformDeEquipId ~= 0 then
                description = string.format("%s\nTransformTo: [%d] (onDeEquip).", description, transformDeEquipId)
            end

            local decayId = itemType:getDecayId()
            if decayId ~= -1 then
                description = string.format("%s\nDecayTo: [%d]", description, decayId)
            end
        elseif thing:isCreature() then
            local str = "%s\nHealth: [%d / %d]"
            if thing:getMaxMana() > 0 then
                str = string.format("%s, Mana: [%d / %d]", str, thing:getMana(), thing:getMaxMana())
            end
            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
        end

        local position = thing:getPosition()
        description = string.format(
            "%s\nPosition: [X: %d] [Y: %d] [Z: %d].",
            description, position.x, position.y, position.z
        )

        if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nIP: [%s].", description, Game.convertIpToString(thing:getIp()))
            end
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
    local description = "You see " .. creature:getDescription(distance)
    if self:getGroup():getAccess() then
        local str = "%s\nHealth: [%d / %d]"
        if creature:getMaxMana() > 0 then
            str = string.format("%s, Mana: [%d / %d]", str, creature:getMana(), creature:getMaxMana())
        end
        description = string.format(str, description, creature:getHealth(), creature:getMaxHealth()) .. "."

        local position = creature:getPosition()
        description = string.format(
            "%s\nPosition: [X: %d] [Y: %d] [Z: %d].",
            description, position.x, position.y, position.z
        )

        if creature:isPlayer() then
            description = string.format("%s\nIP: [%s].", description, Game.convertIpToString(creature:getIp()))
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInTrade(partner, item, distance)
    self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. item:getDescription(distance))
end

function Player:onLookInShop(itemType, count)
    return true
end

function Player:onMoveItem(item, count, fromPosition, toPosition)
    return true
end

function Player:onMoveCreature(creature, fromPosition, toPosition)
    return true
end

function Player:onTurn(direction)
    return true
end

function Player:onTradeRequest(target, item)
    return true
end

function Player:onTradeAccept(target, item, targetItem)
    return true
end

local soulCondition = Condition(CONDITION_SOUL, CONDITIONID_DEFAULT)
soulCondition:setTicks(4 * 60 * 1000)
soulCondition:setParameter(CONDITION_PARAM_SOULGAIN, 1)

local function useStamina(player)
    local staminaMinutes = player:getStamina()
    if staminaMinutes == 0 then
        return
    end

    local playerId = player:getId()
    local currentTime = os.time()
    local timePassed = currentTime - nextUseStaminaTime[playerId]
    if timePassed <= 0 then
        return
    end

    if timePassed > 60 then
        if staminaMinutes > 2 then
            staminaMinutes = staminaMinutes - 2
        else
            staminaMinutes = 0
        end
        nextUseStaminaTime[playerId] = currentTime + 120
    else
        staminaMinutes = staminaMinutes - 1
        nextUseStaminaTime[playerId] = currentTime + 60
    end
    player:setStamina(staminaMinutes)
end

function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

    -- Soul regeneration
    local vocation = self:getVocation()
    if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
        soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
        self:addCondition(soulCondition)
    end

    -- Apply experience stage multiplier
    exp = exp * Game.getExperienceStage(self:getLevel())

    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end

    return exp
end

function Player:onLoseExperience(exp)
    return exp
end

function Player:onGainSkillTries(skill, tries)
    if skill == SKILL_MAGLEVEL then
        return tries * configManager.getNumber(configKeys.RATE_MAGIC)
    end
    return tries * configManager.getNumber(configKeys.RATE_SKILL)
end
 
I need the same! Both multipliers of config.lua and vocations.xml, is it possible??
what i did is this:

Code:
function Player:onGainExperience(source, exp, rawExp)
    if type(source) == "userdata" then
        return 0
    else return exp
    end
end
Code:
    <event class="Player" method="onGainExperience" enabled="1" />
    <event class="Player" method="onLoseExperience" enabled="0" />
    <event class="Player" method="onGainSkillTries" enabled="0" />

Only change i did i think. and its working like i wanted.
 
Ohh, thanks! But I think it won't work for what I want :/

I want to use the config.lua to set an overall rate multiplier (like, every vocation advance melee skills 3x faster), and vocations.xml to set individual skill rates among each vocation (knight advancing melee faster than others, or a new promotion that advances sword fighting faster than club and axe, for example). Just like it was back in 8.x OTs...

So, in the end I would have config.lua AND vocations.xml working together, both multiplying rates.

It isn't what those codes do, right?
 
Ohh, thanks! But I think it won't work for what I want :/

I want to use the config.lua to set an overall rate multiplier (like, every vocation advance melee skills 3x faster), and vocations.xml to set individual skill rates among each vocation (knight advancing melee faster than others, or a new promotion that advances sword fighting faster than club and axe, for example). Just like it was back in 8.x OTs...

So, in the end I would have config.lua AND vocations.xml working together, both multiplying rates.

It isn't what those codes do, right?
eh. actually config is doing what you just said and xml multipliers do what you just said too.
 

Similar threads

Back
Top