TFS 0.X monsters give levels, not experience ,its possible?

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
monsters give levels, not experience ,its possible?

If YES then
say 'how'
 

Mister Budex

BudexOT.com
Joined
Jun 22, 2016
Messages
1,171
Best answers
18
Reaction score
205
Experience is level so it probably gives experience without showing numbers ?
 

ckripz

Member
Joined
May 30, 2013
Messages
59
Best answers
0
Reaction score
6
something like that the idea
Code:
local config = {
    ["rotworm"] = {level = 1},
    ["demon"] = {level = 8}
}

function onkill(cid, target)
    local monster = config[target:getName()]
    local player = Player(cid)

    local playerLevel = player:getLevel()
    local exptoLevel = getExpToLevel(playerLevel, (playerLevel + monster.level))

    player:addExperience(exptoLevel)
end
 
OP
V

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
something like that the idea
Code:
local config = {
    ["rotworm"] = {level = 1},
    ["demon"] = {level = 8}
}

function onkill(cid, target)
    local monster = config[target:getName()]
    local player = Player(cid)

    local playerLevel = player:getLevel()
    local exptoLevel = getExpToLevel(playerLevel, (playerLevel + monster.level))

    player:addExperience(exptoLevel)
end
Okey, but it possible to change it in sources? And if i set in monsters/demon.xml in expierience="1" that monster give me 1 lvl, not exp? And in game after kill show me number "1" not experience "3213213", and if i have in stages exp x900 i get 900 levels
 
Last edited:
OP
V

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
Or where i can change "experience to nextlevel"? Maybe i change it to 1 everytime, and i remove stages and in monsters i set 1 experience point.
 

chekybrekyv

Banned User
Joined
Oct 15, 2018
Messages
113
Best answers
0
Reaction score
60
WHY XD
when someone is so stupid they want to cause whole thing to crash xD
 
OP
V

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
Or, where i can change if i kill monster i saw how much experience i get, so where i can change it to how levels i get?
 

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,031
Best answers
19
Reaction score
1,087
Location
PLand
You can do it easily in sources. Biggest problem in this case is calculation of exp sharing. How many levels should receive each player?
If monster gives 3 levels and 2 players hit it, there is veeery big chance that both players will receive 1 level, so 'total level' from monster will be 2, not 3.

If you want to change it to '1 exp = 1 level', you can change math that calculate it. It's in player.h file:
PHP:
static uint64_t getExpForLevel(uint32_t lv)
{
    lv--;
    return ((50ULL * lv * lv * lv) - (150ULL * lv * lv) + (400ULL * lv)) / 3ULL;
}
To make it 1 lvl = 1 exp, replace it with:
PHP:
static uint64_t getExpForLevel(uint32_t lv)
{
    lv--;
    return lv;
}
1 lvl = 0 exp
2 lvl = 1 exp
3 lvl = 2 exp
 
OP
V

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
You can do it easily in sources. Biggest problem in this case is calculation of exp sharing. How many levels should receive each player?
If monster gives 3 levels and 2 players hit it, there is veeery big chance that both players will receive 1 level, so 'total level' from monster will be 2, not 3.

If you want to change it to '1 exp = 1 level', you can change math that calculate it. It's in player.h file:
PHP:
static uint64_t getExpForLevel(uint32_t lv)
{
    lv--;
    return ((50ULL * lv * lv * lv) - (150ULL * lv * lv) + (400ULL * lv)) / 3ULL;
}
To make it 1 lvl = 1 exp, replace it with:
PHP:
static uint64_t getExpForLevel(uint32_t lv)
{
    lv--;
    return lv;
}
1 lvl = 0 exp
2 lvl = 1 exp
3 lvl = 2 exp
Okey, so maybe better is change experience numbers, to how much level i get after kill monsters (only that info), you know how i can change it?
 

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,031
Best answers
19
Reaction score
1,087
Location
PLand
Okey, so maybe better is change experience numbers, to how much level i get after kill monsters (only that info), you know how i can change it?
I'm not sure what you mean. I gave you code, that give as many levels, as monster give exp. Set in monster 'experience="15"' and it will give 15 levels.
 
OP
V

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
I'm not sure what you mean. I gave you code, that give as many levels, as monster give exp. Set in monster 'experience="15"' and it will give 15 levels.
yea, i know but that code work with stages? And if i have 200k level and in monster i set experience=1 then i got 1 level? or i need 200k experience points to next level?

