TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BattlegroundWS.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __BATTLEGROUNDWS_H
20 #define __BATTLEGROUNDWS_H
21 
22 #include "Battleground.h"
23 #include "BattlegroundScore.h"
24 
26 {
32 };
33 
35 {
43 };
44 
46 {
49  BG_WS_SPELL_WARSONG_FLAG_PICKED = 61266, // fake spell, does not exist but used as timer start event
52  BG_WS_SPELL_SILVERWING_FLAG_PICKED = 61265, // fake spell, does not exist but used as timer start event
55 };
56 
58 {
61 // FLAG_UNK = 1547,
69 };
70 
72 {
92 };
93 
95 {
110 };
111 
113 {
118 };
119 
121 {
126 };
127 
129 {
132 
134 };
135 
137 {
140 };
141 
143 {
146 };
147 
148 #define WS_EVENT_START_BATTLE 8563
149 
151 {
152  friend class BattlegroundWS;
153 
154  protected:
155  BattlegroundWGScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0), FlagReturns(0) { }
156 
157  void UpdateScore(uint32 type, uint32 value) override
158  {
159  switch (type)
160  {
161  case SCORE_FLAG_CAPTURES: // Flags captured
162  FlagCaptures += value;
163  break;
164  case SCORE_FLAG_RETURNS: // Flags returned
165  FlagReturns += value;
166  break;
167  default:
168  BattlegroundScore::UpdateScore(type, value);
169  break;
170  }
171  }
172 
173  void BuildObjectivesBlock(std::vector<int32>& stats) override
174  {
175  stats.push_back(FlagCaptures);
176  stats.push_back(FlagReturns);
177  }
178 
179  uint32 GetAttr1() const final override { return FlagCaptures; }
180  uint32 GetAttr2() const final override { return FlagReturns; }
181 
184 };
185 
187 {
188  public:
189  /* Construction */
190  BattlegroundWS();
191  ~BattlegroundWS();
192 
193  /* inherited from BattlegroundClass */
194  void AddPlayer(Player* player) override;
195  void StartingEventCloseDoors() override;
196  void StartingEventOpenDoors() override;
197 
198  /* BG Flags */
199  ObjectGuid GetFlagPickerGUID(int32 team) const override
200  {
201  if (team == TEAM_ALLIANCE || team == TEAM_HORDE)
202  return m_FlagKeepers[team];
203  return ObjectGuid::Empty;
204  }
209  void RespawnFlag(uint32 Team, bool captured);
212 
213  /* Battleground Events */
214  void EventPlayerDroppedFlag(Player* player) override;
215  void EventPlayerClickedOnFlag(Player* player, GameObject* target_obj) override;
216  void EventPlayerCapturedFlag(Player* player);
217 
218  void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
219  void HandleAreaTrigger(Player* player, uint32 trigger, bool entered) override;
220  void HandleKillPlayer(Player* player, Player* killer) override;
221  bool SetupBattleground() override;
222  void Reset() override;
223  void EndBattleground(uint32 winner) override;
224  WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
225 
226  void UpdateFlagState(uint32 team, uint32 value);
228  void UpdateTeamScore(uint32 team);
229  bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override;
230  void SetDroppedFlagGUID(ObjectGuid guid, int32 team = -1) override
231  {
232  if (team == TEAM_ALLIANCE || team == TEAM_HORDE)
233  m_DroppedFlagGUID[team] = guid;
234  }
235 
238 
239  /* Scorekeeping */
243 
244  uint32 GetPrematureWinner() override;
245 
246  /* Achievements*/
247  bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = nullptr, uint32 miscvalue1 = 0) override;
248 
249  protected:
250  void PostUpdateImpl(uint32 diff) override;
251  void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const override;
252 
253  private:
254  ObjectGuid m_FlagKeepers[2]; // 0 - alliance, 1 - horde
256  uint8 _flagState[2]; // for checking flag state
259  uint32 _lastFlagCaptureTeam; // Winner is based on this if score is equal
260 
266  uint8 _flagDebuffState; // 0 - no debuffs, 1 - focused assault, 2 - brutal assault
268 };
269 #endif
BG_WS_TimerOrScore
Definition: BattlegroundWS.h:25
BG_WS_FlagState
Definition: BattlegroundWS.h:112
Definition: BattlegroundWS.h:60
void PostUpdateImpl(uint32 diff) override
Post-update hook.
Definition: BattlegroundWS.cpp:73
Definition: BattlegroundWS.h:88
Definition: BattlegroundWS.h:98
Definition: BattlegroundScore.h:35
BG_WS_Sound
Definition: BattlegroundWS.h:34
Definition: BattlegroundWS.h:104
Definition: BattlegroundWS.h:40
Definition: BattlegroundWS.h:145
void RemovePlayer(Player *player, ObjectGuid guid, uint32 team) override
Definition: BattlegroundWS.cpp:608
int32 m_TeamScores[BG_TEAMS_COUNT]
Definition: Battleground.h:562
Definition: BattlegroundWS.h:125
uint32 FlagCaptures
Definition: BattlegroundWS.h:182
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void EventPlayerCapturedFlag(Player *player)
Definition: BattlegroundWS.cpp:309
BG_WS_SpellId
Definition: BattlegroundWS.h:45
Definition: BattlegroundWS.h:133
Definition: BattlegroundWS.h:31
Points
Definition: ScriptedEscortAI.cpp:31
Definition: BattlegroundWS.h:59
Definition: BattlegroundWS.h:76
int32 _flagSpellForceTimer
Definition: BattlegroundWS.h:264
void SetTeamPoint(uint32 TeamID, uint32 Points=0)
Definition: BattlegroundWS.h:241
Definition: BattlegroundWS.h:53
Definition: BattlegroundWS.h:30
void UpdateTeamScore(uint32 team)
Definition: BattlegroundWS.cpp:643
uint32 _lastFlagCaptureTeam
Definition: BattlegroundWS.h:259
BattlegroundWGScore(ObjectGuid playerGuid, uint32 team)
Definition: BattlegroundWS.h:155
BG_WS_CarrierDebuffs
Definition: BattlegroundWS.h:136
Definition: BattlegroundWS.h:139
BG_WS_CreatureTypes
Definition: BattlegroundWS.h:128
virtual void UpdateScore(uint32 type, uint32 value)
Definition: BattlegroundScore.h:65
Definition: BattlegroundWS.h:96
Definition: BattlegroundWS.h:78
Definition: BattlegroundWS.h:65
Definition: BattlegroundWS.h:79
Definition: BattlegroundWS.h:85
Definition: BattlegroundWS.h:66
Definition: DBCStructure.h:1434
Definition: BattlegroundWS.h:38
Definition: BattlegroundWS.h:63
Definition: BattlegroundWS.h:73
ObjectGuid GetFlagPickerGUID(int32 team) const override
Definition: BattlegroundWS.h:199
uint8 _minutesElapsed
Definition: BattlegroundWS.h:267
ObjectGuid m_DroppedFlagGUID[2]
Definition: BattlegroundWS.h:255
Definition: BattlegroundWS.h:47
~BattlegroundWS()
Definition: BattlegroundWS.cpp:71
void RespawnFlagAfterDrop(uint32 Team)
Definition: BattlegroundWS.cpp:281
Definition: BattlegroundWS.h:102
Definition: BattlegroundWS.h:81
bool UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true) override
Definition: BattlegroundWS.cpp:812
Definition: BattlegroundWS.h:67
uint8 GetFlagState(uint32 team)
Definition: BattlegroundWS.h:211
Definition: BattlegroundWS.h:131
Definition: BattlegroundWS.h:83
Definition: BattlegroundWS.h:109
bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const *source, Unit const *target=nullptr, uint32 miscvalue1=0) override
Definition: BattlegroundWS.cpp:904
void AddPoint(uint32 TeamID, uint32 Points=1)
Definition: BattlegroundWS.h:240
Definition: BattlegroundWS.h:90
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
Definition: BattlegroundScore.h:54
Definition: BattlegroundWS.h:101
void UpdateScore(uint32 type, uint32 value) override
Definition: BattlegroundWS.h:157
Team
Definition: SharedDefines.h:997
uint32 GetAttr2() const finaloverride
Definition: BattlegroundWS.h:180
Definition: BattlegroundWS.h:117
void HandleKillPlayer(Player *player, Player *killer) override
Definition: BattlegroundWS.cpp:802
Definition: BattlegroundWS.h:97
Definition: BattlegroundScore.h:36
uint8 _flagState[2]
Definition: BattlegroundWS.h:256
void SetHordeFlagPicker(ObjectGuid guid)
Definition: BattlegroundWS.h:206
BG_WS_WorldStates
Definition: BattlegroundWS.h:57
Definition: BattlegroundWS.h:52
Definition: BattlegroundWS.h:124
Definition: BattlegroundWS.h:42
Definition: BattlegroundWS.h:105
void GetPlayerPositionData(std::vector< WorldPackets::Battleground::BattlegroundPlayerPosition > *positions) const override
Definition: BattlegroundWS.cpp:193
int32_t int32
Definition: Define.h:146
Definition: BattlegroundWS.h:41
uint32_t uint32
Definition: Define.h:150
bool IsHordeFlagPickedup() const
Definition: BattlegroundWS.h:208
Definition: BattlegroundWS.h:37
void EndBattleground(uint32 winner) override
Definition: BattlegroundWS.cpp:788
void StartingEventOpenDoors() override
Definition: BattlegroundWS.cpp:232
Definition: WorldStatePackets.h:27
Definition: SharedDefines.h:992
Definition: BattlegroundWS.h:138
Definition: GameObject.h:880
Definition: BattlegroundWS.h:86
Definition: BattlegroundWS.h:103
BattlegroundWS()
Definition: BattlegroundWS.cpp:42
uint32 GetAttr1() const finaloverride
Definition: BattlegroundWS.h:179
uint32 GetPrematureWinner() override
Definition: BattlegroundWS.cpp:894
WorldSafeLocsEntry const * GetClosestGraveYard(Player *player) override
Definition: BattlegroundWS.cpp:831
Definition: BattlegroundWS.h:62
Definition: BattlegroundWS.h:36
uint32 FlagReturns
Definition: BattlegroundWS.h:183
Definition: BattlegroundWS.h:29
void Reset() override
Definition: BattlegroundWS.cpp:751
Definition: BattlegroundWS.h:150
Definition: BattlegroundWS.h:115
Definition: BattlegroundWS.h:82
void StartingEventCloseDoors() override
Definition: BattlegroundWS.cpp:218
Definition: BattlegroundWS.h:108
bool IsAllianceFlagPickedup() const
Definition: BattlegroundWS.h:207
Definition: BattlegroundWS.h:80
void SetAllianceFlagPicker(ObjectGuid guid)
Definition: BattlegroundWS.h:205
void HandleAreaTrigger(Player *player, uint32 trigger, bool entered) override
Definition: BattlegroundWS.cpp:651
Definition: BattlegroundWS.h:49
Definition: BattlegroundWS.h:100
Definition: BattlegroundWS.h:114
Definition: BattlegroundWS.h:51
void EventPlayerClickedOnFlag(Player *player, GameObject *target_obj) override
Definition: BattlegroundWS.cpp:485
uint32 m_HonorEndKills
Definition: BattlegroundWS.h:263
Definition: BattlegroundWS.h:27
void EventPlayerDroppedFlag(Player *player) override
Definition: BattlegroundWS.cpp:397
Definition: BattlegroundWS.h:54
uint32 m_HonorWinKills
Definition: BattlegroundWS.h:262
bool _bothFlagsKept
Definition: BattlegroundWS.h:265
Definition: BattlegroundWS.h:91
Definition: BattlegroundWS.h:130
Definition: BattlegroundWS.h:74
ObjectGuid GetDroppedFlagGUID(uint32 TeamID)
Definition: BattlegroundWS.h:236
Definition: BattlegroundWS.h:107
ObjectGuid m_FlagKeepers[2]
Definition: BattlegroundWS.h:254
void BuildObjectivesBlock(std::vector< int32 > &stats) override
Definition: BattlegroundWS.h:173
uint8_t uint8
Definition: Define.h:152
Definition: BattlegroundWS.h:99
int32 _flagsDropTimer[2]
Definition: BattlegroundWS.h:258
Definition: BattlegroundWS.h:39
void SetDroppedFlagGUID(ObjectGuid guid, int32 team=-1) override
Definition: BattlegroundWS.h:230
Definition: BattlegroundWS.h:50
Definition: BattlegroundWS.h:28
Definition: Battleground.h:235
BG_WS_Objectives
Definition: BattlegroundWS.h:142
Definition: BattlegroundWS.h:77
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: BattlegroundWS.h:87
Definition: BattlegroundWS.h:186
Definition: BattlegroundWS.h:106
Definition: ObjectGuid.h:189
Definition: BattlegroundWS.h:123
#define const
Definition: zconf.h:217
Definition: BattlegroundWS.h:75
int32 _flagsTimer[2]
Definition: BattlegroundWS.h:257
Definition: BattlegroundWS.h:89
void RemovePoint(uint32 TeamID, uint32 Points=1)
Definition: BattlegroundWS.h:242
bool SetupBattleground() override
Definition: BattlegroundWS.cpp:702
void SetLastFlagCapture(uint32 team)
Definition: BattlegroundWS.h:227
Definition: SharedDefines.h:993
Definition: BattlegroundWS.h:84
Definition: BattlegroundWS.h:122
BG_WS_ObjectEntry
Definition: BattlegroundWS.h:94
Definition: Unit.h:1305
Definition: BattlegroundWS.h:116
void UpdateFlagState(uint32 team, uint32 value)
Definition: BattlegroundWS.cpp:635
void RespawnFlag(uint32 Team, bool captured)
Definition: BattlegroundWS.cpp:257
void AddPlayer(Player *player) override
Definition: BattlegroundWS.cpp:251
BG_WS_ObjectTypes
Definition: BattlegroundWS.h:71
Definition: BattlegroundWS.h:144
Definition: BattlegroundWS.h:48
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
Definition: BattlegroundWS.cpp:854
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: BattlegroundWS.h:68
uint32 m_ReputationCapture
Definition: BattlegroundWS.h:261
Definition: BattlegroundWS.h:64
BG_WS_Graveyards
Definition: BattlegroundWS.h:120
uint8 _flagDebuffState
Definition: BattlegroundWS.h:266