Core/Spells: Fixed LoS checks for spells like shadowfury

This commit is contained in:
Shauren
2014-08-04 18:56:17 +02:00
parent 15b1d41740
commit e4d6d34f6e
2 changed files with 22 additions and 15 deletions
+20 -13
View File
@@ -1207,7 +1207,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
{
if (Unit* unitTarget = (*itr)->ToUnit())
AddUnitTarget(unitTarget, effMask, false);
AddUnitTarget(unitTarget, effMask, false, true, center);
else if (GameObject* gObjTarget = (*itr)->ToGameObject())
AddGOTarget(gObjTarget, effMask);
}
@@ -2000,10 +2000,10 @@ void Spell::CleanupTargetList()
m_delayMoment = 0;
}
void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= true*/, bool implicit /*= true*/)
void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= true*/, bool implicit /*= true*/, Position const* losPosition /*= nullptr*/)
{
for (uint32 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
if (!m_spellInfo->Effects[effIndex].IsEffect() || !CheckEffectTarget(target, effIndex))
if (!m_spellInfo->Effects[effIndex].IsEffect() || !CheckEffectTarget(target, effIndex, losPosition))
effectMask &= ~(1 << effIndex);
// no effects left
@@ -4798,7 +4798,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (IsTriggered() && m_triggeredByAuraSpell)
if (DynamicObject* dynObj = m_caster->GetDynObject(m_triggeredByAuraSpell->Id))
losTarget = dynObj;
if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_DISABLE_LOS) && !target->IsWithinLOSInMap(losTarget))
return SPELL_FAILED_LINE_OF_SIGHT;
}
@@ -6413,7 +6413,7 @@ CurrentSpellTypes Spell::GetCurrentContainer() const
return(CURRENT_GENERIC_SPELL);
}
bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* losPosition) const
{
switch (m_spellInfo->Effects[eff].ApplyAuraName)
{
@@ -6463,15 +6463,22 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
// all ok by some way or another, skip normal check
break;
default: // normal case
// Get GO cast coordinates if original caster -> GO
WorldObject* caster = NULL;
if (IS_GAMEOBJECT_GUID(m_originalCasterGUID))
caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID);
if (!caster)
caster = m_caster;
if (target != m_caster && !target->IsWithinLOSInMap(caster))
return false;
{
if (losPosition)
return target->IsWithinLOS(losPosition->GetPositionX(), losPosition->GetPositionY(), losPosition->GetPositionZ());
else
{
// Get GO cast coordinates if original caster -> GO
WorldObject* caster = NULL;
if (IS_GAMEOBJECT_GUID(m_originalCasterGUID))
caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID);
if (!caster)
caster = m_caster;
if (target != m_caster && !target->IsWithinLOSInMap(caster))
return false;
}
break;
}
}
return true;
+2 -2
View File
@@ -417,7 +417,7 @@ class Spell
void WriteSpellGoTargets(WorldPacket* data);
void WriteAmmoToPacket(WorldPacket* data);
bool CheckEffectTarget(Unit const* target, uint32 eff) const;
bool CheckEffectTarget(Unit const* target, uint32 eff, Position const* losPosition) const;
bool CanAutoCast(Unit* target);
void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); }
void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); }
@@ -607,7 +607,7 @@ class Spell
SpellDestination m_destTargets[MAX_SPELL_EFFECTS];
void AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid = true, bool implicit = true);
void AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid = true, bool implicit = true, Position const* losPosition = nullptr);
void AddGOTarget(GameObject* target, uint32 effectMask);
void AddItemTarget(Item* item, uint32 effectMask);
void AddDestTarget(SpellDestination const& dest, uint32 effIndex);