OregonCore  revision 3611e8a-git
Your Favourite TBC server
OutdoorPvPHP.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "OutdoorPvPHP.h"
19 #include "OutdoorPvP.h"
20 #include "OutdoorPvPMgr.h"
21 #include "Player.h"
22 #include "WorldPacket.h"
23 #include "World.h"
24 #include "ObjectMgr.h"
25 #include "Language.h"
26 
28 
30 
32 
34 
36  : OPvPCapturePoint(pvp), m_TowerType(type)
37 {
39  HPCapturePoints[type].map,
40  HPCapturePoints[type].x,
41  HPCapturePoints[type].y,
42  HPCapturePoints[type].z,
43  HPCapturePoints[type].o,
44  HPCapturePoints[type].rot0,
45  HPCapturePoints[type].rot1,
46  HPCapturePoints[type].rot2,
47  HPCapturePoints[type].rot3);
48  AddObject(type,
49  HPTowerFlags[type].entry,
50  HP_TowerArtKit_N[type],
51  HPTowerFlags[type].map,
52  HPTowerFlags[type].x,
53  HPTowerFlags[type].y,
54  HPTowerFlags[type].z,
55  HPTowerFlags[type].o,
56  HPTowerFlags[type].rot0,
57  HPTowerFlags[type].rot1,
58  HPTowerFlags[type].rot2,
59  HPTowerFlags[type].rot3);
60 }
61 
63 {
64  m_TypeId = OUTDOOR_PVP_HP;
65 }
66 
68 {
69  m_AllianceTowersControlled = 0;
70  m_HordeTowersControlled = 0;
71  // add the zones affected by the pvp buff
72  for (int i = 0; i < OutdoorPvPHPBuffZonesNum; ++i)
73  RegisterZone(OutdoorPvPHPBuffZones[i]);
74 
75  AddCapturePoint(new OPvPCapturePointHP(this, HP_TOWER_BROKEN_HILL));
76 
77  AddCapturePoint(new OPvPCapturePointHP(this, HP_TOWER_OVERLOOK));
78 
79  AddCapturePoint(new OPvPCapturePointHP(this, HP_TOWER_STADIUM));
80 
81  return true;
82 }
83 
85 {
86  // add buffs
87  if (plr->GetTeam() == ALLIANCE)
88  {
89  if (m_AllianceTowersControlled >= 3)
90  plr->CastSpell(plr, AllianceBuff, true);
91  }
92  else
93  {
94  if (m_HordeTowersControlled >= 3)
95  plr->CastSpell(plr, HordeBuff, true);
96  }
98 }
99 
101 {
102  // remove buffs
103  if (plr->GetTeam() == ALLIANCE)
105  else
108 }
109 
111 {
112  bool changed = OutdoorPvP::Update(diff);
113  if (changed)
114  {
115  if (m_AllianceTowersControlled == 3)
116  TeamApplyBuff(TEAM_ALLIANCE, AllianceBuff, HordeBuff);
117  else if (m_HordeTowersControlled == 3)
118  TeamApplyBuff(TEAM_HORDE, HordeBuff, AllianceBuff);
119  else
120  {
121  TeamCastSpell(TEAM_ALLIANCE, -AllianceBuff);
122  TeamCastSpell(TEAM_HORDE, -HordeBuff);
123  }
124  SendUpdateWorldState(HP_UI_TOWER_COUNT_A, m_AllianceTowersControlled);
125  SendUpdateWorldState(HP_UI_TOWER_COUNT_H, m_HordeTowersControlled);
126  }
127  return changed;
128 }
129 
131 {
139  for (int i = 0; i < HP_TOWER_NUM; ++i)
140  {
141  plr->SendUpdateWorldState(HP_MAP_N[i], 0);
142  plr->SendUpdateWorldState(HP_MAP_A[i], 0);
143  plr->SendUpdateWorldState(HP_MAP_H[i], 0);
144  }
145 }
146 
148 {
149  data << uint32(HP_UI_TOWER_DISPLAY_A) << uint32(1);
150  data << uint32(HP_UI_TOWER_DISPLAY_H) << uint32(1);
151  data << uint32(HP_UI_TOWER_COUNT_A) << uint32(m_AllianceTowersControlled);
152  data << uint32(HP_UI_TOWER_COUNT_H) << uint32(m_HordeTowersControlled);
154  data << uint32(HP_UI_TOWER_SLIDER_POS) << uint32(50);
155  data << uint32(HP_UI_TOWER_SLIDER_N) << uint32(100);
156  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
157  itr->second->FillInitialWorldStates(data);
158 }
159 
161 {
162  uint32 field = 0;
163  switch (m_OldState)
164  {
166  field = HP_MAP_N[m_TowerType];
167  break;
169  field = HP_MAP_A[m_TowerType];
170  if (((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled)
171  ((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled--;
172  sWorld.SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(HP_LANG_LOOSE_A[m_TowerType]));
173  break;
175  field = HP_MAP_H[m_TowerType];
176  if (((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled)
177  ((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled--;
178  sWorld.SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(HP_LANG_LOOSE_H[m_TowerType]));
179  break;
181  field = HP_MAP_N[m_TowerType];
182  break;
184  field = HP_MAP_N[m_TowerType];
185  break;
187  field = HP_MAP_A[m_TowerType];
188  break;
190  field = HP_MAP_H[m_TowerType];
191  break;
192  }
193 
194  // send world state update
195  if (field)
196  {
197  m_PvP->SendUpdateWorldState(field, 0);
198  field = 0;
199  }
200  uint32 artkit = 21;
202  switch (m_State)
203  {
205  field = HP_MAP_N[m_TowerType];
206  break;
208  field = HP_MAP_A[m_TowerType];
209  artkit = 2;
210  artkit2 = HP_TowerArtKit_A[m_TowerType];
211  if (((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled < 3)
212  ((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled++;
213  sWorld.SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(HP_LANG_CAPTURE_A[m_TowerType]));
214  break;
216  field = HP_MAP_H[m_TowerType];
217  artkit = 1;
218  artkit2 = HP_TowerArtKit_H[m_TowerType];
219  if (((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled < 3)
220  ((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled++;
221  sWorld.SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(HP_LANG_CAPTURE_H[m_TowerType]));
222  break;
224  field = HP_MAP_N[m_TowerType];
225  break;
227  field = HP_MAP_N[m_TowerType];
228  break;
230  field = HP_MAP_A[m_TowerType];
231  artkit = 2;
232  artkit2 = HP_TowerArtKit_A[m_TowerType];
233  break;
235  field = HP_MAP_H[m_TowerType];
236  artkit = 1;
237  artkit2 = HP_TowerArtKit_H[m_TowerType];
238  break;
239  }
240 
242  if (m_capturePoint)
243  m_capturePoint->SetGoArtKit(artkit);
244  if (flag)
245  flag->SetGoArtKit(artkit2);
246 
247  // send world state update
248  if (field)
249  m_PvP->SendUpdateWorldState(field, 1);
250 
251  // complete quest objective
253  SendObjectiveComplete(HP_CREDITMARKER[m_TowerType], 0);
254 }
255 
257 {
259  // send these updates to only the ones in this objective
260  uint32 phase = (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f);
262  // send this too, sometimes the slider disappears, dunno why :(
264 }
265 
267 {
268  switch (m_State)
269  {
272  data << uint32(HP_MAP_N[m_TowerType]) << uint32(0);
273  data << uint32(HP_MAP_A[m_TowerType]) << uint32(1);
274  data << uint32(HP_MAP_H[m_TowerType]) << uint32(0);
275  break;
278  data << uint32(HP_MAP_N[m_TowerType]) << uint32(0);
279  data << uint32(HP_MAP_A[m_TowerType]) << uint32(0);
280  data << uint32(HP_MAP_H[m_TowerType]) << uint32(1);
281  break;
285  default:
286  data << uint32(HP_MAP_N[m_TowerType]) << uint32(1);
287  data << uint32(HP_MAP_A[m_TowerType]) << uint32(0);
288  data << uint32(HP_MAP_H[m_TowerType]) << uint32(0);
289  break;
290  }
291 }
292 
294 {
296  {
298  uint32 phase = (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f);
301  return true;
302  }
303  return false;
304 }
305 
307 {
310 }
311 
313 {
314  if (killed->GetTypeId() != TYPEID_PLAYER)
315  return;
316 
317  if (plr->GetTeam() == ALLIANCE && killed->ToPlayer()->GetTeam() != ALLIANCE)
318  plr->CastSpell(plr, AlliancePlayerKillReward, true);
319  else if (plr->GetTeam() == HORDE && killed->ToPlayer()->GetTeam() != HORDE)
320  plr->CastSpell(plr, HordePlayerKillReward, true);
321 }
322 
const go_type HPTowerFlags[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:81
virtual void HandlePlayerEnterZone(Player *plr, uint32 zone)
Definition: OutdoorPvP.cpp:237
OutdoorPvP * m_PvP
Definition: OutdoorPvP.h:159
void FillInitialWorldStates(WorldPacket &data)
void SendUpdateWorldState(uint32 Field, uint32 Value)
Definition: Player.cpp:7713
const go_type HPCapturePoints[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:74
const uint32 HP_LANG_CAPTURE_H[HP_TOWER_NUM]
void HandlePlayerLeave(Player *plr)
virtual void HandlePlayerLeave(Player *plr)
Definition: OutdoorPvP.cpp:48
const uint32 HP_MAP_N[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:62
const uint32 HP_MAP_H[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:66
bool AddObject(uint32 type, uint32 entry, uint32 artKit, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
Definition: OutdoorPvP.cpp:94
static T * Find(uint64 guid)
void FillInitialWorldStates(WorldPacket &data)
bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o=0, float rotation0=0, float rotation1=0, float rotation2=0, float rotation3=0)
Definition: OutdoorPvP.cpp:116
#define sObjectMgr
Definition: ObjectMgr.h:1285
bool Update(uint32 diff)
Player * ToPlayer()
Definition: Object.h:386
void RemoveAurasDueToSpell(uint32 spellId, Aura *except=NULL)
Definition: Unit.cpp:4316
const uint32 HP_CREDITMARKER[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:43
void SendObjectiveComplete(uint32 id, uint64 guid)
Definition: OutdoorPvP.cpp:401
uint8 GetTypeId() const
Definition: Object.h:204
const uint32 HP_TowerArtKit_N[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:72
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1174
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:391
GameObject * m_capturePoint
Definition: OutdoorPvP.h:126
virtual void HandlePlayerLeaveZone(Player *plr, uint32 zone)
Definition: OutdoorPvP.cpp:242
std::map< uint32, uint64 > m_Objects
Definition: OutdoorPvP.h:163
void HandlePlayerLeaveZone(Player *plr, uint32 zone)
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:156
const uint32 HP_TowerArtKit_A[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:68
OutdoorPvPHPTowerType m_TowerType
Definition: OutdoorPvPHP.h:106
const uint32 HP_MAP_A[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:64
const uint32 HP_LANG_CAPTURE_A[HP_TOWER_NUM]
bool HandlePlayerEnter(Player *plr)
const uint32 HP_LANG_LOOSE_H[HP_TOWER_NUM]
#define OutdoorPvPHPBuffZonesNum
Definition: OutdoorPvPHP.h:23
uint32 GetTeam() const
Definition: Player.h:2075
virtual bool HandlePlayerEnter(Player *plr)
Definition: OutdoorPvP.cpp:37
OutdoorPvPHPTowerType
Definition: OutdoorPvPHP.h:35
void HandlePlayerEnterZone(Player *plr, uint32 zone)
#define sWorld
Definition: World.h:860
void SendRemoveWorldStates(Player *plr)
virtual bool Update(uint32 diff)
Definition: OutdoorPvP.cpp:254
ACE_UINT32 uint32
Definition: Define.h:71
const uint32 OutdoorPvPHPBuffZones[OutdoorPvPHPBuffZonesNum]
Definition: OutdoorPvPHP.h:25
OutdoorPvPEPTowerType m_TowerType
Definition: OutdoorPvPEP.h:172
const uint32 HP_TowerArtKit_H[HP_TOWER_NUM]
Definition: OutdoorPvPHP.h:70
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:384
ObjectiveStates m_OldState
Definition: OutdoorPvP.h:153
Definition: Unit.h:884
Definition: Player.h:922
bool SetupOutdoorPvP()
const uint32 HP_LANG_LOOSE_A[HP_TOWER_NUM]
ObjectiveStates m_State
Definition: OutdoorPvP.h:154
void SetGoArtKit(uint32 artkit)
Definition: GameObject.cpp:964
void HandleKillImpl(Player *plr, Unit *killed)
OPvPCapturePointHP(OutdoorPvP *pvp, OutdoorPvPHPTowerType type)