void Totem::Summon(Unit* owner) { AIM_Initialize(); owner->GetMap()->Add((Creature*)this); if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI()) ((Creature*)owner)->AI()->JustSummoned((Creature*)this); switch(m_type) { case TOTEM_PASSIVE: { for (uint32 i = 0; i <= GetSpellMaxIndex(); ++i) { if (uint32 spellId = GetSpell(i)) CastSpell(this, spellId, true); } break; } case TOTEM_STATUE: { if (GetSpell(0)) CastSpell(GetOwner(), GetSpell(0), true); break; } default: break; } }
void Totem::UnSummon() { CombatStop(); uint32 maxIdx = GetSpellMaxIndex(); for (int32 i = maxIdx; i >= 0; --i) { if (uint32 spellId = GetSpell(i)) RemoveAurasDueToSpell(spellId); } if (Unit* owner = GetOwner()) { owner->_RemoveTotem(this); for (int32 i = maxIdx; i >= 0; --i) { if (uint32 spellId = GetSpell(i)) owner->RemoveAurasDueToSpell(spellId); } // Remove Sentry Totem aura on totem unsummon if (GetEntry() == SENTRY_TOTEM_ENTRY) owner->RemoveAurasDueToSpell(6495); //remove aura all party members too if (owner->GetTypeId() == TYPEID_PLAYER) { ((Player*)owner)->SendAutoRepeatCancel(this); // Not only the player can summon the totem (scripted AI) if (Group* pGroup = ((Player*)owner)->GetGroup()) { for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->getSource(); if (Target && pGroup->SameSubGroup((Player*)owner, Target)) { for (int32 i = maxIdx; i >= 0; --i) { if (uint32 spellId = GetSpell(i)) Target->RemoveAurasDueToSpell(spellId); } } } } } if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI()) ((Creature*)owner)->AI()->SummonedCreatureDespawn((Creature*)this); } // any totem unsummon look like as totem kill, req. for proper animation if (isAlive()) SetDeathState(DEAD); AddObjectToRemoveList(); }