[12159] Related bg cleanups of EY cleanup

This commit is contained in:
stfx 2012-08-30 14:00:36 +02:00 committed by Antz
parent 975c2b1e1c
commit 061ca54cb0
5 changed files with 73 additions and 75 deletions

View file

@ -113,17 +113,17 @@ void BattleGroundAB::Update(uint32 diff)
{
m_lastTick[team] -= BG_AB_TickIntervals[points];
m_TeamScores[team] += BG_AB_TickPoints[points];
m_HonorScoreTics[team] += BG_AB_TickPoints[points];
m_honorScoreTicks[team] += BG_AB_TickPoints[points];
m_ReputationScoreTics[team] += BG_AB_TickPoints[points];
if (m_ReputationScoreTics[team] >= m_ReputationTics)
{
(team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
m_ReputationScoreTics[team] -= m_ReputationTics;
}
if (m_HonorScoreTics[team] >= m_HonorTics)
if (m_honorScoreTicks[team] >= m_honorTicks)
{
RewardHonorToTeam(GetBonusHonorFromKill(1), (team == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE);
m_HonorScoreTics[team] -= m_HonorTics;
m_honorScoreTicks[team] -= m_honorTicks;
}
if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE)
{
@ -463,16 +463,16 @@ void BattleGroundAB::Reset()
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
{
m_TeamScores[i] = 0;
m_lastTick[i] = 0;
m_HonorScoreTics[i] = 0;
m_TeamScores[i] = 0;
m_lastTick[i] = 0;
m_honorScoreTicks[i] = 0;
m_ReputationScoreTics[i] = 0;
m_TeamScores500Disadvantage[i] = false;
}
m_IsInformedNearVictory = false;
m_IsInformedNearVictory = false;
bool isBGWeekend = BattleGroundMgr::IsBGWeekend(GetTypeID());
m_HonorTics = (isBGWeekend) ? BG_AB_ABBGWeekendHonorTicks : BG_AB_NotABBGWeekendHonorTicks;
m_honorTicks = (isBGWeekend) ? BG_AB_ABBGWeekendHonorTicks : BG_AB_NotABBGWeekendHonorTicks;
m_ReputationTics = (isBGWeekend) ? BG_AB_ABBGWeekendReputationTicks : BG_AB_NotABBGWeekendReputationTicks;
for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i)

View file

@ -227,10 +227,10 @@ class BattleGroundAB : public BattleGround
BG_AB_BannerTimer m_BannerTimers[BG_AB_NODES_MAX];
uint32 m_NodeTimers[BG_AB_NODES_MAX];
uint32 m_lastTick[BG_TEAMS_COUNT];
uint32 m_HonorScoreTics[BG_TEAMS_COUNT];
uint32 m_honorScoreTicks[BG_TEAMS_COUNT];
uint32 m_ReputationScoreTics[BG_TEAMS_COUNT];
bool m_IsInformedNearVictory;
uint32 m_HonorTics;
uint32 m_honorTicks;
uint32 m_ReputationTics;
// need for achievements
bool m_TeamScores500Disadvantage[BG_TEAMS_COUNT];

View file

@ -63,7 +63,7 @@ void BattleGroundWS::Update(uint32 diff)
if (m_FlagsDropTimer[BG_TEAM_ALLIANCE] < 0)
{
m_FlagsDropTimer[BG_TEAM_ALLIANCE] = 0;
RespawnFlagAfterDrop(ALLIANCE);
RespawnDroppedFlag(ALLIANCE);
}
}
if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
@ -83,18 +83,15 @@ void BattleGroundWS::Update(uint32 diff)
if (m_FlagsDropTimer[BG_TEAM_HORDE] < 0)
{
m_FlagsDropTimer[BG_TEAM_HORDE] = 0;
RespawnFlagAfterDrop(HORDE);
RespawnDroppedFlag(HORDE);
}
}
if (m_EndTimer <= diff)
{
uint32 allianceScore = GetTeamScore(ALLIANCE);
uint32 hordeScore = GetTeamScore(HORDE);
if (allianceScore > hordeScore)
if (m_TeamScores[BG_TEAM_ALLIANCE] > m_TeamScores[BG_TEAM_HORDE])
EndBattleGround(ALLIANCE);
else if (allianceScore < hordeScore)
else if (m_TeamScores[BG_TEAM_ALLIANCE] < m_TeamScores[BG_TEAM_HORDE])
EndBattleGround(HORDE);
else
{
@ -166,7 +163,7 @@ void BattleGroundWS::RespawnFlag(Team team, bool captured)
}
}
void BattleGroundWS::RespawnFlagAfterDrop(Team team)
void BattleGroundWS::RespawnDroppedFlag(Team team)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
@ -195,34 +192,32 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source)
m_LastCapturedFlagTeam = source->GetTeam();
Team winner = TEAM_NONE;
source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if (source->GetTeam() == ALLIANCE)
{
if (!IsHordeFlagPickedup())
if (!IsHordeFlagPickedUp())
return;
ClearHordeFlagPicker(); // must be before aura remove to prevent 2 events (drop+capture) at the same time
ClearHordeFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// horde flag in base (but not respawned yet)
m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Horde Flag from Player
source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
if (GetTeamScore(ALLIANCE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(ALLIANCE, 1);
if (m_TeamScores[BG_TEAM_ALLIANCE] < BG_WS_MAX_TEAM_SCORE)
m_TeamScores[BG_TEAM_ALLIANCE] += 1;
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE);
}
else
{
if (!IsAllianceFlagPickedup())
if (!IsAllianceFlagPickedUp())
return;
ClearAllianceFlagPicker(); // must be before aura remove to prevent 2 events (drop+capture) at the same time
ClearAllianceFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// alliance flag in base (but not respawned yet)
m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Alliance Flag from Player
source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
if (GetTeamScore(HORDE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(HORDE, 1);
if (m_TeamScores[BG_TEAM_HORDE] < BG_WS_MAX_TEAM_SCORE)
m_TeamScores[BG_TEAM_HORDE] += 1;
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
RewardReputationToTeam(889, m_ReputationCapture, HORDE);
}
@ -243,10 +238,10 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source)
// only flag capture should be updated
UpdatePlayerScore(source, SCORE_FLAG_CAPTURES, 1); // +1 flag captures
if (GetTeamScore(ALLIANCE) == BG_WS_MAX_TEAM_SCORE)
Team winner = TEAM_NONE;
if (m_TeamScores[BG_TEAM_ALLIANCE] == BG_WS_MAX_TEAM_SCORE)
winner = ALLIANCE;
if (GetTeamScore(HORDE) == BG_WS_MAX_TEAM_SCORE)
else if (m_TeamScores[BG_TEAM_HORDE] == BG_WS_MAX_TEAM_SCORE)
winner = HORDE;
if (winner)
@ -272,21 +267,21 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
// just take off the aura
if (source->GetTeam() == ALLIANCE)
{
if (!IsHordeFlagPickedup())
if (!IsHordeFlagPickedUp())
return;
if (GetHordeFlagPickerGuid() == source->GetObjectGuid())
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
{
ClearHordeFlagPicker();
ClearHordeFlagCarrier();
source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
}
}
else
{
if (!IsAllianceFlagPickedup())
if (!IsAllianceFlagPickedUp())
return;
if (GetAllianceFlagPickerGuid() == source->GetObjectGuid())
if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid())
{
ClearAllianceFlagPicker();
ClearAllianceFlagCarrier();
source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
}
}
@ -297,11 +292,11 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
if (source->GetTeam() == ALLIANCE)
{
if (!IsHordeFlagPickedup())
if (!IsHordeFlagPickedUp())
return;
if (GetHordeFlagPickerGuid() == source->GetObjectGuid())
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
{
ClearHordeFlagPicker();
ClearHordeFlagCarrier();
source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_GROUND;
source->CastSpell(source, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true);
@ -310,11 +305,11 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
}
else
{
if (!IsAllianceFlagPickedup())
if (!IsAllianceFlagPickedUp())
return;
if (GetAllianceFlagPickerGuid() == source->GetObjectGuid())
if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid())
{
ClearAllianceFlagPicker();
ClearAllianceFlagCarrier();
source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND;
source->CastSpell(source, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true);
@ -360,7 +355,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
type = CHAT_MSG_BG_SYSTEM_HORDE;
PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP);
SpawnEvent(WS_EVENT_FLAG_A, 0, false);
SetAllianceFlagPicker(source->GetObjectGuid());
SetAllianceFlagCarrier(source->GetObjectGuid());
m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
// update world state to show correct flag carrier
UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER);
@ -376,7 +371,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
type = CHAT_MSG_BG_SYSTEM_ALLIANCE;
PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP);
SpawnEvent(WS_EVENT_FLAG_H, 0, false);
SetHordeFlagPicker(source->GetObjectGuid());
SetHordeFlagCarrier(source->GetObjectGuid());
m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
// update world state to show correct flag carrier
UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER);
@ -402,7 +397,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
type = CHAT_MSG_BG_SYSTEM_HORDE;
PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP);
SpawnEvent(WS_EVENT_FLAG_A, 0, false);
SetAllianceFlagPicker(source->GetObjectGuid());
SetAllianceFlagCarrier(source->GetObjectGuid());
source->CastSpell(source, BG_WS_SPELL_SILVERWING_FLAG, true);
m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER);
@ -430,7 +425,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
type = CHAT_MSG_BG_SYSTEM_ALLIANCE;
PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP);
SpawnEvent(WS_EVENT_FLAG_H, 0, false);
SetHordeFlagPicker(source->GetObjectGuid());
SetHordeFlagCarrier(source->GetObjectGuid());
source->CastSpell(source, BG_WS_SPELL_WARSONG_FLAG, true);
m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER);
@ -450,23 +445,23 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
void BattleGroundWS::RemovePlayer(Player* plr, ObjectGuid guid)
{
// sometimes flag aura not removed :(
if (IsAllianceFlagPickedup() && m_FlagKeepers[BG_TEAM_ALLIANCE] == guid)
if (IsAllianceFlagPickedUp() && m_flagCarrierAlliance == guid)
{
if (!plr)
{
sLog.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
ClearAllianceFlagPicker();
ClearAllianceFlagCarrier();
RespawnFlag(ALLIANCE, false);
}
else
EventPlayerDroppedFlag(plr);
}
if (IsHordeFlagPickedup() && m_FlagKeepers[BG_TEAM_HORDE] == guid)
if (IsHordeFlagPickedUp() && m_flagCarrierHorde == guid)
{
if (!plr)
{
sLog.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
ClearHordeFlagPicker();
ClearHordeFlagCarrier();
RespawnFlag(HORDE, false);
}
else
@ -485,9 +480,9 @@ void BattleGroundWS::UpdateFlagState(Team team, uint32 value)
void BattleGroundWS::UpdateTeamScore(Team team)
{
if (team == ALLIANCE)
UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE, GetTeamScore(team));
UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE, m_TeamScores[BG_TEAM_ALLIANCE]);
else
UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE, GetTeamScore(team));
UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE, m_TeamScores[BG_TEAM_HORDE]);
}
void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
@ -509,12 +504,12 @@ void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
break;
case 3646: // Alliance Flag spawn
if (m_FlagState[BG_TEAM_HORDE] && !m_FlagState[BG_TEAM_ALLIANCE])
if (GetHordeFlagPickerGuid() == source->GetObjectGuid())
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
EventPlayerCapturedFlag(source);
break;
case 3647: // Horde Flag spawn
if (m_FlagState[BG_TEAM_ALLIANCE] && !m_FlagState[BG_TEAM_HORDE])
if (GetAllianceFlagPickerGuid() == source->GetObjectGuid())
if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid())
EventPlayerCapturedFlag(source);
break;
case 3649: // unk1
@ -547,10 +542,13 @@ void BattleGroundWS::Reset()
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
{
m_DroppedFlagGuid[i].Clear();
m_FlagKeepers[i].Clear();
m_FlagState[i] = BG_WS_FLAG_STATE_ON_BASE;
m_TeamScores[i] = 0;
}
m_flagCarrierAlliance.Clear();
m_flagCarrierHorde.Clear();
bool isBGWeekend = BattleGroundMgr::IsBGWeekend(GetTypeID());
m_ReputationCapture = (isBGWeekend) ? 45 : 35;
m_HonorWinKills = (isBGWeekend) ? 3 : 1;
@ -630,8 +628,8 @@ WorldSafeLocsEntry const* BattleGroundWS::GetClosestGraveYard(Player* player)
void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count)
{
FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_ALLIANCE, GetTeamScore(ALLIANCE));
FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_HORDE, GetTeamScore(HORDE));
FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_ALLIANCE, m_TeamScores[BG_TEAM_ALLIANCE]);
FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_HORDE, m_TeamScores[BG_TEAM_HORDE]);
if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, -1);

