aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Totem
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2011-05-19 22:27:18 +0200
committerShauren <shauren.trinity@gmail.com>2011-05-19 22:27:18 +0200
commitac4ed1efdf2d800ab2ea605fac982c9436cfba1b (patch)
tree93a7af028452062695f6ad09c29f1c1fb4cb299f /src/server/game/Entities/Totem
parentf03bdceaff76d8488cb683a80ac3fd6149c6299b (diff)
Core/Spells: Moved setting UNIT_CREATED_BY_SPELL out of spell effect handlers and sending SMSG_TOTEM_CREATED into Totem class
Diffstat (limited to 'src/server/game/Entities/Totem')
-rwxr-xr-xsrc/server/game/Entities/Totem/Totem.cpp37
-rwxr-xr-xsrc/server/game/Entities/Totem/Totem.h6
2 files changed, 27 insertions, 16 deletions
diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp
index 63ae2dd9bda..cc2b272625b 100755
--- a/src/server/game/Entities/Totem/Totem.cpp
+++ b/src/server/game/Entities/Totem/Totem.cpp
@@ -24,7 +24,7 @@
#include "ObjectMgr.h"
#include "SpellMgr.h"
-Totem::Totem(SummonPropertiesEntry const *properties, Unit *owner) : Minion(properties, owner)
+Totem::Totem(SummonPropertiesEntry const* properties, Unit* owner) : Minion(properties, owner)
{
m_unitTypeMask |= UNIT_MASK_TOTEM;
m_duration = 0;
@@ -54,18 +54,14 @@ void Totem::InitStats(uint32 duration)
{
Minion::InitStats(duration);
+ // set display id depending on caster's race
if (m_owner->GetTypeId() == TYPEID_PLAYER)
- // set display id depending on race
SetDisplayId(m_owner->GetModelForTotem(PlayerTotemType(m_Properties->Id)));
- // Get spell casted by totem
- SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell());
- if (totemSpell)
- {
- // If spell have cast time -> so its active totem
- if (GetSpellCastTime(totemSpell))
+ // Get spell cast by totem
+ if (SpellEntry const* totemSpell = sSpellStore.LookupEntry(GetSpell()))
+ if (GetSpellCastTime(totemSpell)) // If spell has cast time -> its an active totem
m_type = TOTEM_ACTIVE;
- }
if (GetEntry() == SENTRY_TOTEM_ENTRY)
SetReactState(REACT_AGGRESSIVE);
@@ -73,6 +69,19 @@ void Totem::InitStats(uint32 duration)
m_duration = duration;
SetLevel(m_owner->getLevel());
+
+ // client requires SMSG_TOTEM_CREATED to be sent before adding to world
+ if (m_owner->GetTypeId() == TYPEID_PLAYER
+ && m_Properties->Slot >= SUMMON_SLOT_TOTEM
+ && m_Properties->Slot < MAX_TOTEM_SLOT)
+ {
+ WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
+ data << uint8(m_Properties->Slot - 1);
+ data << uint64(GetGUID());
+ data << uint32(duration);
+ data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL));
+ m_owner->ToPlayer()->SendDirectMessage(&data);
+ }
}
void Totem::InitSummon()
@@ -106,11 +115,11 @@ void Totem::UnSummon()
if (Player* owner = m_owner->ToPlayer())
{
owner->SendAutoRepeatCancel(this);
+
if (SpellEntry const* spell = sSpellStore.LookupEntry(GetUInt32Value(UNIT_CREATED_BY_SPELL)))
owner->SendCooldownEvent(spell);
- // Not only the player can summon the totem (scripted AI)
- Group* group = owner->GetGroup();
- if (group)
+
+ if (Group* group = owner->GetGroup())
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
@@ -129,7 +138,8 @@ bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) co
// TODO: possibly all negative auras immune?
if (GetEntry() == 5925)
return false;
- switch(spellInfo->EffectApplyAuraName[index])
+
+ switch (spellInfo->EffectApplyAuraName[index])
{
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_LEECH:
@@ -139,5 +149,6 @@ bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) co
default:
break;
}
+
return Creature::IsImmunedToSpellEffect(spellInfo, index);
}
diff --git a/src/server/game/Entities/Totem/Totem.h b/src/server/game/Entities/Totem/Totem.h
index c8ee245d3fa..f1105f2a917 100755
--- a/src/server/game/Entities/Totem/Totem.h
+++ b/src/server/game/Entities/Totem/Totem.h
@@ -33,13 +33,13 @@ enum TotemType
class Totem : public Minion
{
public:
- explicit Totem(SummonPropertiesEntry const *properties, Unit *owner);
- virtual ~Totem(){};
+ Totem(SummonPropertiesEntry const* properties, Unit* owner);
+ virtual ~Totem() {}
void Update(uint32 time);
void InitStats(uint32 duration);
void InitSummon();
void UnSummon();
- uint32 GetSpell(uint8 slot=0) const { return m_spells[slot]; }
+ uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; }
uint32 GetTotemDuration() const { return m_duration; }
TotemType GetTotemType() const { return m_type; }