AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ArenaSpectator Namespace Reference

Functions

template<class T >
AC_GAME_API void SendPacketTo (const T *object, std::string &&message)
 
template<class T , typename Format , typename... Args>
void SendCommand (T *o, Format &&fmt, Args &&... args)
 
template<class T >
void SendCommand_String (T *o, ObjectGuid targetGUID, const char *prefix, const char *c)
 
template<class T >
void SendCommand_UInt32Value (T *o, ObjectGuid targetGUID, const char *prefix, uint32 t)
 
template<class T >
void SendCommand_GUID (T *o, ObjectGuid targetGUID, const char *prefix, ObjectGuid t)
 
template<class T >
void SendCommand_Spell (T *o, ObjectGuid targetGUID, const char *prefix, uint32 id, int32 casttime)
 
template<class T >
void SendCommand_Cooldown (T *o, ObjectGuid targetGUID, const char *prefix, uint32 id, uint32 dur, uint32 maxdur)
 
template<class T >
void SendCommand_Aura (T *o, ObjectGuid targetGUID, const char *prefix, ObjectGuid caster, uint32 id, bool isDebuff, uint32 dispel, int32 dur, int32 maxdur, uint32 stack, bool remove)
 
AC_GAME_API bool HandleSpectatorSpectateCommand (ChatHandler *handler, std::string const &name)
 
AC_GAME_API bool HandleSpectatorWatchCommand (ChatHandler *handler, std::string const &name)
 
AC_GAME_API void CreatePacket (WorldPacket &data, std::string const &message)
 
AC_GAME_API void HandleResetCommand (Player *player)
 
AC_GAME_API bool ShouldSendAura (Aura *aura, uint8 effMask, ObjectGuid targetGUID, bool remove)
 

Function Documentation

◆ CreatePacket()

void ArenaSpectator::CreatePacket ( WorldPacket data,
std::string const &  message 
)
213{
214 std::size_t len = message.length();
215 data.Initialize(SMSG_MESSAGECHAT, 1 + 4 + 8 + 4 + 8 + 4 + 1 + len + 1);
216 data << uint8(CHAT_MSG_WHISPER);
217 data << uint32(LANG_ADDON);
218 data << uint64(0);
219 data << uint32(0);
220 data << uint64(0);
221 data << uint32(len + 1);
222 data << message;
223 data << uint8(0);
224}
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
std::uint64_t uint64
Definition: Define.h:106
@ CHAT_MSG_WHISPER
Definition: SharedDefines.h:3159
@ LANG_ADDON
Definition: SharedDefines.h:753
@ SMSG_MESSAGECHAT
Definition: Opcodes.h:180
void Initialize(uint16 opcode, std::size_t newres=200)
Definition: WorldPacket.h:68

References CHAT_MSG_WHISPER, WorldPacket::Initialize(), LANG_ADDON, and SMSG_MESSAGECHAT.

◆ HandleResetCommand()

