*Move target handling of TARGET_DEST_CASTER_FRONT_LEAP out of SPELL_EFFECT_LEAP handler, this fixes spells with SPELL_EFFECT_LEAP using other target types.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-07-21 02:06:51 +02:00
parent 1944cd17a1
commit dd89c54c6e
5 changed files with 65 additions and 45 deletions
@@ -2223,6 +2223,56 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
pos.m_orientation = m_orientation;
}
void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float angle)
{
angle += m_orientation;
float destx, desty, destz, ground, floor;
destx = pos.m_positionX + dist * cos(angle);
desty = pos.m_positionY + dist * sin(angle);
ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(),pos.m_positionX,pos.m_positionY,pos.m_positionZ+0.5f,destx,desty,destz+0.5f,destx,desty,destz,-0.5f);
// collision occured
if (col)
{
// move back a bit
destx -= CONTACT_DISTANCE * cos(angle);
desty -= CONTACT_DISTANCE * sin(angle);
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
}
float step = dist/10.0f;
int j = 0;
for (j; j < 10; j++)
{
// do not allow too big z changes
if (fabs(pos.m_positionZ - destz) > 6)
{
destx -= step * cos(angle);
desty -= step * sin(angle);
ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
}
// we have correct destz now
else
{
pos.Relocate(destx, desty, destz);
break;
}
}
Trinity::NormalizeMapCoord(pos.m_positionX);
Trinity::NormalizeMapCoord(pos.m_positionY);
UpdateGroundPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
pos.m_orientation = m_orientation;
}
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
{
m_phaseMask = newPhaseMask;