• 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.0 Experience Skill/magic Table

Devlinn

Member
Joined
Mar 25, 2015
Messages
295
Reaction score
6
hi someone have idea how to create experience table ?
like
//skill distance table
{
1;500
2;1000
3;2000
4;5000
}
//magic level table experience
{
1;10000
2;25000
3;40000
}
 
Its pretty simple just create your table(s)
Code:
local distance = {
    500,
    1000,
    2000,
    5000
}
local magic = {
    10000,
    25000,
    40000
}

Then use a for loop and ipairs to cycle through the tables
Code:
    for k, v in ipairs(distance) do
        print(v)
    end

    for k, v in ipairs(magic) do
        print(v)
    end


Assuming this is just for testing purpose, if this is not what your looking for then please rephrase your question :)
 
Its pretty simple just create your table(s)
Code:
local distance = {
    500,
    1000,
    2000,
    5000
}
local magic = {
    10000,
    25000,
    40000
}

Then use a for loop and ipairs to cycle through the tables
Code:
    for k, v in ipairs(distance) do
        print(v)
    end

    for k, v in ipairs(magic) do
        print(v)
    end


Assuming this is just for testing purpose, if this is not what your looking for then please rephrase your question :)

can you litle help me where this add? and remove old automatic distance/magic experience
 
There is thing with skills in TFS. If it gains negative value and it exceeds the amount player has, player will get maximum skill level possible (Which is 255 if not changed in source)

If you want full control over skills. Put all the player skills idk, around 200. Then remove it all with specific Condition.
Now on, when player gains skill tries and it would exceed the required amount (said in table). Then instead. "reset" the skillTries and increase the another skill level condition.
Keep in mind you would have to use effectiveSkillLevel for any kind of formulas then.

If you didn't know yet, skillTries are calculated in events player:eek:nGainSkillTries (or something like that)
 
There is thing with skills in TFS. If it gains negative value and it exceeds the amount player has, player will get maximum skill level possible (Which is 255 if not changed in source)

If you want full control over skills. Put all the player skills idk, around 200. Then remove it all with specific Condition.
Now on, when player gains skill tries and it would exceed the required amount (said in table). Then instead. "reset" the skillTries and increase the another skill level condition.
Keep in mind you would have to use effectiveSkillLevel for any kind of formulas then.

If you didn't know yet, skillTries are calculated in events player:eek:nGainSkillTries (or something like that)
yes i want full control skills/magic level/level its better
thanks you but im not very good on c/c++
i find this line in vocation.cpp
PHP:
uint32_t Vocation::getReqSkillTries(int32_t skill, int32_t level)
{
    if (skill < SKILL_FIRST || skill > SKILL_LAST) {
        return 0;
    }

    auto it = cacheSkill[skill].find(level);
    if (it != cacheSkill[skill].end()) {
        return it->second;
    }

    uint32_t tries = static_cast<uint32_t>(skillBase[skill] * std::pow(static_cast<float>(skillMultipliers[skill]), level - 11));
    cacheSkill[skill][level] = tries;
    return tries;
}

uint64_t Vocation::getReqMana(uint32_t magLevel)
{
    auto it = cacheMana.find(magLevel);
    if (it != cacheMana.end()) {
        return it->second;
    }

    uint64_t reqMana = static_cast<uint64_t>(400 * std::pow(manaMultiplier, static_cast<int32_t>(magLevel) - 1));
    uint32_t modResult = reqMana % 20;
    if (modResult < 10) {
        reqMana -= modResult;
    } else {
        reqMana -= modResult + 20;
    }

    cacheMana[magLevel] = reqMana;
    return reqMana;
}

on level experience i try this
player.cpp
PHP:
#define local
            uint64_t currLevelExp = Player::getExpForLevel(level);
            uint64_t nextLevelExp = Player::getExpForLevel(level = local level);
            if (nextLevelExp > currLevelExp) {
                levelPercent = Player::getPercentLevel(experience - currLevelExp, nextLevelExp - currLevelExp);
            } else {
                levelPercent = 0;
            }
        }
      
local level = {
    10000,
};

this dont work ;]
 
