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
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->GetSession()->SendPacket(&data);
640}
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
Definition: Player.h:1056
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
580{
581 for (auto& capturePoint : _capturePoints)
582 if (capturePoint.second->CanTalkTo(player, c, gso))
583 return true;
584
585 return false;
586}

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:122
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
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()

Map * OutdoorPvP::GetMap ( ) const
inline
244{ return _map; }
Map * _map
Definition: OutdoorPvP.h:272

References _map.

Referenced by OPvPCapturePoint::DelCreature(), OPvPCapturePoint::DelObject(), and OPvPCapturePointNA::GetAliveGuardsCount().

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

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}

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}

References _capturePoints.

◆ HandleKill()

void OutdoorPvP::HandleKill ( Player killer,
Unit killed 
)
virtual
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->GetTypeId() == TYPEID_UNIT)
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->GetTypeId() == TYPEID_UNIT)
526 {
527 HandleKillImpl(killer, killed);
528 }
529 }
530}
#define ASSERT
Definition: Errors.h:68
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
TypeID GetTypeId() const
Definition: Object.h:121
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition: Player.cpp:12678
Group * GetGroup()
Definition: Player.h:2431
bool IsOutdoorPvPActive()
Definition: Player.cpp:6320
Definition: Group.h:169
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
bool IsInsideObjective(Player *player) const
Definition: OutdoorPvP.cpp:532
virtual void HandleKillImpl(Player *, Unit *)
Definition: OutdoorPvP.h:230

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

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

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:106
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2072

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:169
std::string const & GetName() const
Definition: Object.h:446
WorldSession * GetSession() const
Definition: Player.h:1961
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
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:147
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:1589
GameobjectTypes GetGoType() const
Definition: GameObject.h:205
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:146
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:221
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 
)
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:104
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
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:108
Map * FindMap() const
Definition: Object.h:518

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