aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/Creature.cpp13
-rw-r--r--src/game/Map.cpp20
-rw-r--r--src/game/Map.h1
3 files changed, 27 insertions, 7 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 226d2e97ebb..6ad520407cd 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -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;
}
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 3958f0ea8bf..d9971518bf3 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -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
diff --git a/src/game/Map.h b/src/game/Map.h
index 25caa758ae9..9c06ac3fa47 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -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;