darkjav
Senior Developer
Hello,
I'm trying to make it so players that are within the protection level can be walked through.
Original code:
I did change on code and this is what I tried:
But not work, i not have errors, only that players now can't walk through in pz, or walk in low level players.
I'm trying to make it so players that are within the protection level can be walked through.
Original code:
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);
}
I did change on code and this is what I tried:
Code:
bool Player::canSeeCreature(const Creature* creature) const
{
if (creature == this) {
return true;
}
if (creature->isInGhostMode() && !group->access) {
return false;
}
if (!creature->getPlayer() && !canSeeInvisibility() && creature->isInvisible()) {
return false;
}
return true;
}
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) || player->getLevel() < static_cast<uint32_t>(g_config.getNumber(ConfigManager::PROTECTION_LEVEL)))) {
const Item* playerTileGround = playerTile->getGround();
if (playerTileGround && playerTileGround->hasWalkStack()) {
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;
}
}
return false;
}
But not work, i not have errors, only that players now can't walk through in pz, or walk in low level players.