Skip to content

Instantly share code, notes, and snippets.

@walkline
Created December 23, 2011 16:36
Show Gist options
  • Save walkline/1514683 to your computer and use it in GitHub Desktop.
Save walkline/1514683 to your computer and use it in GitHub Desktop.
diff --git a/src/server/game/Chat/Commands/Level0.cpp b/src/server/game/Chat/Commands/Level0.cpp
index 9f9cedf..3449d9e 100755
--- a/src/server/game/Chat/Commands/Level0.cpp
+++ b/src/server/game/Chat/Commands/Level0.cpp
@@ -244,9 +244,9 @@ bool ChatHandler::HandleSpectateCommand(const char *args)
float x, y, z;
target->GetContactPoint(_player, x, y, z);
+ _player->SetSpectate(true);
_player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE);
_player->SetPhaseMask(target->GetPhaseMask(), true);
- _player->SetSpectate(true);
return true;
}
@@ -289,7 +289,7 @@ bool ChatHandler::HandleSpectateFromCommand(const char *args)
return false;
}
- if (target->isSpectator())
+ if (target->isSpectator() && target != _player)
{
PSendSysMessage("Can`t do that. Your target is spectator.");
SetSentErrorMessage(true);
@@ -312,7 +312,8 @@ bool ChatHandler::HandleSpectateFromCommand(const char *args)
return false;
}
- _player->SetViewpoint(target, true);
+ (target == _player) ? _player->SetViewpoint(_player->getSpectateFrom(), false) :
+ _player->SetViewpoint(target, true);
return true;
}
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index b1f5905..6dcb89a 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1019,6 +1019,10 @@ void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false *
void GameObject::Use(Unit* user)
{
+ if (Player *tmpPlayer = user->ToPlayer())
+ if (tmpPlayer->isSpectator())
+ return;
+
// by default spell caster is user
Unit* spellCaster = user;
uint32 spellId = 0;
@@ -1593,6 +1597,10 @@ void GameObject::Use(Unit* user)
void GameObject::CastSpell(Unit* target, uint32 spellId)
{
+ if (Player *tmpPlayer = target->ToPlayer())
+ if (tmpPlayer->isSpectator())
+ return;
+
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
return;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index b498c53..9d736bb 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -2865,6 +2865,8 @@ void Player::SetSpectate(bool on)
{
if (on)
{
+ //add aspectof the cheetah
+ AddAura(5118, this);
spectatorFlag = true;
m_ExtraFlags |= PLAYER_EXTRA_GM_ON;
@@ -2874,8 +2876,11 @@ void Player::SetSpectate(bool on)
{
pet->setFaction(35);
pet->getHostileRefManager().setOnlineOfflineState(false);
+ RemovePet(pet, PET_SAVE_AS_CURRENT);
}
+ UnsummonPetTemporaryIfAny();
+
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
ResetContestedPvP();
@@ -2923,6 +2928,7 @@ void Player::SetSpectate(bool on)
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER);
spectateCanceled = false;
spectatorFlag = false;
+ RemoveAura(5118);
}
UpdateObjectVisibility();
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 92e4564..e5bd4a9 100755
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1159,6 +1159,7 @@ class Player : public Unit, public GridObject<Player>
void SetGMVisible(bool on);
bool isSpectateCanceled() { return spectateCanceled; }
bool CancelSpectate() { spectateCanceled = true; }
+ Unit* getSpectateFrom() { return spectateFrom; }
bool isSpectator() const { return spectatorFlag; }
void SetSpectate(bool on);
bool Has310Flyer(bool checkAllSpells, uint32 excludeSpellId = 0);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 5a7645b..1ca2de8 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3988,6 +3988,11 @@ void Unit::RemoveArenaAuras()
{
AuraApplication const* aurApp = iter->second;
Aura const* aura = aurApp->GetBase();
+ //allow aspect for spectator
+ if (Player *tmpPlayer = ToPlayer() )
+ if (tmpPlayer->isSpectator() && aura->GetId() == 5118)
+ ++iter;
+
if (!(aura->GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_UNK21) // don't remove stances, shadowform, pally/hunter auras
&& !aura->IsPassive() // don't remove passive auras
&& (aurApp->IsPositive() || !(aura->GetSpellInfo()->AttributesEx3 & SPELL_ATTR3_DEATH_PERSISTENT))) // not negative death persistent auras
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 2099f37..09fdc3d 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4604,10 +4604,8 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_ONLY_INDOORS;
}
- Player *tmpPlayer = m_caster->ToPlayer();
-// sLog->outString("CASTING SPELL: %i", m_spellInfo->Id);
- if (tmpPlayer != NULL)
- if(tmpPlayer->isSpectator())
+ if (Player *tmpPlayer = m_caster->ToPlayer())
+ if(tmpPlayer->isSpectator() && m_spellInfo->Id != 5118)
return SPELL_FAILED_SPELL_UNAVAILABLE;
// only check at first call, Stealth auras are already removed at second call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment