本文整理汇总了C++中Tile::__queryAdd方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::__queryAdd方法的具体用法?C++ Tile::__queryAdd怎么用?C++ Tile::__queryAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::__queryAdd方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canWalkTo
bool Monster::canWalkTo(Position pos, Direction dir)
{
if(getNoMove())
return false;
switch(dir)
{
case NORTH:
pos.y += -1;
break;
case WEST:
pos.x += -1;
break;
case EAST:
pos.x += 1;
break;
case SOUTH:
pos.y += 1;
break;
default:
break;
}
if(!isInSpawnRange(pos) || !getWalkCache(pos))
return false;
Tile* tile = g_game.getTile(pos);
if(!tile || g_game.isSwimmingPool(NULL, getTile(), false) != g_game.isSwimmingPool(NULL, tile, false)) // prevent monsters entering/exiting to swimming pool
return false;
return !tile->getTopVisibleCreature(this) && tile->__queryAdd(
0, this, 1, FLAG_PATHFINDING) == RET_NOERROR;
}
示例2: canWalkTo
bool Npc::canWalkTo(const Position& fromPos, Direction dir)
{
if (masterRadius == 0) {
return false;
}
Position toPos = getNextPosition(dir, fromPos);
if (!Spawns::getInstance()->isInZone(masterPos, masterRadius, toPos)) {
return false;
}
Tile* tile = g_game.getTile(toPos.x, toPos.y, toPos.z);
if (!tile || tile->__queryAdd(0, this, 1, 0) != RET_NOERROR) {
return false;
}
if (!floorChange && (tile->floorChange() || tile->getTeleportItem())) {
return false;
}
if (!ignoreHeight && tile->hasHeight(1)) {
return false;
}
return true;
}
示例3: getWalkCache
int32_t Creature::getWalkCache(const Position& pos) const
{
if(!useCacheMap()){
return 2;
}
const Position& myPos = getPosition();
if(myPos.z != pos.z){
return 0;
}
if(pos == myPos){
return 1;
}
int32_t dx = pos.x - myPos.x;
int32_t dy = pos.y - myPos.y;
if((std::abs(dx) <= (mapWalkWidth - 1) / 2) &&
(std::abs(dy) <= (mapWalkHeight - 1) / 2)){
int32_t x = (mapWalkWidth - 1) / 2 + dx;
int32_t y = (mapWalkHeight - 1) / 2 + dy;
#ifdef __DEBUG__
//testing
Tile* tile = g_game.getParentTile(pos.x, pos.y, pos.z);
if(tile && (tile->__queryAdd(0, this, 1, FLAG_PATHFINDING | FLAG_IGNOREFIELDDAMAGE) == RET_NOERROR)){
if(!localMapCache[y][x]){
std::cout << "Wrong cache value" << std::endl;
}
}
else{
if(localMapCache[y][x]){
std::cout << "Wrong cache value" << std::endl;
}
}
#endif
if(localMapCache[y][x]){
return 1;
}
else{
return 0;
}
}
//out of range
return 2;
}
示例4: canWalkTo
bool Monster::canWalkTo(Position pos, Direction dir)
{
if(getNoMove())
return false;
switch(dir)
{
case NORTH:
pos.y += -1;
break;
case WEST:
pos.x += -1;
break;
case EAST:
pos.x += 1;
break;
case SOUTH:
pos.y += 1;
break;
default:
break;
}
if(!isInSpawnRange(pos) || !getWalkCache(pos))
return false;
Tile* tile = g_game.getTile(pos);
if(!tile || g_game.isSwimmingPool(NULL, getTile(), false) != g_game.isSwimmingPool(NULL, tile, false)) // prevent monsters entering/exiting to swimming pool
return false;
/*
// Check here
// If we don't follow, or attack, and we can't handle the damage, then we can't move on this field
MagicField* field = NULL;
if(!followCreature && !attackedCreature && (field = tile->getFieldItem()) && !isImmune(field->getCombatType()))
return false;
*/
return !tile->getTopVisibleCreature(this) && tile->__queryAdd(
0, this, 1, FLAG_PATHFINDING) == RET_NOERROR;
}
示例5: canWalkTo
bool Npc::canWalkTo(const Position& fromPos, Direction dir)
{
Position toPos = fromPos;
switch(dir){
case NORTH:
toPos.y -= 1;
break;
case SOUTH:
toPos.y += 1;
break;
case WEST:
toPos.x -= 1;
break;
case EAST:
toPos.x += 1;
break;
default:
break;
}
bool result = Spawns::getInstance()->isInZone(masterPos, masterRadius, toPos);
if(!result){
return false;
}
Tile* tile = g_game.getTile(toPos.x, toPos.y, toPos.z);
if(!tile || tile->__queryAdd(0, this, 1, 0) != RET_NOERROR){
return false;
}
if(!floorChange && (tile->floorChange() || tile->getTeleportItem())){
return false;
}
return true;
}
示例6: canWalkTo
bool Monster::canWalkTo(Position pos, Direction dir)
{
switch(dir)
{
case NORTH: pos.y += -1; break;
case WEST: pos.x += -1; break;
case EAST: pos.x += 1; break;
case SOUTH: pos.y += 1; break;
default:
break;
}
if(isInSpawnRange(pos))
{
if(getWalkCache(pos) == 0)
return false;
Tile* tile = g_game.getTile(pos.x, pos.y, pos.z);
if(tile && tile->getTopVisibleCreature(this) == NULL && tile->__queryAdd(0, this, 1, FLAG_PATHFINDING) == RET_NOERROR)
return true;
}
return false;
}
示例7: canWalkTo
bool Actor::canWalkTo(Position pos, Direction dir)
{
switch(dir.value()){
case enums::NORTH: pos.y += -1; break;
case enums::WEST: pos.x += -1; break;
case enums::EAST: pos.x += 1; break;
case enums::SOUTH: pos.y += 1; break;
default:
break;
}
if(isInSpawnRange(pos)){
if(getWalkCache(pos) == 0){
return false;
}
Tile* tile = g_game.getParentTile(pos.x, pos.y, pos.z);
if(tile && tile->getTopVisibleCreature(this) == NULL && tile->__queryAdd(0, this, 1, FLAG_PATHFINDING) == RET_NOERROR){
return true;
}
}
return false;
}