http://villavu.com/forum/showthread.php?t=59944More specifically:
{===============================================================================
function InfGM_GaussFunction : Integer;
By: Cstrike
Acts as a gaussian function. Is a pre-determined one for easy on-the-fly result.
===============================================================================}
function InfGM_GaussFunction : Integer;
var coefficient : Integer;
begin
case random(30) of
0: coefficient := 100;
1: coefficient := 99;
2: coefficient := 97;
3: coefficient := 96;
4: coefficient := 92;
5: coefficient := 91;
6: coefficient := 88;
7: coefficient := 87;
8: coefficient := 84;
9: coefficient := 82;
10: coefficient := 80;
11: coefficient := 78;
12: coefficient := 74;
13: coefficient := 72;
14: coefficient := 69;
15: coefficient := 67;
16: coefficient := 64;
17: coefficient := 62;
18: coefficient := 60;
19: coefficient := 58;
20: coefficient := 54;
21: coefficient := 48;
22: coefficient := 46;
23: coefficient := 36;
24: coefficient := 28;
25: coefficient := 21;
26: coefficient := 16;
27: coefficient := 12;
28: coefficient := 7;
29: coefficient := 4;
30: coefficient := 0;
end;
result := 100-coefficient;
end;
{===============================================================================
function InfGM_GaussFunctionSmall : Integer;
By: Cstrike
See above, though if the mouse values are small this takes it into account.
===============================================================================}
function InfGM_GaussFunctionSmall : Integer;
var coefficient : Integer;
begin
case random(30) of
0: coefficient := 100;
1: coefficient := 98;
2: coefficient := 95;
3: coefficient := 92;
4: coefficient := 90;
5: coefficient := 85;
6: coefficient := 82;
7: coefficient := 80;
8: coefficient := 76;
9: coefficient := 74;
10: coefficient := 71;
11: coefficient := 68;
12: coefficient := 66;
13: coefficient := 64;
14: coefficient := 60;
15: coefficient := 67;
16: coefficient := 54;
17: coefficient := 52;
18: coefficient := 50;
19: coefficient := 48;
20: coefficient := 44;
21: coefficient := 40;
22: coefficient := 35;
23: coefficient := 30;
24: coefficient := 25;
25: coefficient := 21;
26: coefficient := 16;
27: coefficient := 12;
28: coefficient := 7;
29: coefficient := 4;
30: coefficient := 0;
end;
result := 100-coefficient;
end;
{===============================================================================
procedure InfGM_GMouse (x, y, xR, yR : Integer; LeftClick : Boolean);
By: Cstrike
Using the gaussian function, clicks mouse at center point and random deviates
both up/down/left/right from the center based on a random gaussian value.
Idea originally thought of to my knowledge by Xtensity. I didn't use this code
though, since I couldn't convert it to a useable format.
===============================================================================}
procedure InfGM_GMouse (x, y, xR, yR : Integer; LeftClick : Boolean);
var xP, yP, xnew, ynew, xpos, ypos : Integer;
begin
if (x < 5) then xP := InfGM_GaussFunctionSmall else xP := InfGM_GaussFunction;
if (y < 5) then yP := InfGM_GaussFunctionSmall else yP := InfGM_GaussFunction;
xnew := round((xR*xP)/100.0);
ynew := round((yR*yP)/100.0);
case random (5) of
0..2 : xpos := x + xnew;
3..5 : xpos := x - xnew;
end;
case random (5) of
0..2 : ypos := y + ynew;
3..5 : ypos := y - ynew;
end;
Mouse (xpos, ypos, 0, 0, LeftClick);
end;
{===============================================================================
procedure InfGM_GMMouse (x, y, xR, yR : Integer);
By: Cstrike
See InfGM_GMouse.
===============================================================================}
procedure InfGM_GMMouse (x, y, xR, yR : Integer);
var xP, yP, xnew, ynew, xpos, ypos : Integer;
begin
if (x < 5) then xP := InfGM_GaussFunctionSmall else xP := InfGM_GaussFunction;
if (y < 5) then yP := InfGM_GaussFunctionSmall else yP := InfGM_GaussFunction;
xnew := round((xR*xP)/100.0);
ynew := round((yR*yP)/100.0);
case random (5) of
0..2 : xpos := x + xnew;
3..5 : xpos := x - xnew;
end;
case random (5) of
0..2 : ypos := y + ynew;
3..5 : ypos := y - ynew;
end;
MMouse (xpos, ypos, 0, 0);
end;
{===============================================================================
function InfGM_GMouseFail (x, y, xMax, yMax, xOutsideBounds, yOutsideBounds : Integer) : Boolean;
By: Cstrike
Purposely fails to act human, then clicks in the specified range. Returns true
if left click, false if right click
===============================================================================}
function InfGM_GMouseFail (x, y, xMax, yMax, xOutsideBounds, yOutsideBounds : Integer) : Boolean;
var cx, cy, xP, yP, xnew, ynew, xpos, ypos : Integer;
begin
Result := False; // Guess it doesnt matter
if (x < 5) then xP := InfGM_GaussFunctionSmall else xP := InfGM_GaussFunction;
if (y < 5) then yP := InfGM_GaussFunctionSmall else yP := InfGM_GaussFunction;
xnew := round((xOutsideBounds*xP)/100.0);
ynew := round((yOutsideBounds*yP)/100.0);
case random (5) of
0..2 : xpos := x + xnew;
3..5 : xpos := x - xnew;
end;
case random (5) of
0..2 : ypos := y + ynew;
3..5 : ypos := y - ynew;
end;
// If were inside the normal range... [Need to fix this]
if (xpos <= xMax) and (ypos <= yMax) then
begin
Mouse (xpos, ypos, 0, 0, false) // Needs to be fixed to include -ve's
Result := False;
end else // else if were outside
begin
case random(11) of
0..3: begin
Mouse (xpos, ypos, 0, 0, true);
wait (55+random(53));
InfGM_GMouse (x, y, xMax, yMax, true);
Result := True;
end;
4..11: begin
Mouse (xpos, ypos, 0, 0, false);
wait (185+random(153));
GetMousePos(cx, cy);
MMouse (cx + RandomRange(70,130), cy + RandomRange(-150, 150), 0, 0);
wait (115+random(155));
InfGM_GMouse (x, y, xMax, yMax, false);
Result := False;
end;
end;
end;
end;
Permission was given by Cstrike upon his departure to use his code.