本文整理汇总了C++中PlayerObject::getTargetId方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getTargetId方法的具体用法?C++ PlayerObject::getTargetId怎么用?C++ PlayerObject::getTargetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getTargetId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//======================================================================================================================
//
// Modifies the Admin List
//
void ObjectController::_handleTransferStructure(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// requirement we have the structure targeted AND give the name of the recipient on the commandline
// OR we have the recipient targeted and stand NEXT to the structure were about to transfer
//do we have a valid donor ?
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if(!player)
{
return;
}
// is the player online and near 30m ?
// we get the players id as targetid if yes, otherwise we get the name as string
// however, we do not want players that are not online
//now get the target player
PlayerObject* recipient = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(targetId));
if(!recipient)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "no_transfer_target"), player);
return;
}
//do we have a valid structure ??? check our target first
uint64 id = player->getTargetId();
Object* object = gWorldManager->getObjectById(id);
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);
if(!structure)
{
// we need to get the nearest structure that we own
// for now dustoff
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
//is the structure in Range???
float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Transfer_Structure_Distance",(float)8.0);
if(glm::distance(player->mPosition, structure->mPosition) > fTransferDistance)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
StructureAsyncCommand command;
command.PlayerId = player->getId();
command.StructureId = structure->getId();
command.RecipientId = recipient->getId();
command.PlayerStr = recipient->getFirstName().getAnsi();
command.Command = Structure_Command_TransferStructure;
gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->getFirstName().getAnsi(),"ADMIN",command);
}
示例2: sscanf
//======================================================================================================================
//
// Modifies the Admin List
//
void ObjectController::_handleNameStructure(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// requirement we have the structure targeted AND give the name of the recipient on the commandline
// OR we have the recipient targeted and stand NEXT to the structure were about to transfer
//do we have a valid donor ?
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if(!player)
{
return;
}
//do we have a valid structure ??? check our target first
uint64 id = player->getTargetId();
Object* object = gWorldManager->getObjectById(id);
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);
if(!structure)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
//is the structure in Range???
float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
if(glm::distance(player->mPosition, structure->mPosition) > fTransferDistance)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
//find out where our structure is
BString dataStr;
message->getStringUnicode16(dataStr);
BString nameStr;
dataStr.convert(BSTRType_ANSI);
sscanf(dataStr.getAnsi(),"%s",nameStr.getAnsi());
if(nameStr.getLength() > 68)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "not_valid_name"), player);
return;
}
StructureAsyncCommand command;
command.Command = Structure_Command_RenameStructure;
command.PlayerId = player->getId();
command.StructureId = structure->getId();
gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->getFirstName().getAnsi(),"ADMIN",command);
}
示例3: getTarget
uint64 ScriptSupport::getTarget(uint64 playerId)
{
uint64 targetId = 0;
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(playerId));
if (playerObject)
{
targetId = playerObject->getTargetId();
}
return targetId;
}
示例4: removeKnownObject
bool Object::removeKnownObject(Object* object)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(this);
if(player)
{
if(player->getTargetId() == object->getId())
player->setTarget(0);
}
if(object->getType() == ObjType_Player)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(object);
PlayerObjectSet::iterator it = mKnownPlayers.find(player);
if(it != mKnownPlayers.end())
{
//we might be its target
if(player->getTargetId() == this->getId())
player->setTarget(0);
mKnownPlayers.erase(it);
return(true);
}
}
else
{
ObjectSet::iterator it = mKnownObjects.find(object);
if(it != mKnownObjects.end())
{
mKnownObjects.erase(it);
return(true);
}
}
return(false);
}
示例5: getParentOfTarget
uint64 ScriptSupport::getParentOfTarget(uint64 playerId)
{
uint64 parentId = 0;
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(playerId));
if (playerObject)
{
uint64 targetId = playerObject->getTargetId();
Object* object = dynamic_cast<Object*>(gWorldManager->getObjectById(targetId));
if (object)
{
parentId = object->getParentId();
}
}
return parentId;
}
示例6: unRegisterWatcher
bool Object::unRegisterWatcher(PlayerObject* object) {
if (getType() == ObjType_Player) {
PlayerObject* player = static_cast<PlayerObject*>(this);
if (player->getTargetId() == object->getId()) {
player->setTarget(0);
}
}
auto it = mKnownPlayers.find(object);
if (it != mKnownPlayers.end()) {
if (object->getTargetId() == getId()) {
object->setTarget(0);
}
mKnownPlayers.erase(it);
//DLOG(info) << "Object::unRegisterWatcher :: Player" << object->getId() << " was successfully unregistered from " << getId();
return true;
}
DLOG(info) << "Object::unRegisterWatcher :: Object" << object->getId() << " could not be unregistered for " << getId();
return false;
}
示例7: if
//======================================================================================================================
//
// Modifies the Admin List
//
void ObjectController::_handleModifyPermissionList(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if(!player)
{
DLOG(INFO) << " ObjectController::_handleModifyPermissionList Player not found";
return;
}
//find out where our structure is
BString dataStr;
message->getStringUnicode16(dataStr);
BString playerStr,list,action;
dataStr.convert(BSTRType_ANSI);
int8 s1[64],s2[32],s3[32];
sscanf(dataStr.getAnsi(),"%32s %16s %16s",s1, s2, s3);
playerStr = s1;
list = s2;
action = s3;
if(playerStr.getLength() > 40)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "permission_40_char"), player);
return;
}
//TODO is target a structure?? used when using the commandline option
uint64 id = player->getTargetId();
Object* object = gWorldManager->getObjectById(id);
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);
//if we have no structure that way, see whether we have a structure were we just used the adminlist
if(!structure)
{
id = player->getStructurePermissionId();
Object* object = gWorldManager->getObjectById(id);
structure = dynamic_cast<PlayerStructure*>(object);
}
if(!structure)
{
return;
}
//is the structure in Range???
float fAdminListDistance = gWorldConfig->getConfiguration<float>("Player_Admin_List_Distance",(float)32.0);
if(player->getParentId())
{
if(CellObject* cell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(player->getParentId())))
{
if(HouseObject* house = dynamic_cast<HouseObject*>(gWorldManager->getObjectById(cell->getParentId())))
{
if(house->getId() != structure->getId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
}
}
}
else if(glm::distance(player->mPosition, structure->mPosition) > fAdminListDistance)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
player->setStructurePermissionId(0);
StructureAsyncCommand command;
command.PlayerId = player->getId();
command.StructureId = structure->getId();
command.List = list;
command.PlayerStr = playerStr;
if(action == "add")
{
command.Command = Structure_Command_AddPermission;
gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->getFirstName().getAnsi(),"ADMIN",command);
}
if(action == "remove")
{
command.Command = Structure_Command_RemovePermission;
gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->getFirstName().getAnsi(),"ADMIN",command);
}
}
示例8: playerWorldUpdate
//.........这里部分代码省略.........
{
// We are not "busy" processing anything from previous sessions.
if (player->getCurrentSpeed() == 0.0)
{
if (mMovementInactivityTrigger > 0)
{
if (--mMovementInactivityTrigger == 0)
{
// We are not moving, but how far are we from last full update pos?
if (glm::distance(player->mPosition, player->getLastUpdatePosition()) < 16)
{
// Force a full update, inclusive of saving current "update pos".
OutOfUpdateRange = true;
}
}
}
}
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));
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
mDestroyOutOfRangeObjects = false; // Stop the destroy-messages, in case we already have started to send them.
if (OutOfUpdateRange)
{
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.
_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->getTargetId())
{
Object* target = player->getTarget();
if (target && (!(player->checkKnownObjects(target))))
{
player->setTarget(0);
gMessageLib->sendTargetUpdateDeltasCreo6(player);
}
}
}
}
}
}
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;
}