本文整理汇总了C++中Battleground::GetPlayers方法的典型用法代码示例。如果您正苦于以下问题:C++ Battleground::GetPlayers方法的具体用法?C++ Battleground::GetPlayers怎么用?C++ Battleground::GetPlayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Battleground
的用法示例。
在下文中一共展示了Battleground::GetPlayers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleSpectateResetCommand
static bool HandleSpectateResetCommand(ChatHandler* handler, const char *args)
{
Player* player = handler->GetSession()->GetPlayer();
if (!player)
{
handler->PSendSysMessage("Cant find player.");
handler->SetSentErrorMessage(true);
return false;
}
if (!player->IsSpectator())
{
handler->PSendSysMessage("You are not a spectator!");
handler->SetSentErrorMessage(true);
return false;
}
Battleground *bGround = player->GetBattleground();
if (!bGround)
return false;
if (bGround->GetStatus() != STATUS_IN_PROGRESS)
return true;
for (Battleground::BattlegroundPlayerMap::const_iterator itr = bGround->GetPlayers().begin(); itr != bGround->GetPlayers().end(); ++itr)
if (Player* tmpPlayer = ObjectAccessor::FindPlayer(itr->first))
{
if (tmpPlayer->IsSpectator())
continue;
uint32 tmpID = bGround->GetPlayerTeam(tmpPlayer->GetGUID());
/*
// generate addon massage
std::string pName = tmpPlayer->GetName();
std::string tName = "";
if (Player *target = tmpPlayer->GetSelectedPlayer())
tName = target->GetName();
SpectatorAddonMsg msg; // Travis
msg.SetPlayer(pName);
if (tName != "")
msg.SetTarget(tName);
msg.SetStatus(tmpPlayer->IsAlive());
msg.SetClass(tmpPlayer->getClass());
msg.SetCurrentHP(tmpPlayer->GetHealth());
msg.SetMaxHP(tmpPlayer->GetMaxHealth());
Powers powerType = tmpPlayer->getPowerType();
msg.SetMaxPower(tmpPlayer->GetMaxPower(powerType));
msg.SetCurrentPower(tmpPlayer->GetPower(powerType));
msg.SetPowerType(powerType);
msg.SetTeam(tmpID);
msg.SendPacket(player->GetGUID());
*/
}
return true;
}
示例2: OnGossipHello
bool OnGossipHello(Player* player, GameObject* /*pGO*/)
{
if (player->HasAura(32727))
{
player->m_clicked = true;
Battleground* battleground = player->GetBattleground();
uint8 numOfReadyPlrs = 0;
for (Battleground::BattlegroundPlayerMap::const_iterator itr = battleground->GetPlayers().begin(); itr != battleground->GetPlayers().end(); ++itr)
{
if (Player *plr = sObjectAccessor->FindPlayer(itr->first))
{
if (plr->m_clicked == true)
++numOfReadyPlrs;
}
}
// 0 by se nemela vypsat nikdy, ale co uz...
if (numOfReadyPlrs == 0 && battleground->GetArenaType() == 2)
ChatHandler(player->GetSession()).PSendSysMessage("Je pripraveno %u hracu ze %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
// 2v2
else if (numOfReadyPlrs == 1 && battleground->GetArenaType() == 2)
ChatHandler(player->GetSession()).PSendSysMessage("Je pripraven %u hrac ze %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
else if ((numOfReadyPlrs == 2 || numOfReadyPlrs == 3) && battleground->GetArenaType() == 2)
ChatHandler(player->GetSession()).PSendSysMessage("Jsou pripraveni %u hraci ze %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
else if (numOfReadyPlrs == 4 && battleground->GetArenaType() == 2)
ChatHandler(player->GetSession()).PSendSysMessage("Jsou pripraveni vsichni hraci.", numOfReadyPlrs, battleground->GetArenaType()*2);
// 3v3
else if (numOfReadyPlrs == 0 && battleground->GetArenaType() == 3)
ChatHandler(player->GetSession()).PSendSysMessage("Je pripraveno %u hracu z %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
else if (numOfReadyPlrs == 1 && battleground->GetArenaType() == 3)
ChatHandler(player->GetSession()).PSendSysMessage("Je pripraven %u hrac z %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
else if ((numOfReadyPlrs == 2 || numOfReadyPlrs == 3 || numOfReadyPlrs == 4) && battleground->GetArenaType() == 3)
ChatHandler(player->GetSession()).PSendSysMessage("Jsou pripraveni %u hraci z %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
else if (numOfReadyPlrs == 5 && battleground->GetArenaType() == 3)
ChatHandler(player->GetSession()).PSendSysMessage("Je pripraveno %u hracu z %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
else if (numOfReadyPlrs == 6 && battleground->GetArenaType() == 3)
ChatHandler(player->GetSession()).PSendSysMessage("Jsou pripraveni vsichni hraci.", numOfReadyPlrs, battleground->GetArenaType()*2);
// Todle je pro 5v5 a a ja jsem linej vypisovat vsechny mozny kombinace. Pokud se nekomu chce, muze to doplnit, ale me to prijde zbytecny.
else
ChatHandler(player->GetSession()).PSendSysMessage("Je pripraveno %u hracu z %u potrebnych.", numOfReadyPlrs, battleground->GetArenaType()*2);
if ((battleground->GetStartDelayTime() - player->timeDiff) <= 15000)
{
player->GetSession()->SendAreaTriggerMessage("Arena za chvili zacina");
}
else
{
player->GetSession()->SendAreaTriggerMessage("Jste oznacen jako pripaven");
}
}
return true;
}
示例3: HandleSpectateCommand
//.........这里部分代码省略.........
}
if (player->GetMap()->IsBattlegroundOrArena() && !player->isSpectator())
{
handler->PSendSysMessage("Вы уже находитесь на поле битвы или арене.");
handler->SetSentErrorMessage(true);
return false;
}
Map* map = target->GetMap();
if (!map->IsBattleArena())
{
handler->PSendSysMessage("Игрок не на арене.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->GetMap()->IsBattleground())
{
handler->PSendSysMessage("Не могу сделать это, в то время как вы находитесь на поле боя.");
handler->SetSentErrorMessage(true);
return false;
}
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
// remember current position as entry point for return at bg end teleportation
if (!player->GetMap()->IsBattlegroundOrArena())
player->SetBattlegroundEntryPoint();
if (target->isSpectator())
{
handler->PSendSysMessage("Не могу сделать этого. Ваша цель - зритель.");
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
// search for two teams
Battleground *bGround = target->GetBattleground();
if (bGround->isRated())
{
uint32 slot = bGround->GetArenaType() - 2;
if (bGround->GetArenaType() > 3)
slot = 2;
uint32 firstTeamID = target->GetArenaTeamId(slot);
uint32 secondTeamID = 0;
Player *firstTeamMember = target;
Player *secondTeamMember = NULL;
for (Battleground::BattlegroundPlayerMap::const_iterator itr = bGround->GetPlayers().begin(); itr != bGround->GetPlayers().end(); ++itr)
if (Player* tmpPlayer = ObjectAccessor::FindPlayer(itr->first))
{
if (tmpPlayer->isSpectator())
continue;
uint32 tmpID = tmpPlayer->GetArenaTeamId(slot);
if (tmpID != firstTeamID && tmpID > 0)
{
secondTeamID = tmpID;
secondTeamMember = tmpPlayer;
break;
}
}
if (firstTeamID > 0 && secondTeamID > 0 && secondTeamMember)
{
ArenaTeam *firstTeam = sArenaTeamMgr->GetArenaTeamById(firstTeamID);
ArenaTeam *secondTeam = sArenaTeamMgr->GetArenaTeamById(secondTeamID);
if (firstTeam && secondTeam)
{
handler->PSendSysMessage("Вы вошли на Арену.");
handler->PSendSysMessage("Команды:");
handler->PSendSysMessage("%s - %s", firstTeam->GetName().c_str(), secondTeam->GetName().c_str());
handler->PSendSysMessage("%u(%u) - %u(%u)", firstTeam->GetRating(), firstTeam->GetAverageMMR(firstTeamMember->GetGroup()),
secondTeam->GetRating(), secondTeam->GetAverageMMR(secondTeamMember->GetGroup()));
}
}
}
// to point to see at target with same orientation
float x, y, z;
target->GetContactPoint(player, x, y, z);
player->TeleportTo(target->GetMapId(), x, y, z, player->GetAngle(target), TELE_TO_GM_MODE);
player->SetPhaseMask(target->GetPhaseMask(), true);
player->SetSpectate(true);
target->GetBattleground()->AddSpectator(player->GetGUID());
return true;
}
示例4: ShowPage
void ShowPage(Player* player, uint16 page, uint32 IsTop)
{
uint32 firstTeamId = 0;
uint16 TypeOne = 0;
uint16 TypeTwo = 0;
uint16 TypeThree = 0;
uint16 mmr = 0;
uint16 mmrTwo = 0;
bool haveNextPage = false;
for (uint8 i = 0; i <= MAX_BATTLEGROUND_TYPE_ID; ++i)
{
if (!sBattlegroundMgr->IsArenaType(BattlegroundTypeId(i)))
continue;
//BattlegroundContainer arenas = sBattlegroundMgr->GetBattlegroundsByType((BattlegroundTypeId)i);
BattlegroundData* arenas = sBattlegroundMgr->GetAllBattlegroundsWithTypeId(BattlegroundTypeId(i));
if (!arenas || arenas->m_Battlegrounds.empty())
continue;
for (BattlegroundContainer::const_iterator itr = arenas->m_Battlegrounds.begin(); itr != arenas->m_Battlegrounds.end(); ++itr)
{
Battleground* arena = itr->second;
Player* target = ObjectAccessor::FindPlayer(GetFirstPlayerGuid(arena));
if (target && (target->HasAura(32728) || target->HasAura(32727)))
continue;
if (!arena->GetPlayersSize())
continue;
if (arena->GetArenaType() == ARENA_TYPE_2v2)
{
mmr = arena->GetArenaMatchmakerRating(0);
firstTeamId = target->GetArenaTeamId(0);
Battleground::BattlegroundPlayerMap::const_iterator citr = arena->GetPlayers().begin();
for (; citr != arena->GetPlayers().end(); ++citr)
if (Player* plrs = sObjectAccessor->FindPlayer(citr->first))
if (plrs->GetArenaTeamId(0) != firstTeamId)
mmrTwo = arena->GetArenaMatchmakerRating(citr->second.Team);
}
else if (arena->GetArenaType() == ARENA_TYPE_3v3)
{
mmr = arena->GetArenaMatchmakerRating(1);
firstTeamId = target->GetArenaTeamId(1);
Battleground::BattlegroundPlayerMap::const_iterator citr = arena->GetPlayers().begin();
for (; citr != arena->GetPlayers().end(); ++citr)
if (Player* plrs = sObjectAccessor->FindPlayer(citr->first))
if (plrs->GetArenaTeamId(1) != firstTeamId)
mmrTwo = arena->GetArenaMatchmakerRating(citr->second.Team);
}
else if (arena->GetArenaType() == ARENA_TYPE_5v5 && arena->GetArenaType() == ARENA_TYPE_3v3_SOLO)
{
mmr = arena->GetArenaMatchmakerRating(2);
firstTeamId = target->GetArenaTeamId(2);
Battleground::BattlegroundPlayerMap::const_iterator citr = arena->GetPlayers().begin();
for (; citr != arena->GetPlayers().end(); ++citr)
if (Player* plrs = sObjectAccessor->FindPlayer(citr->first))
if (plrs->GetArenaTeamId(2) != firstTeamId)
mmrTwo = arena->GetArenaMatchmakerRating(citr->second.Team);
}
if (IsTop == 1 && arena->GetArenaType() == ARENA_TYPE_2v2)
{
TypeOne++;
if (TypeOne > (page + 1) * GamesOnPage)
{
haveNextPage = true;
break;
}
if (TypeOne >= page * GamesOnPage)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr, mmrTwo), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
}
else if (IsTop == 2 && arena->GetArenaType() == ARENA_TYPE_3v3)
{
TypeTwo++;
if (TypeTwo > (page + 1) * GamesOnPage)
{
haveNextPage = true;
break;
}
if (TypeTwo >= page * GamesOnPage)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr, mmrTwo), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
}
else if (IsTop == 3 && arena->GetArenaType() == ARENA_TYPE_5v5 && arena->GetArenaType() == ARENA_TYPE_3v3_SOLO)
{
TypeThree++;
if (TypeThree > (page + 1) * GamesOnPage)
{
haveNextPage = true;
break;
}
if (TypeThree >= page * GamesOnPage)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr, mmrTwo), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
}
}
}
//.........这里部分代码省略.........
示例5: HandleSpectateCommand
//.........这里部分代码省略.........
return false;
}
if (player->GetMap()->IsBattleground())
{
handler->PSendSysMessage("你在战场里不能同时观察.");
handler->SetSentErrorMessage(true);
return false;
}
if (target->HasAura(32728) || target->HasAura(32727))
{
handler->PSendSysMessage("你还不能观察,竞技场还没有开始.");
handler->SetSentErrorMessage(true);
return false;
}
if (target->IsSpectator())
{
handler->PSendSysMessage("不能进入,目标在观察状态.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->IsMounted())
{
handler->PSendSysMessage("不能在有坐骑的情况下观察.");
handler->SetSentErrorMessage(true);
return false;
}
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
// remember current position as entry point for return at bg end teleportation
if (!player->GetMap()->IsBattlegroundOrArena())
player->SetBattlegroundEntryPoint();
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
// search for two teams
Battleground *bGround = target->GetBattleground();
if (bGround->isRated())
{
uint32 slot = bGround->GetArenaType() - 2;
if (bGround->GetArenaType() > 3)
slot = 2;
uint32 firstTeamID = target->GetArenaTeamId(slot);
uint32 secondTeamID = 0;
Player *firstTeamMember = target;
Player *secondTeamMember = NULL;
for (Battleground::BattlegroundPlayerMap::const_iterator itr = bGround->GetPlayers().begin(); itr != bGround->GetPlayers().end(); ++itr)
if (Player* tmpPlayer = ObjectAccessor::FindPlayer(itr->first))
{
if (tmpPlayer->IsSpectator())
continue;
uint32 tmpID = tmpPlayer->GetArenaTeamId(slot);
if (tmpID != firstTeamID && tmpID > 0)
{
secondTeamID = tmpID;
secondTeamMember = tmpPlayer;
break;
}
}
if (firstTeamID > 0 && secondTeamID > 0 && secondTeamMember)
{
ArenaTeam *firstTeam = sArenaTeamMgr->GetArenaTeamById(firstTeamID);
ArenaTeam *secondTeam = sArenaTeamMgr->GetArenaTeamById(secondTeamID);
if (firstTeam && secondTeam)
{
handler->PSendSysMessage("你进入了竞技场积分赛.");
handler->PSendSysMessage("队伍:");
handler->PSendSysMessage("|cFFffffff%s|r vs |cFFffffff%s|r", firstTeam->GetName().c_str(), secondTeam->GetName().c_str());
handler->PSendSysMessage("|cFFffffff%u(%u)|r -- |cFFffffff%u(%u)|r", firstTeam->GetRating(), firstTeam->GetAverageMMR(firstTeamMember->GetGroup()),
secondTeam->GetRating(), secondTeam->GetAverageMMR(secondTeamMember->GetGroup()));
}
}
}
// to point to see at target with same orientation
float x, y, z;
target->GetContactPoint(player, x, y, z);
player->TeleportTo(target->GetMapId(), x, y, z, player->GetAngle(target), TELE_TO_GM_MODE);
player->SetPhaseMask(target->GetPhaseMask(), true);
player->SetSpectate(true);
target->GetBattleground()->AddSpectator(player->GetGUID());
return true;
}
示例6: HandleSpectateCommand
//.........这里部分代码省略.........
return false;
}
if (player->GetMap()->IsBattleground())
{
handler->PSendSysMessage("You can't do that while in a battleground.");
handler->SetSentErrorMessage(true);
return false;
}
if (target->HasAura(32728) || target->HasAura(32727))
{
handler->PSendSysMessage("You can't do that. The Arena match didn't start yet.");
handler->SetSentErrorMessage(true);
return false;
}
if (target->IsSpectator())
{
handler->PSendSysMessage("You can't do that. Your target is a spectator.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->IsMounted())
{
handler->PSendSysMessage("Cannot Spectate while mounted.");
handler->SetSentErrorMessage(true);
return false;
}
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
// remember current position as entry point for return at bg end teleportation
if (!player->GetMap()->IsBattlegroundOrArena())
player->SetBattlegroundEntryPoint();
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
// search for two teams
Battleground *bGround = target->GetBattleground();
if (bGround->isRated())
{
uint32 slot = bGround->GetArenaType() - 2;
if (bGround->GetArenaType() > 3)
slot = 2;
uint32 firstTeamID = target->GetArenaTeamId(slot);
uint32 secondTeamID = 0;
Player *firstTeamMember = target;
Player *secondTeamMember = NULL;
for (Battleground::BattlegroundPlayerMap::const_iterator itr = bGround->GetPlayers().begin(); itr != bGround->GetPlayers().end(); ++itr)
if (Player* tmpPlayer = ObjectAccessor::FindPlayer(itr->first))
{
if (tmpPlayer->IsSpectator())
continue;
uint32 tmpID = tmpPlayer->GetArenaTeamId(slot);
if (tmpID != firstTeamID && tmpID > 0)
{
secondTeamID = tmpID;
secondTeamMember = tmpPlayer;
break;
}
}
if (firstTeamID > 0 && secondTeamID > 0 && secondTeamMember)
{
ArenaTeam *firstTeam = sArenaTeamMgr->GetArenaTeamById(firstTeamID);
ArenaTeam *secondTeam = sArenaTeamMgr->GetArenaTeamById(secondTeamID);
if (firstTeam && secondTeam)
{
handler->PSendSysMessage("You entered a Rated Arena.");
handler->PSendSysMessage("Teams:");
handler->PSendSysMessage("|cFFffffff%s|r vs |cFFffffff%s|r", firstTeam->GetName().c_str(), secondTeam->GetName().c_str());
handler->PSendSysMessage("|cFFffffff%u(%u)|r -- |cFFffffff%u(%u)|r", firstTeam->GetRating(), firstTeam->GetAverageMMR(firstTeamMember->GetGroup()),
secondTeam->GetRating(), secondTeam->GetAverageMMR(secondTeamMember->GetGroup()));
}
}
}
// to point to see at target with same orientation
float x, y, z;
target->GetContactPoint(player, x, y, z);
player->TeleportTo(target->GetMapId(), x, y, z, player->GetAngle(target), TELE_TO_GM_MODE);
player->SetPhaseMask(target->GetPhaseMask(), true);
player->SetSpectate(true);
target->GetBattleground()->AddSpectator(player->GetGUID());
return true;
}