*Fix that bug that charmed player still be charmed even after death.

--HG--
branch : trunk
This commit is contained in:
megamage
2008-12-11 22:22:35 -06:00
parent 6dbc24a32b
commit 3700760285
+13 -11
View File
@@ -2945,13 +2945,15 @@ void Aura::HandleModCharm(bool apply, bool Real)
return;
Unit* caster = GetCaster();
if( apply )
{
if(!caster)
return;
if(int32(m_target->getLevel()) <= m_modifier.m_amount)
{
if( apply )
{
if(int32(m_target->getLevel()) > m_modifier.m_amount)
return;
m_target->SetCharmerGUID(GetCasterGUID());
m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction());
m_target->CastStop(m_target==caster ? GetId() : 0);
@@ -3009,7 +3011,7 @@ void Aura::HandleModCharm(bool apply, bool Real)
m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
// restore UNIT_FIELD_BYTES_0
if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
if(caster && cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
{
CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
if(cainfo && cainfo->bytes0 != 0)
@@ -3022,8 +3024,14 @@ void Aura::HandleModCharm(bool apply, bool Real)
else
sLog.outError("Aura::HandleModCharm: target="I64FMTD" with typeid=%d has a charm aura but no charm info!", m_target->GetGUID(), m_target->GetTypeId());
}
((Creature*)m_target)->AIM_Initialize();
if(((Creature*)m_target)->AI() && caster)
((Creature*)m_target)->AI()->AttackStart(caster);
}
if(caster)
{
caster->SetCharm(0);
if(caster->GetTypeId() == TYPEID_PLAYER)
@@ -3032,12 +3040,6 @@ void Aura::HandleModCharm(bool apply, bool Real)
data << uint64(0);
((Player*)caster)->GetSession()->SendPacket(&data);
}
if(m_target->GetTypeId() == TYPEID_UNIT)
{
((Creature*)m_target)->AIM_Initialize();
if (((Creature*)m_target)->AI())
((Creature*)m_target)->AI()->AttackStart(caster);
}
}
}
}