Core/Wintergrasp: Fix Wintergrasp tenacity

This commit is contained in:
mik1893
2016-07-28 22:58:54 +01:00
committed by Yehonal
parent 5d3a91576e
commit e72b8ac1cc

View File

@@ -201,15 +201,13 @@ bool BattlefieldWG::Update(uint32 diff)
else else
m_saveTimer -= diff; m_saveTimer -= diff;
// Update Tenacity // Update Tenacity every 2,5 sec.
if (IsWarTime()) if (IsWarTime())
{ {
if (m_tenacityUpdateTimer <= diff) if (m_tenacityUpdateTimer <= diff)
{ {
m_tenacityUpdateTimer = 10000; m_tenacityUpdateTimer = 2500;
if (!m_updateTenacityList.empty()) UpdateTenacity();
UpdateTenacity();
m_updateTenacityList.clear();
} }
else else
m_tenacityUpdateTimer -= diff; m_tenacityUpdateTimer -= diff;
@@ -1087,42 +1085,7 @@ void BattlefieldWG::UpdateTenacity()
newStack = int32((1.0f - ((float)alliancePlayers / hordePlayers)) * 4.0f); // negative, should cast on horde newStack = int32((1.0f - ((float)alliancePlayers / hordePlayers)) * 4.0f); // negative, should cast on horde
} }
// Return if no change in stack and apply tenacity to new player // new way to check: always add stacks if they exist, to every one in the game
if (newStack == m_tenacityStack)
{
for (GuidSet::const_iterator itr = m_updateTenacityList.begin(); itr != m_updateTenacityList.end(); ++itr)
if (Player* newPlayer = ObjectAccessor::FindPlayer(*itr))
if ((newPlayer->GetTeamId() == TEAM_ALLIANCE && m_tenacityStack > 0) || (newPlayer->GetTeamId() == TEAM_HORDE && m_tenacityStack < 0))
{
newStack = std::min(abs(newStack), 20);
uint32 buff_honor = GetHonorBuff(newStack);
newPlayer->SetAuraStack(SPELL_TENACITY, newPlayer, newStack);
if (buff_honor)
newPlayer->CastSpell(newPlayer, buff_honor, true);
}
return;
}
if (m_tenacityStack != 0)
{
if (m_tenacityStack > 0 && newStack <= 0) // old buff was on alliance
team = TEAM_ALLIANCE;
else if (m_tenacityStack < 0 && newStack >= 0) // old buff was on horde
team = TEAM_HORDE;
}
m_tenacityStack = newStack;
// Remove old buff
if (team != TEAM_NEUTRAL)
{
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->RemoveAurasDueToSpell(SPELL_TENACITY);
for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
unit->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
}
// Apply new buff // Apply new buff
if (newStack) if (newStack)
@@ -1147,6 +1110,28 @@ void BattlefieldWG::UpdateTenacity()
unit->CastSpell(unit, buff_honor, true); unit->CastSpell(unit, buff_honor, true);
} }
} }
if (m_tenacityStack != 0)
{
if (m_tenacityStack > 0 && newStack <= 0) // old buff was on alliance
team = TEAM_ALLIANCE;
else if (m_tenacityStack < 0 && newStack >= 0) // old buff was on horde
team = TEAM_HORDE;
}
// Remove old buff
if (team != TEAM_NEUTRAL)
{
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->RemoveAurasDueToSpell(SPELL_TENACITY);
for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
unit->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
}
m_tenacityStack = newStack; // Assign new tenacity value
} }
WintergraspCapturePoint::WintergraspCapturePoint(BattlefieldWG* battlefield, TeamId teamInControl) : BfCapturePoint(battlefield) WintergraspCapturePoint::WintergraspCapturePoint(BattlefieldWG* battlefield, TeamId teamInControl) : BfCapturePoint(battlefield)