aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/Object.cpp14
-rw-r--r--src/game/Object.h6
-rw-r--r--src/game/SharedDefines.h20
-rw-r--r--src/game/Spell.cpp78
-rw-r--r--src/game/SpellMgr.cpp18
5 files changed, 90 insertions, 46 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 51eea6ecc83..160c32e5f03 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1620,4 +1620,16 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
z = GetPositionZ();
UpdateGroundPositionZ(x,y,z);
-} \ No newline at end of file
+}
+
+void WorldObject::GetClosePointAt(float &x, float &y, float &z, float dist, float angle)
+{
+ angle += GetOrientation();
+ x += dist * cos(angle);
+ y += dist * sin(angle);
+ Trinity::NormalizeMapCoord(x);
+ Trinity::NormalizeMapCoord(y);
+ UpdateGroundPositionZ(x, y, z);
+}
+
+
diff --git a/src/game/Object.h b/src/game/Object.h
index 6b98f50bc65..9314b032f18 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -394,6 +394,12 @@ class TRINITY_DLL_SPEC WorldObject : public Object
// angle calculated from current orientation
GetNearPoint(NULL,x,y,z,size,distance2d,GetOrientation() + angle);
}
+ void GetClosePointAt(float &x, float &y, float &z, float dist, float angle);
+ void GetClosePoint(float &x, float &y, float &z, float dist, float angle)
+ {
+ GetPosition(x, y, z);
+ GetClosePointAt(x, y, z, dist, angle);
+ }
void GetContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const
{
// angle to face `obj` to `this` using distance includes size of `obj`
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index 07840998cf2..7fd985149ac 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -882,23 +882,33 @@ enum Targets
TARGET_DEST_TARGET_BACK = 65, // uses in teleport behind spells
TARGET_DEST_TARGET_RIGHT = 66,
TARGET_DEST_TARGET_LEFT = 67,
- TARGET_DEST_TARGET_ENEMY_UNKNOWN2 = 70,
+ TARGET_DEST_TARGET_FRONT_LEFT = 68,
+ TARGET_DEST_TARGET_BACK_LEFT = 69,
+ TARGET_DEST_TARGET_BACK_RIGHT = 70,
+ TARGET_DEST_TARGET_FRONT_RIGHT = 71,
TARGET_DEST_CASTER_RANDOM = 72,
TARGET_DEST_CASTER_RADIUS = 73,
TARGET_DEST_TARGET_RANDOM = 74,
TARGET_DEST_TARGET_RADIUS = 75,
TARGET_DEST_CHANNEL = 76,
- TARGET_SINGLE_ENEMY = 77,
TARGET_UNIT_CHANNEL = 77,
- TARGET_DEST_CASTER_FRONT_UNKNOWN = 78,
- TARGET_DEST_TABLE_UNKNOWN2 = 80,
+ TARGET_DEST_DEST_FRONT = 78,
+ TARGET_DEST_DEST_BACK = 79,
+ TARGET_DEST_DEST_RIGHT = 80,
+ TARGET_DEST_DEST_LEFT = 81,
+ TARGET_DEST_DEST_FRONT_LEFT = 82,
+ TARGET_DEST_DEST_BACK_LEFT = 83,
+ TARGET_DEST_DEST_BACK_RIGHT = 84,
+ TARGET_DEST_DEST_FRONT_RIGHT = 85,
TARGET_DEST_DEST_RANDOM = 86,
TARGET_DEST_DEST = 87,
TARGET_UNIT_AREA_ALL_CHANNEL = 88,
+ TARGET_DEST_TRAJ = 89,
TARGET_UNIT_MINIPET = 90,
+ TARGET_CORPSE_AREA_ENEMY_PLAYER = 93,
};
-#define TOTAL_SPELL_TARGETS 91
+#define TOTAL_SPELL_TARGETS 94
enum SpellMissInfo
{
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index d48550def0c..c5d6e748668 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -1641,7 +1641,6 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
AddItemTarget(m_targets.getItemTarget(), i);
}break;
- case TARGET_DEST_TABLE_UNKNOWN2:
case TARGET_TABLE_X_Y_Z_COORDINATES:
if(SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id))
{
@@ -1890,15 +1889,12 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
float x, y, z, angle, dist;
- if (m_spellInfo->EffectRadiusIndex[i])
- dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
- else
- dist = 3.0f;//do we need this?
- if (cur == TARGET_DEST_CASTER_RANDOM)
- dist *= rand_norm(); // This case we need to consider caster size
- else
- dist -= m_caster->GetObjectSize(); // Size is calculated in GetNearPoint(), but we do not need it
- //need a new function to remove this repeated work
+ float objSize = m_caster->GetObjectSize();
+ dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
+ if(dist < objSize)
+ dist = objSize;
+ else if(cur == TARGET_DEST_CASTER_RANDOM)
+ dist = objSize + (dist - objSize) * rand_norm();
switch(cur)
{
@@ -1908,7 +1904,6 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
case TARGET_DEST_CASTER_FRONT_RIGHT:angle = M_PI/4; break;
case TARGET_MINION:
case TARGET_DEST_CASTER_FRONT_LEAP:
- case TARGET_DEST_CASTER_FRONT_UNKNOWN:
case TARGET_DEST_CASTER_FRONT: angle = 0.0f; break;
case TARGET_DEST_CASTER_BACK: angle = M_PI; break;
case TARGET_DEST_CASTER_RIGHT: angle = M_PI/2; break;
@@ -1916,7 +1911,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
default: angle = rand_norm()*2*M_PI; break;
}
- m_caster->GetClosePoint(x, y, z, 0, dist, angle);
+ m_caster->GetClosePoint(x, y, z, dist, angle);
m_targets.setDestination(x, y, z); // do not know if has ground visual
}break;
@@ -1942,15 +1937,12 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
float x, y, z, angle, dist;
- if (m_spellInfo->EffectRadiusIndex[i])
- dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
- else
- dist = 3.0f;//do we need this?
- if (cur == TARGET_DEST_TARGET_RANDOM)
- dist *= rand_norm(); // This case we need to consider caster size
- else
- dist -= target->GetObjectSize(); // Size is calculated in GetNearPoint(), but we do not need it
- //need a new function to remove this repeated work
+ float objSize = target->GetObjectSize();
+ dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
+ if(dist < objSize)
+ dist = objSize;
+ else if(cur == TARGET_DEST_CASTER_RANDOM)
+ dist = objSize + (dist - objSize) * rand_norm();
switch(cur)
{
@@ -1958,10 +1950,14 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
case TARGET_DEST_TARGET_BACK: angle = M_PI; break;
case TARGET_DEST_TARGET_RIGHT: angle = M_PI/2; break;
case TARGET_DEST_TARGET_LEFT: angle = -M_PI/2; break;
+ case TARGET_DEST_TARGET_FRONT_LEFT: angle = -M_PI/4; break;
+ case TARGET_DEST_TARGET_BACK_LEFT: angle = -3*M_PI/4; break;
+ case TARGET_DEST_TARGET_BACK_RIGHT: angle = 3*M_PI/4; break;
+ case TARGET_DEST_TARGET_FRONT_RIGHT:angle = M_PI/4; break;
default: angle = rand_norm()*2*M_PI; break;
}
- target->GetClosePoint(x, y, z, 0, dist, angle);
+ target->GetClosePoint(x, y, z, dist, angle);
m_targets.setDestination(x, y, z); // do not know if has ground visual
}break;
@@ -1973,23 +1969,33 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
break;
}
+ if(cur == TARGET_DEST_DEST)
+ break;
+
+ float x, y, z, angle, dist;
+
+ dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
+ if (cur == TARGET_DEST_DEST_RANDOM)
+ dist *= rand_norm();
+
switch(cur)
{
- case TARGET_DEST_DEST_RANDOM:
- {
-
- float x, y, z, dist, px, py, pz;
- dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
- x = m_targets.m_destX;
- y = m_targets.m_destY;
- z = m_targets.m_destZ;
- m_caster->GetRandomPoint(x, y, z, dist, px, py, pz);
- m_targets.setDestination(px, py, pz);
- }
- break;
- case TARGET_DEST_DEST:
- break;
+ case TARGET_DEST_DEST_FRONT: angle = 0.0f; break;
+ case TARGET_DEST_DEST_BACK: angle = M_PI; break;
+ case TARGET_DEST_DEST_RIGHT: angle = M_PI/2; break;
+ case TARGET_DEST_DEST_LEFT: angle = -M_PI/2; break;
+ case TARGET_DEST_DEST_FRONT_LEFT: angle = -M_PI/4; break;
+ case TARGET_DEST_DEST_BACK_LEFT: angle = -3*M_PI/4; break;
+ case TARGET_DEST_DEST_BACK_RIGHT: angle = 3*M_PI/4; break;
+ case TARGET_DEST_DEST_FRONT_RIGHT:angle = M_PI/4; break;
+ default: angle = rand_norm()*2*M_PI; break;
}
+
+ x = m_targets.m_destX;
+ y = m_targets.m_destY;
+ z = m_targets.m_destZ;
+ m_caster->GetClosePointAt(x, y, z, dist, angle);
+ m_targets.setDestination(x, y, z); // do not know if has ground visual
}break;
default:
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 87efc32952a..91da024b111 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -126,11 +126,14 @@ SpellMgr::SpellMgr()
SpellTargetType[i] = TARGET_TYPE_AREA_DEST;
break;
case TARGET_DEST_TARGET_ENEMY:
- case TARGET_DEST_TARGET_ENEMY_UNKNOWN:
case TARGET_DEST_TARGET_FRONT:
case TARGET_DEST_TARGET_BACK:
case TARGET_DEST_TARGET_RIGHT:
case TARGET_DEST_TARGET_LEFT:
+ case TARGET_DEST_TARGET_FRONT_LEFT:
+ case TARGET_DEST_TARGET_BACK_LEFT:
+ case TARGET_DEST_TARGET_BACK_RIGHT:
+ case TARGET_DEST_TARGET_FRONT_RIGHT:
case TARGET_DEST_TARGET_RANDOM:
case TARGET_DEST_TARGET_RADIUS:
SpellTargetType[i] = TARGET_TYPE_DEST_TARGET;
@@ -144,7 +147,6 @@ SpellMgr::SpellMgr()
case TARGET_DEST_CASTER_FRONT:
case TARGET_MINION:
case TARGET_DEST_CASTER_FRONT_LEAP:
- case TARGET_DEST_CASTER_FRONT_UNKNOWN:
case TARGET_DEST_CASTER_BACK:
case TARGET_DEST_CASTER_RIGHT:
case TARGET_DEST_CASTER_LEFT:
@@ -152,8 +154,16 @@ SpellMgr::SpellMgr()
case TARGET_DEST_CASTER_RADIUS:
SpellTargetType[i] = TARGET_TYPE_DEST_CASTER;
break;
- case TARGET_DEST_DEST_RANDOM:
case TARGET_DEST_DEST:
+ case TARGET_DEST_DEST_FRONT_LEFT:
+ case TARGET_DEST_DEST_BACK_LEFT:
+ case TARGET_DEST_DEST_BACK_RIGHT:
+ case TARGET_DEST_DEST_FRONT_RIGHT:
+ case TARGET_DEST_DEST_FRONT:
+ case TARGET_DEST_DEST_BACK:
+ case TARGET_DEST_DEST_RIGHT:
+ case TARGET_DEST_DEST_LEFT:
+ case TARGET_DEST_DEST_RANDOM:
SpellTargetType[i] = TARGET_TYPE_DEST_DEST;
break;
default:
@@ -469,7 +479,7 @@ bool IsPositiveTarget(uint32 targetA, uint32 targetB)
case TARGET_IN_FRONT_OF_CASTER:
case TARGET_ALL_ENEMY_IN_AREA_CHANNELED:
case TARGET_CURRENT_ENEMY_COORDINATES:
- case TARGET_SINGLE_ENEMY:
+ case TARGET_UNIT_CHANNEL:
return false;
case TARGET_ALL_AROUND_CASTER:
return (targetB == TARGET_ALL_PARTY || targetB == TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER);