[11889] Improve handling of target mode TARGET_RANDOM_NEARBY_DEST

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
pasdVn 2012-01-26 00:13:57 +01:00 committed by Schmoozerd
parent f25e14fd9f
commit 0fe4f21b6a
2 changed files with 20 additions and 16 deletions

View file

@ -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;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11888"
#define REVISION_NR "11889"
#endif // __REVISION_NR_H__