*Some update of summon effect code.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-27 18:12:45 -05:00
parent ef87d10a81
commit 34599a46f7
8 changed files with 175 additions and 273 deletions
+24 -34
View File
@@ -53,8 +53,12 @@ void Totem::Update( uint32 time )
Creature::Update( time );
}
void Totem::Summon(Unit* owner)
void Totem::InitSummon(uint32 duration)
{
Unit *owner = GetOwner();
if(!owner)
return;
CreatureInfo const *cinfo = GetCreatureInfo();
if (owner->GetTypeId()==TYPEID_PLAYER && cinfo)
{
@@ -79,24 +83,32 @@ void Totem::Summon(Unit* owner)
sLog.outErrorDb("Totem::Summon: Missing modelid information for entry %u, team %u, totem will use default values.",GetEntry(),((Player*)owner)->GetTeam());
}
// Only add if a display exists.
sLog.outDebug("AddObject at Totem.cpp line 49");
SetInstanceId(owner->GetInstanceId());
owner->GetMap()->Add((Creature*)this);
WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);
data << GetGUID();
SendMessageToSet(&data,true);
switch(m_type)
{
case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); break;
case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break;
default: break;
}
if(m_type == TOTEM_PASSIVE)
CastSpell(this, GetSpell(), true);
if(GetEntry() == SENTRY_TOTEM_ENTRY)
SetReactState(REACT_AGGRESSIVE);
m_duration = duration;
SetCreatorGUID(owner->GetGUID());
setFaction(owner->getFaction());
SetLevel(owner->getLevel());
// 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))
m_type = TOTEM_ACTIVE;
}
TempSummon::InitSummon(duration);
}
void Totem::UnSummon()
@@ -142,14 +154,6 @@ void Totem::UnSummon()
AddObjectToRemoveList();
}
void Totem::SetOwner(Unit *owner)
{
SetCreatorGUID(owner->GetGUID());
TempSummon::SetOwner(owner, true);
setFaction(owner->getFaction());
SetLevel(owner->getLevel());
}
Unit *Totem::GetOwner()
{
uint64 ownerid = GetOwnerGUID();
@@ -158,20 +162,6 @@ Unit *Totem::GetOwner()
return ObjectAccessor::GetUnit(*this, ownerid);
}
void Totem::SetTypeBySummonSpell(SpellEntry const * spellProto)
{
// 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))
m_type = TOTEM_ACTIVE;
}
if(spellProto->SpellIconID==2056)
m_type = TOTEM_STATUE; //Jewelery statue
}
bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
{
// TODO: possibly all negative auras immuned?