AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
OutdoorPvP Class Reference

#include "OutdoorPvP.h"

Inheritance diagram for OutdoorPvP:
ZoneScript OutdoorPvPEP OutdoorPvPGH OutdoorPvPHP OutdoorPvPNA OutdoorPvPSI OutdoorPvPTF OutdoorPvPZM

Public Types

typedef std::map< ObjectGuid::LowType, OPvPCapturePoint * > OPvPCapturePointMap
 
typedef std::pair< ObjectGuid::LowType, GameObject * > GoScriptPair
 
typedef std::pair< ObjectGuid::LowType, Creature * > CreatureScriptPair
 

Public Member Functions

 OutdoorPvP ()=default
 
 ~OutdoorPvP () override
 
void DeleteSpawns ()
 
virtual void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &)
 
virtual bool HandleAreaTrigger (Player *player, uint32 trigger)
 
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 *creature) override
 
void OnCreatureRemove (Creature *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 teamId, uint32 spellId, uint32 spellId2=0, Player *sameMapPlr=nullptr)
 
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 OnUnitDeath (Unit *)
 
virtual void OnCreatureEvade (Creature *)
 
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)
 

Protected Member Functions

void BroadcastPacket (WorldPacket &data) const
 
virtual void SendRemoveWorldStates (Player *)
 
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 spawnId) const
 
void RegisterZone (uint32 zoneid)
 
bool HasPlayer (Player const *player) const
 
void TeamCastSpell (TeamId team, int32 spellId, Player *sameMapPlr=nullptr)
 
void SetMapFromZone (uint32 zone)
 

Protected Attributes

OPvPCapturePointMap _capturePoints
 
std::array< PlayerSet, 2 > _players
 
uint32 _typeId {}
 
bool _sendUpdate { true }
 
Map_map {}
 
std::unordered_map< ObjectGuid::LowType, GameObject * > _goScriptStore
 
std::unordered_map< ObjectGuid::LowType, Creature * > _creatureScriptStore
 

Friends

class OutdoorPvPMgr
 

Detailed Description

Member Typedef Documentation

◆ CreatureScriptPair

◆ GoScriptPair

◆ OPvPCapturePointMap

Constructor & Destructor Documentation

◆ OutdoorPvP()

OutdoorPvP::OutdoorPvP ( )
default

◆ ~OutdoorPvP()

OutdoorPvP::~OutdoorPvP ( )
override
274{
275 DeleteSpawns();
276}
void DeleteSpawns()
Definition OutdoorPvP.cpp:245

References DeleteSpawns().

Member Function Documentation

◆ AddCapturePoint()

void OutdoorPvP::AddCapturePoint ( OPvPCapturePoint cp)
inlineprotected

◆ AwardKillBonus()

virtual void OutdoorPvP::AwardKillBonus ( Player )
inlinevirtual
236{}

◆ BroadcastPacket()

void OutdoorPvP::BroadcastPacket ( WorldPacket data) const
protected
634{
635 // This is faster than sWorld->SendZoneMessage
636 for (auto const& playerSet : _players)
637 for (auto itr : playerSet)
638 if (Player* const player = ObjectAccessor::FindPlayer(itr))
639 player->SendDirectMessage(&data);
640}
std::array< PlayerSet, 2 > _players
Definition OutdoorPvP.h:269
Definition Player.h:1066
Definition ObjectAccessor.h:61
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245

References _players, and ObjectAccessor::FindPlayer().

◆ CanTalkTo()

bool OutdoorPvP::CanTalkTo ( Player player,
Creature c,
GossipMenuItems const &  gso 
)
virtual
580{
581 for (auto& capturePoint : _capturePoints)
582 if (capturePoint.second->CanTalkTo(player, c, gso))
583 return true;
584
585 return false;
586}
virtual bool CanTalkTo(Player *player, Creature *c, GossipMenuItems const &gso)
Definition OutdoorPvP.cpp:579

