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


C++ Reference::checkForageAreas方法代码示例

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


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

示例1: finishForaging

void ForageManagerImplementation::finishForaging(CreatureObject* player, int forageType, float forageX, float forageY, const String& zoneName) {
	if (player == NULL)
		return;

	Locker playerLocker(player);
	Locker forageAreasLocker(_this.get());

	player->removePendingTask("foraging");

	if (player->getZone() == NULL)
		return;

	//Check if player moved.
	float playerX = player->getPositionX();
	float playerY = player->getPositionY();

	if ((fabs(playerX - forageX) > 2.0) || (fabs(playerY - forageY) > 2.0) || player->getZone()->getZoneName() != zoneName) {
		player->sendSystemMessage("@skl_use:sys_forage_movefail"); //"You fail to forage because you moved."
		return;
	}

	//Check if player is in combat.
	if (player->isInCombat()) {
		player->sendSystemMessage("@skl_use:sys_forage_combatfail"); //"Combat distracts you from your foraging attempt."
		return;
	}

	//Check if player is allowed to forage in this area.
	if (forageType != ForageManager::SHELLFISH) {

		Reference<ForageAreaCollection*> forageAreaCollection = forageAreas.get(player->getFirstName());

		if (forageAreaCollection != NULL) { //Player has foraged before.
			if (!forageAreaCollection->checkForageAreas(forageX, forageY, zoneName, forageType)) {
				if( forageType == LAIR ){
					player->sendSystemMessage("There is nothing of interest remaining in the lair.");
				}
				else{
					player->sendSystemMessage("@skl_use:sys_forage_empty"); //"There is nothing in this area to forage."
				}
				return;
			}

		} else { //Player has not foraged before.
			forageAreaCollection = new ForageAreaCollection(player, forageX, forageY, zoneName, forageType);
			forageAreas.put(player->getFirstName(), forageAreaCollection);
		}
	}

	//Calculate the player's chance to find an item.
	int chance;
	int skillMod;

	switch(forageType) {
	case ForageManager::SCOUT:
	case ForageManager::LAIR:
		skillMod = player->getSkillMod("foraging");
		chance = (int)(15 + (skillMod * 0.8));
		break;
	case ForageManager::MEDICAL:
		skillMod = player->getSkillMod("medical_foraging");
		chance = (int)(15 + (skillMod * 0.6));
		break;
	default:
		skillMod = 20;
		chance = (int)(15 + (skillMod * 0.6));
		break;
	}

	//Determine if player finds an item.
	if (chance > 100) //There could possibly be +foraging skill tapes.
		chance = 100;

	if (System::random(80) > chance) {
		if (forageType == ForageManager::SHELLFISH)
			player->sendSystemMessage("@harvesting:found_nothing");
		else if (forageType == ForageManager::LAIR)
			player->sendSystemMessage("@lair_n:found_nothing");
		else
			player->sendSystemMessage("@skl_use:sys_forage_fail"); //"You failed to find anything worth foraging."

	} else {

		forageGiveItems(player, forageType, forageX, forageY, zoneName);

	}

	return;

}
开发者ID:Chilastra-Reborn,项目名称:Chilastra-source-code,代码行数:90,代码来源:ForageManagerImplementation.cpp


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