*Fix Creature::FallGround. By Silver1ce.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-16 19:05:30 -06:00
parent 6a66df09eb
commit ba4338783a
3 changed files with 27 additions and 7 deletions
+6 -7
View File
@@ -1676,16 +1676,15 @@ bool Creature::FallGround()
if (getDeathState() == DEAD_FALLING)
return false;
// Let's do with no vmap because no way to get far distance with vmap high call
float tz = GetMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), false);
// Abort too if the ground is very near
if (fabs(GetPositionZ() - tz) < 0.1f)
float x, y, z;
GetPosition(x, y, z);
float ground_Z = GetMap()->GetVmapHeight(x, y, z, true);
if (fabs(ground_Z - z) < 0.1f)
return false;
Unit::setDeathState(DEAD_FALLING);
GetMotionMaster()->MovePoint(0, GetPositionX(), GetPositionY(), tz);
Relocate(GetPositionX(), GetPositionY(), tz);
GetMotionMaster()->MovePoint(0, x, y, ground_Z);
Relocate(x, y, ground_Z);
return true;
}
+20
View File
@@ -1265,6 +1265,26 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
}
}
float Map::GetVmapHeight(float x, float y, float z, bool useMaps) const
{
float mapHeight;
float vmapHeight;
if (useMaps)
{
mapHeight = GetHeight(x, y, z, false);
if (fabs(mapHeight - z) < 0.1)
return mapHeight;
}
else
mapHeight = INVALID_HEIGHT;
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
if (vmgr->isLineOfSightCalcEnabled())
bool result = vmgr->getObjectHitPos(GetId(), x, y, z + 2.0f, x, y, mapHeight, x, y, vmapHeight, 0);
else
return INVALID_HEIGHT;
return vmapHeight;
}
uint16 Map::GetAreaFlag(float x, float y ) const
{
//local x,y coords
+1
View File
@@ -183,6 +183,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
// some calls like isInWater should not use vmaps due to processor power
// can return INVALID_HEIGHT if under z+2 z coord not found height
float GetHeight(float x, float y, float z, bool pCheckVMap=true) const;
float GetVmapHeight(float x, float y, float z, bool useMaps) const;
bool IsInWater(float x, float y, float z) const; // does not use z pos. This is for future use
uint16 GetAreaFlag(float x, float y ) const;