bool Player::canWalkthrough(const Creature* creature) const
{
if(creature == this || creature->isWalkable() ||
(creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
return true;
const Player* player = creature->getPlayer();
if(!player)
return false;
if(
(
(
(
(
player->getVocation()->isAttackable() &&
player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL)
)
|| (
player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) &&
!player->getTile()->hasFlag(TILESTATE_HOUSE)
)
)
) && player->getTile()->ground &&
player->getTile()->ground->getID() != 11063
) && (
!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
|| player->getAccess() <= getAccess()
)
) return true;
return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
|| (isGhost() && getGhostAccess() > player->getGhostAccess());
}
open player.cpp
chance bool Player::canWalkthrough
to
Lua:text.......
static int32_t neighbourOrderList[8][2] =
{
{-1, 0},
{0, 1},
{1, 0},
{0, -1},
//diagonal
{-1, -1},
{1, -1},
{1, 1},
{-1, 1},
};
1. getPlayer position,Map::getTile(int32_t x, int32_t y, int32_t z)
not depot in pzThat's for walking through players in depot.
bool Player::isBlocked(){
int32_t n[8][2] =
{
{-1, 0},
{0, 1},
{1, 0},
{0, -1},
//diagonal
{-1, -1},
{1, -1},
{1, 1},
{-1, 1},
};
bool isBlocked = true;
Position p = getPosition();
for(uint8_t i = 0; i<= 7; i++){
Tile* tile = g_game.getTile(p.x + n[i][1], p.y + n[i][2], p.z)
ReturnValue ret = tile->__queryAdd(0, this, 1, 0);
if(ret == RET_NOERROR)
isBlocked = false;
}
}
if isBlocked()
return true;
bool Player::isBlocked(){
int32_t n[8][2] =
{
{-1, 0},
{0, 1},
{1, 0},
{0, -1},
//diagonal
{-1, -1},
{1, -1},
{1, 1},
{-1, 1},
};
bool isBlocked = true;
Position p = getPosition();
for(uint8_t i = 0; i<= 7; i++){
Tile* tile = g_game.getTile(p.x + n[i][1], p.y + n[i][2], p.z)
if(tile){
ReturnValue ret = tile->__queryAdd(0, this, 1, 0);
if(ret == RET_NOERROR)
isBlocked = false;
}
}
return isBlocked;
}