本文整理汇总了C++中Group::GetFirstMember方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::GetFirstMember方法的具体用法?C++ Group::GetFirstMember怎么用?C++ Group::GetFirstMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::GetFirstMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleBattlemasterJoinOpcode
void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
{
uint64 guid;
uint32 bgTypeId_;
uint32 instanceId;
uint8 joinAsGroup;
bool isPremade = false;
Group * grp;
recv_data >> guid; // battlemaster guid
recv_data >> bgTypeId_; // battleground type id (DBC id)
recv_data >> instanceId; // instance id, 0 if First Available selected
recv_data >> joinAsGroup; // join as group
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
sLog.outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u",bgTypeId_,_player->GetGUIDLow());
return;
}
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid)));
// can do this, since it's battleground, not arena
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, 0);
// ignore if player is already in BG
if (_player->InBattleGround())
return;
// get bg instance or bg template if instance not found
BattleGround *bg = NULL;
if (instanceId)
bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId);
if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
{
sLog.outError("Battleground: no available bg / template found");
return;
}
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel());
if (!bracketEntry)
return;
// check queueing conditions
if (!joinAsGroup)
{
// check Deserter debuff
if (!_player->CanJoinToBattleground())
{
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << uint32(0xFFFFFFFE);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattleGroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
uint32 err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
if (err != BG_JOIN_ERR_OK)
{
SendBattleGroundOrArenaJoinError(err);
return;
}
}
// if we're here, then the conditions to join a bg are met. We can proceed in joining.
// _player->GetGroup() was already checked, grp is already initialized
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
if (joinAsGroup /* && _player->GetGroup()*/)
{
sLog.outDebug("Battleground: the following players are joining as group:");
GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *member = itr->getSource();
if(!member) continue; // this should never happen
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId); // add to queue
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
member->GetSession()->SendPacket(&data);
//.........这里部分代码省略.........
示例2: HandlePushQuestToParty
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
{
uint32 questId;
recvPacket >> questId;
if (!_player->CanShareQuest(questId))
return;
TC_LOG_DEBUG("network", "WORLD: Received CMSG_PUSHQUESTTOPARTY questId = %u", questId);
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
if (!quest)
return;
Player * const sender = GetPlayer();
Group* group = sender->GetGroup();
if (!group)
return;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* receiver = itr->GetSource();
if (!receiver || receiver == sender)
continue;
if (!receiver->SatisfyQuestStatus(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_HAVE_QUEST);
continue;
}
if (receiver->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE)
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_FINISH_QUEST);
continue;
}
if (!receiver->CanTakeQuest(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_CANT_TAKE_QUEST);
continue;
}
if (!receiver->SatisfyQuestLog(false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_LOG_FULL);
continue;
}
if (receiver->GetDivider() != 0)
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_BUSY);
continue;
}
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_SHARING_QUEST);
if (quest->IsAutoAccept() && receiver->CanAddQuest(quest, true) && receiver->CanTakeQuest(quest, true))
{
receiver->AddQuest(quest, sender);
if (receiver->CanCompleteQuest(questId))
receiver->CompleteQuest(questId);
}
if ((quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly()) || quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true);
else
{
receiver->SetDivider(sender->GetGUID());
receiver->PlayerTalkClass->SendQuestGiverQuestDetails(quest, sender->GetGUID(), true);
}
}
}
示例3: HandleLootMoneyOpcode
void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
{
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: CMSG_LOOT_MONEY");
Player* player = GetPlayer();
uint64 guid = player->GetLootGUID();
if (!guid)
return;
Loot* loot = NULL;
bool shareMoney = true;
switch (GUID_HIPART(guid))
{
case HIGHGUID_GAMEOBJECT:
{
GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid);
// do not check distance for GO if player is the owner of it (ex. fishing bobber)
if (go && ((go->GetOwnerGUID() == player->GetGUID() || go->IsWithinDistInMap(player, INTERACTION_DISTANCE))))
loot = &go->loot;
break;
}
case HIGHGUID_CORPSE: // remove insignia ONLY in BG
{
Corpse* bones = ObjectAccessor::GetCorpse(*player, guid);
if (bones && bones->IsWithinDistInMap(player, INTERACTION_DISTANCE))
{
loot = &bones->loot;
shareMoney = false;
}
break;
}
case HIGHGUID_ITEM:
{
if (Item* item = player->GetItemByGuid(guid))
{
loot = &item->loot;
shareMoney = false;
}
break;
}
case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
{
Creature* creature = player->GetMap()->GetCreature(guid);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->lootForPickPocketed);
if (lootAllowed && creature->IsWithinDistInMap(player, INTERACTION_DISTANCE))
{
loot = &creature->loot;
if (creature->IsAlive())
shareMoney = false;
}
break;
}
default:
return; // unlootable type
}
if (loot)
{
loot->NotifyMoneyRemoved();
if (shareMoney && player->GetGroup()) //item, pickpocket and players can be looted only single player
{
Group* group = player->GetGroup();
std::vector<Player*> playersNear;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue;
if (player->IsWithinDistInMap(member, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
playersNear.push_back(member);
}
uint32 goldPerPlayer = uint32((loot->gold) / (playersNear.size()));
for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
{
(*i)->ModifyMoney(goldPerPlayer);
(*i)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, goldPerPlayer);
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1);
data << uint32(goldPerPlayer);
data << uint8(playersNear.size() <= 1); // Controls the text displayed in chat. 0 is "Your share is..." and 1 is "You loot..."
(*i)->GetSession()->SendPacket(&data);
}
}
else
{
player->ModifyMoney(loot->gold);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, loot->gold);
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1);
data << uint32(loot->gold);
//.........这里部分代码省略.........
示例4: HandleBattlemasterJoinArena
void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
{
DEBUG_LOG("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
//recv_data.hexlike();
ObjectGuid guid; // arena Battlemaster guid
uint8 arenaslot; // 2v2, 3v3 or 5v5
uint8 asGroup; // asGroup
uint8 isRated; // isRated
Group * grp;
recv_data >> guid >> arenaslot >> asGroup >> isRated;
// ignore if we already in BG or BG queue
if (_player->InBattleGround())
return;
Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
if(!unit->isBattleMaster()) // it's not battle master
return;
uint8 arenatype = 0;
uint32 arenaRating = 0;
switch(arenaslot)
{
case 0:
arenatype = ARENA_TYPE_2v2;
break;
case 1:
arenatype = ARENA_TYPE_3v3;
break;
case 2:
arenatype = ARENA_TYPE_5v5;
break;
default:
sLog.outError("Unknown arena slot %u at HandleBattlemasterJoinArena()", arenaslot);
return;
}
// check existence
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
sLog.outError("Battleground: template bg (all arenas) not found");
return;
}
BattleGroundTypeId bgTypeId = bg->GetTypeID();
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel());
if (!bracketEntry)
return;
GroupJoinBattlegroundResult err;
// check queue conditions
if (!asGroup)
{
// check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattleGroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return;
// may be Group::CanJoinBattleGroundQueue should be moved to player class...
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
}
uint32 ateamId = 0;
if (isRated)
{
ateamId = _player->GetArenaTeamId(arenaslot);
// check real arena team existence only here (if it was moved to group->CanJoin .. () then we would have to get it twice)
ArenaTeam * at = sObjectMgr.GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queue
arenaRating = at->GetRating();
// the arena team id must match for everyone in the group
// get the personal ratings for queue
uint32 avg_pers_rating = 0;
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
//.........这里部分代码省略.........
示例5: HandleMessagechatOpcode
//.........这里部分代码省略.........
GetPlayer()->m_speakCount = 0;
}
else
GetPlayer()->Whisper(msg, lang, player->GetObjectGuid());
} break;
case CHAT_MSG_PARTY:
{
std::string msg;
recv_data >> msg;
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
break;
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if (msg.empty())
break;
// if player is in battleground, he cannot say to battleground members by /p
Group* group = GetPlayer()->GetOriginalGroup();
if (!group)
{
group = _player->GetGroup();
if (!group || group->isBGGroup())
return;
}
// Playerbot mod: broadcast message to bot members
for(GroupReference* itr = group->GetFirstMember(); itr != NULL; itr=itr->next())
{
Player* player = itr->getSource();
if (player && player->GetPlayerbotAI())
{
player->GetPlayerbotAI()->HandleCommand(msg, *GetPlayer());
GetPlayer()->m_speakTime = 0;
GetPlayer()->m_speakCount = 0;
}
}
// END Playerbot mod
WorldPacket data;
ChatHandler::FillMessageData(&data, this, type, lang, msg.c_str());
group->BroadcastPacket(&data, false, group->GetMemberGroup(GetPlayer()->GetObjectGuid()));
break;
}
case CHAT_MSG_GUILD:
{
std::string msg;
recv_data >> msg;
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
break;
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if (msg.empty())
示例6: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
if (!bg)
return;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
GroupJoinBattlegroundResult err;
// check queue conditions
if (!joinAsGroup)
{
// check Deserter debuff
if (!_player->CanJoinToBattleground())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
return;
// check if has free queue slots
if (!_player->HasFreeBattlegroundQueueId())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
_player->GetSession()->SendPacket(&data);
return;
}
BattlegroundQueue& bgQueue = sBattlegroundMgr->m_BattlegroundQueues[bgQueueTypeId];
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, isPremade);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
// already checked if queueSlot is valid, now just get it
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
WorldPacket data;
// send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0);
SendPacket(&data);
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName());
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam());
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
BattlegroundQueue& bgQueue = sBattlegroundMgr->m_BattlegroundQueues[bgQueueTypeId];
GroupQueueInfo* ginfo = NULL;
uint32 avgTime = 0;
if (err > 0)
{
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: the following players are joining as group:");
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, isPremade);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue; // this should never happen
WorldPacket data;
if (err <= 0)
{
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
continue;
}
// add to queue
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
// send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0);
member->GetSession()->SendPacket(&data);
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName());
}
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: group end");
}
sBattlegroundMgr->ScheduleQueueUpdate(bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例7: HandleLootMoneyOpcode
void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("WORLD: CMSG_LOOT_MONEY");
Player* player = GetPlayer();
ObjectGuid guid = player->GetLootGuid();
if (!guid)
return;
Loot* pLoot = NULL;
Item* pItem = NULL;
switch (guid.GetHigh())
{
case HIGHGUID_GAMEOBJECT:
{
GameObject* pGameObject = GetPlayer()->GetMap()->GetGameObject(guid);
// not check distance for GO in case owned GO (fishing bobber case, for example)
if (pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player, INTERACTION_DISTANCE)))
pLoot = &pGameObject->loot;
break;
}
case HIGHGUID_CORPSE: // remove insignia ONLY in BG
{
Corpse* bones = _player->GetMap()->GetCorpse(guid);
if (bones && bones->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
pLoot = &bones->loot;
break;
}
case HIGHGUID_ITEM:
{
pItem = GetPlayer()->GetItemByGuid(guid);
if (!pItem || !pItem->HasGeneratedLoot())
return;
pLoot = &pItem->loot;
break;
}
case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
{
Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid);
bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass() == CLASS_ROGUE && pCreature->lootForPickPocketed);
if (ok_loot && pCreature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
pLoot = &pCreature->loot ;
break;
}
default:
return; // unlootable type
}
if (pLoot)
{
pLoot->NotifyMoneyRemoved();
if (!guid.IsItem() && player->GetGroup()) // item can be looted only single player
{
Group* group = player->GetGroup();
std::vector<Player*> playersNear;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* playerGroup = itr->getSource();
if (!playerGroup)
continue;
if (player->IsWithinDistInMap(playerGroup, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
playersNear.push_back(playerGroup);
}
if (playersNear.size() == 0)
{
sLog.outError("WorldSession::HandleLootMoneyOpcode %s try aquire group loot without any group member! Cheat attempt assumed.", player->GetObjectGuid().GetString().c_str());
return;
}
uint64 money_per_player = uint32((pLoot->gold) / (playersNear.size()));
for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
{
(*i)->ModifyMoney(money_per_player);
(*i)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, money_per_player);
if (Guild* guild = sGuildMgr.GetGuildById((*i)->GetGuildId()))
if (uint32 guildGold = (*i)->GetTotalAuraModifier(SPELL_AURA_MOD_MONEY_TO_GUILD_BANK) / 100.0f * money_per_player)
guild->HandleCashFlow(guildGold, *i);
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1);
data << uint32(money_per_player);
data << uint8(playersNear.size() > 1 ? 0 : 1);// 0 is "you share of loot..."
(*i)->GetSession()->SendPacket(&data);
}
}
else
//.........这里部分代码省略.........
示例8: HandleGroupSummonCommand
//Summon group of player
bool ChatHandler::HandleGroupSummonCommand(const char* args)
{
Player* target;
if (!extractPlayerTarget((char*)args, &target))
return false;
// check online security
if (HasLowerSecurity(target, 0))
return false;
Group *grp = target->GetGroup();
std::string nameLink = GetNameLink(target);
if (!grp)
{
PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
SetSentErrorMessage(true);
return false;
}
Map* gmMap = m_session->GetPlayer()->GetMap();
bool to_instance = gmMap->Instanceable();
// we are in instance, and can summon only player in our group with us as lead
if (to_instance && (
!m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
(m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID())))
// the last check is a bit excessive, but let it be, just in case
{
SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
SetSentErrorMessage(true);
return false;
}
for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *pl = itr->getSource();
if (!pl || pl == m_session->GetPlayer() || !pl->GetSession())
continue;
// check online security
if (HasLowerSecurity(pl, 0))
return false;
std::string plNameLink = GetNameLink(pl);
if (pl->IsBeingTeleported() == true)
{
PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
SetSentErrorMessage(true);
return false;
}
if (to_instance)
{
Map* plMap = pl->GetMap();
if (plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId())
{
// cannot summon from instance to instance
PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str());
SetSentErrorMessage(true);
return false;
}
}
PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), "");
if (needReportToTarget(pl))
ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, GetNameLink().c_str());
// stop flight if need
if (pl->isInFlight())
{
pl->GetMotionMaster()->MovementExpired();
pl->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
pl->SaveRecallPosition();
if (pl->IsMounted())
{
pl->Unmount();
pl->RemoveAurasByType(SPELL_AURA_MOUNTED);
}
// before GM
float x, y, z;
m_session->GetPlayer()->GetClosePoint(x, y, z, pl->GetObjectSize());
pl->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, pl->GetOrientation());
}
return true;
}
示例9: FocusMagic
void FocusMagic(uint32 diff)
{
if (!FOCUSMAGIC || me->getLevel() < 20 || fmCheckTimer > diff || GC_Timer > diff || Rand() < 50 || IsCasting())
return;
if (Unit* target = FindAffectedTarget(FOCUSMAGIC, me->GetGUID(), 70, 2))
{
fmCheckTimer = 30000;
return;
}
else
{
Group* pGroup = master->GetGroup();
if (!pGroup)
{
if (master->getPowerType() == POWER_MANA && !master->HasAura(FOCUSMAGIC) && me->GetExactDist(master) < 30)
target = master;
}
else
{
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pPlayer = itr->GetSource();
if (!pPlayer || pPlayer->isDead()) continue;
if (me->GetMapId() != pPlayer->GetMapId()) continue;
if ((pPlayer->getClass() == CLASS_MAGE ||
pPlayer->getClass() == CLASS_PRIEST ||
pPlayer->getClass() == CLASS_SHAMAN ||
pPlayer->getClass() == CLASS_DRUID ||
pPlayer->getClass() == CLASS_PALADIN ||
pPlayer->getClass() == CLASS_WARLOCK) &&
!pPlayer->HasAura(FOCUSMAGIC) && me->GetExactDist(pPlayer) < 30)
{
target = pPlayer;
break;
}
}
if (!target)
{
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pPlayer = itr->GetSource();
if (!pPlayer || !pPlayer->HaveBot()) continue;
if (me->GetMapId() != pPlayer->GetMapId()) continue;
for (uint8 i = 0; i != pPlayer->GetMaxNpcBots(); ++i)
{
Creature* cre = pPlayer->GetBotMap(i)->_Cre();
if (!cre || cre == me || cre->isDead() || cre->getPowerType() != POWER_MANA) continue;
if ((cre->GetBotClass() == CLASS_MAGE ||
cre->GetBotClass() == CLASS_PRIEST ||
cre->GetBotClass() == CLASS_SHAMAN ||
cre->GetBotClass() == CLASS_DRUID ||
cre->GetBotClass() == CLASS_WARLOCK) &&
!cre->HasAura(FOCUSMAGIC) && me->GetExactDist(cre) < 30)
{
target = cre;
break;
}
}
}
}
}
if (target && doCast(target, FOCUSMAGIC))
{
GC_Timer = 500;
fmCheckTimer = 30000;
return;
}
}
fmCheckTimer = 5000;
}
示例10: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
// player is already in random queue
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_IN_RANDOM_BG);
SendPacket(battlefieldStatus.Write());
return;
}
if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB)
{
// player is already in queue, can't start random queue
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_IN_NON_RANDOM_BG);
SendPacket(battlefieldStatus.Write());
return;
}
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
// player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattlegroundQueueId())
{
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
SendPacket(battlefieldStatus.Write());
return;
}
// check Freeze debuff
if (_player->HasAura(9454))
return;
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
WorldPackets::Battleground::BattlefieldStatusQueued battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, _player, queueSlot, ginfo->JoinTime, avgTime, ginfo->ArenaType, false);
SendPacket(battlefieldStatus.Write());
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s",
bgQueueTypeId, bgTypeId, _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
}
else
{
grp = _player->GetGroup();
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
ObjectGuid errorGuid;
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0, errorGuid);
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = NULL;
uint32 avgTime = 0;
if (!err)
{
TC_LOG_DEBUG("bg.battleground", "Battleground: the following players are joining as group:");
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue; // this should never happen
if (err)
{
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, err, &errorGuid);
member->SendDirectMessage(battlefieldStatus.Write());
continue;
}
// add to queue
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
WorldPackets::Battleground::BattlefieldStatusQueued battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, member, queueSlot, ginfo->JoinTime, avgTime, ginfo->ArenaType, true);
member->SendDirectMessage(battlefieldStatus.Write());
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s",
bgQueueTypeId, bgTypeId, member->GetGUID().ToString().c_str(), member->GetName().c_str());
}
TC_LOG_DEBUG("bg.battleground", "Battleground: group end");
}
sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例11: HandleBattlemasterJoinArena
void WorldSession::HandleBattlemasterJoinArena(WorldPackets::Battleground::BattlemasterJoinArena& packet)
{
// ignore if we already in BG or BG queue
if (_player->InBattleground())
return;
uint8 arenatype = ArenaTeam::GetTypeBySlot(packet.TeamSizeIndex);
//check existence
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
TC_LOG_ERROR("network", "Battleground: template bg (all arenas) not found");
return;
}
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, nullptr))
{
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
return;
}
BattlegroundTypeId bgTypeId = bg->GetTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvpDifficultyEntry const* bracketEntry = DB2Manager::GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
Group* grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
uint32 ateamId = _player->GetArenaTeamId(packet.TeamSizeIndex);
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queuing
uint32 arenaRating = at->GetRating();
uint32 matchmakerRating = at->GetAverageMMR(grp);
// the arenateam id must match for everyone in the group
if (arenaRating <= 0)
arenaRating = 1;
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
uint32 avgTime = 0;
GroupQueueInfo* ginfo = nullptr;
ObjectGuid errorGuid;
GroupJoinBattlegroundResult err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, arenatype, arenatype, true, packet.TeamSizeIndex, errorGuid);
if (!err)
{
TC_LOG_DEBUG("bg.battleground", "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(packet.TeamSizeIndex), _player->GetName().c_str(), matchmakerRating, arenatype);
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, true, false, arenaRating, matchmakerRating, ateamId);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue;
if (err)
{
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, arenatype, err, &errorGuid);
member->SendDirectMessage(battlefieldStatus.Write());
continue;
}
// add to queue
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
WorldPackets::Battleground::BattlefieldStatusQueued battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, member, queueSlot, ginfo->JoinTime, avgTime, arenatype, true);
member->SendDirectMessage(battlefieldStatus.Write());
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for arena as group bg queue type %u bg type %u, %s, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUID().ToString().c_str(), member->GetName().c_str());
}
sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例12: HandleLootMoneyOpcode
void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/)
{
sLog.outDebug("WORLD: CMSG_LOOT_MONEY");
Player *player = GetPlayer();
uint64 guid = player->GetLootGUID();
if (!guid)
return;
Loot *pLoot = NULL;
switch(GUID_HIPART(guid))
{
case HIGHGUID_GAMEOBJECT:
{
GameObject *pGameObject = GetPlayer()->GetMap()->GetGameObject(guid);
// not check distance for GO in case owned GO (fishing bobber case, for example)
if (pGameObject && ((pGameObject->GetOwnerGUID() == _player->GetGUID() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE))))
pLoot = &pGameObject->loot;
break;
}
case HIGHGUID_CORPSE: // remove insignia ONLY in BG
{
Corpse *bones = ObjectAccessor::GetCorpse(*GetPlayer(), guid);
if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
pLoot = &bones->loot;
break;
}
case HIGHGUID_ITEM:
{
if (Item *item = GetPlayer()->GetItemByGuid(guid))
pLoot = &item->loot;
break;
}
case HIGHGUID_UNIT:
{
Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid);
bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass() == CLASS_ROGUE && pCreature->lootForPickPocketed);
if (ok_loot && pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
pLoot = &pCreature->loot ;
break;
}
default:
return; // unlootable type
}
if (pLoot)
{
if (!IS_ITEM_GUID(guid) && player->GetGroup()) //item can be looted only single player
{
Group *group = player->GetGroup();
std::vector<Player*> playersNear;
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* playerGroup = itr->getSource();
if (!playerGroup)
continue;
if (player->IsWithinDistInMap(playerGroup,sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE),false))
playersNear.push_back(playerGroup);
}
uint32 money_per_player = uint32((pLoot->gold)/(playersNear.size()));
for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
{
(*i)->ModifyMoney(money_per_player);
(*i)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, money_per_player);
//Offset surely incorrect, but works
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4);
data << uint32(money_per_player);
(*i)->GetSession()->SendPacket(&data);
}
}
else
{
player->ModifyMoney(pLoot->gold);
player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, pLoot->gold);
}
pLoot->gold = 0;
pLoot->NotifyMoneyRemoved();
}
}
示例13: HandlePushQuestToParty
void WorldSession::HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& packet)
{
if (!_player->CanShareQuest(packet.QuestID))
return;
Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID);
if (!quest)
return;
Player * const sender = GetPlayer();
Group* group = sender->GetGroup();
if (!group)
return;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* receiver = itr->GetSource();
if (!receiver || receiver == sender)
continue;
if (!receiver->SatisfyQuestStatus(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_ONQUEST);
continue;
}
if (receiver->GetQuestStatus(packet.QuestID) == QUEST_STATUS_COMPLETE)
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_ALREADY_DONE);
continue;
}
if (!receiver->CanTakeQuest(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_INVALID);
continue;
}
if (!receiver->SatisfyQuestLog(false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_LOG_FULL);
continue;
}
if (!receiver->GetDivider().IsEmpty())
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_BUSY);
continue;
}
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_SUCCESS);
if (quest->IsAutoAccept() && receiver->CanAddQuest(quest, true) && receiver->CanTakeQuest(quest, true))
receiver->AddQuestAndCheckCompletion(quest, sender);
if (quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly())
receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true);
else
{
receiver->SetDivider(sender->GetGUID());
receiver->PlayerTalkClass->SendQuestGiverQuestDetails(quest, receiver->GetGUID(), true);
}
}
}
示例14: HandleBattlemasterJoinArena
//.........这里部分代码省略.........
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattlegroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
}
uint32 ateamId = 0;
if (isRated)
{
ateamId = _player->GetArenaTeamId(arenaslot);
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queueing
arenaRating = at->GetRating();
matchmakerRating = at->GetAverageMMR(grp);
// the arenateam id must match for everyone in the group
if (arenaRating <= 0)
arenaRating = 1;
}
BattlegroundQueue &bgQueue = sBattlegroundMgr->m_BattlegroundQueues[bgQueueTypeId];
if (asGroup)
{
uint32 avgTime = 0;
if (err > 0)
{
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena join as group start");
if (isRated)
{
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName(), matchmakerRating, arenatype);
bg->SetRated(true);
}
else
bg->SetRated(false);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, matchmakerRating, ateamId);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue;
WorldPacket data;
if (err <= 0)
{
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
continue;
}
// add to queue
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
// send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
member->GetSession()->SendPacket(&data);
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName());
}
}
else
{
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, matchmakerRating, ateamId);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
WorldPacket data;
// send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
SendPacket(&data);
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName());
}
sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例15: HandleLootMoneyOpcode
void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/)
{
sLog.outDebug("WORLD: CMSG_LOOT_MONEY");
Player* player = GetPlayer();
uint64 guid = player->GetLootGUID();
if (!guid)
return;
Loot* pLoot = NULL;
bool shareMoney = true;
switch (GUID_HIPART(guid))
{
case HIGHGUID_GAMEOBJECT:
{
GameObject* pGameObject = GetPlayer()->GetMap()->GetGameObject(guid);
// not check distance for GO in case owned GO (fishing bobber case, for example)
if (pGameObject && ((pGameObject->GetOwnerGUID() == _player->GetGUID() || pGameObject->IsWithinDistInMap(_player, INTERACTION_DISTANCE))))
pLoot = &pGameObject->loot;
break;
}
case HIGHGUID_CORPSE: // remove insignia ONLY in BG
{
Corpse* bones = ObjectAccessor::GetCorpse(*GetPlayer(), guid);
if (bones && bones->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
{
pLoot = &bones->loot;
shareMoney = false;
}
break;
}
case HIGHGUID_ITEM:
{
if (Item* item = GetPlayer()->GetItemByGuid(guid))
{
pLoot = &item->loot;
shareMoney = false;
}
break;
}
case HIGHGUID_UNIT:
{
Creature* creature = GetPlayer()->GetMap()->GetCreature(guid);
bool ok_loot = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_SKINNING);
if (ok_loot && creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
{
pLoot = &creature->loot;
if (creature->IsAlive())
shareMoney = false;
}
else
player->SendLootError(guid, ok_loot ? LOOT_ERROR_TOO_FAR : LOOT_ERROR_DIDNT_KILL);
break;
}
default:
return; // unlootable type
}
if (pLoot)
{
pLoot->NotifyMoneyRemoved();
if (shareMoney && player->GetGroup()) //item, pickpocket and players can be looted only single player
{
Group* group = player->GetGroup();
std::vector<Player*> playersNear;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* playerGroup = itr->getSource();
if (!playerGroup)
continue;
if (player->GetDistance2d(playerGroup) < sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE))
playersNear.push_back(playerGroup);
}
uint32 money_per_player = uint32((pLoot->gold) / (playersNear.size()));
for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
{
(*i)->ModifyMoney(money_per_player);
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4);
data << uint32(money_per_player);
(*i)->GetSession()->SendPacket(&data);
}
}
else
player->ModifyMoney(pLoot->gold);
pLoot->gold = 0;
}
}