function Entity_gravity(var Dist2floor, var fallspeed, var resilience, ENTITY* ent)
{
VECTOR temp;
var range=0.2;//play with this
var current_height;
vec_set(temp.x, ent.x);
temp.z -= 10000;
current_height = c_trace(ent.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | GLIDE | IGNORE_PASSENTS);
if(current_height > Dist2floor+range)
{ent.z -= fallspeed * time_step;}
if(current_height < Dist2floor-range)
{ent.z += resilience*time_step;}
return current_height;
}