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

Character Speed Editing

RealRolePlayer

New Member
Joined
Oct 28, 2015
Messages
19
Reaction score
0
As you know, Tibia character get an increase on their speed as they level up. I want to take this feature out and make the players with the same speed neverminding the level. Any leads on how to do this?
Working on TFS 1.2 with client 10.98
 
There are 2 ways to do this.
#1 - With Source Edits
#2 - Without Source Edits (Annoying Way)

With source edits you would simply go to player.h and change:
Code:
void updateBaseSpeed() {
if (!hasFlag(PlayerFlag_SetMaxSpeed)) {
baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));
} else {
baseSpeed = PLAYER_MAX_SPEED;
}
}

To:
Code:
void updateBaseSpeed() {
if (!hasFlag(PlayerFlag_SetMaxSpeed)) {
baseSpeed = vocation->getBaseSpeed();
} else {
baseSpeed = PLAYER_MAX_SPEED;
}
}
 
I'll try this way, but is this Source Edits a program or a directory? I have looked for this file Player.h and I haven't found it, any leads on where to locate the file?
Sorry for the lack of knowledge
 
I'll try this way, but is this Source Edits a program or a directory? I have looked for this file Player.h and I haven't found it, any leads on where to locate the file?
Sorry for the lack of knowledge

I'm guessing you have never compiled a server before.

Basically, before you make TFS.exe, you have a bunch of files.
Here is the Github for TFS:
https://github.com/otland/forgottenserver

You'd need to download the source, make the above edit, then compile the source, and use the new TFS.exe (or theforgottenserver.exe whatever it gets called) as your new server file.

It is kind of complex, but you can look up TFS Compile Tutorials here on OTLand.
I wish you luck!
 
I did compile this server, I found a link to a so called "All-In-One" rar with the server ready to be compiled, spr editor, map editor and a few other things. I had to download UniserverZ and Znote AAC too. Guess I got the link from Otland itself... I'm not on my pc now so I can't send you the link but I got my server up and running... Should have I edited the player speed before compiling the server? Will I not be able to edit this feature on the server I compiled previously?
 
There are 2 ways to do this.
#1 - With Source Edits
#2 - Without Source Edits (Annoying Way)

With source edits you would simply go to player.h and change:
Code:
void updateBaseSpeed() {
if (!hasFlag(PlayerFlag_SetMaxSpeed)) {
baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));
} else {
baseSpeed = PLAYER_MAX_SPEED;
}
}

To:
Code:
void updateBaseSpeed() {
if (!hasFlag(PlayerFlag_SetMaxSpeed)) {
baseSpeed = vocation->getBaseSpeed();
} else {

baseSpeed = PLAYER_MAX_SPEED;
}
}



I saw this line on the player.h file

Code:
static constexpr int32_t PLAYER_MAX_SPEED = 1500;
static constexpr int32_t PLAYER_MIN_SPEED = 10;

If I set both Max and Min speed to the same level, doesn't it have the effect I wanted to on the server? If not, could you please explain me why?
 
Sure, but you'll make it so players can't be hasted or paralyzed.

Thats the maximum POSSIBLE speed, and the minimum POSSIBLE speed.

Meaning, if you have 1400 speed, and haste to 2000 speed, you'll hit the max (1500)

Likewise, if you have 150 speed, and get paralyzed down to 0, you'll be set to 10 speed.

I wouldn't suggest changing these as your solution, unless you do not plan to have any items, or spells that change speed. (Boots of Haste won't do anything either if you change these to the same number)
 
Sure, but you'll make it so players can't be hasted or paralyzed.

Thats the maximum POSSIBLE speed, and the minimum POSSIBLE speed.

Meaning, if you have 1400 speed, and haste to 2000 speed, you'll hit the max (1500)

Likewise, if you have 150 speed, and get paralyzed down to 0, you'll be set to 10 speed.

I wouldn't suggest changing these as your solution, unless you do not plan to have any items, or spells that change speed. (Boots of Haste won't do anything either if you change these to the same number)


I see... That's the reason why GOD characters are not affected by haste, right?
 
#2 - Without Source Edits (Annoying Way)
how set player speed at advance/login event is more annoying than actually compile whole server? nevertheless your changes are not friendly to server performance, you could just set PLAYER_MAX_SPEED to actually to maximum speed he'd like to have, set player flags to flag hasMaxSpeed in Group or Player constructor, even so group.xml, done that you'd be salving CPU cycles each time it needs to do something with speed.
 
how set player speed at advance/login event is more annoying than actually compile whole server? nevertheless your changes are not friendly to server performance, you could just set PLAYER_MAX_SPEED to actually to maximum speed he'd like to have, set player flags to flag hasMaxSpeed in Group or Player constructor, even so group.xml, done that you'd be salving CPU cycles each time it needs to do something with speed.

@Shyzoul

First i'll say what you are right about:
Correct, you could set the player's speed at login, and each time they level up.

