本文整理汇总了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;
}