void ArenaSpectator::HandleResetCommand ( Player player)
227{
228 if (!player->FindMap() || !player->IsInWorld() || !player->FindMap()->IsBattleArena())
229 return;
230
231 Battleground* bg = ((BattlegroundMap*)player->FindMap())->GetBG();
232 if (!bg || bg->GetStatus() != STATUS_IN_PROGRESS)
233 return;
234
236 for (Battleground::BattlegroundPlayerMap::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
237 {
238 if (player->HasReceivedSpectatorResetFor(itr->first))
239 continue;
240
241 Player* plr = itr->second;
242 player->AddReceivedSpectatorResetFor(itr->first);
243
244 SendCommand_String(player, itr->first, "NME", plr->GetName().c_str());
245 // Xinef: addon compatibility
246 SendCommand_UInt32Value(player, itr->first, "TEM", plr->GetBgTeamId() == TEAM_ALLIANCE ? ALLIANCE : HORDE);
247 SendCommand_UInt32Value(player, itr->first, "CLA", plr->getClass());
248 SendCommand_UInt32Value(player, itr->first, "MHP", plr->GetMaxHealth());
249 SendCommand_UInt32Value(player, itr->first, "CHP", plr->GetHealth());
250 SendCommand_UInt32Value(player, itr->first, "STA", plr->IsAlive() ? 1 : 0);
251 Powers ptype = plr->getPowerType();
252 SendCommand_UInt32Value(player, itr->first, "PWT", ptype);
253 SendCommand_UInt32Value(player, itr->first, "MPW", ptype == POWER_RAGE || ptype == POWER_RUNIC_POWER ? plr->GetMaxPower(ptype) / 10 : plr->GetMaxPower(ptype));
254 SendCommand_UInt32Value(player, itr->first, "CPW", ptype == POWER_RAGE || ptype == POWER_RUNIC_POWER ? plr->GetPower(ptype) / 10 : plr->GetPower(ptype));
255 Pet* pet = plr->GetPet();
256 SendCommand_UInt32Value(player, itr->first, "PHP", pet && pet->GetCreatureTemplate()->family ? (uint32)pet->GetHealthPct() : 0);
257 SendCommand_UInt32Value(player, itr->first, "PET", pet ? pet->GetCreatureTemplate()->family : 0);
258 SendCommand_GUID(player, itr->first, "TRG", plr->GetTarget());
259 SendCommand_UInt32Value(player, itr->first, "RES", 1);
260 SendCommand_UInt32Value(player, itr->first, "CDC", 1);
261 SendCommand_UInt32Value(player, itr->first, "TIM", (bg->GetStartTime() < 46 * MINUTE * IN_MILLISECONDS) ? (46 * MINUTE * IN_MILLISECONDS - bg->GetStartTime()) / IN_MILLISECONDS : 0);
262 // "SPE" not here (only possible to send starting a new cast)
263
264 // send all "CD"
265 SpellCooldowns const& sc = plr->GetSpellCooldownMap();
266 for (SpellCooldowns::const_iterator itrc = sc.begin(); itrc != sc.end(); ++itrc)
267 if (itrc->second.sendToSpectator && itrc->second.maxduration >= SPECTATOR_COOLDOWN_MIN * IN_MILLISECONDS && itrc->second.maxduration <= SPECTATOR_COOLDOWN_MAX * IN_MILLISECONDS)
268 if (uint32 cd = (getMSTimeDiff(getMSTime(), itrc->second.end) / 1000))
269 SendCommand_Cooldown(player, itr->first, "ACD", itrc->first, cd, itrc->second.maxduration / 1000);
270
271 // send all visible "AUR"
272 Unit::VisibleAuraMap const* visibleAuras = plr->GetVisibleAuras();
273 for (Unit::VisibleAuraMap::const_iterator aitr = visibleAuras->begin(); aitr != visibleAuras->end(); ++aitr)
274 {
275 Aura* aura = aitr->second->GetBase();
276 if (ShouldSendAura(aura, aitr->second->GetEffectMask(), plr->GetGUID(), false))
277 SendCommand_Aura(player, itr->first, "AUR", aura->GetCasterGUID(), aura->GetSpellInfo()->Id, aura->GetSpellInfo()->IsPositive(), aura->GetSpellInfo()->Dispel, aura->GetDuration(), aura->GetMaxDuration(), (aura->GetCharges() > 1 ? aura->GetCharges() : aura->GetStackAmount()), false);
278 }
279 }
280}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
constexpr auto MINUTE
Definition: Common.h:47
uint32 getMSTime()
Definition: Timer.h:103
uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
Definition: Timer.h:110
Powers
Definition: SharedDefines.h:268
@ POWER_RAGE
Definition: SharedDefines.h:270
@ POWER_RUNIC_POWER
Definition: SharedDefines.h:275
@ ALLIANCE
Definition: SharedDefines.h:768
@ HORDE
Definition: SharedDefines.h:767
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
std::map< uint32, SpellCooldown > SpellCooldowns
Definition: Player.h:208
#define SPECTATOR_COOLDOWN_MAX
Definition: ArenaSpectator.h:37
#define SPECTATOR_COOLDOWN_MIN
Definition: ArenaSpectator.h:36
@ STATUS_IN_PROGRESS
Definition: Battleground.h:202
AC_GAME_API bool ShouldSendAura(Aura *aura, uint8 effMask, ObjectGuid targetGUID, bool remove)
Definition: ArenaSpectator.cpp:282
void SendCommand_Cooldown(T *o, ObjectGuid targetGUID, const char *prefix, uint32 id, uint32 dur, uint32 maxdur)
Definition: ArenaSpectator.h:89
void SendCommand_Aura(T *o, ObjectGuid targetGUID, const char *prefix, ObjectGuid caster, uint32 id, bool isDebuff, uint32 dispel, int32 dur, int32 maxdur, uint32 stack, bool remove)
Definition: ArenaSpectator.h:102
void SendCommand_String(T *o, ObjectGuid targetGUID, const char *prefix, const char *c)
Definition: ArenaSpectator.h:53
void SendCommand_UInt32Value(T *o, ObjectGuid targetGUID, const char *prefix, uint32 t)
Definition: ArenaSpectator.h:62
void SendCommand_GUID(T *o, ObjectGuid targetGUID, const char *prefix, ObjectGuid t)
Definition: ArenaSpectator.h:71
Definition: Battleground.h:303
std::map< ObjectGuid, Player * > BattlegroundPlayerMap
Definition: Battleground.h:417
uint32 GetStartTime() const
Definition: Battleground.h:334
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:418
BattlegroundStatus GetStatus() const
Definition: Battleground.h:332
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:205
uint32 family
Definition: CreatureData.h:217
bool IsInWorld() const
Definition: Object.h:107
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
Map * FindMap() const
Definition: Object.h:537
std::string const & GetName() const
Definition: Object.h:463
Definition: Pet.h:41
Definition: Player.h:1081
bool HasReceivedSpectatorResetFor(ObjectGuid guid)
Definition: Player.h:2583
Pet * GetPet() const
Definition: Player.cpp:8939
void AddReceivedSpectatorResetFor(ObjectGuid guid)
Definition: Player.h:2585
SpellCooldowns const & GetSpellCooldownMap() const
Definition: Player.h:1779
TeamId GetBgTeamId() const
Definition: Player.h:2278
float GetHealthPct() const
Definition: Unit.h:1031
uint32 GetMaxHealth() const
Definition: Unit.h:1030
uint8 getClass() const
Definition: Unit.h:800
bool IsAlive() const
Definition: Unit.h:1654
std::map< uint8, AuraApplication * > VisibleAuraMap
Definition: Unit.h:652
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1057
uint32 GetHealth() const
Definition: Unit.h:1029
VisibleAuraMap const * GetVisibleAuras()
Definition: Unit.h:1412
Powers getPowerType() const
Definition: Unit.h:1052
uint32 GetPower(Powers power) const
Definition: Unit.h:1056
ObjectGuid GetTarget() const
Definition: Unit.h:818
bool IsBattleArena() const
Definition: Map.h:453
Definition: Map.h:851
Definition: SpellAuras.h:87
int32 GetMaxDuration() const
Definition: SpellAuras.h:129
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:105
int32 GetDuration() const
Definition: SpellAuras.h:133
uint8 GetStackAmount() const
Definition: SpellAuras.h:148
uint8 GetCharges() const
Definition: SpellAuras.h:141
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:100
uint32 Id
Definition: SpellInfo.h:320
uint32 Dispel
Definition: SpellInfo.h:322
bool IsPositive() const
Definition: SpellInfo.cpp:1237

References Player::AddReceivedSpectatorResetFor(), ALLIANCE, SpellInfo::Dispel, CreatureTemplate::family, WorldObject::FindMap(), Player::GetBgTeamId(), Aura::GetCasterGUID(), Aura::GetCharges(), Unit::getClass(), Creature::GetCreatureTemplate(), Aura::GetDuration(), Aura::GetEffectMask(), Object::GetGUID(), Unit::GetHealth(), Unit::GetHealthPct(), Aura::GetMaxDuration(), Unit::GetMaxHealth(), Unit::GetMaxPower(), getMSTime(), getMSTimeDiff(), WorldObject::GetName(), Player::GetPet(), Battleground::GetPlayers(), Unit::GetPower(), Unit::getPowerType(), Player::GetSpellCooldownMap(), Aura::GetSpellInfo(), Aura::GetStackAmount(), Battleground::GetStartTime(), Battleground::GetStatus(), Unit::GetTarget(), Unit::GetVisibleAuras(), Player::HasReceivedSpectatorResetFor(), HORDE, SpellInfo::Id, IN_MILLISECONDS, Unit::IsAlive(), Map::IsBattleArena(), Object::IsInWorld(), SpellInfo::IsPositive(), MINUTE, POWER_RAGE, POWER_RUNIC_POWER, SendCommand_Aura(), SendCommand_Cooldown(), SendCommand_GUID(), SendCommand_String(), SendCommand_UInt32Value(), ShouldSendAura(), SPECTATOR_COOLDOWN_MAX, SPECTATOR_COOLDOWN_MIN, STATUS_IN_PROGRESS, and TEAM_ALLIANCE.

Referenced by Battleground::_ProcessJoin(), WorldSession::HandleMoveWorldportAck(), and spectator_commandscript::HandleSpectatorResetCommand().

◆ HandleSpectatorSpectateCommand()

bool ArenaSpectator::HandleSpectatorSpectateCommand ( ChatHandler handler,
std::string const &  name 
)
29{
30 Player* player = handler->GetSession()->GetPlayer();
31 std::list<std::string> errors;
32
33 if (player->IsSpectator())
34 {
35 if (player->FindMap() && player->FindMap()->IsBattleArena())
36 {
37 HandleSpectatorWatchCommand(handler, name);
38 return true;
39 }
40 handler->PSendSysMessage("You are already spectacting arena.");
41 return true;
42 }
43
44 if (player->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_TELEPORT) && player->GetMapId() == 609)
45 {
46 handler->PSendSysMessage("Death Knights can't spectate before finishing questline.");
47 return true;
48 }
49
51 if (!spectate)
52 {
53 handler->SendSysMessage("Requested player not found.");
54 return true;
55 }
56
57 if (spectate->IsSpectator())
58 {
59 handler->SendSysMessage("Requested player is a spectator.");
60 return true;
61 }
62
63 if (!spectate->FindMap() || !spectate->FindMap()->IsBattleArena())
64 {
65 handler->SendSysMessage("Requested player is not in arena.");
66 return true;
67 }
68
69 BattlegroundMap* bgmap = ((BattlegroundMap*)spectate->FindMap());
70 if (!bgmap->GetBG() || bgmap->GetBG()->GetStatus() == STATUS_WAIT_LEAVE)
71 {
72 handler->SendSysMessage("This arena battle has finished.");
73 return true;
74 }
75
76 if (player->IsBeingTeleported() || !player->IsInWorld())
77 errors.push_back("Can't use while being teleported.");
78
79 if (!player->FindMap() || player->FindMap()->Instanceable())
80 errors.push_back("Can't use while in instance, bg or arena.");
81
82 if (player->GetVehicle())
83 errors.push_back("Can't be on a vehicle.");
84
85 if (player->IsInCombat())
86 errors.push_back("Can't be in combat.");
87
88 if (player->isUsingLfg())
89 errors.push_back("Can't spectate while using LFG system.");
90
91 if (player->InBattlegroundQueue())
92 errors.push_back("Can't be queued for arena or bg.");
93
94 if (player->GetGroup())
95 errors.push_back("Can't be in a group.");
96
98 errors.push_back("Can't be isolated.");
99
100 if (player->m_mover != player)
101 errors.push_back("You must control yourself.");
102
103 if (player->IsInFlight())
104 errors.push_back("Can't be in flight.");
105
106 if (player->IsMounted())
107 errors.push_back("Dismount before spectating.");
108
109 if (!player->IsAlive())
110 errors.push_back("Must be alive.");
111
112 if (!player->m_Controlled.empty())
113 errors.push_back("Can't be controlling creatures.");
114
115 const Unit::VisibleAuraMap* va = player->GetVisibleAuras();
116 for (auto itr = va->begin(); itr != va->end(); ++itr)
117 if (Aura* aura = itr->second->GetBase())
118 if (!itr->second->IsPositive() && !aura->IsPermanent() && aura->GetDuration() < HOUR * IN_MILLISECONDS)
119 {
120 switch (aura->GetSpellInfo()->Id)
121 {
124 case 26013: // bg deserter
125 case 57724: // sated
126 case 57723: // exhaustion
127 case 25771: // forbearance
128 case 15007: // resurrection sickness
129 case 24755: // Tricked or Treated (z eventu)
130 continue;
131 }
132
133 errors.push_back("Can't have negative auras.");
134 break;
135 }
136
137 if (uint32 inviteInstanceId = player->GetPendingSpectatorInviteInstanceId())
138 {
139 if (Battleground* tbg = sBattlegroundMgr->GetBattleground(inviteInstanceId, BATTLEGROUND_TYPE_NONE))
140 tbg->RemoveToBeTeleported(player->GetGUID());
142 }
143
144 bool bgPreparation = false;
145 if ((!handler->GetSession()->GetSecurity() && bgmap->GetBG()->GetStatus() != STATUS_IN_PROGRESS) ||
146 (handler->GetSession()->GetSecurity() && bgmap->GetBG()->GetStatus() != STATUS_WAIT_JOIN && bgmap->GetBG()->GetStatus() != STATUS_IN_PROGRESS))
147 {
148 bgPreparation = true;
149 handler->SendSysMessage("Arena is not in progress yet. You will be invited as soon as it starts.");
150 bgmap->GetBG()->AddToBeTeleported(player->GetGUID(), spectate->GetGUID());
152 }
153
154 if (!errors.empty())
155 {
156 handler->PSendSysMessage("To spectate, please fix the following:");
157 for (std::list<std::string>::const_iterator itr = errors.begin(); itr != errors.end(); ++itr)
158 handler->PSendSysMessage("- {}", (*itr));
159
160 return true;
161 }
162
163 if (bgPreparation)
164 return true;
165
166 float z = spectate->GetMapId() == 618 ? std::max(28.27f, spectate->GetPositionZ() + 0.25f) : spectate->GetPositionZ() + 0.25f;
167
168 player->SetPendingSpectatorForBG(spectate->GetBattlegroundId());
170 player->SetEntryPoint();
171 player->TeleportTo(spectate->GetMapId(), spectate->GetPositionX(), spectate->GetPositionY(), z, spectate->GetOrientation(), TELE_TO_GM_MODE);
172
173 return true;
174}
constexpr auto HOUR
Definition: Common.h:48
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:146
@ BATTLEGROUND_TYPE_NONE
Definition: SharedDefines.h:3480
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:176
@ TELE_TO_GM_MODE
Definition: Player.h:826
@ CLASS_CONTEXT_TELEPORT
Definition: UnitDefines.h:207
@ UNIT_STATE_ISOLATED
Definition: UnitDefines.h:162
@ STATUS_WAIT_LEAVE
Definition: Battleground.h:203
@ STATUS_WAIT_JOIN
Definition: Battleground.h:201
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:186
AC_GAME_API bool HandleSpectatorWatchCommand(ChatHandler *handler, std::string const &name)
Definition: ArenaSpectator.cpp:176
@ LFG_SPELL_DUNGEON_COOLDOWN
Definition: LFGMgr.h:52
@ LFG_SPELL_DUNGEON_DESERTER
Definition: LFGMgr.h:53
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:271
void AddToBeTeleported(ObjectGuid spectator, ObjectGuid participant)
Definition: Battleground.h:409
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
WorldSession * GetSession()
Definition: Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
float GetPositionZ() const
Definition: Position.h:118
float GetOrientation() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:116
float GetPositionY() const
Definition: Position.h:117
uint32 GetMapId() const
Definition: Position.h:275
BattlegroundTypeId GetBattlegroundTypeId() const
Definition: Player.h:2255
bool isUsingLfg()
Definition: Player.cpp:13103
SafeUnitPointer m_mover
Definition: Player.h:2333
void SetEntryPoint()
Definition: Player.cpp:11316
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition: Player.cpp:12237
void SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
Definition: Player.cpp:12338
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition: Player.cpp:1284
Group * GetGroup()
Definition: Player.h:2468
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
void SetPendingSpectatorInviteInstanceId(uint32 bgInstanceId)
Definition: Player.h:2581
uint32 GetBattlegroundId() const
Definition: Player.h:2254
bool IsSpectator() const
Definition: Player.h:2576
void SetPendingSpectatorForBG(uint32 bgInstanceId)
Definition: Player.h:2579
uint32 GetPendingSpectatorInviteInstanceId() const
Definition: Player.h:2582
bool IsBeingTeleported() const
Definition: Player.h:2090
Vehicle * GetVehicle() const
Definition: Unit.h:1786
ControlSet m_Controlled
Definition: Unit.h:1940
bool IsInFlight() const
Definition: Unit.h:1572
bool IsMounted() const
Definition: Unit.h:1747
bool HasUnitState(const uint32 f) const
Definition: Unit.h:701
bool IsInCombat() const
Definition: Unit.h:884
bool Instanceable() const
Definition: Map.h:445
Battleground * GetBG()
Definition: Map.h:864
AccountTypes GetSecurity() const
Definition: WorldSession.h:359
Player * GetPlayer() const
Definition: WorldSession.h:362

