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

C++ [TFS 0.X] Walkthrough problem - Working just with click

potinho

Advanced OT User
Joined
Oct 11, 2009
Messages
1,402
Solutions
17
Reaction score
150
Location
Brazil
I want to make players can pass through other players in PZ area, but only works on i click on player, with arrow cant pass (in PZ area). Can u guys help me to fix?

C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasFlag(PlayerFlag_CanPassThroughAllCreatures) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    if(((g_game.getWorldType() == WORLDTYPE_OPTIONAL &&
        !player->isProtected()) || player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) || player->isProtected()) && player->getTile()->ground
        && Item::items[player->getTile()->ground->getID()].walkStack && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
        || player->getAccess() <= getAccess()))
        return true;

    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
When player walks with arrows, it calculates 'path' [1 step 'path'] on client side.
When player 'use item' or use map walk, it calculates 'path' on server side.

Server has up to date information about players, so it allows player to walk thru other player by checking Player::canWalkthrough every step.

Information about 'can I walk thru player' is send to tibia client, when player sees other player for first time. Then it's cached and never updated.
So if player saw other player outside depot, his client will cache 'this player is not walkable' and won't let tibia client walk thru other player. Pressing 'arrow' in client won't even send packet 'make step' to server.

Only real fix for that is to send 'update walkthru' every player step to every other player on screen.

TODO on TFS 0.x:
1. This function is not implemented at all on 0.4:
here is TFS 1.5 code for it:
2. Function to send 'walkthru' to all players on screen does not exist on 0.4. Here is 1.5 code:
3. You got to send update of 'walkthru' every player step, ex. in this line:
under:
Code:
    if(creature != this)
        return;
add:
Code:
g_game.updateCreatureWalkthrough(this);
so it will execute only for player that makes step, not all players 'on his screen' - we want to 'broadcast walkthru' of player that just did step, not X times same information for all players that 'see someone makes step'.

EDIT: Code like that is on Kasteria and it did not affect CPU/network usage heavily.
 
Back
Top