2 * Copyright (C) 2005,2006 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"
30 m_type
= TOTEM_PASSIVE
;
33 void Totem::Update( uint32 time
)
35 Unit
*owner
= GetOwner();
36 if (!owner
|| !owner
->isAlive() || !this->isAlive())
38 UnSummon(); // remove self
42 if (m_duration
<= time
)
44 UnSummon(); // remove self
50 Creature::Update( time
);
56 sLog
.outDebug("AddObject at Totem.cpp line 49");
57 MapManager::Instance().GetMap(GetMapId())->Add((Creature
*)this);
59 data
.Initialize(SMSG_GAMEOBJECT_SPAWN_ANIM
);
61 SendMessageToSet(&data
,true);
65 if (m_type
== TOTEM_PASSIVE
)
66 this->CastSpell(this, m_spell
, true);
69 void Totem::UnSummon()
71 if (m_type
== TOTEM_LAST_BURST
)
72 this->CastSpell(this, m_spell
, true);
75 data
.Initialize(SMSG_GAMEOBJECT_DESPAWN_ANIM
);
77 SendMessageToSet(&data
, true);
78 data
.Initialize(SMSG_DESTROY_OBJECT
);
80 SendMessageToSet(&data
, true);
83 RemoveAurasDueToSpell(m_spell
);
84 Unit
*owner
= this->GetOwner();
86 owner
->RemoveAurasDueToSpell(m_spell
);
88 ObjectAccessor::Instance().AddObjectToRemoveList(this);
91 void Totem::SetOwner(uint64 guid
)
93 SetUInt64Value(UNIT_FIELD_SUMMONEDBY
, guid
);
94 Unit
*owner
= this->GetOwner();
97 this->setFaction(owner
->getFaction());
98 this->SetLevel(owner
->getLevel());
102 Unit
*Totem::GetOwner()
104 uint64 ownerid
= GetOwnerGUID();
107 return ObjectAccessor::Instance().GetUnit(*this, ownerid
);
110 void Totem::SetSpell(uint32 spellId
)
112 //now, spellId is the spell of EffectSummonTotem , not the spell1 of totem!
113 m_spell
= this->GetCreatureInfo()->spell1
;
114 if (GetDuration(sSpellStore
.LookupEntry(m_spell
)) != -1)
115 m_type
= TOTEM_ACTIVE
;
119 SpellEntry
*spellinfo
= sSpellStore
.LookupEntry(spellId
);
120 if ( spellinfo
&& spellinfo
->SpellFamilyFlags
== 0x28000000 )
121 m_type
= TOTEM_LAST_BURST
; //For Fire Nova Totem and Corrupted Fire Nova Totem