I replaced that code with this function:
float GetDistanceForClimbing(object oPC, location lLoc)
{
object oArea = GetAreaFromLocation(lLoc);
vector vTest1 = GetPositionFromLocation(GetLocation(oPC));
vector vTest2 = GetPositionFromLocation(lLoc);
float fDistance = GetDistanceBetweenLocations(Location(oArea, Vector(vTest1.x, vTest1.y, 0.0), 0.0),
Location(oArea, Vector(vTest2.x, vTest2.y, 0.0), 0.0));
return MetersToFeet(fDistance);
}
As you can see it sets Z coordinates for both locations to 0.0 and then gets the distance. I've attached a script that uses this function.