[8542] Correct formulas for destinantion coords calculation for implicit target types 72, 73, 89

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
nos4r2zod 2009-09-27 13:56:37 +03:00 committed by Ambal
parent a5ef1f9457
commit 62cee4d29f
3 changed files with 13 additions and 9 deletions

View file

@ -1051,9 +1051,9 @@ enum Targets
TARGET_SINGLE_FRIEND_2 = 57, TARGET_SINGLE_FRIEND_2 = 57,
TARGET_AREAEFFECT_PARTY_AND_CLASS = 61, TARGET_AREAEFFECT_PARTY_AND_CLASS = 61,
TARGET_DUELVSPLAYER_COORDINATES = 63, TARGET_DUELVSPLAYER_COORDINATES = 63,
TARGET_BEHIND_VICTIM = 65, // uses in teleport behind spells, caster/target dependent from spell effect TARGET_BEHIND_VICTIM = 65, // used in teleport behind spells, caster/target dependent from spell effect
TARGET_RANDOM_NEARBY_LOC = 72, // uses in teleport onto nearby locations TARGET_RANDOM_NEARBY_LOC = 72, // used in teleport onto nearby locations
TARGET_RANDOM_NEARBY_LOC_LR = 73, // the same as TARGET_RANDOM_NEARBY_LOC but with larger ranges TARGET_RANDOM_CIRCUMFERENCE_POINT = 73,
TARGET_DYNAMIC_OBJECT_COORDINATES = 76, TARGET_DYNAMIC_OBJECT_COORDINATES = 76,
TARGET_SINGLE_ENEMY = 77, TARGET_SINGLE_ENEMY = 77,
TARGET_POINT_AT_NORTH = 78, // 78-85 possible _COORDINATES at radius with pi/4 step around target in unknown order, N? TARGET_POINT_AT_NORTH = 78, // 78-85 possible _COORDINATES at radius with pi/4 step around target in unknown order, N?

View file

@ -1314,10 +1314,12 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
switch(targetMode) switch(targetMode)
{ {
case TARGET_RANDOM_NEARBY_LOC: case TARGET_RANDOM_NEARBY_LOC:
case TARGET_RANDOM_NEARBY_LOC_LR: radius *= sqrt(rand_norm()); // Get a random point in circle. Use sqrt(rand) to correct distribution when converting polar to Cartesian coordinates.
case TARGET_RANDOM_CIRCUMFERENCE_POINT:
{ {
float dest_x = m_caster->GetPositionX() + irand(-radius, radius); float angle = 2.0 * M_PI * rand_norm();
float dest_y = m_caster->GetPositionY() + irand(-radius, radius); float dest_x = m_caster->GetPositionX() + cos(angle) * radius;
float dest_y = m_caster->GetPositionY() + sin(angle) * radius;
float dest_z = m_caster->GetMap()->GetHeight(dest_x, dest_y, MAX_HEIGHT); float dest_z = m_caster->GetMap()->GetHeight(dest_x, dest_y, MAX_HEIGHT);
m_targets.setDestination(dest_x, dest_y, dest_z); m_targets.setDestination(dest_x, dest_y, dest_z);
@ -1326,8 +1328,10 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
} }
case TARGET_RANDOM_NEARBY_DEST: case TARGET_RANDOM_NEARBY_DEST:
{ {
float dest_x = m_targets.m_destX + irand(-radius, radius); radius *= sqrt(rand_norm()); // Get a random point in circle. Use sqrt(rand) to correct distribution when converting polar to Cartesian coordinates.
float dest_y = m_targets.m_destY + irand(-radius, radius); float angle = 2.0 * M_PI * rand_norm();
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->GetMap()->GetHeight(dest_x, dest_y, MAX_HEIGHT); float dest_z = m_caster->GetMap()->GetHeight(dest_x, dest_y, MAX_HEIGHT);
m_targets.setDestination(dest_x, dest_y, dest_z); m_targets.setDestination(dest_x, dest_y, dest_z);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8541" #define REVISION_NR "8542"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__