SRL Archive - SRL Bugs

New Pillory/Fix


Wanted

2009-12-15 20:21:27

Everything needed updating from minor to complete rewrite, most of the advanced code is Niels' original concepts so 70% credit goes to him

New Pillory.scar

Edit: Btw, I still have the account :stirthepot:

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Pillory Routines --//
//-----------------------------------------------------------------//
// * function Pillory_LockScreen: Boolean; // * by Nielsie95
// * function Pillory_DoneLocks: Boolean; // * by Nielsie95
// * function Pillory_InRandom: Boolean; // * by IceFire908
// * function Pillory_ClickCageLock: Boolean; // * by IceFire908
// * function Pillory_GetLock: string; // * by Nielsie95 & IceFire908
// * function Pillory_GetKey(col: Integer): string; // * by Nielsie95 fixed by IceFire908
// * function SolvePilloryPuzzle: Boolean; // * by Nielsie95 & IceFire908
//-----------------------------------------------------------------//


{*******************************************************************************
function Pillory_LockScreen: Boolean;
by: Nielsie95
Description: Checks if the lock screen is visible.
*******************************************************************************}

function Pillory_LockScreen: Boolean;
begin
Result := LoggedIn and (GetColor(502, 22) = 65536);
end;

{*******************************************************************************
function Pillory_DoneLocks: Boolean;
by: Nielsie95
Description: Returns True if the locks have been opened.
*******************************************************************************}

function Pillory_DoneLocks: Boolean;
begin
Result := not Pillory_LockScreen;
if Result then
if FindNPCChatText('spinning lock', Nothing) then
begin
Result := False;
if ClickContinue(True, True) then
Wait(2000 + Random(1000));
end;
end;

{*******************************************************************************
function Pillory_InRandom: Boolean;
by: IceFire908
Description: Returns True if in the pillory random and not its not completed.
*******************************************************************************}

function Pillory_InRandom: Boolean;
var
TPA: TPointArray;
begin
FindColorsTolerance(TPA, 237, MMCX - 15, MMCY - 15, MMCX + 15, MMCY + 15, 17);
Result := ((not (TabExists(tab_Magic))) and (InRange(Length(TPA), 9, 18))) or (not (Pillory_DoneLocks));
end;

{*******************************************************************************
function Pillory_ClickCageLock: Boolean;
by: IceFire908
Description: Clicks the cage lock.
*******************************************************************************}

function Pillory_ClickCageLock: Boolean;
var
T, X: LongInt;
P: TPoint;
begin
T := GetSystemTime;
repeat
if (SpiralMouse(P.X, P.Y, MSCX - 20, MSCY - 20, MSCX + 20, MSCY - 20, 'age', 30, 8)) then
begin
GetMousePos(P.X, P.Y);
Mouse(P.X, P.Y, 0, 0, True);
X := GetSystemTime;
while ((GetSystemTime - X) < 5000) and (not Pillory_LockScreen) do
Wait(100);
Result := Pillory_LockScreen;
if (Result) then
WriteLn('Pillory: Opened LockScreen!');
Exit;
end;
until ((GetSystemTime - T) > RandomRange(8000, 12000));
end;

{*******************************************************************************
function Pillory_GetLock: string;
by: Nielsie95 & IceFire908
Description: Returns the type of lock that needs to be opened.
*******************************************************************************}

function Pillory_GetLock: string;
var
Dens: TIntegerArray;
TPA: TPointArray;
Bounds, B: TBox;
LC, T: LongInt;
E: Extended;
I: Byte;
begin
SetArrayLength(Dens, 4);
T := GetSystemTime;
while (((GetSystemTime - T) < 8000) and (Pillory_LockScreen)) do
begin
Wait(RandomRange(50, 75));
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.26, 0.55);
FindColorsTolerance(TPA, 1121831, 40, 40, 180, 180, 4);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
LC := Length(TPA);
if (LC < 300) then
Continue;
if (LC > 1100) then
begin
Result := 'circle';
Exit;
end;
Bounds := GetTPABounds(TPA);
if (((Bounds.X2 - Bounds.X1) < 24) and ((Bounds.Y2 - Bounds.Y2) < 24)) then
Continue;
for I := 0 to 3 do
begin
B := bounds;
B.X2 := (Bounds.X1 + Bounds.X2) shr 1;
B.Y2 := (Bounds.Y1 + Bounds.Y2) shr 1;
case I of
1: begin
B.X1 := B.X2;
B.X2 := Bounds.X2;
end;
2: begin
B.Y1 := B.Y2;
B.Y2 := Bounds.Y2;
end;
3: begin
B.X1 := B.X2;
B.X2 := Bounds.X2;
B.Y1 := B.Y2;
B.Y2 := Bounds.Y2;
end;
end;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.26, 0.55);
FindColorsTolerance(TPA, 1121831, B.X1, B.Y1, B.X2, B.Y2, 4);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
Dens[I] := Length(TPA);
end;
QuickSort(Dens);
E := MaxE(Bounds.X2 - Bounds.X1, Bounds.Y2 - Bounds.Y1) / MinE(Bounds.X2 - Bounds.X1, Bounds.Y2 - Bounds.Y1);
if (((Dens[3] - Dens[0]) > 150) and (LC > 500)) then
begin
Result := 'triangle';
Exit;
end;
if ((((Dens[3] - Dens[0]) < 35) and (LC > 600)) or
(((Dens[3] - Dens[0]) < 75) and (LC > 750) and (LC < 900))) and
(E < 1.3) then
begin
Result := 'square';
Exit;
end;
end;
Result := 'rombus';
end;

