Core/Spells: Grounding Totem: - correctly magnet spells and dies - let missile spells fly on it and destroys all spells during the travel time of first one

Thx @amsjunior1

Closes #13147
Fixes #5611
This commit is contained in:
mik1893
2014-10-18 21:13:37 +01:00
committed by DDuarte
parent 47359a1ae2
commit ef4043436b
3 changed files with 26 additions and 2 deletions
+20 -2
View File
@@ -3460,7 +3460,7 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMo
ASSERT(!aurApp->GetEffectMask());
// Remove totem at next update if totem loses its aura
if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && ToCreature()->IsTotem()&& ToTotem()->GetSummonerGUID() == aura->GetCasterGUID())
if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && ToCreature()->IsTotem())
{
if (ToTotem()->GetSpell() == aura->GetId() && ToTotem()->GetTotemType() == TOTEM_PASSIVE)
ToTotem()->setDeathState(JUST_DIED);
@@ -9584,6 +9584,15 @@ int32 Unit::DealHeal(Unit* victim, uint32 addhealth)
return gain;
}
bool Unit::IsMagnet() const
{
// Grounding Totem
if (GetUInt32Value(UNIT_CREATED_BY_SPELL) == 8177) /// @todo: find a more generic solution
return true;
return false;
}
Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo)
{
// Patch 1.2 notes: Spell Reflection no longer reflects abilities
@@ -9599,7 +9608,16 @@ Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo)
&& _IsValidAttackTarget(magnet, spellInfo))
{
/// @todo handle this charge drop by proc in cast phase on explicit target
(*itr)->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
if (victim && spellInfo->Speed > 0.0f)
{
// Set up missile speed based delay
uint32 delay = uint32(std::floor(std::max<float>(victim->GetDistance(this), 5.0f) / spellInfo->Speed * 1000.0f));
// Schedule charge drop
(*itr)->GetBase()->DropChargeDelayed(delay,AURA_REMOVE_BY_EXPIRE);
}
else
(*itr)->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
return magnet;
}
}
+1
View File
@@ -1971,6 +1971,7 @@ class Unit : public WorldObject
uint32 BuildAuraStateUpdateForTarget(Unit* target) const;
bool HasAuraState(AuraStateType flag, SpellInfo const* spellProto = NULL, Unit const* Caster = NULL) const;
void UnsummonAllTotems();
bool IsMagnet() const;
Unit* GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo);
Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = NULL);
+5
View File
@@ -1738,6 +1738,11 @@ bool SpellInfo::CheckTargetCreatureType(Unit const* target) const
else
return true;
}
// if target is magnet (i.e Grounding Totem) the check is skipped
if (target->IsMagnet())
return true;
uint32 creatureType = target->GetCreatureTypeMask();
return !TargetCreatureType || !creatureType || (creatureType & TargetCreatureType);
}