OregonCore  revision 3611e8a-git
Your Favourite TBC server
OutdoorPvPEP.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 "OutdoorPvPEP.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 #include "GossipDef.h"
27 
29 
31 
33 
35 
37 
39  : OPvPCapturePoint(pvp), m_TowerType(type)
40 {
42  EPCapturePoints[type].map,
43  EPCapturePoints[type].x,
44  EPCapturePoints[type].y,
45  EPCapturePoints[type].z,
46  EPCapturePoints[type].o,
47  EPCapturePoints[type].rot0,
48  EPCapturePoints[type].rot1,
49  EPCapturePoints[type].rot2,
50  EPCapturePoints[type].rot3);
51 
52  for (uint8 i = 0; i < 2; i++)
53  AddObject(type + EP_TOWER_NUM * i,
54  EPTowerFlags[type + EP_TOWER_NUM * i].entry,
55  21,
56  EPTowerFlags[type + EP_TOWER_NUM * i].map,
57  EPTowerFlags[type + EP_TOWER_NUM * i].x,
58  EPTowerFlags[type + EP_TOWER_NUM * i].y,
59  EPTowerFlags[type + EP_TOWER_NUM * i].z,
60  EPTowerFlags[type + EP_TOWER_NUM * i].o,
61  EPTowerFlags[type + EP_TOWER_NUM * i].rot0,
62  EPTowerFlags[type + EP_TOWER_NUM * i].rot1,
63  EPTowerFlags[type + EP_TOWER_NUM * i].rot2,
64  EPTowerFlags[type + EP_TOWER_NUM * i].rot3);
65 
66  EP_TOWER_EVENT_TEAM[type] = 0;
67 }
68 
70 {
71  m_TypeId = OUTDOOR_PVP_EP;
72 }
73 
75 {
76  m_AllianceTowersControlled = 0;
77  m_HordeTowersControlled = 0;
78 
79  // add the zones affected by the pvp buff
80  for (uint8 i = 0; i < OutdoorPvPEPBuffZonesNum; ++i)
81  RegisterZone(OutdoorPvPEPBuffZones[i]);
82 
83  AddCapturePoint(new OPvPCapturePointEP(this, EP_TOWER_CROWNGUARD));
84  AddCapturePoint(new OPvPCapturePointEP(this, EP_TOWER_EASTWALL));
85  AddCapturePoint(new OPvPCapturePointEP(this, EP_TOWER_NORTHPASS));
86  AddCapturePoint(new OPvPCapturePointEP(this, EP_TOWER_PLAGUEWOOD));
87 
88  return true;
89 }
90 
92 {
93  // add buffs
94  if (plr->GetTeam() == ALLIANCE)
95  {
96  if (m_AllianceTowersControlled > 0)
97  plr->CastSpell(plr, EP_AllianceBuffs[m_AllianceTowersControlled - 1], true);
98  }
99  else
100  {
101  if (m_HordeTowersControlled > 0)
102  plr->CastSpell(plr, EP_HordeBuffs[m_HordeTowersControlled - 1], true);
103  }
105 }
106 
108 {
109  // remove buffs
110  if (plr->GetTeam() == ALLIANCE)
111  {
112  for (uint8 i = 0; i < OutdoorPvPEPTeamsBuffNum; ++i)
114  }
115  else
116  {
117  for (uint8 i = 0; i < OutdoorPvPEPTeamsBuffNum; ++i)
119  }
121 }
122 
124 {
125  bool changed = false;
126  if ((changed = OutdoorPvP::Update(diff)))
127  {
128  for (uint8 i = 0; i < OutdoorPvPEPTeamsBuffNum; ++i)
129  {
130  TeamCastSpell(TEAM_ALLIANCE, -EP_AllianceBuffs[i]);
131  TeamCastSpell(TEAM_HORDE, -EP_HordeBuffs[i]);
132  }
133 
134  uint32 AllianceBuff = m_AllianceTowersControlled > 0 ? EP_AllianceBuffs[m_AllianceTowersControlled - 1] : 0;
135  uint32 HordeBuff = m_HordeTowersControlled > 0 ? EP_HordeBuffs[m_HordeTowersControlled - 1] : 0;
136  if (m_AllianceTowersControlled > 0)
137  TeamApplyBuff(TEAM_ALLIANCE, AllianceBuff, HordeBuff);
138  if (m_HordeTowersControlled > 0)
139  TeamApplyBuff(TEAM_HORDE, HordeBuff, AllianceBuff);
140 
141  SendUpdateWorldState(EP_UI_TOWER_COUNT_A, m_AllianceTowersControlled);
142  SendUpdateWorldState(EP_UI_TOWER_COUNT_H, m_HordeTowersControlled);
143  }
144  return changed;
145 }
146 
148 {
154 
155  for (uint8 i = 0; i < EP_TOWER_NUM; ++i)
156  {
157  plr->SendUpdateWorldState(EP_MAP_N[i], 0);
158  plr->SendUpdateWorldState(EP_MAP_A[i], 0);
159  plr->SendUpdateWorldState(EP_MAP_H[i], 0);
160  plr->SendUpdateWorldState(EP_MAP_N_A[i], 0);
161  plr->SendUpdateWorldState(EP_MAP_N_H[i], 0);
162  }
163 }
164 
166 {
167  data << EP_UI_TOWER_COUNT_A << m_AllianceTowersControlled;
168  data << EP_UI_TOWER_COUNT_H << m_HordeTowersControlled;
169  data << EP_UI_TOWER_SLIDER_DISPLAY << uint32(0);
170  data << EP_UI_TOWER_SLIDER_POS << uint32(50);
171  data << EP_UI_TOWER_SLIDER_N << uint32(100);
172  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
173  itr->second->FillInitialWorldStates(data);
174 }
175 
177 {
178  uint32 field = 0;
179  switch (m_OldState)
180  {
182  field = EP_MAP_N[m_TowerType];
183  break;
185  field = EP_MAP_A[m_TowerType];
186  if (((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled)
187  ((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled--;
188  sWorld.SendZoneText(OutdoorPvPEPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(EP_LANG_LOOSE_A[m_TowerType]));
189  break;
191  field = EP_MAP_H[m_TowerType];
192  if (((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled)
193  ((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled--;
194  sWorld.SendZoneText(OutdoorPvPEPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(EP_LANG_LOOSE_H[m_TowerType]));
195  break;
198  field = EP_MAP_N_A[m_TowerType];
199  break;
202  field = EP_MAP_N_H[m_TowerType];
203  break;
204  }
205 
206  // send world state update
207  if (field)
208  {
209  m_PvP->SendUpdateWorldState(field, 0);
210  field = 0;
211  }
212 
213  uint32 artkit = 21;
214  switch (m_State)
215  {
217  field = EP_MAP_N[m_TowerType];
218  break;
220  field = EP_MAP_A[m_TowerType];
221  artkit = 2;
222  if (((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled < 4)
223  ((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled++;
224  sWorld.SendZoneText(OutdoorPvPEPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(EP_LANG_CAPTURE_A[m_TowerType]));
225  break;
227  field = EP_MAP_H[m_TowerType];
228  artkit = 1;
229  if (((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled < 4)
230  ((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled++;
231  sWorld.SendZoneText(OutdoorPvPEPBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(EP_LANG_CAPTURE_H[m_TowerType]));
232  break;
235  field = EP_MAP_N_A[m_TowerType];
236  break;
239  field = EP_MAP_N_H[m_TowerType];
240  break;
241  }
242 
244 
247  if (m_capturePoint)
248  m_capturePoint->SetGoArtKit(artkit);
249  if (flag)
250  flag->SetGoArtKit(artkit);
251  if (flag2)
252  flag2->SetGoArtKit(artkit);
253 
254  // send world state update
255  if (field)
256  m_PvP->SendUpdateWorldState(field, 1);
257 
258  // complete quest objective
260  SendObjectiveComplete(EP_CREDITMARKER[m_TowerType], 0);
261 }
262 
264 {
266  // send these updates to only the ones in this objective
267  uint32 phase = (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f);
270 }
271 
273 {
274  switch (m_State)
275  {
277  data << uint32(EP_MAP_N[m_TowerType]) << uint32(0);
278  data << uint32(EP_MAP_A[m_TowerType]) << uint32(1);
279  data << uint32(EP_MAP_H[m_TowerType]) << uint32(0);
280  data << uint32(EP_MAP_N_A[m_TowerType]) << uint32(0);
281  data << uint32(EP_MAP_N_H[m_TowerType]) << uint32(0);
282  break;
284  data << uint32(EP_MAP_N[m_TowerType]) << uint32(0);
285  data << uint32(EP_MAP_A[m_TowerType]) << uint32(0);
286  data << uint32(EP_MAP_H[m_TowerType]) << uint32(1);
287  data << uint32(EP_MAP_N_A[m_TowerType]) << uint32(0);
288  data << uint32(EP_MAP_N_H[m_TowerType]) << uint32(0);
289  break;
292  data << uint32(EP_MAP_N[m_TowerType]) << uint32(0);
293  data << uint32(EP_MAP_A[m_TowerType]) << uint32(0);
294  data << uint32(EP_MAP_H[m_TowerType]) << uint32(0);
295  data << uint32(EP_MAP_N_A[m_TowerType]) << uint32(1);
296  data << uint32(EP_MAP_N_H[m_TowerType]) << uint32(0);
297  break;
300  data << uint32(EP_MAP_N[m_TowerType]) << uint32(0);
301  data << uint32(EP_MAP_A[m_TowerType]) << uint32(0);
302  data << uint32(EP_MAP_H[m_TowerType]) << uint32(0);
303  data << uint32(EP_MAP_N_A[m_TowerType]) << uint32(0);
304  data << uint32(EP_MAP_N_H[m_TowerType]) << uint32(1);
305  break;
307  default:
308  data << uint32(EP_MAP_N[m_TowerType]) << uint32(1);
309  data << uint32(EP_MAP_A[m_TowerType]) << uint32(0);
310  data << uint32(EP_MAP_H[m_TowerType]) << uint32(0);
311  data << uint32(EP_MAP_N_A[m_TowerType]) << uint32(0);
312  data << uint32(EP_MAP_N_H[m_TowerType]) << uint32(0);
313  break;
314  }
315 }
316 
318 {
320  {
322  uint32 phase = (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f);
325  return true;
326  }
327  return false;
328 }
329 
331 {
334 }
335 
336 // Tower specific events
338 {
340  {
342  switch (m_TowerType)
343  {
344  case EP_TOWER_CROWNGUARD:
345  LinkGraveYard(team);
346  break;
347  case EP_TOWER_EASTWALL:
348  SummonSupportUnits(team);
349  break;
350  case EP_TOWER_NORTHPASS:
351  SummonShrine(team);
352  break;
353  case EP_TOWER_PLAGUEWOOD:
354  SummonFlightMaster(team);
355  break;
356  default:
357  break;
358  }
359  }
361  {
362  switch (m_TowerType)
363  {
364  case EP_TOWER_CROWNGUARD:
365  UnlinkGraveYard();
366  break;
367  case EP_TOWER_EASTWALL:
369  break;
370  case EP_TOWER_NORTHPASS:
371  UnsummonShrine();
372  break;
373  case EP_TOWER_PLAGUEWOOD:
375  break;
376  default:
377  break;
378  }
379  }
380 }
381 
383 {
385  {
387  sObjectMgr.RemoveGraveYardLink(EP_GraveYardId, EP_GraveYardZone, team, false);
388  sObjectMgr.AddGraveYardLink(EP_GraveYardId, EP_GraveYardZone, team, false);
389  }
390 }
391 
393 {
396 }
397 
399 {
401  {
403  const creature_type* ct = NULL;
404  if (team == ALLIANCE)
405  ct = EP_EWT_Summons_A;
406  else
407  ct = EP_EWT_Summons_H;
408 
409  for (uint8 i = 0; i < EP_EWT_NUM_CREATURES; ++i)
410  {
411  DelCreature(i);
412  AddCreature(i, ct[i].entry, ct[i].teamval, ct[i].map, ct[i].x, ct[i].y, ct[i].z, ct[i].o, 1000000);
413  }
414  }
415 }
416 
418 {
419  for (uint8 i = 0; i < EP_EWT_NUM_CREATURES; ++i)
420  DelCreature(i);
422 }
423 
425 {
427  {
432  if (go)
433  go->SetUInt32Value(GAMEOBJECT_FACTION, (team == ALLIANCE ? 84 : 83));
434 
438  }
439 }
440 
442 {
446 }
447 
449 {
451  {
455 
456  // Change the flightmasters's faction to horde and display a red aura around the npc
458  if (c && team == HORDE)
459  {
462  }
463  }
464 }
465 
467 {
470 }
471 
void HandlePlayerEnterZone(Player *plr, uint32 zone)
float rot1
Definition: OutdoorPvP.h:59
float z
Definition: OutdoorPvP.h:56
uint32 map
Definition: OutdoorPvP.h:69
const creature_type EP_EWT_Summons_H[EP_EWT_NUM_CREATURES]
Definition: OutdoorPvPEP.h:116
float y
Definition: OutdoorPvP.h:55
virtual void HandlePlayerEnterZone(Player *plr, uint32 zone)
Definition: OutdoorPvP.cpp:237
const uint32 EP_LANG_CAPTURE_A[EP_TOWER_NUM]
const uint32 EP_CREDITMARKER[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:43
OutdoorPvP * m_PvP
Definition: OutdoorPvP.h:159
void SendUpdateWorldState(uint32 Field, uint32 Value)
Definition: Player.cpp:7713
uint32 entry
Definition: OutdoorPvP.h:67
uint32 EP_TOWER_EVENT_TEAM[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:168
const uint32 EP_LANG_FLIGHT_GOSSIPS[EP_TOWER_NUM-1]
virtual void HandlePlayerLeave(Player *plr)
Definition: OutdoorPvP.cpp:48
const uint8 EP_EWT_NUM_CREATURES
Definition: OutdoorPvPEP.h:103
bool DelObject(uint32 type)
Definition: OutdoorPvP.cpp:175
const uint32 EP_LANG_LOOSE_H[EP_TOWER_NUM]
#define OutdoorPvPEPBuffZonesNum
Definition: OutdoorPvPEP.h:23
const uint32 EP_MAP_N_A[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:48
bool SetupOutdoorPvP()
const uint32 EP_GraveYardId
Definition: OutdoorPvPEP.h:32
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
const uint32 EP_LANG_LOOSE_A[EP_TOWER_NUM]
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
const uint32 EP_LANG_CAPTURE_H[EP_TOWER_NUM]
static T * Find(uint64 guid)
const int EP_HordeBuffs[OutdoorPvPEPTeamsBuffNum]
Definition: OutdoorPvPEP.h:29
const go_type EPCapturePoints[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:79
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
void SummonFlightMaster(uint32 team)
float o
Definition: OutdoorPvP.h:57
#define sObjectMgr
Definition: ObjectMgr.h:1285
OutdoorPvPEPTowerType
Definition: OutdoorPvPEP.h:34
const uint32 EP_MAP_N[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:45
void RemoveAurasDueToSpell(uint32 spellId, Aura *except=NULL)
Definition: Unit.cpp:4316
void SendObjectiveComplete(uint32 id, uint64 guid)
Definition: OutdoorPvP.cpp:401
void FillInitialWorldStates(WorldPacket &data)
void SummonShrine(uint32 team)
ACE_UINT8 uint8
Definition: Define.h:73
float rot2
Definition: OutdoorPvP.h:60
uint32 map
Definition: OutdoorPvP.h:53
void SummonSupportUnits(uint32 team)
float rot3
Definition: OutdoorPvP.h:61
float rot0
Definition: OutdoorPvP.h:58
uint32 faction
Definition: Creature.h:150
const creature_type EP_PWT_FlightMaster
Definition: OutdoorPvPEP.h:125
const go_type EP_NPT_LordaeronShrine
Definition: OutdoorPvPEP.h:128
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1174
OPvPCapturePointEP(OutdoorPvP *pvp, OutdoorPvPEPTowerType type)
bool AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay=0)
Definition: OutdoorPvP.cpp:105
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:391
const creature_type EP_EWT_Summons_A[EP_EWT_NUM_CREATURES]
Definition: OutdoorPvPEP.h:107
GameObject * m_capturePoint
Definition: OutdoorPvP.h:126
void SendRemoveWorldStates(Player *plr)
void HandlePlayerLeave(Player *plr)
virtual void HandlePlayerLeaveZone(Player *plr, uint32 zone)
Definition: OutdoorPvP.cpp:242
std::map< uint32, uint64 > m_Objects
Definition: OutdoorPvP.h:163
const uint32 EP_MAP_N_H[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:49
const uint32 EP_MAP_H[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:47
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:156
const uint32 OutdoorPvPEPBuffZones[OutdoorPvPEPBuffZonesNum]
Definition: OutdoorPvPEP.h:26
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:598
const go_type EP_NPT_LordaeronShrineAura
Definition: OutdoorPvPEP.h:129
void FillInitialWorldStates(WorldPacket &data)
bool HandlePlayerEnter(Player *plr)
uint32 entry
Definition: OutdoorPvP.h:52
uint32 GetTeam() const
Definition: Player.h:2075
const uint32 EP_MAP_A[EP_TOWER_NUM]
Definition: OutdoorPvPEP.h:46
virtual bool HandlePlayerEnter(Player *plr)
Definition: OutdoorPvP.cpp:37
void HandlePlayerLeaveZone(Player *plr, uint32 zone)
#define sWorld
Definition: World.h:860
std::map< uint32, uint64 > m_Creatures
Definition: OutdoorPvP.h:164
virtual bool Update(uint32 diff)
Definition: OutdoorPvP.cpp:254
const go_type EPTowerFlags[EP_TOWER_NUM *2]
Definition: OutdoorPvPEP.h:87
void LinkGraveYard(uint32 team)
ACE_UINT32 uint32
Definition: Define.h:71
const uint32 EP_GraveYardZone
Definition: OutdoorPvPEP.h:31
const int EP_AllianceBuffs[OutdoorPvPEPTeamsBuffNum]
Definition: OutdoorPvPEP.h:28
bool DelCreature(uint32 type)
Definition: OutdoorPvP.cpp:141
OutdoorPvPEPTowerType m_TowerType
Definition: OutdoorPvPEP.h:172
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:384
bool Update(uint32 diff)
ObjectiveStates m_OldState
Definition: OutdoorPvP.h:153
Definition: Player.h:922
ObjectiveStates m_State
Definition: OutdoorPvP.h:154
void SetGoArtKit(uint32 artkit)
Definition: GameObject.cpp:964
float x
Definition: OutdoorPvP.h:54
const uint32 EP_PWT_FlightMasterAura
Definition: OutdoorPvPEP.h:126
#define OutdoorPvPEPTeamsBuffNum
Definition: OutdoorPvPEP.h:24