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

#include "Battlefield.h"

Inheritance diagram for BfGraveyard:
BfGraveyardWG

Public Member Functions

 BfGraveyard (Battlefield *Bf)
 
void GiveControlTo (TeamId team)
 
TeamId GetControlTeamId () const
 
float GetDistance (Player *player)
 
void Initialize (TeamId startcontrol, uint32 gy)
 
void SetSpirit (Creature *spirit, TeamId team)
 
void AddPlayer (ObjectGuid player_guid)
 
void RemovePlayer (ObjectGuid player_guid)
 
void Resurrect ()
 
void RelocateDeadPlayers ()
 
bool HasNpc (ObjectGuid guid)
 
bool HasPlayer (ObjectGuid guid) const
 
uint32 GetGraveyardId () const
 

Protected Attributes

TeamId m_ControlTeam
 
uint32 m_GraveyardId
 
ObjectGuid m_SpiritGuide [2]
 
GuidUnorderedSet m_ResurrectQueue
 
Battlefieldm_Bf
 

Detailed Description

Constructor & Destructor Documentation

◆ BfGraveyard()

BfGraveyard::BfGraveyard ( Battlefield Bf)
661{
662 m_Bf = battlefield;
663 m_GraveyardId = 0;
665 m_ResurrectQueue.clear();
666}
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
uint32 m_GraveyardId
Definition: Battlefield.h:198
GuidUnorderedSet m_ResurrectQueue
Definition: Battlefield.h:200
Battlefield * m_Bf
Definition: Battlefield.h:201
TeamId m_ControlTeam
Definition: Battlefield.h:197

References m_Bf, m_ControlTeam, m_GraveyardId, m_ResurrectQueue, and TEAM_NEUTRAL.

Member Function Documentation

◆ AddPlayer()

void BfGraveyard::AddPlayer ( ObjectGuid  player_guid)
693{
694 if (!m_ResurrectQueue.count(playerGuid))
695 {
696 m_ResurrectQueue.insert(playerGuid);
697
698 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
699 player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
700 }
701}
@ SPELL_WAITING_FOR_RESURRECT
Definition: Battleground.h:132
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
Definition: Player.h:1046

References ObjectAccessor::FindPlayer(), m_ResurrectQueue, and SPELL_WAITING_FOR_RESURRECT.

◆ GetControlTeamId()

TeamId BfGraveyard::GetControlTeamId ( ) const
inline
153{ return m_ControlTeam; }

References m_ControlTeam.

◆ GetDistance()

float BfGraveyard::GetDistance ( Player player)
687{
688 const GraveyardStruct* safeLoc = sGraveyard->GetGraveyard(m_GraveyardId);
689 return player->GetDistance2d(safeLoc->x, safeLoc->y);
690}
#define sGraveyard
Definition: GameGraveyard.h:75
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1263
Definition: GameGraveyard.h:28
float x
Definition: GameGraveyard.h:31
float y
Definition: GameGraveyard.h:32

References WorldObject::GetDistance2d(), m_GraveyardId, sGraveyard, GraveyardStruct::x, and GraveyardStruct::y.

◆ GetGraveyardId()

uint32 BfGraveyard::GetGraveyardId ( ) const
inline
194{ return m_GraveyardId; }

References m_GraveyardId.

Referenced by Battlefield::GetClosestGraveyard().

◆ GiveControlTo()

void BfGraveyard::GiveControlTo ( TeamId  team)
742{
743 m_ControlTeam = team;
744 // Teleport to other graveyard, player witch were on this graveyard
746}
void RelocateDeadPlayers()
Definition: Battlefield.cpp:748

References m_ControlTeam, and RelocateDeadPlayers().

Referenced by WGWorkshop::GiveControlTo(), and WGWorkshop::UpdateGraveyardAndWorkshop().

◆ HasNpc()

bool BfGraveyard::HasNpc ( ObjectGuid  guid)
inline
178 {
179 if (!m_SpiritGuide[0] && !m_SpiritGuide[1])
180 return false;
181
182 // performance
183 /*if (!ObjectAccessor::FindUnit(m_SpiritGuide[0]) &&
184 !ObjectAccessor::FindUnit(m_SpiritGuide[1]))
185 return false;*/
186
187 return (m_SpiritGuide[0] == guid || m_SpiritGuide[1] == guid);
188 }
ObjectGuid m_SpiritGuide[2]
Definition: Battlefield.h:199

References m_SpiritGuide.

◆ HasPlayer()

bool BfGraveyard::HasPlayer ( ObjectGuid  guid) const
inline
191{ return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }

References m_ResurrectQueue.

◆ Initialize()