Now for what you are wrong about:
  1. My changes do nothing negative to server performance, if anything, not doing the extra math would increase performance by maybe 0.000000000001 Microseconds. So you are Wrong Once @Shyzoul
  2. If you look in the source: PLAYER_MAX_SPEED is used when calculating your StepSpeed in getStepSpeed. Which is used when determining how long it takes you to get to the next tile. Meaning if you set PLAYER_MAX_SPEED to 200, and you have 200 base speed, then you use haste. OH NO! Haste does nothing. Equip Boots of Haste, OH NO! Still 200 movement speed. So you are Wrong Twice @Shyzoul
  3. Oh and it would save CPU Cycles if you gave them the flag hasMaxSpeed? Not really, in updateBaseSpeed (which is already used every time you log in, or level, or change vocation) it does the following check: if (!hasFlag(PlayerFlag_SetMaxSpeed)) { Meaning it is ALREADY RUNNING THIS FUNCTION. Then it has 2 choices. True of False, if True it does baseSpeed = PLAYER_MAX_SPEED; and if false it does baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));. I suggested changing the false to baseSpeed = vocation->getBaseSpeed(); as my fix. Which probably has absolutely no difference in CPU Cycles than baseSpeed = PLAYER_MAX_SPEED;. So Wrong Thrice @Shyzoul
I'm glad you are here to help, and to suggest your way of fixing this without source edits. But please don't talk as if my way of doing things is worse than your way. It is better in EVERY SINGLE POSSIBLE WAY. The only reason your idea might be "better" is it does not require someone have the knowledge of how to compile.

But if you know HOW to compile a server, and you've already done it before (as the person above has) I would suggest editing this in the source, because it is the RIGHT way to do it.
The way you presented is the Wrong Ghetto Lazy Ass way of doing things Mr. @Shyzoul
 
First i'll say what you are right about:
Correct, you could set the player's speed at login, and each time they level up.

Now for what you are wrong about:
  1. My changes do nothing negative to server performance, if anything, not doing the extra math would increase performance by maybe 0.000000000001 Microseconds. So you are Wrong Once @Shyzoul
  2. If you look in the source: PLAYER_MAX_SPEED is used when calculating your StepSpeed in getStepSpeed. Which is used when determining how long it takes you to get to the next tile. Meaning if you set PLAYER_MAX_SPEED to 200, and you have 200 base speed, then you use haste. OH NO! Haste does nothing. Equip Boots of Haste, OH NO! Still 200 movement speed. So you are Wrong Twice @Shyzoul
  3. Oh and it would save CPU Cycles if you gave them the flag hasMaxSpeed? Not really, in updateBaseSpeed (which is already used every time you log in, or level, or change vocation) it does the following check: if (!hasFlag(PlayerFlag_SetMaxSpeed)) { Meaning it is ALREADY RUNNING THIS FUNCTION. Then it has 2 choices. True of False, if True it does baseSpeed = PLAYER_MAX_SPEED; and if false it does baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));. I suggested changing the false to baseSpeed = vocation->getBaseSpeed(); as my fix. Which probably has absolutely no difference in CPU Cycles than baseSpeed = PLAYER_MAX_SPEED;. So Wrong Thrice @Shyzoul
I'm glad you are here to help, and to suggest your way of fixing this without source edits. But please don't talk as if my way of doing things is worse than your way. It is better in EVERY SINGLE POSSIBLE WAY. The only reason your idea might be "better" is it does not require someone have the knowledge of how to compile.

But if you know HOW to compile a server, and you've already done it before (as the person above has) I would suggest editing this in the source, because it is the RIGHT way to do it.
The way you presented is the Wrong Ghetto Lazy Ass way of doing things Mr. @Shyzoul

dude you mad? it was thought, btw i didn't mean to give a C++ solution just a C++ thought as i said, and even if i say now "look StepSpeed or getStepSpeed and give a work around for that bla bla" because there is always a work around, would never be better than Lua anyway, nor yours, even so i didn't mean to offend you either, was my way to expose an __idea__, nothing more than that, my point on yours replies.
1. because of 3 reason, nothing else.
2. you're right, btw i assumed a variable with scope of only in that file (static) labeled MAX_SPEED were suppose to only hold the max speed
3. when i mean waste o cpu cycles i meant you ever will check if player hasflag before go to else block, which is what you're interested in, for a server that it doesnt mean nothing, there is no reason to test before, unless if he want his own character to be faster, which is why tfs test flags before, but im not expanding to that cases, and it was reason why i thought use flag, it seemed better, less code, faster execution, but as you said PLAYER_MAX_SPEED does not do what it says, it has more purposes than just set the player speed, and i never said what you proposed to him is negative to server performance, i said there is better ways, and you can't denny it, there is.
 
Sorry for digging out the topic but can I change the value of player speed without "src" folder?

creaturescripts.xml

Take note of <event type="login" name="PlayerLogin" script="login.lua" />

login.lua
So between here:
Lua:
function onLogin(player)
    -- do things
    return true
end

you can do whatever you want.

Set max speed:
Lua:
player:setSpeed(1500)

or you could find the original speed calc in player.h
and make use of that to to boost speed

Lua:
-- Speed via lua
local level = player:getLevel()
local baseSpeed = player:getVocation():getBaseSpeed()
local speed = baseSpeed + (2 * (level - 1))
player:setSpeed(speed)

But this gets overwritten when you change level and get more speed:
So you'd need to add this in creaturescripts.xml
XML:
<event type="advance" name="Advance" event="script" value="advance.lua"/>

advance.lua
Lua:
function onAdvance(player, skill, oldLevel, newLevel)

    -- Speed via lua
    local level = player:getLevel()
    local baseSpeed = player:getVocation():getBaseSpeed()
    local speed = baseSpeed + (2 * (level - 1))
    player:setSpeed(speed)

    -- player:setSpeed(1500)

    return true
end
 
Last edited:
Back
Top