References Battleground::AddToBeTeleported(), BATTLEGROUND_TYPE_NONE, CLASS_CONTEXT_TELEPORT, CLASS_DEATH_KNIGHT, WorldObject::FindMap(), ObjectAccessor::FindPlayerByName(), Player::GetBattlegroundId(), Player::GetBattlegroundTypeId(), BattlegroundMap::GetBG(), Player::GetGroup(), Object::GetGUID(), WorldLocation::GetMapId(), Position::GetOrientation(), Player::GetPendingSpectatorInviteInstanceId(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), WorldSession::GetSecurity(), ChatHandler::GetSession(), Battleground::GetStatus(), Unit::GetVehicle(), Unit::GetVisibleAuras(), HandleSpectatorWatchCommand(), Unit::HasUnitState(), HOUR, IN_MILLISECONDS, Player::InBattlegroundQueue(), Map::Instanceable(), Unit::IsAlive(), Map::IsBattleArena(), Player::IsBeingTeleported(), Player::IsClass(), Unit::IsInCombat(), Unit::IsInFlight(), Object::IsInWorld(), Unit::IsMounted(), Player::IsSpectator(), Player::isUsingLfg(), lfg::LFG_SPELL_DUNGEON_COOLDOWN, lfg::LFG_SPELL_DUNGEON_DESERTER, Unit::m_Controlled, Player::m_mover, PLAYER_MAX_BATTLEGROUND_QUEUES, ChatHandler::PSendSysMessage(), sBattlegroundMgr, ChatHandler::SendSysMessage(), Player::SetBattlegroundId(), Player::SetEntryPoint(), Player::SetPendingSpectatorForBG(), Player::SetPendingSpectatorInviteInstanceId(), STATUS_IN_PROGRESS, STATUS_WAIT_JOIN, STATUS_WAIT_LEAVE, TEAM_NEUTRAL, TELE_TO_GM_MODE, Player::TeleportTo(), and UNIT_STATE_ISOLATED.

