Flight
2012-04-08 08:46:24
Hi there,
So this concept has crossed most of our minds but it seems no one has really worked towards this, but what if we could monitor UpText while the mouse is still moving?
I've seen quite a few posts of people saying it couldn't be done because of the fact Simba is not multi-threaded? Well that may be, but we can come mighty close to getting the same results.
Many of you know the advantage of having a function that searches for UpText while the mouse is still in movement; I'm sure alot of you know where I'm going with this. On the other hand, it's not much of a gain, but should it work successfully than our mouse movements are one step closer to human, no?
Right now, every script that searches for a moving on-screen object, like an NPC, will statically move to a generated coordinate and then check/wait for an UpText or array of UpText. But what happens if that object moves position while the mouse has already been told where to move and is moving? Then we've failed to find that object while a normal human would never miss.
An example of NPC-finding:
1. [NPC is at on-screen coordinate Point(250, 175)]
Normal scripts would begin to move the mouse to this coordinate, and while until the mouse has reached the coordinate, nothing else is checked nor updated.
2. [NPC changes location to coordinate Point(150, 90)]
A dynamic UpText searching function will constantly monitor the UpText for each mouse 'step' from the origin to the destination. So if the NPC moves location but is still within the path of the mouse, the function could detect the UpText, all the way until the destination is reached. Should the UpText be found before the destination is reached then we could tell the script to do something else. Cancel the mouse-movement and left/right click perhaps?
I was tweaking around with this and I believe I have it working just how I want it now. What I do is stand beside the Castle Wars bank chest and move the mouse from, roughly, 200 "Y's" above the chest down to 200 "Y's" below the chest. If the UpText string array of "['Use', 'Bank', 'hest']" is found within that mouse path, the script will right-click. I've done everything I could think of to speed up the response time while retaining a human delay.
Here's what I've come to so far:
If you'd like to see it for yourself, stand beside the Castle Wars bank chest and run the script. Run it first as is, then change line 175 to this (below) and run it a second time:
Anywho, I'm guessing most people would regard this as "not worth it", which is fine, but if anyone is interested in the idea please do share some comments and suggestions. You understand the concept here, it's not just limited to checking UpText, we can constantly search for colors at a certain coordinate while the mouse is moving as well; anything we want.
So this concept has crossed most of our minds but it seems no one has really worked towards this, but what if we could monitor UpText while the mouse is still moving?
I've seen quite a few posts of people saying it couldn't be done because of the fact Simba is not multi-threaded? Well that may be, but we can come mighty close to getting the same results.
Many of you know the advantage of having a function that searches for UpText while the mouse is still in movement; I'm sure alot of you know where I'm going with this. On the other hand, it's not much of a gain, but should it work successfully than our mouse movements are one step closer to human, no?
Right now, every script that searches for a moving on-screen object, like an NPC, will statically move to a generated coordinate and then check/wait for an UpText or array of UpText. But what happens if that object moves position while the mouse has already been told where to move and is moving? Then we've failed to find that object while a normal human would never miss.
An example of NPC-finding:
1. [NPC is at on-screen coordinate Point(250, 175)]
Normal scripts would begin to move the mouse to this coordinate, and while until the mouse has reached the coordinate, nothing else is checked nor updated.
2. [NPC changes location to coordinate Point(150, 90)]
A dynamic UpText searching function will constantly monitor the UpText for each mouse 'step' from the origin to the destination. So if the NPC moves location but is still within the path of the mouse, the function could detect the UpText, all the way until the destination is reached. Should the UpText be found before the destination is reached then we could tell the script to do something else. Cancel the mouse-movement and left/right click perhaps?
I was tweaking around with this and I believe I have it working just how I want it now. What I do is stand beside the Castle Wars bank chest and move the mouse from, roughly, 200 "Y's" above the chest down to 200 "Y's" below the chest. If the UpText string array of "['Use', 'Bank', 'hest']" is found within that mouse path, the script will right-click. I've done everything I could think of to speed up the response time while retaining a human delay.
Here's what I've come to so far:
program New;
{$DEFINE SMART}
{$i SRL/srl.simba}
function IsUpTextReMutli(DaText: TStringArray): Boolean;
var
TheText: string;
i, n: Integer;
begin
TheText := GetUpText;
n := High(DaText);
for i := 0 to n do
if ExecRegExpr(DaText[i], TheText) then
begin
Result := True;
Exit;
end;
end;
procedure FastClick(button: variant);
var
a,b,c : integer;
iButton: Integer;
begin
if (button) then
iButton := mouse_left
else
iButton := mouse_right;
GetMousePos(b, c);
HoldMouse(b, c, iButton);
for a := 0 to 2 do
Wait(20 + Random(30));
GetMousePos(b, c);
ReleaseMouse(b, c, iButton);
end;
{
-Spline by BenLand100
-Shift speed every mouse step
-Search for an uptext string array while the mouse is in movement
-Left or right click if uptext is found
}
Function DynamicWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, targetArea: extended;
Text: TStringArray; LClick: Boolean): Boolean;
var
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,step: extended;
lastX,lastY,MSP,W,maxStep: integer;
sqrt2,sqrt3,sqrt5: extended;
begin
MSP := MouseSpeed;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
repeat
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
maxStep := (RandomRange(7, 11)); //I've decreased the maxStep so we have more steps along our path
//This means a higher chance of finding our UpText
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
if (Length(Text) > 0) then //Only if we're searching for text
begin
if IsUpTextReMutli(Text) then
begin
FastClick(LClick);
Result := True;
Exit;
end;
case Random(50) of
1..25: W := (MSP + (Random((MSP/4))));
26..50: W := (MSP - (RandomRange((MSP/2), MSP-1)));
end;
if (W < 1) then
W := 1;
wait(W);
end else
begin
case Random(50) of
1..25: W := (MSP + (Random((MSP/4))));
26..50: W := (MSP - (RandomRange((MSP/2), MSP-1)));
end;
if (W < 1) then
W := 1;
wait(W);
end;
step:= hypot(xs - lastX, ys - lastY);
lastdist:= dist;
until(hypot(xs - xe, ys - ye) < 1)
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));
MouseSpeed := MSP;
end;
Procedure HumanMMouse(eX, eY, ranX, ranY: Integer; Text: TStringArray; LClick: Boolean);
var
randSpeed: extended;
X,Y,X2,Y2,A,Dist,MP: integer;
begin
A := MouseSpeed;
GetMousePos(X, Y);
Dist := Distance(X, Y, eX, eY);
MP := Round(Dist/150);
if MP < 0 then
MP := 1;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
X2 := RandomRange(eX-(A*MP), eX+(A*MP));
Y2 := RandomRange(eY-(A*MP), eY+(A*MP));
if DynamicWindMouse(X, Y, X2, Y2, 9, 5, 10.0 / randSpeed, 15.0 / randSpeed, 10.0 * randSpeed, Text, LClick) then
Exit;
GetMousePos(X, Y);
MMouse(eX, eY, ranX, ranY);
MouseSpeed := A;
end;
begin
Smart_Server := 86;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
setupSRL();
ClickNorth(SRL_Angle_High);
MouseSpeed := 20; //I like 15-25 (My formula is actually backwards, high # = slower)
MMouse(300, 120, 5, 15); //Move the mouse above the chest
Wait(RandomRange(1000, 1400));
HumanMMouse(300, 300, 5, 15, ['Use', 'Bank', 'hest'], False); //Anywhere below the chest
end.
If you'd like to see it for yourself, stand beside the Castle Wars bank chest and run the script. Run it first as is, then change line 175 to this (below) and run it a second time:
HumanMMouse(300, 300, 5, 15, [], False);
The empty array means we don't search for text, and this would mimic the normal mouse-movement.Anywho, I'm guessing most people would regard this as "not worth it", which is fine, but if anyone is interested in the idea please do share some comments and suggestions. You understand the concept here, it's not just limited to checking UpText, we can constantly search for colors at a certain coordinate while the mouse is moving as well; anything we want.