SRL Archive - SRL Archives

TargetMMouse - More human?


King of Knives

2007-11-18 15:48:19

I've had this idea for some time, but I first got to executing it today. It's very simple, and not very perfect at all.

I've been looking at myself while playing legitly, and what I've noticed is, that the closer my mouse is to my target, the slower and more shaky I move it, so I won't miss it.

So, basicly, this script will find the point of the current mouse-position in a number of circles with different radius'es, revolving from the mouse-target.

Say, you want to move to 100,50, and your current mouse-position is 50, 50. Easy to calculate; Your target is 90 degrees angle in a circle from the current mouseposition, and the radius is 50.

So, basicly (good word), this will calculate the angle of the targetpoint in a circle, then move to radius 50 and same angle, and slow down from there.

I think it looks more humanlike, but I don't know. Maybe it's just because my hand is a little shaky by nature. The downside, though, is that calculating the angle and radius is damn slow. 2-3 seconds if not more, usually.

I can't really explain it any more, but if anybody would try this and then comment it, I'd be happy.
—
Code:
 
program New;
{.include SRL/SRL.scar}


Function FFSAngle(Px,Py,Ox,Oy: Integer; var Radius: Integer): Integer;
var Cpx,Cpy,R,I: Integer;
begin
for R:= 800 downto 1 do
begin
for I:= 0 to 359 do
begin
Cpx:= Round(R*Sin(Radians(I)))+Ox;
Cpy:= Round(-R*Cos(Radians(I)))+Oy;
if PointInBox(IntToPoint(Px,Py),IntToBox(Cpx-1,Cpy-1,Cpx+1,Cpy+1)) then
begin
Result:= I;
Radius:= R;
Exit;
end;
end;
end;
end;

Procedure TargetMMouse(ax,bx,rx,ry: Integer);
var x,y,a,b,R,Ang,Rad,TM,RCount,Cx,Cy: Integer;
begin
TM:= MouseSpeed;
GetMousePos(x,y)
A:= Ax+random(Rx)
B:= Bx+random(Ry)
Ang:= FFSAngle(x,y,a,b,R)
Writeln('Radius is '+IntToStr(R))
Writeln('Angle is '+IntToStr(Ang))
if (R < 51) then
begin
MMouse(a,b,0,0)
MouseSpeed:= Randomize(TM,2)
end else
begin
Rad:= Randomize(50,3)
MouseSpeed:= Randomize(8,1)
Cx:= Round(Rad*Sin(Radians(Ang)))+A;
Cy:= Round(-Rad*Cos(Radians(Ang)))+B;
MMouse(Cx,Cy,2,2)
RCount:= 40;
repeat
MouseSpeed:= Randomize((RCount/10)+3,1)
Rad:= Randomize(RCount,3)
Cx:= Round(Rad*Sin(Radians(Ang)))+A;
Cy:= Round(-Rad*Cos(Radians(Ang)))+B;
Writeln('Setting Mousespeed to '+IntToStr(MouseSpeed))
MMouse(Cx,Cy,2,2)
RCount:= RCount - 10;
until(RCount = 0)
MMouse(a,b,0,0)
MouseSpeed:= Randomize(TM,2)
end;
end;

begin
SetupSRL;
TargetMMouse(1073, 81,5,5)
end.

PS: Don't hold the mouse more than 600 pixels from the target. That will make the whole thing useless.

Ty,
-Knives

Macrosoft

2007-11-18 16:57:01

really cool idea!!!!!!I never thought of that!

Works great!

mastaraymond

2007-11-18 17:11:37

Funny one ^.^

Macrosoft

2007-11-18 21:15:23

check this out:

program New;
{.include SRL/SRL.scar}


Function FFSAngle(Px,Py,Ox,Oy: Integer; var Radius: Integer): Integer;
var Cpx,Cpy,R,I: Integer;
begin
for R:= 800 downto 1 do
begin
for I:= 0 to 359 do
begin
Cpx:= Round(R*Sin(Radians(I)))+Ox;
Cpy:= Round(-R*Cos(Radians(I)))+Oy;
if PointInBox(IntToPoint(Px,Py),IntToBox(Cpx-1,Cpy-1,Cpx+1,Cpy+1)) then
begin
Result:= I;
Radius:= R;
Exit;
end;
end;
end;
end;

