本文整理汇总了C++中PlayerObject::getTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getTarget方法的具体用法?C++ PlayerObject::getTarget怎么用?C++ PlayerObject::getTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handleTeach
void ObjectController::_handleTeach(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// check if our attribute targetplayer exists
// check if our target is a player
// parse the string if a known skill was selected
// check what skills we can teach
// check which of these skills the target might learn
PlayerObject* teacherObject = dynamic_cast<PlayerObject*>(mObject);
PlayerObject* pupilObject = dynamic_cast<PlayerObject*> (teacherObject->getTarget());
// check if we have a target
if(!pupilObject )
{
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","no_target");
return;
}
if(pupilObject == teacherObject)
{
// target self:(
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","no_teach_self");
return;
}
if((teacherObject->getGroupId() == 0)||(teacherObject->getGroupId() != pupilObject ->getGroupId()))
{
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","not_in_same_group","","",L"",0,"","",L"",pupilObject->getId());
return;
}
//check if our pupil already gets taught
if (!pupilObject->getTrade()->getTeacher())
{
pupilObject->getTrade()->setTeacher(teacherObject);
gSkillManager->teach(pupilObject,teacherObject,"");
}
else
{
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","student_has_offer_to_learn","","",L"",0,"","",L"",pupilObject->getId());
}
}
示例2: playerWorldUpdate
//.........这里部分代码省略.........
{
// gLogger->logMsgF("... but to close to last update pos, %.1f",MSG_NORMAL, player->mPosition.distance2D(player->getLastUpdatePosition()));
}
}
}
}
else
{
mMovementInactivityTrigger = 2; // We only check this when we are running idle with slow frequency
// Need to be standstill for this amount of seconds * 5 (or whatever time we use for slow updates) before we update.
}
}
// Position check for SI-update.
OutOfUpdateRange |= !(glm::distance(player->mPosition, player->getLastUpdatePosition()) < 64.0f);
//OutOfUpdateRange |= !(player->mPosition.inRange2D(player->getLastUpdatePosition(),64.0f));
// gLogger->logMsgF("Distance = %f",MSG_NORMAL, player->mPosition.distance2D(player->getLastUpdatePosition()));
if (mUpdatingObjects || forcedUpdate || OutOfUpdateRange)
{
// More than 64 m from where we loaded SI, reload it.
// We need to abort any pending operation if we get a forcedUpdate (meaning entered, changed or left a cell or subzone).
if ((forcedUpdate) || OutOfUpdateRange)
{
// Save these coordinates
// gLogger->logMsg("forcedUpdate");
mDestroyOutOfRangeObjects = false; // Stop the destroy-messages, in case we already have started to send them.
if (OutOfUpdateRange)
{
// gLogger->logMsg("Out of 64m range");
player->setLastUpdatePosition(player->mPosition);
//If our player is mounted let's update his mount
if(player->checkIfMounted() && player->getMount())
{
player->getMount()->setLastUpdatePosition(player->mPosition);
}
// We shall destroy out of range objects when we are done with the update of known objects.
mDestroyOutOfRangeObjects = true;
}
_findInRangeObjectsOutside(true);
}
}
else if (!mDestroyOutOfRangeObjects)
{
// This is the fast update, based on qt.
// gLogger->logMsg("_findInRangeObjectsOutside(false)");
_findInRangeObjectsOutside(false);
}
// Update some of the objects we found.
mUpdatingObjects = !_updateInRangeObjectsOutside();
if (!mUpdatingObjects)
{
// We are not updating new objects.
if (mDestroyOutOfRangeObjects)
{
// We are ready to destroy objects out of range.
if (_destroyOutOfRangeObjects(&mInRangeObjects))
{
// All objects are now destroyed.
mDestroyOutOfRangeObjects = false;
// If active target out of range, clear.
if (player->getTarget())
{
// gLogger->logMsgF("playerWorldUpdate have a Target of type %d", MSG_NORMAL, player->getTarget()->getType());
// The list of objects we shall check for untargeting consist of all objects that we can "interact with".
if ((player->getTarget()->getType() & (ObjType_Player | ObjType_NPC | ObjType_Creature)) ||
((player->getTarget()->getType() == ObjType_Tangible) && (dynamic_cast<TangibleObject*>(player->getTarget())->getTangibleGroup() == TanGroup_TicketCollector)))
{
if (!(player->checkKnownObjects(player->getTarget())))
{
player->setTarget(NULL);
gMessageLib->sendTargetUpdateDeltasCreo6(player);
// gLogger->logMsg("playerWorldUpdate clear Target");
}
}
}
}
}
}
}
uint64 msToWait = 4900; // Will give 5 sec.
if (mUpdatingObjects || mDestroyOutOfRangeObjects)
{
// We are busy, need to continue processing asap.
msToWait = 900; // This should make us tick every second, since that's the base time for the timer we use.
}
return msToWait;
}