Camel
2015-01-30 18:08:48
I've been experimenting around with the mousing procedure we all use. I've modified it to update the position of the point its mousing at while its moving there, allowing me to fairly accurately mouse moving objects.
Before I continue, all credit for this post goes to @Flight and @BenLand100 as they wrote humanwindMouse and I just modified/bastardized it.
Anyway, here is a video of the code doing things. This video has incredibly low quality, you might need to fullscreen it to see what is actually happening.
[video=youtube;D8FHXCZillE]https://www.youtube.com/watch?v=D8FHXCZillE[/video]
Obviously, the air altar isn't moving, i'm just playing with the camera so relative to you its moving. I couldn't find an object that moves around fast enough to show off what this can actually do. But hopefully you get the picture.
Here is all the code used in the video.
This is the modified HumanWindMouse. I pass it a procedure to update the TPoint and I changed a few things in it as well.
I also made a procedure to make using the above procedure easier. (just like we do with the actual humanWindMouse)
And then the procedure that gives the TPoint for the air altar.
And the program.
This is just the bare stuff, there is absolutely no failsafes in this, it just assumes the altar is in vision. It doesn't check mouseover text or really anything. To use this in a script, it would have to be modified to be able to deal with failure.
So yeah, I think this has potential for use in some things. Especially when its just an object with a very unique color.
Before I continue, all credit for this post goes to @Flight and @BenLand100 as they wrote humanwindMouse and I just modified/bastardized it.
Anyway, here is a video of the code doing things. This video has incredibly low quality, you might need to fullscreen it to see what is actually happening.
[video=youtube;D8FHXCZillE]https://www.youtube.com/watch?v=D8FHXCZillE[/video]
Obviously, the air altar isn't moving, i'm just playing with the camera so relative to you its moving. I couldn't find an object that moves around fast enough to show off what this can actually do. But hopefully you get the picture.
Here is all the code used in the video.
This is the modified HumanWindMouse. I pass it a procedure to update the TPoint and I changed a few things in it as well.
procedure Mmoving(xs, ys, gravity, wind, minwait, maxwait, targetArea : Extended; updateP : procedure(var p : TPoint));
var
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,D: extended;
lastX,lastY,MSP,W,TDist: integer;
pointi : TPoint;
T : LongWord;
sqrt2,sqrt3,sqrt5,maxStep,rCnc: extended;
begin
MSP := mouseSpeed;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
updateP(pointI);
if PointI.x = -1 then
exit;
TDist := distance(round(xs), round(ys), pointI.x, pointI.y);
t := getSystemTime() + 10000;
repeat
if (getSystemTime() > t) then
break;
updateP(pointI);
if PointI.x = -1 then
exit;
dist:= hypot(xs - pointI.x, ys - pointI.y);
wind:= minE(wind, dist);
if (dist < 1) then
dist := 1;
D := (round((round(TDist)*0.3))/7);
if (D > 25) then
D := 25;
if (D < 5) then
D := 5;
rCnc := random(6);
if (rCnc = 1) then
D := randomRange(2,3);
if (D <= round(dist)) then
maxStep := D
else
maxStep := round(dist);
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 * (PointI.x - xs) / dist;
veloY:= veloY + gravity * (PointI.y - 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));
W := (random((round(100/MSP)))*6);
if (W < 5) then
W := 5;
W := round(W*0.9);
wait(W);
lastdist:= dist;
until(hypot(xs - PointI.x, ys - PointI.y) < 3);
mouseSpeed := MSP;
end; I also made a procedure to make using the above procedure easier. (just like we do with the actual humanWindMouse)
procedure mMovingObject(button: integer; updateP : procedure(var p : TPoint));
var
randSpeed: extended;
x,y,ms: integer;
begin
if (button = MOUSE_NONE) then
exit;
ms := mouseSpeed;
randSpeed := (random(mouseSpeed) / 2.0 + mouseSpeed) / 10.0;
getMousePos(x,y);
Mmoving(x, y, MOUSE_HUMAN, 5, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed, @updateP);
mouseSpeed := ms;
fastClick(button);
end; And then the procedure that gives the TPoint for the air altar.
procedure findAltar(var p : TPoint);
var
TPA : TPointARray;
x,y : integer;
begin
findColorsSpiralTolerance(x,y,TPA,13480323,mainscreen.getBounds(),7,colorSetting(2, 0.45, 0.85));
if (Length(TPA) < 1) then
begin
p.x := -1;
end;
p := middleTPA(TPA);
end; And the program.
begin
SetupSRL();
mMovingObject(MOUSE_RIGHT,@findAltar);
end. This is just the bare stuff, there is absolutely no failsafes in this, it just assumes the altar is in vision. It doesn't check mouseover text or really anything. To use this in a script, it would have to be modified to be able to deal with failure.
So yeah, I think this has potential for use in some things. Especially when its just an object with a very unique color.