From 307d09877a49312d9de867feaef059042577760c Mon Sep 17 00:00:00 2001 From: Pedro Antonio <37176834+Valdifer@users.noreply.github.com> Date: Fri, 17 Mar 2023 15:26:54 +0100 Subject: [PATCH] fix(Core/Battlefield): Wintergrasp Workshops SW/SE (#14104) * Now only SW and SE are owned by Attacker, the rest are for Defender team Co-authored-by: M'Dic --- src/server/game/Battlefield/Battlefield.cpp | 7 ++++-- src/server/game/Battlefield/Battlefield.h | 3 ++- .../game/Battlefield/Zones/BattlefieldWG.cpp | 22 +++++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index fe6544a23..254720eb5 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -917,10 +917,13 @@ void BfCapturePoint::SendChangePhase() } } -bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint) +bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint, TeamId team) { ASSERT(capturePoint); + //At first call using TEAM_NEUTRAL as a checker but never using it, after first call we reset the capturepoints to the new winner of the last WG war + if (team == TEAM_NEUTRAL) + team = m_team; LOG_DEBUG("bg.battlefield", "Creating capture point {}", capturePoint->GetEntry()); m_capturePoint = capturePoint->GetGUID(); @@ -939,7 +942,7 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint) m_neutralValuePct = goinfo->capturePoint.neutralPercent; m_minValue = m_maxValue * goinfo->capturePoint.neutralPercent / 100; m_capturePointEntry = capturePoint->GetEntry(); - if (m_team == TEAM_ALLIANCE) + if (team == TEAM_ALLIANCE) { m_value = m_maxValue; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE; diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 308d3f281..12bae2338 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -104,7 +104,8 @@ public: virtual void ChangeTeam(TeamId /*oldTeam*/) {} virtual void SendChangePhase(); - bool SetCapturePointData(GameObject* capturePoint); + //Added team to reset capturepoints on sliders after warTime + bool SetCapturePointData(GameObject* capturePoint, TeamId team); GameObject* GetCapturePointGo(); GameObject* GetCapturePointGo(WorldObject* obj); diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 51a4fec74..6697ffe36 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -102,7 +102,7 @@ bool BattlefieldWG::SetupBattlefield() // When between games, the graveyard is controlled by the defending team if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL) - graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].gyid); + graveyard->Initialize(WGGraveYard[i].gyid == BATTLEFIELD_WG_GY_WORKSHOP_SE || WGGraveYard[i].gyid == BATTLEFIELD_WG_GY_WORKSHOP_SW ? GetAttackerTeam() : m_DefenderTeam, WGGraveYard[i].gyid); else graveyard->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid); @@ -114,7 +114,7 @@ bool BattlefieldWG::SetupBattlefield() for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++) { WGWorkshop* workshop = new WGWorkshop(this, i); - if (i < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST) + if (i == BATTLEFIELD_WG_WORKSHOP_SE || i == BATTLEFIELD_WG_WORKSHOP_SW) workshop->GiveControlTo(GetAttackerTeam(), true); else workshop->GiveControlTo(GetDefenderTeam(), true); @@ -262,6 +262,11 @@ void BattlefieldWG::OnBattleStart() if (*itr) (*itr)->UpdateGraveyardAndWorkshop(); + // Set Sliders capture points data to his owners when battle start + for (BfCapturePointVector::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) + (*itr)->SetCapturePointData((*itr)->GetCapturePointGo(), + (*itr)->GetCapturePointGo()->GetEntry() == GO_WINTERGRASP_FACTORY_BANNER_SE || (*itr)->GetCapturePointGo()->GetEntry() == GO_WINTERGRASP_FACTORY_BANNER_SW ? GetAttackerTeam() : GetDefenderTeam()); + for (uint8 team = 0; team < 2; ++team) for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) { @@ -375,7 +380,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) // Update all graveyard, control is to defender when no wartime for (uint8 i = 0; i < BATTLEFIELD_WG_GY_HORDE; i++) if (BfGraveyard* graveyard = GetGraveyardById(i)) - graveyard->GiveControlTo(GetDefenderTeam()); + graveyard->GiveControlTo(i == BATTLEFIELD_WG_GY_WORKSHOP_SE || i == BATTLEFIELD_WG_GY_WORKSHOP_SW ? GetAttackerTeam() : GetDefenderTeam()); for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetDefenderTeam()].begin(); itr != m_KeepGameObject[GetDefenderTeam()].end(); ++itr) (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY); @@ -396,7 +401,10 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) } for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr) + { + (*itr)->GiveControlTo((*itr)->workshopId == BATTLEFIELD_WG_WORKSHOP_SE || (*itr)->workshopId == BATTLEFIELD_WG_WORKSHOP_SW ? GetAttackerTeam() : GetDefenderTeam(), true); (*itr)->Save(); + } for (uint8 team = 0; team < 2; ++team) { @@ -689,9 +697,9 @@ void BattlefieldWG::OnGameObjectCreate(GameObject* go) { if (workshop->workshopId == workshopId) { - WintergraspCapturePoint* capturePoint = new WintergraspCapturePoint(this, GetAttackerTeam()); - - capturePoint->SetCapturePointData(go); + WintergraspCapturePoint* capturePoint = new WintergraspCapturePoint(this, workshop->teamControl); + //Sending neutral team at start to set normal capture points by workshop->teamControl, TEAM_NEUTRAL is ignored at first call + capturePoint->SetCapturePointData(go, TEAM_NEUTRAL); capturePoint->LinkToWorkshop(workshop); AddCapturePoint(capturePoint); break; @@ -846,7 +854,7 @@ void BattlefieldWG::OnPlayerJoinWar(Player* player) if (player->GetTeamId() == TEAM_HORDE) player->TeleportTo(571, 5025.857422f, 3674.628906f, 362.737122f, 4.135169f); else - player->TeleportTo(571, 5101.284f, 2186.564f, 373.549f, 3.812f); + player->TeleportTo(571, 5101.284f, 2186.564f, 365.549f, 3.812f); } if (player->GetTeamId() == GetAttackerTeam())