From d926ad63c037457198cec8a28a86863643d92dc6 Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 13 Feb 2013 20:21:26 +0100 Subject: Core/Spells: Fixed charge effects with non-explicit targets --- src/server/game/Spells/Spell.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/server/game/Spells/Spell.cpp') diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 18dc6f104a4..53bcd6bd077 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5148,26 +5148,23 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->HasUnitState(UNIT_STATE_ROOT)) return SPELL_FAILED_ROOTED; - Unit* target = m_targets.GetUnitTarget(); - - if (!target) - return SPELL_FAILED_DONT_REPORT; - - if (m_caster->GetTypeId() == TYPEID_PLAYER) - if (!target->isAlive()) - return SPELL_FAILED_BAD_TARGETS; - - Position pos; - target->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ); - target->GetFirstCollisionPosition(pos, CONTACT_DISTANCE, target->GetRelativeAngle(m_caster)); + if (GetSpellInfo()->NeedsExplicitUnitTarget()) + { + Unit* target = m_targets.GetUnitTarget(); + if (!target) + return SPELL_FAILED_DONT_REPORT; - 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()); - if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT) - return SPELL_FAILED_OUT_OF_RANGE; - else if (!result) - return SPELL_FAILED_NOPATH; + Position pos; + target->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ); + target->GetFirstCollisionPosition(pos, CONTACT_DISTANCE, target->GetRelativeAngle(m_caster)); + 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()); + if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT) + return SPELL_FAILED_OUT_OF_RANGE; + else if (!result || m_preGeneratedPath.GetPathType() & PATHFIND_NOPATH) + return SPELL_FAILED_NOPATH; + } break; } case SPELL_EFFECT_SKINNING: -- cgit v1.2.3