Iam not so deep in this kind of functions and CVs is down. If someone has a better fix, do it. Iam here not sure about how it really works. int dist_att (int dir , object *ob, object *enemy, object *part, rv_vector *rv) { int dist; if (can_hit(part,enemy,rv)) return dir; if (rv->distance < 10) return absdir(dir+4); /* This was 81 below? That seems outragously far - I'm thinking that was * a typo and it shoud be 18 */ else if (dist>18) { ** <- dist has no valid value - so this will go funny random return dir; } return 0; } I'll changed this to else if (rv->distance>18) {