Core/Battleground: Get rid of dinamic casts BattlegroundXX outside Battleground scope by implementing generic functions (1/2)

- HandleQuestComplete, CanActivateGO and IsSpellAllowed
This commit is contained in:
Spp committed 2013-08-07 10:31:13 +02:00
1 parent f245124127
commit b05665660a
22 files changed
+366 -401

No files matched your search

@@ -19,7 +19,6 @@
#include "AchievementMgr.h" #include "AchievementMgr.h"
#include "ArenaTeam.h" #include "ArenaTeam.h"
#include "ArenaTeamMgr.h" #include "ArenaTeamMgr.h"
#include "BattlegroundAB.h"
#include "Battleground.h" #include "Battleground.h"
#include "CellImpl.h" #include "CellImpl.h"
#include "Common.h" #include "Common.h"
+18 -20
View File
@@ -524,7 +524,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType()); BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetBGTeam()); sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetBGTeam());
player->GetSession()->SendPacket(&status); player->SendDirectMessage(&status);
player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION); player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
player->ResetAllPowers(); player->ResetAllPowers();
@@ -639,20 +639,19 @@ void Battleground::SendPacketToAll(WorldPacket* packet)
{ {
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (Player* player = _GetPlayer(itr, "SendPacketToAll")) if (Player* player = _GetPlayer(itr, "SendPacketToAll"))
player->GetSession()->SendPacket(packet); player->SendDirectMessage(packet);
} }
void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket* packet, Player* sender, bool self) void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket* packet, Player* sender, bool self)
{ {
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
if (Player* player = _GetPlayerForTeam(TeamID, itr, "SendPacketToTeam")) if (Player* player = _GetPlayerForTeam(TeamID, itr, "SendPacketToTeam"))
{
if (self || sender != player) if (self || sender != player)
{ player->SendDirectMessage(packet);
WorldSession* session = player->GetSession(); }
TC_LOG_DEBUG(LOG_FILTER_BATTLEGROUND, "%s %s - SendPacketToTeam %u, Player: %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), }
session->GetPlayerInfo().c_str(), TeamID, sender ? sender->GetName().c_str() : "null");
session->SendPacket(packet);
}
} }
void Battleground::PlaySoundToAll(uint32 SoundID) void Battleground::PlaySoundToAll(uint32 SoundID)
@@ -669,7 +668,7 @@ void Battleground::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
if (Player* player = _GetPlayerForTeam(TeamID, itr, "PlaySoundToTeam")) if (Player* player = _GetPlayerForTeam(TeamID, itr, "PlaySoundToTeam"))
{ {
sBattlegroundMgr->BuildPlaySoundPacket(&data, SoundID); sBattlegroundMgr->BuildPlaySoundPacket(&data, SoundID);
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
} }
} }
@@ -694,7 +693,7 @@ void Battleground::YellToAll(Creature* creature, char const* text, uint32 langua
{ {
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
creature->BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, text, language, creature->GetName(), itr->first); creature->BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, text, language, creature->GetName(), itr->first);
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
} }
} }
@@ -720,11 +719,11 @@ void Battleground::UpdateWorldState(uint32 Field, uint32 Value)
SendPacketToAll(&data); SendPacketToAll(&data);
} }
void Battleground::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* Source) void Battleground::UpdateWorldStateForPlayer(uint32 field, uint32 value, Player* player)
{ {
WorldPacket data; WorldPacket data;
sBattlegroundMgr->BuildUpdateWorldStatePacket(&data, Field, Value); sBattlegroundMgr->BuildUpdateWorldStatePacket(&data, field, value);
Source->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
} }
void Battleground::EndBattleground(uint32 winner) void Battleground::EndBattleground(uint32 winner)
@@ -916,11 +915,11 @@ void Battleground::EndBattleground(uint32 winner)
BlockMovement(player); BlockMovement(player);
player->GetSession()->SendPacket(&pvpLogData); player->SendDirectMessage(&pvpLogData);
WorldPacket data; WorldPacket data;
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetBGTeam()); sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetBGTeam());
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1); player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
} }
@@ -1023,7 +1022,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
{ {
WorldPacket data; WorldPacket data;
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0, 0); sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0, 0);
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
} }
// this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
@@ -1727,8 +1726,7 @@ void Battleground::SendWarningToAll(int32 entry, ...)
data << (uint8)0; data << (uint8)0;
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
if (player->GetSession()) player->SendDirectMessage(&data);
player->GetSession()->SendPacket(&data);
} }
void Battleground::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2) void Battleground::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2)
@@ -1860,10 +1858,10 @@ void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player)
BlockMovement(player); BlockMovement(player);
sBattlegroundMgr->BuildPvpLogDataPacket(&data, this); sBattlegroundMgr->BuildPvpLogDataPacket(&data, this);
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetBGTeam()); sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetBGTeam());
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
} }
uint32 Battleground::GetAlivePlayersCountByTeam(uint32 Team) const uint32 Battleground::GetAlivePlayersCountByTeam(uint32 Team) const
+7 -48
View File
@@ -29,17 +29,6 @@ class Group;
class Player; class Player;
class WorldPacket; class WorldPacket;
class BattlegroundMap; class BattlegroundMap;
class BattlegroundAV;
class BattlegroundWS;
class BattlegroundAB;
class BattlegroundNA;
class BattlegroundBE;
class BattlegroundEY;
class BattlegroundRL;
class BattlegroundSA;
class BattlegroundDS;
class BattlegroundRV;
class BattlegroundIC;
struct PvPDifficultyEntry; struct PvPDifficultyEntry;
struct WorldSafeLocsEntry; struct WorldSafeLocsEntry;
@@ -300,7 +289,7 @@ class Battleground
virtual void DestroyGate(Player* /*player*/, GameObject* /*go*/) {} virtual void DestroyGate(Player* /*player*/, GameObject* /*go*/) {}
/* achievement req. */ /* achievement req. */
virtual bool IsAllNodesConrolledByTeam(uint32 /*team*/) const { return false; } virtual bool IsAllNodesControlledByTeam(uint32 /*team*/) const { return false; }
void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry); void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry);
/* Battleground */ /* Battleground */
@@ -433,7 +422,7 @@ class Battleground
void RewardHonorToTeam(uint32 Honor, uint32 TeamID); void RewardHonorToTeam(uint32 Honor, uint32 TeamID);
void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID); void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID);
void UpdateWorldState(uint32 Field, uint32 Value); void UpdateWorldState(uint32 Field, uint32 Value);
void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* Source); void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* player);
void EndBattleground(uint32 winner); void EndBattleground(uint32 winner);
void BlockMovement(Player* player); void BlockMovement(Player* player);
@@ -448,7 +437,7 @@ class Battleground
Group* GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE]; } Group* GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE]; }
void SetBgRaid(uint32 TeamID, Group* bg_raid); void SetBgRaid(uint32 TeamID, Group* bg_raid);
virtual void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); virtual void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
static TeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } static TeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; } uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; }
@@ -477,7 +466,7 @@ class Battleground
// Triggers handle // Triggers handle
// must be implemented in BG subclass // must be implemented in BG subclass
virtual void HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/); virtual void HandleAreaTrigger(Player* /*player*/, uint32 /*Trigger*/);
// must be implemented in BG subclass if need AND call base class generic code // must be implemented in BG subclass if need AND call base class generic code
virtual void HandleKillPlayer(Player* player, Player* killer); virtual void HandleKillPlayer(Player* player, Player* killer);
virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/); virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/);
@@ -541,43 +530,13 @@ class Battleground
virtual uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return 0; } virtual uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return 0; }
virtual void SetDroppedFlagGUID(uint64 /*guid*/, int32 /*team*/ = -1) {} virtual void SetDroppedFlagGUID(uint64 /*guid*/, int32 /*team*/ = -1) {}
virtual void HandleQuestComplete(uint32 /*questid*/, Player* /*player*/) {}
virtual bool CanActivateGO(int32 /*entry*/, uint32 /*team*/) const { return true; }
virtual bool IsSpellAllowed(uint32 /*spellId*/, Player const* /*player*/) const { return true; }
uint32 GetTeamScore(uint32 TeamID) const; uint32 GetTeamScore(uint32 TeamID) const;
virtual uint32 GetPrematureWinner(); virtual uint32 GetPrematureWinner();
BattlegroundAV* ToBattlegroundAV() { if (GetTypeID() == BATTLEGROUND_AV) return reinterpret_cast<BattlegroundAV*>(this); else return NULL; }
BattlegroundAV const* ToBattlegroundAV() const { if (GetTypeID() == BATTLEGROUND_AV) return reinterpret_cast<const BattlegroundAV*>(this); else return NULL; }
BattlegroundWS* ToBattlegroundWS() { if (GetTypeID() == BATTLEGROUND_WS) return reinterpret_cast<BattlegroundWS*>(this); else return NULL; }
BattlegroundWS const* ToBattlegroundWS() const { if (GetTypeID() == BATTLEGROUND_WS) return reinterpret_cast<const BattlegroundWS*>(this); else return NULL; }
BattlegroundAB* ToBattlegroundAB() { if (GetTypeID() == BATTLEGROUND_AB) return reinterpret_cast<BattlegroundAB*>(this); else return NULL; }
BattlegroundAB const* ToBattlegroundAB() const { if (GetTypeID() == BATTLEGROUND_AB) return reinterpret_cast<const BattlegroundAB*>(this); else return NULL; }
BattlegroundNA* ToBattlegroundNA() { if (GetTypeID() == BATTLEGROUND_NA) return reinterpret_cast<BattlegroundNA*>(this); else return NULL; }
BattlegroundNA const* ToBattlegroundNA() const { if (GetTypeID() == BATTLEGROUND_NA) return reinterpret_cast<const BattlegroundNA*>(this); else return NULL; }
BattlegroundBE* ToBattlegroundBE() { if (GetTypeID() == BATTLEGROUND_BE) return reinterpret_cast<BattlegroundBE*>(this); else return NULL; }
BattlegroundBE const* ToBattlegroundBE() const { if (GetTypeID() == BATTLEGROUND_BE) return reinterpret_cast<const BattlegroundBE*>(this); else return NULL; }
BattlegroundEY* ToBattlegroundEY() { if (GetTypeID() == BATTLEGROUND_EY) return reinterpret_cast<BattlegroundEY*>(this); else return NULL; }
BattlegroundEY const* ToBattlegroundEY() const { if (GetTypeID() == BATTLEGROUND_EY) return reinterpret_cast<const BattlegroundEY*>(this); else return NULL; }
BattlegroundRL* ToBattlegroundRL() { if (GetTypeID() == BATTLEGROUND_RL) return reinterpret_cast<BattlegroundRL*>(this); else return NULL; }
BattlegroundRL const* ToBattlegroundRL() const { if (GetTypeID() == BATTLEGROUND_RL) return reinterpret_cast<const BattlegroundRL*>(this); else return NULL; }
BattlegroundSA* ToBattlegroundSA() { if (GetTypeID() == BATTLEGROUND_SA) return reinterpret_cast<BattlegroundSA*>(this); else return NULL; }
BattlegroundSA const* ToBattlegroundSA() const { if (GetTypeID() == BATTLEGROUND_SA) return reinterpret_cast<const BattlegroundSA*>(this); else return NULL; }
BattlegroundDS* ToBattlegroundDS() { if (GetTypeID() == BATTLEGROUND_DS) return reinterpret_cast<BattlegroundDS*>(this); else return NULL; }
BattlegroundDS const* ToBattlegroundDS() const { if (GetTypeID() == BATTLEGROUND_DS) return reinterpret_cast<const BattlegroundDS*>(this); else return NULL; }
BattlegroundRV* ToBattlegroundRV() { if (GetTypeID() == BATTLEGROUND_RV) return reinterpret_cast<BattlegroundRV*>(this); else return NULL; }
BattlegroundRV const* ToBattlegroundRV() const { if (GetTypeID() == BATTLEGROUND_RV) return reinterpret_cast<const BattlegroundRV*>(this); else return NULL; }
BattlegroundIC* ToBattlegroundIC() { if (GetTypeID() == BATTLEGROUND_IC) return reinterpret_cast<BattlegroundIC*>(this); else return NULL; }
BattlegroundIC const* ToBattlegroundIC() const { if (GetTypeID() == BATTLEGROUND_IC) return reinterpret_cast<const BattlegroundIC*>(this); else return NULL; }
protected: protected:
// this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground // this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground
void EndNow(); void EndNow();
@@ -111,23 +111,28 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
int points = team_points[team]; int points = team_points[team];
if (!points) if (!points)
continue; continue;
m_lastTick[team] += diff; m_lastTick[team] += diff;
if (m_lastTick[team] > BG_AB_TickIntervals[points]) if (m_lastTick[team] > BG_AB_TickIntervals[points])
{ {
m_lastTick[team] -= BG_AB_TickIntervals[points]; m_lastTick[team] -= BG_AB_TickIntervals[points];
m_TeamScores[team] += BG_AB_TickPoints[points]; m_TeamScores[team] += BG_AB_TickPoints[points];
m_HonorScoreTics[team] += BG_AB_TickPoints[points]; m_HonorScoreTics[team] += BG_AB_TickPoints[points];
m_ReputationScoreTics[team] += BG_AB_TickPoints[points]; m_ReputationScoreTics[team] += BG_AB_TickPoints[points];
if (m_ReputationScoreTics[team] >= m_ReputationTics) if (m_ReputationScoreTics[team] >= m_ReputationTics)
{ {
(team == TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE); (team == TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
m_ReputationScoreTics[team] -= m_ReputationTics; m_ReputationScoreTics[team] -= m_ReputationTics;
} }
if (m_HonorScoreTics[team] >= m_HonorTics) if (m_HonorScoreTics[team] >= m_HonorTics)
{ {
RewardHonorToTeam(GetBonusHonorFromKill(1), (team == TEAM_ALLIANCE) ? ALLIANCE : HORDE); RewardHonorToTeam(GetBonusHonorFromKill(1), (team == TEAM_ALLIANCE) ? ALLIANCE : HORDE);
m_HonorScoreTics[team] -= m_HonorTics; m_HonorScoreTics[team] -= m_HonorTics;
} }
if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE) if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE)
{ {
if (team == TEAM_ALLIANCE) if (team == TEAM_ALLIANCE)
@@ -140,9 +145,10 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
if (m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE) if (m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE)
m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE; m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE;
if (team == TEAM_ALLIANCE) if (team == TEAM_ALLIANCE)
UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]); UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]);
if (team == TEAM_HORDE) else if (team == TEAM_HORDE)
UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]); UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]);
// update achievement flags // update achievement flags
// we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources // we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources
@@ -155,7 +161,7 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
// Test win condition // Test win condition
if (m_TeamScores[TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE) if (m_TeamScores[TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE)
EndBattleground(ALLIANCE); EndBattleground(ALLIANCE);
if (m_TeamScores[TEAM_HORDE] >= BG_AB_MAX_TEAM_SCORE) else if (m_TeamScores[TEAM_HORDE] >= BG_AB_MAX_TEAM_SCORE)
EndBattleground(HORDE); EndBattleground(HORDE);
} }
} }
@@ -397,8 +403,7 @@ void BattlegroundAB::_NodeDeOccupied(uint8 node)
RelocateDeadPlayers(BgCreatures[node]); RelocateDeadPlayers(BgCreatures[node]);
if (BgCreatures[node]) DelCreature(node);
DelCreature(node);
// buff object isn't despawned // buff object isn't despawned
} }
@@ -696,7 +701,7 @@ void BattlegroundAB::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
} }
} }
bool BattlegroundAB::IsAllNodesConrolledByTeam(uint32 team) const bool BattlegroundAB::IsAllNodesControlledByTeam(uint32 team) const
{ {
uint32 count = 0; uint32 count = 0;
for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i) for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
@@ -270,7 +270,7 @@ class BattlegroundAB : public Battleground
void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj);
/* achievement req. */ /* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited bool IsAllNodesControlledByTeam(uint32 team) const;
bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; } bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
uint32 GetPrematureWinner(); uint32 GetPrematureWinner();
@@ -445,7 +445,7 @@ void BattlegroundAV::StartingEventOpenDoors()
DoorOpen(BG_AV_OBJECT_DOOR_A); DoorOpen(BG_AV_OBJECT_DOOR_A);
// Achievement: The Alterac Blitz // Achievement: The Alterac Blitz
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, AV_EVENT_START_BATTLE); StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, BG_AV_EVENT_START_BATTLE);
} }
void BattlegroundAV::AddPlayer(Player* player) void BattlegroundAV::AddPlayer(Player* player)
@@ -733,7 +733,7 @@ void BattlegroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial)
return; return;
} }
bool BattlegroundAV::PlayerCanDoMineQuest(int32 GOId, uint32 team) bool BattlegroundAV::CanActivateGO(int32 GOId, uint32 team) const
{ {
if (GOId == BG_AV_OBJECTID_MINE_N) if (GOId == BG_AV_OBJECTID_MINE_N)
return (m_Mine_Owner[AV_NORTH_MINE] == team); return (m_Mine_Owner[AV_NORTH_MINE] == team);
@@ -50,7 +50,7 @@
#define BG_AV_KILL_SURVIVING_CAPTAIN 2 #define BG_AV_KILL_SURVIVING_CAPTAIN 2
#define BG_AV_REP_SURVIVING_CAPTAIN 125 #define BG_AV_REP_SURVIVING_CAPTAIN 125
#define AV_EVENT_START_BATTLE 9166 // Achievement: The Alterac Blitz #define BG_AV_EVENT_START_BATTLE 9166 // Achievement: The Alterac Blitz
enum BG_AV_Sounds enum BG_AV_Sounds
{ /// @todo: get out if there comes a sound when neutral team captures mine { /// @todo: get out if there comes a sound when neutral team captures mine
@@ -1527,7 +1527,8 @@ inline BG_AV_Nodes &operator++(BG_AV_Nodes &i){ return i = BG_AV_Nodes(i + 1); }
struct BattlegroundAVScore : public BattlegroundScore struct BattlegroundAVScore : public BattlegroundScore
{ {
BattlegroundAVScore() : GraveyardsAssaulted(0), GraveyardsDefended(0), TowersAssaulted(0), TowersDefended(0), MinesCaptured(0), LeadersKilled(0), SecondaryObjectives(0) { } BattlegroundAVScore() : GraveyardsAssaulted(0), GraveyardsDefended(0), TowersAssaulted(0),
TowersDefended(0), MinesCaptured(0), LeadersKilled(0), SecondaryObjectives(0) { }
~BattlegroundAVScore() { } ~BattlegroundAVScore() { }
uint32 GraveyardsAssaulted; uint32 GraveyardsAssaulted;
uint32 GraveyardsDefended; uint32 GraveyardsDefended;
@@ -1550,20 +1551,20 @@ class BattlegroundAV : public Battleground
void StartingEventOpenDoors(); void StartingEventOpenDoors();
void RemovePlayer(Player* player, uint64 guid, uint32 team); void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger); void HandleAreaTrigger(Player* player, uint32 trigger);
bool SetupBattleground(); bool SetupBattleground();
void ResetBGSubclass(); void ResetBGSubclass();
/*general stuff*/ /*general stuff*/
void UpdateScore(uint16 team, int16 points); void UpdateScore(uint16 team, int16 points);
void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
/*handlestuff*/ //these are functions which get called from extern /*handlestuff*/ //these are functions which get called from extern
void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj);
void HandleKillPlayer(Player* player, Player* killer); void HandleKillPlayer(Player* player, Player* killer);
void HandleKillUnit(Creature* unit, Player* killer); void HandleKillUnit(Creature* unit, Player* killer);
void HandleQuestComplete(uint32 questid, Player* player); void HandleQuestComplete(uint32 questid, Player* player);
bool PlayerCanDoMineQuest(int32 GOId, uint32 team); bool CanActivateGO(int32 GOId, uint32 team) const;
void EndBattleground(uint32 winner); void EndBattleground(uint32 winner);
@@ -142,12 +142,10 @@ bool BattlegroundBE::SetupBattleground()
void BattlegroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) void BattlegroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor)
{ {
BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID()); BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID());
if (itr == PlayerScores.end()) // player not found... if (itr == PlayerScores.end()) // player not found...
return; return;
//there is nothing special in this score //there is nothing special in this score
Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); Battleground::UpdatePlayerScore(Source, type, value, doAddHonor);
} }
@@ -33,7 +33,6 @@ BattlegroundDS::BattlegroundDS()
StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S; StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_15S; StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_15S;
StartDelayTimes[BG_STARTING_EVENT_FOURTH] = BG_START_DELAY_NONE; StartDelayTimes[BG_STARTING_EVENT_FOURTH] = BG_START_DELAY_NONE;
//we must set messageIds
StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_ARENA_ONE_MINUTE; StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_ARENA_ONE_MINUTE;
StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_ARENA_THIRTY_SECONDS; StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_ARENA_THIRTY_SECONDS;
StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_ARENA_FIFTEEN_SECONDS; StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_ARENA_FIFTEEN_SECONDS;
@@ -122,7 +122,7 @@ void BattlegroundEY::StartingEventOpenDoors()
} }
// Achievement: Flurry // Achievement: Flurry
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EY_EVENT_START_BATTLE); StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, BG_EY_EVENT_START_BATTLE);
} }
void BattlegroundEY::AddPoints(uint32 Team, uint32 Points) void BattlegroundEY::AddPoints(uint32 Team, uint32 Points)
@@ -591,16 +591,16 @@ void BattlegroundEY::HandleKillPlayer(Player* player, Player* killer)
EventPlayerDroppedFlag(player); EventPlayerDroppedFlag(player);
} }
void BattlegroundEY::EventPlayerDroppedFlag(Player* Source) void BattlegroundEY::EventPlayerDroppedFlag(Player* player)
{ {
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
{ {
// if not running, do not cast things at the dropper player, neither send unnecessary messages // if not running, do not cast things at the dropper player, neither send unnecessary messages
// just take off the aura // just take off the aura
if (IsFlagPickedup() && GetFlagPickerGUID() == Source->GetGUID()) if (IsFlagPickedup() && GetFlagPickerGUID() == player->GetGUID())
{ {
SetFlagPicker(0); SetFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
} }
return; return;
} }
@@ -608,31 +608,31 @@ void BattlegroundEY::EventPlayerDroppedFlag(Player* Source)
if (!IsFlagPickedup()) if (!IsFlagPickedup())
return; return;
if (GetFlagPickerGUID() != Source->GetGUID()) if (GetFlagPickerGUID() != player->GetGUID())
return; return;
SetFlagPicker(0); SetFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
m_FlagState = BG_EY_FLAG_STATE_ON_GROUND; m_FlagState = BG_EY_FLAG_STATE_ON_GROUND;
m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME; m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
Source->CastSpell(Source, SPELL_RECENTLY_DROPPED_FLAG, true); player->CastSpell(player, SPELL_RECENTLY_DROPPED_FLAG, true);
Source->CastSpell(Source, BG_EY_PLAYER_DROPPED_FLAG_SPELL, true); player->CastSpell(player, BG_EY_PLAYER_DROPPED_FLAG_SPELL, true);
//this does not work correctly :((it should remove flag carrier name) //this does not work correctly :((it should remove flag carrier name)
UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_WAIT_RESPAWN); UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_WAIT_RESPAWN); UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL); SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL);
else else
SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL); SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL);
} }
void BattlegroundEY::EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj) void BattlegroundEY::EventPlayerClickedOnFlag(Player* player, GameObject* target_obj)
{ {
if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !Source->IsWithinDistInMap(target_obj, 10)) if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !player->IsWithinDistInMap(target_obj, 10))
return; return;
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
{ {
UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_ON_PLAYER); UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_ON_PLAYER);
PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE); PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE);
@@ -648,18 +648,18 @@ void BattlegroundEY::EventPlayerClickedOnFlag(Player* Source, GameObject* target
m_FlagState = BG_EY_FLAG_STATE_ON_PLAYER; m_FlagState = BG_EY_FLAG_STATE_ON_PLAYER;
SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_ONE_DAY); SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_ONE_DAY);
SetFlagPicker(Source->GetGUID()); SetFlagPicker(player->GetGUID());
//get flag aura on player //get flag aura on player
Source->CastSpell(Source, BG_EY_NETHERSTORM_FLAG_SPELL, true); player->CastSpell(player, BG_EY_NETHERSTORM_FLAG_SPELL, true);
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, Source->GetName().c_str()); PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, player->GetName().c_str());
else else
PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName().c_str()); PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, player->GetName().c_str());
} }
void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point) void BattlegroundEY::EventTeamLostPoint(Player* player, uint32 Point)
{ {
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
@@ -695,9 +695,9 @@ void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point)
m_PointState[Point] = EY_POINT_NO_OWNER; m_PointState[Point] = EY_POINT_NO_OWNER;
if (Team == ALLIANCE) if (Team == ALLIANCE)
SendMessageToAll(m_LosingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); SendMessageToAll(m_LosingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, player);
else else
SendMessageToAll(m_LosingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source); SendMessageToAll(m_LosingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, player);
UpdatePointsIcons(Team, Point); UpdatePointsIcons(Team, Point);
UpdatePointsCount(Team); UpdatePointsCount(Team);
@@ -707,12 +707,12 @@ void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point)
DelCreature(Point + 6);//NULL checks are in DelCreature! 0-5 spirit guides DelCreature(Point + 6);//NULL checks are in DelCreature! 0-5 spirit guides
} }
void BattlegroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point) void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point)
{ {
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
uint32 Team = Source->GetTeam(); uint32 Team = player->GetTeam();
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY); SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY);
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY); SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY);
@@ -739,9 +739,9 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point)
m_PointState[Point] = EY_POINT_UNDER_CONTROL; m_PointState[Point] = EY_POINT_UNDER_CONTROL;
if (Team == ALLIANCE) if (Team == ALLIANCE)
SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, player);
else else
SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source); SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, player);
if (BgCreatures[Point]) if (BgCreatures[Point])
DelCreature(Point); DelCreature(Point);
@@ -774,18 +774,18 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point)
} }
} }
void BattlegroundEY::EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType) void BattlegroundEY::EventPlayerCapturedFlag(Player* player, uint32 BgObjectType)
{ {
if (GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGUID() != Source->GetGUID()) if (GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGUID() != player->GetGUID())
return; return;
SetFlagPicker(0); SetFlagPicker(0);
m_FlagState = BG_EY_FLAG_STATE_WAIT_RESPAWN; m_FlagState = BG_EY_FLAG_STATE_WAIT_RESPAWN;
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE); PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE);
else else
PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_HORDE); PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_HORDE);
@@ -796,26 +796,26 @@ void BattlegroundEY::EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType
m_FlagCapturedBgObjectType = BgObjectType; m_FlagCapturedBgObjectType = BgObjectType;
uint8 team_id = 0; uint8 team_id = 0;
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
{ {
team_id = TEAM_ALLIANCE; team_id = TEAM_ALLIANCE;
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_A, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_A, CHAT_MSG_BG_SYSTEM_ALLIANCE, player);
} }
else else
{ {
team_id = TEAM_HORDE; team_id = TEAM_HORDE;
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_H, CHAT_MSG_BG_SYSTEM_HORDE, Source); SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_H, CHAT_MSG_BG_SYSTEM_HORDE, player);
} }
if (m_TeamPointsCount[team_id] > 0) if (m_TeamPointsCount[team_id] > 0)
AddPoints(Source->GetTeam(), BG_EY_FlagPoints[m_TeamPointsCount[team_id] - 1]); AddPoints(player->GetTeam(), BG_EY_FlagPoints[m_TeamPointsCount[team_id] - 1]);
UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1); UpdatePlayerScore(player, SCORE_FLAG_CAPTURES, 1);
} }
void BattlegroundEY::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) void BattlegroundEY::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor)
{ {
BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID()); BattlegroundScoreMap::iterator itr = PlayerScores.find(player->GetGUID());
if (itr == PlayerScores.end()) // player not found if (itr == PlayerScores.end()) // player not found
return; return;
@@ -823,10 +823,10 @@ void BattlegroundEY::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
{ {
case SCORE_FLAG_CAPTURES: // flags captured case SCORE_FLAG_CAPTURES: // flags captured
((BattlegroundEYScore*)itr->second)->FlagCaptures += value; ((BattlegroundEYScore*)itr->second)->FlagCaptures += value;
Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, EY_OBJECTIVE_CAPTURE_FLAG); player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, EY_OBJECTIVE_CAPTURE_FLAG);
break; break;
default: default:
Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); Battleground::UpdatePlayerScore(player, type, value, doAddHonor);
break; break;
} }
} }
@@ -934,7 +934,7 @@ WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveYard(Player* player)
return nearestEntry; return nearestEntry;
} }
bool BattlegroundEY::IsAllNodesConrolledByTeam(uint32 team) const bool BattlegroundEY::IsAllNodesControlledByTeam(uint32 team) const
{ {
uint32 count = 0; uint32 count = 0;
for (int i = 0; i < EY_POINTS_MAX; ++i) for (int i = 0; i < EY_POINTS_MAX; ++i)
@@ -952,4 +952,4 @@ uint32 BattlegroundEY::GetPrematureWinner()
return HORDE; return HORDE;
return Battleground::GetPrematureWinner(); return Battleground::GetPrematureWinner();
} }
@@ -24,6 +24,7 @@
enum BG_EY_Misc enum BG_EY_Misc
{ {
BG_EY_EVENT_START_BATTLE = 13180, // Achievement: Flurry
BG_EY_FLAG_RESPAWN_TIME = (8*IN_MILLISECONDS), BG_EY_FLAG_RESPAWN_TIME = (8*IN_MILLISECONDS),
BG_EY_FPOINTS_TICK_TIME = (2*IN_MILLISECONDS) BG_EY_FPOINTS_TICK_TIME = (2*IN_MILLISECONDS)
}; };
@@ -219,8 +220,6 @@ enum EYBattlegroundObjectTypes
#define BG_EY_NotEYWeekendHonorTicks 260 #define BG_EY_NotEYWeekendHonorTicks 260
#define BG_EY_EYWeekendHonorTicks 160 #define BG_EY_EYWeekendHonorTicks 160
#define EY_EVENT_START_BATTLE 13180 // Achievement: Flurry
enum BG_EY_Score enum BG_EY_Score
{ {
BG_EY_WARNING_NEAR_VICTORY_SCORE = 1400, BG_EY_WARNING_NEAR_VICTORY_SCORE = 1400,
@@ -368,7 +367,7 @@ class BattlegroundEY : public Battleground
void EventPlayerDroppedFlag(Player* Source); void EventPlayerDroppedFlag(Player* Source);
/* achievement req. */ /* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const; bool IsAllNodesControlledByTeam(uint32 team) const;
uint32 GetPrematureWinner(); uint32 GetPrematureWinner();
private: private:
@@ -84,7 +84,7 @@ void BattlegroundIC::SendTransportInit(Player* player)
WorldPacket packet; WorldPacket packet;
transData.BuildPacket(&packet); transData.BuildPacket(&packet);
player->GetSession()->SendPacket(&packet); player->SendDirectMessage(&packet);
} }
void BattlegroundIC::DoAction(uint32 action, uint64 var) void BattlegroundIC::DoAction(uint32 action, uint64 var)
@@ -290,19 +290,6 @@ void BattlegroundIC::StartingEventOpenDoors()
} }
} }
bool BattlegroundIC::IsAllNodesConrolledByTeam(uint32 team) const
{
uint32 count = 0;
ICNodeState controlledState = team == ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H;
for (int i = 0; i < NODE_TYPE_WORKSHOP; ++i)
{
if (nodePoint[i].nodeState == controlledState)
++count;
}
return count == NODE_TYPE_WORKSHOP;
}
void BattlegroundIC::AddPlayer(Player* player) void BattlegroundIC::AddPlayer(Player* player)
{ {
Battleground::AddPlayer(player); Battleground::AddPlayer(player);
@@ -349,9 +336,9 @@ void BattlegroundIC::HandleAreaTrigger(Player* player, uint32 trigger)
} }
} }
void BattlegroundIC::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) void BattlegroundIC::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor)
{ {
std::map<uint64, BattlegroundScore*>::iterator itr = PlayerScores.find(Source->GetGUID()); std::map<uint64, BattlegroundScore*>::iterator itr = PlayerScores.find(player->GetGUID());
if (itr == PlayerScores.end()) // player not found... if (itr == PlayerScores.end()) // player not found...
return; return;
@@ -365,7 +352,7 @@ void BattlegroundIC::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
((BattlegroundICScore*)itr->second)->BasesDefended += value; ((BattlegroundICScore*)itr->second)->BasesDefended += value;
break; break;
default: default:
Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); Battleground::UpdatePlayerScore(player, type, value, doAddHonor);
break; break;
} }
} }
@@ -888,8 +875,8 @@ WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveYard(Player* player)
// If so, select the closest node to place ghost on // If so, select the closest node to place ghost on
if (!nodes.empty()) if (!nodes.empty())
{ {
float plr_x = player->GetPositionX(); float player_x = player->GetPositionX();
float plr_y = player->GetPositionY(); float player_y = player->GetPositionY();
float mindist = 999999.0f; float mindist = 999999.0f;
for (uint8 i = 0; i < nodes.size(); ++i) for (uint8 i = 0; i < nodes.size(); ++i)
@@ -897,7 +884,7 @@ WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const*entry = sWorldSafeLocsStore.LookupEntry(BG_IC_GraveyardIds[nodes[i]]); WorldSafeLocsEntry const*entry = sWorldSafeLocsStore.LookupEntry(BG_IC_GraveyardIds[nodes[i]]);
if (!entry) if (!entry)
continue; continue;
float dist = (entry->x - plr_x)*(entry->x - plr_x)+(entry->y - plr_y)*(entry->y - plr_y); float dist = (entry->x - player_x)*(entry->x - player_x)+(entry->y - player_y)*(entry->y - player_y);
if (mindist > dist) if (mindist > dist)
{ {
mindist = dist; mindist = dist;
@@ -958,3 +945,35 @@ Transport* BattlegroundIC::CreateTransport(uint32 goEntry, uint32 period)
return t; return t;
} }
bool BattlegroundIC::IsAllNodesControlledByTeam(uint32 team) const
{
uint32 count = 0;
ICNodeState controlledState = team == ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H;
for (int i = 0; i < NODE_TYPE_WORKSHOP; ++i)
{
if (nodePoint[i].nodeState == controlledState)
++count;
}
return count == NODE_TYPE_WORKSHOP;
}
bool BattlegroundIC::IsSpellAllowed(uint32 spellId, Player const* player) const
{
switch (spellId)
{
case SPELL_OIL_REFINERY:
case SPELL_QUARRY:
{
uint32 team = player->GetTeamId();
uint8 nodeType = spellId = SPELL_OIL_REFINERY ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY;
uint8 nodeState = team == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H;
return GetNodeState(nodeType) == nodeState;
}
default:
break;
}
return true;
}
@@ -868,7 +868,7 @@ class BattlegroundIC : public Battleground
void PostUpdateImpl(uint32 diff); void PostUpdateImpl(uint32 diff);
void RemovePlayer(Player* player, uint64 guid, uint32 team); void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger); void HandleAreaTrigger(Player* player, uint32 trigger);
bool SetupBattleground(); bool SetupBattleground();
void SpawnLeader(uint32 teamid); void SpawnLeader(uint32 teamid);
void HandleKillUnit(Creature* unit, Player* killer); void HandleKillUnit(Creature* unit, Player* killer);
@@ -882,7 +882,7 @@ class BattlegroundIC : public Battleground
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
/* Scorekeeping */ /* Scorekeeping */
void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
void FillInitialWorldStates(WorldPacket& data); void FillInitialWorldStates(WorldPacket& data);
@@ -892,7 +892,9 @@ class BattlegroundIC : public Battleground
uint32 GetNodeState(uint8 nodeType) const { return (uint8)nodePoint[nodeType].nodeState; } uint32 GetNodeState(uint8 nodeType) const { return (uint8)nodePoint[nodeType].nodeState; }
bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited bool IsAllNodesControlledByTeam(uint32 team) const;
bool IsSpellAllowed(uint32 spellId, Player const* player) const;
private: private:
uint32 closeFortressDoorsTimer; uint32 closeFortressDoorsTimer;
bool doorsClosed; bool doorsClosed;
@@ -274,7 +274,7 @@ void BattlegroundSA::StartShips()
WorldPacket pkt; WorldPacket pkt;
GetBGObject(i)->BuildValuesUpdateBlockForPlayer(&data, p); GetBGObject(i)->BuildValuesUpdateBlockForPlayer(&data, p);
data.BuildPacket(&pkt); data.BuildPacket(&pkt);
p->GetSession()->SendPacket(&pkt); p->SendDirectMessage(&pkt);
} }
} }
} }
@@ -947,7 +947,7 @@ void BattlegroundSA::SendTransportInit(Player* player)
GetBGObject(BG_SA_BOAT_TWO)->BuildCreateUpdateBlockForPlayer(&transData, player); GetBGObject(BG_SA_BOAT_TWO)->BuildCreateUpdateBlockForPlayer(&transData, player);
WorldPacket packet; WorldPacket packet;
transData.BuildPacket(&packet); transData.BuildPacket(&packet);
player->GetSession()->SendPacket(&packet); player->SendDirectMessage(&packet);
} }
} }
@@ -962,6 +962,6 @@ void BattlegroundSA::SendTransportsRemove(Player* player)
GetBGObject(BG_SA_BOAT_TWO)->BuildOutOfRangeUpdateBlock(&transData); GetBGObject(BG_SA_BOAT_TWO)->BuildOutOfRangeUpdateBlock(&transData);
WorldPacket packet; WorldPacket packet;
transData.BuildPacket(&packet); transData.BuildPacket(&packet);
player->GetSession()->SendPacket(&packet); player->SendDirectMessage(&packet);
} }
} }
@@ -274,15 +274,15 @@ void BattlegroundWS::RespawnFlagAfterDrop(uint32 team)
_bothFlagsKept = false; _bothFlagsKept = false;
} }
void BattlegroundWS::EventPlayerCapturedFlag(Player* Source) void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
{ {
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
uint32 winner = 0; uint32 winner = 0;
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
{ {
if (!IsHordeFlagPickedup()) if (!IsHordeFlagPickedup())
return; return;
@@ -290,11 +290,12 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* Source)
// horde flag in base (but not respawned yet) // horde flag in base (but not respawned yet)
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Horde Flag from Player // Drop Horde Flag from Player
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); player->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
if (_flagDebuffState == 1) if (_flagDebuffState == 1)
Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
if (_flagDebuffState == 2) else if (_flagDebuffState == 2)
Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
if (GetTeamScore(TEAM_ALLIANCE) < BG_WS_MAX_TEAM_SCORE) if (GetTeamScore(TEAM_ALLIANCE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(ALLIANCE, 1); AddPoint(ALLIANCE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE); PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
@@ -308,34 +309,35 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* Source)
// alliance flag in base (but not respawned yet) // alliance flag in base (but not respawned yet)
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Alliance Flag from Player // Drop Alliance Flag from Player
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); player->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
if (_flagDebuffState == 1) if (_flagDebuffState == 1)
Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
if (_flagDebuffState == 2) else if (_flagDebuffState == 2)
Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
if (GetTeamScore(TEAM_HORDE) < BG_WS_MAX_TEAM_SCORE) if (GetTeamScore(TEAM_HORDE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(HORDE, 1); AddPoint(HORDE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE); PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
RewardReputationToTeam(889, m_ReputationCapture, HORDE); RewardReputationToTeam(889, m_ReputationCapture, HORDE);
} }
//for flag capture is reward 2 honorable kills //for flag capture is reward 2 honorable kills
RewardHonorToTeam(GetBonusHonorFromKill(2), Source->GetTeam()); RewardHonorToTeam(GetBonusHonorFromKill(2), player->GetTeam());
SpawnBGObject(BG_WS_OBJECT_H_FLAG, BG_WS_FLAG_RESPAWN_TIME); SpawnBGObject(BG_WS_OBJECT_H_FLAG, BG_WS_FLAG_RESPAWN_TIME);
SpawnBGObject(BG_WS_OBJECT_A_FLAG, BG_WS_FLAG_RESPAWN_TIME); SpawnBGObject(BG_WS_OBJECT_A_FLAG, BG_WS_FLAG_RESPAWN_TIME);
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, player);
else else
SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, Source); SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, player);
UpdateFlagState(Source->GetTeam(), 1); // flag state none UpdateFlagState(player->GetTeam(), 1); // flag state none
UpdateTeamScore(Source->GetTeamId()); UpdateTeamScore(player->GetTeamId());
// only flag capture should be updated // only flag capture should be updated
UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1); // +1 flag captures UpdatePlayerScore(player, SCORE_FLAG_CAPTURES, 1); // +1 flag captures
// update last flag capture to be used if teamscore is equal // update last flag capture to be used if teamscore is equal
SetLastFlagCapture(Source->GetTeam()); SetLastFlagCapture(player->GetTeam());
if (GetTeamScore(TEAM_ALLIANCE) == BG_WS_MAX_TEAM_SCORE) if (GetTeamScore(TEAM_ALLIANCE) == BG_WS_MAX_TEAM_SCORE)
winner = ALLIANCE; winner = ALLIANCE;
@@ -356,34 +358,36 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* Source)
} }
else else
{ {
_flagsTimer[GetTeamIndexByTeamId(Source->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME; _flagsTimer[GetTeamIndexByTeamId(player->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME;
} }
} }
void BattlegroundWS::EventPlayerDroppedFlag(Player* Source) void BattlegroundWS::EventPlayerDroppedFlag(Player* player)
{ {
if (GetStatus() != STATUS_IN_PROGRESS) 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 // 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 // just take off the aura
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
{ {
if (!IsHordeFlagPickedup()) if (!IsHordeFlagPickedup())
return; return;
if (GetFlagPickerGUID(TEAM_HORDE) == Source->GetGUID())
if (GetFlagPickerGUID(TEAM_HORDE) == player->GetGUID())
{ {
SetHordeFlagPicker(0); SetHordeFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); player->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
} }
} }
else else
{ {
if (!IsAllianceFlagPickedup()) if (!IsAllianceFlagPickedup())
return; return;
if (GetFlagPickerGUID(TEAM_ALLIANCE) == Source->GetGUID())
if (GetFlagPickerGUID(TEAM_ALLIANCE) == player->GetGUID())
{ {
SetAllianceFlagPicker(0); SetAllianceFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); player->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
} }
} }
return; return;
@@ -391,20 +395,20 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
bool set = false; bool set = false;
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
{ {
if (!IsHordeFlagPickedup()) if (!IsHordeFlagPickedup())
return; return;
if (GetFlagPickerGUID(TEAM_HORDE) == Source->GetGUID()) if (GetFlagPickerGUID(TEAM_HORDE) == player->GetGUID())
{ {
SetHordeFlagPicker(0); SetHordeFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); player->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
if (_flagDebuffState == 1) if (_flagDebuffState == 1)
Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
if (_flagDebuffState == 2) else if (_flagDebuffState == 2)
Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_GROUND; _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_GROUND;
Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true); player->CastSpell(player, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true);
set = true; set = true;
} }
} }
@@ -412,41 +416,41 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
{ {
if (!IsAllianceFlagPickedup()) if (!IsAllianceFlagPickedup())
return; return;
if (GetFlagPickerGUID(TEAM_ALLIANCE) == Source->GetGUID()) if (GetFlagPickerGUID(TEAM_ALLIANCE) == player->GetGUID())
{ {
SetAllianceFlagPicker(0); SetAllianceFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); player->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
if (_flagDebuffState == 1) if (_flagDebuffState == 1)
Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
if (_flagDebuffState == 2) else if (_flagDebuffState == 2)
Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND; _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND;
Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true); player->CastSpell(player, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true);
set = true; set = true;
} }
} }
if (set) if (set)
{ {
Source->CastSpell(Source, SPELL_RECENTLY_DROPPED_FLAG, true); player->CastSpell(player, SPELL_RECENTLY_DROPPED_FLAG, true);
UpdateFlagState(Source->GetTeam(), 1); UpdateFlagState(player->GetTeam(), 1);
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
{ {
SendMessageToAll(LANG_BG_WS_DROPPED_HF, CHAT_MSG_BG_SYSTEM_HORDE, Source); SendMessageToAll(LANG_BG_WS_DROPPED_HF, CHAT_MSG_BG_SYSTEM_HORDE, player);
UpdateWorldState(BG_WS_FLAG_UNK_HORDE, uint32(-1)); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, uint32(-1));
} }
else else
{ {
SendMessageToAll(LANG_BG_WS_DROPPED_AF, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); SendMessageToAll(LANG_BG_WS_DROPPED_AF, CHAT_MSG_BG_SYSTEM_ALLIANCE, player);
UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1)); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1));
} }
_flagsDropTimer[GetTeamIndexByTeamId(Source->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME; _flagsDropTimer[GetTeamIndexByTeamId(player->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME;
} }
} }
void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj) void BattlegroundWS::EventPlayerClickedOnFlag(Player* player, GameObject* target_obj)
{ {
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
@@ -455,48 +459,48 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
ChatMsg type = CHAT_MSG_BG_SYSTEM_NEUTRAL; ChatMsg type = CHAT_MSG_BG_SYSTEM_NEUTRAL;
//alliance flag picked up from base //alliance flag picked up from base
if (Source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE if (player->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE
&& BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID()) && BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID())
{ {
message_id = LANG_BG_WS_PICKEDUP_AF; message_id = LANG_BG_WS_PICKEDUP_AF;
type = CHAT_MSG_BG_SYSTEM_HORDE; type = CHAT_MSG_BG_SYSTEM_HORDE;
PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP);
SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY);
SetAllianceFlagPicker(Source->GetGUID()); SetAllianceFlagPicker(player->GetGUID());
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
//update world state to show correct flag carrier //update world state to show correct flag carrier
UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER);
UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1);
Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG, true); player->CastSpell(player, BG_WS_SPELL_SILVERWING_FLAG, true);
Source->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, BG_WS_SPELL_SILVERWING_FLAG_PICKED); player->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, BG_WS_SPELL_SILVERWING_FLAG_PICKED);
if (_flagState[1] == BG_WS_FLAG_STATE_ON_PLAYER) if (_flagState[1] == BG_WS_FLAG_STATE_ON_PLAYER)
_bothFlagsKept = true; _bothFlagsKept = true;
} }
//horde flag picked up from base //horde flag picked up from base
if (Source->GetTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE if (player->GetTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE
&& BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID()) && BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID())
{ {
message_id = LANG_BG_WS_PICKEDUP_HF; message_id = LANG_BG_WS_PICKEDUP_HF;
type = CHAT_MSG_BG_SYSTEM_ALLIANCE; type = CHAT_MSG_BG_SYSTEM_ALLIANCE;
PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP);
SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY);
SetHordeFlagPicker(Source->GetGUID()); SetHordeFlagPicker(player->GetGUID());
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
//update world state to show correct flag carrier //update world state to show correct flag carrier
UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER);
UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1);
Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG, true); player->CastSpell(player, BG_WS_SPELL_WARSONG_FLAG, true);
Source->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, BG_WS_SPELL_WARSONG_FLAG_PICKED); player->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, BG_WS_SPELL_WARSONG_FLAG_PICKED);
if (_flagState[0] == BG_WS_FLAG_STATE_ON_PLAYER) if (_flagState[0] == BG_WS_FLAG_STATE_ON_PLAYER)
_bothFlagsKept = true; _bothFlagsKept = true;
} }
//Alliance flag on ground(not in base) (returned or picked up again from ground!) //Alliance flag on ground(not in base) (returned or picked up again from ground!)
if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && player->IsWithinDistInMap(target_obj, 10)
&& target_obj->GetGOInfo()->entry == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY) && target_obj->GetGOInfo()->entry == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY)
{ {
if (Source->GetTeam() == ALLIANCE) if (player->GetTeam() == ALLIANCE)
{ {
message_id = LANG_BG_WS_RETURNED_AF; message_id = LANG_BG_WS_RETURNED_AF;
type = CHAT_MSG_BG_SYSTEM_ALLIANCE; type = CHAT_MSG_BG_SYSTEM_ALLIANCE;
@@ -504,7 +508,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
RespawnFlag(ALLIANCE, false); RespawnFlag(ALLIANCE, false);
SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_IMMEDIATELY);
PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED); PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED);
UpdatePlayerScore(Source, SCORE_FLAG_RETURNS, 1); UpdatePlayerScore(player, SCORE_FLAG_RETURNS, 1);
_bothFlagsKept = false; _bothFlagsKept = false;
} }
else else
@@ -513,14 +517,14 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
type = CHAT_MSG_BG_SYSTEM_HORDE; type = CHAT_MSG_BG_SYSTEM_HORDE;
PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP);
SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY);
SetAllianceFlagPicker(Source->GetGUID()); SetAllianceFlagPicker(player->GetGUID());
Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG, true); player->CastSpell(player, BG_WS_SPELL_SILVERWING_FLAG, true);
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER);
if (_flagDebuffState == 1) if (_flagDebuffState == 1)
Source->CastSpell(Source, WS_SPELL_FOCUSED_ASSAULT, true); player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true);
if (_flagDebuffState == 2) else if (_flagDebuffState == 2)
Source->CastSpell(Source, WS_SPELL_BRUTAL_ASSAULT, true); player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true);
UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1);
} }
//called in HandleGameObjectUseOpcode: //called in HandleGameObjectUseOpcode:
@@ -528,10 +532,10 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
} }
//Horde flag on ground(not in base) (returned or picked up again) //Horde flag on ground(not in base) (returned or picked up again)
if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && player->IsWithinDistInMap(target_obj, 10)
&& target_obj->GetGOInfo()->entry == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY) && target_obj->GetGOInfo()->entry == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY)
{ {
if (Source->GetTeam() == HORDE) if (player->GetTeam() == HORDE)
{ {
message_id = LANG_BG_WS_RETURNED_HF; message_id = LANG_BG_WS_RETURNED_HF;
type = CHAT_MSG_BG_SYSTEM_HORDE; type = CHAT_MSG_BG_SYSTEM_HORDE;
@@ -539,7 +543,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
RespawnFlag(HORDE, false); RespawnFlag(HORDE, false);
SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_IMMEDIATELY);
PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED); PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED);
UpdatePlayerScore(Source, SCORE_FLAG_RETURNS, 1); UpdatePlayerScore(player, SCORE_FLAG_RETURNS, 1);
_bothFlagsKept = false; _bothFlagsKept = false;
} }
else else
@@ -548,14 +552,14 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
type = CHAT_MSG_BG_SYSTEM_ALLIANCE; type = CHAT_MSG_BG_SYSTEM_ALLIANCE;
PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP);
SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY);
SetHordeFlagPicker(Source->GetGUID()); SetHordeFlagPicker(player->GetGUID());
Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG, true); player->CastSpell(player, BG_WS_SPELL_WARSONG_FLAG, true);
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER);
if (_flagDebuffState == 1) if (_flagDebuffState == 1)
Source->CastSpell(Source, WS_SPELL_FOCUSED_ASSAULT, true); player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true);
if (_flagDebuffState == 2) else if (_flagDebuffState == 2)
Source->CastSpell(Source, WS_SPELL_BRUTAL_ASSAULT, true); player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true);
UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1);
} }
//called in HandleGameObjectUseOpcode: //called in HandleGameObjectUseOpcode:
@@ -565,8 +569,8 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
if (!message_id) if (!message_id)
return; return;
SendMessageToAll(message_id, type, Source); SendMessageToAll(message_id, type, player);
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
} }
void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/) void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
@@ -660,7 +664,7 @@ void BattlegroundWS::HandleAreaTrigger(Player* player, uint32 trigger)
} }
//if (buff_guid) //if (buff_guid)
// HandleTriggerBuff(buff_guid, Source); // HandleTriggerBuff(buff_guid, player);
} }
bool BattlegroundWS::SetupBattleground() bool BattlegroundWS::SetupBattleground()
@@ -773,9 +777,9 @@ void BattlegroundWS::HandleKillPlayer(Player* player, Player* killer)
Battleground::HandleKillPlayer(player, killer); Battleground::HandleKillPlayer(player, killer);
} }
void BattlegroundWS::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) void BattlegroundWS::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor)
{ {
BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID()); BattlegroundScoreMap::iterator itr = PlayerScores.find(player->GetGUID());
if (itr == PlayerScores.end()) // player not found if (itr == PlayerScores.end()) // player not found
return; return;
@@ -783,14 +787,14 @@ void BattlegroundWS::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
{ {
case SCORE_FLAG_CAPTURES: // flags captured case SCORE_FLAG_CAPTURES: // flags captured
((BattlegroundWGScore*)itr->second)->FlagCaptures += value; ((BattlegroundWGScore*)itr->second)->FlagCaptures += value;
Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, WS_OBJECTIVE_CAPTURE_FLAG); player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, WS_OBJECTIVE_CAPTURE_FLAG);
break; break;
case SCORE_FLAG_RETURNS: // flags returned case SCORE_FLAG_RETURNS: // flags returned
((BattlegroundWGScore*)itr->second)->FlagReturns += value; ((BattlegroundWGScore*)itr->second)->FlagReturns += value;
Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, WS_OBJECTIVE_RETURN_FLAG); player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, WS_OBJECTIVE_RETURN_FLAG);
break; break;
default: default:
Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); Battleground::UpdatePlayerScore(player, type, value, doAddHonor);
break; break;
} }
} }
@@ -182,12 +182,12 @@ class BattlegroundWS : public Battleground
uint8 GetFlagState(uint32 team) { return _flagState[GetTeamIndexByTeamId(team)]; } uint8 GetFlagState(uint32 team) { return _flagState[GetTeamIndexByTeamId(team)]; }
/* Battleground Events */ /* Battleground Events */
void EventPlayerDroppedFlag(Player* Source); void EventPlayerDroppedFlag(Player* player);
void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj); void EventPlayerClickedOnFlag(Player* player, GameObject* target_obj);
void EventPlayerCapturedFlag(Player* Source); void EventPlayerCapturedFlag(Player* player);
void RemovePlayer(Player* player, uint64 guid, uint32 team); void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger); void HandleAreaTrigger(Player* player, uint32 trigger);
void HandleKillPlayer(Player* player, Player* killer); void HandleKillPlayer(Player* player, Player* killer);
bool SetupBattleground(); bool SetupBattleground();
void Reset(); void Reset();
@@ -197,7 +197,7 @@ class BattlegroundWS : public Battleground
void UpdateFlagState(uint32 team, uint32 value); void UpdateFlagState(uint32 team, uint32 value);
void SetLastFlagCapture(uint32 team) { _lastFlagCaptureTeam = team; } void SetLastFlagCapture(uint32 team) { _lastFlagCaptureTeam = team; }
void UpdateTeamScore(uint32 team); void UpdateTeamScore(uint32 team);
void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
void SetDroppedFlagGUID(uint64 guid, int32 team = -1) void SetDroppedFlagGUID(uint64 guid, int32 team = -1)
{ {
if (team == TEAM_ALLIANCE || team == TEAM_HORDE) if (team == TEAM_ALLIANCE || team == TEAM_HORDE)
@@ -17,7 +17,7 @@
*/ */
#include "GameObjectAI.h" #include "GameObjectAI.h"
#include "BattlegroundAV.h" #include "Battleground.h"
#include "CellImpl.h" #include "CellImpl.h"
#include "CreatureAISelector.h" #include "CreatureAISelector.h"
#include "DynamicTree.h" #include "DynamicTree.h"
@@ -324,7 +324,7 @@ void GameObject::Update(uint32 diff)
WorldPacket packet; WorldPacket packet;
BuildValuesUpdateBlockForPlayer(&udata, caster->ToPlayer()); BuildValuesUpdateBlockForPlayer(&udata, caster->ToPlayer());
udata.BuildPacket(&packet); udata.BuildPacket(&packet);
caster->ToPlayer()->GetSession()->SendPacket(&packet); caster->ToPlayer()->SendDirectMessage(&packet);
SendCustomAnim(GetGoAnimProgress()); SendCustomAnim(GetGoAnimProgress());
} }
@@ -373,7 +373,7 @@ void GameObject::Update(uint32 diff)
caster->ToPlayer()->RemoveGameObject(this, false); caster->ToPlayer()->RemoveGameObject(this, false);
WorldPacket data(SMSG_FISH_ESCAPED, 0); WorldPacket data(SMSG_FISH_ESCAPED, 0);
caster->ToPlayer()->GetSession()->SendPacket(&data); caster->ToPlayer()->SendDirectMessage(&data);
} }
// can be delete // can be delete
m_lootState = GO_JUST_DEACTIVATED; m_lootState = GO_JUST_DEACTIVATED;
@@ -872,7 +872,9 @@ bool GameObject::IsDynTransport() const
bool GameObject::IsDestructibleBuilding() const bool GameObject::IsDestructibleBuilding() const
{ {
GameObjectTemplate const* gInfo = GetGOInfo(); GameObjectTemplate const* gInfo = GetGOInfo();
if (!gInfo) return false; if (!gInfo)
return false;
return gInfo->type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING; return gInfo->type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING;
} }
@@ -948,12 +950,8 @@ bool GameObject::ActivateToQuest(Player* target) const
{ {
if (LootTemplates_Gameobject.HaveQuestLootForPlayer(GetGOInfo()->GetLootId(), target)) if (LootTemplates_Gameobject.HaveQuestLootForPlayer(GetGOInfo()->GetLootId(), target))
{ {
/// @todo fix this hack if (Battleground const* bg = target->GetBattleground())
//look for battlegroundAV for some objects which are only activated after mine gots captured by own team return bg->CanActivateGO(GetEntry(), target->GetTeam());
if (GetEntry() == BG_AV_OBJECTID_MINE_N || GetEntry() == BG_AV_OBJECTID_MINE_S)
if (Battleground* bg = target->GetBattleground())
if (bg->GetTypeID(true) == BATTLEGROUND_AV && !bg->ToBattlegroundAV()->PlayerCanDoMineQuest(GetEntry(), target->GetTeam()))
return false;
return true; return true;
} }
break; break;
@@ -1242,7 +1240,7 @@ void GameObject::Use(Unit* user)
{ {
WorldPacket data(SMSG_GAMEOBJECT_PAGETEXT, 8); WorldPacket data(SMSG_GAMEOBJECT_PAGETEXT, 8);
data << GetGUID(); data << GetGUID();
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
} }
else if (info->goober.gossipID) else if (info->goober.gossipID)
{ {
@@ -1384,7 +1382,7 @@ void GameObject::Use(Unit* user)
SetLootState(GO_JUST_DEACTIVATED); SetLootState(GO_JUST_DEACTIVATED);
WorldPacket data(SMSG_FISH_NOT_HOOKED, 0); WorldPacket data(SMSG_FISH_NOT_HOOKED, 0);
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
break; break;
} }
} }
@@ -1647,7 +1645,7 @@ void GameObject::Use(Unit* user)
player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
WorldPacket data(SMSG_ENABLE_BARBER_SHOP, 0); WorldPacket data(SMSG_ENABLE_BARBER_SHOP, 0);
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->barberChair.chairheight); player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->barberChair.chairheight);
return; return;
@@ -1843,7 +1841,7 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, u
data << uint32(-change); // change < 0 triggers SPELL_BUILDING_HEAL combat log event data << uint32(-change); // change < 0 triggers SPELL_BUILDING_HEAL combat log event
// change >= 0 triggers SPELL_BUILDING_DAMAGE event // change >= 0 triggers SPELL_BUILDING_DAMAGE event
data << uint32(spellId); data << uint32(spellId);
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
} }
GameObjectDestructibleState newState = GetDestructibleState(); GameObjectDestructibleState newState = GetDestructibleState();
+4 -15
View File
@@ -25,7 +25,6 @@
#include "BattlefieldMgr.h" #include "BattlefieldMgr.h"
#include "BattlefieldWG.h" #include "BattlefieldWG.h"
#include "Battleground.h" #include "Battleground.h"
#include "BattlegroundAV.h"
#include "BattlegroundMgr.h" #include "BattlegroundMgr.h"
#include "CellImpl.h" #include "CellImpl.h"
#include "Channel.h" #include "Channel.h"
@@ -8770,22 +8769,12 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
if (go->getLootState() == GO_READY) if (go->getLootState() == GO_READY)
{ {
uint32 lootid = go->GetGOInfo()->GetLootId(); uint32 lootid = go->GetGOInfo()->GetLootId();
if (Battleground* bg = GetBattleground())
/// @todo fix this big hack if (!bg->CanActivateGO(go->GetEntry(), GetTeam()))
if ((go->GetEntry() == BG_AV_OBJECTID_MINE_N || go->GetEntry() == BG_AV_OBJECTID_MINE_S))
{
if (Battleground* bg = GetBattleground())
{ {
if (bg->GetTypeID(true) == BATTLEGROUND_AV) SendLootRelease(guid);
{ return;
if (!bg->ToBattlegroundAV()->PlayerCanDoMineQuest(go->GetEntry(), GetTeam()))
{
SendLootRelease(guid);
return;
}
}
} }
}
if (lootid) if (lootid)
{ {
+84 -82
View File
@@ -29,7 +29,6 @@
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "Group.h" #include "Group.h"
#include "Battleground.h" #include "Battleground.h"
#include "BattlegroundAV.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "GameObjectAI.h" #include "GameObjectAI.h"
@@ -510,6 +509,10 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData)
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %u, quest = %u", uint32(GUID_LOPART(guid)), questId); TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %u, quest = %u", uint32(GUID_LOPART(guid)), questId);
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
if (!quest)
return;
Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT); Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
if (!object || !object->hasInvolvedQuest(questId)) if (!object || !object->hasInvolvedQuest(questId))
return; return;
@@ -518,38 +521,33 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData)
if (!_player->CanInteractWithQuestGiver(object)) if (!_player->CanInteractWithQuestGiver(object))
return; return;
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId)) if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE)
{ {
if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE) TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "Possible hacking attempt: Player %s [guid: %u] tried to complete quest [entry: %u] without being in possession of the quest!",
{ _player->GetName().c_str(), _player->GetGUIDLow(), questId);
TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "Possible hacking attempt: Player %s [guid: %u] tried to complete quest [entry: %u] without being in possession of the quest!", return;
_player->GetName().c_str(), _player->GetGUIDLow(), questId);
return;
}
/// @todo need a virtual function
if (_player->InBattleground())
if (Battleground* bg = _player->GetBattleground())
if (bg->GetTypeID() == BATTLEGROUND_AV)
bg->ToBattlegroundAV()->HandleQuestComplete(questId, _player);
if (_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE)
{
if (quest->IsRepeatable())
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, guid, _player->CanCompleteRepeatableQuest(quest), false);
else
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, guid, _player->CanRewardQuest(quest, false), false);
}
else
{
if (quest->GetReqItemsCount()) // some items required
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, guid, _player->CanRewardQuest(quest, false), false);
else // no items required
_player->PlayerTalkClass->SendQuestGiverOfferReward(quest, guid, true);
}
if (Creature* creature = object->ToCreature())
sScriptMgr->OnQuestComplete(_player, creature, quest);
} }
if (Battleground* bg = _player->GetBattleground())
bg->HandleQuestComplete(questId, _player);
if (_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE)
{
if (quest->IsRepeatable())
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, guid, _player->CanCompleteRepeatableQuest(quest), false);
else
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, guid, _player->CanRewardQuest(quest, false), false);
}
else
{
if (quest->GetReqItemsCount()) // some items required
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, guid, _player->CanRewardQuest(quest, false), false);
else // no items required
_player->PlayerTalkClass->SendQuestGiverOfferReward(quest, guid, true);
}
if (Creature* creature = object->ToCreature())
sScriptMgr->OnQuestComplete(_player, creature, quest);
} }
void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/) void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/)
@@ -565,66 +563,70 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
if (!_player->CanShareQuest(questId)) if (!_player->CanShareQuest(questId))
return; return;
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PUSHQUESTTOPARTY quest = %u", questId); TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PUSHQUESTTOPARTY questId = %u", questId);
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId)) Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
if (!quest)
return;
Player * const sender = GetPlayer();
Group* group = sender->GetGroup();
if (!group)
return;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
if (Group* group = _player->GetGroup()) Player* receiver = itr->GetSource();
if (!receiver || receiver == sender)
continue;
if (!receiver->SatisfyQuestStatus(quest, false))
{ {
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_HAVE_QUEST);
{ continue;
Player* player = itr->GetSource(); }
if (!player || player == _player) // skip self if (receiver->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE)
continue; {
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_FINISH_QUEST);
continue;
}
if (!player->SatisfyQuestStatus(quest, false)) if (!receiver->CanTakeQuest(quest, false))
{ {
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_HAVE_QUEST); sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_CANT_TAKE_QUEST);
continue; continue;
} }
if (player->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE) if (!receiver->SatisfyQuestLog(false))
{ {
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_FINISH_QUEST); sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_LOG_FULL);
continue; continue;
} }
if (!player->CanTakeQuest(quest, false)) if (receiver->GetDivider() != 0)
{ {
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_CANT_TAKE_QUEST); sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_BUSY);
continue; continue;
} }
if (!player->SatisfyQuestLog(false)) sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_SHARING_QUEST);
{
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_LOG_FULL);
continue;
}
if (player->GetDivider() != 0) if (quest->IsAutoAccept() && receiver->CanAddQuest(quest, true) && receiver->CanTakeQuest(quest, true))
{ {
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_BUSY); receiver->AddQuest(quest, sender);
continue; if (receiver->CanCompleteQuest(questId))
} receiver->CompleteQuest(questId);
}
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_SHARING_QUEST); if ((quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly()) || quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true);
if (quest->IsAutoAccept() && player->CanAddQuest(quest, true) && player->CanTakeQuest(quest, true)) else
{ {
player->AddQuest(quest, _player); receiver->SetDivider(sender->GetGUID());
if (player->CanCompleteQuest(questId)) receiver->PlayerTalkClass->SendQuestGiverQuestDetails(quest, sender->GetGUID(), true);
player->CompleteQuest(questId);
}
if ((quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly()) || quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
player->PlayerTalkClass->SendQuestGiverRequestItems(quest, _player->GetGUID(), player->CanCompleteRepeatableQuest(quest), true);
else
{
player->SetDivider(_player->GetGUID());
player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, _player->GetGUID(), true);
}
}
} }
} }
} }
@@ -646,7 +648,7 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
WorldPacket data(MSG_QUEST_PUSH_RESULT, 8 + 4 + 1); WorldPacket data(MSG_QUEST_PUSH_RESULT, 8 + 4 + 1);
data << uint64(_player->GetGUID()); data << uint64(_player->GetGUID());
data << uint8(msg); // valid values: 0-8 data << uint8(msg); // valid values: 0-8
player->GetSession()->SendPacket(&data); player->SendDirectMessage(&data);
_player->SetDivider(0); _player->SetDivider(0);
} }
} }
+1 -3
View File
@@ -45,8 +45,6 @@
#include "CreatureAI.h" #include "CreatureAI.h"
#include "BattlegroundMgr.h" #include "BattlegroundMgr.h"
#include "Battleground.h" #include "Battleground.h"
#include "BattlegroundEY.h"
#include "BattlegroundWS.h"
#include "OutdoorPvPMgr.h" #include "OutdoorPvPMgr.h"
#include "Language.h" #include "Language.h"
#include "SocialMgr.h" #include "SocialMgr.h"
@@ -1338,7 +1336,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex)
float gainMultiplier = 0.0f; float gainMultiplier = 0.0f;
// Don`t restore from self drain // Don't restore from self drain
if (m_caster != unitTarget) if (m_caster != unitTarget)
{ {
gainMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this); gainMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this);
+26 -35
View File
@@ -29,7 +29,6 @@
#include "BattlegroundMgr.h" #include "BattlegroundMgr.h"
#include "CreatureAI.h" #include "CreatureAI.h"
#include "MapManager.h" #include "MapManager.h"
#include "BattlegroundIC.h"
#include "BattlefieldWG.h" #include "BattlefieldWG.h"
#include "BattlefieldMgr.h" #include "BattlefieldMgr.h"
#include "Player.h" #include "Player.h"
@@ -358,7 +357,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg
if (!spellInfo) if (!spellInfo)
return false; return false;
bool need_check_reagents = false; bool needCheckReagents = false;
// check effects // check effects
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
@@ -401,7 +400,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg
return false; return false;
} }
need_check_reagents = true; needCheckReagents = true;
break; break;
} }
case SPELL_EFFECT_LEARN_SPELL: case SPELL_EFFECT_LEARN_SPELL:
@@ -423,7 +422,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg
} }
} }
if (need_check_reagents) if (needCheckReagents)
{ {
for (uint8 j = 0; j < MAX_SPELL_REAGENTS; ++j) for (uint8 j = 0; j < MAX_SPELL_REAGENTS; ++j)
{ {
@@ -447,7 +446,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg
uint32 SpellMgr::GetSpellDifficultyId(uint32 spellId) const uint32 SpellMgr::GetSpellDifficultyId(uint32 spellId) const
{ {
SpellDifficultySearcherMap::const_iterator i = mSpellDifficultySearcherMap.find(spellId); SpellDifficultySearcherMap::const_iterator i = mSpellDifficultySearcherMap.find(spellId);
return i == mSpellDifficultySearcherMap.end() ? 0 : (*i).second; return i == mSpellDifficultySearcherMap.end() ? 0 : i->second;
} }
void SpellMgr::SetSpellDifficultyId(uint32 spellId, uint32 id) void SpellMgr::SetSpellDifficultyId(uint32 spellId, uint32 id)
@@ -1102,7 +1101,13 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
if (!player || (auraSpell > 0 && !player->HasAura(auraSpell)) || (auraSpell < 0 && player->HasAura(-auraSpell))) if (!player || (auraSpell > 0 && !player->HasAura(auraSpell)) || (auraSpell < 0 && player->HasAura(-auraSpell)))
return false; return false;
// Extra conditions -- leaving the possibility add extra conditions... if (player)
{
if (Battleground* bg = player->GetBattleground())
return bg->IsSpellAllowed(spellId, player);
}
// Extra conditions
switch (spellId) switch (spellId)
{ {
case 58600: // No fly Zone - Dalaran case 58600: // No fly Zone - Dalaran
@@ -1127,41 +1132,26 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
return false; return false;
break; break;
} }
case 68719: // Oil Refinery - Isle of Conquest.
case 68720: // Quarry - Isle of Conquest.
{
if (!player || player->GetBattlegroundTypeId() != BATTLEGROUND_IC || !player->GetBattleground())
return false;
uint8 nodeType = spellId == 68719 ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY;
uint8 nodeState = player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H;
BattlegroundIC* pIC = player->GetBattleground()->ToBattlegroundIC();
if (pIC->GetNodeState(nodeType) == nodeState)
return true;
return false;
}
case 56618: // Horde Controls Factory Phase Shift case 56618: // Horde Controls Factory Phase Shift
case 56617: // Alliance Controls Factory Phase Shift case 56617: // Alliance Controls Factory Phase Shift
{ {
if (!player) if (!player)
return false; return false;
Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId()); Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId());
if (!bf || bf->GetTypeId() != BATTLEFIELD_WG) if (!bf || bf->GetTypeId() != BATTLEFIELD_WG)
return false; return false;
// team that controls the workshop in the specified area // team that controls the workshop in the specified area
uint32 team = bf->GetData(newArea); uint32 team = bf->GetData(newArea);
if (team == TEAM_HORDE) if (team == TEAM_HORDE)
return spellId == 56618; return spellId == 56618;
else if (team == TEAM_ALLIANCE) else if (team == TEAM_ALLIANCE)
return spellId == 56617; return spellId == 56617;
}
break; break;
}
case 57940: // Essence of Wintergrasp - Northrend case 57940: // Essence of Wintergrasp - Northrend
case 58045: // Essence of Wintergrasp - Wintergrasp case 58045: // Essence of Wintergrasp - Wintergrasp
{ {
@@ -1356,6 +1346,7 @@ void SpellMgr::LoadSpellRanks()
mSpellInfoMap[addedSpell]->ChainEntry = &mSpellChains[addedSpell]; mSpellInfoMap[addedSpell]->ChainEntry = &mSpellChains[addedSpell];
prevRank = addedSpell; prevRank = addedSpell;
++itr; ++itr;
if (itr == rankChain.end()) if (itr == rankChain.end())
{ {
mSpellChains[addedSpell].next = NULL; mSpellChains[addedSpell].next = NULL;
@@ -1616,7 +1607,7 @@ void SpellMgr::LoadSpellTargetPositions()
SpellInfo const* spellInfo = GetSpellInfo(Spell_ID); SpellInfo const* spellInfo = GetSpellInfo(Spell_ID);
if (!spellInfo) if (!spellInfo)
{ {
TC_LOG_ERROR(LOG_FILTER_SQL, "Spell (ID:%u) listed in `spell_target_position` does not exist.", Spell_ID); TC_LOG_ERROR(LOG_FILTER_SQL, "Spell (Id: %u) listed in `spell_target_position` does not exist.", Spell_ID);
continue; continue;
} }
@@ -40,7 +40,7 @@ class achievement_resilient_victory : public AchievementCriteriaScript
if (bg->GetTypeID(true) != BATTLEGROUND_AB) if (bg->GetTypeID(true) != BATTLEGROUND_AB)
return false; return false;
if (!bg->ToBattlegroundAB()->IsTeamScores500Disadvantage(source->GetTeam())) if (!static_cast<BattlegroundAB*>(bg)->IsTeamScores500Disadvantage(source->GetTeam()))
return false; return false;
return true; return true;
@@ -54,14 +54,10 @@ class achievement_bg_control_all_nodes : public AchievementCriteriaScript
bool OnCheck(Player* source, Unit* /*target*/) OVERRIDE bool OnCheck(Player* source, Unit* /*target*/) OVERRIDE
{ {
Battleground* bg = source->GetBattleground(); if (Battleground* bg = source->GetBattleground())
if (!bg) return bg->IsAllNodesControlledByTeam(source->GetTeam());
return false;
if (!bg->IsAllNodesConrolledByTeam(source->GetTeam())) return false;
return false;
return true;
} }
}; };
@@ -84,7 +80,7 @@ class achievement_save_the_day : public AchievementCriteriaScript
if (bg->GetTypeID(true) != BATTLEGROUND_WS) if (bg->GetTypeID(true) != BATTLEGROUND_WS)
return false; return false;
if (bg->ToBattlegroundWS()->GetFlagState(player->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE) if (static_cast<BattlegroundWS*>(bg)->GetFlagState(player->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE)
return true; return true;
} }
return false; return false;
@@ -209,7 +205,7 @@ class achievement_everything_counts : public AchievementCriteriaScript
if (bg->GetTypeID(true) != BATTLEGROUND_AV) if (bg->GetTypeID(true) != BATTLEGROUND_AV)
return false; return false;
if (bg->ToBattlegroundAV()->IsBothMinesControlledByTeam(source->GetTeam())) if (static_cast<BattlegroundAV*>(bg)->IsBothMinesControlledByTeam(source->GetTeam()))
return true; return true;
return false; return false;
@@ -230,7 +226,7 @@ class achievement_bg_av_perfection : public AchievementCriteriaScript
if (bg->GetTypeID(true) != BATTLEGROUND_AV) if (bg->GetTypeID(true) != BATTLEGROUND_AV)
return false; return false;
if (bg->ToBattlegroundAV()->IsAllTowersControlledAndCaptainAlive(source->GetTeam())) if (static_cast<BattlegroundAV*>(bg)->IsAllTowersControlledAndCaptainAlive(source->GetTeam()))
return true; return true;
return false; return false;
@@ -253,10 +249,14 @@ class achievement_bg_sa_defense_of_ancients : public AchievementCriteriaScript
if (!battleground) if (!battleground)
return false; return false;
if (player->GetTeamId() == battleground->ToBattlegroundSA()->Attackers) BattlegroundSA* bg = static_cast<BattlegroundSA*>(battleground);
if (!bg)
return false; return false;
if (!battleground->ToBattlegroundSA()->gateDestroyed) if (player->GetTeamId() == bg->Attackers)
return false;
if (!bg->gateDestroyed)
return true; return true;
return false; return false;
@@ -308,7 +308,11 @@ class achievement_not_even_a_scratch : public AchievementCriteriaScript
if (!battleground) if (!battleground)
return false; return false;
if (battleground->ToBattlegroundSA()->notEvenAScratch(source->GetTeam())) BattlegroundSA* bg = static_cast<BattlegroundSA*>(battleground);
if (!bg)
return false;
if (bg->notEvenAScratch(source->GetTeam()))
return true; return true;
return false; return false;