OregonCore  revision fb2a440-git
Your Favourite TBC server
OutdoorPvP Class Reference

#include <OutdoorPvP.h>

+ Inheritance diagram for OutdoorPvP:

Public Types

typedef std::map< uint32, OPvPCapturePoint * > OPvPCapturePointMap
 

Public Member Functions

 OutdoorPvP ()
 
virtual ~OutdoorPvP ()
 
void DeleteSpawns ()
 
virtual void FillInitialWorldStates (WorldPacket &)
 
virtual bool HandleAreaTrigger (Player *plr, uint32 trigger)
 
virtual bool HandleCustomSpell (Player *plr, uint32 spellId, GameObject *go)
 
virtual bool HandleOpenGo (Player *plr, uint64 guid)
 
virtual bool SetupOutdoorPvP ()
 
void OnGameObjectCreate (GameObject *go, bool add) override
 
void OnGameObjectRemove (GameObject *go)
 
void OnCreatureCreate (Creature *, bool) 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 *plr) const
 
virtual void AwardKillBonus (Player *)
 
uint32 GetTypeId ()
 
virtual bool HandleDropFlag (Player *plr, uint32 spellId)
 
virtual bool HandleGossipOption (Player *plr, uint64 guid, uint32 gossipid)
 
virtual bool CanTalkTo (Player *plr, Creature *c, GossipMenuItems gso)
 
void TeamApplyBuff (TeamId team, uint32 spellId, uint32 spellId2=0)
 
- Public Member Functions inherited from ZoneScript
 ZoneScript ()
 
virtual uint32 GetCreatureEntry (uint32, const CreatureData *data)
 
virtual uint32 GetGameObjectEntry (uint32, uint32 entry)
 
virtual void OnCreatureDeath (Creature *)
 
virtual void OnPlayerDeath (Player *)
 
virtual uint64 GetData64 (uint32)
 All-purpose data storage 64 bit. More...
 
virtual void SetData64 (uint32, uint64)
 
virtual uint32 GetData (uint32)
 All-purpose data storage 32 bit. More...
 
virtual void SetData (uint32, uint32)
 
virtual void ProcessEvent (GameObject *, uint32 eventId=0)
 
virtual void ProcessEvent (Unit *, uint32 eventId=0)
 

Protected Member Functions

virtual void SendRemoveWorldStates (Player *)
 
virtual void HandlePlayerEnterZone (Player *plr, uint32 zone)
 
virtual void HandlePlayerLeaveZone (Player *plr, uint32 zone)
 
void AddCapturePoint (OPvPCapturePoint *cp)
 
OPvPCapturePointGetCapturePoint (uint32 lowguid) const
 
void RegisterZone (uint32 zoneid)
 
bool HasPlayer (Player *plr) const
 
void TeamCastSpell (TeamId team, int32 spellId)
 

Protected Attributes

OPvPCapturePointMap m_capturePoints
 
PlayerSet m_players [2]
 
uint32 m_TypeId
 

Friends

class OutdoorPvPMgr
 

Detailed Description

Definition at line 170 of file OutdoorPvP.h.

Member Typedef Documentation

Definition at line 181 of file OutdoorPvP.h.

Constructor & Destructor Documentation

OutdoorPvP::OutdoorPvP ( )

Definition at line 228 of file OutdoorPvP.cpp.

229 {
230 }
OutdoorPvP::~OutdoorPvP ( )
virtual

Definition at line 232 of file OutdoorPvP.cpp.

References OPvPCapturePoint::DeleteSpawns().

233 {
234  DeleteSpawns();
235 }
void DeleteSpawns()
Definition: OutdoorPvP.cpp:218

Member Function Documentation

void OutdoorPvP::AddCapturePoint ( OPvPCapturePoint cp)
inlineprotected

Definition at line 242 of file OutdoorPvP.h.

References OPvPCapturePoint::m_capturePointGUID.

243  {
245  }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
uint32 m_capturePointGUID
Definition: OutdoorPvP.h:125
virtual void OutdoorPvP::AwardKillBonus ( Player )
inlinevirtual

Definition at line 215 of file OutdoorPvP.h.

215 {}
bool OutdoorPvP::CanTalkTo ( Player plr,
Creature c,
GossipMenuItems  gso 
)
virtual

Definition at line 498 of file OutdoorPvP.cpp.

Referenced by OPvPCapturePointZM_GraveYard::ChangeState().