References _capturePoints.

◆ DeleteSpawns()

void OutdoorPvP::DeleteSpawns ( )
246{
247 // Remove script from any registered gameobjects/creatures
248 for (auto& itr : _goScriptStore)
249 {
250 if (GameObject* go = itr.second)
251 go->ClearZoneScript();
252 }
253
254 _goScriptStore.clear();
255
256 for (auto& itr : _creatureScriptStore)
257 {
258 if (Creature* creature = itr.second)
259 creature->ClearZoneScript();
260 }
261
262 _creatureScriptStore.clear();
263
264 for (auto& capturePoint : _capturePoints)
265 {
266 capturePoint.second->DeleteSpawns();
267 delete capturePoint.second;
268 }
269
270 _capturePoints.clear();
271}
Definition Creature.h:47
Definition GameObject.h:120
std::unordered_map< ObjectGuid::LowType, Creature * > _creatureScriptStore
Definition OutdoorPvP.h:274
std::unordered_map< ObjectGuid::LowType, GameObject * > _goScriptStore
Definition OutdoorPvP.h:273

References _capturePoints, _creatureScriptStore, and _goScriptStore.

Referenced by ~OutdoorPvP().

◆ FillInitialWorldStates()

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

◆ GetCapturePoint()

OPvPCapturePoint * OutdoorPvP::GetCapturePoint ( ObjectGuid::LowType  spawnId) const
protected
730{
731 auto const itr = _capturePoints.find(spawnId);
732 if (itr != _capturePoints.end())
733 {
734 return itr->second;
735 }
736
737 return nullptr;
738}

References _capturePoints.

Referenced by OnGameObjectCreate(), and OnGameObjectRemove().

◆ GetMap()

◆ GetTypeId()

uint32 OutdoorPvP::GetTypeId ( ) const
inline
238{ return _typeId; }
uint32 _typeId
Definition OutdoorPvP.h:270

References _typeId.

Referenced by Player::SendInitWorldStates().

◆ HandleAreaTrigger()

bool OutdoorPvP::HandleAreaTrigger ( Player player,
uint32  trigger 
)
virtual

Reimplemented in OutdoorPvPSI.

629{
630 return false;
631}

◆ HandleCustomSpell()

bool OutdoorPvP::HandleCustomSpell ( Player player,
uint32  spellId,
GameObject go 
)
virtual

Reimplemented in OutdoorPvPSI.

548{
549 for (auto& capturePoint : _capturePoints)
550 if (capturePoint.second->HandleCustomSpell(player, spellId, go))
551 return true;
552
553 return false;
554}
virtual bool HandleCustomSpell(Player *player, uint32 spellId, GameObject *go)
Definition OutdoorPvP.cpp:547

References _capturePoints.

◆ HandleDropFlag()

bool OutdoorPvP::HandleDropFlag ( Player player,
uint32  spellId 
)
virtual

Reimplemented in OutdoorPvPSI.

589{
590 for (auto& capturePoint : _capturePoints)
591 if (capturePoint.second->HandleDropFlag(player, id))
592 return true;
593
594 return false;
595}
virtual bool HandleDropFlag(Player *player, uint32 spellId)
Definition OutdoorPvP.cpp:588

References _capturePoints.

◆ HandleGossipOption()

bool OutdoorPvP::HandleGossipOption ( Player player,
Creature creature,
uint32  gossipId 
)
virtual
571{
572 for (auto& capturePoint : _capturePoints)
573 if (capturePoint.second->HandleGossipOption(player, creature, id))
574 return true;
575
576 return false;
577}
virtual bool HandleGossipOption(Player *player, Creature *creature, uint32 gossipId)
Definition OutdoorPvP.cpp:570

References _capturePoints.

◆ HandleKill()

void OutdoorPvP::HandleKill ( Player killer,
Unit killed 
)
virtual

