C++ Get Map Height Syntax

I’m a beginner trying to script a creature that keeps getting below groundlevel.

I want to code something like:

[CODE]if (me->GetPositionZ() != MapHeight()) //if creature is above or below the ground…

{

move to pos Z of the MapHeight(); //set its Z position to the ground level

}[/CODE]

Could anybody please provide me the piece of code?

float x = me->GetPositionX();
float y = me->GetPositionY();
float z = me->GetPositionZ();

float groundZ = me->GetMap()->GetHeight(x, y, z, true);
if (z > groundZ)
    me->MotionMaster()->MovePoint(0, x, y, groundZ);

something like that. didnt really understand what you are trying to do here, but Map::GetHeight is the function you are looking for.

[/CODE]

A simple example of what he’s trying to do: Workaround the bug on Val’kyrs NPC model when they are chasing someone on terrain.