SRL Archive - SRL Snippets

[Antiban]CheckMovingObjs


Flight

2012-08-10 00:33:02

Y'ello,

I just whipped this up as an add-on to my anti-ban in one of my scripts and thought maybe someone else would like to use it.

-How it works [Simple]-
The procedure finds areas of the MS with high movement and moves the mouse to one of these areas. It's optional to have it right-click and examine the options of the menu. The more right-click options there are, the longer it will wait. After waiting the mouse will move up until the menu is closed out. Again, this is only if you have the parameter 'RClick' set to True.

-How it works [Explained]-
It's actually pretty smart how it works. First off the MS is split into an array of 35x35 boxes (roughly the size of a single RS tile), credits to Home for this. Next, each box is measured for the pixelshift within it, if the 'shift count' is above 100, it's considered a high-movement box, and the middle of this box is stored as a point in a TPA. Later on the procedure will pick a random box for this array (containing high movement) and move the mouse to it. Should the RClick option be set to true it'll right-click at that coordinate. Then the total number of right-click options are counted then this number is randomly multiplied to be used as the wait. So the more options there are in the menu, the longer it will wait, just like the longer it would take a human to read them all.

The first function is one Home built, you'll need it for this anti-ban to work:

//by Home
function AreaToBoxArray(const AreaX1, AreaY1, AreaX2, AreaY2, Width, Height: Integer): TBoxArray;
var
AreaW, AreaH: Integer;
BoxX, BoxY: Integer;
x, y, i: Integer;
begin
// Calculate the area dimensions
AreaW := AreaX2 - AreaX1 + 1;
AreaH := AreaY2 - AreaY1 + 1;

// Calculate the number of boxes in each dimension
BoxX := AreaW div Width;
if AreaW mod Width <> 0 then Inc(BoxX);
BoxY := AreaH div Height;
if AreaH mod Height <> 0 then Inc(BoxY);

// Set the number of boxes
SetLength(Result, BoxX * BoxY);

// Calculate the boxes
i := 0;
for y := 0 to BoxY - 1 do
for x := 0 to BoxX - 1 do
begin
Result[i] := IntToBox(AreaX1 + x * Width,
AreaY1 + y * Height,
Min(AreaX2, AreaX1 + (x + 1) * Width - 1),
Min(AreaY2, AreaY1 + (y + 1) * Height - 1));
Inc(i);
end;
end;


Procedure CheckMovingObjs(RClick: Boolean);
var
TBA: TBoxArray;
MidBox: TPoint;
TIA: TIntegerArray;
H,I,J,X,Y,T: Integer;
TPA,PBox: TPointArray;
RCOpts: Array of TOptions;
begin
if not LoggedIn then Exit;

ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);

PBox := TPAFromBox(IntToBox(240, 130, 275, 185));
TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 35, 35);
TIA := PixelShiftMulti(TBA, 300);

for H := 0 to High(TBA) do
begin
if (TIA[H] > 100) then
begin
MidBox := MiddleBox(TBA[H]);
SetArrayLength(TPA, Length(TPA)+1);
TPA[High(TPA)] := MidBox;
end;
end;

ClearTPAFromTPAWrap(TPA, PBox, TPA);
if (Length(TPA) < 1) then Exit;

I := Random(Length(TPA));
MissMouse2(TPA[I].X, TPA[I].Y, 5, 5);
if RClick then
begin
FastClick(Mouse_Right);
RCOpts := GetChooseOptions('All');
J := Length(RCOpts);
Wait(RandomRange(J*75, J*120));

MarkTime(T);
repeat
GetMousePos(X, Y);
BrakeMMouse(X-10,Y-10,15,5);
if (TimeFromMark(T) > 5000) then
break;
until(not FindTextEx(X,Y,['Choose','Option'],['UpCharsEx'],MSX1,MSY1,MSX2,MSY2))

if FindTextEx(X,Y,['Choose','Option'],['UpCharsEx'],MSX1,MSY1,MSX2,MSY2) then
MMouse(RandomRange(MIX1,MIX2),RandomRange(MIY1,MIY2),0,0);
end;

end;

Edit:
I had a problem with it right-clicking on massive player/item spawns to where the menu Y spanned the length of the MS therefore unable to close out of the menu. I fixed this by throwing in a loop to keep moving the mouse up & left until the menu was closed out. If it's still not closed out after 5 seconds the mouse is moved randomly to the inventory. Can't go wrong. ;)


Let me know how it works for you guys.

Sin

2012-08-10 00:42:41

Great job!
But I do see a problem when you're doing something and it chooses to click under you by accident.

Nebula

2012-08-10 00:50:20

Do you mean > 300 or > 100? In the function it's 100.

@shay
I just did a test and the Box that your player is in while North+Highest angle is box 67 so a user could do this to get rid of that box if that is causing issues.


if (h = 67) then
continue;

Edit: Actually I just looked at it some more and the players box is already removed so yeah.

Edit2: But wait, If it clears the player from the TPA, how did it detect my player doing an emote?

Edit3: looking into this further

Edit4: Oh it just doesn't right click. Nevermind lol.

Flight

2012-08-10 01:01:28

From: Shay
Great job!
But I do see a problem when you're doing something and it chooses to click under you by accident.


I'm not sure what you mean by 'under you'. If you mean clicking where your player stands then that area surrounding your player should be ignored overall.

From: Nebula
Do you mean > 300 or > 100? In the function it's 100.

@shay
I just did a test and the Box that your player is in while North+Highest angle is box 67 so a user could do this to get rid of that box if that is causing issues.


if (h = 67) then
continue;

Edit: Actually I just looked at it some more and the players box is already removed so yeah.

Edit2:But wait, If it clears the player from the TPA, how did it detect my player doing an emote?

Edit3:looking into this further


Yeah, I got the shiftcount mixed up with analyzing time. :S I'll correct that in the OP. Also, unless 'ClearTPAFromTPAWrap' is flawed it should not pick an area in the player's box (Box(240, 130, 275, 185)).

Olly

2012-08-12 13:47:27

MissMouse2(TPA.X, TPA.Y, 5, 5); Is that a custom function you use? I guess il just change it to missmouse.

Edit: Also FastClick :p

Nebula

2012-08-12 14:04:40

From: Ollybest
MissMouse2(TPA.X, TPA.Y, 5, 5); Is that a custom function you use? I guess il just change it to missmouse.

Edit: Also FastClick :p


Those are functions in the MouseHandler include. C:\Simba\Includes\SRL\srl\misc\MouseHandler. Yeah, they're custom mouse functions- most if not all of the functions are made by flight.

E: Actually MouseHandler is not part of the include, you have to manually download it.

Here I'll attach it to this post. This is version 1.01 I'm not sure if he's created a newer version or not though.

Flight

2012-08-12 20:56:53

From: Nebula
Those are functions in the MouseHandler include. C:\Simba\Includes\SRL\srl\misc\MouseHandler. Yeah, they're custom mouse functions- most if not all of the functions are made by flight.

E: Actually MouseHandler is not part of the include, you have to manually download it.

Here I'll attach it to this post. This is version 1.01 I'm not sure if he's created a newer version or not though.


Thank you very much Nebula. :)