You need vectors, so:
var ...[3]; !!
And this line is wrong:
detect_hit.x+=400;//detect 400 quants ahead of character
You are tracing into the wrong direction - always in X direction but the enemy can be everywhere! You must rotate the vector before:
temp.x = 400;
temp.y = 0;
temp.z = 0;
vec_rotate(temp,my.pan);
vec_add(detect_hit, temp);
understand what I mean?