Last edited:
oh my. My fail, though TFS 1.0 had skillTries function too, apparently not.
Well, either update TFS or change the skillrate value to 0 in config.
and then in onHealthChange function start adding skilltries each time monster takes damage (in other words, you also will set how much of skill exp they get when they hit monster)
 
oh my. My fail, though TFS 1.0 had skillTries function too, apparently not.
Well, either update TFS or change the skillrate value to 0 in config.
and then in onHealthChange function start adding skilltries each time monster takes damage (in other words, you also will set how much of skill exp they get when they hit monster)
ahmmmmmmmmmmmmm
i like that.
table of experience skill look up.
1attack monster like 1 experience like look
distance experience table
1lvl-100exp
2lvl-250exp
3lvl-500exp (1hit monster = 1exp)
......
sword experience table
1lvl-300
2lvl-750
3lvl-1115
etc

i know can change experience how much fast i get level distance etc
on vocations.xml multiplayer
but i want table of experience use


maybe i wrong understand you
 
yes you can do that.
but I'm correct the rates in .xml wont change anything. You would have to recognize the attacker vocation in onhealthchange function and then make another table of specific rates for each vocation.
 
yes you can do that.
but I'm correct the rates in .xml wont change anything. You would have to recognize the attacker vocation in onhealthchange function and then make another table of specific rates for each vocation.
this fuction onhealthchange not have
yes you can do that.
but I'm correct the rates in .xml wont change anything. You would have to recognize the attacker vocation in onhealthchange function and then make another table of specific rates for each vocation.
fuction? onhealthchange
not have
 
data>creaturescripts>scripts>your script name.lua
inside that you you write the function
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
to register the script you write into .xml file this
Code:
<event type="healthchange"         name="randomName"              script="your script name.lua"/>
 
data>creaturescripts>scripts>your script name.lua
inside that you you write the function
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
to register the script you write into .xml file this
Code:
<event type="healthchange"         name="randomName"              script="your script name.lua"/>
hmmm?
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local level exp = {
0,
1,
2
}
local distance exp = {
1,
2,

}
end
i thiink this dont work xD
you can little explain ?
 
variables cant be in 2 different words. but you are on a right track.
So, we write them like this:
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local levelExp = {
0,
1,
2
}
local distance_exp = {
1,
2,

}
end

But these don't have to be inside function itself, because they will never change while server is running? (right)
If you create table inside a function, then each time this function is called it will create the local table, and we don't need that.
Its enough if it loads the table once when server starts up. (right?)

So I would do something like this:
Code:
local levelExp = {
0,
1,
2
}

local distanceExp = {
1,
2,

}
print()
print("levelExp table ")
for tableKey, value in ipairs(levelExp) do
print("["..tableKey.."] = "..value)
end

print()
print("distanceExp table ")
for tableKey, value in ipairs(distanceExp) do
print("["..tableKey.."] = "..value)
end

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

end
 
variables cant be in 2 different words. but you are on a right track.
So, we write them like this:
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local levelExp = {
0,
1,
2
}
local distance_exp = {
1,
2,

}
end

But these don't have to be inside function itself, because they will never change while server is running? (right)
If you create table inside a function, then each time this function is called it will create the local table, and we don't need that.
Its enough if it loads the table once when server starts up. (right?)

So I would do something like this:
Code:
local levelExp = {
0,
1,
2
}

local distanceExp = {
1,
2,

}
print()
print("levelExp table ")
for tableKey, value in ipairs(levelExp) do
print("["..tableKey.."] = "..value)
end

print()
print("distanceExp table ")
for tableKey, value in ipairs(distanceExp) do
print("["..tableKey.."] = "..value)
end

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

end
now i understand yes i see.how to work it?
i think this is hard
 
Last edited:
yes this is hard.

Now you gotta figure out which origin is NOT spell.
then when player hit includes physical damage then
it will check what weapon attacker is using (distance,axe,sword, etc)
then based on weaponType you know what skill to modify
then you run the correct loop using the table
inside the loop you compare player level with table keys.
finally you check if the exp you are about to add doesn't exceed the table value
if it does then add new skillLevel to player
else add exp to skillTries.
break

Hopefully I got it all written down.
 
Back
Top