diff --git a/src/game/BattleGround/BattleGroundEY.cpp b/src/game/BattleGround/BattleGroundEY.cpp index 9dd6ddf63..5fc8f7922 100644 --- a/src/game/BattleGround/BattleGroundEY.cpp +++ b/src/game/BattleGround/BattleGroundEY.cpp @@ -31,16 +31,11 @@ BattleGroundEY::BattleGroundEY() { m_BuffChange = true; - m_BgObjects.resize(BG_EY_OBJECT_MAX); - - m_Points_Trigger[BG_EY_NODE_FEL_REAVER] = TR_FEL_REAVER_BUFF; - m_Points_Trigger[BG_EY_NODE_BLOOD_ELF] = TR_BLOOD_ELF_BUFF; - m_Points_Trigger[BG_EY_NODE_DRAENEI_RUINS] = TR_DRAENEI_RUINS_BUFF; - m_Points_Trigger[BG_EY_NODE_MAGE_TOWER] = TR_MAGE_TOWER_BUFF; + m_BgObjects.resize(EY_OBJECT_MAX); m_StartMessageIds[BG_STARTING_EVENT_FIRST] = 0; m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_EY_START_ONE_MINUTE; - m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_EY_START_HALF_MINUTE; + m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_EY_START_HALF_MINUTE; m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_EY_HAS_BEGUN; } @@ -52,45 +47,31 @@ void BattleGroundEY::Update(uint32 diff) { BattleGround::Update(diff); - if (GetStatus() == STATUS_IN_PROGRESS) + if (GetStatus() != STATUS_IN_PROGRESS) + return; + + // resource counter + if (m_resourceUpdateTimer < diff) { - m_PointAddingTimer -= diff; - if (m_PointAddingTimer <= 0) - { - m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME; - if (m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0) - AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]); - if (m_TeamPointsCount[BG_TEAM_HORDE] > 0) - AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]); - } + UpdateResources(); + m_resourceUpdateTimer = EY_RESOURCES_UPDATE_TIME; + } + else + m_resourceUpdateTimer -= diff; - if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND) + // flag respawn + if (m_flagState == EY_FLAG_STATE_WAIT_RESPAWN || m_flagState == EY_FLAG_STATE_ON_GROUND) + { + if (m_flagRespawnTimer < diff) { - m_FlagsTimer -= diff; - - if (m_FlagsTimer < 0) - { - m_FlagsTimer = 0; - if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN) - RespawnFlag(true); - else - RespawnFlagAfterDrop(); - } - } - - m_TowerCapCheckTimer -= diff; - if (m_TowerCapCheckTimer <= 0) - { - // check if player joined point - /*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times - but we can count of players on current point in CheckSomeoneLeftPoint - */ - CheckSomeoneJoinedPoint(); - // check if player left point - CheckSomeoneLeftPoint(); - UpdatePointStatuses(); - m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME; + m_flagRespawnTimer = 0; + if (m_flagState == EY_FLAG_STATE_WAIT_RESPAWN) + RespawnFlag(); + else + RespawnDroppedFlag(); } + else + m_flagRespawnTimer -= diff; } } @@ -103,161 +84,57 @@ void BattleGroundEY::StartingEventOpenDoors() // eye-doors are despawned, not opened SpawnEvent(BG_EVENT_DOOR, 0, false); - for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + for (uint8 i = 0; i < EY_NODES_MAX; ++i) { // randomly spawn buff uint8 buff = urand(0, 2); - SpawnBGObject(m_BgObjects[BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + buff + i * 3], RESPAWN_IMMEDIATELY); + SpawnBGObject(m_BgObjects[EY_OBJECT_SPEEDBUFF_FEL_REAVER_RUINS + buff + i * 3], RESPAWN_IMMEDIATELY); } // Players that join battleground after start are not eligible to get achievement. - StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_EY_EVENT_START_BATTLE); + StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, EY_EVENT_START_BATTLE); } void BattleGroundEY::AddPoints(Team team, uint32 points) { BattleGroundTeamIndex team_index = GetTeamIndexByTeamId(team); m_TeamScores[team_index] += points; - m_HonorScoreTics[team_index] += points; - if (m_HonorScoreTics[team_index] >= m_HonorTics) + m_honorScoreTicks[team_index] += points; + if (m_honorScoreTicks[team_index] >= m_honorTicks) { RewardHonorToTeam(GetBonusHonorFromKill(1), team); - m_HonorScoreTics[team_index] -= m_HonorTics; - } - UpdateTeamScore(team); -} - -void BattleGroundEY::CheckSomeoneJoinedPoint() -{ - for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) - { - uint8 j = 0; - while (j < m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].size()) - { - Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS][j]); - if (!plr) - { - sLog.outError("BattleGroundEY:CheckSomeoneJoinedPoint: %s not found!", m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS][j].GetString().c_str()); - ++j; - continue; - } - if (plr->CanUseCapturePoint() && - plr->IsWithinDist3d(BG_EY_NodePositions[i][0], BG_EY_NodePositions[i][1], BG_EY_NodePositions[i][2], 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[BG_EY_PLAYERS_OUT_OF_POINTS][j]); - // remove player from "free space" - m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].erase(m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].begin() + j); - } - else - ++j; - } + m_honorScoreTicks[team_index] -= m_honorTicks; } } -void BattleGroundEY::CheckSomeoneLeftPoint() +void BattleGroundEY::UpdateResources() { - // reset current point counts - for (uint8 i = 0; i < 2 * BG_EY_NODES_MAX; ++i) - m_CurrentPointPlayersCount[i] = 0; - for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + if (m_towersAlliance > 0) { - uint8 j = 0; - while (j < m_PlayersNearPoint[i].size()) - { - Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[i][j]); - if (!plr) - { - sLog.outError("BattleGroundEY: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_EY_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_EY_NodePositions[i][0], BG_EY_NodePositions[i][1], BG_EY_NodePositions[i][2], BG_EY_POINT_RADIUS)) - // move player out of point (add him to players that are out of points - { - m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].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; - } - } + AddPoints(ALLIANCE, eyTickPoints[m_towersAlliance - 1]); + UpdateTeamScore(ALLIANCE); } -} - -void BattleGroundEY::UpdatePointStatuses() -{ - for (uint8 point = 0; point < BG_EY_NODES_MAX; ++point) + if (m_towersHorde > 0) { - 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; - - Team pointOwnerTeamId; - // 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 = TEAM_NONE; - - for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i) - { - if (Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[point][i])) - { - 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); - } - } - } + AddPoints(HORDE, eyTickPoints[m_towersHorde - 1]); + UpdateTeamScore(HORDE); } } void BattleGroundEY::UpdateTeamScore(Team team) { - uint32 score = GetTeamScore(team); + uint32 score = m_TeamScores[GetTeamIndexByTeamId(team)]; - if (score >= BG_EY_MAX_TEAM_SCORE) + if (score >= EY_MAX_TEAM_SCORE) { - score = BG_EY_MAX_TEAM_SCORE; + score = EY_MAX_TEAM_SCORE; EndBattleGround(team); } if (team == ALLIANCE) - UpdateWorldState(EY_ALLIANCE_RESOURCES, score); + UpdateWorldState(WORLD_STATE_EY_RESOURCES_ALLIANCE, score); else - UpdateWorldState(EY_HORDE_RESOURCES, score); + UpdateWorldState(WORLD_STATE_EY_RESOURCES_HORDE, score); } void BattleGroundEY::EndBattleGround(Team winner) @@ -271,73 +148,146 @@ void BattleGroundEY::EndBattleGround(Team winner) RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE); RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE); + // disable capture points + for (uint8 i = 0; i < EY_NODES_MAX; ++i) + if (GameObject* go = GetBgMap()->GetGameObject(m_towers[i])) + go->SetLootState(GO_JUST_DEACTIVATED); + BattleGround::EndBattleGround(winner); } -void BattleGroundEY::UpdatePointsCount(Team team) -{ - if (team == ALLIANCE) - UpdateWorldState(EY_ALLIANCE_BASE, m_TeamPointsCount[BG_TEAM_ALLIANCE]); - else - UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]); -} - -void BattleGroundEY::UpdatePointsIcons(Team team, uint32 point) -{ - if (m_PointState[point] == EY_POINT_UNDER_CONTROL) - { - UpdateWorldState(PointsIconStruct[point].WorldStateControlIndex, WORLD_STATE_REMOVE); - if (team == ALLIANCE) - UpdateWorldState(PointsIconStruct[point].WorldStateAllianceControlledIndex, WORLD_STATE_ADD); - else - UpdateWorldState(PointsIconStruct[point].WorldStateHordeControlledIndex, WORLD_STATE_ADD); - } - else - { - if (team == ALLIANCE) - UpdateWorldState(PointsIconStruct[point].WorldStateAllianceControlledIndex, WORLD_STATE_REMOVE); - else - UpdateWorldState(PointsIconStruct[point].WorldStateHordeControlledIndex, WORLD_STATE_REMOVE); - - UpdateWorldState(PointsIconStruct[point].WorldStateControlIndex, WORLD_STATE_ADD); - } -} - void BattleGroundEY::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); // create score and add it to map BattleGroundEYScore* sc = new BattleGroundEYScore; - m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].push_back(plr->GetObjectGuid()); - m_PlayerScores[plr->GetObjectGuid()] = sc; } void BattleGroundEY::RemovePlayer(Player* plr, ObjectGuid guid) { // sometimes flag aura not removed :( - for (uint8 j = BG_EY_NODES_MAX; j >= 0; --j) + if (IsFlagPickedUp()) { - for (size_t i = 0; i < m_PlayersNearPoint[j].size(); ++i) - if (m_PlayersNearPoint[j][i] == guid) - m_PlayersNearPoint[j].erase(m_PlayersNearPoint[j].begin() + i); - } - if (IsFlagPickedup()) - { - if (m_FlagKeeper == guid) + if (m_flagCarrier == guid) { if (plr) EventPlayerDroppedFlag(plr); else { - ClearFlagPicker(); - RespawnFlag(true); + ClearFlagCarrier(); + RespawnFlag(); } } } } +void BattleGroundEY::HandleGameObjectCreate(GameObject* go) +{ + // set initial data and activate capture points + switch (go->GetEntry()) + { + case GO_CAPTURE_POINT_BLOOD_ELF_TOWER: + m_towers[NODE_BLOOD_ELF_TOWER] = go->GetObjectGuid(); + go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + break; + case GO_CAPTURE_POINT_FEL_REAVER_RUINS: + m_towers[NODE_FEL_REAVER_RUINS] = go->GetObjectGuid(); + go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + break; + case GO_CAPTURE_POINT_MAGE_TOWER: + m_towers[NODE_MAGE_TOWER] = go->GetObjectGuid(); + go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + break; + case GO_CAPTURE_POINT_DRAENEI_RUINS: + m_towers[NODE_DRAENEI_RUINS] = go->GetObjectGuid(); + go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + break; + } +} + +// process the capture events +bool BattleGroundEY::HandleEvent(uint32 eventId, GameObject* go) +{ + for (uint8 i = 0; i < EY_NODES_MAX; ++i) + { + if (eyTowers[i] == go->GetEntry()) + { + for (uint8 j = 0; j < 4; ++j) + { + if (eyTowerEvents[i][j].eventEntry == eventId) + { + ProcessCaptureEvent(go, i, eyTowerEvents[i][j].team, eyTowerEvents[i][j].worldState, eyTowerEvents[i][j].message); + + // no need to iterate other events or towers + return false; + } + } + // no need to iterate other towers + return false; + } + } + + return false; +} + +void BattleGroundEY::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team, uint32 newWorldState, uint32 message) +{ + if (team == ALLIANCE) + { + // update counter + ++m_towersAlliance; + UpdateWorldState(WORLD_STATE_EY_TOWER_COUNT_ALLIANCE, m_towersAlliance); + + SendMessageToAll(message, CHAT_MSG_BG_SYSTEM_ALLIANCE); + + // spawn gameobjects + SpawnEvent(towerId, BG_TEAM_ALLIANCE, true); + } + else if (team == HORDE) + { + // update counter + ++m_towersHorde; + UpdateWorldState(WORLD_STATE_EY_TOWER_COUNT_HORDE, m_towersHorde); + + SendMessageToAll(message, CHAT_MSG_BG_SYSTEM_HORDE); + + // spawn gameobjects + SpawnEvent(towerId, BG_TEAM_HORDE, true); + } + else + { + if (m_towerOwner[towerId] == ALLIANCE) + { + // update counter + --m_towersAlliance; + UpdateWorldState(WORLD_STATE_EY_TOWER_COUNT_ALLIANCE, m_towersAlliance); + + SendMessageToAll(message, CHAT_MSG_BG_SYSTEM_ALLIANCE); + } + else + { + // update counter + --m_towersHorde; + UpdateWorldState(WORLD_STATE_EY_TOWER_COUNT_HORDE, m_towersHorde); + + SendMessageToAll(message, CHAT_MSG_BG_SYSTEM_HORDE); + } + + // despawn gameobjects + SpawnEvent(towerId, EY_NEUTRAL_TEAM, true); + } + + // update tower state + UpdateWorldState(m_towerWorldState[towerId], WORLD_STATE_REMOVE); + m_towerWorldState[towerId] = newWorldState; + UpdateWorldState(m_towerWorldState[towerId], WORLD_STATE_ADD); + + // update capture point owner + m_towerOwner[towerId] = team; +} + void BattleGroundEY::HandleAreaTrigger(Player* source, uint32 trigger) { if (GetStatus() != STATUS_IN_PROGRESS) @@ -348,41 +298,21 @@ void BattleGroundEY::HandleAreaTrigger(Player* source, uint32 trigger) switch (trigger) { - case TR_BLOOD_ELF_POINT: - if (m_PointState[BG_EY_NODE_BLOOD_ELF] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BG_EY_NODE_BLOOD_ELF] == source->GetTeam()) - if (m_FlagState && GetFlagPickerGuid() == source->GetObjectGuid()) - EventPlayerCapturedFlag(source, BG_EY_NODE_BLOOD_ELF); + case AREATRIGGER_BLOOD_ELF_TOWER_POINT: + if (m_towerOwner[NODE_BLOOD_ELF_TOWER] == source->GetTeam()) + EventPlayerCapturedFlag(source, NODE_BLOOD_ELF_TOWER); break; - case TR_FEL_REAVER_POINT: - if (m_PointState[BG_EY_NODE_FEL_REAVER] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BG_EY_NODE_FEL_REAVER] == source->GetTeam()) - if (m_FlagState && GetFlagPickerGuid() == source->GetObjectGuid()) - EventPlayerCapturedFlag(source, BG_EY_NODE_FEL_REAVER); + case AREATRIGGER_FEL_REAVER_RUINS_POINT: + if (m_towerOwner[NODE_FEL_REAVER_RUINS] == source->GetTeam()) + EventPlayerCapturedFlag(source, NODE_FEL_REAVER_RUINS); break; - case TR_MAGE_TOWER_POINT: - if (m_PointState[BG_EY_NODE_MAGE_TOWER] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BG_EY_NODE_MAGE_TOWER] == source->GetTeam()) - if (m_FlagState && GetFlagPickerGuid() == source->GetObjectGuid()) - EventPlayerCapturedFlag(source, BG_EY_NODE_MAGE_TOWER); + case AREATRIGGER_MAGE_TOWER_POINT: + if (m_towerOwner[NODE_MAGE_TOWER] == source->GetTeam()) + EventPlayerCapturedFlag(source, NODE_MAGE_TOWER); break; - case TR_DRAENEI_RUINS_POINT: - if (m_PointState[BG_EY_NODE_DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BG_EY_NODE_DRAENEI_RUINS] == source->GetTeam()) - if (m_FlagState && GetFlagPickerGuid() == source->GetObjectGuid()) - EventPlayerCapturedFlag(source, BG_EY_NODE_DRAENEI_RUINS); - break; - case 4512: - case 4515: - case 4517: - case 4519: - case 4530: - case 4531: - case 4568: - case 4569: - case 4570: - case 4571: - case 5866: - break; - default: - sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", trigger); - source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger); + case AREATRIGGER_DRAENEI_RUINS_POINT: + if (m_towerOwner[NODE_DRAENEI_RUINS] == source->GetTeam()) + EventPlayerCapturedFlag(source, NODE_DRAENEI_RUINS); break; } } @@ -390,18 +320,17 @@ void BattleGroundEY::HandleAreaTrigger(Player* source, uint32 trigger) bool BattleGroundEY::SetupBattleGround() { // buffs - for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + for (uint8 i = 0; i < EY_NODES_MAX; ++i) { - AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(m_Points_Trigger[i]); + AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(eyTriggers[i]); if (!at) { - sLog.outError("BattleGroundEY: Unknown trigger: %u", m_Points_Trigger[i]); + sLog.outError("BattleGroundEY: Unknown trigger: %u", eyTriggers[i]); continue; } - if (!AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3, Buff_Entries[0], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) - || !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 1, Buff_Entries[1], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) - || !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 2, Buff_Entries[2], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) - ) + if (!AddObject(EY_OBJECT_SPEEDBUFF_FEL_REAVER_RUINS + i * 3, Buff_Entries[0], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) + || !AddObject(EY_OBJECT_SPEEDBUFF_FEL_REAVER_RUINS + i * 3 + 1, Buff_Entries[1], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) + || !AddObject(EY_OBJECT_SPEEDBUFF_FEL_REAVER_RUINS + i * 3 + 2, Buff_Entries[2], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY)) sLog.outError("BattleGroundEY: Cannot spawn buff"); } @@ -415,52 +344,51 @@ void BattleGroundEY::Reset() m_TeamScores[BG_TEAM_ALLIANCE] = 0; m_TeamScores[BG_TEAM_HORDE] = 0; - m_TeamPointsCount[BG_TEAM_ALLIANCE] = 0; - m_TeamPointsCount[BG_TEAM_HORDE] = 0; - m_HonorScoreTics[BG_TEAM_ALLIANCE] = 0; - m_HonorScoreTics[BG_TEAM_HORDE] = 0; - m_FlagState = BG_EY_FLAG_STATE_ON_BASE; - m_FlagKeeper.Clear(); + + m_towersAlliance = 0; + m_towersHorde = 0; + + m_honorTicks = BattleGroundMgr::IsBGWeekend(GetTypeID()) ? EY_WEEKEND_HONOR_TICKS : EY_NORMAL_HONOR_TICKS; + m_honorScoreTicks[BG_TEAM_ALLIANCE] = 0; + m_honorScoreTicks[BG_TEAM_HORDE] = 0; + + m_flagState = EY_FLAG_STATE_ON_BASE; + m_flagCarrier.Clear(); m_DroppedFlagGuid.Clear(); - m_PointAddingTimer = 0; - m_TowerCapCheckTimer = 0; - bool isBGWeekend = BattleGroundMgr::IsBGWeekend(GetTypeID()); - m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks; - for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + m_flagRespawnTimer = 0; + m_resourceUpdateTimer = 0; + + m_towerWorldState[NODE_BLOOD_ELF_TOWER] = WORLD_STATE_EY_BLOOD_ELF_TOWER_NEUTRAL; + m_towerWorldState[NODE_FEL_REAVER_RUINS] = WORLD_STATE_EY_FEL_REAVER_RUINS_NEUTRAL; + m_towerWorldState[NODE_MAGE_TOWER] = WORLD_STATE_EY_MAGE_TOWER_NEUTRAL; + m_towerWorldState[NODE_DRAENEI_RUINS] = WORLD_STATE_EY_DRAENEI_RUINS_NEUTRAL; + + for (uint8 i = 0; i < EY_NODES_MAX; ++i) { - m_PointOwnedByTeam[i] = TEAM_NONE; - m_PointState[i] = EY_POINT_STATE_UNCONTROLLED; - m_PointBarStatus[i] = BG_EY_PROGRESS_BAR_STATE_MIDDLE; - m_PlayersNearPoint[i].clear(); - m_PlayersNearPoint[i].reserve(15); // tip size - m_ActiveEvents[i] = BG_EYE_NEUTRAL_TEAM; // neutral team owns every node + m_towerOwner[i] = TEAM_NONE; + m_ActiveEvents[i] = EY_NEUTRAL_TEAM; } + // the flag in the middle is spawned at beginning - m_ActiveEvents[BG_EY_EVENT_CAPTURE_FLAG] = BG_EY_EVENT2_FLAG_CENTER; - - m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].clear(); - m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].reserve(30); + m_ActiveEvents[EY_EVENT_CAPTURE_FLAG] = EY_EVENT2_FLAG_CENTER; } -void BattleGroundEY::RespawnFlag(bool send_message) +void BattleGroundEY::RespawnFlag() { - m_FlagState = BG_EY_FLAG_STATE_ON_BASE; + m_flagState = EY_FLAG_STATE_ON_BASE; // will despawn captured flags at the node and spawn in center - SpawnEvent(BG_EY_EVENT_CAPTURE_FLAG, BG_EY_EVENT2_FLAG_CENTER, true); + SpawnEvent(EY_EVENT_CAPTURE_FLAG, EY_EVENT2_FLAG_CENTER, true); - if (send_message) - { - SendMessageToAll(LANG_BG_EY_RESETED_FLAG, CHAT_MSG_BG_SYSTEM_NEUTRAL); - PlaySoundToAll(BG_EY_SOUND_FLAG_RESET); // flags respawned sound... - } + PlaySoundToAll(EY_SOUND_FLAG_RESET); + SendMessageToAll(LANG_BG_EY_RESETED_FLAG, CHAT_MSG_BG_SYSTEM_NEUTRAL); - UpdateWorldState(NETHERSTORM_FLAG, WORLD_STATE_ADD); + UpdateWorldState(WORLD_STATE_EY_NETHERSTORM_FLAG_READY, WORLD_STATE_ADD); } -void BattleGroundEY::RespawnFlagAfterDrop() +void BattleGroundEY::RespawnDroppedFlag() { - RespawnFlag(true); + RespawnFlag(); GameObject* obj = GetBgMap()->GetGameObject(GetDroppedFlagGuid()); if (obj) @@ -486,62 +414,68 @@ void BattleGroundEY::EventPlayerDroppedFlag(Player* source) { // if not running, do not cast things at the dropper player, neither send unnecessary messages // just take off the aura - if (IsFlagPickedup() && GetFlagPickerGuid() == source->GetObjectGuid()) + if (IsFlagPickedUp() && GetFlagCarrierGuid() == source->GetObjectGuid()) { - ClearFlagPicker(); - source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); + ClearFlagCarrier(); + source->RemoveAurasDueToSpell(EY_NETHERSTORM_FLAG_SPELL); } return; } - if (!IsFlagPickedup()) + if (!IsFlagPickedUp()) return; - if (GetFlagPickerGuid() != source->GetObjectGuid()) + if (GetFlagCarrierGuid() != source->GetObjectGuid()) return; - ClearFlagPicker(); - source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); - m_FlagState = BG_EY_FLAG_STATE_ON_GROUND; - m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME; + ClearFlagCarrier(); + source->RemoveAurasDueToSpell(EY_NETHERSTORM_FLAG_SPELL); + m_flagState = EY_FLAG_STATE_ON_GROUND; + m_flagRespawnTimer = EY_FLAG_RESPAWN_TIME; source->CastSpell(source, SPELL_RECENTLY_DROPPED_FLAG, true); - source->CastSpell(source, BG_EY_PLAYER_DROPPED_FLAG_SPELL, true); - // this does not work correctly :( (it should remove flag carrier name) - UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_WAIT_RESPAWN); - UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_WAIT_RESPAWN); + source->CastSpell(source, EY_PLAYER_DROPPED_FLAG_SPELL, true); if (source->GetTeam() == ALLIANCE) + { + UpdateWorldState(WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_ALLIANCE, 1); SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL); + } else + { + UpdateWorldState(WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_HORDE, 1); SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL); + } } void BattleGroundEY::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { - if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !source->IsWithinDistInMap(target_obj, 10)) + if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedUp() || !source->IsWithinDistInMap(target_obj, 10)) return; + if (m_flagState == EY_FLAG_STATE_ON_BASE) + UpdateWorldState(WORLD_STATE_EY_NETHERSTORM_FLAG_READY, WORLD_STATE_REMOVE); + if (source->GetTeam() == ALLIANCE) { - UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_ON_PLAYER); - PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE); + PlaySoundToAll(EY_SOUND_FLAG_PICKED_UP_ALLIANCE); + + m_flagState = EY_FLAG_STATE_ON_ALLIANCE_PLAYER; + UpdateWorldState(WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_ALLIANCE, 2); } else { - UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_ON_PLAYER); - PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_HORDE); + PlaySoundToAll(EY_SOUND_FLAG_PICKED_UP_HORDE); + + m_flagState = EY_FLAG_STATE_ON_HORDE_PLAYER; + UpdateWorldState(WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_HORDE, 2); } - if (m_FlagState == BG_EY_FLAG_STATE_ON_BASE) - UpdateWorldState(NETHERSTORM_FLAG, WORLD_STATE_REMOVE); - m_FlagState = BG_EY_FLAG_STATE_ON_PLAYER; - // despawn center-flag - SpawnEvent(BG_EY_EVENT_CAPTURE_FLAG, BG_EY_EVENT2_FLAG_CENTER, false); + SpawnEvent(EY_EVENT_CAPTURE_FLAG, EY_EVENT2_FLAG_CENTER, false); - SetFlagPicker(source->GetObjectGuid()); + SetFlagCarrier(source->GetObjectGuid()); // get flag aura on player - source->CastSpell(source, BG_EY_NETHERSTORM_FLAG_SPELL, true); + source->CastSpell(source, EY_NETHERSTORM_FLAG_SPELL, true); source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); if (source->GetTeam() == ALLIANCE) @@ -550,98 +484,39 @@ void BattleGroundEY::EventPlayerClickedOnFlag(Player* source, GameObject* target PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, source->GetName()); } -void BattleGroundEY::EventTeamLostPoint(Player* source, uint32 point) +void BattleGroundEY::EventPlayerCapturedFlag(Player* source, EYNodes node) { - if (GetStatus() != STATUS_IN_PROGRESS) + if (GetStatus() != STATUS_IN_PROGRESS || GetFlagCarrierGuid() != source->GetObjectGuid()) return; - // neutral node - Team team = m_PointOwnedByTeam[point]; + ClearFlagCarrier(); - if (!team) - return; - - if (team == ALLIANCE) - --m_TeamPointsCount[BG_TEAM_ALLIANCE]; - else - --m_TeamPointsCount[BG_TEAM_HORDE]; - - // it's important to set the OwnedBy before despawning spiritguides, else - // player won't get teleported away - m_PointOwnedByTeam[point] = TEAM_NONE; - m_PointState[point] = EY_POINT_NO_OWNER; - - SpawnEvent(point, BG_EYE_NEUTRAL_TEAM, true); // will despawn alliance/horde - - // buff isn't despawned - - if (team == ALLIANCE) - SendMessageToAll(LoosingPointTypes[point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); - else - SendMessageToAll(LoosingPointTypes[point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, source); - - UpdatePointsIcons(team, point); - UpdatePointsCount(team); -} - -void BattleGroundEY::EventTeamCapturedPoint(Player* source, uint32 point) -{ - if (GetStatus() != STATUS_IN_PROGRESS) - return; - - Team team = source->GetTeam(); - - ++m_TeamPointsCount[GetTeamIndexByTeamId(team)]; - SpawnEvent(point, GetTeamIndexByTeamId(team), true); - - // buff isn't respawned - - m_PointOwnedByTeam[point] = team; - m_PointState[point] = EY_POINT_UNDER_CONTROL; - - if (team == ALLIANCE) - SendMessageToAll(CapturingPointTypes[point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); - else - SendMessageToAll(CapturingPointTypes[point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, source); - - UpdatePointsIcons(team, point); - UpdatePointsCount(team); -} - -void BattleGroundEY::EventPlayerCapturedFlag(Player* source, BG_EY_Nodes node) -{ - if (GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGuid() != source->GetObjectGuid()) - return; - - ClearFlagPicker(); - m_FlagState = BG_EY_FLAG_STATE_WAIT_RESPAWN; - source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); + m_flagState = EY_FLAG_STATE_WAIT_RESPAWN; + m_flagRespawnTimer = EY_FLAG_RESPAWN_TIME; + source->RemoveAurasDueToSpell(EY_NETHERSTORM_FLAG_SPELL); source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); - if (source->GetTeam() == ALLIANCE) - PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE); - else - PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_HORDE); - - SpawnEvent(BG_EY_EVENT_CAPTURE_FLAG, node, true); - - m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME; - - BattleGroundTeamIndex team_id; if (source->GetTeam() == ALLIANCE) { - team_id = BG_TEAM_ALLIANCE; + PlaySoundToAll(EY_SOUND_FLAG_CAPTURED_ALLIANCE); + + if (m_towersAlliance > 0) + AddPoints(ALLIANCE, eyFlagPoints[m_towersAlliance - 1]); + SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_A, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); } else { - team_id = BG_TEAM_HORDE; + PlaySoundToAll(EY_SOUND_FLAG_CAPTURED_HORDE); + + if (m_towersHorde > 0) + AddPoints(HORDE, eyFlagPoints[m_towersHorde - 1]); + SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_H, CHAT_MSG_BG_SYSTEM_HORDE, source); } - if (m_TeamPointsCount[team_id] > 0) - AddPoints(source->GetTeam(), BG_EY_FlagPoints[m_TeamPointsCount[team_id] - 1]); + SpawnEvent(EY_EVENT_CAPTURE_FLAG, node, true); UpdatePlayerScore(source, SCORE_FLAG_CAPTURES, 1); } @@ -665,39 +540,38 @@ void BattleGroundEY::UpdatePlayerScore(Player* source, uint32 type, uint32 value void BattleGroundEY::FillInitialWorldStates(WorldPacket& data, uint32& count) { - FillInitialWorldState(data, count, EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]); - FillInitialWorldState(data, count, EY_ALLIANCE_BASE, m_TeamPointsCount[BG_TEAM_ALLIANCE]); - FillInitialWorldState(data, count, 0xab6, 0x0); - FillInitialWorldState(data, count, 0xab5, 0x0); - FillInitialWorldState(data, count, 0xab4, 0x0); - FillInitialWorldState(data, count, 0xab3, 0x0); - FillInitialWorldState(data, count, 0xab2, 0x0); - FillInitialWorldState(data, count, 0xab1, 0x0); - FillInitialWorldState(data, count, 0xab0, 0x0); - FillInitialWorldState(data, count, 0xaaf, 0x0); + // counter states + FillInitialWorldState(data, count, WORLD_STATE_EY_TOWER_COUNT_ALLIANCE, m_towersAlliance); + FillInitialWorldState(data, count, WORLD_STATE_EY_TOWER_COUNT_HORDE, m_towersHorde); - FillInitialWorldState(data, count, DRAENEI_RUINS_HORDE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_DRAENEI_RUINS] == HORDE && m_PointState[BG_EY_NODE_DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, DRAENEI_RUINS_ALLIANCE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_DRAENEI_RUINS] == ALLIANCE && m_PointState[BG_EY_NODE_DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, DRAENEI_RUINS_UNCONTROL, m_PointState[BG_EY_NODE_DRAENEI_RUINS] != EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, MAGE_TOWER_ALLIANCE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_MAGE_TOWER] == ALLIANCE && m_PointState[BG_EY_NODE_MAGE_TOWER] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, MAGE_TOWER_HORDE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_MAGE_TOWER] == HORDE && m_PointState[BG_EY_NODE_MAGE_TOWER] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, MAGE_TOWER_UNCONTROL, m_PointState[BG_EY_NODE_MAGE_TOWER] != EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, FEL_REAVER_HORDE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_FEL_REAVER] == HORDE && m_PointState[BG_EY_NODE_FEL_REAVER] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, FEL_REAVER_ALLIANCE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_FEL_REAVER] == ALLIANCE && m_PointState[BG_EY_NODE_FEL_REAVER] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, FEL_REAVER_UNCONTROL, m_PointState[BG_EY_NODE_FEL_REAVER] != EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, BLOOD_ELF_HORDE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_BLOOD_ELF] == HORDE && m_PointState[BG_EY_NODE_BLOOD_ELF] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, BLOOD_ELF_ALLIANCE_CONTROL, m_PointOwnedByTeam[BG_EY_NODE_BLOOD_ELF] == ALLIANCE && m_PointState[BG_EY_NODE_BLOOD_ELF] == EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, BLOOD_ELF_UNCONTROL, m_PointState[BG_EY_NODE_BLOOD_ELF] != EY_POINT_UNDER_CONTROL); - FillInitialWorldState(data, count, NETHERSTORM_FLAG, m_FlagState == BG_EY_FLAG_STATE_ON_BASE); - FillInitialWorldState(data, count, 0xad2, 0x1); - FillInitialWorldState(data, count, 0xad1, 0x1); - FillInitialWorldState(data, count, 0xabe, GetTeamScore(HORDE)); - FillInitialWorldState(data, count, 0xabd, GetTeamScore(ALLIANCE)); - FillInitialWorldState(data, count, 0xa05, 0x8e); - FillInitialWorldState(data, count, 0xaa0, 0x0); - FillInitialWorldState(data, count, 0xa9f, 0x0); - FillInitialWorldState(data, count, 0xa9e, 0x0); - FillInitialWorldState(data, count, 0xc0d, 0x17b); + FillInitialWorldState(data, count, WORLD_STATE_EY_RESOURCES_ALLIANCE, m_TeamScores[BG_TEAM_ALLIANCE]); + FillInitialWorldState(data, count, WORLD_STATE_EY_RESOURCES_HORDE, m_TeamScores[BG_TEAM_HORDE]); + + // tower world states + FillInitialWorldState(data, count, WORLD_STATE_EY_BLOOD_ELF_TOWER_ALLIANCE, m_towerOwner[NODE_BLOOD_ELF_TOWER] == ALLIANCE); + FillInitialWorldState(data, count, WORLD_STATE_EY_BLOOD_ELF_TOWER_HORDE, m_towerOwner[NODE_BLOOD_ELF_TOWER] == HORDE); + FillInitialWorldState(data, count, WORLD_STATE_EY_BLOOD_ELF_TOWER_NEUTRAL, m_towerOwner[NODE_BLOOD_ELF_TOWER] == TEAM_NONE); + + FillInitialWorldState(data, count, WORLD_STATE_EY_FEL_REAVER_RUINS_ALLIANCE, m_towerOwner[NODE_FEL_REAVER_RUINS] == ALLIANCE); + FillInitialWorldState(data, count, WORLD_STATE_EY_FEL_REAVER_RUINS_HORDE, m_towerOwner[NODE_FEL_REAVER_RUINS] == HORDE); + FillInitialWorldState(data, count, WORLD_STATE_EY_FEL_REAVER_RUINS_NEUTRAL, m_towerOwner[NODE_FEL_REAVER_RUINS] == TEAM_NONE); + + FillInitialWorldState(data, count, WORLD_STATE_EY_MAGE_TOWER_ALLIANCE, m_towerOwner[NODE_MAGE_TOWER] == ALLIANCE); + FillInitialWorldState(data, count, WORLD_STATE_EY_MAGE_TOWER_HORDE, m_towerOwner[NODE_MAGE_TOWER] == HORDE); + FillInitialWorldState(data, count, WORLD_STATE_EY_MAGE_TOWER_NEUTRAL, m_towerOwner[NODE_MAGE_TOWER] == TEAM_NONE); + + FillInitialWorldState(data, count, WORLD_STATE_EY_DRAENEI_RUINS_ALLIANCE, m_towerOwner[NODE_DRAENEI_RUINS] == ALLIANCE); + FillInitialWorldState(data, count, WORLD_STATE_EY_DRAENEI_RUINS_HORDE, m_towerOwner[NODE_DRAENEI_RUINS] == HORDE); + FillInitialWorldState(data, count, WORLD_STATE_EY_DRAENEI_RUINS_NEUTRAL, m_towerOwner[NODE_DRAENEI_RUINS] == TEAM_NONE); + + // flag states + FillInitialWorldState(data, count, WORLD_STATE_EY_NETHERSTORM_FLAG_READY, m_flagState == EY_FLAG_STATE_ON_BASE); + FillInitialWorldState(data, count, WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_ALLIANCE, m_flagState == EY_FLAG_STATE_ON_ALLIANCE_PLAYER ? 2 : 1); + FillInitialWorldState(data, count, WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_HORDE, m_flagState == EY_FLAG_STATE_ON_HORDE_PLAYER ? 2 : 1); + + // capture point states + // if you leave the bg while being in capture point radius - and later join same type of bg the slider would still be displayed because the client caches it + FillInitialWorldState(data, count, WORLD_STATE_EY_CAPTURE_POINT_SLIDER_DISPLAY, WORLD_STATE_REMOVE); } WorldSafeLocsEntry const* BattleGroundEY::GetClosestGraveYard(Player* player) @@ -706,8 +580,8 @@ WorldSafeLocsEntry const* BattleGroundEY::GetClosestGraveYard(Player* player) switch (player->GetTeam()) { - case ALLIANCE: g_id = EY_GRAVEYARD_MAIN_ALLIANCE; break; - case HORDE: g_id = EY_GRAVEYARD_MAIN_HORDE; break; + case ALLIANCE: g_id = GRAVEYARD_EY_MAIN_ALLIANCE; break; + case HORDE: g_id = GRAVEYARD_EY_MAIN_HORDE; break; default: return NULL; } @@ -732,13 +606,13 @@ WorldSafeLocsEntry const* BattleGroundEY::GetClosestGraveYard(Player* player) distance = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y) + (entry->z - plr_z) * (entry->z - plr_z); nearestDistance = distance; - for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + for (uint8 i = 0; i < EY_NODES_MAX; ++i) { - if (m_PointOwnedByTeam[i] == player->GetTeam() && m_PointState[i] == EY_POINT_UNDER_CONTROL) + if (m_towerOwner[i] == player->GetTeam()) { - entry = sWorldSafeLocsStore.LookupEntry(CapturingPointTypes[i].GraveYardId); + entry = sWorldSafeLocsStore.LookupEntry(eyGraveyards[i]); if (!entry) - sLog.outError("BattleGroundEY: Not found graveyard: %u", CapturingPointTypes[i].GraveYardId); + sLog.outError("BattleGroundEY: Not found graveyard: %u", eyGraveyards[i]); else { distance = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y) + (entry->z - plr_z) * (entry->z - plr_z); @@ -756,8 +630,8 @@ WorldSafeLocsEntry const* BattleGroundEY::GetClosestGraveYard(Player* player) bool BattleGroundEY::IsAllNodesControlledByTeam(Team team) const { - for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) - if (m_PointState[i] != EY_POINT_UNDER_CONTROL || m_PointOwnedByTeam[i] != team) + for (uint8 i = 0; i < EY_NODES_MAX; ++i) + if (m_towerOwner[i] != team) return false; return true; diff --git a/src/game/BattleGround/BattleGroundEY.h b/src/game/BattleGround/BattleGroundEY.h index 517e2ea21..6c886cdb1 100644 --- a/src/game/BattleGround/BattleGroundEY.h +++ b/src/game/BattleGround/BattleGroundEY.h @@ -23,215 +23,225 @@ class BattleGround; -#define BG_EY_FLAG_RESPAWN_TIME (10*IN_MILLISECONDS)//10 seconds -#define BG_EY_FPOINTS_TICK_TIME (2*IN_MILLISECONDS) //2 seconds +#define EY_FLAG_RESPAWN_TIME (10 * IN_MILLISECONDS) //10 seconds +#define EY_RESOURCES_UPDATE_TIME (2 * IN_MILLISECONDS) //2 seconds -enum BG_EY_WorldStates +enum EYWorldStates { - EY_ALLIANCE_RESOURCES = 2749, - EY_HORDE_RESOURCES = 2750, - EY_ALLIANCE_BASE = 2752, - EY_HORDE_BASE = 2753, - DRAENEI_RUINS_HORDE_CONTROL = 2733, - DRAENEI_RUINS_ALLIANCE_CONTROL = 2732, - DRAENEI_RUINS_UNCONTROL = 2731, - MAGE_TOWER_ALLIANCE_CONTROL = 2730, - MAGE_TOWER_HORDE_CONTROL = 2729, - MAGE_TOWER_UNCONTROL = 2728, - FEL_REAVER_HORDE_CONTROL = 2727, - FEL_REAVER_ALLIANCE_CONTROL = 2726, - FEL_REAVER_UNCONTROL = 2725, - BLOOD_ELF_HORDE_CONTROL = 2724, - BLOOD_ELF_ALLIANCE_CONTROL = 2723, - BLOOD_ELF_UNCONTROL = 2722, - PROGRESS_BAR_PERCENT_GREY = 2720, //100 = empty (only grey), 0 = blue|red (no grey) - PROGRESS_BAR_STATUS = 2719, //50 init!, 48 ... hordak bere .. 33 .. 0 = full 100% hordacky , 100 = full alliance - PROGRESS_BAR_SHOW = 2718, //1 init, 0 druhy send - bez messagu, 1 = controlled alliance - NETHERSTORM_FLAG = 2757, - // set to 2 when flag is picked up, and to 1 if it is dropped - NETHERSTORM_FLAG_STATE_ALLIANCE = 2769, - NETHERSTORM_FLAG_STATE_HORDE = 2770 + WORLD_STATE_EY_RESOURCES_ALLIANCE = 2749, + WORLD_STATE_EY_RESOURCES_HORDE = 2750, + WORLD_STATE_EY_TOWER_COUNT_ALLIANCE = 2752, + WORLD_STATE_EY_TOWER_COUNT_HORDE = 2753, + + WORLD_STATE_EY_BLOOD_ELF_TOWER_ALLIANCE = 2723, + WORLD_STATE_EY_BLOOD_ELF_TOWER_HORDE = 2724, + WORLD_STATE_EY_BLOOD_ELF_TOWER_NEUTRAL = 2722, + //WORLD_STATE_EY_BLOOD_ELF_TOWER_ALLIANCE_CONFLICT = 2735, // unused on retail + //WORLD_STATE_EY_BLOOD_ELF_TOWER_HORDE_CONFLICT = 2736, // unused on retail + + WORLD_STATE_EY_FEL_REAVER_RUINS_ALLIANCE = 2726, + WORLD_STATE_EY_FEL_REAVER_RUINS_HORDE = 2727, + WORLD_STATE_EY_FEL_REAVER_RUINS_NEUTRAL = 2725, + //WORLD_STATE_EY_FEL_REAVER_RUINS_ALLIANCE_CONFLICT = 2739, // unused on retail + //WORLD_STATE_EY_FEL_REAVER_RUINS_HORDE_CONFLICT = 2740, // unused on retail + + WORLD_STATE_EY_MAGE_TOWER_ALLIANCE = 2730, + WORLD_STATE_EY_MAGE_TOWER_HORDE = 2729, + WORLD_STATE_EY_MAGE_TOWER_NEUTRAL = 2728, + //WORLD_STATE_EY_MAGE_TOWER_ALLIANCE_CONFLICT = 2741, // unused on retail + //WORLD_STATE_EY_MAGE_TOWER_HORDE_CONFLICT = 2742, // unused on retail + + WORLD_STATE_EY_DRAENEI_RUINS_ALLIANCE = 2732, + WORLD_STATE_EY_DRAENEI_RUINS_HORDE = 2733, + WORLD_STATE_EY_DRAENEI_RUINS_NEUTRAL = 2731, + //WORLD_STATE_EY_DRAENEI_RUINS_ALLIANCE_CONFLICT = 2738, // unused on retail + //WORLD_STATE_EY_DRAENEI_RUINS_HORDE_CONFLICT = 2737, // unused on retail + + WORLD_STATE_EY_NETHERSTORM_FLAG_READY = 2757, + WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_ALLIANCE = 2769, + WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_HORDE = 2770, + + WORLD_STATE_EY_CAPTURE_POINT_SLIDER_DISPLAY = 2718 }; -enum BG_EY_ProgressBarConsts +enum EYCapturePoints { - BG_EY_POINT_MAX_CAPTURERS_COUNT = 5, - BG_EY_POINT_RADIUS = 70, - BG_EY_PROGRESS_BAR_DONT_SHOW = 0, - BG_EY_PROGRESS_BAR_SHOW = 1, - BG_EY_PROGRESS_BAR_PERCENT_GREY = 40, - BG_EY_PROGRESS_BAR_STATE_MIDDLE = 50, - BG_EY_PROGRESS_BAR_HORDE_CONTROLLED = 0, - BG_EY_PROGRESS_BAR_NEUTRAL_LOW = 30, - BG_EY_PROGRESS_BAR_NEUTRAL_HIGH = 70, - BG_EY_PROGRESS_BAR_ALI_CONTROLLED = 100 + GO_CAPTURE_POINT_BLOOD_ELF_TOWER = 184080, + GO_CAPTURE_POINT_FEL_REAVER_RUINS = 184081, + GO_CAPTURE_POINT_MAGE_TOWER = 184082, + GO_CAPTURE_POINT_DRAENEI_RUINS = 184083 }; -enum BG_EY_Sounds +enum EYEvents { - // strange ids, but sure about them - BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE = 8212, - BG_EY_SOUND_FLAG_CAPTURED_HORDE = 8213, - BG_EY_SOUND_FLAG_PICKED_UP_HORDE = 8174, - BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE = 8173, - BG_EY_SOUND_FLAG_RESET = 8192 + //EVENT_BLOOD_ELF_TOWER_WIN_ALLIANCE = 12965, + //EVENT_BLOOD_ELF_TOWER_WIN_HORDE = 12964, + EVENT_BLOOD_ELF_TOWER_PROGRESS_ALLIANCE = 12905, + EVENT_BLOOD_ELF_TOWER_PROGRESS_HORDE = 12904, + EVENT_BLOOD_ELF_TOWER_NEUTRAL_ALLIANCE = 12957, + EVENT_BLOOD_ELF_TOWER_NEUTRAL_HORDE = 12956, + + //EVENT_FEL_REAVER_RUINS_WIN_ALLIANCE = 12969, + //EVENT_FEL_REAVER_RUINS_WIN_HORDE = 12968, + EVENT_FEL_REAVER_RUINS_PROGRESS_ALLIANCE = 12911, + EVENT_FEL_REAVER_RUINS_PROGRESS_HORDE = 12910, + EVENT_FEL_REAVER_RUINS_NEUTRAL_ALLIANCE = 12960, + EVENT_FEL_REAVER_RUINS_NEUTRAL_HORDE = 12961, + + //EVENT_MAGE_TOWER_WIN_ALLIANCE = 12971, + //EVENT_MAGE_TOWER_WIN_HORDE = 12970, + EVENT_MAGE_TOWER_PROGRESS_ALLIANCE = 12909, + EVENT_MAGE_TOWER_PROGRESS_HORDE = 12908, + EVENT_MAGE_TOWER_NEUTRAL_ALLIANCE = 12962, + EVENT_MAGE_TOWER_NEUTRAL_HORDE = 12963, + + //EVENT_DRAENEI_RUINS_WIN_ALLIANCE = 12967, + //EVENT_DRAENEI_RUINS_WIN_HORDE = 12966, + EVENT_DRAENEI_RUINS_PROGRESS_ALLIANCE = 12907, + EVENT_DRAENEI_RUINS_PROGRESS_HORDE = 12906, + EVENT_DRAENEI_RUINS_NEUTRAL_ALLIANCE = 12958, + EVENT_DRAENEI_RUINS_NEUTRAL_HORDE = 12959 }; -enum BG_EY_Spells +enum EYSounds { - BG_EY_NETHERSTORM_FLAG_SPELL = 34976, - BG_EY_PLAYER_DROPPED_FLAG_SPELL = 34991 + EY_SOUND_FLAG_PICKED_UP_ALLIANCE = 8212, + EY_SOUND_FLAG_CAPTURED_HORDE = 8213, + EY_SOUND_FLAG_PICKED_UP_HORDE = 8174, + EY_SOUND_FLAG_CAPTURED_ALLIANCE = 8173, + EY_SOUND_FLAG_RESET = 8192 }; -enum EYBattleGroundPointsTrigger +enum EYSpells { - TR_BLOOD_ELF_POINT = 4476, - TR_FEL_REAVER_POINT = 4514, - TR_MAGE_TOWER_POINT = 4516, - TR_DRAENEI_RUINS_POINT = 4518, - TR_BLOOD_ELF_BUFF = 4568, - TR_FEL_REAVER_BUFF = 4569, - TR_MAGE_TOWER_BUFF = 4570, - TR_DRAENEI_RUINS_BUFF = 4571 + EY_NETHERSTORM_FLAG_SPELL = 34976, + EY_PLAYER_DROPPED_FLAG_SPELL = 34991 }; -enum EYBattleGroundGaveyards +enum EYPointsTrigger { - EY_GRAVEYARD_MAIN_ALLIANCE = 1103, - EY_GRAVEYARD_MAIN_HORDE = 1104, - EY_GRAVEYARD_FEL_REAVER = 1105, - EY_GRAVEYARD_BLOOD_ELF = 1106, - EY_GRAVEYARD_DRAENEI_RUINS = 1107, - EY_GRAVEYARD_MAGE_TOWER = 1108 + AREATRIGGER_BLOOD_ELF_TOWER_POINT = 4476, // also 4512 + AREATRIGGER_FEL_REAVER_RUINS_POINT = 4514, // also 4515 + AREATRIGGER_MAGE_TOWER_POINT = 4516, // also 4517 + AREATRIGGER_DRAENEI_RUINS_POINT = 4518, // also 4519 + + AREATRIGGER_BLOOD_ELF_TOWER_BUFF = 4568, + AREATRIGGER_FEL_REAVER_RUINS_BUFF = 4569, + //AREATRIGGER_FEL_REAVER_RUINS_BUFF_2 = 5866, + AREATRIGGER_MAGE_TOWER_BUFF = 4570, + AREATRIGGER_DRAENEI_RUINS_BUFF = 4571 + + //AREATRIGGER_EY_HORDE_START = 4530, + //AREATRIGGER_EY_ALLIANCE_START = 4531 }; -enum BG_EY_Nodes +enum EYGaveyards { - BG_EY_NODE_FEL_REAVER = 0, - BG_EY_NODE_BLOOD_ELF = 1, - BG_EY_NODE_DRAENEI_RUINS = 2, - BG_EY_NODE_MAGE_TOWER = 3, - - // special internal node - BG_EY_PLAYERS_OUT_OF_POINTS = 4, // used for store out of node players data + GRAVEYARD_EY_MAIN_ALLIANCE = 1103, + GRAVEYARD_EY_MAIN_HORDE = 1104, + GRAVEYARD_FEL_REAVER_RUINS = 1105, + GRAVEYARD_BLOOD_ELF_TOWER = 1106, + GRAVEYARD_DRAENEI_RUINS = 1107, + GRAVEYARD_MAGE_TOWER = 1108 }; -#define BG_EY_NODES_MAX 4 -#define BG_EY_NODES_MAX_WITH_SPECIAL 5 +enum EYNodes +{ + // TODO: Re-change order after we drop battleground_event and associated tables + NODE_BLOOD_ELF_TOWER = 1, + NODE_FEL_REAVER_RUINS = 0, + NODE_MAGE_TOWER = 3, + NODE_DRAENEI_RUINS = 2 +}; + +#define EY_NODES_MAX 4 // node-events work like this: event1:nodeid, event2:state (0alliance,1horde,2neutral) -#define BG_EYE_NEUTRAL_TEAM 2 -#define BG_EY_EVENT_CAPTURE_FLAG 4 // event1=4, event2=nodeid or 4 for the default center spawn -#define BG_EY_EVENT2_FLAG_CENTER 4 // maximum node is 3 so 4 for center is ok +#define EY_NEUTRAL_TEAM 2 +#define EY_EVENT_CAPTURE_FLAG 4 // event1=4, event2=nodeid or 4 for the default center spawn +#define EY_EVENT2_FLAG_CENTER 4 // maximum node is 3 so 4 for center is ok // all other event2 are just nodeids, i won't define something here -// x, y, z -// used to check, when player is in range of a node -const float BG_EY_NodePositions[BG_EY_NODES_MAX][3] = -{ - {2024.600708f, 1742.819580f, 1195.157715f}, // BG_EY_NODE_FEL_REAVER - {2050.493164f, 1372.235962f, 1194.563477f}, // BG_EY_NODE_BLOOD_ELF - {2301.010498f, 1386.931641f, 1197.183472f}, // BG_EY_NODE_DRAENEI_RUINS - {2282.121582f, 1760.006958f, 1189.707153f} // BG_EY_NODE_MAGE_TOWER -}; - -enum EYBattleGroundObjectTypes +enum EYBuffs { // buffs - BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER = 1, - BG_EY_OBJECT_REGENBUFF_FEL_REAVER = 2, - BG_EY_OBJECT_BERSERKBUFF_FEL_REAVER = 3, - BG_EY_OBJECT_SPEEDBUFF_BLOOD_ELF = 4, - BG_EY_OBJECT_REGENBUFF_BLOOD_ELF = 5, - BG_EY_OBJECT_BERSERKBUFF_BLOOD_ELF = 6, - BG_EY_OBJECT_SPEEDBUFF_DRAENEI_RUINS = 7, - BG_EY_OBJECT_REGENBUFF_DRAENEI_RUINS = 8, - BG_EY_OBJECT_BERSERKBUFF_DRAENEI_RUINS = 9, - BG_EY_OBJECT_SPEEDBUFF_MAGE_TOWER = 10, - BG_EY_OBJECT_REGENBUFF_MAGE_TOWER = 11, - BG_EY_OBJECT_BERSERKBUFF_MAGE_TOWER = 12, - BG_EY_OBJECT_MAX = 13 + EY_OBJECT_SPEEDBUFF_FEL_REAVER_RUINS = 1, + EY_OBJECT_REGENBUFF_FEL_REAVER_RUINS = 2, + EY_OBJECT_BERSERKBUFF_FEL_REAVER_RUINS = 3, + EY_OBJECT_SPEEDBUFF_BLOOD_ELF_TOWER = 4, + EY_OBJECT_REGENBUFF_BLOOD_ELF_TOWER = 5, + EY_OBJECT_BERSERKBUFF_BLOOD_ELF_TOWER = 6, + EY_OBJECT_SPEEDBUFF_DRAENEI_RUINS = 7, + EY_OBJECT_REGENBUFF_DRAENEI_RUINS = 8, + EY_OBJECT_BERSERKBUFF_DRAENEI_RUINS = 9, + EY_OBJECT_SPEEDBUFF_MAGE_TOWER = 10, + EY_OBJECT_REGENBUFF_MAGE_TOWER = 11, + EY_OBJECT_BERSERKBUFF_MAGE_TOWER = 12, + EY_OBJECT_MAX = 13 }; -#define BG_EY_NotEYWeekendHonorTicks 330 -#define BG_EY_EYWeekendHonorTicks 200 -#define BG_EY_EVENT_START_BATTLE 13180 +#define EY_NORMAL_HONOR_TICKS 30 +#define EY_WEEKEND_HONOR_TICKS 200 +#define EY_EVENT_START_BATTLE 13180 -enum BG_EY_Score +enum EYScore { - BG_EY_WARNING_NEAR_VICTORY_SCORE = 1400, - BG_EY_MAX_TEAM_SCORE = 1600 + EY_WARNING_NEAR_VICTORY_SCORE = 1400, + EY_MAX_TEAM_SCORE = 1600 }; -enum BG_EY_FlagState +enum EYFlagState { - BG_EY_FLAG_STATE_ON_BASE = 0, - BG_EY_FLAG_STATE_WAIT_RESPAWN = 1, - BG_EY_FLAG_STATE_ON_PLAYER = 2, - BG_EY_FLAG_STATE_ON_GROUND = 3 + EY_FLAG_STATE_ON_BASE = 0, + EY_FLAG_STATE_WAIT_RESPAWN = 1, + EY_FLAG_STATE_ON_ALLIANCE_PLAYER = 2, + EY_FLAG_STATE_ON_HORDE_PLAYER = 3, + EY_FLAG_STATE_ON_GROUND = 4 }; -enum EYBattleGroundPointState +static const uint8 eyTickPoints[EY_NODES_MAX] = {1, 2, 5, 10}; +static const uint32 eyFlagPoints[EY_NODES_MAX] = {75, 85, 100, 500}; + +static const uint32 eyGraveyards[EY_NODES_MAX] = {GRAVEYARD_FEL_REAVER_RUINS, GRAVEYARD_BLOOD_ELF_TOWER, GRAVEYARD_DRAENEI_RUINS, GRAVEYARD_MAGE_TOWER}; +static const uint32 eyTriggers[EY_NODES_MAX] = {AREATRIGGER_FEL_REAVER_RUINS_BUFF, AREATRIGGER_BLOOD_ELF_TOWER_BUFF, AREATRIGGER_DRAENEI_RUINS_BUFF, AREATRIGGER_MAGE_TOWER_BUFF}; + +struct EYTowerEvent { - EY_POINT_NO_OWNER = 0, - EY_POINT_STATE_UNCONTROLLED = 0, - EY_POINT_UNDER_CONTROL = 3 + uint32 eventEntry; + Team team; + uint32 message; + uint32 worldState; }; -struct BattleGroundEYPointIconsStruct +static const EYTowerEvent eyTowerEvents[EY_NODES_MAX][4] = { - BattleGroundEYPointIconsStruct(uint32 _WorldStateControlIndex, uint32 _WorldStateAllianceControlledIndex, uint32 _WorldStateHordeControlledIndex) - : WorldStateControlIndex(_WorldStateControlIndex), WorldStateAllianceControlledIndex(_WorldStateAllianceControlledIndex), WorldStateHordeControlledIndex(_WorldStateHordeControlledIndex) {} - uint32 WorldStateControlIndex; - uint32 WorldStateAllianceControlledIndex; - uint32 WorldStateHordeControlledIndex; + { + {EVENT_FEL_REAVER_RUINS_PROGRESS_ALLIANCE, ALLIANCE, LANG_BG_EY_HAS_TAKEN_A_B_TOWER, WORLD_STATE_EY_FEL_REAVER_RUINS_ALLIANCE}, + {EVENT_FEL_REAVER_RUINS_PROGRESS_HORDE, HORDE, LANG_BG_EY_HAS_TAKEN_H_F_RUINS, WORLD_STATE_EY_FEL_REAVER_RUINS_HORDE}, + {EVENT_FEL_REAVER_RUINS_NEUTRAL_HORDE, TEAM_NONE, LANG_BG_EY_HAS_LOST_A_F_RUINS, WORLD_STATE_EY_FEL_REAVER_RUINS_NEUTRAL}, + {EVENT_FEL_REAVER_RUINS_NEUTRAL_ALLIANCE, TEAM_NONE, LANG_BG_EY_HAS_LOST_H_F_RUINS, WORLD_STATE_EY_FEL_REAVER_RUINS_NEUTRAL}, + }, + { + {EVENT_BLOOD_ELF_TOWER_PROGRESS_ALLIANCE, ALLIANCE, LANG_BG_EY_HAS_TAKEN_A_B_TOWER, WORLD_STATE_EY_BLOOD_ELF_TOWER_ALLIANCE}, + {EVENT_BLOOD_ELF_TOWER_PROGRESS_HORDE, HORDE, LANG_BG_EY_HAS_TAKEN_H_B_TOWER, WORLD_STATE_EY_BLOOD_ELF_TOWER_HORDE}, + {EVENT_BLOOD_ELF_TOWER_NEUTRAL_HORDE, TEAM_NONE, LANG_BG_EY_HAS_LOST_A_B_TOWER, WORLD_STATE_EY_BLOOD_ELF_TOWER_NEUTRAL}, + {EVENT_BLOOD_ELF_TOWER_NEUTRAL_ALLIANCE, TEAM_NONE, LANG_BG_EY_HAS_LOST_H_B_TOWER, WORLD_STATE_EY_BLOOD_ELF_TOWER_NEUTRAL}, + }, + { + {EVENT_DRAENEI_RUINS_PROGRESS_ALLIANCE, ALLIANCE, LANG_BG_EY_HAS_TAKEN_A_D_RUINS, WORLD_STATE_EY_DRAENEI_RUINS_ALLIANCE}, + {EVENT_DRAENEI_RUINS_PROGRESS_HORDE, HORDE, LANG_BG_EY_HAS_TAKEN_H_D_RUINS, WORLD_STATE_EY_DRAENEI_RUINS_HORDE}, + {EVENT_DRAENEI_RUINS_NEUTRAL_HORDE, TEAM_NONE, LANG_BG_EY_HAS_LOST_A_D_RUINS, WORLD_STATE_EY_DRAENEI_RUINS_NEUTRAL}, + {EVENT_DRAENEI_RUINS_NEUTRAL_ALLIANCE, TEAM_NONE, LANG_BG_EY_HAS_LOST_H_D_RUINS, WORLD_STATE_EY_DRAENEI_RUINS_NEUTRAL}, + }, + { + {EVENT_MAGE_TOWER_PROGRESS_ALLIANCE, ALLIANCE, LANG_BG_EY_HAS_TAKEN_A_M_TOWER, WORLD_STATE_EY_MAGE_TOWER_ALLIANCE}, + {EVENT_MAGE_TOWER_PROGRESS_HORDE, HORDE, LANG_BG_EY_HAS_TAKEN_H_M_TOWER, WORLD_STATE_EY_MAGE_TOWER_HORDE}, + {EVENT_MAGE_TOWER_NEUTRAL_HORDE, TEAM_NONE, LANG_BG_EY_HAS_LOST_A_M_TOWER, WORLD_STATE_EY_MAGE_TOWER_NEUTRAL}, + {EVENT_MAGE_TOWER_NEUTRAL_ALLIANCE, TEAM_NONE, LANG_BG_EY_HAS_LOST_H_M_TOWER, WORLD_STATE_EY_MAGE_TOWER_NEUTRAL}, + }, }; -struct BattleGroundEYLoosingPointStruct -{ - BattleGroundEYLoosingPointStruct(uint32 _MessageIdAlliance, uint32 _MessageIdHorde) - : MessageIdAlliance(_MessageIdAlliance), MessageIdHorde(_MessageIdHorde) - {} - - uint32 MessageIdAlliance; - uint32 MessageIdHorde; -}; - -struct BattleGroundEYCapturingPointStruct -{ - BattleGroundEYCapturingPointStruct(uint32 _MessageIdAlliance, uint32 _MessageIdHorde, uint32 _GraveYardId) - : MessageIdAlliance(_MessageIdAlliance), MessageIdHorde(_MessageIdHorde), GraveYardId(_GraveYardId) - {} - uint32 MessageIdAlliance; - uint32 MessageIdHorde; - uint32 GraveYardId; -}; - -const uint8 BG_EY_TickPoints[BG_EY_NODES_MAX] = {1, 2, 5, 10}; -const uint32 BG_EY_FlagPoints[BG_EY_NODES_MAX] = {75, 85, 100, 500}; - -// constant arrays: -const BattleGroundEYPointIconsStruct PointsIconStruct[BG_EY_NODES_MAX] = -{ - BattleGroundEYPointIconsStruct(FEL_REAVER_UNCONTROL, FEL_REAVER_ALLIANCE_CONTROL, FEL_REAVER_HORDE_CONTROL), - BattleGroundEYPointIconsStruct(BLOOD_ELF_UNCONTROL, BLOOD_ELF_ALLIANCE_CONTROL, BLOOD_ELF_HORDE_CONTROL), - BattleGroundEYPointIconsStruct(DRAENEI_RUINS_UNCONTROL, DRAENEI_RUINS_ALLIANCE_CONTROL, DRAENEI_RUINS_HORDE_CONTROL), - BattleGroundEYPointIconsStruct(MAGE_TOWER_UNCONTROL, MAGE_TOWER_ALLIANCE_CONTROL, MAGE_TOWER_HORDE_CONTROL) -}; -const BattleGroundEYLoosingPointStruct LoosingPointTypes[BG_EY_NODES_MAX] = -{ - BattleGroundEYLoosingPointStruct(LANG_BG_EY_HAS_LOST_A_F_RUINS, LANG_BG_EY_HAS_LOST_H_F_RUINS), - BattleGroundEYLoosingPointStruct(LANG_BG_EY_HAS_LOST_A_B_TOWER, LANG_BG_EY_HAS_LOST_H_B_TOWER), - BattleGroundEYLoosingPointStruct(LANG_BG_EY_HAS_LOST_A_D_RUINS, LANG_BG_EY_HAS_LOST_H_D_RUINS), - BattleGroundEYLoosingPointStruct(LANG_BG_EY_HAS_LOST_A_M_TOWER, LANG_BG_EY_HAS_LOST_H_M_TOWER) -}; -const BattleGroundEYCapturingPointStruct CapturingPointTypes[BG_EY_NODES_MAX] = -{ - BattleGroundEYCapturingPointStruct(LANG_BG_EY_HAS_TAKEN_A_F_RUINS, LANG_BG_EY_HAS_TAKEN_H_F_RUINS, EY_GRAVEYARD_FEL_REAVER), - BattleGroundEYCapturingPointStruct(LANG_BG_EY_HAS_TAKEN_A_B_TOWER, LANG_BG_EY_HAS_TAKEN_H_B_TOWER, EY_GRAVEYARD_BLOOD_ELF), - BattleGroundEYCapturingPointStruct(LANG_BG_EY_HAS_TAKEN_A_D_RUINS, LANG_BG_EY_HAS_TAKEN_H_D_RUINS, EY_GRAVEYARD_DRAENEI_RUINS), - BattleGroundEYCapturingPointStruct(LANG_BG_EY_HAS_TAKEN_A_M_TOWER, LANG_BG_EY_HAS_TAKEN_H_M_TOWER, EY_GRAVEYARD_MAGE_TOWER) -}; +static const uint32 eyTowers[EY_NODES_MAX] = {GO_CAPTURE_POINT_FEL_REAVER_RUINS, GO_CAPTURE_POINT_BLOOD_ELF_TOWER, GO_CAPTURE_POINT_DRAENEI_RUINS, GO_CAPTURE_POINT_MAGE_TOWER}; class BattleGroundEYScore : public BattleGroundScore { @@ -256,17 +266,20 @@ class BattleGroundEY : public BattleGround virtual void StartingEventOpenDoors() override; /* BG Flags */ - ObjectGuid const& GetFlagPickerGuid() const { return m_FlagKeeper; } - void SetFlagPicker(ObjectGuid guid) { m_FlagKeeper = guid; } - void ClearFlagPicker() { m_FlagKeeper.Clear(); } - bool IsFlagPickedup() const { return !m_FlagKeeper.IsEmpty(); } - uint8 GetFlagState() const { return m_FlagState; } - void RespawnFlag(bool send_message); - void RespawnFlagAfterDrop(); + ObjectGuid const& GetFlagCarrierGuid() const { return m_flagCarrier; } + void SetFlagCarrier(ObjectGuid guid) { m_flagCarrier = guid; } + void ClearFlagCarrier() { m_flagCarrier.Clear(); } + bool IsFlagPickedUp() const { return !m_flagCarrier.IsEmpty(); } + uint8 GetFlagState() const { return m_flagState; } + void RespawnFlag(); + void RespawnDroppedFlag(); void RemovePlayer(Player* plr, ObjectGuid guid) override; + bool HandleEvent(uint32 eventId, GameObject* go) override; + void HandleGameObjectCreate(GameObject* go) override; void HandleAreaTrigger(Player* source, uint32 trigger) override; void HandleKillPlayer(Player* player, Player* killer) override; + virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; virtual bool SetupBattleGround() override; virtual void Reset() override; @@ -286,42 +299,30 @@ class BattleGroundEY : public BattleGround bool IsAllNodesControlledByTeam(Team team) const override; private: - void EventPlayerCapturedFlag(Player* source, BG_EY_Nodes node); // NOTE: virtual BattleGround::EventPlayerCapturedFlag has different parameters list - void EventTeamCapturedPoint(Player* source, uint32 point); - void EventTeamLostPoint(Player* source, uint32 point); - void UpdatePointsCount(Team team); - void UpdatePointsIcons(Team team, uint32 point); - - /* Point status updating procedures */ - void CheckSomeoneLeftPoint(); - void CheckSomeoneJoinedPoint(); - void UpdatePointStatuses(); + // process capture events + void ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team, uint32 newWorldState, uint32 message); + void EventPlayerCapturedFlag(Player* source, EYNodes node); // NOTE: virtual BattleGround::EventPlayerCapturedFlag has different parameters list + void UpdateResources(); /* Scorekeeping */ - uint32 GetTeamScore(Team team) const { return m_TeamScores[GetTeamIndexByTeamId(team)]; } void AddPoints(Team team, uint32 points); - void RemovePoint(Team team, uint32 points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] -= points; } - void SetTeamPoint(Team team, uint32 points = 0) { m_TeamScores[GetTeamIndexByTeamId(team)] = points; } - - uint32 m_HonorScoreTics[2]; - uint32 m_TeamPointsCount[BG_TEAMS_COUNT]; - - uint32 m_Points_Trigger[BG_EY_NODES_MAX]; - - ObjectGuid m_FlagKeeper; // keepers guid + EYFlagState m_flagState; + ObjectGuid m_flagCarrier; ObjectGuid m_DroppedFlagGuid; - uint8 m_FlagState; // for checking flag state - int32 m_FlagsTimer; - int32 m_TowerCapCheckTimer; - Team m_PointOwnedByTeam[BG_EY_NODES_MAX]; - uint8 m_PointState[BG_EY_NODES_MAX]; - int32 m_PointBarStatus[BG_EY_NODES_MAX]; - GuidVector m_PlayersNearPoint[BG_EY_NODES_MAX_WITH_SPECIAL]; - uint8 m_CurrentPointPlayersCount[2 * BG_EY_NODES_MAX]; + uint8 m_towersAlliance; + uint8 m_towersHorde; - int32 m_PointAddingTimer; - uint32 m_HonorTics; + uint32 m_towerWorldState[EY_NODES_MAX]; + + Team m_towerOwner[EY_NODES_MAX]; + ObjectGuid m_towers[EY_NODES_MAX]; + + uint32 m_honorTicks; + uint32 m_honorScoreTicks[BG_TEAMS_COUNT]; + + uint32 m_flagRespawnTimer; + uint32 m_resourceUpdateTimer; }; #endif diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 50f4f1135..767f5ce53 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8474,40 +8474,27 @@ static WorldStatePair AB_world_states[] = static WorldStatePair EY_world_states[] = { - { 0xac1, 0x0 }, // 2753 7 Horde Bases - { 0xac0, 0x0 }, // 2752 8 Alliance Bases - { 0xab6, 0x0 }, // 2742 9 Mage Tower - Horde conflict - { 0xab5, 0x0 }, // 2741 10 Mage Tower - Alliance conflict - { 0xab4, 0x0 }, // 2740 11 Fel Reaver - Horde conflict - { 0xab3, 0x0 }, // 2739 12 Fel Reaver - Alliance conflict - { 0xab2, 0x0 }, // 2738 13 Draenei - Alliance conflict - { 0xab1, 0x0 }, // 2737 14 Draenei - Horde conflict - { 0xab0, 0x0 }, // 2736 15 unk // 0 at start - { 0xaaf, 0x0 }, // 2735 16 unk // 0 at start - { 0xaad, 0x0 }, // 2733 17 Draenei - Horde control - { 0xaac, 0x0 }, // 2732 18 Draenei - Alliance control - { 0xaab, 0x1 }, // 2731 19 Draenei uncontrolled (1 - yes, 0 - no) - { 0xaaa, 0x0 }, // 2730 20 Mage Tower - Alliance control - { 0xaa9, 0x0 }, // 2729 21 Mage Tower - Horde control - { 0xaa8, 0x1 }, // 2728 22 Mage Tower uncontrolled (1 - yes, 0 - no) - { 0xaa7, 0x0 }, // 2727 23 Fel Reaver - Horde control - { 0xaa6, 0x0 }, // 2726 24 Fel Reaver - Alliance control - { 0xaa5, 0x1 }, // 2725 25 Fel Reaver uncontrolled (1 - yes, 0 - no) - { 0xaa4, 0x0 }, // 2724 26 Boold Elf - Horde control - { 0xaa3, 0x0 }, // 2723 27 Boold Elf - Alliance control - { 0xaa2, 0x1 }, // 2722 28 Boold Elf uncontrolled (1 - yes, 0 - no) - { 0xac5, 0x1 }, // 2757 29 Flag (1 - show, 0 - hide) - doesn't work exactly this way! - { 0xad2, 0x1 }, // 2770 30 Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag - { 0xad1, 0x1 }, // 2769 31 Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag - { 0xabe, 0x0 }, // 2750 32 Horde resources - { 0xabd, 0x0 }, // 2749 33 Alliance resources - { 0xa05, 0x8e }, // 2565 34 unk, constant? - { 0xaa0, 0x0 }, // 2720 35 Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0) - { 0xa9f, 0x0 }, // 2719 36 Capturing progress-bar (0 - left, 100 - right) - { 0xa9e, 0x0 }, // 2718 37 Capturing progress-bar (1 - show, 0 - hide) - { 0xc0d, 0x17b }, // 3085 38 unk - // and some more ... unknown - { 0x0, 0x0 } + { 2753, 0 }, // WORLD_STATE_EY_TOWER_COUNT_HORDE + { 2752, 0 }, // WORLD_STATE_EY_TOWER_COUNT_ALLIANCE + { 2733, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_DRAENEI_RUINS_HORDE + { 2732, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_DRAENEI_RUINS_ALLIANCE + { 2731, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_DRAENEI_RUINS_NEUTRAL + { 2730, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_MAGE_TOWER_ALLIANCE + { 2729, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_MAGE_TOWER_HORDE + { 2728, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_MAGE_TOWER_NEUTRAL + { 2727, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_FEL_REAVER_HORDE + { 2726, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_FEL_REAVER_ALLIANCE + { 2725, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_FEL_REAVER_NEUTRAL + { 2724, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_BLOOD_ELF_HORDE + { 2723, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_BLOOD_ELF_ALLIANCE + { 2722, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_BLOOD_ELF_NEUTRAL + { 2757, WORLD_STATE_REMOVE }, // WORLD_STATE_EY_NETHERSTORM_FLAG_READY + { 2770, 1 }, // WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_HORDE + { 2769, 1 }, // WORLD_STATE_EY_NETHERSTORM_FLAG_STATE_ALLIANCE + { 2750, 0 }, // WORLD_STATE_EY_RESOURCES_HORDE + { 2749, 0 }, // WORLD_STATE_EY_RESOURCES_ALLIANCE + { 2565, 0x8e }, // global unk -- TODO: move to global world state + { 3085, 0x17b } // global unk -- TODO: move to global world state }; static WorldStatePair SI_world_states[] = // Silithus diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index cac463d3d..855b55d3b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12155" + #define REVISION_NR "12156" #endif // __REVISION_NR_H__