void BattleGroundBG::CheckSomeoneJoinedPoint() { for (uint8 i = 0; i < BG_BG_NODES_MAX; ++i) { uint8 j = 0; while (j < m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS].size()) { Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS][j]); if (!plr) { sLog.outError("BattleGroundBG:CheckSomeoneJoinedPoint: %s not found!", m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS][j].GetString().c_str()); ++j; continue; } if (plr->CanUseCapturePoint() && plr->IsWithinDist3d(BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_POINT_RADIUS)) { // player joined point! // show progress bar UpdateWorldStateForPlayer(BG_PROGRESS_BAR_PERCENT_GREY, BG_PROGRESS_BAR_PERCENT_GREY, plr); UpdateWorldStateForPlayer(BG_PROGRESS_BAR_STATUS, m_PointBarStatus[i], plr); UpdateWorldStateForPlayer(BG_PROGRESS_BAR_SHOW, BG_PROGRESS_BAR_SHOW, plr); // add player to point m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS][j]); // remove player from "free space" m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS].erase(m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS].begin() + j); } else ++j; } } }
void BattleGroundEY::CheckSomeoneJoinedPoint() { GameObject* obj = NULL; for (uint8 i = 0; i < EY_POINTS_MAX; ++i) { obj = HashMapHolder<GameObject>::Find(m_BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]); if (obj) { uint8 j = 0; while (j < m_PlayersNearPoint[EY_POINTS_MAX].size()) { Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]); if (plr && plr->CanCaptureTowerPoint() && plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) { //player joined point! //show progress bar UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, plr); UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], plr); UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, plr); //add player to point m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[EY_POINTS_MAX][j]); //remove player from "free space" m_PlayersNearPoint[EY_POINTS_MAX].erase(m_PlayersNearPoint[EY_POINTS_MAX].begin() + j); } else ++j; } } } }
void BattlegroundEY::UpdatePointStatuses() { for (uint8 point = 0; point < EY_POINTS_MAX; ++point) { if (m_PlayersNearPoint[point].empty()) continue; // Count new point bar status: m_PointBarStatus[point] += (m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] < BG_EY_POINT_MAX_CAPTURERS_COUNT) ? m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] : BG_EY_POINT_MAX_CAPTURERS_COUNT; if (m_PointBarStatus[point] > BG_EY_PROGRESS_BAR_ALI_CONTROLLED) // Point is full Alliance. m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_ALI_CONTROLLED; if (m_PointBarStatus[point] < BG_EY_PROGRESS_BAR_HORDE_CONTROLLED) // Point is full Horde. m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED; uint32 pointOwnerTeamId = 0; // Find which team should own this point. if (m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW) pointOwnerTeamId = HORDE; else if (m_PointBarStatus[point] >= BG_EY_PROGRESS_BAR_NEUTRAL_HIGH) pointOwnerTeamId = ALLIANCE; else pointOwnerTeamId = EY_POINT_NO_OWNER; for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i) { Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[point][i]); if (player) { UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], player); // If the point owner changed we must evoke the event! if (pointOwnerTeamId != m_PointOwnedByTeam[point]) { // The point was uncontrolled and the player is from the team which captured the point. if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && player->GetBGTeam() == pointOwnerTeamId) this->EventTeamCapturedPoint(player, point); // The point was under control andthe player isn't from the team which controlled it. if (m_PointState[point] == EY_POINT_UNDER_CONTROL && player->GetBGTeam() != m_PointOwnedByTeam[point]) this->EventTeamLostPoint(player, point); } // Fix for Fel Reaver Ruins. if (point == FEL_REAVER && m_PointOwnedByTeam[point] == player->GetBGTeam()) if (m_FlagState && GetFlagPickerGUID() == player->GetGUID()) if (player->GetDistance2d(2044.0f, 1730.0f) < 2.0f) EventPlayerCapturedFlag(player, BG_EY_OBJECT_FLAG_FEL_REAVER); } } } }
void BattlegroundEY::CheckSomeoneJoinedPoint() { GameObject* obj = NULL; for (uint8 i = 0; i < EY_POINTS_MAX; ++i) { obj = HashMapHolder<GameObject>::Find(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]); if (obj) { uint8 j = 0; while (j < m_PlayersNearPoint[EY_POINTS_MAX].size()) { Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]); if (!player) { sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY:CheckSomeoneJoinedPoint: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[EY_POINTS_MAX][j])); ++j; continue; } if (player->CanCaptureTowerPoint() && player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) { // Player joined the point! Show progress bar. UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, player); UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], player); UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, player); // Add the player to the point. m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[EY_POINTS_MAX][j]); // Remove the player from "free space". m_PlayersNearPoint[EY_POINTS_MAX].erase(m_PlayersNearPoint[EY_POINTS_MAX].begin() + j); } else ++j; } } } }
void BattlegroundEY::CheckSomeoneJoinedPoint() { GameObject* obj = NULL; for (uint8 i = 0; i < EY_POINTS_MAX; ++i) { obj = GetBgMap()->GetGameObject(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]); if (obj) { uint8 j = 0; while (j < m_PlayersNearPoint[EY_POINTS_MAX].size()) { Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]); if (!player) { TC_LOG_ERROR("bg.battleground", "BattlegroundEY:CheckSomeoneJoinedPoint: Player (%s) not found!", m_PlayersNearPoint[EY_POINTS_MAX][j].ToString().c_str()); ++j; continue; } if (player->CanCaptureTowerPoint() && player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) { //player joined point! //show progress bar UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, player); UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], player); UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, player); //add player to point m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[EY_POINTS_MAX][j]); //remove player from "free space" m_PlayersNearPoint[EY_POINTS_MAX].erase(m_PlayersNearPoint[EY_POINTS_MAX].begin() + j); } else ++j; } } } }
void BattleGroundEY::UpdatePointStatuses() { for(uint8 point = 0; point < BG_EY_NODES_MAX; ++point) { if (m_PlayersNearPoint[point].empty()) continue; //count new point bar status: m_PointBarStatus[point] += (m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] < BG_EY_POINT_MAX_CAPTURERS_COUNT) ? m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] : BG_EY_POINT_MAX_CAPTURERS_COUNT; if (m_PointBarStatus[point] > BG_EY_PROGRESS_BAR_ALI_CONTROLLED) //point is fully alliance's m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_ALI_CONTROLLED; if (m_PointBarStatus[point] < BG_EY_PROGRESS_BAR_HORDE_CONTROLLED) //point is fully horde's m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED; uint32 pointOwnerTeamId = 0; //find which team should own this point if (m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW) pointOwnerTeamId = HORDE; else if (m_PointBarStatus[point] >= BG_EY_PROGRESS_BAR_NEUTRAL_HIGH) pointOwnerTeamId = ALLIANCE; else pointOwnerTeamId = EY_POINT_NO_OWNER; for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i) { Player *plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[point][i]); if (plr) { UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], plr); //if point owner changed we must evoke event! if (pointOwnerTeamId != m_PointOwnedByTeam[point]) { //point was uncontrolled and player is from team which captured point if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && plr->GetTeam() == pointOwnerTeamId) EventTeamCapturedPoint(plr, point); //point was under control and player isn't from team which controlled it if (m_PointState[point] == EY_POINT_UNDER_CONTROL && plr->GetTeam() != m_PointOwnedByTeam[point]) EventTeamLostPoint(plr, point); } } } } }
void BattlegroundEY::CheckSomeoneLeftPoint() { // Reset current "players at point" count. for (uint8 i = 0; i < 2 * EY_POINTS_MAX; ++i) m_CurrentPointPlayersCount[i] = 0; GameObject* obj = NULL; for (uint8 i = 0; i < EY_POINTS_MAX; ++i) { obj = HashMapHolder<GameObject>::Find(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]); if (obj) { uint8 j = 0; while (j < m_PlayersNearPoint[i].size()) { Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[i][j]); if (!player) { sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundEY:CheckSomeoneLeftPoint Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[i][j])); // Move non - existing player to "free space" - this will cause many errors to be shown in log, but it is a very important bug. m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); continue; } // Move the player out of the point (Add him to the players that are out of points). if (!player->CanCaptureTowerPoint() || !player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) { m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, player); } else // The player is near the flag, so update the count. { m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(player->GetBGTeam())]++; ++j; } } } } }
void BattleGroundEY::CheckSomeoneLeftPoint() { //reset current point counts for (uint8 i = 0; i < 2*EY_POINTS_MAX; ++i) m_CurrentPointPlayersCount[i] = 0; GameObject *obj = NULL; for(uint8 i = 0; i < EY_POINTS_MAX; ++i) { obj = HashMapHolder<GameObject>::Find(m_BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REALVER + i]); if(obj) { uint8 j = 0; while (j < m_PlayersNearPoint[i].size()) { Player *plr = objmgr.GetPlayer(m_PlayersNearPoint[i][j]); if (!plr) { sLog.outError("BattleGroundEY: Player " I64FMTD " not found!", m_PlayersNearPoint[i][j]); //move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); ++j; continue; } if (!plr->isAllowUseBattleGroundObject() || !plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) //move player out of point (add him to players that are out of points { m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, plr); } else { //player is neat flag, so update count: m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(plr->GetTeam())]++; ++j; } } } } }
void BattleGroundBG::CheckSomeoneLeftPoint() { // reset current point counts for (uint8 i = 0; i < 2 * BG_BG_NODES_MAX; ++i) m_CurrentPointPlayersCount[i] = 0; for (uint8 i = 0; i < BG_BG_NODES_MAX; ++i) { uint8 j = 0; while (j < m_PlayersNearPoint[i].size()) { Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[i][j]); if (!plr) { sLog.outError("BattleGroundBG:CheckSomeoneLeftPoint %s not found!", m_PlayersNearPoint[i][j].GetString().c_str()); // move nonexistent player to "free space" - this will cause many error showing in log, but it is a very important bug m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); ++j; continue; } if (!plr->CanUseCapturePoint() || !plr->IsWithinDist3d(BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_POINT_RADIUS)) // move player out of point (add him to players that are out of points { m_PlayersNearPoint[BG_BG_PLAYERS_OUT_OF_POINTS].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); UpdateWorldStateForPlayer(BG_PROGRESS_BAR_SHOW, BG_BG_PROGRESS_BAR_DONT_SHOW, plr); } else { // player is neat flag, so update count: m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(plr->GetTeam())]++; ++j; } } } }