anyeor
Member
- Joined
- Jan 6, 2010
- Messages
- 132
- Solutions
- 2
- Reaction score
- 20
Has anyone found a fix for that?![]()
Its not just with stairs the same thing happens if you use /c playername. I think it tries to predict where the player was looking, because the spectator client doesnt know the players original direction, so when they appear, it just makes a prediction. At least thats what i assume
are you using 1.5+ or 1.4 ?It's a client side bug I think
if u use player:setDirection(EAST) it won't update it for your view but for others it does
My experience with c++ is to bad to fix that
same questionIts not just with stairs the same thing happens if you use /c playername. I think it tries to predict where the player was looking, because the spectator client doesnt know the players original direction, so when they appear, it just makes a prediction. At least thats what i assume
are you using 1.5+ or 1.4 ?
From what I recall this works well with TFS, but not with RealOTS. You'll see yourself facing the correct direction, but other players won't see it that way.![]()
Gyazo Screen Video
gyazo.com
This is TFS based 1.4.2 let me check from other viewFrom what I recall this works well with TFS, but not with RealOTS. You'll see yourself facing the correct direction, but other players won't see it that way.
Im on tfs 1.2are you using 1.5+ or 1.4 ?
same questionu using 1.5+ ?
Thats what i understood from his message.It's the other way
Your view is wrong, from people view it's right
god marko view
View attachment 93917
Knight view
View attachment 93918
If it was easy everyone would be pro programmer, hard part comes when you have to write it in smart way and consider all out comes like proper check for nil values before using objects like the player, the tile, position or any item or thing retrieved from the map, because after a while you will be scrathing your head and thinking why is my server crashing sometimesThats what i understood from his message.
I believe its easy for a beginner coder with basic knowledge to add a simple check on the stairs direction in position.z - 1 and set player direction based on it.
![]()
forgottenserver/src/player.cpp at b577e5452b86ea5d6f42198e7219daccdedced4c · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
Im on tfs 1.2![]()
setDirection(direction); line is completely missing for both going up and down and I guess this the problem .if (!tmpTile->hasFlag(TILESTATE_FLOORCHANGE)) {
creature->setDirection(direction); // Add this line
destPos.z--;
}
In game.cpp, when handling floor changes (around line 769+) , thesetDirection(direction);line is completely missing for both going up and down and I guess this the problem .
C++:if (!tmpTile->hasFlag(TILESTATE_FLOORCHANGE)) { creature->setDirection(direction); // Add this line destPos.z--; }
Around line 779 (going down stairs): same as it should be fixed add the same line in the pervious code .
I guess this should fix the problem .. with tfs 1.5 i think it's really client issue if im mistaken it would be from protocolgame 100%
connect(LocalPlayer, {onPositionChange = onPositionChange})
disconnect(LocalPlayer, {onPositionChange = onPositionChange})
function getDirectionTo(from, to)
if from.x == to.x and from.y == to.y then
return InvalidDirection
end
local dir
local x_offset = to.x - from.x
if x_offset < 0 then
dir = 3
x_offset = -x_offset
else
dir = 1
end
local y_offset = to.y - from.y
if y_offset >= 0 then
if y_offset > x_offset then
dir = 2
elseif y_offset == x_offset then
if dir == 3 then
dir = 6
else
dir = 5
end
end
else
y_offset = -y_offset
if y_offset > x_offset then
dir = 0
elseif y_offset == x_offset then
if dir == 3 then
dir = 7
else
dir = 4
end
end
end
return dir
end
function onPositionChange(player, newPos, oldPos)
if (oldPos.z ~= newPos.z and (oldPos.x ~= newPos.x or oldPos.y ~= newPos.y)) then
local dir = getDirectionTo(oldPos, newPos);
if(dir ~= 8) then
player:setDirection(dir);
end
end
end
![]()
forgottenserver/src/game.cpp at b577e5452b86ea5d6f42198e7219daccdedced4c · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
This is already done here using internalCreatureTurn the issue is the creature is standing correctly but for the user that is currently online on the char that used stairs can see incorrect direction meanwhile if any other player passes by him he will see him in the expected direction (Thats TFS 1.4.2 + OTCv8)
Post automatically merged:
Here is the solution i went with when i had this solved.
yourClientPath/modules/game_walking/walking.lua
in init() you must make sure you add if not existingand in terminateCode:connect(LocalPlayer, {onPositionChange = onPositionChange})Code:disconnect(LocalPlayer, {onPositionChange = onPositionChange})
if onPositionChange have other code in your walking.lua just put the code at the end of onPositionChange and keep 1 callback only to merge them.
LUA:function getDirectionTo(from, to) if from.x == to.x and from.y == to.y then return InvalidDirection end local dir local x_offset = to.x - from.x if x_offset < 0 then dir = 3 x_offset = -x_offset else dir = 1 end local y_offset = to.y - from.y if y_offset >= 0 then if y_offset > x_offset then dir = 2 elseif y_offset == x_offset then if dir == 3 then dir = 6 else dir = 5 end end else y_offset = -y_offset if y_offset > x_offset then dir = 0 elseif y_offset == x_offset then if dir == 3 then dir = 7 else dir = 4 end end end return dir end function onPositionChange(player, newPos, oldPos) if (oldPos.z ~= newPos.z and (oldPos.x ~= newPos.x or oldPos.y ~= newPos.y)) then local dir = getDirectionTo(oldPos, newPos); if(dir ~= 8) then player:setDirection(dir); end end end
It is because setDirection just fills the variable direction inside Player class with the value it doesn't tell the client of the new direction when using player:setDirection in lua or c++ because you didn't call sendCreatureTurn from c++ so the client won't be notified of the change and since you can't use sendCreatureTurn on self it is pointless, (Self is the player that is on the client of the otherside connection in this instance which is LocalPlayer on OTCv8) so this localPlayer will never be notified of its new direction neither the players around it BUT if players around him left the location and came back they will see the new direction that was added with set because this will trigger the client to update the player direction when sendAddCreature triggers addCreature that send protocolMessage on a header that triggers getCreature in clientSide and finally setDirection in clientSide thats why you can't see that your direction is changed but others canYeah that solved the problem nice thanks you appreciate it
Only left to check why player:setDirection doesnt set the direction from your view