DeSnob
2011-12-13 22:13:31
I encountered the Pinball random event about half an hour ago. It locates the pillars correctly; however, it had one issue. It would MMouse the pillar and sometimes take 3 to 5 seconds to click. This created missclicks whenever the random changed the view angle. It continuously reset itself to 0 due to its slowness. I looked at the code and it messed up at the uptext check. Just needed a little modification and it was working much faster and solved the random successfully.
Status: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
Status: | SRL Randoms Report |
Status: | [url]www.villavu.com[/url] |
Status: |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Status: | Pinballs Solved : 1 |
Status: \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/Changed the IsUpText to:result := IsUpTextMultiCustom(['ag', 'illar']);Here's the Pinball.scar://-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ? Pinball Routines --//
//-----------------------------------------------------------------//
// * function Pinball_InRandom: Boolean; // * by TRiLeZ
// * function p_ScanPillar(var x, y: Integer): Boolean; // * by SKy Scripter
// * function p_GetScore: string; // * by ZephyrsFury
// * function ExitPinball: string; // * by ZephyrsFury, SKy Scripter & Wizzup?
// * function SolvePinball: Boolean; // * by SKy Scripter fixed by Wizzup?
{*******************************************************************************
function Pinball_InRandom: Boolean;
by: TRiLeZ
Description: Checks if you are in the pinball random.
Date: December 30, 2009
*******************************************************************************}
function Pinball_InRandom: Boolean;
begin
if InBlack then
if (not (GetColor(504, 348) = 657930)) then //Arrow in chat box
Result := (CountColor(0, 204, 17, 280, 43) > 80);
end;
{*******************************************************************************
function p_ScanPillar(var x, y: Integer): Boolean;
by: SKy Scripter & NCDS
Updated: Nov 9, 2011 by NCDS
Description: Scans for the pinball pillar
*******************************************************************************}
function p_ScanPillar(var x, y: Integer): Boolean;
var
Points: TPointArray;
Colors: array of Integer;
P2D, pillar: T2DPointArray;
I, Hi, Bitmap,
J, ind, hi_P, ii: Integer;
H, S, L: Extended;
{$IFDEF SIMBA}
OldTarget : integer;
Temp : Integer;
{$ELSE}
Canvas: TCanvas;
Temp : HDC;
{$ENDIF}
begin
Result := false;
Bitmap := -1;
try
Temp := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.10, 1.93);
FindColorsTolerance(Points, 8708721, MSX1, MMY1, MSX2, MSY2, 5);
HI := High(Points);
Result := False;
ColorToleranceSpeed(Temp);
if (Hi < 20) then
Exit;
Colors := GetColors(Points);
{$IFDEF Simba}
Bitmap := CreateBitmap(MSX2+2, MSY2+2);
FastDrawClear(Bitmap,10);
J := 0;
for I := 0 to HI do
begin
ColortoHSL(Colors[I], H, S, L);
if (L > 50.0) then
begin
RectangleBitmap(bitmap,IntToBox(max(0,Points[I].x - 1), max(0,Points[I].y - 1),
Points[I].x + 1, Points[I].y + 1),clRed);
J := J + 1;
end;
end;
if (J > 20) then
begin
FloodFillBitmap(Bitmap,Point(2,2),10,0);
FloodFillBitmap(Bitmap,Point(MSX2 - 5, MSY2 - 5),10,0);
OldTarget := GetImageTarget;
SetTargetBitmap(Bitmap);
FindColorsTolerance(Points, 10, 0, 0, MSX2-5, MSY2-5, 0);
SetImageTarget(OldTarget);
{$ELSE}
Bitmap := BitmapFromString(MSX2, MSY2, '');
Canvas := GetBitmapCanvas(Bitmap);
Canvas.Brush.Color := 10;
Canvas.Brush.Style := bsSolid;
Canvas.Rectangle(0, 0, MSX2, MSY2);
J := 0;
Canvas.Brush.Color := 255;
Canvas.Pen.Color := 255;
for I := 0 to HI do
begin
ColortoHSL(Colors[I], H, S, L);
if (L > 50.0) then
begin
Canvas.Rectangle(Points[I].x - 1, Points[I].y - 1,
Points[I].x + 1, Points[I].y + 1);
J := J + 1;
end;
end;
if (J > 20) then
begin
Canvas.Brush.Color := 0;
Canvas.FloodFill(2, 2, 10, 0);
Canvas.FloodFill(MSX2 - 5, MSY2 - 5, 10, 0);
Temp := GetClientCanvas.Handle;
SetTargetBitmap(Bitmap);
FindColorsTolerance(Points, 10, 0, 0, MSX2-5, MSY2-5, 0);
SetTargetDc(temp);
{$ENDIF}
if (Length(Points) > 10) then
begin
P2D := TPAtoATPA(Points, 60);
sortATPASize(p2d, true);
hi := high(p2d);
for i := 0 to hi do
begin
pillar := findGapsTPA(p2d[i], 10);
hi_P := High(pillar);
for ii := 0 to hi_P do
result := (length(pillar[ii]) > 2);
end;
end;
end;
if (result) then
begin
MiddleTPAEx(P2D[ind], x, y);
MMouse(x, y, 0, 0);
result := IsUpTextMultiCustom(['ag', 'illar']);
end;
{$ifdef Simba}
DisplayDebugImgWindow(MSX2,MSY2);
DrawBitmapDebugImg(bitmap);
{$else}
DisplayDebugImgWindow(MSX2, MSY2);
SafeCopyCanvas(canvas, GetDebugCanvas, 0, 0, MSX2, MSY2, 0, 0, MSX2, MSY2);
{$endif}
finally
if bitmap <> - 1 then
FreeBitmap(bitmap);
end;
end;
{*******************************************************************************
function p_GetScore: string;
by: ZephyrsFury
Description: Gets the pinball score.
*******************************************************************************}
function P_GetScore: Integer;
begin
Result := -1;
case (CountColor(0, 278, 17, 316, 48)) of
32, 34: case (CountColor(65535, 278, 17, 316, 48)) of
0: Result := 0;
56: Result := 4;
69: Result := 5;
78: Result := 8;
62: Result := 9;
end;
26: Result := 1;
38: Result := 2;
36: Result := 3;
33: Result := 6;
31: Result := 7;
58: Result := 10;
else
WriteLn('Count: ' + IntToStr(CountColor(0, 278, 17, 316, 48)) + ' Bug in P_GetScore!');
end;
end;
{*******************************************************************************
function ExitPinball: Boolean;
by: ZephyrsFury, SKy Scripter & Wizzup?
Description: Exits the pinball random.
*******************************************************************************}
function ExitPinball: Boolean;
var
CTS, II, X, Y, T: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.57, 0.67);
if (FindColorsTolerance(TPA, 8359275, MSX1, MSY1, MSX2, MSY2, 8)) then
begin
ATPA := SplitTPA(TPA, 30);
SortATPASize(ATPA, True);
for II := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[II], X, Y);
Mouse(X, Y, 0, 0, False);
Wait(200 + Random(100));
if (ChooseOptionMulti(['xit C', 'it C', 't Ca'])) then
begin
WriteLn('Exit Found');
T := GetSystemTime;
while (GetSystemTime - T < 30000) and (PercentBlackMM = 100) do
begin
while (ClickContinue(True, True)) do
Wait(500 + Random(1000));
Wait(1000 + Random(2000));
end;
Result := (PercentBlackMM < 100);
if (Result) then Break;
end;
Wait(500 + Random(1000));
end;
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
{*******************************************************************************
function SolvePinball: Boolean;
by: SKy Scripter fixed by Wizzup?
Description: Attempts to solve the Pinball random.
*******************************************************************************}
function SolvePinball: Boolean;
var
x, y, i, score, time, time2: Integer;
begin
Result := false;
Try
for i := 1 to 3 do
begin
ClickContinue(True, True);
Wait(1000);
end;
Wait(1000);
Writeln('Starting the pinball solver.');
Time := GetSystemTime;
while (p_GetScore <> 10) and (GetSystemTime - Time < 240000) do
begin
if p_ScanPillar(x, y) then
begin
Mouse(x, y, 0, 0, True);
score := p_GetScore;
time2 := getsystemtime;
while (score = p_GetScore) and (getsystemtime - time2 < 10000) do
Wait(1000);
Wait(1000 + Random(1000));
end;
Wait(200);
end;
if (GetSystemTime - Time >= 240000) or (p_GetScore <> 10) Then
exit;
for i := 0 to 1 do
begin;
MakeCompass('S');
SetAngle(False);
Wait(3000 + random(500));
Result := ExitPinball;
MakeCompass('N');
SetAngle(True);
if Result then break;
end;
if result and (ClickContinue(True, True)) then
Wait(500 + Random(1000));
finally
if Result Then
Writeln('Pinball Solved.')
end;
end;