I know that engine doesn't use same hull as dll for crouch players. But i've seen that dll has a way to tell the engine which hulls it is using.
So, finally, don't know if with TraceHull engine uses correct hull when player is crouched.
So, do as if player was not crouched, can be a problem if player is right under a ceil.
PHP Code:
Float:distance_to_ground( id )
{
new Float:start[3], Float:end[3], bool:bDucking;
entity_get_vector(id, EV_VEC_origin, start);
bDucking = !!(entity_get_int(id, EV_INT_flags) & FL_DUCKING);
if( bDucking )
{
start[2] += 18.0;
}
end[0] = start[0];
end[1] = start[1];
end[2] = start[2] - 9999.0;
new ptr = create_tr2();
engfunc(EngFunc_TraceHull, start, dest, IGNORE_MONSTERS, HULL_HUMAN, id, ptr);
new Float:distance;
get_tr2(ptr, TR_flFraction, distance);
free_tr2(ptr);
if( distance < 1.0 )
{
distance *= 9999.0;
if( bDucking )
{
distance -= 18.0;
return distance;
}
}
return -1.0
}
__________________