Then debug the code (on your own), check critical values before calculation and the like.
Btw. this is how mouse_dir3d behaves:
void main()
{
fps_max = 60;
level_load(NULL);
camera.z = 512;
camera.tilt = -90;
mouse_mode = 4;
while(1)
{
DEBUG_VAR(mouse_dir3d.x,20);
DEBUG_VAR(mouse_dir3d.y,40);
DEBUG_VAR(mouse_dir3d.z,60);
wait(1);
}
}
You can try to add a "if(mouse_dir3d.z < 0) {...}" line around your mouse target calculation block.