diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 1700db542..a784d8096 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1657,13 +1657,15 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& unMaxTargets += (*m)->GetModifier()->m_amount; } - switch(targetMode) + switch (targetMode) { case TARGET_RANDOM_NEARBY_LOC: - radius *= sqrtf(rand_norm_f()); // Get a random point in circle. Use sqrt(rand) to correct distribution when converting polar to Cartesian coordinates. - // no 'break' expected since we use code in case TARGET_RANDOM_CIRCUMFERENCE_POINT!!! + // Get a random point in circle. Use sqrt(rand) to correct distribution when converting polar to Cartesian coordinates. + radius *= sqrtf(rand_norm_f()); + // no 'break' expected since we use code in case TARGET_RANDOM_CIRCUMFERENCE_POINT!!! case TARGET_RANDOM_CIRCUMFERENCE_POINT: { + // Get a random point AT the circumference float angle = 2.0f * M_PI_F * rand_norm_f(); float dest_x, dest_y, dest_z; m_caster->GetClosePoint(dest_x, dest_y, dest_z, 0.0f, radius, angle); @@ -1675,20 +1677,22 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& case TARGET_91: case TARGET_RANDOM_NEARBY_DEST: { - radius *= sqrtf(rand_norm_f()); // Get a random point in circle. Use sqrt(rand) to correct distribution when converting polar to Cartesian coordinates. - float angle = 2.0f * M_PI_F * rand_norm_f(); - float dest_x = m_targets.m_destX + cos(angle) * radius; - float dest_y = m_targets.m_destY + sin(angle) * radius; - float dest_z = m_targets.m_destZ; - m_caster->UpdateGroundPositionZ(dest_x, dest_y, dest_z); - m_targets.setDestination(dest_x, dest_y, dest_z); - - if (targetMode == TARGET_RANDOM_NEARBY_DEST && radius > 0.0f) + // Get a random point IN the CIRCEL around current M_TARGETS COORDINATES(!). + if (radius > 0.0f) { - // caster included here? - FillAreaTargets(targetUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_ALL); + // Use sqrt(rand) to correct distribution when converting polar to Cartesian coordinates. + radius *= sqrtf(rand_norm_f()); + float angle = 2.0f * M_PI_F * rand_norm_f(); + float dest_x = m_targets.m_destX + cos(angle) * radius; + float dest_y = m_targets.m_destY + sin(angle) * radius; + float dest_z = m_caster->GetPositionZ(); + m_caster->UpdateGroundPositionZ(dest_x, dest_y, dest_z); + m_targets.setDestination(dest_x, dest_y, dest_z); } - else + + // This targetMode is often used as 'last' implicitTarget for positive spells, that just require coordinates + // and no unitTarget (e.g. summon effects). As MaNGOS always needs a unitTarget we add just the caster here. + if (IsPositiveSpell(m_spellInfo)) targetUnitMap.push_back(m_caster); break; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c3e303b91..96e11265c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11888" + #define REVISION_NR "11889" #endif // __REVISION_NR_H__