Reimplemented in OutdoorPvPGH, and OutdoorPvPNA.

499{
500 ASSERT(killer);
501
502 if (Group* group = killer->GetGroup())
503 {
504 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
505 {
506 Player* groupGuy = itr->GetSource();
507 if (!groupGuy)
508 continue;
509
510 // skip if too far away
511 if (!groupGuy->IsAtGroupRewardDistance(killed) && killer != groupGuy)
512 continue;
513
514 // creature kills must be notified, even if not inside objective / not outdoor pvp active
515 // player kills only count if active and inside objective
516 if ((groupGuy->IsOutdoorPvPActive() && IsInsideObjective(groupGuy)) || killed->IsCreature())
517 {
518 HandleKillImpl(groupGuy, killed);
519 }
520 }
521 }
522 else
523 {
524 // creature kills must be notified, even if not inside objective / not outdoor pvp active
525 if ((killer->IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed->IsCreature())
526 {
527 HandleKillImpl(killer, killed);
528 }
529 }
530}
#define ASSERT
Definition Errors.h:68
Definition GroupReference.h:27
Definition Group.h:169
bool IsCreature() const
Definition Object.h:204
bool IsInsideObjective(Player *player) const
Definition OutdoorPvP.cpp:532
virtual void HandleKillImpl(Player *, Unit *)
Definition OutdoorPvP.h:230
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition Player.cpp:12751
Group * GetGroup()
Definition Player.h:2477
bool IsOutdoorPvPActive()
Definition Player.cpp:6415

References ASSERT, Player::GetGroup(), HandleKillImpl(), Player::IsAtGroupRewardDistance(), Object::IsCreature(), IsInsideObjective(), and Player::IsOutdoorPvPActive().

◆ HandleKillImpl()

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

Reimplemented in OutdoorPvPHP, OutdoorPvPNA, and OutdoorPvPZM.

230{}

Referenced by HandleKill().

◆ HandleOpenGo()

bool OutdoorPvP::HandleOpenGo ( Player player,
GameObject go 
)
virtual
562{
563 for (auto& capturePoint : _capturePoints)
564 if (capturePoint.second->HandleOpenGo(player, go) >= 0)
565 return true;
566
567 return false;
568}
virtual bool HandleOpenGo(Player *player, GameObject *go)
Definition OutdoorPvP.cpp:561

References _capturePoints.

◆ HandlePlayerEnterZone()

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

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

279{
280 _players[player->GetTeamId()].insert(player->GetGUID());
281}
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
TeamId GetTeamId(bool original=false) const
Definition Player.h:2101

References _players, Object::GetGUID(), and Player::GetTeamId().

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

◆ HandlePlayerLeaveZone()

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

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

284{
285 // inform the objectives of the leaving
286 for (auto& _capturePoint : _capturePoints)
287 {
288 _capturePoint.second->HandlePlayerLeave(player);
289 }
290
291 // 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)
292 if (!player->GetSession()->PlayerLogout())
293 {
294 SendRemoveWorldStates(player);
295 }
296
297 _players[player->GetTeamId()].erase(player->GetGUID());
298 LOG_DEBUG("outdoorpvp", "OutdoorPvP: Player {} left an outdoorpvp zone", player->GetName());
299}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
virtual void SendRemoveWorldStates(Player *)
Definition OutdoorPvP.h:249
WorldSession * GetSession() const
Definition Player.h:1993
std::string const & GetName() const
Definition Object.h:524
bool PlayerLogout() const
Definition WorldSession.h:393

References _capturePoints, _players, Object::GetGUID(), WorldObject::GetName(), Player::GetSession(), Player::GetTeamId(), LOG_DEBUG, WorldSession::PlayerLogout(), and SendRemoveWorldStates().

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

◆ HandlePlayerResurrects()

void OutdoorPvP::HandlePlayerResurrects ( Player player,
uint32  zone 
)
protectedvirtual
302{
303}

◆ HasPlayer()

bool OutdoorPvP::HasPlayer ( Player const *  player) const
protected
648{
649 PlayerSet const& plSet = _players[player->GetTeamId()];
650 return plSet.find(player->GetGUID()) != plSet.end();
651}
GuidSet PlayerSet
Definition OutdoorPvP.h:88

References _players, Object::GetGUID(), and Player::GetTeamId().

◆ IsInsideObjective()

bool OutdoorPvP::IsInsideObjective ( Player player) const
533{
534 for (auto& capturePoint : _capturePoints)
535 if (capturePoint.second->IsInsideObjective(player))
536 return true;
537
538 return false;
539}

References _capturePoints.

Referenced by HandleKill().

◆ OnCreatureCreate()

void OutdoorPvP::OnCreatureCreate ( Creature creature)
overridevirtual

Reimplemented from ZoneScript.

709{
710 CreatureScriptPair sp(creature->GetGUID().GetCounter(), creature);
711 _creatureScriptStore.insert(sp);
712}
LowType GetCounter() const
Definition ObjectGuid.h:145
std::pair< ObjectGuid::LowType, Creature * > CreatureScriptPair
Definition OutdoorPvP.h:201

References _creatureScriptStore, ObjectGuid::GetCounter(), and Object::GetGUID().

◆ OnCreatureRemove()

void OutdoorPvP::OnCreatureRemove ( Creature creature)
overridevirtual

Reimplemented from ZoneScript.

715{
716 _creatureScriptStore.erase(creature->GetGUID().GetCounter());
717}

References _creatureScriptStore, ObjectGuid::GetCounter(), and Object::GetGUID().

◆ OnGameObjectCreate()

void OutdoorPvP::OnGameObjectCreate ( GameObject go)
overridevirtual

Reimplemented from ZoneScript.

678{
679 GoScriptPair sp(go->GetGUID().GetCounter(), go);
680 _goScriptStore.insert(sp);
681
683 {
684 return;
685 }
686
688 {
689 cp->_capturePoint = go;
690 }
691}
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition SharedDefines.h:1600
GameobjectTypes GetGoType() const
Definition GameObject.h:202
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
Definition OutdoorPvP.h:91
OPvPCapturePoint * GetCapturePoint(ObjectGuid::LowType spawnId) const
Definition OutdoorPvP.cpp:729
std::pair< ObjectGuid::LowType, GameObject * > GoScriptPair
Definition OutdoorPvP.h:200

References _goScriptStore, GAMEOBJECT_TYPE_CAPTURE_POINT, GetCapturePoint(), ObjectGuid::GetCounter(), GameObject::GetGoType(), Object::GetGUID(), and GameObject::GetSpawnId().

◆ OnGameObjectRemove()

void OutdoorPvP::OnGameObjectRemove ( GameObject go)
overridevirtual

Reimplemented from ZoneScript.

694{
695 _goScriptStore.erase(go->GetGUID().GetCounter());
696
698 {
699 return;
700 }
701
703 {
704 cp->_capturePoint = nullptr;
705 }
706}

References _goScriptStore, GAMEOBJECT_TYPE_CAPTURE_POINT, GetCapturePoint(), ObjectGuid::GetCounter(), GameObject::GetGoType(), Object::GetGUID(), and GameObject::GetSpawnId().

◆ RegisterZone()

void OutdoorPvP::RegisterZone ( uint32  zoneid)
protected

◆ SendRemoveWorldStates()

virtual void OutdoorPvP::SendRemoveWorldStates ( Player )
inlineprotectedvirtual

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

249{} // world state stuff

Referenced by HandlePlayerLeaveZone().

◆ SendUpdateWorldState()

◆ SetMapFromZone()

void OutdoorPvP::SetMapFromZone ( uint32  zone)
protected
720{
721 AreaTableEntry const* areaTable = sAreaTableStore.LookupEntry(zone);
722 ASSERT(areaTable);
723
724 Map* map = sMapMgr->CreateBaseMap(areaTable->mapid);
725 ASSERT(!map->Instanceable());
726 _map = map;
727}
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define sMapMgr
Definition MapMgr.h:220
Definition Map.h:163
bool Instanceable() const
Definition Map.h:294
Definition DBCStructure.h:519
uint32 mapid
Definition DBCStructure.h:521

References _map, ASSERT, Map::Instanceable(), AreaTableEntry::mapid, sAreaTableStore, and sMapMgr.

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

◆ SetupOutdoorPvP()

virtual bool OutdoorPvP::SetupOutdoorPvP ( )
inlinevirtual

◆ TeamApplyBuff()

void OutdoorPvP::TeamApplyBuff ( TeamId  teamId,
uint32  spellId,
uint32  spellId2 = 0,
Player sameMapPlr = nullptr 
)
672{
673 TeamCastSpell(teamId, (int32)spellId, sameMapPlr);
674 TeamCastSpell(teamId == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE, spellId2 ? -(int32)spellId2 : -(int32)spellId, sameMapPlr);
675}
std::int32_t int32
Definition Define.h:103
@ TEAM_ALLIANCE
Definition SharedDefines.h:771
@ TEAM_HORDE
Definition SharedDefines.h:772
void TeamCastSpell(TeamId team, int32 spellId, Player *sameMapPlr=nullptr)
Definition OutdoorPvP.cpp:653

References TEAM_ALLIANCE, TEAM_HORDE, and TeamCastSpell().

Referenced by OPvPCapturePointNA::FactionTakeOver(), OutdoorPvPSI::HandleAreaTrigger(), OPvPCapturePointZM_Graveyard::HandleOpenGo(), OutdoorPvPHP::Update(), and OutdoorPvPTF::Update().

◆ TeamCastSpell()

void OutdoorPvP::TeamCastSpell ( TeamId  team,
int32  spellId,
Player sameMapPlr = nullptr 
)
protected
654{
655 if (spellId > 0)
656 {
657 for (auto itr : _players[team])
658 if (Player* const player = ObjectAccessor::FindPlayer(itr))
659 if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
660 player->CastSpell(player, (uint32)spellId, true);
661 }
662 else
663 {
664 for (auto itr : _players[team])
665 if (Player* const player = ObjectAccessor::FindPlayer(itr))
666 if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
667 player->RemoveAura((uint32) - spellId); // by stack?
668 }
669}
std::uint32_t uint32
Definition Define.h:107

References _players, WorldObject::FindMap(), and ObjectAccessor::FindPlayer().

Referenced by TeamApplyBuff(), OutdoorPvPHP::Update(), and OutdoorPvPTF::Update().

◆ Update()

bool OutdoorPvP::Update ( uint32  diff)
virtual

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

306{
307 bool objective_changed = false;
308 for (auto& capturePoint : _capturePoints)
309 {
310 if (capturePoint.second->Update(diff))
311 objective_changed = true;
312 }
313
314 return objective_changed;
315}

References _capturePoints.

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

Friends And Related Symbol Documentation

◆ OutdoorPvPMgr

friend class OutdoorPvPMgr
friend

Member Data Documentation

◆ _capturePoints

◆ _creatureScriptStore

std::unordered_map<ObjectGuid::LowType, Creature*> OutdoorPvP::_creatureScriptStore
protected

◆ _goScriptStore

std::unordered_map<ObjectGuid::LowType, GameObject*> OutdoorPvP::_goScriptStore
protected

◆ _map

Map* OutdoorPvP::_map {}
protected
272{};

Referenced by GetMap(), and SetMapFromZone().

◆ _players

◆ _sendUpdate

bool OutdoorPvP::_sendUpdate { true }
protected
271{ true };

Referenced by SendUpdateWorldState().

◆ _typeId


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