[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

@ -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);