当前位置: 首页>>代码示例>>C++>>正文


C++ Tile::__queryAdd方法代码示例

本文整理汇总了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;
}
开发者ID:alexisjojo,项目名称:darkkonia,代码行数:33,代码来源:monster.cpp

示例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;
}
开发者ID:NoyiGao,项目名称:forgottenserver,代码行数:26,代码来源:npc.cpp

示例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;
}
开发者ID:Ablankzin,项目名称:server,代码行数:50,代码来源:creature.cpp

示例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;
}
开发者ID:milbradt,项目名称:TFS,代码行数:41,代码来源:monster.cpp

示例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;
}
开发者ID:cp1337,项目名称:devland,代码行数:41,代码来源:npc.cpp

示例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;
}
开发者ID:armadaazteca,项目名称:tfs0.2.15,代码行数:23,代码来源:monster.cpp

示例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;
}
开发者ID:opentibia,项目名称:server,代码行数:24,代码来源:actor.cpp


注:本文中的Tile::__queryAdd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。