Referenced by spectator_commandscript::HandleSpectatorSpectateCommand(), and WorldSession::HandleSummonResponseOpcode().

◆ HandleSpectatorWatchCommand()

bool ArenaSpectator::HandleSpectatorWatchCommand ( ChatHandler handler,
std::string const &  name 
)
177{
178 Player* player = handler->GetSession()->GetPlayer();
179 if (!player->IsSpectator())
180 return true;
181
182 if (!player->FindMap() || !player->FindMap()->IsBattleArena())
183 return true;
184
185 Battleground* bg = ((BattlegroundMap*)player->FindMap())->GetBG();
186 if (!bg || bg->GetStatus() != STATUS_IN_PROGRESS)
187 return true;
188
190 if (!spectate || !spectate->IsAlive() || spectate->IsSpectator() || spectate->GetGUID() == player->GetGUID() || !spectate->IsInWorld() || !spectate->FindMap() || spectate->IsBeingTeleported() || spectate->FindMap() != player->FindMap() || !bg->IsPlayerInBattleground(spectate->GetGUID()))
191 return true;
192
193 if (WorldObject* o = player->GetViewpoint())
194 if (Unit* u = o->ToUnit())
195 {
196 u->RemoveAurasByType(SPELL_AURA_BIND_SIGHT, player->GetGUID());
198
199 if (u->GetGUID() == spectate->GetGUID())
200 return true;
201 }
202
203 if (player->GetUInt64Value(PLAYER_FARSIGHT) || player->m_seer != player) // pussywizard: below this point we must not have a viewpoint!
204 return true;
205
206 if (player->HaveAtClient(spectate))
207 player->CastSpell(spectate, SPECTATOR_SPELL_BINDSIGHT, true);
208
209 return true;
210}
@ EFFECT_1
Definition: SharedDefines.h:32
@ SPELL_AURA_BIND_SIGHT
Definition: SpellAuraDefines.h:64
@ PLAYER_FARSIGHT
Definition: UpdateFields.h:334
#define SPECTATOR_SPELL_BINDSIGHT
Definition: ArenaSpectator.h:38
bool IsPlayerInBattleground(ObjectGuid guid) const
Definition: Battleground.cpp:1759
uint64 GetUInt64Value(uint16 index) const
Definition: Object.cpp:311
Unit * ToUnit()
Definition: Object.h:209
Definition: Object.h:410
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:11444
WorldObject * m_seer
Definition: Player.h:2334
WorldObject * GetViewpoint() const
Definition: Player.cpp:13247
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
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4909

