Quote:
Originally Posted by jimaway
unfortunately that will fail when the player is on/over an edge of a higher point
|
Good thinking.
To fix Connor's:
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, end, IGNORE_MONSTERS, HULL_HUMAN, id, ptr);
new Float:distance;
get_tr2(ptr, TR_flFraction, distance);
free_tr2(ptr);
distance *= 9999.0;
return distance;
}
__________________