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


C++ Town::getTemplePosition方法代码示例

本文整理汇总了C++中Town::getTemplePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Town::getTemplePosition方法的具体用法?C++ Town::getTemplePosition怎么用?C++ Town::getTemplePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Town的用法示例。


在下文中一共展示了Town::getTemplePosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: teleportToTown

void Commands::teleportToTown(Player* player, const std::string& cmd, const std::string& param)
{
	std::string tmp = param;
	Town* town = Towns::getInstance().getTown(tmp);
	if (town) {
		Position oldPosition = player->getPosition();
		Position newPosition = g_game.getClosestFreeTile(player, 0, town->getTemplePosition(), true);

		if (player->getPosition() != town->getTemplePosition()) {
			if (newPosition.x == 0) {
				player->sendCancel("You can not teleport there.");
			} else if (g_game.internalTeleport(player, newPosition) == RET_NOERROR) {
				g_game.addMagicEffect(oldPosition, NM_ME_POFF, player->isInGhostMode());
				g_game.addMagicEffect(newPosition, NM_ME_TELEPORT, player->isInGhostMode());
			}
		}
	} else {
		player->sendCancel("Could not find the town.");
	}
}
开发者ID:Remoq7,项目名称:forgottenserver,代码行数:20,代码来源:commands.cpp

示例2: teleportToTown

bool Commands::teleportToTown(Creature* creature, const std::string& cmd, const std::string& param)
{
	std::string tmp = param;
	Player* player = creature->getPlayer();

	if(!player){
		return false;
	}

	Town* town = Towns::getInstance().getTown(tmp);
	if(town){
		if(g_game.internalTeleport(creature, town->getTemplePosition()) == RET_NOERROR) {
			g_game.addMagicEffect(town->getTemplePosition(), NM_ME_ENERGY_AREA);
			return true;
		}
	}

	player->sendCancel("Could not find the town.");

	return false;
}
开发者ID:ChubNtuck,项目名称:avesta74,代码行数:21,代码来源:commands.cpp

示例3: loadPlayer