References Unit::CastSpell(), EFFECT_1, WorldObject::FindMap(), ObjectAccessor::FindPlayerByName(), Object::GetGUID(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Battleground::GetStatus(), Object::GetUInt64Value(), Player::GetViewpoint(), Player::HaveAtClient(), Unit::IsAlive(), Map::IsBattleArena(), Player::IsBeingTeleported(), Object::IsInWorld(), Battleground::IsPlayerInBattleground(), Player::IsSpectator(), Player::m_seer, PLAYER_FARSIGHT, Unit::RemoveAurasDueToSpell(), SPECTATOR_SPELL_BINDSIGHT, SPELL_AURA_BIND_SIGHT, STATUS_IN_PROGRESS, and Object::ToUnit().

Referenced by HandleSpectatorSpectateCommand(), and spectator_commandscript::HandleSpectatorWatchCommand().

◆ SendCommand()

template<class T , typename Format , typename... Args>
void ArenaSpectator::SendCommand ( T *  o,
Format &&  fmt,
Args &&...  args 
)
inline
48 {
49 SendPacketTo(o, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
50 }
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
AC_GAME_API void SendPacketTo(const T *object, std::string &&message)

References SendPacketTo(), and Acore::StringFormat().

Referenced by WorldSession::HandleMoveWorldportAck(), spectator_commandscript::HandleSpectatorVersionCommand(), SendCommand_Aura(), SendCommand_Cooldown(), SendCommand_GUID(), SendCommand_Spell(), SendCommand_String(), and SendCommand_UInt32Value().

◆ SendCommand_Aura()

template<class T >
void ArenaSpectator::SendCommand_Aura ( T *  o,
ObjectGuid  targetGUID,
const char *  prefix,
ObjectGuid  caster,
uint32  id,
bool  isDebuff,
uint32  dispel,
int32  dur,
int32  maxdur,
uint32  stack,
bool  remove 
)
inline
103 {
104 if (!targetGUID.IsPlayer())
105 return;
106
107 SendCommand(o, "%s0x%016llX;%s=%u,%u,%i,%i,%u,%u,%u,0x%016llX;", SPECTATOR_ADDON_PREFIX, targetGUID.GetRawValue(), prefix, remove ? 1 : 0, stack, dur, maxdur, id, dispel, isDebuff ? 1 : 0, caster.GetRawValue());
108 }
#define SPECTATOR_ADDON_PREFIX
Definition: ArenaSpectator.h:35
void SendCommand(T *o, Format &&fmt, Args &&... args)
Definition: ArenaSpectator.h:47
uint64 GetRawValue() const
Definition: ObjectGuid.h:142
bool IsPlayer() const
Definition: ObjectGuid.h:168

References ObjectGuid::GetRawValue(), ObjectGuid::IsPlayer(), SendCommand(), and SPECTATOR_ADDON_PREFIX.

Referenced by AuraApplication::ClientUpdate(), and HandleResetCommand().

◆ SendCommand_Cooldown()

template<class T >
void ArenaSpectator::SendCommand_Cooldown ( T *  o,
ObjectGuid  targetGUID,
const char *  prefix,
uint32  id,
uint32  dur,
uint32  maxdur 
)
inline
90 {
91 if (!targetGUID.IsPlayer())
92 return;
93
94 if (SpellInfo const* si = sSpellMgr->GetSpellInfo(id))
95 if (si->SpellIconID == 1)
96 return;
97
98 SendCommand(o, "%s0x%016llX;%s=%u,%u,%u;", SPECTATOR_ADDON_PREFIX, targetGUID.GetRawValue(), prefix, id, dur, maxdur);
99 }
#define sSpellMgr
Definition: SpellMgr.h:825
Definition: SpellInfo.h:316

References ObjectGuid::GetRawValue(), ObjectGuid::IsPlayer(), SendCommand(), SPECTATOR_ADDON_PREFIX, and sSpellMgr.

Referenced by Player::_AddSpellCooldown(), and HandleResetCommand().

◆ SendCommand_GUID()

template<class T >
void ArenaSpectator::SendCommand_GUID ( T *  o,
ObjectGuid  targetGUID,
const char *  prefix,
ObjectGuid  t 
)
inline
72 {
73 if (!targetGUID.IsPlayer())
74 return;
75
76 SendCommand(o, "%s0x%016llX;%s=0x%016llX;", SPECTATOR_ADDON_PREFIX, targetGUID.GetRawValue(), prefix, t.GetRawValue());
77 }

References ObjectGuid::GetRawValue(), ObjectGuid::IsPlayer(), SendCommand(), and SPECTATOR_ADDON_PREFIX.

Referenced by HandleResetCommand(), and Player::SetSelection().

◆ SendCommand_Spell()

template<class T >
void ArenaSpectator::SendCommand_Spell ( T *  o,
ObjectGuid  targetGUID,
const char *  prefix,
uint32  id,
int32  casttime 
)
inline
81 {
82 if (!targetGUID.IsPlayer())
83 return;
84
85 SendCommand(o, "%s0x%016llX;%s=%u,%i;", SPECTATOR_ADDON_PREFIX, targetGUID.GetRawValue(), prefix, id, casttime);
86 }

References ObjectGuid::GetRawValue(), ObjectGuid::IsPlayer(), SendCommand(), and SPECTATOR_ADDON_PREFIX.

Referenced by Spell::cancel(), Spell::SendChannelStart(), and Spell::SendSpellStart().

◆ SendCommand_String()

template<class T >
void ArenaSpectator::SendCommand_String ( T *  o,
ObjectGuid  targetGUID,
const char *  prefix,
const char *  c 
)
inline
54 {
55 if (!targetGUID.IsPlayer())
56 return;
57
58 SendCommand(o, "%s0x%016llX;%s=%s;", SPECTATOR_ADDON_PREFIX, targetGUID.GetRawValue(), prefix, c);
59 }

References ObjectGuid::GetRawValue(), ObjectGuid::IsPlayer(), SendCommand(), and SPECTATOR_ADDON_PREFIX.

Referenced by HandleResetCommand().

◆ SendCommand_UInt32Value()

template<class T >
void ArenaSpectator::SendCommand_UInt32Value ( T *  o,
ObjectGuid  targetGUID,
const char *  prefix,
uint32  t 
)
inline

◆ SendPacketTo()

template<class T >
AC_GAME_API void ArenaSpectator::SendPacketTo ( const T *  object,
std::string &&  message 
)

Referenced by SendCommand().

◆ ShouldSendAura()

bool ArenaSpectator::ShouldSendAura ( Aura aura,
uint8  effMask,
ObjectGuid  targetGUID,
bool  remove 
)
283{
285 return false;
286
288 return true;
289
290 for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i)
291 {
292 if (effMask & (1 << i))
293 {
294 AuraType at = aura->GetEffect(i)->GetAuraType();
295 if ((aura->GetEffect(i)->GetAmount() && (aura->GetSpellInfo()->IsPositive() || targetGUID != aura->GetCasterGUID())) ||
297 return true;
298 }
299 }
300 return false;
301}
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1636
@ EFFECT_0
Definition: SharedDefines.h:31
@ SPELL_ATTR1_NO_AURA_ICON
Definition: SharedDefines.h:447
@ SPELLFAMILY_GENERIC
Definition: SharedDefines.h:3528
@ SPELL_ATTR0_CU_DONT_BREAK_STEALTH
Definition: SpellInfo.h:182
AuraType
Definition: SpellAuraDefines.h:62
@ SPELL_AURA_DISPEL_IMMUNITY
Definition: SpellAuraDefines.h:104
@ SPELL_AURA_SCHOOL_IMMUNITY
Definition: SpellAuraDefines.h:102
@ SPELL_AURA_MECHANIC_IMMUNITY
Definition: SpellAuraDefines.h:140
@ SPELL_AURA_EFFECT_IMMUNITY
Definition: SpellAuraDefines.h:100
@ SPELL_AURA_STATE_IMMUNITY
Definition: SpellAuraDefines.h:101
AuraType GetAuraType() const
Definition: SpellAuraEffects.cpp:447
int32 GetAmount() const
Definition: SpellAuraEffects.h:64
AuraEffect * GetEffect(uint8 effIndex) const
Definition: SpellAuras.h:175
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:415
uint32 SpellIconID
Definition: SpellInfo.h:380
uint32 SpellFamilyName
Definition: SpellInfo.h:387

References EFFECT_0, AuraEffect::GetAmount(), AuraEffect::GetAuraType(), Aura::GetCasterGUID(), Aura::GetEffect(), Aura::GetSpellInfo(), SpellInfo::HasAttribute(), SpellInfo::IsPositive(), MAX_SPELL_EFFECTS, SPELL_ATTR0_CU_DONT_BREAK_STEALTH, SPELL_ATTR1_NO_AURA_ICON, SPELL_AURA_DISPEL_IMMUNITY, SPELL_AURA_EFFECT_IMMUNITY, SPELL_AURA_MECHANIC_IMMUNITY, SPELL_AURA_SCHOOL_IMMUNITY, SPELL_AURA_STATE_IMMUNITY, SPELLFAMILY_GENERIC, SpellInfo::SpellFamilyName, and SpellInfo::SpellIconID.

Referenced by AuraApplication::ClientUpdate(), and HandleResetCommand().