本文整理汇总了C++中GroupReference::getSource方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupReference::getSource方法的具体用法?C++ GroupReference::getSource怎么用?C++ GroupReference::getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupReference
的用法示例。
在下文中一共展示了GroupReference::getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleBattleGroundJoinOpcode
void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8+4+4+1);
uint64 guid;
uint32 bgTypeId;
uint32 instanceId;
uint8 joinAsGroup;
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
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from: " I64FMT, guid);
// ignore if we already in BG or BG queue
if(_player->InBattleGround())
return;
// check Deserter debuff
if( !_player->CanJoinToBattleground() )
{
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << (uint32) 0xFFFFFFFE;
_player->GetSession()->SendPacket(&data);
return;
}
// check existence
BattleGround *bg = sBattleGroundMgr.GetBattleGround(bgTypeId);
if(!bg)
return;
if(joinAsGroup && _player->GetGroup())
{
Group *grp = _player->GetGroup();
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *member = itr->getSource();
if(!member) continue;
if( !member->CanJoinToBattleground() )
{
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << (uint32) 0xFFFFFFFE;
_player->GetSession()->SendPacket(&data);
continue;
}
if (member->GetBattleGroundQueueIndex(bgTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
continue;
WorldPacket data;
uint32 queueSlot = member->AddBattleGroundQueueId(bgTypeId); // add to queue
if (queueSlot == PLAYER_MAX_BATTLEGROUND_QUEUES)
{
// fill data packet
//member->GetSession()->SendPacket(data);
continue;
}
// store entry point coords (same as leader entry point)
member->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, member->GetTeam(), queueSlot, STATUS_WAIT_QUEUE, 0, 0);
member->GetSession()->SendPacket(&data);
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
member->GetSession()->SendPacket(&data);
sBattleGroundMgr.m_BattleGroundQueues[bgTypeId].AddPlayer(member, bgTypeId);
}
}
else
{
if (_player->GetBattleGroundQueueIndex(bgTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
uint32 queueSlot = _player->AddBattleGroundQueueId(bgTypeId);
if (queueSlot == PLAYER_MAX_BATTLEGROUND_QUEUES)
{
WorldPacket data;
// fill data packet
//SendPacket(data);
return;
}
// store entry point coords
_player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, _player->GetTeam(), queueSlot, STATUS_WAIT_QUEUE, 0, 0);
SendPacket(&data);
sBattleGroundMgr.m_BattleGroundQueues[bgTypeId].AddPlayer(_player, bgTypeId);
}
}
示例2: HandleTeleGroupCommand
//Teleport group to given game_tele.entry
static bool HandleTeleGroupCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* target = handler->getSelectedPlayer();
if (!target)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
if (!tele)
{
handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
if (!map || map->IsBattlegroundOrArena())
{
handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
handler->SetSentErrorMessage(true);
return false;
}
std::string nameLink = handler->GetNameLink(target);
Group* group = target->GetGroup();
if (!group)
{
handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
handler->SetSentErrorMessage(true);
return false;
}
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* player = itr->getSource();
if (!player || !player->GetSession())
continue;
// check online security
if (handler->HasLowerSecurity(player, 0))
return false;
std::string plNameLink = handler->GetNameLink(player);
if (player->IsBeingTeleported())
{
handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
continue;
}
handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str());
if (handler->needReportToTarget(player))
(ChatHandler(player)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
// stop flight if need
if (player->isInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
return true;
}
示例3: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->GetBattlegroundQueueIndex(bgQueueTypeIdRandom) < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
//player is already in random queue
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB)
{
//player is already in queue, can't start random queue
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_NON_RANDOM_BG);
_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())
{
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, 0, false, isPremade, 0, 0);
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, ginfo->ArenaType);
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(), false, 0);
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, 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
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, ginfo->ArenaType);
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(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例4: HandlePushQuestToParty
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
{
uint32 questId;
recvPacket >> questId;
DEBUG_LOG("WORLD: Received CMSG_PUSHQUESTTOPARTY quest = %u", questId);
if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(questId))
{
if (Group* pGroup = _player->GetGroup())
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *pPlayer = itr->getSource();
if (!pPlayer || pPlayer == _player) // skip self
continue;
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_SHARING_QUEST);
if (!pPlayer->SatisfyQuestStatus(pQuest, false))
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_HAVE_QUEST);
continue;
}
if (pPlayer->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE)
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_FINISH_QUEST);
continue;
}
if (!pPlayer->CanTakeQuest(pQuest, false))
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_CANT_TAKE_QUEST);
continue;
}
if (!pPlayer->SatisfyQuestLog(false))
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_LOG_FULL);
continue;
}
if (pPlayer->GetDividerGuid())
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_BUSY);
continue;
}
pPlayer->SetDividerGuid(_player->GetObjectGuid());
if (pPlayer->GetPlayerbotAI())
pPlayer->GetPlayerbotAI()->AcceptQuest( pQuest, _player );
else
{
pPlayer->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, _player->GetObjectGuid(), true);
pPlayer->SetDividerGuid(_player->GetObjectGuid());
}
}
}
}
}
示例5: HandleBattleGroundJoinOpcode
void WorldSession::HandleBattleGroundJoinOpcode(WorldPacket& recv_data)
{
uint64 guid;
uint32 bgTypeId;
uint32 instanceId;
uint8 joinAsGroup;
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 (bgTypeId >= MAX_BATTLEGROUND_TYPES)
{
sLog.outError("Battleground: invalid bgtype received. possible cheater? player guid %u",_player->GetGUIDLow());
return;
}
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
uint32 bgQueueTypeId = sBattleGroundMgr.BGQueueTypeId(bgTypeId, 0);
// ignore if player is already in BG
if (_player->InBattleGround())
return;
Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
if (!unit->isBattleMaster()) // it's not battlemaster
return;
// get bg instance or bg template if instance not found
BattleGround *bg = NULL;
if (instanceId)
bg = sBattleGroundMgr.GetBattleGround(instanceId);
if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
{
sLog.outError("Battleground: no available bg / template found");
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(bgTypeId, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
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
if (joinAsGroup /* && _player->GetGroup()*/)
{
sLog.outDebug("Battleground: the following players are joining as group:");
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, 0, false, 0);
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
// store entry point coords (same as leader entry point)
if (!sWorld.getConfig(CONFIG_BATTLEGROUND_WRATH_LEAVE_MODE))
member->SetBattleGroundEntryPoint(member->GetMapId(), member->GetPositionX(), member->GetPositionY(), member->GetPositionZ(), member->GetOrientation());
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, member->GetTeam(), queueSlot, STATUS_WAIT_QUEUE, 0, 0);
member->GetSession()->SendPacket(&data);
//.........这里部分代码省略.........
示例6: HandleBattlemasterJoinOpcode
void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
{
ObjectGuid 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_);
DEBUG_LOG( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from %s", guid.GetString().c_str());
// can do this, since it's battleground, not arena
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, ARENA_TYPE_NONE);
// ignore if player is already in BG
if (_player->InBattleGround())
return;
Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
if (!unit->isBattleMaster()) // it's not battlemaster
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;
}
BattleGroundBracketId bgBracketId = _player->GetBattleGroundBracketIdFromLevel(bgTypeId);
// check queue 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(bgTypeId, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) &&
(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)
{
DEBUG_LOG("Battleground: the following players are joining as group:");
GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bgBracketId, ARENA_TYPE_NONE, false, isPremade, 0);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundBracketIdFromLevel(bgTypeId));
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
//.........这里部分代码省略.........
示例7: HandleQuestgiverAcceptQuestOpcode
void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
{
uint64 guid;
uint32 questId;
uint32 unk1;
recvData >> guid >> questId >> unk1;
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), questId, unk1);
Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT|TYPEMASK_ITEM|TYPEMASK_PLAYER);
// no or incorrect quest giver
if (!object || (object->GetTypeId() != TYPEID_PLAYER && !object->hasQuest(questId)) ||
(object->GetTypeId() == TYPEID_PLAYER && object != _player && !object->ToPlayer()->CanShareQuest(questId)))
{
_player->PlayerTalkClass->SendCloseGossip();
_player->SetDivider(0);
return;
}
// some kind of WPE protection
if (!_player->CanInteractWithQuestGiver(object))
return;
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
{
// prevent cheating
if (!GetPlayer()->CanTakeQuest(quest, true))
{
_player->PlayerTalkClass->SendCloseGossip();
_player->SetDivider(0);
return;
}
if (_player->GetDivider() != 0)
{
Player* player = ObjectAccessor::FindPlayer(_player->GetDivider());
if (player)
{
player->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST);
_player->SetDivider(0);
}
}
if (_player->CanAddQuest(quest, true))
{
_player->AddQuest(quest, object);
if (quest->HasFlag(QUEST_FLAGS_PARTY_ACCEPT))
{
if (Group* group = _player->GetGroup())
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* player = itr->getSource();
if (!player || player == _player) // not self
continue;
if (player->CanTakeQuest(quest, true))
{
player->SetDivider(_player->GetGUID());
//need confirmation that any gossip window will close
player->PlayerTalkClass->SendCloseGossip();
_player->SendQuestConfirmAccept(quest, player);
}
}
}
}
if (_player->CanCompleteQuest(questId))
_player->CompleteQuest(questId);
switch (object->GetTypeId())
{
case TYPEID_UNIT:
sScriptMgr->OnQuestAccept(_player, (object->ToCreature()), quest);
(object->ToCreature())->AI()->sQuestAccept(_player, quest);
break;
case TYPEID_ITEM:
case TYPEID_CONTAINER:
{
sScriptMgr->OnQuestAccept(_player, ((Item*)object), quest);
// destroy not required for quest finish quest starting item
bool destroyItem = true;
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if ((quest->RequiredItemId[i] == ((Item*)object)->GetEntry()) && (((Item*)object)->GetTemplate()->MaxCount > 0))
{
destroyItem = false;
break;
}
}
if (destroyItem)
_player->DestroyItem(((Item*)object)->GetBagSlot(), ((Item*)object)->GetSlot(), true);
//.........这里部分代码省略.........
示例8: UpdateAI
void UpdateAI(const uint32 uiDiff)
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
if (!m_bIsEnraged && m_creature->GetHealthPercent() < 25.0f)
{
if (!m_creature->IsNonMeleeSpellCasted(false))
{
m_bIsEnraged = true;
DoScriptText(SAY_ENRAGE, m_creature);
DoCastSpellIfCan(m_creature, SPELL_ENRAGE);
}
}
if (uiCrystalChainTimer < uiDiff)
{
if (!m_creature->IsNonMeleeSpellCasted(false))
{
if (m_bIsRegularMode)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
{
if (Player* pPlayer = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
DoCastSpellIfCan(pPlayer, SPELL_CRYSTAL_CHAINS);
uiCrystalChainTimer = 30000;
}
}
else
{
if (Unit* pSource = m_creature->getVictim())
{
uiCrystalChainTimer = 15000;
Player* pPlayer = pSource->GetCharmerOrOwnerPlayerOrPlayerItself();
if (!pPlayer)
return;
if (Group* pGroup = pPlayer->GetGroup())
{
for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
{
if (Player* pMember = pRef->getSource())
{
if (pMember->isAlive() && pMember->IsWithinDistInMap(m_creature, 50.0f))
m_creature->CastSpell(pMember, SPELL_CRYSTAL_CHAINS, true);
}
}
}
else
m_creature->CastSpell(pPlayer, SPELL_CRYSTAL_CHAINS, false);
}
}
}
}
else
uiCrystalChainTimer -= uiDiff;
if (uiTailSweepTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_TAIL_SWEEP) == CAST_OK)
uiTailSweepTimer = urand(2500, 7500);
}
else
uiCrystalChainTimer -= uiDiff;
if (uiCrystalfireBreathTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_CRYSTALFIRE_BREATH : SPELL_CRYSTALFIRE_BREATH_H) == CAST_OK)
uiCrystalfireBreathTimer = urand(15000, 20000);
}
else
uiCrystalfireBreathTimer -= uiDiff;
if (!m_bIsRegularMode)
{
if (uiCrystallizeTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_CRYSTALLIZE) == CAST_OK)
{
uiCrystallizeTimer = urand(15000, 25000);
DoScriptText(SAY_CRYSTAL_NOVA, m_creature);
}
}
else
uiCrystallizeTimer -= uiDiff;
}
DoMeleeAttackIfReady();
}
示例9: AddGroup
// add group or player (grp == NULL) to bg queue with the given leader and bg specifications
GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, BattlegroundTypeId BgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 arenateamid)
{
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
// create new ginfo
GroupQueueInfo* ginfo = new GroupQueueInfo;
ginfo->BgTypeId = BgTypeId;
ginfo->ArenaType = ArenaType;
ginfo->ArenaTeamId = arenateamid;
ginfo->IsRated = isRated;
ginfo->IsInvitedToBGInstanceGUID = 0;
ginfo->JoinTime = getMSTime();
ginfo->RemoveInviteTime = 0;
ginfo->Team = leader->GetBGTeam();
ginfo->ArenaTeamRating = ArenaRating;
ginfo->ArenaMatchmakerRating = MatchmakerRating;
ginfo->OpponentsTeamRating = 0;
ginfo->OpponentsMatchmakerRating = 0;
ginfo->Players.clear();
//compute index (if group is premade or joined a rated match) to queues
uint32 index = 0;
if (!isRated && !isPremade)
index += BG_TEAMS_COUNT;
if (ginfo->Team == HORDE)
index++;
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Adding Group to BattlegroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
uint32 lastOnlineTime = getMSTime();
//announce world (this don't need mutex)
if (isRated && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
{
ArenaTeam* Team = sArenaTeamMgr->GetArenaTeamById(arenateamid);
if (Team)
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, Team->GetName().c_str(), ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
}
//add players from group to ginfo
if (grp)
{
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue; // this should never happen
PlayerQueueInfo& pl_info = m_QueuedPlayers[member->GetGUID()];
pl_info.LastOnlineTime = lastOnlineTime;
pl_info.GroupInfo = ginfo;
// add the pinfo to ginfo's list
ginfo->Players[member->GetGUID()] = &pl_info;
}
}
else
{
PlayerQueueInfo& pl_info = m_QueuedPlayers[leader->GetGUID()];
pl_info.LastOnlineTime = lastOnlineTime;
pl_info.GroupInfo = ginfo;
ginfo->Players[leader->GetGUID()] = &pl_info;
}
//add GroupInfo to m_QueuedGroups
{
//ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_Lock);
m_QueuedGroups[bracketId][index].push_back(ginfo);
//announce to world, this code needs mutex
if (!isRated && !isPremade && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
{
if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId))
{
char const* bgName = bg->GetName();
uint32 MinPlayers = bg->GetMinPlayersPerTeam();
uint32 qHorde = 0;
uint32 qAlliance = 0;
uint32 q_min_level = bracketEntry->minLevel;
uint32 q_max_level = bracketEntry->maxLevel;
GroupsQueueType::const_iterator itr;
for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
if (!(*itr)->IsInvitedToBGInstanceGUID)
qAlliance += (*itr)->Players.size();
for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
if (!(*itr)->IsInvitedToBGInstanceGUID)
qHorde += (*itr)->Players.size();
// Show queue status to player only (when joining queue)
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
{
ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
}
// System message
else
{
sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level,
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
}
}
//.........这里部分代码省略.........
示例10: UpdateAI
void FollowerAI::UpdateAI(const uint32 uiDiff)
{
if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !m_creature->getVictim())
{
if (m_uiUpdateFollowTimer < uiDiff)
{
if (HasFollowState(STATE_FOLLOW_COMPLETE) && !HasFollowState(STATE_FOLLOW_POSTEVENT))
{
debug_log("SD2: FollowerAI is set completed, despawns.");
m_creature->ForcedDespawn();
return;
}
bool bIsMaxRangeExceeded = true;
if (Player* pPlayer = GetLeaderForFollower())
{
if (HasFollowState(STATE_FOLLOW_RETURNING))
{
debug_log("SD2: FollowerAI is returning to leader.");
RemoveFollowState(STATE_FOLLOW_RETURNING);
m_creature->GetMotionMaster()->MoveFollow(pPlayer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
return;
}
if (Group* pGroup = pPlayer->GetGroup())
{
for (GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
{
Player* pMember = pRef->getSource();
if (pMember && m_creature->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE))
{
bIsMaxRangeExceeded = false;
break;
}
}
}
else
{
if (m_creature->IsWithinDistInMap(pPlayer, MAX_PLAYER_DISTANCE))
bIsMaxRangeExceeded = false;
}
}
if (bIsMaxRangeExceeded)
{
debug_log("SD2: FollowerAI failed because player/group was to far away or not found");
m_creature->ForcedDespawn();
return;
}
m_uiUpdateFollowTimer = 1000;
}
else
m_uiUpdateFollowTimer -= uiDiff;
}
UpdateFollowerAI(uiDiff);
}
示例11: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
{
//player is already in queue, can't start random queue
WorldPacket data;
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_NON_RANDOM_BG);
_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())
{
WorldPacket data;
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
_player->GetSession()->SendPacket(&data);
return;
}
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return;
bool have_bots = false;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue; // this should never happen
if (member->GetPlayerbotAI())
{
ChatHandler(_player).PSendSysMessage("|cffff0000You cannot get in battleground queue as premade because you have bots in your group. Adding you in queue as single player.");
have_bots = true;
joinAsGroup = false;
break;
}
}
if (!have_bots)
{
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) &&
(grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
}
}
// 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)
{
GroupQueueInfo* ginfo = NULL;
uint32 avgTime = 0;
if(err > 0)
{
DEBUG_LOG("Battleground: the following players are joining as group:");
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, ARENA_TYPE_NONE, false, isPremade, 0);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
示例12: HandleBattlemasterJoinArena
//.........这里部分代码省略.........
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())
{
Player *member = itr->getSource();
// calc avg personal rating
avg_pers_rating += member->GetArenaPersonalRating(arenaslot);
}
if (arenatype)
avg_pers_rating /= arenatype;
// if avg personal rating is more than 150 points below the teams rating, the team will be queued against an opponent matching or similar to the average personal rating
if (avg_pers_rating + 150 < arenaRating)
arenaRating = avg_pers_rating;
}
BattleGroundQueue &bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
if (asGroup)
{
uint32 avgTime;
if(err > 0)
{
DEBUG_LOG("Battleground: arena join as group start");
if (isRated)
DEBUG_LOG("Battleground: arena team id %u, leader %s queued with rating %u for type %u",_player->GetArenaTeamId(arenaslot),_player->GetName(),arenaRating,arenatype);
GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, ateamId);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *member = itr->getSource();
if(!member)
示例13: HandleMessagechatOpcode
//.........这里部分代码省略.........
{
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;
sChatLog.PartyMsg(GetPlayer(), msg);
// 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;
}
if ((type == CHAT_MSG_PARTY_LEADER) && !group->IsLeader(_player->GetObjectGuid()))
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, NULL, 0, msg.c_str(), NULL);
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())
break;
示例14: HandleQuestPushToParty
void WorldSession::HandleQuestPushToParty(WorldPacket& recvPacket)
{
uint32 questId;
recvPacket >> questId;
sLog.outDebug("WORLD: Received CMSG_PUSHQUESTTOPARTY quest = %u", questId);
if (Quest const *pQuest = objmgr.GetQuestTemplate(questId))
{
if (Group* pGroup = _player->GetGroup())
{
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pPlayer = itr->getSource();
if (!pPlayer || pPlayer == _player) // skip self
continue;
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_SHARING_QUEST);
// 2.4.3: can only share quests within 10 yards
if (_player->GetDistance(pPlayer) > 10)
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_TOO_FAR);
continue;
}
//player already has quest
if (!pPlayer->SatisfyQuestStatus(pQuest, false))
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_HAVE_QUEST);
continue;
}
//player already completed quest
if (pPlayer->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE)
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_FINISH_QUEST);
continue;
}
//player is ineligible for the quest
if (!pPlayer->CanTakeQuest(pQuest, false))
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_CANT_TAKE_QUEST);
continue;
}
//player has full quest log
if (!pPlayer->SatisfyQuestLog(false))
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_LOG_FULL);
continue;
}
if (pPlayer->GetDivider() != 0)
{
_player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_BUSY);
continue;
}
pPlayer->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, _player->GetGUID(), true);
pPlayer->SetDivider(_player->GetGUID());
}
}
}
}
示例15: SendLfgRoleCheckUpdate
void WorldSession::SendLfgRoleCheckUpdate()
{
if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLE))
{
DEBUG_LOG("SendLfgRoleCheckUpdate %u failed - Dungeon finder disabled", GetPlayer()->GetObjectGuid().GetCounter());
return;
}
Group* pGroup = GetPlayer()->GetGroup();
if (!pGroup)
return;
LFGDungeonSet const* dungeons = pGroup->GetLFGGroupState()->GetDungeons();
if (!dungeons)
return;
DEBUG_LOG("SMSG_LFG_ROLE_CHECK_UPDATE %u, dugeons size " SIZEFMTD, GetPlayer()->GetObjectGuid().GetCounter(), dungeons->size());
WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons->size() * 4 + 1 + pGroup->GetMembersCount() * (8 + 1 + 4 + 1));
data << uint32(pGroup->GetLFGGroupState()->GetRoleCheckState()); // Check result
data << uint8(pGroup->GetLFGGroupState()->GetRoleCheckState() == LFG_ROLECHECK_INITIALITING);
data << uint8(dungeons->size()); // Number of dungeons
if (dungeons->size())
{
for (LFGDungeonSet::const_iterator itr = dungeons->begin(); itr != dungeons->end(); ++itr)
{
data << uint32(*itr ? (*itr)->Entry() : 0); // Dungeon Entry
}
}
data << uint8(pGroup->GetMembersCount()); // Players in group
if (pGroup->GetMembersCount())
{
// Leader info MUST be sent 1st :S
ObjectGuid leaderguid = pGroup->GetLeaderGuid();
Player* pLeader = sObjectMgr.GetPlayer(leaderguid);
LFGRoleMask roles = LFG_ROLE_MASK_NONE;
uint8 leaderLevel = 1;
if (pLeader)
{
roles = pLeader->GetLFGPlayerState()->GetRoles();
leaderLevel = pLeader->getLevel();
}
data << leaderguid; // Guid
data << uint8(roles != LFG_ROLE_MASK_NONE); // Ready
data << uint32(roles); // Roles
data << uint8(leaderLevel); // Level
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player* pGroupMember = itr->getSource())
{
ObjectGuid guid = pGroupMember->GetObjectGuid();
// Leader data handle first
if (guid == leaderguid)
continue;
roles = pGroupMember->GetLFGPlayerState()->GetRoles();
data << guid; // Guid
data << uint8(roles != LFG_ROLE_MASK_NONE); // Ready
data << uint32(roles); // Roles
data << uint8(pGroupMember->getLevel()); // Level
}
}
}
SendPacket(&data);
}