im pretty sure its this bit
//follow mouse
x = mouse_x;
y = mouse_y;
and
if (d <= maxd)
not doing all situations you want. you want if the mouse is no where near the object that it follows mouse(or disapears?) if its withing a certain distance it locks on, if it is within the sprite it manually aims a little.
you need another bit then
//follow mouse
xx = mouse_x;
yy = mouse_y;
//stop here, if auto-aim is off
if(global.auto_aim==0)
{
x=xx;
y=yy;
exit;
}
//snap to ped? find a ped
var ins;
ins = instance_nearest(xx,yy, obj_peds)
if (ins != noone)
{
//distance to ped
var d;
d = point_distance(ins.x, ins.y, xx, yy);
//within snap 300 is way to big but I have no idea for you game. I would use the ped radius
var maxd;
maxd = 48;
//maxd = point_distance(ins.bbox_left, ins.bbox_top, ins.bbox_right, ins.bbox_bottom) / 2;
//snap on ped, but not right on it. On ped within the snap radius
if (d <= maxd*2)
{
var a;
a = point_direction(ins.x, ins.y, xx, yy);
x = ins.x + lengthdir_x(median(0, maxd, d), a);
y = ins.y + lengthdir_y(median(0, maxd, d), a);
}
}i think that will do what you want? if i understood the code(i dont have access to GM atm to test). i made it so the aim obj only follows the mouse directly if its within the sprite OR outside the range for auto aim(i put 2*mxd, as i think maxd is the sprite size? or half, so i thought youd want the mouse to lock on outside of the sprite). i think thats it... else his code needs to be changed