499 {
500  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
501  if (itr->second->CanTalkTo(plr, c, gso))
502  return true;
503 
504  return false;
505 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
void OutdoorPvP::DeleteSpawns ( )

Definition at line 218 of file OutdoorPvP.cpp.

219 {
220  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
221  {
222  itr->second->DeleteSpawns();
223  delete itr->second;
224  }
225  m_capturePoints.clear();
226 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
virtual void OutdoorPvP::FillInitialWorldStates ( WorldPacket )
inlinevirtual
OPvPCapturePoint* OutdoorPvP::GetCapturePoint ( uint32  lowguid) const
inlineprotected

Definition at line 247 of file OutdoorPvP.h.

248  {
249  OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
250  if (itr != m_capturePoints.end())
251  return itr->second;
252  return NULL;
253  }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
uint32 OutdoorPvP::GetTypeId ( )
inline

Definition at line 217 of file OutdoorPvP.h.

References OutdoorPvPMgr::CanTalkTo(), OutdoorPvPMgr::HandleDropFlag(), and OutdoorPvPMgr::HandleGossipOption().

Referenced by Player::SendInitWorldStates().

218  {
219  return m_TypeId;
220  }
uint32 m_TypeId
Definition: OutdoorPvP.h:234
bool OutdoorPvP::HandleAreaTrigger ( Player plr,
uint32  trigger 
)
virtual

Reimplemented in OutdoorPvPSI.

Definition at line 539 of file OutdoorPvP.cpp.

540 {
541  return false;
542 }
bool OutdoorPvP::HandleCustomSpell ( Player plr,
uint32  spellId,
GameObject go 
)
virtual

Reimplemented in OutdoorPvPSI.

Definition at line 464 of file OutdoorPvP.cpp.

465 {
466  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
467  if (itr->second->HandleCustomSpell(plr, spellId, go))
468  return true;
469 
470  return false;
471 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
bool OutdoorPvP::HandleDropFlag ( Player plr,
uint32  spellId 
)
virtual

Reimplemented in OutdoorPvPSI.

Definition at line 507 of file OutdoorPvP.cpp.

Referenced by OPvPCapturePointZM_GraveYard::ChangeState().

508 {
509  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
510  if (itr->second->HandleDropFlag(plr, id))
511  return true;
512 
513  return false;
514 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
bool OutdoorPvP::HandleGossipOption ( Player plr,
uint64  guid,
uint32  gossipid 
)
virtual

Definition at line 489 of file OutdoorPvP.cpp.

Referenced by OPvPCapturePointZM_GraveYard::ChangeState().

490 {
491  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
492  if (itr->second->HandleGossipOption(plr, guid, id))
493  return true;
494 
495  return false;
496 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
void OutdoorPvP::HandleKill ( Player killer,
Unit killed 
)
virtual

Definition at line 421 of file OutdoorPvP.cpp.

References Player::GetGroup(), Object::GetTypeId(), Player::IsAtGroupRewardDistance(), OPvPCapturePoint::IsInsideObjective(), Player::IsOutdoorPvPActive(), GroupReference::next(), and TYPEID_UNIT.

422 {
423  if (Group* pGroup = killer->GetGroup())
424  {
425  for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
426  {
427  Player* pGroupGuy = itr->GetSource();
428 
429  if (!pGroupGuy)
430  continue;
431 
432  // skip if too far away
433  if (!pGroupGuy->IsAtGroupRewardDistance(killed))
434  continue;
435 
436  // creature kills must be notified, even if not inside objective / not outdoor pvp active
437  // player kills only count if active and inside objective
438  if ((pGroupGuy->IsOutdoorPvPActive() && IsInsideObjective(pGroupGuy)) || killed->GetTypeId() == TYPEID_UNIT)
439  HandleKillImpl(pGroupGuy, killed);
440  }
441  }
442  else
443  {
444  // creature kills must be notified, even if not inside objective / not outdoor pvp active
445  if (killer && ((killer->IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed->GetTypeId() == TYPEID_UNIT))
446  HandleKillImpl(killer, killed);
447  }
448 }
Group * GetGroup()
Definition: Player.h:2577
bool IsInsideObjective(Player *plr) const
Definition: OutdoorPvP.cpp:450
virtual void HandleKillImpl(Player *, Unit *)
Definition: OutdoorPvP.h:209
bool IsOutdoorPvPActive()
Definition: Player.cpp:6400
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition: Player.cpp:19935
uint8 GetTypeId() const
Definition: Object.h:210
GroupReference * next()
Definition: Player.h:922
Definition: Group.h:154
virtual void OutdoorPvP::HandleKillImpl ( Player ,
Unit  
)
inlinevirtual

Reimplemented in OutdoorPvPNA, OutdoorPvPZM, and OutdoorPvPHP.

Definition at line 209 of file OutdoorPvP.h.

209 {}
bool OutdoorPvP::HandleOpenGo ( Player plr,
uint64  guid 
)
virtual

Definition at line 480 of file OutdoorPvP.cpp.

Referenced by OPvPCapturePointZM_GraveYard::ChangeState().

481 {
482  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
483  if (itr->second->HandleOpenGo(plr, guid) >= 0)
484  return true;
485 
486  return false;
487 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
void OutdoorPvP::HandlePlayerEnterZone ( Player plr,
uint32  zone 
)
protectedvirtual
void OutdoorPvP::HandlePlayerLeaveZone ( Player plr,
uint32  zone 
)
protectedvirtual

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

Definition at line 242 of file OutdoorPvP.cpp.

References WorldObject::GetName(), Player::GetSession(), Player::GetTeamId(), WorldSession::PlayerLogout(), and sLog.

Referenced by OutdoorPvPSI::HandlePlayerLeaveZone(), OutdoorPvPHP::HandlePlayerLeaveZone(), OutdoorPvPTF::HandlePlayerLeaveZone(), OutdoorPvPEP::HandlePlayerLeaveZone(), OutdoorPvPZM::HandlePlayerLeaveZone(), and OutdoorPvPNA::HandlePlayerLeaveZone().

243 {
244  // inform the objectives of the leaving
245  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
246  itr->second->HandlePlayerLeave(plr);
247  // 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)
248  if (!plr->GetSession()->PlayerLogout())
250  m_players[plr->GetTeamId()].erase(plr);
251  sLog.outDebug("Player %s left an outdoorpvp zone", plr->GetName());
252 }
virtual void SendRemoveWorldStates(Player *)
Definition: OutdoorPvP.h:237
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
#define sLog
Log class singleton.
Definition: Log.h:187
PlayerSet m_players[2]
Definition: OutdoorPvP.h:233
const char * GetName() const
Definition: Object.h:704
bool PlayerLogout() const
Definition: WorldSession.h:77
TeamId GetTeamId() const
Definition: Player.h:2067
WorldSession * GetSession() const
Definition: Player.h:1944
bool OutdoorPvP::HasPlayer ( Player plr) const
protected

Definition at line 549 of file OutdoorPvP.cpp.

References Player::GetTeamId().

550 {
551  return m_players[plr->GetTeamId()].find(plr) != m_players[plr->GetTeamId()].end();
552 }
PlayerSet m_players[2]
Definition: OutdoorPvP.h:233
TeamId GetTeamId() const
Definition: Player.h:2067
bool OutdoorPvP::IsInsideObjective ( Player plr) const

Definition at line 450 of file OutdoorPvP.cpp.

451 {
452  for (OPvPCapturePointMap::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
453  if (itr->second->IsInsideObjective(plr))
454  return true;
455 
456  return false;
457 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
void OutdoorPvP::OnCreatureCreate ( Creature ,
bool   
)
inlineoverridevirtual

Reimplemented from ZoneScript.

Definition at line 199 of file OutdoorPvP.h.

References OutdoorPvPMgr::Update(), and value.

199 {}
void OutdoorPvP::OnGameObjectCreate ( GameObject go,
bool  add 
)
overridevirtual

Reimplemented from ZoneScript.

Definition at line 570 of file OutdoorPvP.cpp.

References GAMEOBJECT_TYPE_CAPTURE_POINT, GameObject::GetDBTableGUIDLow(), and GameObject::GetGoType().

571 {
573  return;
574 
576  cp->m_capturePoint = add ? go : NULL;
577 }
OPvPCapturePoint * GetCapturePoint(uint32 lowguid) const
Definition: OutdoorPvP.h:247
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
uint32 GetDBTableGUIDLow() const
Definition: GameObject.h:607
void OutdoorPvP::OnGameObjectRemove ( GameObject go)

Definition at line 579 of file OutdoorPvP.cpp.

References GAMEOBJECT_TYPE_CAPTURE_POINT, GameObject::GetDBTableGUIDLow(), and GameObject::GetGoType().

580 {
582  return;
583 
585  cp->m_capturePoint = NULL;
586 }
OPvPCapturePoint * GetCapturePoint(uint32 lowguid) const
Definition: OutdoorPvP.h:247
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
uint32 GetDBTableGUIDLow() const
Definition: GameObject.h:607
void OutdoorPvP::RegisterZone ( uint32  zoneid)
protected

Definition at line 544 of file OutdoorPvP.cpp.

References sOutdoorPvPMgr.

Referenced by OutdoorPvPSI::SetupOutdoorPvP().

545 {
546  sOutdoorPvPMgr.AddZone(zoneId, this);
547 }
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:79
virtual void OutdoorPvP::SendRemoveWorldStates ( Player )
inlineprotectedvirtual
void OutdoorPvP::SendUpdateWorldState ( uint32  field,
uint32  value 
)

Definition at line 384 of file OutdoorPvP.cpp.

Referenced by OPvPCapturePointHP::ChangeState(), OPvPCapturePointEP::ChangeState(), OPvPCapturePointNA::Update(), OPvPCapturePointNA::UpdateHalaaWorldState(), OPvPCapturePointTF::UpdateTowerState(), OPvPCapturePointZM_Beacon::UpdateTowerState(), OPvPCapturePointZM_GraveYard::UpdateTowerState(), OutdoorPvPSI::UpdateWorldState(), and OPvPCapturePointNA::UpdateWyvernRoostWorldState().

385 {
386  for (int i = 0; i < 2; ++i)
387  for (PlayerSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
388  (*itr)->SendUpdateWorldState(field, value);
389 }
etc mysql my cnf *Then change max_allowed_packet to a bigger value
PlayerSet m_players[2]
Definition: OutdoorPvP.h:233
virtual bool OutdoorPvP::SetupOutdoorPvP ( )
inlinevirtual

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

Definition at line 192 of file OutdoorPvP.h.

Referenced by OutdoorPvPMgr::InitOutdoorPvP().

193  {
194  return true;
195  }
void OutdoorPvP::TeamApplyBuff ( TeamId  team,
uint32  spellId,
uint32  spellId2 = 0 
)

Definition at line 564 of file OutdoorPvP.cpp.

References OTHER_TEAM.

Referenced by OutdoorPvPSI::HandleAreaTrigger(), and OPvPCapturePointZM_GraveYard::HandleOpenGo().

565 {
566  TeamCastSpell(team, spellId);
567  TeamCastSpell(OTHER_TEAM(team), spellId2 ? -(int32)spellId2 : -(int32)spellId);
568 }
void TeamCastSpell(TeamId team, int32 spellId)
Definition: OutdoorPvP.cpp:554
ACE_INT32 int32
Definition: Define.h:67
#define OTHER_TEAM(a)
Definition: OutdoorPvP.h:47
void OutdoorPvP::TeamCastSpell ( TeamId  team,
int32  spellId 
)
protected

Definition at line 554 of file OutdoorPvP.cpp.

555 {
556  if (spellId > 0)
557  for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
558  (*itr)->CastSpell(*itr, (uint32)spellId, true);
559  else
560  for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
561  (*itr)->RemoveAurasDueToSpell((uint32) - spellId);
562 }
PlayerSet m_players[2]
Definition: OutdoorPvP.h:233
ACE_UINT32 uint32
Definition: Define.h:71
bool OutdoorPvP::Update ( uint32  diff)
virtual

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

Definition at line 254 of file OutdoorPvP.cpp.

Referenced by OutdoorPvPHP::Update(), OutdoorPvPTF::Update(), OutdoorPvPEP::Update(), and OutdoorPvPZM::Update().

255 {
256  bool objective_changed = false;
257  for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
258  {
259  if (itr->second->Update(diff))
260  objective_changed = true;
261  }
262  return objective_changed;
263 }
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231

Friends And Related Function Documentation

friend class OutdoorPvPMgr
friend

Definition at line 172 of file OutdoorPvP.h.

Member Data Documentation

OPvPCapturePointMap OutdoorPvP::m_capturePoints
protected

Definition at line 231 of file OutdoorPvP.h.

PlayerSet OutdoorPvP::m_players[2]
protected

Definition at line 233 of file OutdoorPvP.h.

uint32 OutdoorPvP::m_TypeId
protected

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