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 (WorldPacket &)
 
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 OnCreatureCreate (Creature *)
 
virtual void OnCreatureRemove (Creature *)
 
virtual void OnGameObjectCreate (GameObject *)
 
virtual void OnGameObjectRemove (GameObject *)
 
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
273{
274 DeleteSpawns();
275}
void DeleteSpawns()
Definition: OutdoorPvP.cpp:244

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
633{
634 // This is faster than sWorld->SendZoneMessage
635 for (auto const& playerSet : _players)
636 for (auto itr : playerSet)
637 if (Player* const player = ObjectAccessor::FindPlayer(itr))
638 player->GetSession()->SendPacket(&data);
639}
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
Definition: Player.h:1064
std::array< PlayerSet, 2 > _players
Definition: OutdoorPvP.h:269

References _players, and ObjectAccessor::FindPlayer().

◆ CanTalkTo()

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

References _capturePoints.

◆ DeleteSpawns()

void OutdoorPvP::DeleteSpawns ( )
245{
246 // Remove script from any registered gameobjects/creatures
247 for (auto& itr : _goScriptStore)
248 {
249 if (GameObject* go = itr.second)
250 go->ClearZoneScript();
251 }
252
253 _goScriptStore.clear();
254
255 for (auto& itr : _creatureScriptStore)
256 {
257 if (Creature* creature = itr.second)
258 creature->ClearZoneScript();
259 }
260
261 _creatureScriptStore.clear();
262
263 for (auto& capturePoint : _capturePoints)
264 {
265 capturePoint.second->DeleteSpawns();
266 delete capturePoint.second;
267 }
268
269 _capturePoints.clear();
270}
Definition: Creature.h:46
Definition: GameObject.h:121
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 ( WorldPacket )
inlinevirtual

◆ GetCapturePoint()

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

References _capturePoints.

Referenced by OnGameObjectCreate(), and OnGameObjectRemove().

◆ GetMap()

Map * OutdoorPvP::GetMap ( ) const
inline

◆ 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.

628{
629 return false;
630}

◆ HandleCustomSpell()

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

Reimplemented in OutdoorPvPSI.

547{
548 for (auto& capturePoint : _capturePoints)
549 if (capturePoint.second->HandleCustomSpell(player, spellId, go))
550 return true;
551
552 return false;
553}

References _capturePoints.

◆ HandleDropFlag()

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

Reimplemented in OutdoorPvPSI.

588{
589 for (auto& capturePoint : _capturePoints)
590 if (capturePoint.second->HandleDropFlag(player, id))
591 return true;
592
593 return false;
594}

References _capturePoints.

◆ HandleGossipOption()

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

References _capturePoints.

◆ HandleKill()

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

Reimplemented in OutdoorPvPNA.

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

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

◆ 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
561{
562 for (auto& capturePoint : _capturePoints)
563 if (capturePoint.second->HandleOpenGo(player, go) >= 0)
564 return true;
565
566 return false;
567}

References _capturePoints.

◆ HandlePlayerEnterZone()

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

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

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

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.

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

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
301{
302}

◆ HasPlayer()

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

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

◆ IsInsideObjective()

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

References _capturePoints.

Referenced by HandleKill().

◆ OnCreatureCreate()

void OutdoorPvP::OnCreatureCreate ( Creature creature)
overridevirtual

Reimplemented from ZoneScript.

708{
709 CreatureScriptPair sp(creature->GetGUID().GetCounter(), creature);
710 _creatureScriptStore.insert(sp);
711}
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.

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

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

◆ OnGameObjectCreate()

void OutdoorPvP::OnGameObjectCreate ( GameObject go)
overridevirtual

Reimplemented from ZoneScript.

677{
678 GoScriptPair sp(go->GetGUID().GetCounter(), go);
679 _goScriptStore.insert(sp);
680
682 {
683 return;
684 }
685
687 {
688 cp->_capturePoint = go;
689 }
690}
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition: SharedDefines.h:1589
GameobjectTypes GetGoType() const
Definition: GameObject.h:204
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:145
Definition: OutdoorPvP.h:91
OPvPCapturePoint * GetCapturePoint(ObjectGuid::LowType spawnId) const
Definition: OutdoorPvP.cpp:728
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.

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

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
719{
720 AreaTableEntry const* areaTable = sAreaTableStore.LookupEntry(zone);
721 ASSERT(areaTable);
722
723 Map* map = sMapMgr->CreateBaseMap(areaTable->mapid);
724 ASSERT(!map->Instanceable());
725 _map = map;
726}
#define sMapMgr
Definition: MapMgr.h:221
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
Definition: Map.h:313
bool Instanceable() const
Definition: Map.h:447
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 
)
671{
672 TeamCastSpell(teamId, (int32)spellId, sameMapPlr);
673 TeamCastSpell(teamId == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE, spellId2 ? -(int32)spellId2 : -(int32)spellId, sameMapPlr);
674}
std::int32_t int32
Definition: Define.h:103
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
void TeamCastSpell(TeamId team, int32 spellId, Player *sameMapPlr=nullptr)
Definition: OutdoorPvP.cpp:652

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
653{
654 if (spellId > 0)
655 {
656 for (auto itr : _players[team])
657 if (Player* const player = ObjectAccessor::FindPlayer(itr))
658 if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
659 player->CastSpell(player, (uint32)spellId, true);
660 }
661 else
662 {
663 for (auto itr : _players[team])
664 if (Player* const player = ObjectAccessor::FindPlayer(itr))
665 if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
666 player->RemoveAura((uint32) - spellId); // by stack?
667 }
668}
std::uint32_t uint32
Definition: Define.h:107
Map * FindMap() const
Definition: Object.h:532

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.

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

References _capturePoints.

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

Friends And Related Function 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

Referenced by GetMap(), and SetMapFromZone().

◆ _players

◆ _sendUpdate

bool OutdoorPvP::_sendUpdate { true }
protected

Referenced by SendUpdateWorldState().

◆ _typeId