本文整理汇总了C++中PlayerObject::checkIfMounted方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::checkIfMounted方法的具体用法?C++ PlayerObject::checkIfMounted怎么用?C++ PlayerObject::checkIfMounted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::checkIfMounted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPlayerPosition
void ScriptSupport::setPlayerPosition(uint64 playerId, uint64 cellId, float posX, float posY, float posZ)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(playerId));
if (player)
{
// Anh_Math::Quaternion direction;
glm::vec3 position;
position.x = posX;
position.y = posY;
position.z = posZ;
player->mPosition = position;
player->setParentId(cellId);
if (cellId)
{
// We are inside a cell.
gMessageLib->sendDataTransformWithParent053(player);
gMessageLib->sendUpdateTransformMessageWithParent(player);
}
else
{
gMessageLib->sendDataTransform053(player);
gMessageLib->sendUpdateTransformMessage(player);
//If our player is mounted move his mount aswell
if(player->checkIfMounted() && player->getMount())
{
player->getMount()->mPosition = position;
gMessageLib->sendDataTransform053(player->getMount());
gMessageLib->sendUpdateTransformMessage(player->getMount());
}
}
}
}
示例2: DismountPlayer
void VehicleController::DismountPlayer() {
if(!body_) {
LOG(error) << "Vehicle::DismountPlayer() no vehicle body!";
return;
}
PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(owner_));
CreatureObject* owner_creature = owner->GetCreature();
if(!owner->checkIfMounted()) {
LOG(error) << "Vehicle::DismountPlayer() no vehicle body!";
return;
}
//For safe measures make the player equipped by nothing
body_->RemoveObject(owner, owner_creature);
gMessageLib->sendContainmentMessage_InRange(owner_creature->getId(), 0, owner_creature->GetArrangementId(), owner_creature);
gMessageLib->sendUpdateTransformMessage(body_);
// TODO: make this more automatic...
gStateManager.removeActionState(owner_creature, CreatureState_RidingMount);
gStateManager.removeActionState(body_, CreatureState_MountedCreature);
owner->setMounted(false);
gMessageLib->sendPostureAndStateUpdate(owner_creature);
gMessageLib->sendUpdateMovementProperties(owner);
}
示例3: prepareCustomRadialMenu
void MountObject::prepareCustomRadialMenu(CreatureObject* creature, uint8_t item_count) {
PlayerObject* player = creature->GetGhost();// dynamic_cast<PlayerObject*>(creature);
if (!player) {
// Verify the data passed in is what is expected. In debug mode the assert will
// trigger and crash the server.
assert(false && "MountObject::handleObjectMenuSelect - Menu preparation requested for a non-player object.");
return;
}
// Reset the radial menu with a new instance.
mRadialMenu.reset(new RadialMenu());
// Add the radial options for the custom menu.
mRadialMenu->addItem(1, 0, radId_examine, radAction_Default);
// Check to see if the player requesting the menu is the owner of the mount.
if(player->getId() == owner_) {
// Check to see if the player is mounted or not and display the appropriate exit/enter option.
if(player->checkIfMounted()) {
mRadialMenu->addItem(2, 0, radId_serverVehicleExit,radAction_Default, "@pet/pet_menu:menu_enter_exit");
} else {
mRadialMenu->addItem(2, 0, radId_serverVehicleEnter,radAction_Default, "@pet/pet_menu:menu_enter_exit");
}
mRadialMenu->addItem(3, 0, radId_vehicleStore,radAction_ObjCallback, "@pet/pet_menu:menu_store");
// @TODO: Check if near a garage then add repair
}
}
示例4: DismountPlayer
void VehicleController::DismountPlayer() {
if(!body_) {
LOG(error) << "Vehicle::DismountPlayer() no vehicle body!";
return;
}
LOG(error) << "Vehicle::DismountPlayer()";
PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(owner_));
CreatureObject* owner_creature = owner->GetCreature();
if(!owner->checkIfMounted()) {
LOG(error) << "Vehicle::DismountPlayer() no vehicle body!";
return;
}
//see elaboration downstairs
// body_->RemoveObject(owner, owner_creature);
gMessageLib->sendContainmentMessage_InRange(owner_creature->getId(), 0, 0, owner_creature);
//gMessageLib->sendUpdateTransformMessage(body_);
// TODO: make this more automatic...
gStateManager.removeActionState(owner_creature, CreatureState_RidingMount);
gStateManager.setCurrentLocomotionState(owner_creature, CreatureLocomotion_Standing);
gStateManager.setCurrentPostureState(owner_creature, CreaturePosture_Upright);
gStateManager.removeActionState(body_, CreatureState_MountedCreature);
owner->setMounted(false);
gMessageLib->sendUpdateMovementProperties(owner);
}
示例5: _handleMount
void ObjectController::_handleMount(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// The very idea with using ID's instead of object refs are that you can TEST them without using the object itself.
// And some parameter validation...
if (targetId == 0)
{
DLOG(info) << "ObjectController::_handleMount : Cannot find vehicle ID :(";
return;
}
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if (player && player->getMount() && (player->getParentId() == 0))
{
// Do we have a valid target?
if (!player->checkIfMounted())
{
// verify its player's mount
MountObject* pet = dynamic_cast<MountObject*>(gWorldManager->getObjectById(targetId));
if (pet && (pet->owner() == player->getId()))
{
// get the mount Vehicle object by the id (Creature object id - 1 )
if(VehicleController* vehicle = dynamic_cast<VehicleController*>(gWorldManager->getObjectById(pet->controller())))
{
//The /mount command can work up to 32m on live
if(glm::distance(vehicle->body()->mPosition, player->mPosition) <= 32) {
//change locomotion
vehicle->MountPlayer();
} else {
gMessageLib->SendSystemMessage(L"Your target is too far away to mount.", player);
}
}
else
{
DLOG(info) << "ObjectController::_handleMount : Cannot find vehicle";
}
}
} else {
gMessageLib->SendSystemMessage(L"You cannot mount this because you are already mounted.", player);
}
}
}
示例6: Store
//===============================================================================================
//stores the physical body
void VehicleController::Store()
{
if(!body_) {
DLOG(info) << "Vehicle::store() Error: Store was called for a nonexistant body object!";
return;
}
PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(owner_));
if(!owner_ || owner->GetCreature()->isDead() || owner->GetCreature()->isIncapacitated()) {
DLOG(info) << "Vehicle::store() couldnt find owner";
return;
}
// todo auto dismount
if(owner->checkIfMounted())
{
DLOG(info) << "Vehicle::store() dismounted";
DismountPlayer();
}
if(!owner->checkIfMountCalled())
{
DLOG(info) << "Vehicle::store() Mount wasnt called !!!";
return;
}
//the body is a creature_object!!!
gSpatialIndexManager->RemoveObjectFromWorld(body_);
owner->setMount(NULL);
owner->setMounted(false);
owner->setMountCalled(false);
// finally unload & destroy the vehicle creature
gWorldManager->destroyObject(body_);
// null the reference
body_ = NULL;
}
示例7: _handleDismount
void ObjectController::_handleDismount(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// The very idea with using ID's instead of object refs are that you can TEST them without using the object itself.
// And some parameter validation...
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if (player && player->getMount() && (player->getParentId() == 0))
{
if (player->checkIfMounted())
{
// verify its player's mount
MountObject* pet = NULL;
if (targetId == 0)
{
// No object targeted, assume the one we are riding. - what else should we dismount ???
pet = player->getMount();
}
else
{
pet = dynamic_cast<MountObject*>(gWorldManager->getObjectById(targetId));
}
if (pet && (pet->owner() == player->getId()))
{
// get the pets controller for a swoop its the vehicle
if(VehicleController* vehicle = dynamic_cast<VehicleController*>(gWorldManager->getObjectById(pet->controller())))
{
vehicle->DismountPlayer();
}
}
}
else
{
gMessageLib->SendSystemMessage(L"You are not mounted to perform this action.", player);
}
}
}
示例8: _verifyCombatState
bool CombatManager::_verifyCombatState(CreatureObject* attacker, uint64 defenderId)
{
PlayerObject* playerAttacker = dynamic_cast<PlayerObject*>(attacker);
CreatureObject* defender = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(defenderId));
if (!defender)
{
// No such object.
return(false);
}
// Do not try to attack already incapped or dead objects.
if (defender->isIncapacitated() || defender->isDead())
{
return false;
}
//Do not attack if we are incapped or already dead or mounted.
if (attacker->isIncapacitated() || attacker->isDead() || playerAttacker->checkIfMounted())
{
return false;
}
// make sure we got both objects
if (playerAttacker && defender)
{
//Do not attack if we are mounted
if(playerAttacker->checkIfMounted())
{
return false;
}
// if our target is a player, he must be dueling us or both need to be overt(TODO)
if (PlayerObject* defenderPlayer = dynamic_cast<PlayerObject*>(defender))
{
// also return, if our target is incapacitated or dead
if(!playerAttacker->checkDuelList(defenderPlayer) || !defenderPlayer->checkDuelList(playerAttacker)
|| defenderPlayer == playerAttacker)
{
return(false);
}
if(defenderPlayer->isIncapacitated())
{
// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_incap");
return(false);
}
else if(defenderPlayer->isDead())
{
// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_dead");
return(false);
}
// put us in combat state
gStateManager.setCurrentActionState(attacker, CreatureState_Combat);
gStateManager.setCurrentActionState(attacker, CreatureState_CombatAttitudeNormal);
// put our target in combat state
if(!defenderPlayer->states.checkState(CreatureState_Combat))
{
gStateManager.setCurrentActionState(defender, CreatureState_Combat);
gStateManager.setCurrentActionState(defender, CreatureState_CombatAttitudeNormal);
}
// update our defender list
if (!playerAttacker->checkDefenderList(defenderPlayer->getId()))
{
playerAttacker->AddDefender(defenderPlayer->getId());
}
// update our targets defender list
if (!defenderPlayer->checkDefenderList(playerAttacker->getId()))
{
playerAttacker->AddDefender(defenderPlayer->getId());
}
if (!defenderPlayer->autoAttackEnabled())
{
// Player can/may start auto-attack if idle.
defenderPlayer->getController()->enqueueAutoAttack(playerAttacker->getId());
}
}
else
{
// our target is a creature
if (defender->isIncapacitated())
{
// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_incap");
return(false);
}
else if (defender->isDead())
{
// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_dead");
return(false);
}
// Vefify that out target is attackable. It's not nice to spam attacks at innocent npc's.
if (!(defender->getPvPStatus() & CreaturePvPStatus_Attackable))
{
//.........这里部分代码省略.........
示例9: _destroyOutOfRangeObjects
bool ObjectController::_destroyOutOfRangeObjects(ObjectSet *inRangeObjects)
{
//TODO: when a container gets out of range
//we need to destroy the children, too!!!!!!!
// iterate our knowns
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
ObjectSet* knownObjects = player->getKnownObjects();
ObjectSet::iterator objIt = knownObjects->begin();
PlayerObjectSet* knownPlayers = player->getKnownPlayers();
PlayerObjectSet::iterator playerIt = knownPlayers->begin();
const uint32 objectDestroyLimit = 5000;
// update players
while(playerIt != knownPlayers->end())
{
PlayerObject* playerObject = (*playerIt);
// if its not in the current inrange queries result, destroy it
if(inRangeObjects->find(playerObject) == inRangeObjects->end())
{
// send a destroy to us
gMessageLib->sendDestroyObject(playerObject->getId(),player);
//If player is mounted destroy his mount too
if(playerObject->checkIfMounted() && playerObject->getMount())
{
gMessageLib->sendDestroyObject(playerObject->getMount()->getId(),player);
player->removeKnownObject(playerObject->getMount());
playerObject->getMount()->removeKnownObject(player);
}
//send a destroy to him
gMessageLib->sendDestroyObject(player->getId(),playerObject);
//If we're mounted destroy our mount too
if(player->checkIfMounted() && playerObject->getMount())
{
gMessageLib->sendDestroyObject(player->getMount()->getId(),playerObject);
playerObject->removeKnownObject(player->getMount());
player->getMount()->removeKnownObject(playerObject);
}
// we don't know each other anymore
knownPlayers->erase(playerIt++);
playerObject->removeKnownObject(player);
continue;
}
++playerIt;
}
// We may want to limit the amount of messages sent in one session.
uint32 messageCount = 0;
// update objects
//for(ObjectSet::const_iterator objIt = knownObjects->begin(); objIt != knownObjects->end(); objIt++)
//we access the list above so it needs to be reset to the beginning
objIt = knownObjects->begin();
while(objIt != knownObjects->end())
{
Object* object = (*objIt);
// if its not in the current inrange queries result, destroy it
if(inRangeObjects->find(object) == inRangeObjects->end())
{
if(object->getType() == ObjType_Structure)//ObjType_Tangible
{
}
// send a destroy to us
gMessageLib->sendDestroyObject(object->getId(),player);
// we don't know each other anymore
knownObjects->erase(objIt++);
object->removeKnownObject(player);
if (++messageCount >= objectDestroyLimit)
{
break;
}
continue;
}
++objIt;
}
// For test
bool allDestroyed = false;
if (objIt == knownObjects->end())
{
allDestroyed = true;
}
return allDestroyed;
//.........这里部分代码省略.........
示例10: handleRequestCoreSample
bool ArtisanManager::handleRequestCoreSample(Object* player,Object* target, Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(player);
if(cmdProperties)
// unfortunately it's not in this opcode
// hardcode for now
//mSampleActionCost = cmdProperties->mActionCost;
mSampleActionCost = 150;
if(playerObject->GetCreature()->getPerformingState() != PlayerPerformance_None || playerObject->checkIfMounted() || playerObject->GetCreature()->isDead() || playerObject->GetCreature()->states.checkState(CreatureState_Combat))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return false;
}
// can't sample while surveying
if(playerObject->getSurveyState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_survey"), playerObject);
return false;
}
// don't allow sampling in buildings
if(playerObject->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), playerObject);
return false;
}
uint64 localTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
// don't allow more than one sample at a time
if(playerObject->getSamplingState())
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
if(!playerObject->getNextSampleTime() || (int32)(playerObject->getNextSampleTime() - localTime) <= 0)
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(target);
CurrentResource* resource = NULL;
BString resourceName;
message->getStringUnicode16(resourceName);
resourceName.convert(BSTRType_ANSI);
resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));
if(resource == NULL || tool == NULL)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_noresource"), playerObject);
return false;
}
if((resource->getType()->getCategoryId() == 903)||(resource->getType()->getCategoryId() == 904))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "must_have_harvester"), playerObject);
return false;
}
playerObject->setSamplingState(true);
auto terrain = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::terrain::TerrainService>("TerrainService");
if(terrain->IsWater(gWorldManager->getZoneId(), playerObject->mPosition.x, playerObject->mPosition.z))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_swimming"), playerObject);
return false;
}
resourceName.convert(BSTRType_Unicode16);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "start_sampling", L"", L"", resourceName.getUnicode16()), playerObject);
// change posture
gStateManager.setCurrentPostureState(playerObject->GetCreature(), CreaturePosture_Crouched);
// play animation
gWorldManager->getClientEffect(tool->getInternalAttribute<uint32>("sample_effect"));
// schedule execution
std::shared_ptr<SimpleEvent> start_sample_event = nullptr;
start_sample_event = std::make_shared<SimpleEvent>(EventType("start_sample"), 0, 2000,
std::bind(&ArtisanManager::sampleEvent,this, playerObject, resource, tool));
// notify any listeners
gEventDispatcher.Notify(start_sample_event);
return true;
}
示例11: handleRequestCoreSample
bool ArtisanManager::handleRequestCoreSample(Object* player,Object* target, Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(player);
if(cmdProperties)
// unfortunately it's not in this opcode
// hardcode for now
//mSampleActionCost = cmdProperties->mActionCost;
mSampleActionCost = 150;
if(playerObject->getPerformingState() != PlayerPerformance_None || playerObject->checkIfMounted() || playerObject->isDead())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return false;
}
// can't sample while surveying
if(playerObject->getSurveyState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_survey"), playerObject);
return false;
}
// don't allow sampling in buildings
if(playerObject->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), playerObject);
return false;
}
uint64 localTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
// don't allow more than one sample at a time
if(playerObject->getSamplingState())
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
if(!playerObject->getNextSampleTime() || (int32)(playerObject->getNextSampleTime() - localTime) <= 0)
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(target);
CurrentResource* resource = NULL;
BString resourceName;
message->getStringUnicode16(resourceName);
resourceName.convert(BSTRType_ANSI);
resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));
if(resource == NULL || tool == NULL)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_noresource"), playerObject);
return false;
}
if((resource->getType()->getCategoryId() == 903)||(resource->getType()->getCategoryId() == 904))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "must_have_harvester"), playerObject);
return false;
}
playerObject->setSamplingState(true);
ArtisanHeightmapAsyncContainer* container = new ArtisanHeightmapAsyncContainer(this, HeightmapCallback_ArtisanSurvey);
container->addToBatch(playerObject->mPosition.x,playerObject->mPosition.z);
container->playerObject = playerObject;
container->resource = resource;
container->resourceName = resourceName;
container->tool = tool;
gHeightmap->addNewHeightMapJob(container);
return true;
}
示例12: _destroyOutOfRangeObjects
bool ObjectController::_destroyOutOfRangeObjects(ObjectSet *inRangeObjects)
{
//TODO: when a container gets out of range
//we need to destroy the children, too!!!!!!!
// iterate our knowns
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
ObjectSet* knownObjects = player->getKnownObjects();
ObjectSet::iterator objIt = knownObjects->begin();
PlayerObjectSet* knownPlayers = player->getKnownPlayers();
PlayerObjectSet::iterator playerIt = knownPlayers->begin();
const uint32 objectDestroyLimit = 5000;
// update players
while(playerIt != knownPlayers->end())
{
PlayerObject* playerObject = (*playerIt);
// if its not in the current inrange queries result, destroy it
if(inRangeObjects->find(playerObject) == inRangeObjects->end())
{
// send a destroy to us
gMessageLib->sendDestroyObject(playerObject->getId(),player);
//If player is mounted destroy his mount too
if(playerObject->checkIfMounted() && playerObject->getMount())
{
gMessageLib->sendDestroyObject(playerObject->getMount()->getId(),player);
player->removeKnownObject(playerObject->getMount());
playerObject->getMount()->removeKnownObject(player);
}
//send a destroy to him
gMessageLib->sendDestroyObject(player->getId(),playerObject);
//If we're mounted destroy our mount too
if(player->checkIfMounted() && playerObject->getMount())
{
gMessageLib->sendDestroyObject(player->getMount()->getId(),playerObject);
playerObject->removeKnownObject(player->getMount());
player->getMount()->removeKnownObject(playerObject);
}
// we don't know each other anymore
knownPlayers->erase(playerIt++);
playerObject->removeKnownObject(player);
continue;
}
++playerIt;
}
// We may want to limit the amount of messages sent in one session.
uint32 messageCount = 0;
// update objects
while(objIt != knownObjects->end())
{
Object* object = (*objIt);
// if its not in the current inrange queries result, destroy it
if(inRangeObjects->find(object) == inRangeObjects->end())
{
if(object->getType() == ObjType_Structure)
{
if(FactoryObject* factory = dynamic_cast<FactoryObject*>(object))
{
//delete the hoppers contents
TangibleObject* hopper = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById(factory->getIngredientHopper()));
if(hopper)
{
ObjectIDList* ol = hopper->getObjects();
ObjectIDList::iterator it = ol->begin();
while(it != ol->end())
{
TangibleObject* tO = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById((*it)));
if(!tO)
{
assert(false && "ObjectController::_destroyOutOfRangeObjects WorldManager unable to find TangibleObject instance");
}
tO->removeKnownObject(player);
player->removeKnownObject(tO);
gMessageLib->sendDestroyObject(tO->getId(),player);
it++;
}
hopper->removeKnownObject(player);
player->removeKnownObject(hopper);
gMessageLib->sendDestroyObject(hopper->getId(),player);
}
//.........这里部分代码省略.........
示例13: handleDataTransform
void ObjectController::handleDataTransform(Message* message,bool inRangeUpdate)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if (!player)
{
gLogger->logMsgF("ObjectController::handleDataTransform Object is NOT A PLAYER, id = %"PRIu64"", MSG_HIGH, mObject->getId());
return;
}
glm::vec3 pos;
glm::quat dir;
uint32 inMoveCount;
uint32 tickCount;
float speed;
bool updateAll = false;
// get tick and move counters
tickCount = message->getUint32();
inMoveCount = message->getUint32();
// gLogger->logMsg("ObjectController::handleDataTransform");
//uint64 localTimeStart = Anh_Utils::Clock::getSingleton()->getLocalTime();
// only process if its in sequence
if(player->getInMoveCount() >= inMoveCount)
{
return;
}
//uint32 ticks = tickCount - player->getClientTickCount();
// update tick and move counters...
player->setLastMoveTick(tickCount);
player->setClientTickCount(tickCount);
player->setInMoveCount(inMoveCount);
if(player->checkIfMounted() && player->getMount())
{
//Player is mounted lets update his mount too
player->getMount()->setLastMoveTick(tickCount);
//player->getMount()->setInMoveCount((inMoveCount+1));
player->getMount()->setInMoveCount((inMoveCount)); // + 1 or nor does not matter, as long as we update inMoveCount.
}
// get new direction, position and speed
dir.x = message->getFloat();
dir.y = message->getFloat();
dir.z = message->getFloat();
dir.w = message->getFloat();
pos.x = message->getFloat();
pos.y = message->getFloat();
pos.z = message->getFloat();
speed = message->getFloat();
// gLogger->logMsgF("Position outside = %.2f, %.2f, %.2f",MSG_NORMAL, pos.x, pos.y, pos.z);
/*
if (Heightmap::isHeightmapCacheAvaliable())
{
gLogger->logMsgF("Heightmap value = %.2f",MSG_NORMAL, Heightmap::Instance()->getCachedHeightAt2DPosition(pos.x, pos.z));
}
*/
// gLogger->logMsgF("Direction = %f, %f, %f, %f",MSG_NORMAL, dir.x, dir.y, dir.z, dir.w);
// stop entertaining, if we were
// important is, that if we move we change our posture to NOT skill animating anymore!
// so only stop entertaining when we are performing and NOT skillanimationg
if(player->getPerformingState() != PlayerPerformance_None && player->getPosture() != CreaturePosture_SkillAnimating)
{
gEntertainerManager->stopEntertaining(player);
}
// if we just left a building
if(player->getParentId() != 0)
{
updateAll = true;
// Testing with 4 for add and 0 for remove.
// Remove us from previous cell.
gMessageLib->broadcastContainmentMessage(player->getId(),player->getParentId(),0,player);
// remove us from the last cell we were in
if(CellObject* cell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(player->getParentId())))
{
cell->removeObject(player);
}
else
{
gLogger->logMsgF("Error removing %"PRIu64" from cell(%"PRIu64")",MSG_HIGH,player->getId(),player->getParentId());
}
// we are outside again
player->setParentId(0);
player->mPosition = pos;
// Add us to the world.
gMessageLib->broadcastContainmentMessage(player->getId(),0,4,player);
//.........这里部分代码省略.........
示例14: handleDataTransformWithParent
void ObjectController::handleDataTransformWithParent(Message* message,bool inRangeUpdate)
{
// FIXME: for now assume we only get messages from players
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
glm::vec3 pos;
glm::quat dir;
uint32 inMoveCount;
uint32 tickCount;
uint64 parentId;
float speed;
bool updateAll = false;
// get tick and move counters
tickCount = message->getUint32();
inMoveCount = message->getUint32();
// only process if its in sequence
if (player->getInMoveCount() <= inMoveCount)
{
uint64 oldParentId = player->getParentId();
//uint32 ticks = tickCount - player->getClientTickCount();
// update tick and move counters
player->setClientTickCount(tickCount);
player->setInMoveCount(inMoveCount);
// get new direction, position, parent and speed
parentId = message->getUint64();
dir.x = message->getFloat();
dir.y = message->getFloat();
dir.z = message->getFloat();
dir.w = message->getFloat();
pos.x = message->getFloat();
pos.y = message->getFloat();
pos.z = message->getFloat();
speed = message->getFloat();
// gLogger->logMsgF("Position inside = %f, %f, %f",MSG_NORMAL, pos.x, pos.y, pos.z);
// gLogger->logMsgF("Direction = %f, %f, %f, %f",MSG_NORMAL, dir.x, dir.y, dir.z, dir.w);
// stop entertaining, if we were
if(player->getPerformingState() != PlayerPerformance_None && player->getPosture() != CreaturePosture_SkillAnimating)
{
gEntertainerManager->stopEntertaining(player);
}
// if we changed cell
if (oldParentId != parentId)
{
CellObject* cell = NULL;
// gLogger->logMsgF("We changed cell from (%"PRIu64") to (%"PRIu64")",MSG_NORMAL, oldParentId, parentId);
// Remove us from whatever we where in before.
// (4 for add and 0 for remove)
gMessageLib->broadcastContainmentMessage(player->getId(),oldParentId,0,player);
// only remove us from si, if we just entered the building
if (oldParentId != 0)
{
if((cell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(oldParentId))))
{
cell->removeObject(player);
// Done above.. gMessageLib->broadcastContainmentMessage(player->getId(),parentId,4,player);
}
else
{
gLogger->logMsgF("Error removing %"PRIu64" from cell(%"PRIu64")",MSG_NORMAL,player->getId(),oldParentId);
}
}
else
{
updateAll = true; // We just entered the building.
// remove us from qt
if(player->getSubZoneId())
{
if(QTRegion* region = gWorldManager->getQTRegion(player->getSubZoneId()))
{
player->setSubZoneId(0);
region->mTree->removeObject(player);
//If our player is mounted lets update his mount aswell
if(player->checkIfMounted() && player->getMount())
{
player->getMount()->setSubZoneId(0);
region->mTree->removeObject(player->getMount());
//Can't ride into a building with a mount! :-p
//However, its easy to do so we have handling incase the client is tricked.
// the vehicle is the INTANGIBLE Datapad Controller
// the *vehicle* itself is the BODY
if(Vehicle* datapad_pet = dynamic_cast<Vehicle*>(gWorldManager->getObjectById(player->getMount()->getPetController())))
{
//.........这里部分代码省略.........
示例15: 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;
}