mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11889] Improve handling of target mode TARGET_RANDOM_NEARBY_DEST
Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
f25e14fd9f
commit
0fe4f21b6a
2 changed files with 20 additions and 16 deletions
|
|
@ -1657,13 +1657,15 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
unMaxTargets += (*m)->GetModifier()->m_amount;
|
unMaxTargets += (*m)->GetModifier()->m_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(targetMode)
|
switch (targetMode)
|
||||||
{
|
{
|
||||||
case TARGET_RANDOM_NEARBY_LOC:
|
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.
|
// 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!!!
|
radius *= sqrtf(rand_norm_f());
|
||||||
|
// no 'break' expected since we use code in case TARGET_RANDOM_CIRCUMFERENCE_POINT!!!
|
||||||
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 angle = 2.0f * M_PI_F * rand_norm_f();
|
||||||
float dest_x, dest_y, dest_z;
|
float dest_x, dest_y, dest_z;
|
||||||
m_caster->GetClosePoint(dest_x, dest_y, dest_z, 0.0f, radius, angle);
|
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_91:
|
||||||
case TARGET_RANDOM_NEARBY_DEST:
|
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.
|
// Get a random point IN the CIRCEL around current M_TARGETS COORDINATES(!).
|
||||||
float angle = 2.0f * M_PI_F * rand_norm_f();
|
if (radius > 0.0f)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
// caster included here?
|
// Use sqrt(rand) to correct distribution when converting polar to Cartesian coordinates.
|
||||||
FillAreaTargets(targetUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_ALL);
|
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);
|
targetUnitMap.push_back(m_caster);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11888"
|
#define REVISION_NR "11889"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue