• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 1.0 Walkthrough Players

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,317
Solutions
35
Reaction score
435
Hey guys,

I wanted to make it so that low level players can't be used to block traps and spawns so I made it so that they can be walkedthrough even outside of the pz. To prevent players from walking on them on Depot tiles I had to make depot tiles Non-PvP zone and return false for non-pvp zones. The problem I'm having right now is that, normally players aren't able to walk through low level players on depot tiles. However, players who are using Dash on Magebot are able to dash through players below protection level even on depot tiles!

This is my player.cpp, is there any way to prevent that?


Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }
    if ((player->isAttackable() &&
    (player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))))
    return true;
 
    const Tile* playerTile = player->getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        Item* playerTileGround = playerTile->ground;
        if (playerTileGround && playerTileGround->hasWalkStack()) {
            Player* thisPlayer = const_cast<Player*>(this);
            if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return true;
            }

            if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
            }

            thisPlayer->setLastWalkthroughPosition(creature->getPosition());
            return true;
        }
    }

    return false;
}

bool Player::canWalkthroughEx(const Creature* creature) const
{
    if (group->access) {
        return true;
    }

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

    const Tile* playerTile = player->getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_NOPVPZONE)){
        return false;
    }
    return playerTile && playerTile->hasFlag(TILESTATE_NONE);
}
 
Bro how i can add this in my sources?

Look:
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }

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

    const Tile* playerTile = player->getTile();
    if (!playerTile || !playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        return false;
    }

    const Item* playerTileGround = playerTile->getGround();
    if (!playerTileGround || !playerTileGround->hasWalkStack()) {
        return false;
    }

    Player* thisPlayer = const_cast<Player*>(this);
    if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
        thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
        return false;
    }

    if (creature->getPosition() != lastWalkthroughPosition) {
        thisPlayer->setLastWalkthroughPosition(creature->getPosition());
        return false;
    }

    thisPlayer->setLastWalkthroughPosition(creature->getPosition());
    return true;
}

bool Player::canWalkthroughEx(const Creature* creature) const
{
    if (group->access) {
        return true;
    }

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

    const Tile* playerTile = player->getTile();
    return playerTile && (playerTile->hasFlag(TILESTATE_PROTECTIONZONE);
}
 
Back
Top