aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2014-07-05 14:29:12 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2014-07-05 14:29:12 +0200
commit7008ac98aa15c41d408874fa7761a4e01e24042c (patch)
treea13d1619ff3132558e6afaf14dce8016318d7efa /src/server/game/Spells/Spell.cpp
parenta508ce1976caaf8ede6afcea7e8a857399f548ef (diff)
parent2042b095266cabd79b26d8325d4dee600260d4c9 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 7a4d4904cc1..4920e0c2254 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -5106,15 +5106,24 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!target)
return SPELL_FAILED_DONT_REPORT;
- //target->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
- Position pos = target->GetFirstCollisionPosition(CONTACT_DISTANCE, target->GetRelativeAngle(m_caster));
+ float objSize = target->GetObjectSize();
+ float range = m_spellInfo->GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict
- m_preGeneratedPath.SetPathLengthLimit(m_spellInfo->GetMaxRange(true) * 1.5f);
- bool result = m_preGeneratedPath.CalculatePath(pos.m_positionX, pos.m_positionY, pos.m_positionZ + target->GetObjectSize(), false, true);
+ m_preGeneratedPath.SetPathLengthLimit(range);
+ // first try with raycast, if it fails fall back to normal path
+ bool result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + target->GetObjectSize(), false, true);
if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT)
return SPELL_FAILED_OUT_OF_RANGE;
else if (!result || m_preGeneratedPath.GetPathType() & PATHFIND_NOPATH)
- return SPELL_FAILED_NOPATH;
+ {
+ result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + target->GetObjectSize(), false, false);
+ if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT)
+ return SPELL_FAILED_OUT_OF_RANGE;
+ else if (!result || m_preGeneratedPath.GetPathType() & PATHFIND_NOPATH)
+ return SPELL_FAILED_NOPATH;
+ }
+
+ m_preGeneratedPath.ReducePathLenghtByDist(objSize); // move back
}
break;
}