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)
666{
667 m_Bf = battlefield;
668 m_GraveyardId = 0;
670 m_ResurrectQueue.clear();
671}
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
uint32 m_GraveyardId
Definition: Battlefield.h:197
GuidUnorderedSet m_ResurrectQueue
Definition: Battlefield.h:199
Battlefield * m_Bf
Definition: Battlefield.h:200
TeamId m_ControlTeam
Definition: Battlefield.h:196

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

Member Function Documentation

◆ AddPlayer()

void BfGraveyard::AddPlayer ( ObjectGuid  player_guid)
698{
699 if (!m_ResurrectQueue.count(playerGuid))
700 {
701 m_ResurrectQueue.insert(playerGuid);
702
703 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
704 player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
705 }
706}
@ SPELL_WAITING_FOR_RESURRECT
Definition: Battleground.h:137
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:245
Definition: Player.h:1081

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

◆ GetControlTeamId()

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

References m_ControlTeam.

◆ GetDistance()

float BfGraveyard::GetDistance ( Player player)
692{
693 const GraveyardStruct* safeLoc = sGraveyard->GetGraveyard(m_GraveyardId);
694 return player->GetDistance2d(safeLoc->x, safeLoc->y);
695}
#define sGraveyard
Definition: GameGraveyard.h:74
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1274
Definition: GameGraveyard.h:27
float x
Definition: GameGraveyard.h:30
float y
Definition: GameGraveyard.h:31

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

◆ GetGraveyardId()

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

References m_GraveyardId.

Referenced by Battlefield::GetClosestGraveyard().

◆ GiveControlTo()

void BfGraveyard::GiveControlTo ( TeamId  team)
747{
748 m_ControlTeam = team;
749 // Teleport to other graveyard, player witch were on this graveyard
751}
void RelocateDeadPlayers()
Definition: Battlefield.cpp:753

References m_ControlTeam, and RelocateDeadPlayers().

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

◆ HasNpc()

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

References m_SpiritGuide.

◆ HasPlayer()

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

References m_ResurrectQueue.

◆ Initialize()

void BfGraveyard::Initialize ( TeamId  startcontrol,
uint32  gy 
)
674{
675 m_ControlTeam = startControl;
676 m_GraveyardId = graveyardId;
677}

References m_ControlTeam, and m_GraveyardId.

Referenced by BattlefieldWG::SetupBattlefield().

◆ RelocateDeadPlayers()

void BfGraveyard::RelocateDeadPlayers ( )
754{
755 GraveyardStruct const* closestGrave = nullptr;
756 for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
757 {
758 Player* player = ObjectAccessor::FindPlayer(*itr);
759 if (!player)
760 continue;
761
762 if (closestGrave)
763 player->TeleportTo(player->GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
764 else
765 {
766 closestGrave = m_Bf->GetClosestGraveyard(player);
767 if (closestGrave)
768 player->TeleportTo(player->GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
769 }
770 }
771}
GraveyardStruct const * GetClosestGraveyard(Player *player)
Definition: Battlefield.cpp:596
float GetOrientation() const
Definition: Position.h:119
uint32 GetMapId() const
Definition: Position.h:275
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1334
float z
Definition: GameGraveyard.h:32

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)
709{
710 m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid));
711
712 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
713 player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
714}

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

◆ Resurrect()

void BfGraveyard::Resurrect ( )
717{
718 if (m_ResurrectQueue.empty())
719 return;
720
721 for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
722 {
723 // Get player object from his guid
724 Player* player = ObjectAccessor::FindPlayer(*itr);
725 if (!player)
726 continue;
727
728 // Check if the player is in world and on the good graveyard
729 if (player->IsInWorld())
731 spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true);
732
733 // Resurect player
734 player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true);
735 player->ResurrectPlayer(1.0f);
736 player->CastSpell(player, 6962, true);
737 player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
738
739 player->SpawnCorpseBones(false);
740 }
741
742 m_ResurrectQueue.clear();
743}
@ SPELL_SPIRIT_HEAL
Definition: Battleground.h:139
@ SPELL_SPIRIT_HEAL_MANA
Definition: Battleground.h:143
@ SPELL_RESURRECTION_VISUAL
Definition: Battleground.h:140
Creature * GetCreature(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:210
bool IsInWorld() const
Definition: Object.h:107
void SpawnCorpseBones(bool triggerSave=true)
Definition: Player.cpp:4705
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition: Player.cpp:4492
Definition: Unit.h:630
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:1167

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 
)
680{
681 if (!spirit)
682 {
683 LOG_ERROR("bg.battlefield", "BfGraveyard::SetSpirit: Invalid Spirit.");
684 return;
685 }
686
687 m_SpiritGuide[team] = spirit->GetGUID();
689}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
@ REACT_PASSIVE
Definition: Unit.h:548
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition: Creature.h:94
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112

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().