mastaraymond
2007-10-19 20:29:02
Proof it worked:[php]
SRL Compiled in 63 msec
Pinball detected!
5603685
We've succesfully tagged this pillar! Current score: 1
We've succesfully tagged this pillar! Current score: 2
We've succesfully tagged this pillar! Current score: 3
We've succesfully tagged this pillar! Current score: 4
We've succesfully tagged this pillar! Current score: 5
We've succesfully tagged this pillar! Current score: 6
We've succesfully tagged this pillar! Current score: 7
We've succesfully tagged this pillar! Current score: 8
We've succesfully tagged this pillar! Current score: 9
We've succesfully tagged this pillar! Current score: 10
Solved the Pinball!
Successfully executed[/php]Oh, and here is the code ^^.
program New;
{.include SRL/SRL.scar}
Function PinballDetected: Boolean;
begin;
if (GetColor(MMCX,MMCY) = 0) then
if StrToIntDef(GetNumbers(GetTextAtEx(374, 241,0, UpChars, True,True,0,0,65535,9, False, tr_NormalChars)),-1) <> -1 then
Result := True;
end;
Function SolvePinBallRay: Boolean;
var
CTS,CurrentScore,MSPeed,RRX,RRY,MTime,LastClick,StartTime,Fails,I,GroundColor,Timer : Integer;
TPA : TPointArray;
SortedTPA : TPointArrayArray;
ClickedRight : Boolean;
begin;
if not PinballDetected then exit;
While ClickToContinue do //Just to be sure? Idk if he needs to talk ^^.
begin;
if not LoggedIn then exit;
Wait(500+Random(500));
end;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
GroundColor := GetColor(298, 188);
if not SimilarColors(GroundColor,5735272,10) then
begin;
FindColorsSpiralTolerance(MSCX,MSCY,TPA,5735272,MSX1,MSY1,MSX2,MSY2,10);
Try
GroundColor := GetColor(TPA[1000].x,TPA[1000].y);
except
GroundColor := GetColor(TPA[Length(TPA)-1].x,TPA[Length(TPA)-1].y)
end;
end;
Result := False;
MSPeed := MouseSpeed;
MouseSpeed := 20;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.17,0.57);
StartTime := GetSystemTime;
LastClick := GetSystemTime;
Timer := GetSystemTime;
CurrentScore := StrToIntDef(GetNumbers(GetTextAtEx(374, 241,0, UpChars, True,True,0,0,65535,9, False, tr_NormalChars)),0);
repeat
if not LoggedIn then break;
if (GetSystemTime - LastClick) > 45000 then
begin;
Mouse(MSCX, MSCY,5,5,true);
LastClick := GetSystemTime;
end;
if (CurrentScore = -1) or (Currentscore = 10) then break;
FindColorsSpiralTolerance(0, 0, TPA, 6199903, MSX1, MSY1, MSX2, MSY2,5);
if GetArrayLength(TPA) > 30 then
begin;
SortedTPA := TPAtoATPAEx(TPA,60,70);
SortATPASize(SortedTPA,True);
I := GetArrayLength(SortedTPA[0]) - 1;
if I > 30 then
begin;
Tpa := RearrangeTPA(SortedTPA[0],0,I,True,True);
if (TPA[I].x-TPA[0].x) > 25 then
begin;
MiddleTPAex(SortedTPA[0],RRX,RRY);
Timer := GetSystemTime - Timer;
Mouse(RRX,RRY,0,0,True);
GetMousePos(RRX,RRY);
MTime := GetSystemTime;
While not ClickedRight and Not ((GetSystemTime - MTime) > 200) do
begin;
ClickedRight := SimilarColors(GetColor(RRX-5,RRY+5),4471248,10);
Wait(5);
end;
LastClick := GetSystemTime;
if ClickedRight then
begin;
RRX := CurrentScore;
While Not ((GetSystemTime - LastClick) > 20000) and (RRX = Currentscore) do
begin;
CurrentScore := StrToIntDef(GetNumbers(GetTextAtEx(374, 241,0, UpChars, True,True,0,0,65535,9, False, tr_NormalChars)),-1);
if (CurrentScore = -1) then break;
Wait(200+random(50));
end;
if CurrentScore = 0 then
begin;
Fails := Fails + 1;
Writeln('Misclicked! Score has been reset! Fails: '+inttostr(Fails));
end else if (RRX = Currentscore) then
Writeln('Misclicked! Going on baby!')
else if CurrentScore <> -1 then
Writeln('We'#39've succesfully tagged a pillar, took: '+inttostr(Timer)+ 'ms! Current score: '+inttostr(Currentscore));
Timer := GetSystemTime;
end;
end;
end;
end else
Wait(50);
until ((GetSystemTime - StartTime) > 620000) or (Fails > 8)
MouseSpeed := MSpeed;
if CurrentScore >= 10 then
begin;
ColorToleranceSpeed(1);
Fails := 0;
MakeCompass('n');
repeat
HighestAngle;
MakeCompass('n');
Fails := Fails + 1;
For I := 1 to 3 do
begin;
RRX := MSCX;
RRY := 333;
FindColorSpiralTolerance(RRX,RRY,GroundColor,MSX1,MSY1,MSX2,MSY2,10);
if RRY >= 330 then RRY := 320
MMouse(RRX,RRY,5,5);
GetMousePos(RRX,RRY);
Mouse(RRX,RRY,0,0,True);
Wait(4000+Random(750));
if StrToIntDef(GetNumbers(GetTextAtEx(374, 241,0, UpChars, True,True,0,0,65535,9, False, tr_NormalChars)),-1) = -1 then Break;
end;
if StrToIntDef(GetNumbers(GetTextAtEx(374, 241,0, UpChars, True,True,0,0,65535,9, False, tr_NormalChars)),-1) = -1 then Break;
if IsUpTextMultiCustom(['xit','ave','Exit','Cave']) then
Break;
RRX := MSCX;
RRY := 333;
FindColorSpiralTolerance(RRX,RRY,6582101,MSX1,MSY1,MSX2,MSY2,10);
MMouse(RRX,RRY,0,0);
if IsUpTextMultiCustom(['xit','ave','Exit','Cave']) then
Break;
until(Fails >= 2)
if not (Fails >= 2) then
begin;
if StrToIntDef(GetNumbers(GetTextAtEx(374, 241,0, UpChars, True,True,0,0,65535,9, False, tr_NormalChars)),-1) <> -1 then
begin;
GetMousePos(RRX,RRY);
Wait(5+random(10));
Mouse(RRX,RRY,0,0,True);
end;
Result := True;
TakeScreen('Solved Pinball');
Writeln('Solved the Pinball!');
// Inc(Pinballs);
ColorToleranceSpeed(CTS);
Wait(5000 + Random(1000));
Exit;
end;
end;
// inc(NOPinballs);
ColorToleranceSpeed(CTS);
Players[CurrentPlayer].Rand := 'PinBall';
Logout;
end;
begin
SetupSRL;
if PinballDetected then
begin;
WritelN('Pinball detected!');
SolvePinBallRay;
end;
end.