there you go (copied from MMod by Avarax)
function Aim(const X1,Y1,X2,Y2: single) : single;
begin
if (X2 - X1)<>0 then begin
if X1 > X2 then
result:= arctan((y2 - y1) / (x2 - x1)) + Pi
else
result:= arctan((y2 - y1) / (x2 - x1));
end
else begin
if Y2 > Y1 then result:= Pi/2 + Pi/4;
if Y2 < Y1 then result:= -Pi/2 + Pi/4;
end;
end;
procedure Shoot(const X1,Y1,X2,Y2,speed,power,decentralize,accuracy: single; const owner,style: byte);
var AccuracyMarginal: integer;
angle: single;
begin
If Accuracy < 100 then
AccuracyMarginal:=round((100 - Accuracy) / 100 * 3600)
else
AccuracyMarginal:=0;
angle:=Aim(X1,Y1,X2,Y2);
CreateBullet(X1+decentralize*cos(angle),Y1+decentralize*sin(angle),cos(angle + deg2rad(random(-AccuracyMarginal,AccuracyMarginal) / 10))*speed,sin(angle + deg2rad(random(-AccuracyMarginal,AccuracyMarginal) / 10))*speed,power,style,owner);
end;