[10529] Water level in movement use fixes.

* Move selection allowed upper and lower heights for target point
  into near point core function used for contact/close point selection.
  Selection base at possibility target point searcher fly/swim(or walk by water bottom).
* Use vamp water level data so have proper water level in instances in movements.
* Use increased ground search distance for water level case.
This commit is contained in:
VladimirMangos 2010-09-25 07:31:29 +04:00
parent f92518ee14
commit 2170c9c919
13 changed files with 171 additions and 41 deletions

View file

@ -1436,6 +1436,70 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface
}
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
{
switch (GetTypeId())
{
case TYPEID_UNIT:
{
// non fly unit don't must be in air
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
if (!((Creature const*)this)->canFly())
{
bool canSwim = ((Creature const*)this)->canSwim();
float ground_z = z;
float max_z = canSwim
? GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK))
: ((ground_z = GetBaseMap()->GetHeight(x, y, z, true)));
if (max_z > INVALID_HEIGHT)
{
if (z > max_z)
z = max_z;
else if (z < ground_z)
z = ground_z;
}
}
else
{
float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
if (z < ground_z)
z = ground_z;
}
break;
}
case TYPEID_PLAYER:
{
// for server controlled moves playr work same as creature (but it can always swim)
if (!((Player const*)this)->CanFly())
{
float ground_z = z;
float max_z = GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK));
if (max_z > INVALID_HEIGHT)
{
if (z > max_z)
z = max_z;
else if (z < ground_z)
z = ground_z;
}
}
else
{
float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
if (z < ground_z)
z = ground_z;
}
break;
}
default:
{
float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
if(ground_z > INVALID_HEIGHT)
z = ground_z;
break;
}
}
}
bool WorldObject::IsPositionValid() const
{
return MaNGOS::IsValidMapCoord(m_positionX,m_positionY,m_positionZ,m_orientation);
@ -1759,7 +1823,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
// if detection disabled, return first point
if(!sWorld.getConfig(CONFIG_BOOL_DETECT_POS_COLLISION))
{
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
return;
}
@ -1782,7 +1849,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
// maybe can just place in primary position
if( selector.CheckOriginal() )
{
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
if(IsWithinLOS(x,y,z))
return;
@ -1797,7 +1867,11 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
{
GetNearPoint2D(x,y,distance2d,absAngle+angle);
z = GetPositionZ();
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
if(IsWithinLOS(x,y,z))
return;
@ -1811,7 +1885,11 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
{
GetNearPoint2D(x,y,distance2d,absAngle+angle);
z = GetPositionZ();
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
if(IsWithinLOS(x,y,z))
return;
@ -1825,7 +1903,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
x = first_x;
y = first_y;
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
return;
}
@ -1836,7 +1917,11 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
{
GetNearPoint2D(x,y,distance2d,absAngle+angle);
z = GetPositionZ();
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
if(IsWithinLOS(x,y,z))
return;
@ -1851,7 +1936,11 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
{
GetNearPoint2D(x,y,distance2d,absAngle+angle);
z = GetPositionZ();
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
if(IsWithinLOS(x,y,z))
return;
@ -1861,7 +1950,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
x = first_x;
y = first_y;
UpdateGroundPositionZ(x,y,z); // update to LOS height if available
if (searcher)
searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available
else
UpdateGroundPositionZ(x,y,z);
}
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
@ -1963,5 +2055,4 @@ bool WorldObject::IsControlledByPlayer() const
default:
return false;
}
}
}