void BfGraveyard::Initialize ( TeamId  startcontrol,
uint32  gy 
)
669{
670 m_ControlTeam = startControl;
671 m_GraveyardId = graveyardId;
672}

References m_ControlTeam, and m_GraveyardId.

Referenced by BattlefieldWG::SetupBattlefield().

◆ RelocateDeadPlayers()

void BfGraveyard::RelocateDeadPlayers ( )
749{
750 GraveyardStruct const* closestGrave = nullptr;
751 for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
752 {
753 Player* player = ObjectAccessor::FindPlayer(*itr);
754 if (!player)
755 continue;
756
757 if (closestGrave)
758 player->TeleportTo(player->GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
759 else
760 {
761 closestGrave = m_Bf->GetClosestGraveyard(player);
762 if (closestGrave)
763 player->TeleportTo(player->GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
764 }
765 }
766}
GraveyardStruct const * GetClosestGraveyard(Player *player)
Definition: Battlefield.cpp:591
float GetOrientation() const
Definition: Position.h:120
uint32 GetMapId() const
Definition: Position.h:276
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1311
float z
Definition: GameGraveyard.h:33

References ObjectAccessor::FindPlayer(), Battlefield::GetClosestGraveyard(), WorldLocation::GetMapId(), Position::GetOrientation(), m_Bf, m_ResurrectQueue, Player::TeleportTo(), GraveyardStruct::x, GraveyardStruct::y, and GraveyardStruct::z.

Referenced by GiveControlTo().

◆ RemovePlayer()

void BfGraveyard::RemovePlayer ( ObjectGuid  player_guid)
704{
705 m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid));
706
707 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
708 player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
709}

References ObjectAccessor::FindPlayer(), m_ResurrectQueue, and SPELL_WAITING_FOR_RESURRECT.

◆ Resurrect()

void BfGraveyard::Resurrect ( )
712{
713 if (m_ResurrectQueue.empty())
714 return;
715
716 for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
717 {
718 // Get player object from his guid
719 Player* player = ObjectAccessor::FindPlayer(*itr);
720 if (!player)
721 continue;
722
723 // Check if the player is in world and on the good graveyard
724 if (player->IsInWorld())
726 spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true);
727
728 // Resurect player
729 player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true);
730 player->ResurrectPlayer(1.0f);
731 player->CastSpell(player, 6962, true);
732 player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
733
734 player->SpawnCorpseBones(false);
735 }
736
737 m_ResurrectQueue.clear();
738}
@ SPELL_SPIRIT_HEAL
Definition: Battleground.h:134
@ SPELL_SPIRIT_HEAL_MANA
Definition: Battleground.h:138
@ SPELL_RESURRECTION_VISUAL
Definition: Battleground.h:135
Creature * GetCreature(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:215
bool IsInWorld() const
Definition: Object.h:101
void SpawnCorpseBones(bool triggerSave=true)
Definition: Player.cpp:4587
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition: Player.cpp:4375
Definition: Unit.h:1290
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169

References Unit::CastSpell(), ObjectAccessor::FindPlayer(), ObjectAccessor::GetCreature(), Object::IsInWorld(), m_ControlTeam, m_ResurrectQueue, m_SpiritGuide, Player::ResurrectPlayer(), Player::SpawnCorpseBones(), SPELL_RESURRECTION_VISUAL, SPELL_SPIRIT_HEAL, and SPELL_SPIRIT_HEAL_MANA.

◆ SetSpirit()

void BfGraveyard::SetSpirit ( Creature spirit,
TeamId  team 
)
675{
676 if (!spirit)
677 {
678 LOG_ERROR("bg.battlefield", "BfGraveyard::SetSpirit: Invalid Spirit.");
679 return;
680 }
681
682 m_SpiritGuide[team] = spirit->GetGUID();
684}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
@ REACT_PASSIVE
Definition: Unit.h:1023
void SetReactState(ReactStates st)
Definition: Creature.h:89
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106

References Object::GetGUID(), LOG_ERROR, m_SpiritGuide, REACT_PASSIVE, and Creature::SetReactState().

Member Data Documentation

◆ m_Bf

Battlefield* BfGraveyard::m_Bf
protected

◆ m_ControlTeam

TeamId BfGraveyard::m_ControlTeam
protected

◆ m_GraveyardId

uint32 BfGraveyard::m_GraveyardId
protected

◆ m_ResurrectQueue

GuidUnorderedSet BfGraveyard::m_ResurrectQueue
protected

◆ m_SpiritGuide

ObjectGuid BfGraveyard::m_SpiritGuide[2]
protected

Referenced by HasNpc(), Resurrect(), and SetSpirit().