//.........这里部分代码省略.........
		}
		else{
			delete condition;
		}
	}
	// you need to set the vocation after conditions in order to ensure the proper regeneration rates for the vocation
	player->setVocation(result->getDataInt("vocation"));
	// this stuff has to go after the vocation is set
	player->mana = result->getDataInt("mana");
	player->manaMax = result->getDataInt("manamax");
	player->magLevel = result->getDataInt("maglevel");

	uint32_t nextManaCount = (uint32_t)player->vocation->getReqMana(player->magLevel + 1);
	uint32_t manaSpent = (uint32_t)result->getDataInt("manaspent");
	if(manaSpent > nextManaCount){
		//make sure its not out of bound
		manaSpent = 0;
	}
	player->manaSpent = manaSpent;
	player->magLevelPercent = Player::getPercentLevel(player->manaSpent, nextManaCount);

	player->setLossPercent(LOSS_EXPERIENCE, result->getDataInt("loss_experience"));
	player->setLossPercent(LOSS_MANASPENT, result->getDataInt("loss_mana"));
	player->setLossPercent(LOSS_SKILLTRIES, result->getDataInt("loss_skills"));
	player->setLossPercent(LOSS_ITEMS, result->getDataInt("loss_items"));

	player->loginPosition.x = result->getDataInt("posx");
	player->loginPosition.y = result->getDataInt("posy");
	player->loginPosition.z = result->getDataInt("posz");

	player->town = result->getDataInt("town_id");
	Town* town = Towns::getInstance().getTown(player->town);
	if(town){
		player->masterPos = town->getTemplePosition();
	}

	//if posx == 0 AND posy == 0 AND posz == 0
	// login position is temple position
	Position loginPos = player->loginPosition;
	if (loginPos.x == 0 && loginPos.y == 0 && loginPos.z == 0) {
		player->loginPosition = player->masterPos;
	}

	Account acc;
	if (player->getVocationId() && acc.premEnd > 0 && acc.premEnd < std::time(NULL) && (g_config.getNumber(ConfigManager::TEMPLE_TP_ID) != 0)){
		town = Towns::getInstance().getTown(g_config.getNumber(ConfigManager::TEMPLE_TP_ID));
		player->loginPosition = town->getTemplePosition();
	}

	uint32_t rankid = result->getDataInt("rank_id");
	// place it here and now we can drop all additional query instances as all data were loaded
	player->premiumEnd = result->getDataInt("premend");

	player->balance = result->getDataInt("balance");

	player->guildNick = result->getDataString("guildnick");
	db->freeResult(result);

	if(rankid){
		query << "SELECT `guild_ranks`.`name` as `rank`, `guild_ranks`.`guild_id` as `guildid`, `guild_ranks`.`level` as `level`, `guilds`.`name` as `guildname` FROM `guild_ranks`, `guilds` WHERE `guild_ranks`.`id` = " << rankid << " AND `guild_ranks`.`guild_id` = `guilds`.`id`";
		if((result = db->storeQuery(query.str()))){
			player->guildName = result->getDataString("guildname");
			player->guildLevel = result->getDataInt("level");
			player->guildId = result->getDataInt("guildid");
			player->guildRank = result->getDataString("rank");
开发者ID:gianflogao,项目名称:divinity-ots,代码行数:66,代码来源:ioplayer.cpp

示例4: loadPlayer


//.........这里部分代码省略.........
	int32_t skullType = result->getDataInt("skull_type");
	int64_t lastSkullTime = result->getDataLong("skull_time");

	if((skullType == SKULL_RED && std::time(NULL) < lastSkullTime + g_config.getNumber(ConfigManager::RED_SKULL_DURATION))){
		player->lastSkullTime = lastSkullTime;
		player->skullType = (Skulls_t)skullType;
	}
#endif

	loadConditions(player, result);

	// you need to set the vocation after conditions in order to ensure the proper regeneration rates for the vocation
	if(!player->setVocation(result->getDataInt("vocation"))){
		return false;
	}
	// this stuff has to go after the vocation is set
	player->mana = result->getDataInt("mana");
	player->manaMax = result->getDataInt("manamax");
	player->magLevel = result->getDataInt("maglevel");

	uint64_t nextManaCount = (uint64_t)player->vocation->getReqMana(player->magLevel + 1);
	uint64_t manaSpent = (uint64_t)result->getDataInt("manaspent");
	if(manaSpent > nextManaCount){
		//make sure its not out of bound
		manaSpent = 0;
	}
	player->manaSpent = manaSpent;
	player->magLevelPercent = Player::getPercentLevel(player->manaSpent, nextManaCount);

	player->setLossPercent(LOSS_EXPERIENCE, result->getDataInt("loss_experience"));
	player->setLossPercent(LOSS_MANASPENT, result->getDataInt("loss_mana"));
	player->setLossPercent(LOSS_SKILLTRIES, result->getDataInt("loss_skills"));
	player->setLossPercent(LOSS_ITEMS, result->getDataInt("loss_items"));
	player->setLossPercent(LOSS_CONTAINERS, result->getDataInt("loss_containers"));

	player->loginPosition.x = result->getDataInt("posx");
	player->loginPosition.y = result->getDataInt("posy");
	player->loginPosition.z = result->getDataInt("posz");

	player->town = result->getDataInt("town_id");
	Town* town = Towns::getInstance().getTown(player->town);
	if(town){
		player->masterPos = town->getTemplePosition();
	}

	//if posx == 0 AND posy == 0 AND posz == 0
	// login position is temple position
	Position loginPos = player->loginPosition;
	if(loginPos.x == 0 && loginPos.y == 0 && loginPos.z == 0){
		player->loginPosition = player->masterPos;
	}

	// place it here and now we can drop all additional query instances as all data were loaded
#ifdef __OLD_GUILD_SYSTEM__
	uint32_t rankid = result->getDataInt("rank_id");
	player->guildNick = result->getDataString("guildnick");
#endif

	player->balance = result->getDataInt("balance");
	db->freeResult(result);

	//guild system
	query.str("");

#ifdef __OLD_GUILD_SYSTEM__
	query << "SELECT `guild_ranks`.`name` as `rank`, `guild_ranks`.`guild_id` as `guildid`, \
		`guild_ranks`.`level` as `level`, `guilds`.`name` as `guildname` \
		FROM `guild_ranks`, `guilds` \
		WHERE `guild_ranks`.`id` = " << rankid << " AND `guild_ranks`.`guild_id` = `guilds`.`id`";

	if((result = db->storeQuery(query.str()))){
		Guild* guild = g_guilds.getGuildById(result->getDataInt("guildid"));
		if(guild){
			player->setGuild(guild);

			player->guildRank = result->getDataString("rank");
			player->guildLevel = result->getDataInt("level");

			db->freeResult(result);
		}
	}
#else
	query << "SELECT `guild_members`.`nick`, `guild_ranks`.`name`, `guild_ranks`.`level`, `guilds`.`id` \
		FROM `guild_members` \
		LEFT JOIN `guild_ranks` ON `guild_members`.`rank_id` =  `guild_ranks`.`id` \
		LEFT JOIN `guilds` ON `guilds`.`id` = `guild_ranks`.`guild_id` \
		WHERE `guild_members`.`player_id` = " << player->getGUID();

	if((result = db->storeQuery(query.str()))){
		Guild* guild = g_guilds.getGuildById(result->getDataInt("id"));
		if(guild){
			player->setGuild(guild);

			player->guildRank = result->getDataString("name");
			player->guildLevel = result->getDataInt("level");
			player->guildNick = result->getDataString("nick");

			db->freeResult(result);
		}
	}
开发者ID:angeliker,项目名称:OTHire,代码行数:101,代码来源:ioplayer.cpp

示例5: loadPlayer


//.........这里部分代码省略.........
	player->currentOutfit = player->defaultOutfit;

	if (g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) {
		int32_t skullSeconds = result->getDataInt("skulltime") - time(NULL);

		if (skullSeconds > 0) {
			//ensure that we round up the number of ticks
			player->skullTicks = (skullSeconds + 2) * 1000;
			int32_t skull = result->getDataInt("skull");

			if (skull == SKULL_RED) {
				player->skull = SKULL_RED;
			} else if (skull == SKULL_BLACK) {
				player->skull = SKULL_BLACK;
			}
		}
	}

	player->loginPosition.x = result->getDataInt("posx");
	player->loginPosition.y = result->getDataInt("posy");
	player->loginPosition.z = result->getDataInt("posz");

	player->lastLoginSaved = result->getDataLong("lastlogin");
	player->lastLogout = result->getDataLong("lastlogout");

	player->offlineTrainingTime = result->getDataInt("offlinetraining_time") * 1000;
	player->offlineTrainingSkill = result->getDataInt("offlinetraining_skill");

	player->town = result->getDataInt("town_id");

	Town* town = Towns::getInstance().getTown(player->town);

	if (town) {
		player->masterPos = town->getTemplePosition();
	}

	Position loginPos = player->loginPosition;

	if (loginPos.x == 0 && loginPos.y == 0 && loginPos.z == 0) {
		player->loginPosition = player->masterPos;
	}

	player->staminaMinutes = result->getDataInt("stamina");

	db->freeResult(result);

	query.str("");
	query << "SELECT `guild_id`, `rank_id`, `nick` FROM `guild_membership` WHERE `player_id` = " << player->getGUID();

	if ((result = db->storeQuery(query.str()))) {
		uint32_t guildId = result->getDataInt("guild_id");
		uint32_t playerRankId = result->getDataInt("rank_id");
		player->guildNick = result->getDataString("nick");
		db->freeResult(result);

		Guild* guild = g_game.getGuild(guildId);

		if (!guild) {
			query.str("");
			query << "SELECT `name` FROM `guilds` WHERE `id` = " << guildId;

			if ((result = db->storeQuery(query.str()))) {
				guild = new Guild(guildId, result->getDataString("name"));
				db->freeResult(result);
				g_game.addGuild(guild);
开发者ID:24312108k,项目名称:forgottenserver,代码行数:66,代码来源:iologindata.cpp

示例6: loadPlayer

bool IOPlayer::loadPlayer(Player* player, const std::string& name, bool preload /*= false*/)
{
	DatabaseDriver* db = DatabaseDriver::instance();
	DBQuery query;
	DBResult_ptr result;

	query << "SELECT `players`.`id` AS `id`, `players`.`name` AS `name`, `accounts`.`name` AS `accname`, \
		`account_id`, `sex`, `vocation`, `town_id`, `experience`, `level`, `maglevel`, `health`, \
		`groups`.`name` AS `groupname`, `groups`.`flags` AS `groupflags`, `groups`.`access` AS `access`, \
		`groups`.`maxviplist` AS `maxviplist`, `groups`.`maxdepotitems` AS `maxdepotitems`, `groups`.`violation` AS `violationaccess`, \
		`healthmax`, `mana`, `manamax`, `manaspent`, `soul`, `direction`, `lookbody`, \
		`lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `posx`, `posy`, `posz`, `cap`, \
		`lastlogin`, `lastlogout`, `lastip`, `conditions`, `skull_time`, `skull_type`, `stamina`, \
		`loss_experience`, `loss_mana`, `loss_skills`, `loss_items`, `loss_containers` \
		FROM `players` \
		LEFT JOIN `accounts` ON `account_id` = `accounts`.`id`\
		LEFT JOIN `groups` ON `groups`.`id` = `players`.`group_id` \
		WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID) << " AND `players`.`name` = " + db->escapeString(name);

	if(!(result = db->storeQuery(query))){
		return false;
	}

	player->setGUID(result->getDataInt("id"));
	player->accountId = result->getDataInt("account_id");
	player->accountName = result->getDataString("accname");

	player->groupName = result->getDataString("groupname");
	player->accessLevel = result->getDataInt("access");
	player->violationLevel = result->getDataInt("violationaccess");
	player->maxDepotLimit = result->getDataInt("maxdepotitems");
	player->maxVipLimit = result->getDataInt("maxviplist");
	player->setFlags(result->getDataLong("groupflags"));

	if(preload){
		//only loading basic info
		return true;
	}

	// Getting all player properties
	player->setSex((PlayerSex)result->getDataInt("sex"));
	player->setDirection((Direction)result->getDataInt("direction"));
	player->level = std::max((uint32_t)1, (uint32_t)result->getDataInt("level"));

	player->town = result->getDataInt("town_id");
	Town* town = Towns::getInstance()->getTown(player->town);
	if(town){
		player->masterPos = town->getTemplePosition();
	}

	uint64_t currExpCount = Player::getExpForLevel(player->level);
	uint64_t nextExpCount = Player::getExpForLevel(player->level + 1);
	uint64_t experience = (uint64_t)result->getDataLong("experience");
	if(experience < currExpCount || experience  > nextExpCount){
		experience = currExpCount;
	}

	player->experience = experience;
	player->levelPercent = Player::getPercentLevel(player->experience - currExpCount, nextExpCount - currExpCount);
	player->soul = result->getDataInt("soul");
	player->capacity = result->getDataInt("cap");
	player->stamina = result->getDataInt("stamina");
	player->lastLoginSaved = result->getDataInt("lastlogin");
	player->lastLogout = result->getDataInt("lastlogout");

	player->health = result->getDataInt("health");
	player->healthMax = result->getDataInt("healthmax");
	player->defaultOutfit.lookType = result->getDataInt("looktype");
	player->defaultOutfit.lookHead = result->getDataInt("lookhead");
	player->defaultOutfit.lookBody = result->getDataInt("lookbody");
	player->defaultOutfit.lookLegs = result->getDataInt("looklegs");
	player->defaultOutfit.lookFeet = result->getDataInt("lookfeet");
	player->defaultOutfit.lookAddons = result->getDataInt("lookaddons");

	player->currentOutfit = player->defaultOutfit;

#ifdef __SKULLSYSTEM__
	SkullType skullType = SkullType(result->getDataInt("skull_type"));
	int64_t lastSkullTime = result->getDataLong("skull_time");

	if((skullType == SKULL_RED && std::time(NULL) < lastSkullTime + g_config.getNumber(ConfigManager::RED_SKULL_DURATION)) ||
		(skullType == SKULL_BLACK && std::time(NULL) < lastSkullTime + g_config.getNumber(ConfigManager::BLACK_SKULL_DURATION))){
		player->lastSkullTime = lastSkullTime;
		player->skullType = skullType;
	}
#endif

	unsigned long conditionsSize = 0;
	const char* conditions = result->getDataStream("conditions", conditionsSize);
	PropStream propStream;
	propStream.init(conditions, conditionsSize);

	Condition* condition;
	while((condition = Condition::createCondition(propStream))){
		if(condition->unserialize(propStream)){
			player->storedConditionList.push_back(condition);
		}
		else{
			delete condition;
		}
//.........这里部分代码省略.........
开发者ID:Pietia10,项目名称:server,代码行数:101,代码来源:ioplayer.cpp


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