2 * Copyright (C) 2005,2006,2007 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "WorldPacket.h"
21 #include "MapManager.h"
22 #include "Database/DBCStores.h"
26 #include "ObjectMgr.h"
33 m_type
= TOTEM_PASSIVE
;
36 void Totem::Update( uint32 time
)
38 Unit
*owner
= GetOwner();
39 if (!owner
|| !owner
->isAlive() || !this->isAlive())
41 UnSummon(); // remove self
45 if (m_duration
<= time
)
47 UnSummon(); // remove self
53 Creature::Update( time
);
58 sLog
.outDebug("AddObject at Totem.cpp line 49");
59 MapManager::Instance().GetMap(GetMapId())->Add((Creature
*)this);
61 WorldPacket
data(SMSG_GAMEOBJECT_SPAWN_ANIM
, 8);
63 SendMessageToSet(&data
,true);
67 if (m_type
== TOTEM_PASSIVE
)
68 this->CastSpell(this, m_spell
, true);
71 void Totem::UnSummon()
73 if (m_type
== TOTEM_LAST_BURST
)
74 this->CastSpell(this, m_spell
, true);
76 SendObjectDeSpawnAnim(GetGUID());
77 SendDestroyObject(GetGUID());
80 RemoveAurasDueToSpell(m_spell
);
81 Unit
*owner
= this->GetOwner();
84 owner
->RemoveAurasDueToSpell(m_spell
);
86 //remove aura all party members too
88 pGroup
= ((Player
*)owner
)->groupInfo
.group
;
91 for(uint32 p
=0;p
<pGroup
->GetMembersCount();p
++)
93 if(!pGroup
->SameSubGroup(owner
->GetGUID(), pGroup
->GetMemberGUID(p
)))
96 Unit
* Target
= objmgr
.GetPlayer(pGroup
->GetMemberGUID(p
));
97 if (Target
) Target
->RemoveAurasDueToSpell(m_spell
);
102 ObjectAccessor::Instance().AddObjectToRemoveList(this);
105 void Totem::SetOwner(uint64 guid
)
107 SetUInt64Value(UNIT_FIELD_SUMMONEDBY
, guid
);
108 Unit
*owner
= this->GetOwner();
111 this->setFaction(owner
->getFaction());
112 this->SetLevel(owner
->getLevel());
116 Unit
*Totem::GetOwner()
118 uint64 ownerid
= GetOwnerGUID();
121 return ObjectAccessor::Instance().GetUnit(*this, ownerid
);
124 void Totem::SetSpell(uint32 spellId
)
126 //now, spellId is the spell of EffectSummonTotem , not the spell1 of totem!
127 m_spell
= this->GetCreatureInfo()->spell1
;
128 if (GetDuration(sSpellStore
.LookupEntry(m_spell
)) != -1)
129 m_type
= TOTEM_ACTIVE
;
133 SpellEntry
const *spellinfo
= sSpellStore
.LookupEntry(spellId
);
134 if ( spellinfo
&& spellinfo
->SpellFamilyFlags
== 0x28000000 )
135 m_type
= TOTEM_LAST_BURST
; //For Fire Nova Totem and Corrupted Fire Nova Totem