I'm trying to make a aimbot and failed.

I'm using Delphi 7 code is as follows:

in expos eyPos, ezPos. = Floats on the position of the enemy.
xPos, yPos, ZPOS. = My position

I have a OPK And it works very well, but failed to understand the aimbot.
code:

Code:

var
xPos,yPos,zPos,yawY,pitchX,exPos,eyPos,ezPos,distance:single;
begin
distance: = sqrt (
((Expos - xPos) * (Expos - xPos)) +
((eyPos - yPos) * (eyPos - yPos)) +
((ezPos - ZPOS) * (ezPos - ZPOS))
);


if (distance> 0.0) then
begin

pitchX: = Math.Arcsin ((ezPos - ZPOS) / distance) * 180 / PI;
baseaddress = $ 1029344; // mouseY
WriteProcessMemory (HandleWindow, ptr (baseaddress)pitchX, 4, write);

yawY: = -Math.ArcTan2 (expos - xPos, eyPos - yPos)/ Pi * 180 + 180;
baseaddress = $ 1029340; // mouseX
WriteProcessMemory (HandleWindow, ptr (baseaddress)yawY, 4, write);
end;
end;

Thanks for the help you can offer me.