diff options
author | megamage <none@none> | 2009-01-16 19:05:30 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-01-16 19:05:30 -0600 |
commit | ba4338783abb39dcee772511a61d671e6c0256ab (patch) | |
tree | bf9c3c9a9c4f73803241d1092e8e1a8c408e90bb /src | |
parent | 6a66df09ebb158de53c947b1f4aa827ba2a942d0 (diff) |
*Fix Creature::FallGround. By Silver1ce.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Creature.cpp | 13 | ||||
-rw-r--r-- | src/game/Map.cpp | 20 | ||||
-rw-r--r-- | src/game/Map.h | 1 |
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; |