Okay my basic problem is this which appears in some cases:
Demo:
http://romania.g0dsoft.com/upload/bug.rar (29KB)
Code:
var temp_vec[3],temp_vecb[3];
vec_set(temp_vec,vector(-98,0,0));
vec_set(temp_vecb,vector(-108,0,0));
while(c_trace(temp_vecb,temp_vec,IGNORE_MODELS)==0)
{
vec_set(temp_vecb,temp_vec);
temp_vec[0]+=10;
ent_create("cube.mdl",temp_vec,NULL);
wait(-0.1);
}
But i already found a workaround. Instead of using c_content to check wether the target pos. is a block or not i can check trace_hit.
This solves a part of my problem (even though i have to do some ugly coding now)
So the basic problem was:
If i have a c_trace that accidentally exacly touches a wall the result is 0
And if start a new trace without checking tracehit the trace goes right through walls (This is i think a bug since the result is ==0)
Whats still left is:
I have a function that should find an empty space position in a certain area.
I planned to get the position by checking with c_content until i find a CONTENT_EMPTY position. But since c_content shouldnt be used anymore i need an alternative.
EDIT: This is what i use atm instead of c_content:
function _c_content(VECTOR* check_vec,trace_mode)
{
var temp_vec[3],val=1,dist,distb;
vec_set(temp_vec,check_vec);
temp_vec[0]-=val;
if(c_trace(temp_vec,check_vec,trace_mode)!=0)
return(1);
temp_vec[0]=check_vec.x+val;
if(c_trace(temp_vec,check_vec,trace_mode)!=0)
return(1);
temp_vec[0]=check_vec.x;
temp_vec[1]=check_vec.y-val;
if(c_trace(temp_vec,check_vec,trace_mode)!=0)
return(1);
temp_vec[1]=check_vec.y+val;
if(c_trace(temp_vec,check_vec,trace_mode)!=0)
return(1);
temp_vec[1]=check_vec.y;
temp_vec[2]=check_vec.z-val;
if(c_trace(temp_vec,check_vec,trace_mode)!=0)
return(1);
temp_vec[2]=check_vec.z+val;
if(c_trace(temp_vec,check_vec,trace_mode)!=0)
return(1);
return(0);
}
val shouldnt be smaller than 1 because then the function makes "mistakes"...