TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OutdoorPvP Class Reference

#include <OutdoorPvP.h>

Public Types

typedef std::map
< ObjectGuid::LowType,
OPvPCapturePoint * > 
OPvPCapturePointMap
 

Public Member Functions

 OutdoorPvP ()
 
virtual ~OutdoorPvP ()
 
void DeleteSpawns ()
 
virtual void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &)
 
virtual bool HandleAreaTrigger (Player *, uint32, bool)
 
virtual bool HandleCustomSpell (Player *player, uint32 spellId, GameObject *go)
 
virtual bool HandleOpenGo (Player *player, GameObject *go)
 
virtual bool SetupOutdoorPvP ()
 
void OnGameObjectCreate (GameObject *go) override
 
void OnGameObjectRemove (GameObject *go) override
 
void OnCreatureCreate (Creature *) override
 
void SendUpdateWorldState (uint32 field, uint32 value)
 
virtual bool Update (uint32 diff)
 
virtual void HandleKill (Player *killer, Unit *killed)
 
virtual void HandleKillImpl (Player *, Unit *)
 
bool IsInsideObjective (Player *player) const
 
virtual void AwardKillBonus (Player *)
 
uint32 GetTypeId () const
 
virtual bool HandleDropFlag (Player *player, uint32 spellId)
 
virtual bool HandleGossipOption (Player *player, Creature *creature, uint32 gossipid)
 
virtual bool CanTalkTo (Player *player, Creature *c, GossipMenuItems const &gso)
 
void TeamApplyBuff (TeamId team, uint32 spellId, uint32 spellId2=0)
 
void SendDefenseMessage (uint32 zoneId, uint32 id)
 
MapGetMap () const
 
- Public Member Functions inherited from ZoneScript
 ZoneScript ()
 
virtual ~ZoneScript ()
 
virtual uint32 GetCreatureEntry (ObjectGuid::LowType, CreatureData const *data)
 
virtual uint32 GetGameObjectEntry (ObjectGuid::LowType, uint32 entry)
 
virtual void OnCreatureRemove (Creature *)
 
virtual void OnUnitDeath (Unit *)
 
virtual ObjectGuid GetGuidData (uint32) const
 
virtual void SetGuidData (uint32, ObjectGuid)
 
virtual uint64 GetData64 (uint32) const
 
virtual void SetData64 (uint32, uint64)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void ProcessEvent (WorldObject *, uint32)
 

Static Public Member Functions

static TeamId GetTeamIdByTeam (uint32 team)
 

Protected Member Functions

virtual void SendRemoveWorldStates (Player *)
 
void BroadcastPacket (WorldPacket const *data) const
 
virtual void HandlePlayerEnterZone (Player *player, uint32 zone)
 
virtual void HandlePlayerLeaveZone (Player *player, uint32 zone)
 
virtual void HandlePlayerResurrects (Player *player, uint32 zone)
 
void AddCapturePoint (OPvPCapturePoint *cp)
 
OPvPCapturePointGetCapturePoint (ObjectGuid::LowType guid) const
 
void RegisterZone (uint32 zoneid)
 
bool HasPlayer (Player const *player) const
 
void TeamCastSpell (TeamId team, int32 spellId)
 
template<class Worker >
void BroadcastWorker (Worker &_worker, uint32 zoneId)
 
void SetMapFromZone (uint32 zone)
 

Protected Attributes

OPvPCapturePointMap m_capturePoints
 
GuidSet m_players [2]
 
uint32 m_TypeId
 
bool m_sendUpdate
 
Mapm_map
 

Friends

class OutdoorPvPMgr
 

Member Typedef Documentation

Constructor & Destructor Documentation

OutdoorPvP::OutdoorPvP ( )
250 : m_TypeId(0), m_sendUpdate(true), m_map(nullptr) { }
Map * m_map
Definition: OutdoorPvP.h:303
uint32 m_TypeId
Definition: OutdoorPvP.h:273
bool m_sendUpdate
Definition: OutdoorPvP.h:275
OutdoorPvP::~OutdoorPvP ( )
virtual
253 {
254  DeleteSpawns();
255 }
void DeleteSpawns()
Definition: OutdoorPvP.cpp:240

+ Here is the call graph for this function:

Member Function Documentation

