diff options
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rwxr-xr-x | src/server/game/Spells/Spell.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 5589e7328b2..4003f2f3b36 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -642,23 +642,24 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets) // try to select correct unit target if not provided by client or by serverside cast if (neededTargets & (TARGET_FLAG_UNIT_MASK)) { - Unit* target = NULL; + Unit* unit = NULL; // try to use player selection as a target if (Player* playerCaster = m_caster->ToPlayer()) { // selection has to be found and to be valid target for the spell if (Unit* selectedUnit = ObjectAccessor::GetUnit(*m_caster, playerCaster->GetSelection())) if (m_spellInfo->CheckExplicitTarget(m_caster, selectedUnit) == SPELL_CAST_OK) - target = selectedUnit; + unit = selectedUnit; } // try to use attacked unit as a target else if ((m_caster->GetTypeId() == TYPEID_UNIT) && neededTargets & (TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT)) - target = m_caster->getVictim(); + unit = m_caster->getVictim(); + // didn't find anything - let's use self as target - if (!target && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY)) - target = m_caster; + if (!unit && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY)) + unit = m_caster; - m_targets.SetUnitTarget(target); + m_targets.SetUnitTarget(unit); } } @@ -1219,11 +1220,11 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) if (spellHitTarget) { - SpellMissInfo missInfo = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura); - if (missInfo != SPELL_MISS_NONE) + SpellMissInfo missInfo2 = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura); + if (missInfo2 != SPELL_MISS_NONE) { - if (missInfo != SPELL_MISS_MISS) - m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo); + if (missInfo2 != SPELL_MISS_MISS) + m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo2); m_damage = 0; spellHitTarget = NULL; } @@ -6799,7 +6800,7 @@ void Spell::SelectTrajTargets() if (!dist2d) return; - float dz = m_targets.GetDst()->m_positionZ - m_targets.GetSrc()->m_positionZ; + float srcToDestDelta = m_targets.GetDst()->m_positionZ - m_targets.GetSrc()->m_positionZ; UnitList unitList; SearchAreaTarget(unitList, dist2d, PUSH_IN_THIN_LINE, SPELL_TARGETS_ANY); @@ -6809,8 +6810,9 @@ void Spell::SelectTrajTargets() unitList.sort(Trinity::ObjectDistanceOrderPred(m_caster)); float b = tangent(m_targets.GetElevation()); - float a = (dz - dist2d * b) / (dist2d * dist2d); - if (a > -0.0001f) a = 0; + float a = (srcToDestDelta - dist2d * b) / (dist2d * dist2d); + if (a > -0.0001f) + a = 0; DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: a %f b %f", a, b);) float bestDist = m_spellInfo->GetMaxRange(false); @@ -6838,9 +6840,14 @@ void Spell::SelectTrajTargets() } #define CHECK_DIST {\ - DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\ - if (dist > bestDist) continue;\ - if (dist < objDist2d + size && dist > objDist2d - size) { bestDist = dist; break; }\ + DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\ + if (dist > bestDist)\ + continue;\ + if (dist < objDist2d + size && dist > objDist2d - size)\ + {\ + bestDist = dist;\ + break;\ + }\ } if (!a) |