fix(Core/Battlefield): Restrict Within Our Grasp to attackers (#25945)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andrew
2026-05-24 09:26:47 -03:00
committed by GitHub
parent 8bf01db849
commit e0046d8ba8
5 changed files with 22 additions and 0 deletions
@@ -112,6 +112,13 @@ Battlefield* BattlefieldMgr::GetBattlefieldByBattleId(uint32 battleId)
return nullptr;
}
bool BattlefieldMgr::IsWintergraspAttackerVictory()
{
if (Battlefield* bf = GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG))
return static_cast<BattlefieldWG*>(bf)->IsLastBattleAttackerVictory();
return false;
}
void BattlefieldMgr::Update(uint32 diff)
{
_updateTimer += diff;
@@ -47,6 +47,9 @@ public:
Battlefield* GetBattlefieldToZoneId(uint32 zoneId);
Battlefield* GetBattlefieldByBattleId(uint32 battleId);
// True iff the most recent Wintergrasp battle ended with the keep captured.
[[nodiscard]] bool IsWintergraspAttackerVictory();
ZoneScript* GetZoneScript(uint32 zoneId);
void AddZone(uint32 zoneId, Battlefield* handle);
@@ -348,6 +348,9 @@ void BattlefieldWG::CapturePointTaken(uint32 areaId)
void BattlefieldWG::OnBattleEnd(bool endByTimer)
{
// Must be set before SPELL_VICTORY_REWARD so the 1755 criterion can gate on it.
LastBattleAttackerVictory = !endByTimer;
// Remove relic
if (GameObject* go = GetRelic())
go->RemoveFromWorld();
@@ -403,6 +403,9 @@ public:
uint32 GetData(uint32 data) const override;
// True iff the most recent battle ended with the keep captured (attacker win).
[[nodiscard]] bool IsLastBattleAttackerVictory() const { return LastBattleAttackerVictory; }
bool IsKeepNpc(uint32 entry)
{
switch (entry)
@@ -451,6 +454,8 @@ protected:
int32 TenacityStack;
ObjectGuid TitansRelic;
bool LastBattleAttackerVictory{false};
};
uint8 const WG_MAX_OBJ = 32;
@@ -1160,6 +1160,10 @@ public:
if (!wintergrasp)
return false;
// Attacker-only achievement -- defenders winning fast must not qualify.
if (!sBattlefieldMgr->IsWintergraspAttackerVictory())
return false;
return wintergrasp->GetTimer() >= (20 * MINUTE * IN_MILLISECONDS);
}
};