View file

@ -110,17 +110,21 @@ class BattleGroundWS : public BattleGround
virtual void StartingEventOpenDoors() override;
/* BG Flags */
ObjectGuid GetAllianceFlagPickerGuid() const { return m_FlagKeepers[BG_TEAM_ALLIANCE]; }
ObjectGuid GetHordeFlagPickerGuid() const { return m_FlagKeepers[BG_TEAM_HORDE]; }
void SetAllianceFlagPicker(ObjectGuid guid) { m_FlagKeepers[BG_TEAM_ALLIANCE] = guid; }
void SetHordeFlagPicker(ObjectGuid guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; }
void ClearAllianceFlagPicker() { m_FlagKeepers[BG_TEAM_ALLIANCE].Clear(); }
void ClearHordeFlagPicker() { m_FlagKeepers[BG_TEAM_HORDE].Clear(); }
bool IsAllianceFlagPickedup() const { return !m_FlagKeepers[BG_TEAM_ALLIANCE].IsEmpty(); }
bool IsHordeFlagPickedup() const { return !m_FlagKeepers[BG_TEAM_HORDE].IsEmpty(); }
ObjectGuid GetAllianceFlagCarrierGuid() const { return m_flagCarrierAlliance; }
ObjectGuid GetHordeFlagCarrierGuid() const { return m_flagCarrierHorde; }
void SetAllianceFlagCarrier(ObjectGuid guid) { m_flagCarrierAlliance = guid; }
void SetHordeFlagCarrier(ObjectGuid guid) { m_flagCarrierHorde = guid; }
void ClearAllianceFlagCarrier() { m_flagCarrierAlliance.Clear(); }
void ClearHordeFlagCarrier() { m_flagCarrierHorde.Clear(); }
bool IsAllianceFlagPickedUp() const { return !m_flagCarrierAlliance.IsEmpty(); }
bool IsHordeFlagPickedUp() const { return !m_flagCarrierHorde.IsEmpty(); }
void RespawnFlag(Team team, bool captured);
void RespawnFlagAfterDrop(Team team);
uint8 GetFlagState(Team team) { return m_FlagState[GetTeamIndexByTeamId(team)]; }
void RespawnDroppedFlag(Team team);
uint8 GetFlagState(Team team) { return m_FlagState[GetTeamIndexByTeamId(team)]; }
/* Battleground Events */
virtual void EventPlayerDroppedFlag(Player* source) override;
@ -144,13 +148,9 @@ class BattleGroundWS : public BattleGround
ObjectGuid const& GetDroppedFlagGuid(Team team) const { return m_DroppedFlagGuid[GetTeamIndexByTeamId(team)];}
virtual void FillInitialWorldStates(WorldPacket& data, uint32& count) override;
/* Scorekeeping */
uint32 GetTeamScore(Team team) const { return m_TeamScores[GetTeamIndexByTeamId(team)]; }
void AddPoint(Team team, uint32 points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] += points; }
void SetTeamPoint(Team team, uint32 points = 0) { m_TeamScores[GetTeamIndexByTeamId(team)] = points; }
void RemovePoint(Team team, uint32 points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] -= points; }
private:
ObjectGuid m_FlagKeepers[BG_TEAMS_COUNT];
ObjectGuid m_flagCarrierAlliance;
ObjectGuid m_flagCarrierHorde;
ObjectGuid m_DroppedFlagGuid[BG_TEAMS_COUNT];
uint8 m_FlagState[BG_TEAMS_COUNT];

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12158"
#define REVISION_NR "12159"
#endif // __REVISION_NR_H__