本文整理汇总了C++中Pet::GetObjectGuid方法的典型用法代码示例。如果您正苦于以下问题:C++ Pet::GetObjectGuid方法的具体用法?C++ Pet::GetObjectGuid怎么用?C++ Pet::GetObjectGuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pet
的用法示例。
在下文中一共展示了Pet::GetObjectGuid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePetUnlearnOpcode
void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
{
DETAIL_LOG("CMSG_PET_UNLEARN");
ObjectGuid guid;
recvPacket >> guid; // Pet guid
Pet* pet = _player->GetPet();
if (!pet || guid != pet->GetObjectGuid())
{
sLog.outError("HandlePetUnlearnOpcode. %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetGuidStr().c_str());
return;
}
if (pet->getPetType() != HUNTER_PET || pet->m_spells.size() <= 1)
return;
CharmInfo* charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
sLog.outError("WorldSession::HandlePetUnlearnOpcode: %s is considered pet-like but doesn't have a charminfo!", pet->GetGuidStr().c_str());
return;
}
uint32 cost = pet->resetTalentsCost();
if (GetPlayer()->GetMoney() < cost)
{
GetPlayer()->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
return;
}
for (PetSpellMap::iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end();)
{
uint32 spell_id = itr->first; // Pet::removeSpell can invalidate iterator at erase NEW spell
++itr;
pet->unlearnSpell(spell_id, false);
}
pet->SetTP(pet->getLevel() * (pet->GetLoyaltyLevel() - 1));
for (int i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
if (UnitActionBarEntry const* ab = charmInfo->GetActionBarEntry(i))
if (ab->GetAction() && ab->IsActionBarForSpell())
charmInfo->SetActionBar(i, 0, ACT_DISABLED);
// relearn pet passives
pet->LearnPetPassives();
pet->m_resetTalentsTime = time(NULL);
pet->m_resetTalentsCost = cost;
GetPlayer()->ModifyMoney(-(int32)cost);
GetPlayer()->PetSpellInitialize();
}
示例2: HandleRequestPartyMemberStatsOpcode
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
{
DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
ObjectGuid guid;
recv_data >> guid;
Player * player = HashMapHolder<Player>::Find(guid);
if(!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << guid.WriteAsPacked();
data << uint32(GROUP_UPDATE_FLAG_STATUS);
data << uint16(MEMBER_STATUS_OFFLINE);
SendPacket(&data);
return;
}
Pet *pet = player->GetPet();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << player->GetPackGUID();
uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
if(pet)
mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
uint16 online_status = MEMBER_STATUS_ONLINE;
Powers powerType = player->getPowerType();
data << uint32(mask1); // group update mask
data << uint16(online_status); // member's online status
data << uint32(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint32(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
data << uint8(powerType); // GROUP_UPDATE_FLAG_POWER_TYPE
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
//verify player coordinates and zoneid to send to teammates
uint16 iZoneId = 0;
uint16 iCoordX = 0;
uint16 iCoordY = 0;
if (player->IsInWorld())
{
iZoneId = player->GetZoneId();
iCoordX = player->GetPositionX();
iCoordY = player->GetPositionY();
}
else if (player->IsBeingTeleported()) // Player is in teleportation
{
WorldLocation& loc = player->GetTeleportDest(); // So take teleportation destination
iZoneId = sTerrainMgr.GetZoneId(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
iCoordX = loc.coord_x;
iCoordY = loc.coord_y;
}
else
{
//unknown player status.
}
data << uint16(iZoneId); // GROUP_UPDATE_FLAG_ZONE
data << uint16(iCoordX); // GROUP_UPDATE_FLAG_POSITION
data << uint16(iCoordY); // GROUP_UPDATE_FLAG_POSITION
uint64 auramask = 0;
size_t maskPos = data.wpos();
data << uint64(auramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
MAPLOCK_READ(player,MAP_LOCK_TYPE_AURAS);
if(uint32 aura = player->GetVisibleAura(i))
{
auramask |= (uint64(1) << i);
data << uint32(aura);
data << uint8(1);
}
}
data.put<uint64>(maskPos, auramask); // GROUP_UPDATE_FLAG_AURAS
if(pet)
{
Powers petpowertype = pet->getPowerType();
data << pet->GetObjectGuid(); // GROUP_UPDATE_FLAG_PET_GUID
data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
data << uint16(pet->GetDisplayId()); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << uint32(pet->GetHealth()); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << uint32(pet->GetMaxHealth()); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << uint8(petpowertype); // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << uint16(pet->GetPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << uint16(pet->GetMaxPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_MAX_POWER
uint64 petauramask = 0;
size_t petMaskPos = data.wpos();
data << uint64(petauramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
//.........这里部分代码省略.........
示例3: BuildPartyMemberStatsChangedPacket
void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
{
uint32 mask = player->GetGroupUpdateFlag();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) // if update power type, update current/max power also
mask |= (GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER);
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) // same for pets
mask |= (GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER);
uint32 byteCount = 0;
for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
if (mask & (1 << i))
byteCount += GroupUpdateLength[i];
data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
*data << player->GetPackGUID();
*data << uint32(mask);
if (mask & GROUP_UPDATE_FLAG_STATUS)
{
if (player)
{
if (player->IsPvP())
*data << uint16(MEMBER_STATUS_ONLINE | MEMBER_STATUS_PVP);
else
*data << uint16(MEMBER_STATUS_ONLINE);
}
else
*data << uint16(MEMBER_STATUS_OFFLINE);
}
if (mask & GROUP_UPDATE_FLAG_CUR_HP)
*data << uint32(player->GetHealth());
if (mask & GROUP_UPDATE_FLAG_MAX_HP)
*data << uint32(player->GetMaxHealth());
Powers powerType = player->getPowerType();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
*data << uint8(powerType);
if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
*data << uint16(player->GetPower(powerType));
if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
*data << uint16(player->GetMaxPower(powerType));
if (mask & GROUP_UPDATE_FLAG_LEVEL)
*data << uint16(player->getLevel());
if (mask & GROUP_UPDATE_FLAG_ZONE)
*data << uint16(player->GetZoneId());
if (mask & GROUP_UPDATE_FLAG_POSITION)
*data << uint16(player->GetPositionX()) << uint16(player->GetPositionY());
if (mask & GROUP_UPDATE_FLAG_AURAS)
{
MAPLOCK_READ(player,MAP_LOCK_TYPE_AURAS);
const uint64& auramask = player->GetAuraUpdateMask();
*data << uint64(auramask);
for(uint32 i = 0; i < MAX_AURAS; ++i)
{
if(auramask & (uint64(1) << i))
{
*data << uint32(player->GetVisibleAura(i));
*data << uint8(1);
}
}
}
Pet *pet = player->GetPet();
if (mask & GROUP_UPDATE_FLAG_PET_GUID)
*data << (pet ? pet->GetObjectGuid() : ObjectGuid());
if (mask & GROUP_UPDATE_FLAG_PET_NAME)
{
if(pet)
*data << pet->GetName();
else
*data << uint8(0);
}
if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
{
if(pet)
*data << uint16(pet->GetDisplayId());
else
*data << uint16(0);
}
if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
{
if(pet)
*data << uint32(pet->GetHealth());
else
*data << uint32(0);
}
//.........这里部分代码省略.........
示例4: HandleRequestPartyMemberStatsOpcode
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
{
DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
ObjectGuid guid;
recv_data >> guid;
Player *player = sObjectMgr.GetPlayer(guid);
if(!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << guid.WriteAsPacked();
data << uint32(GROUP_UPDATE_FLAG_STATUS);
data << uint16(MEMBER_STATUS_OFFLINE);
SendPacket(&data);
return;
}
Pet *pet = player->GetPet();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << player->GetPackGUID();
uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
if(pet)
mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
Powers powerType = player->getPowerType();
data << uint32(mask1); // group update mask
data << uint16(MEMBER_STATUS_ONLINE); // member's online status
data << uint32(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint32(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
data << uint8(powerType); // GROUP_UPDATE_FLAG_POWER_TYPE
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
data << uint16(player->GetZoneId()); // GROUP_UPDATE_FLAG_ZONE
data << uint16(player->GetPositionX()); // GROUP_UPDATE_FLAG_POSITION
data << uint16(player->GetPositionY()); // GROUP_UPDATE_FLAG_POSITION
uint64 auramask = 0;
size_t maskPos = data.wpos();
data << uint64(auramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 aura = player->GetVisibleAura(i))
{
auramask |= (uint64(1) << i);
data << uint32(aura);
data << uint8(1);
}
}
data.put<uint64>(maskPos, auramask); // GROUP_UPDATE_FLAG_AURAS
if(pet)
{
Powers petpowertype = pet->getPowerType();
data << pet->GetObjectGuid(); // GROUP_UPDATE_FLAG_PET_GUID
data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
data << uint16(pet->GetDisplayId()); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << uint32(pet->GetHealth()); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << uint32(pet->GetMaxHealth()); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << uint8(petpowertype); // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << uint16(pet->GetPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << uint16(pet->GetMaxPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_MAX_POWER
uint64 petauramask = 0;
size_t petMaskPos = data.wpos();
data << uint64(petauramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 petaura = pet->GetVisibleAura(i))
{
petauramask |= (uint64(1) << i);
data << uint32(petaura);
data << uint8(1);
}
}
data.put<uint64>(petMaskPos, petauramask); // GROUP_UPDATE_FLAG_PET_AURAS
}
else
{
data << uint8(0); // GROUP_UPDATE_FLAG_PET_NAME
data << uint64(0); // GROUP_UPDATE_FLAG_PET_AURAS
}
SendPacket(&data);
}
示例5: BuildPartyMemberStatsChangedPacket
void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data)
{
uint32 mask = player->GetGroupUpdateFlag();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) // if update power type, update current/max power also
{ mask |= (GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER); }
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) // same for pets
{ mask |= (GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER); }
uint32 byteCount = 0;
for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
if (mask & (1 << i))
{ byteCount += GroupUpdateLength[i]; }
data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
*data << player->GetPackGUID();
*data << uint32(mask);
if (mask & GROUP_UPDATE_FLAG_STATUS)
{
if (player)
{
if (player->IsPvP())
{ *data << uint8(MEMBER_STATUS_ONLINE | MEMBER_STATUS_PVP); }
else
{ *data << uint8(MEMBER_STATUS_ONLINE); }
}
else
{ *data << uint8(MEMBER_STATUS_OFFLINE); }
}
if (mask & GROUP_UPDATE_FLAG_CUR_HP)
{ *data << uint16(player->GetHealth()); }
if (mask & GROUP_UPDATE_FLAG_MAX_HP)
{ *data << uint16(player->GetMaxHealth()); }
Powers powerType = player->getPowerType();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
{ *data << uint8(powerType); }
if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
{ *data << uint16(player->GetPower(powerType)); }
if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
{ *data << uint16(player->GetMaxPower(powerType)); }
if (mask & GROUP_UPDATE_FLAG_LEVEL)
{ *data << uint16(player->getLevel()); }
if (mask & GROUP_UPDATE_FLAG_ZONE)
{ *data << uint16(player->GetZoneId()); }
if (mask & GROUP_UPDATE_FLAG_POSITION)
{ *data << uint16(player->GetPositionX()) << uint16(player->GetPositionY()); }
if (mask & GROUP_UPDATE_FLAG_AURAS)
{
const uint64& auramask = player->GetAuraUpdateMask();
*data << uint32(auramask);
// In all checked pre-2.x data of packets included only positive auras
for (uint32 i = 0; i < MAX_POSITIVE_AURAS; ++i)
{
if (auramask & (uint64(1) << i))
{
*data << uint16(player->GetUInt32Value(UNIT_FIELD_AURA + i));
}
}
}
Pet* pet = player->GetPet();
if (mask & GROUP_UPDATE_FLAG_PET_GUID)
{ *data << (pet ? pet->GetObjectGuid() : ObjectGuid()); }
if (mask & GROUP_UPDATE_FLAG_PET_NAME)
{
if (pet)
{ *data << pet->GetName(); }
else
{ *data << uint8(0); }
}
if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
{
if (pet)
{ *data << uint16(pet->GetDisplayId()); }
else
{ *data << uint16(0); }
}
if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
{
if (pet)
{ *data << uint16(pet->GetHealth()); }
else
{ *data << uint16(0); }
}
if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP)
//.........这里部分代码省略.........
示例6: BuildPartyMemberStatsChangedPacket
void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data)
{
uint32 mask = player->GetGroupUpdateFlag();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) // if update power type, update current/max power also
mask |= (GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER);
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) // same for pets
mask |= (GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER);
uint32 byteCount = 0;
for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
if (mask & (1 << i))
byteCount += GroupUpdateLength[i];
data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
*data << player->GetPackGUID();
*data << uint32(mask);
if (mask & GROUP_UPDATE_FLAG_STATUS)
{
if (player->IsPvP())
*data << uint16(MEMBER_STATUS_ONLINE | MEMBER_STATUS_PVP);
else
*data << uint16(MEMBER_STATUS_ONLINE);
}
if (mask & GROUP_UPDATE_FLAG_CUR_HP)
*data << uint32(player->GetHealth());
if (mask & GROUP_UPDATE_FLAG_MAX_HP)
*data << uint32(player->GetMaxHealth());
Powers powerType = player->getPowerType();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
*data << uint8(powerType);
if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
*data << uint16(player->GetPower(powerType));
if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
*data << uint16(player->GetMaxPower(powerType));
if (mask & GROUP_UPDATE_FLAG_LEVEL)
*data << uint16(player->getLevel());
if (mask & GROUP_UPDATE_FLAG_ZONE)
*data << uint16(player->GetZoneId());
if (mask & GROUP_UPDATE_FLAG_UNK)
*data << uint16(0);
if (mask & GROUP_UPDATE_FLAG_POSITION)
*data << uint16(player->GetPositionX()) << uint16(player->GetPositionY()) << uint16(player->GetPositionZ());
if (mask & GROUP_UPDATE_FLAG_AURAS)
{
*data << uint8(0); // if true, client clears all auras that are not in auramask and whose index is lower amount sent below
const uint64& auramask = player->GetAuraUpdateMask();
*data << uint64(auramask);
*data << uint32(MAX_AURAS); // server sends here number of visible auras, but client checks
// if aura is in auramask, so it seems no difference if there will be MAX_AURAS
for (uint32 i = 0; i < MAX_AURAS; ++i)
{
if (auramask & (uint64(1) << i))
{
if (SpellAuraHolder* holder = player->GetVisibleAura(i))
{
*data << uint32(holder->GetId());
*data << uint16(holder->GetAuraFlags());
if (holder->GetAuraFlags() & AFLAG_EFFECT_AMOUNT_SEND)
for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i)
if (Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i)))
*data << int32(aura->GetModifier()->m_amount);
else
*data << int32(0);
}
else
{
*data << uint32(0);
*data << uint16(0);
}
}
}
}
Pet* pet = player->GetPet();
if (mask & GROUP_UPDATE_FLAG_PET_GUID)
*data << (pet ? pet->GetObjectGuid() : ObjectGuid());
if (mask & GROUP_UPDATE_FLAG_PET_NAME)
{
if (pet)
*data << pet->GetName();
else
*data << uint8(0);
}
if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
{
//.........这里部分代码省略.........
示例7: HandleRequestPartyMemberStatsOpcode
//.........这里部分代码省略.........
playerStatus |= MEMBER_STATUS_DEAD;
}
if (player->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
playerStatus |= MEMBER_STATUS_PVP_FFA;
if (player->isAFK())
playerStatus |= MEMBER_STATUS_AFK;
if (player->isDND())
playerStatus |= MEMBER_STATUS_DND;
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 255);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << player->GetPackGUID();
data << uint32(updateFlags);
data << uint16(playerStatus); // GROUP_UPDATE_FLAG_STATUS
data << uint32(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint32(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
if (updateFlags & GROUP_UPDATE_FLAG_POWER_TYPE)
data << uint8(powerType);
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
// verify player coordinates and zoneid to send to teammates
uint16 iZoneId = 0;
uint16 iCoordX = 0;
uint16 iCoordY = 0;
if (player->IsInWorld())
{
iZoneId = player->GetZoneId();
iCoordX = player->GetPositionX();
iCoordY = player->GetPositionY();
}
else if (player->IsBeingTeleported()) // Player is in teleportation
{
WorldLocation& loc = player->GetTeleportDest(); // So take teleportation destination
iZoneId = sTerrainMgr.GetZoneId(loc.GetMapId(), loc.x, loc.y, loc.z);
iCoordX = loc.x;
iCoordY = loc.y;
}
data << uint16(iZoneId); // GROUP_UPDATE_FLAG_ZONE
data << uint16(iCoordX); // GROUP_UPDATE_FLAG_POSITION
data << uint16(iCoordY); // GROUP_UPDATE_FLAG_POSITION
uint64 auramask = 0;
size_t maskPos = data.wpos();
data << uint64(auramask); // placeholder
for (uint8 i = 0; i < MAX_AURAS; ++i)
{
if (SpellAuraHolderPtr holder = player->GetVisibleAura(i))
{
auramask |= (uint64(1) << i);
data << uint32(holder->GetId());
data << uint8(holder->GetAuraFlags());
}
}
data.put<uint64>(maskPos, auramask); // GROUP_UPDATE_FLAG_AURAS
if(pet)
{
Powers petPowerType = pet->getPowerType();
data << pet->GetObjectGuid(); // GROUP_UPDATE_FLAG_PET_GUID
data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
data << uint16(pet->GetDisplayId()); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << uint32(pet->GetHealth()); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << uint32(pet->GetMaxHealth()); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << uint8(petPowerType); // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << uint16(pet->GetPower(petPowerType)); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << uint16(pet->GetMaxPower(petPowerType)); // GROUP_UPDATE_FLAG_PET_MAX_POWER
uint64 petAuraMask = 0;
size_t petMaskPos = data.wpos();
data << uint64(petAuraMask); // placeholder
for (uint8 i = 0; i < MAX_AURAS; ++i)
{
if (SpellAuraHolderPtr holder = pet->GetVisibleAura(i))
{
petAuraMask |= (uint64(1) << i);
data << uint32(holder->GetId());
data << uint8(holder->GetAuraFlags());
}
}
data.put<uint64>(petMaskPos, petAuraMask); // GROUP_UPDATE_FLAG_PET_AURAS
}
else
{
data << uint8(0); // GROUP_UPDATE_FLAG_PET_NAME
data << uint16(0); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << uint64(0); // GROUP_UPDATE_FLAG_PET_AURAS
}
if (updateFlags & GROUP_UPDATE_FLAG_VEHICLE_SEAT)
data << uint32(player->m_movementInfo.GetTransportDBCSeat());
SendPacket(&data);
}
示例8: BuildPartyMemberStatsChangedPacket
void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data)
{
uint32 mask = player->GetGroupUpdateFlag();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) // if update power type, update current/max power also
mask |= (GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER);
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) // same for pets
mask |= (GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER);
uint32 byteCount = 0;
for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
{
if (mask & (1 << i))
byteCount += GroupUpdateLength[i];
}
data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
*data << player->GetPackGUID();
*data << uint32(mask);
if (mask & GROUP_UPDATE_FLAG_STATUS)
{
uint16 playerStatus = MEMBER_STATUS_ONLINE;
if (player->IsPvP())
playerStatus |= MEMBER_STATUS_PVP;
if (!player->isAlive())
{
if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
playerStatus |= MEMBER_STATUS_GHOST;
else
playerStatus |= MEMBER_STATUS_DEAD;
}
if (player->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
playerStatus |= MEMBER_STATUS_PVP_FFA;
if (player->isAFK())
playerStatus |= MEMBER_STATUS_AFK;
if (player->isDND())
playerStatus |= MEMBER_STATUS_DND;
*data << uint16(playerStatus);
}
if (mask & GROUP_UPDATE_FLAG_CUR_HP)
*data << uint32(player->GetHealth());
if (mask & GROUP_UPDATE_FLAG_MAX_HP)
*data << uint32(player->GetMaxHealth());
Powers powerType = player->getPowerType();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
*data << uint8(powerType);
if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
*data << uint16(player->GetPower(powerType));
if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
*data << uint16(player->GetMaxPower(powerType));
if (mask & GROUP_UPDATE_FLAG_LEVEL)
*data << uint16(player->getLevel());
if (mask & GROUP_UPDATE_FLAG_ZONE)
*data << uint16(player->GetZoneId());
if (mask & GROUP_UPDATE_FLAG_POSITION)
*data << uint16(player->GetPositionX()) << uint16(player->GetPositionY());
if (mask & GROUP_UPDATE_FLAG_AURAS)
{
const uint64& auraMask = player->GetAuraUpdateMask();
*data << uint64(auraMask);
for (uint32 i = 0; i < MAX_AURAS; ++i)
{
if (auraMask & (uint64(1) << i))
{
SpellAuraHolderPtr holder = player->GetVisibleAura(i);
*data << uint32(holder ? holder->GetId() : 0);
*data << uint8(holder ? holder->GetAuraFlags() : 0);
}
}
}
Pet* pet = player->GetPet();
if (mask & GROUP_UPDATE_FLAG_PET_GUID)
*data << (pet ? pet->GetObjectGuid() : ObjectGuid());
if (mask & GROUP_UPDATE_FLAG_PET_NAME)
*data << (pet ? pet->GetName() : uint8(0));
if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
*data << uint16(pet ? pet->GetDisplayId() : 0);
//.........这里部分代码省略.........
示例9: BuildPartyMemberStatsChangedPacket
void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket& data)
{
uint32 mask = player->GetGroupUpdateFlag();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) // if update power type, update current/max power also
mask |= (GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER);
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) // same for pets
mask |= (GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER);
uint32 byteCount = 0;
for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
if (mask & (1 << i))
byteCount += GroupUpdateLength[i];
data.Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
data << player->GetPackGUID();
data << uint32(mask);
if (mask & GROUP_UPDATE_FLAG_STATUS)
data << uint16(GetGroupMemberStatus(player));
if (mask & GROUP_UPDATE_FLAG_CUR_HP)
data << uint32(player->GetHealth());
if (mask & GROUP_UPDATE_FLAG_MAX_HP)
data << uint32(player->GetMaxHealth());
Powers powerType = player->GetPowerType();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
data << uint8(powerType);
if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
data << uint16(player->GetPower(powerType));
if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
data << uint16(player->GetMaxPower(powerType));
if (mask & GROUP_UPDATE_FLAG_LEVEL)
data << uint16(player->getLevel());
if (mask & GROUP_UPDATE_FLAG_ZONE)
data << uint16(player->GetZoneId());
if (mask & GROUP_UPDATE_FLAG_POSITION)
data << uint16(player->GetPositionX()) << uint16(player->GetPositionY());
if (mask & GROUP_UPDATE_FLAG_AURAS)
{
const uint64& auramask = player->GetAuraUpdateMask();
data << uint64(auramask);
for (uint32 i = 0; i < MAX_AURAS; ++i)
{
if (auramask & (uint64(1) << i))
{
data << uint32(player->GetVisibleAura(i));
data << uint8(1);
}
}
}
Pet* pet = player->GetPet();
if (mask & GROUP_UPDATE_FLAG_PET_GUID)
data << (pet ? pet->GetObjectGuid() : ObjectGuid());
if (mask & GROUP_UPDATE_FLAG_PET_NAME)
{
if (pet)
data << pet->GetName();
else
data << uint8(0);
}
if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
{
if (pet)
data << uint16(pet->GetDisplayId());
else
data << uint16(0);
}
if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
{
if (pet)
data << uint32(pet->GetHealth());
else
data << uint32(0);
}
if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP)
{
if (pet)
data << uint32(pet->GetMaxHealth());
else
data << uint32(0);
}
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE)
{
if (pet)
//.........这里部分代码省略.........