mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Battlegrounds: Implement power resets on arena-fight preparations (first 60 seconds before arena-fight kicks off) (Thanks to Kaelima)
Restores all player powers every 5 seconds untill arena starts (fixes possible exploit with entering arena battle with full rage or runic power) (The 5 second timer is not 100% confirmed, as official pages only states that the power is reset after prep-time - needs feedback) Closes issue 4805 --HG-- branch : trunk
This commit is contained in:
@@ -141,6 +141,7 @@ Battleground::Battleground()
|
||||
m_IsArena = false;
|
||||
m_Winner = 2;
|
||||
m_StartTime = 0;
|
||||
m_ResetStatTimer = 0;
|
||||
m_Events = 0;
|
||||
m_IsRated = false;
|
||||
m_BuffChange = false;
|
||||
@@ -379,6 +380,14 @@ void Battleground::Update(uint32 diff)
|
||||
{
|
||||
ModifyStartDelayTime(diff);
|
||||
|
||||
if (m_ResetStatTimer <= 5000)
|
||||
{
|
||||
m_ResetStatTimer = 0;
|
||||
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
|
||||
if (Player *plr = sObjectMgr.GetPlayer(itr->first))
|
||||
plr->ResetAllPowers();
|
||||
}
|
||||
|
||||
if (!(m_Events & BG_STARTING_EVENT_1))
|
||||
{
|
||||
m_Events |= BG_STARTING_EVENT_1;
|
||||
@@ -434,6 +443,7 @@ void Battleground::Update(uint32 diff)
|
||||
plr->GetSession()->SendPacket(&status);
|
||||
|
||||
plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
|
||||
plr->ResetAllPowers();
|
||||
// remove auras with duration lower than 30s
|
||||
Unit::AuraApplicationMap & auraMap = plr->GetAppliedAuras();
|
||||
for (Unit::AuraApplicationMap::iterator iter = auraMap.begin(); iter != auraMap.end();)
|
||||
@@ -455,12 +465,14 @@ void Battleground::Update(uint32 diff)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
PlaySoundToAll(SOUND_BG_START);
|
||||
|
||||
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
|
||||
if (Player* plr = sObjectMgr.GetPlayer(itr->first))
|
||||
{
|
||||
plr->RemoveAurasDueToSpell(SPELL_PREPARATION);
|
||||
plr->ResetAllPowers();
|
||||
}
|
||||
//Announce BG starting
|
||||
if (sWorld.getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||
{
|
||||
@@ -493,8 +505,9 @@ void Battleground::Update(uint32 diff)
|
||||
}
|
||||
}
|
||||
|
||||
//update start time
|
||||
// Update start time and reset stats timer
|
||||
m_StartTime += diff;
|
||||
m_ResetStatTimer += diff;
|
||||
}
|
||||
|
||||
void Battleground::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
|
||||
@@ -843,8 +856,7 @@ void Battleground::EndBattleground(uint32 winner)
|
||||
}
|
||||
|
||||
|
||||
plr->SetFullHealth();
|
||||
plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
|
||||
plr->ResetAllPowers();
|
||||
plr->CombatStopWithPets(true);
|
||||
|
||||
BlockMovement(plr);
|
||||
@@ -1132,9 +1144,7 @@ void Battleground::AddPlayer(Player *plr)
|
||||
if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
|
||||
{
|
||||
plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);
|
||||
|
||||
plr->SetFullHealth();
|
||||
plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
|
||||
plr->ResetAllPowers();
|
||||
}
|
||||
WorldPacket teammate;
|
||||
teammate.Initialize(SMSG_ARENA_OPPONENT_UPDATE, 8);
|
||||
|
||||
@@ -616,6 +616,7 @@ class Battleground
|
||||
BattlegroundStatus m_Status;
|
||||
uint32 m_ClientInstanceID; //the instance-id which is sent to the client and without any other internal use
|
||||
uint32 m_StartTime;
|
||||
uint32 m_ResetStatTimer;
|
||||
int32 m_EndTime; // it is set to 120000 when bg is ending and it decreases itself
|
||||
uint32 m_LastResurrectTime;
|
||||
BattlegroundBracketId m_BracketId;
|
||||
|
||||
@@ -474,8 +474,7 @@ void BattlegroundSA::TeleportPlayers()
|
||||
plr->SpawnCorpseBones();
|
||||
}
|
||||
|
||||
plr->SetFullHealth();
|
||||
plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
|
||||
plr->ResetAllPowers();
|
||||
plr->CombatStopWithPets(true);
|
||||
|
||||
if (plr->GetTeamId() == attackers)
|
||||
|
||||
@@ -2360,6 +2360,26 @@ void Player::RegenerateHealth()
|
||||
ModifyHealth(int32(addvalue));
|
||||
}
|
||||
|
||||
void Player::ResetAllPowers()
|
||||
{
|
||||
SetHealth(GetMaxHealth());
|
||||
switch (getPowerType())
|
||||
{
|
||||
case POWER_MANA:
|
||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||
break;
|
||||
case POWER_RAGE:
|
||||
SetPower(POWER_RAGE, 0);
|
||||
break;
|
||||
case POWER_ENERGY:
|
||||
SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY));
|
||||
break;
|
||||
case POWER_RUNIC_POWER:
|
||||
SetPower(POWER_RUNIC_POWER, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Player::CanInteractWithNPCs(bool alive) const
|
||||
{
|
||||
if (alive && !isAlive())
|
||||
|
||||
@@ -1993,6 +1993,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
void _ApplyAllStatBonuses();
|
||||
void _RemoveAllStatBonuses();
|
||||
|
||||
void ResetAllPowers();
|
||||
|
||||
void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
|
||||
void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, AuraEffect const * aura, bool apply);
|
||||
void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, AuraEffect const * aura, bool apply);
|
||||
|
||||
Reference in New Issue
Block a user