[8816] call uncharm for all units at delete

currently it was only done for players - but units
also can have charms which must be removed
This commit is contained in:
balrok 2009-11-13 08:07:58 -05:00
parent ef26908948
commit c3c7ab2f63
6 changed files with 19 additions and 14 deletions

View file

@ -7977,7 +7977,7 @@ Pet* Unit::GetPet() const
Unit* Unit::GetCharm() const
{
if(uint64 charm_guid = GetCharmGUID())
if (uint64 charm_guid = GetCharmGUID())
{
if(Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid))
return pet;
@ -7989,6 +7989,15 @@ Unit* Unit::GetCharm() const
return NULL;
}
void Unit::Uncharm()
{
if (Unit* charm = GetCharm())
{
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
}
}
float Unit::GetCombatDistance( const Unit* target ) const
{
float radius = target->GetFloatValue(UNIT_FIELD_COMBATREACH) + GetFloatValue(UNIT_FIELD_COMBATREACH);
@ -11090,6 +11099,7 @@ void Unit::RemoveFromWorld()
// cleanup
if(IsInWorld())
{
Uncharm();
RemoveNotOwnSingleTargetAuras();
RemoveGuardians();
}