If the entity is lit (UNLIT flag not set), and the ground is a level floor and not a model or terrain, you could also check its floor_dist parameter.