{*******************************************************************************
function Pillory_GetKey(col: Integer): string;
by: Nielsie95 fixed by IceFire908
Description: Returns the type of key in Col.
*******************************************************************************}

function Pillory_GetKey(col: Integer): string;
var
tpa: TPointArray;
i, l, e, t: Integer;
b, bounds: TBox;
dens: TIntegerArray;
begin
Result := 'unknown';
SetLength(dens, 4);
t := GetSystemTime;
l := 0;

while ((GetSystemTime - t) < 8000) and Pillory_LockScreen do
begin
Wait(60);
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.26, 0.55);
FindColorsTolerance(tpa, 1121831, 190 + (col * 95), 180, 235 + (col * 95), 260, 4);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
if (Length(tpa) < l) or (Length(tpa) < 230) then
Continue;
l := Length(tpa);
bounds := GetTPABounds(tpa);

if ((bounds.x2 - bounds.x1) < 18) and ((bounds.y2 - bounds.y1) < 18) then
Continue;
e := (bounds.x2 - bounds.x1) - (bounds.y2 - bounds.y1);
if (l > 400) and (l < 600) and (e < -5) then
begin
Result := 'rombus';
Exit;
end;

if (iAbs(e) <= 3) then
if (l > 600) then //if (l > 650) then
begin
Result := 'square';
Exit;
end
else if (l > 375) then
begin
Result := 'circle';
Exit;
end;

for i := 0 to 3 do
begin
b := bounds;
b.x2 := (bounds.x1 + bounds.x2) shr 1;
b.y2 := (bounds.y1 + bounds.y2) shr 1;
case i of
1: begin b.x1 := b.x2; b.x2 := bounds.x2; end;
2: begin b.y1 := b.y2; b.y2 := bounds.y2; end;
3: begin b.x1 := b.x2; b.x2 := bounds.x2; b.y1 := b.y2; b.y2 := bounds.y2; end;
end;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.26, 0.55);
FindColorsTolerance(tpa, 1121831, b.x1, b.y1, b.x2, b.y2, 4);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
dens[i] := Length(tpa);
end;
QuickSort(dens);

if (l < 350) and ((dens[3] - dens[0]) > 50) then
begin
Result := 'triangle';
Exit;
end;
end;
end;

{*******************************************************************************
function SolvePilloryPuzzle: Boolean;
by: Nielsie95 & IceFire908
Description: Solves the pillory random.
*******************************************************************************}

function SolvePilloryPuzzle: Boolean;
var
i, t, f: Integer;
Target: string;
begin
if (not Pillory_InRandom) then
begin
WriteLn('Not in Pillory!');
Exit;
end;
T := GetSystemTime;
SetAngle(True);
if (not (Pillory_LockScreen)) then
if (not Pillory_ClickCageLock) then
begin
Writeln('Pillory: Could not click cagelock!');
LogOut;
Exit;
end;
while Pillory_InRandom and ((GetSystemTime - T) < 180000) and (F < 5) do
begin
Target := Pillory_GetLock;
if (Target = '') then
begin
Inc(f);
Writeln('Pillory: Could not identify lock!');
Wait(1000);
Continue;
end;
WriteLn('Pillory: Target: '+Target);

for I := 0 to 2 do
if (Pillory_GetKey(I) = Target) then
begin
Mouse(208 + (94 * I), 225, 4, 4, True);
Wait(2000 + Random(1000));
Break;
end;

if (I > 2) then
begin
Inc(F);
Writeln('Pillory: Could not get matching key!');
Wait(1000);
Continue;
end;
ClickContinue(True, True);
end;
Result := (not Pillory_InRandom) and LoggedIn;
end;

Nava2

2009-12-16 08:43:36

Committed, please continue to update this and work out any kinks!

Wanted

2009-12-16 18:01:28

All the code is good, but I just found out Pillory works a little different than it used to so I'm going to have to change the main function a little bit, I'll post in a little while.

Tested with my newly posted one (just now) works!

[PHP]SRL Compiled in 15 msec
Pillory: Opened LockScreen!
Pillory: Target: square
Pillory: Target: square
Pillory: Target: circle
Pillory: Target: rombus
Pillory: Target: rombus
True[/PHP]

Wanted

2009-12-24 12:26:34

It solved the randoms

Beggining everything for banking...
Scanning for randoms...
***** STR: FOUND RANDOM: 'Pillory' *****
Pillory: Opened LockScreen!
Pillory: Target: triangle
Pillory: Target: circle
Pillory: Target: rombus
Pillory: Target: rombus
Pillory: Could not get matching key!
***** STR: 'Pillory' RANDOM SOLVED SUCCESSFULLY! *****
Random found! Performing anti-ban.
Scanned for randoms.
Opening VWB...
December 24th, 2009 02_20_04 AM2.bmp
Failed to open VWB, logging out...

But them my char mysteriously ended up at the air altar and failed to open bank…

what happens if you fail pillory?

It even had lamp in inventory when I logged in.

Gu3st...

2009-12-30 06:48:20

***** STR: FOUND RANDOM: 'Pillory' *****
Pillory: Target: triangle
Pillory: Target: circle
Pillory: Target: rombus
Pillory: Target: rombus
Pillory: Could not get matching key!
***** STR: 'Pillory' RANDOM SOLVED SUCCESSFULLY! *****