Its everytime 1xp to level?
 

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,031
Best answers
19
Reaction score
1,087
Location
PLand
yea, i know but that code work with stages? And if i have 200k level and in monster i set experience=1 then i got 1 level? or i need 200k experience points to next level?

Its everytime 1xp to level?
+1 xp = +1 lvl
200.000 level goes to 200.001 when get 1 exp.

EDIT:
Stages/rate will multiply received exp (level).

EDIT 2:
There is very big chance that error in exp gain/share calculation will make people get less exp when they hunt together.
I recommend to use some other formula. Like 100 exp for every level:
PHP:
static uint64_t getExpForLevel(uint32_t lv)
{
    lv--;
    return lv * 100ULL;
}
Then set in monster experience="200" and it will give 2 levels.

Maximum possible level is 4.294.967.295 [maximum unsigned 32 bit number value].
Maximum possible experience value is 18.446.744.073.709.551.615 (4.294.967.295 * 4.294.967.295)
 
Last edited:
OP
V

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
+1 xp = +1 lvl
200.000 level goes to 200.001 when get 1 exp.

EDIT:
Stages/rate will multiply received exp (level).

EDIT 2:
There is very big chance that error in exp gain/share calculation will make people get less exp when they hunt together.
I recommend to use some other formula. Like 100 exp for every level:
PHP:
static uint64_t getExpForLevel(uint32_t lv)
{
    lv--;
    return lv * 100ULL;
}
Then set in monster experience="200" and it will give 2 levels.

Maximum possible level is 4.294.967.295 [maximum unsigned 32 bit number value].
Maximum possible experience value is 18.446.744.073.709.551.615 (4.294.967.295 * 4.294.967.295)
Okey thanks! I have one more question, you know where i can change experience to level? i mean if i kill monster on screen i can saw white numbers (exp), how change it to gained level?

 

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,031
Best answers
19
Reaction score
1,087
Location
PLand
Okey thanks! I have one more question, you know where i can change experience to level? i mean if i kill monster on screen i can saw white numbers (exp), how change it to gained level?
On what engine? TFS 1.3 or some 0.4?
 

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,031
Best answers
19
Reaction score
1,087
Location
PLand
When hunt without Party:
otland/tfs-old-svn

When hunt with Party:
otland/tfs-old-svn

From these 2 places in creature.cpp you must remove code that shows exp (marked yellow on Github).

Then you must add in player.cpp:
PHP:
int16_t color = g_config.getNumber(ConfigManager::EXPERIENCE_COLOR);
if(color < 0)
    color = random_range(0, 255);

std::stringstream ss;
ss << (level - prevLevel);
g_game.addAnimatedText(getPosition(), (uint8_t)color, ss.str());
Under:
otland/tfs-old-svn
PHP:
char advMsg[60];
sprintf(advMsg, "You advanced from Level %d to Level %d.", prevLevel, level);
sendTextMessage(MSG_EVENT_ADVANCE, advMsg);

-------------
Exp color you can change from white to any other in config.lua. Color numbers (animated text):
http://ots.me/colors
If you set in config.lua color value to -1, it will use random color.
 
OP
V

vexler222

Member
Joined
Apr 22, 2012
Messages
268
Best answers
3
Reaction score
6
When hunt without Party:
otland/tfs-old-svn

When hunt with Party:
otland/tfs-old-svn

From these 2 places in creature.cpp you must remove code that shows exp (marked yellow on Github).

Then you must add in player.cpp:
PHP:
int16_t color = g_config.getNumber(ConfigManager::EXPERIENCE_COLOR);
if(color < 0)
    color = random_range(0, 255);

std::stringstream ss;
ss << (level - prevLevel);
g_game.addAnimatedText(getPosition(), (uint8_t)color, ss.str());
Under:
otland/tfs-old-svn
PHP:
char advMsg[60];
sprintf(advMsg, "You advanced from Level %d to Level %d.", prevLevel, level);
sendTextMessage(MSG_EVENT_ADVANCE, advMsg);

-------------
Exp color you can change from white to any other in config.lua. Color numbers (animated text):
http://ots.me/colors
If you set in config.lua color value to -1, it will use random color.
yea, thanks bro! <3
 
Top