Because you take in account distance to wall ?
Look at fm_get_aim_origin and just add punchangle to v_angle and see if you got same results.
Following stock is fm_get_user_origin with less native calls, but using trace_line make it automatically use IGNORE_MONSTER if you pass an index (DONT_IGNORE_MONSTER when you pass -1 as index), so if you want to pass index + DONT_IGNORE_MONSTER you need to use engfunc(), but i don't think you care about players in what you are doing.
PHP Code:
get_aim_origin(id, Float:origin[3])
{
new Float:dest[3];
entity_get_vector(id, EV_VEC_v_angle, origin);
entity_get_vector(id, EV_VEC_punchangle, dest);
xs_vec_add(origin, dest, dest);
angle_vector(dest, ANGLEVECTOR_FORWARD, dest);
xs_vec_mul_scalar(dest, 9999.0, dest); // you may adjust this according to weapon, as cs does
xs_vec_add(origin, dest, dest);
entity_get_vector(id, EV_VEC_origin, origin);
origin[2] += entity_get_int(id, EV_INT_flags) & FL_DUCKING ? 12.0 : 18.0;
trace_line(id, origin, dest, origin);
}
__________________