void BattleGroundWS::EventPlayerCapturedFlag(Player* source) { if (GetStatus() != STATUS_IN_PROGRESS) return; m_LastCapturedFlagTeam = source->GetTeam(); source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) return; 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 (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()) return; 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 (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); } // for flag capture is reward 2 honorable kills RewardHonorToTeam(GetBonusHonorFromKill(2), source->GetTeam()); // despawn flags SpawnEvent(WS_EVENT_FLAG_A, 0, false); SpawnEvent(WS_EVENT_FLAG_H, 0, false); if (source->GetTeam() == ALLIANCE) SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); else SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, source); UpdateFlagState(source->GetTeam(), 1); // flag state none UpdateTeamScore(source->GetTeam()); // only flag capture should be updated UpdatePlayerScore(source, SCORE_FLAG_CAPTURES, 1); // +1 flag captures Team winner = TEAM_NONE; if (m_TeamScores[BG_TEAM_ALLIANCE] == BG_WS_MAX_TEAM_SCORE) winner = ALLIANCE; else if (m_TeamScores[BG_TEAM_HORDE] == BG_WS_MAX_TEAM_SCORE) winner = HORDE; if (winner) { UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 0); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 0); UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, 1); UpdateWorldState(BG_WS_FLAG_STATE_HORDE, 1); EndBattleGround(winner); } else { m_FlagsTimer[GetOtherTeamIndex(GetTeamIndexByTeamId(source->GetTeam()))] = BG_WS_FLAG_RESPAWN_TIME; } }
void BattleGroundWS::EventPlayerDroppedFlag(Player* source) { if (GetStatus() != STATUS_IN_PROGRESS) { // if not running, do not cast things at the dropper player (prevent spawning the "dropped" flag), neither send unnecessary messages // just take off the aura if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) return; if (GetHordeFlagCarrierGuid() == source->GetObjectGuid()) { ClearHordeFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); } } else { if (!IsAllianceFlagPickedUp()) return; if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid()) { ClearAllianceFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); } } return; } bool set = false; if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) return; if (GetHordeFlagCarrierGuid() == source->GetObjectGuid()) { ClearHordeFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); m_FlagState[TEAM_INDEX_HORDE] = BG_WS_FLAG_STATE_ON_GROUND; source->CastSpell(source, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true); set = true; } } else { if (!IsAllianceFlagPickedUp()) return; if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid()) { ClearAllianceFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); m_FlagState[TEAM_INDEX_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND; source->CastSpell(source, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true); set = true; } } if (set) { source->CastSpell(source, SPELL_RECENTLY_DROPPED_FLAG, true); UpdateFlagState(source->GetTeam(), 1); if (source->GetTeam() == ALLIANCE) { SendMessageToAll(LANG_BG_WS_DROPPED_HF, CHAT_MSG_BG_SYSTEM_HORDE, source); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, uint32(-1)); } else { SendMessageToAll(LANG_BG_WS_DROPPED_AF, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1)); } m_FlagsDropTimer[GetOtherTeamIndex(GetTeamIndex(source->GetTeam()))] = BG_WS_FLAG_DROP_TIME; } }