void OutdoorPvP::AddCapturePoint ( OPvPCapturePoint cp)
protected
565 {
566  OPvPCapturePointMap::iterator i = m_capturePoints.find(cp->m_capturePointSpawnId);
567  if (i != m_capturePoints.end())
568  {
569  TC_LOG_ERROR("outdoorpvp", "OutdoorPvP::AddCapturePoint: CapturePoint " UI64FMTD " already exists!", cp->m_capturePointSpawnId);
570  delete i->second;
571  }
573 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269
ObjectGuid::LowType m_capturePointSpawnId
Definition: OutdoorPvP.h:131
#define UI64FMTD
Definition: Define.h:137
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the caller graph for this function:

virtual void OutdoorPvP::AwardKillBonus ( Player )
inlinevirtual
237 { }
void OutdoorPvP::BroadcastPacket ( WorldPacket const data) const
protected
556 {
557  // This is faster than sWorld->SendZoneMessage
558  for (uint32 team = 0; team < 2; ++team)
559  for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
560  if (Player* const player = ObjectAccessor::FindPlayer(*itr))
561  player->SendDirectMessage(data);
562 }
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint32_t uint32
Definition: Define.h:150
GuidSet m_players[2]
Definition: OutdoorPvP.h:271

+ Here is the call graph for this function:

template<class Worker >
void OutdoorPvP::BroadcastWorker ( Worker &  _worker,
uint32  zoneId 
)
protected
643 {
644  for (uint32 i = 0; i < BG_TEAMS_COUNT; ++i)
645  for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
646  if (Player* player = ObjectAccessor::FindPlayer(*itr))
647  if (player->GetZoneId() == zoneId)
648  _worker(player);
649 }
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint32_t uint32
Definition: Define.h:150
GuidSet m_players[2]
Definition: OutdoorPvP.h:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool OutdoorPvP::CanTalkTo ( Player player,
Creature c,
GossipMenuItems const gso 
)
virtual
529 {
530  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
531  if (itr->second->CanTalkTo(player, c, gso))
532  return true;
533 
534  return false;
535 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269
void OutdoorPvP::DeleteSpawns ( )
241 {
242  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
243  {
244  itr->second->DeleteSpawns();
245  delete itr->second;
246  }
247  m_capturePoints.clear();
248 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269

+ Here is the caller graph for this function:

virtual void OutdoorPvP::FillInitialWorldStates ( WorldPackets::WorldState::InitWorldStates )
inlinevirtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, OutdoorPvPTF, OutdoorPvPHP, and OutdoorPvPSI.

205 { }
OPvPCapturePoint * OutdoorPvP::GetCapturePoint ( ObjectGuid::LowType  guid) const
protected
576 {
577  OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(guid);
578  if (itr != m_capturePoints.end())
579  return itr->second;
580  return nullptr;
581 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269

+ Here is the caller graph for this function:

Map* OutdoorPvP::GetMap ( ) const
inline
264 { return m_map; }
Map * m_map
Definition: OutdoorPvP.h:303

+ Here is the caller graph for this function:

static TeamId OutdoorPvP::GetTeamIdByTeam ( uint32  team)
inlinestatic
250  {
251  switch (team)
252  {
253  case ALLIANCE:
254  return TEAM_ALLIANCE;
255  case HORDE:
256  return TEAM_HORDE;
257  default:
258  return TEAM_NEUTRAL;
259  }
260  }
Definition: SharedDefines.h:994
Definition: SharedDefines.h:1000
Definition: SharedDefines.h:992
Definition: SharedDefines.h:999
Definition: SharedDefines.h:993

+ Here is the caller graph for this function:

uint32 OutdoorPvP::GetTypeId ( ) const
inline
239 {return m_TypeId;}
uint32 m_TypeId
Definition: OutdoorPvP.h:273
virtual bool OutdoorPvP::HandleAreaTrigger ( Player ,
uint32  ,
bool   
)
inlinevirtual

Reimplemented in OutdoorPvPSI.

208 { return false; }
bool OutdoorPvP::HandleCustomSpell ( Player player,
uint32  spellId,
GameObject go 
)
virtual

Reimplemented in OutdoorPvPSI.

495 {
496  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
497  if (itr->second->HandleCustomSpell(player, spellId, go))
498  return true;
499 
500  return false;
501 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269
bool OutdoorPvP::HandleDropFlag ( Player player,
uint32  spellId 
)
virtual

Reimplemented in OutdoorPvPSI.

538 {
539  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
540  if (itr->second->HandleDropFlag(player, id))
541  return true;
542 
543  return false;
544 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269
bool OutdoorPvP::HandleGossipOption ( Player player,
Creature creature,
uint32  gossipid 
)
virtual
520 {
521  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
522  if (itr->second->HandleGossipOption(player, creature, id))
523  return true;
524 
525  return false;
526 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269
void OutdoorPvP::HandleKill ( Player killer,
Unit killed 
)
virtual
451 {
452  if (Group* group = killer->GetGroup())
453  {
454  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
455  {
456  Player* groupGuy = itr->GetSource();
457 
458  if (!groupGuy)
459  continue;
460 
461  // skip if too far away
462  if (!groupGuy->IsAtGroupRewardDistance(killed))
463  continue;
464 
465  // creature kills must be notified, even if not inside objective / not outdoor pvp active
466  // player kills only count if active and inside objective
467  if ((groupGuy->IsOutdoorPvPActive() && IsInsideObjective(groupGuy)) || killed->GetTypeId() == TYPEID_UNIT)
468  HandleKillImpl(groupGuy, killed);
469  }
470  }
471  else
472  {
473  // creature kills must be notified, even if not inside objective / not outdoor pvp active
474  if ((killer->IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed->GetTypeId() == TYPEID_UNIT)
475  HandleKillImpl(killer, killed);
476  }
477 }
virtual void HandleKillImpl(Player *, Unit *)
Definition: OutdoorPvP.h:231
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsInsideObjective(Player *player) const
Definition: OutdoorPvP.cpp:479
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

virtual void OutdoorPvP::HandleKillImpl ( Player ,
Unit  
)
inlinevirtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, and OutdoorPvPHP.

231 { }

+ Here is the caller graph for this function:

bool OutdoorPvP::HandleOpenGo ( Player player,
GameObject go 
)
virtual
511 {
512  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
513  if (itr->second->HandleOpenGo(player, go) >= 0)
514  return true;
515 
516  return false;
517 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269
void OutdoorPvP::HandlePlayerEnterZone ( Player player,
uint32  zone 
)
protectedvirtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, OutdoorPvPTF, OutdoorPvPHP, and OutdoorPvPSI.

258 {
259  m_players[player->GetTeamId()].insert(player->GetGUID());
260 }
GuidSet m_players[2]
Definition: OutdoorPvP.h:271

+ Here is the caller graph for this function:

void OutdoorPvP::HandlePlayerLeaveZone ( Player player,
uint32  zone 
)
protectedvirtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, OutdoorPvPTF, OutdoorPvPHP, and OutdoorPvPSI.

263 {
264  // inform the objectives of the leaving
265  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
266  itr->second->HandlePlayerLeave(player);
267  // remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones)
268  if (!player->GetSession()->PlayerLogout())
269  SendRemoveWorldStates(player);
270  m_players[player->GetTeamId()].erase(player->GetGUID());
271  TC_LOG_DEBUG("outdoorpvp", "Player %s left an outdoorpvp zone", player->GetName().c_str());
272 }
virtual void SendRemoveWorldStates(Player *)
Definition: OutdoorPvP.h:278
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
GuidSet m_players[2]
Definition: OutdoorPvP.h:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OutdoorPvP::HandlePlayerResurrects ( Player player,
uint32  zone 
)
protectedvirtual
274 { }
bool OutdoorPvP::HasPlayer ( Player const player) const
protected
589 {
590  GuidSet const &plSet = m_players[player->GetTeamId()];
591  return plSet.find(player->GetGUID()) != plSet.end();
592 }
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
GuidSet m_players[2]
Definition: OutdoorPvP.h:271
bool OutdoorPvP::IsInsideObjective ( Player player) const
480 {
481  for (OPvPCapturePointMap::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
482  if (itr->second->IsInsideObjective(player))
483  return true;
484 
485  return false;
486 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269

+ Here is the caller graph for this function:

void OutdoorPvP::OnCreatureCreate ( Creature )
inlineoverridevirtual

Reimplemented from ZoneScript.

221 { }
void OutdoorPvP::OnGameObjectCreate ( GameObject go)
overridevirtual

Reimplemented from ZoneScript.

617 {
619  return;
620 
622  cp->m_capturePoint = go;
623 }
Definition: SharedDefines.h:2094
Definition: OutdoorPvP.h:87
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
OPvPCapturePoint * GetCapturePoint(ObjectGuid::LowType guid) const
Definition: OutdoorPvP.cpp:575

+ Here is the call graph for this function:

void OutdoorPvP::OnGameObjectRemove ( GameObject go)
overridevirtual

Reimplemented from ZoneScript.

626 {
628  return;
629 
631  cp->m_capturePoint = NULL;
632 }
Definition: SharedDefines.h:2094
Definition: OutdoorPvP.h:87
arena_t NULL
Definition: jemalloc_internal.h:624
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
OPvPCapturePoint * GetCapturePoint(ObjectGuid::LowType guid) const
Definition: OutdoorPvP.cpp:575

+ Here is the call graph for this function:

void OutdoorPvP::RegisterZone ( uint32  zoneid)
protected
584 {
585  sOutdoorPvPMgr->AddZone(zoneId, this);
586 }
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:105

+ Here is the caller graph for this function:

void OutdoorPvP::SendDefenseMessage ( uint32  zoneId,
uint32  id 
)
635 {
636  DefenseMessageBuilder builder(zoneId, id);
638  BroadcastWorker(localizer, zoneId);
639 }
void BroadcastWorker(Worker &_worker, uint32 zoneId)
Definition: OutdoorPvP.cpp:642
Definition: OutdoorPvP.cpp:31
Definition: GridNotifiers.h:1400

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void OutdoorPvP::SendRemoveWorldStates ( Player )
inlineprotectedvirtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, OutdoorPvPTF, OutdoorPvPHP, and OutdoorPvPSI.

278 { }

+ Here is the caller graph for this function:

void OutdoorPvP::SendUpdateWorldState ( uint32  field,
uint32  value 
)
410 {
411  if (m_sendUpdate)
412  for (int i = 0; i < 2; ++i)
413  for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
414  if (Player* const player = ObjectAccessor::FindPlayer(*itr))
415  player->SendUpdateWorldState(field, value);
416 }
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
const FieldDescriptor value
Definition: descriptor.h:1522
bool m_sendUpdate
Definition: OutdoorPvP.h:275
GuidSet m_players[2]
Definition: OutdoorPvP.h:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OutdoorPvP::SetMapFromZone ( uint32  zone)
protected
652 {
653  AreaTableEntry const* areaTable = sAreaTableStore.LookupEntry(zone);
654  ASSERT(areaTable);
655  Map* map = sMapMgr->CreateBaseMap(areaTable->MapID);
656  ASSERT(!map->Instanceable());
657  m_map = map;
658 }
Definition: DBCStructure.h:37
uint32 MapID
Definition: DBCStructure.h:40
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
Map * m_map
Definition: OutdoorPvP.h:303
Definition: Map.h:259
#define sMapMgr
Definition: MapManager.h:194
#define ASSERT
Definition: Errors.h:55
bool Instanceable() const
Definition: Map.h:394

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual bool OutdoorPvP::SetupOutdoorPvP ( )
inlinevirtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, OutdoorPvPTF, OutdoorPvPHP, and OutdoorPvPSI.

217 {return true;}

+ Here is the caller graph for this function:

void OutdoorPvP::TeamApplyBuff ( TeamId  team,
uint32  spellId,
uint32  spellId2 = 0 
)
611 {
612  TeamCastSpell(team, spellId);
613  TeamCastSpell(OTHER_TEAM(team), spellId2 ? -(int32)spellId2 : -(int32)spellId);
614 }
void TeamCastSpell(TeamId team, int32 spellId)
Definition: OutdoorPvP.cpp:594
#define OTHER_TEAM(a)
Definition: OutdoorPvP.h:50
int32_t int32
Definition: Define.h:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OutdoorPvP::TeamCastSpell ( TeamId  team,
int32  spellId 
)
protected
595 {
596  if (spellId > 0)
597  {
598  for (GuidSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
599  if (Player* const player = ObjectAccessor::FindPlayer(*itr))
600  player->CastSpell(player, (uint32)spellId, true);
601  }
602  else
603  {
604  for (GuidSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
605  if (Player* const player = ObjectAccessor::FindPlayer(*itr))
606  player->RemoveAura((uint32)-spellId); // by stack?
607  }
608 }
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint32_t uint32
Definition: Define.h:150
GuidSet m_players[2]
Definition: OutdoorPvP.h:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool OutdoorPvP::Update ( uint32  diff)
virtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, OutdoorPvPTF, OutdoorPvPHP, and OutdoorPvPSI.

277 {
278  bool objective_changed = false;
279  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
280  {
281  if (itr->second->Update(diff))
282  objective_changed = true;
283  }
284  return objective_changed;
285 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:269

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class OutdoorPvPMgr
friend

Member Data Documentation

OPvPCapturePointMap OutdoorPvP::m_capturePoints
protected
Map* OutdoorPvP::m_map
protected
GuidSet OutdoorPvP::m_players[2]
protected
bool OutdoorPvP::m_sendUpdate
protected
uint32 OutdoorPvP::m_TypeId
protected

The documentation for this class was generated from the following files: