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 
)
214{
215 size_t len = message.length();
216 data.Initialize(SMSG_MESSAGECHAT, 1 + 4 + 8 + 4 + 8 + 4 + 1 + len + 1);
217 data << uint8(CHAT_MSG_WHISPER);
218 data << uint32(LANG_ADDON);
219 data << uint64(0);
220 data << uint32(0);
221 data << uint64(0);
222 data << uint32(len + 1);
223 data << message;
224 data << uint8(0);
225}
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
std::uint64_t uint64
Definition: Define.h:107
@ CHAT_MSG_WHISPER
Definition: SharedDefines.h:3131
@ LANG_ADDON
Definition: SharedDefines.h:725
@ SMSG_MESSAGECHAT
Definition: Opcodes.h:180
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:69

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

◆ HandleResetCommand()

void ArenaSpectator::HandleResetCommand ( Player player)
228{
229 if (!player->FindMap() || !player->IsInWorld() || !player->FindMap()->IsBattleArena())
230 return;
231
232 Battleground* bg = ((BattlegroundMap*)player->FindMap())->GetBG();
233 if (!bg || bg->GetStatus() != STATUS_IN_PROGRESS)
234 return;
235
237 for (Battleground::BattlegroundPlayerMap::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
238 {
239 if (player->HasReceivedSpectatorResetFor(itr->first))
240 continue;
241
242 Player* plr = itr->second;
243 player->AddReceivedSpectatorResetFor(itr->first);
244
245 SendCommand_String(player, itr->first, "NME", plr->GetName().c_str());
246 // Xinef: addon compatibility
247 SendCommand_UInt32Value(player, itr->first, "TEM", plr->GetBgTeamId() == TEAM_ALLIANCE ? ALLIANCE : HORDE);
248 SendCommand_UInt32Value(player, itr->first, "CLA", plr->getClass());
249 SendCommand_UInt32Value(player, itr->first, "MHP", plr->GetMaxHealth());
250 SendCommand_UInt32Value(player, itr->first, "CHP", plr->GetHealth());
251 SendCommand_UInt32Value(player, itr->first, "STA", plr->IsAlive() ? 1 : 0);
252 Powers ptype = plr->getPowerType();
253 SendCommand_UInt32Value(player, itr->first, "PWT", ptype);
254 SendCommand_UInt32Value(player, itr->first, "MPW", ptype == POWER_RAGE || ptype == POWER_RUNIC_POWER ? plr->GetMaxPower(ptype) / 10 : plr->GetMaxPower(ptype));
255 SendCommand_UInt32Value(player, itr->first, "CPW", ptype == POWER_RAGE || ptype == POWER_RUNIC_POWER ? plr->GetPower(ptype) / 10 : plr->GetPower(ptype));
256 Pet* pet = plr->GetPet();
257 SendCommand_UInt32Value(player, itr->first, "PHP", pet && pet->GetCreatureTemplate()->family ? (uint32)pet->GetHealthPct() : 0);
258 SendCommand_UInt32Value(player, itr->first, "PET", pet ? pet->GetCreatureTemplate()->family : 0);
259 SendCommand_GUID(player, itr->first, "TRG", plr->GetTarget());
260 SendCommand_UInt32Value(player, itr->first, "RES", 1);
261 SendCommand_UInt32Value(player, itr->first, "CDC", 1);
262 SendCommand_UInt32Value(player, itr->first, "TIM", (bg->GetStartTime() < 46 * MINUTE * IN_MILLISECONDS) ? (46 * MINUTE * IN_MILLISECONDS - bg->GetStartTime()) / IN_MILLISECONDS : 0);
263 // "SPE" not here (only possible to send starting a new cast)
264
265 // send all "CD"
266 SpellCooldowns const& sc = plr->GetSpellCooldownMap();
267 for (SpellCooldowns::const_iterator itrc = sc.begin(); itrc != sc.end(); ++itrc)
268 if (itrc->second.sendToSpectator && itrc->second.maxduration >= SPECTATOR_COOLDOWN_MIN * IN_MILLISECONDS && itrc->second.maxduration <= SPECTATOR_COOLDOWN_MAX * IN_MILLISECONDS)
269 if (uint32 cd = (getMSTimeDiff(getMSTime(), itrc->second.end) / 1000))
270 SendCommand_Cooldown(player, itr->first, "ACD", itrc->first, cd, itrc->second.maxduration / 1000);
271
272 // send all visible "AUR"
273 Unit::VisibleAuraMap const* visibleAuras = plr->GetVisibleAuras();
274 for (Unit::VisibleAuraMap::const_iterator aitr = visibleAuras->begin(); aitr != visibleAuras->end(); ++aitr)
275 {
276 Aura* aura = aitr->second->GetBase();
277 if (ShouldSendAura(aura, aitr->second->GetEffectMask(), plr->GetGUID(), false))
278 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);
279 }
280 }
281}
constexpr auto IN_MILLISECONDS
Definition: Common.h:62
constexpr auto MINUTE
Definition: Common.h:56
uint32 getMSTime()
Definition: Timer.h:103
uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
Definition: Timer.h:110
#define SPECTATOR_COOLDOWN_MAX
Definition: ArenaSpectator.h:37
#define SPECTATOR_COOLDOWN_MIN
Definition: ArenaSpectator.h:36
@ STATUS_IN_PROGRESS
Definition: Battleground.h:197
std::map< uint32, SpellCooldown > SpellCooldowns
Definition: Player.h:209
Powers
Definition: SharedDefines.h:240
@ POWER_RAGE
Definition: SharedDefines.h:242
@ POWER_RUNIC_POWER
Definition: SharedDefines.h:247
@ TEAM_ALLIANCE
Definition: SharedDefines.h:732
@ ALLIANCE
Definition: SharedDefines.h:740
@ HORDE
Definition: SharedDefines.h:739
AC_GAME_API bool ShouldSendAura(Aura *aura, uint8 effMask, ObjectGuid targetGUID, bool remove)
Definition: ArenaSpectator.cpp:283
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:293
std::map< ObjectGuid, Player * > BattlegroundPlayerMap
Definition: Battleground.h:392
uint32 GetStartTime() const
Definition: Battleground.h:324
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:393
BattlegroundStatus GetStatus() const
Definition: Battleground.h:322
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:197
uint32 family
Definition: CreatureData.h:210
bool IsInWorld() const
Definition: Object.h:101
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Map * FindMap() const
Definition: Object.h:518
std::string const & GetName() const
Definition: Object.h:446
Definition: Pet.h:40
Definition: Player.h:1056
bool HasReceivedSpectatorResetFor(ObjectGuid guid)
Definition: Player.h:2540
Pet * GetPet() const
Definition: Player.cpp:8808
void AddReceivedSpectatorResetFor(ObjectGuid guid)
Definition: Player.h:2542
SpellCooldowns const & GetSpellCooldownMap() const
Definition: Player.h:1739
TeamId GetBgTeamId() const
Definition: Player.h:2237
float GetHealthPct() const
Definition: Unit.h:1460
uint32 GetMaxHealth() const
Definition: Unit.h:1453
uint8 getClass() const
Definition: Unit.h:1438
bool IsAlive() const
Definition: Unit.h:1820
std::map< uint8, AuraApplication * > VisibleAuraMap
Definition: Unit.h:1324
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1474
uint32 GetHealth() const
Definition: Unit.h:1452
VisibleAuraMap const * GetVisibleAuras()
Definition: Unit.h:2163
Powers getPowerType() const
Definition: Unit.h:1471
uint32 GetPower(Powers power) const
Definition: Unit.h:1473
ObjectGuid GetTarget() const
Definition: Unit.h:2445
bool IsBattleArena() const
Definition: Map.h:454
Definition: Map.h:847
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:318
uint32 Dispel
Definition: SpellInfo.h:320
bool IsPositive() const
Definition: SpellInfo.cpp:1221

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 
)
30{
31 Player* player = handler->GetSession()->GetPlayer();
32 std::list<std::string> errors;
33
34 if (player->IsSpectator())
35 {
36 if (player->FindMap() && player->FindMap()->IsBattleArena())
37 {
38 HandleSpectatorWatchCommand(handler, name);
39 return true;
40 }
41 handler->PSendSysMessage("You are already spectacting arena.");
42 return true;
43 }
44
45 if (player->getClass() == CLASS_DEATH_KNIGHT && player->GetMapId() == 609)
46 {
47 handler->PSendSysMessage("Death Knights can't spectate before finishing questline.");
48 return true;
49 }
50
52 if (!spectate)
53 {
54 handler->SendSysMessage("Requested player not found.");
55 return true;
56 }
57
58 if (spectate->IsSpectator())
59 {
60 handler->SendSysMessage("Requested player is a spectator.");
61 return true;
62 }
63
64 if (!spectate->FindMap() || !spectate->FindMap()->IsBattleArena())
65 {
66 handler->SendSysMessage("Requested player is not in arena.");
67 return true;
68 }
69
70 BattlegroundMap* bgmap = ((BattlegroundMap*)spectate->FindMap());
71 if (!bgmap->GetBG() || bgmap->GetBG()->GetStatus() == STATUS_WAIT_LEAVE)
72 {
73 handler->SendSysMessage("This arena battle has finished.");
74 return true;
75 }
76
77 if (player->IsBeingTeleported() || !player->IsInWorld())
78 errors.push_back("Can't use while being teleported.");
79
80 if (!player->FindMap() || player->FindMap()->Instanceable())
81 errors.push_back("Can't use while in instance, bg or arena.");
82
83 if (player->GetVehicle())
84 errors.push_back("Can't be on a vehicle.");
85
86 if (player->IsInCombat())
87 errors.push_back("Can't be in combat.");
88
89 if (player->isUsingLfg())
90 errors.push_back("Can't spectate while using LFG system.");
91
92 if (player->InBattlegroundQueue())
93 errors.push_back("Can't be queued for arena or bg.");
94
95 if (player->GetGroup())
96 errors.push_back("Can't be in a group.");
97
99 errors.push_back("Can't be isolated.");
100
101 if (player->m_mover != player)
102 errors.push_back("You must control yourself.");
103
104 if (player->IsInFlight())
105 errors.push_back("Can't be in flight.");
106
107 if (player->IsMounted())
108 errors.push_back("Dismount before spectating.");
109
110 if (!player->IsAlive())
111 errors.push_back("Must be alive.");
112
113 if (!player->m_Controlled.empty())
114 errors.push_back("Can't be controlling creatures.");
115
116 const Unit::VisibleAuraMap* va = player->GetVisibleAuras();
117 for (auto itr = va->begin(); itr != va->end(); ++itr)
118 if (Aura* aura = itr->second->GetBase())
119 if (!itr->second->IsPositive() && !aura->IsPermanent() && aura->GetDuration() < HOUR * IN_MILLISECONDS)
120 {
121 switch (aura->GetSpellInfo()->Id)
122 {
125 case 26013: // bg deserter
126 case 57724: // sated
127 case 57723: // exhaustion
128 case 25771: // forbearance
129 case 15007: // resurrection sickness
130 case 24755: // Tricked or Treated (z eventu)
131 continue;
132 }
133
134 errors.push_back("Can't have negative auras.");
135 break;
136 }
137
138 if (uint32 inviteInstanceId = player->GetPendingSpectatorInviteInstanceId())
139 {
140 if (Battleground* tbg = sBattlegroundMgr->GetBattleground(inviteInstanceId, BATTLEGROUND_TYPE_NONE))
141 tbg->RemoveToBeTeleported(player->GetGUID());
143 }
144
145 bool bgPreparation = false;
146 if ((!handler->GetSession()->GetSecurity() && bgmap->GetBG()->GetStatus() != STATUS_IN_PROGRESS) ||
147 (handler->GetSession()->GetSecurity() && bgmap->GetBG()->GetStatus() != STATUS_WAIT_JOIN && bgmap->GetBG()->GetStatus() != STATUS_IN_PROGRESS))
148 {
149 bgPreparation = true;
150 handler->SendSysMessage("Arena is not in progress yet. You will be invited as soon as it starts.");
151 bgmap->GetBG()->AddToBeTeleported(player->GetGUID(), spectate->GetGUID());
153 }
154
155 if (!errors.empty())
156 {
157 handler->PSendSysMessage("To spectate, please fix the following:");
158 for (std::list<std::string>::const_iterator itr = errors.begin(); itr != errors.end(); ++itr)
159 handler->PSendSysMessage("- %s", (*itr).c_str());
160
161 return true;
162 }
163
164 if (bgPreparation)
165 return true;
166
167 float z = spectate->GetMapId() == 618 ? std::max(28.27f, spectate->GetPositionZ() + 0.25f) : spectate->GetPositionZ() + 0.25f;
168
169 player->SetPendingSpectatorForBG(spectate->GetBattlegroundId());
171 player->SetEntryPoint();
172 player->TeleportTo(spectate->GetMapId(), spectate->GetPositionX(), spectate->GetPositionY(), z, spectate->GetOrientation(), TELE_TO_GM_MODE);
173
174 return true;
175}
constexpr auto HOUR
Definition: Common.h:57
@ STATUS_WAIT_LEAVE
Definition: Battleground.h:198
@ STATUS_WAIT_JOIN
Definition: Battleground.h:196
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:188
@ TELE_TO_GM_MODE
Definition: Player.h:814
@ UNIT_STATE_ISOLATED
Definition: Unit.h:338
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:118
@ BATTLEGROUND_TYPE_NONE
Definition: SharedDefines.h:3452
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:148
AC_GAME_API bool HandleSpectatorWatchCommand(ChatHandler *handler, std::string const &name)
Definition: ArenaSpectator.cpp:177
@ 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:276
void AddToBeTeleported(ObjectGuid spectator, ObjectGuid participant)
Definition: Battleground.h:384
WorldSession * GetSession()
Definition: Chat.h:122
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
float GetPositionZ() const
Definition: Position.h:119
float GetOrientation() const
Definition: Position.h:120
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
uint32 GetMapId() const
Definition: Position.h:276
BattlegroundTypeId GetBattlegroundTypeId() const
Definition: Player.h:2214
bool isUsingLfg()
Definition: Player.cpp:12973
SafeUnitPointer m_mover
Definition: Player.h:2292
void SetEntryPoint()
Definition: Player.cpp:11189
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition: Player.cpp:12115
void SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
Definition: Player.cpp:12216
Group * GetGroup()
Definition: Player.h:2428
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
void SetPendingSpectatorInviteInstanceId(uint32 bgInstanceId)
Definition: Player.h:2538
uint32 GetBattlegroundId() const
Definition: Player.h:2213
bool IsSpectator() const
Definition: Player.h:2533
void SetPendingSpectatorForBG(uint32 bgInstanceId)
Definition: Player.h:2536
uint32 GetPendingSpectatorInviteInstanceId() const
Definition: Player.h:2539
bool IsBeingTeleported() const
Definition: Player.h:2051
Vehicle * GetVehicle() const
Definition: Unit.h:2366
ControlSet m_Controlled
Definition: Unit.h:1879
bool IsInFlight() const
Definition: Unit.h:1688
bool IsMounted() const
Definition: Unit.h:1554
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1410
bool IsInCombat() const
Definition: Unit.h:1700
bool Instanceable() const
Definition: Map.h:446
Battleground * GetBG()
Definition: Map.h:860
AccountTypes GetSecurity() const
Definition: WorldSession.h:359
Player * GetPlayer() const
Definition: WorldSession.h:362

References Battleground::AddToBeTeleported(), BATTLEGROUND_TYPE_NONE, CLASS_DEATH_KNIGHT, WorldObject::FindMap(), ObjectAccessor::FindPlayerByName(), Player::GetBattlegroundId(), Player::GetBattlegroundTypeId(), BattlegroundMap::GetBG(), Unit::getClass(), 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(), 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 
)
178{
179 Player* player = handler->GetSession()->GetPlayer();
180 if (!player->IsSpectator())
181 return true;
182
183 if (!player->FindMap() || !player->FindMap()->IsBattleArena())
184 return true;
185
186 Battleground* bg = ((BattlegroundMap*)player->FindMap())->GetBG();
187 if (!bg || bg->GetStatus() != STATUS_IN_PROGRESS)
188 return true;
189
191 if (!spectate || !spectate->IsAlive() || spectate->IsSpectator() || spectate->GetGUID() == player->GetGUID() || !spectate->IsInWorld() || !spectate->FindMap() || spectate->IsBeingTeleported() || spectate->FindMap() != player->FindMap() || !bg->IsPlayerInBattleground(spectate->GetGUID()))
192 return true;
193
194 if (WorldObject* o = player->GetViewpoint())
195 if (Unit* u = o->ToUnit())
196 {
197 u->RemoveAurasByType(SPELL_AURA_BIND_SIGHT, player->GetGUID());
199
200 if (u->GetGUID() == spectate->GetGUID())
201 return true;
202 }
203
204 if (player->GetUInt64Value(PLAYER_FARSIGHT) || player->m_seer != player) // pussywizard: below this point we must not have a viewpoint!
205 return true;
206
207 if (player->HaveAtClient(spectate))
208 player->CastSpell(spectate, SPECTATOR_SPELL_BINDSIGHT, true);
209
210 return true;
211}
#define SPECTATOR_SPELL_BINDSIGHT
Definition: ArenaSpectator.h:38
@ PLAYER_FARSIGHT
Definition: UpdateFields.h:334
@ SPELL_AURA_BIND_SIGHT
Definition: SpellAuraDefines.h:64
@ EFFECT_1
Definition: SharedDefines.h:31
bool IsPlayerInBattleground(ObjectGuid guid) const
Definition: Battleground.cpp:1778
uint64 GetUInt64Value(uint16 index) const
Definition: Object.cpp:311
Unit * ToUnit()
Definition: Object.h:200
Definition: Object.h:393
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:11316
WorldObject * m_seer
Definition: Player.h:2293
WorldObject * GetViewpoint() const
Definition: Player.cpp:13117
Definition: Unit.h:1302
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
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4845

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(Format &&fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:29
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:144
bool IsPlayer() const
Definition: ObjectGuid.h:170

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

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 
)
284{
286 return false;
287
289 return true;
290
291 for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i)
292 {
293 if (effMask & (1 << i))
294 {
295 AuraType at = aura->GetEffect(i)->GetAuraType();
296 if ((aura->GetEffect(i)->GetAmount() && (aura->GetSpellInfo()->IsPositive() || targetGUID != aura->GetCasterGUID())) ||
298 return true;
299 }
300 }
301 return false;
302}
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
@ SPELL_ATTR0_CU_DONT_BREAK_STEALTH
Definition: SpellInfo.h:182
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1635
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_ATTR1_NO_AURA_ICON
Definition: SharedDefines.h:419
@ SPELLFAMILY_GENERIC
Definition: SharedDefines.h:3500
AuraType GetAuraType() const
Definition: SpellAuraEffects.cpp:447
int32 GetAmount() const
Definition: SpellAuraEffects.h:63
AuraEffect * GetEffect(uint8 effIndex) const
Definition: SpellAuras.h:175
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:412
uint32 SpellIconID
Definition: SpellInfo.h:378
uint32 SpellFamilyName
Definition: SpellInfo.h:385

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