Procedure TargetMMouse(ax,bx,rx,ry: Integer);
var x,y,a,b,R,Ang,Rad,TM,RCount,Cx,Cy: Integer;
begin
TM:= MouseSpeed;
GetMousePos(x,y)
A:= Ax+random(Rx)
B:= Bx+random(Ry)
Ang:= FFSAngle(x,y,a,b,R)
Writeln('Radius is '+IntToStr(R))
Writeln('Angle is '+IntToStr(Ang))
if (R < 51) then
begin
MMouse(a,b,0,0)
MouseSpeed:= Randomize(TM,2)
end else
begin
Rad:= Randomize(50,3)
MouseSpeed:= Randomize(8,1)
Cx:= Round(Rad*Sin(Radians(Ang)))+A;
Cy:= Round(-Rad*Cos(Radians(Ang)))+B;
MMouse(Cx,Cy,2,2)
RCount:= 40;
repeat
MouseSpeed:= Randomize((RCount/10)+3,1)
Rad:= Randomize(RCount,3)
Cx:= Round(Rad*Sin(Radians(Ang)))+A;
Cy:= Round(-Rad*Cos(Radians(Ang)))+B;
Writeln('Setting Mousespeed to '+IntToStr(MouseSpeed))
MMouse(Cx,Cy,2,2)
RCount:= RCount - 10;
until(RCount = 0)
MMouse(a,b,0,0)
MouseSpeed:= Randomize(TM,2)
end;
end;

Function Dist(int1, int2: Integer): Integer;
begin
if (int1 <= int2)then
result:= int2 - int1
else
result:= int1 - int2;
end;

{*******************************************************************************
Procedure TargetMPMouse(ax, bx, rx, ry, Frequency: Integer);
By: Macrosoft and King of Knives
Description: This will move the mouse to point (ax, bx) with a random of
rx, ry. If the mouse unless the distance from the current position to
(ax, bx) is greater than or equal to MinLength, it will act as if you
picked up your mouse to reset it on the mouse pad. Frequency is the
frequency that the mouse is "picked up and reset," provided that the
distance the mouse has to move is high enough.
*******************************************************************************}
procedure TargetMPMouse(ax, ay, rx, ry, MinLength, Frequency: Integer);
var
i, x, y, bx, by, cx, cy, Dis: Integer;
begin
GetMousePos(x, y);
bx:= Randomize(ax, rx);
by:= Randomize(ay, ry);
Dis:= Distance(x, y, bx, by);
if(Dis >= MinLength) then
begin
i:= Random(Frequency);
if(i=0)then
begin
cx:= Round((x + bx)/2) + Random(Round(Dist(x, bx)/10));
cy:= Round((y + by)/2) + Random(Round(Dist(y, by)/10));
MMouse(cx, cy, 0, 0);
PickUpMouse;
TargetMMouse(bx, by, 0, 0);
end else
TargetMMouse(bx, by, 0, 0);
end else
TargetMMouse(bx, by, 0, 0);
end;

begin
SetupSRL;
TargetMPMouse(0, 0, 0, 0, 100, 0);
end.

waits a long time before it does the second part. I think we need to speed TargetMMouse up a bit because thats its loading time

danrox2004

2007-11-18 22:49:59

You can use trig to find the angle much quicker, something like this should work where sx and sy and the starting point and ex and ey are the end point:

angle := degrees(arcTan2(ex - sx, ey - sy));

Also for Dist something like this should work:
dist := abs(int1-int2);

Santa_Clause

2007-11-18 23:06:49

Dist is already in SCAR…

Macrosoft

2007-11-18 23:30:16

From: danrox2004
You can use trig to find the angle much quicker, something like this should work where sx and sy and the starting point and ex and ey are the end point:

angle := degrees(arcTan2(ex - sx, ey - sy));

Also for Dist something like this should work:
dist := abs(int1-int2);


yep, got the dist thing

Im in 8th grade (9th grade math) soooo, trig = False