Important Note
I am going to continue my work on AntiRandom Solvers, but from now onwards they will only be available to the OSR Reflection include (being actively developed by Elfyyy, NKN, Sirenia and myself) which is available here: http://villavu.com/forum/showthread.php?t=107479
This is for several reasons, the most important of which is that there has been rapid development within the OSR Reflection include allowing better detection and solving methods than SRL's antirandoms are capable of.
I was not confident using reflection before because when the hooks are updated in OSR, it can take many days for people to update the pastebin with new hooks (relying solely on JavaHacking update logs). I have been developing the updater for the reflection include, and we are able to update hooks and post to the gc within 10 minutes of an OSR update. This is thanks to some incredible work by Justin, Elfyyy and even Brandon. NKN and Sirenia are leading the development of our own updater (this is different to the include updater), I'd like to call it a hook-nabber, but it's much more complex than that. Atm, we only use the JH logs to compare our hooks and multipliers. Soon we will have 2 methods to get hooks which don't rely on JavaHacking.com (which is rumoured to be posting less information on hooks anyway due to leechers)
I have also seen other members speak of creating their own OSR includes. While we don't have a development team for OSR, we have a lot of very skilled members who are very passionate about it. There is no reason we can't unite and combine our efforts into one include.
After some testing with the new reflection functions, I made the following:- Flawless Mime random detection & solver.
- Flawless Drill Demon detection.
- Flawless Prison Pete detection.
- Flawless Maze detection.
I'm confident we can detect nearly all randoms using reflection and by using it, we get completely accurate information in order to solve each random (compared to SRL's guess-work using colour techniques).
---------------------------------------------------------------------------------------------
Page 9 of the anti-random development thread was not really the place for this.
I've made edits to some of the core anti-randoms which weren't solving, so I'm posting a thread here which will be updated when a new fix is added. If you have made your own edits to fix a solver then post them here, please explain how you fixed the solver. I will test and add any new fixes posted.
There are 2 sections, Stable and Beta. Stable is for randoms which have been tested and worked everytime, Beta is for solvers which are still being developed.
Stable
Fixed the pinball random's cave exit routine. Added compass handling and updated a few colours.
pinball.simba
Code:
(*
Pinball
=======
Stores all the routines to solve the Pinball random. None of these routines
should be used throughout scripts. They only need to be called in SRL's random
detection methods.
This solver uses findGapsTPA to determine which post to click.
*)
//{$DEFINE PB_DEBUG}
const
PB_SCORE_10 = 180; // the tpa length of when the score is 10
(**
* Author: Coh3n
* Description: Detects if a player is in the Pinball random.
*)
function PB_Detect(): boolean;
begin
// makes sure friends tab exists and magic doesn't
if ((not tabExists(TAB_MAGIC)) and (tabExists(TAB_FRIENDS))) then
result := (Trim(GetTextAtExWrap(374, 238, 411, 253, 0, 5, 1,
65535, 5, 'UpChars07')) = 'Score');
end;
(**
* Author: Coh3n
* Description: Returns the length of a tpa found of the yellow color of the
* score at the top of the main screen.
*)
function PB_GetScore(): integer;
var
tpa: TPointArray;
begin
// yellow color of the score
if (findColorsTolerance(tpa, 65535, 373, 239, 434, 258, 30)) then
result := length(tpa);
end;
(**
* Author: SKy Scripter, NCDS, & Coh3n
* Description: Returns true if a flashing pillar is found. Sets coordinates
* to x, y.
*)
const
_PB_FILL_COLOR = 10;
_PB_MIN_LENGTH = 20;
function PB_ScanPost(var x, y: integer): boolean;
var
tpa: TPointArray;
pillarCols: array of integer;
ATPA, pillarGaps: T2DPointArray;
oldTarget, tmpCTS, bmp, i, j, c: integer;
hue, sat, lum: extended;
tmpBox: TBox;
begin
result := false;
bmp := -1;
try
tmpCTS := getColorToleranceSpeed;
setColorToleranceSpeed(3);
// the green of the spinning pillars
findColorsTolerance(tpa, 6011467, MSX1, MMY1, MSX2, MSY2, 38);
setColorToleranceSpeed(tmpCTS);
// if colors aren't found, exit
if (length(tpa) < _PB_MIN_LENGTH) then
exit;
bmp := createBitmap(MSX2 + 5, MSY2 + 5); // creats a bitmap of the MS
fastDrawClear(bmp, _PB_FILL_COLOR); // fill it with a distinct color
c := 0;
pillarCols := getColors(tpa);
// draws a rectangle on the bitmap of the colors that are light enough
for i := 0 to high(tpa) do
begin
colorToHSL(pillarCols[i], hue, sat, lum);
if (lum > 50.0) then
begin
tmpBox := intToBox(max(0, tpa[i].x - 1), max(0, tpa[i].y - 1), tpa[i].x + 1, tpa[i].y + 1);
rectangleBitmap(bmp, tmpBox, clRed);
inc(c);
end;
end;
if (c > _PB_MIN_LENGTH) then
begin
floodFillBitmap(bmp, point(5, 5), _PB_FILL_COLOR, clBlack);
oldTarget := getImageTarget();
setTargetBitmap(bmp);
findColors(tpa, _PB_FILL_COLOR, 0, 0, MSX2 - 5, MSY2 - 5);
setImageTarget(oldTarget); // reset target to RS client
if (length(tpa) > 10) then
begin
ATPA := TPAtoATPA(tpa, 60);
sortATPASize(ATPA, true);
for i := 0 to high(ATPA) do
begin
pillarGaps := findGapsTPA(ATPA[i], 10);
for j := 0 to high(pillarGaps) do
if (length(pillarGaps[j]) > 2) then
begin
middleTPAEx(ATPA[i], x, y);
result := true;
break;
end;
if (result) then
break;
end;
end;
end;
{$IFDEF PB_DEBUG}
displayDebugImgWindow(MSX2, MSY2);
drawBitmapDebugImg(bmp);
{$ENDIF}
finally
if (bmp <> -1) then
freeBitmap(bmp);
end;
if (result) then
addToSRLLog('PB_ScanPost: Found post');
end;
(**
* Author: Coh3n
* Description: Returns true if player clicks a post and the score changes.
*)
function PB_TagPost(): boolean;
var
t, x, y, oldScore: integer;
begin
if (not loggedIn()) then
exit;
oldScore := PB_GetScore();
if (PB_ScanPost(x, y)) then
begin
Mouse(x, y, 5, 5, mouse_right);
if (WaitOptionMulti(['ag', 'g P'], 618)) then
begin
t := (getSystemTime + 6000);
while (getSystemTime < t) do
begin
if (PB_GetScore() <> oldScore) then
begin
addToSRLLog('PB_TagPost: Tagged post');
result := true;
break;
end;
wait(300 + random(200));
end;
end else
MMouse(x, y - 25, 8, 8);
end;
end;
(**
* Author: DemiseScythe & Coh3n
* Description: Uses mainscreen walking to exit the random.
* Updated: Fixed for 07scape. - DannyRS - 23/03/2013
*)
function PB_Exit(): boolean;
var
x, y, t, i: integer;
tpa, tpa_Exit: TPointArray;
ATPA: T2DPointArray;
Deg: Extended;
begin
if (not loggedIn()) then
exit;
addToSRLLog('PB_Exit: Exiting cave');
SetAngle(SRL_ANGLE_HIGH);
Deg := RS_GetCompassAngleDegrees;
Wait(100 + random(50));
MakeCompass('N');
t := (getSystemTime + 25000);
repeat
// the green path color
if (findColorsTolerance(tpa, 4544055, MSX1, MMCY+10, MSX2, MSY2, 35)) then
begin
if (length(tpa) > 0) then
begin
MiddleTPAEx(tpa, x, y);
MMouse(x, y, 5, 5);
Wait(RandomRange(90,150));
if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
begin
ClickMouse2(mouse_left);
if (waitTabExists(TAB_MAGIC, 8000)) then
begin
result := true;
break;
end;
end;
end;
end;
if (findColorsTolerance(tpa, 5734757, MSX1, MMCY, MSX2, MSY2, 35)) then
if (length(tpa) > 0) then
begin
sortTPAFrom(tpa, point(MSCX, MSY2)); // center of the bottom of the MS
x := tpa[0].x;
y := tpa[0].y - 20; // so it's actually on the MS
MMouse(x, y, 5, 5);
// check for the proper uptexts
if (waitUptextMulti(['Walk', 'alk', 'here', 'ere'], 200)) then
begin
ClickMouse2(mouse_left);
end
else if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
begin
ClickMouse2(mouse_left);
if (waitTabExists(TAB_MAGIC, 8000)) then
begin
result := true;
break;
end;
end;
end;
result := tabExists(TAB_MAGIC); // just in case
wait(2000 + random(300));
until ((getSystemTime > t) or (result));
if (result) then
begin
Wait(100 + random(500));
MakeCompass(Deg);
addToSRLLog('PB_Exit: Clicked exit cave')
end else
begin
addToSRLLog('PB_Exit: Took to long to find exit... Looking for backup');
t := (getSystemTime + 20000);
MakeCompass('S');
repeat
if (FindColorsTolerance(tpa_Exit, 4677175, MSX1, MSY1, MSX2, MSY2, 23)) then
ATPA := TPAToATPAEx(tpa_Exit, 70, 5);
if (length(ATPA) > 0) then
begin
SortATPASize(ATPA, True);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
Wait(RandomRange(90,150));
if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
begin
ClickMouse2(mouse_left);
if (waitTabExists(TAB_MAGIC, 8000)) then
begin
result := true;
break;
end;
end;
end;
end;
result := tabExists(TAB_MAGIC);
wait(2000 + random(300));
until ((getSystemTime > t) or (result));
if (result) then
addToSRLLog('PB_Exit: Clicked exit cave with backup')
else
addToSRLLog('PB_Exit: Failed to exit')
end;
end;
(**
* Author: Coh3n & DemiseScythe
* Description: Solves the Pinball random.
*)
function PB_Solve(): boolean;
var
t: integer;
begin
if (not loggedIn()) then
exit;
t := (getSystemTime + (15 * 60000)); // maximum 15 minutes
doConversation('', false);
repeat
if (PB_GetScore = PB_SCORE_10) then // length of "Score: 10"
begin
if (PB_Exit()) then
begin
result := true;
break;
end;
end else
PB_TagPost();
wait(500 + random(200));
until(result or (getSystemTime > t));
end;
Fixed the text options for the frog random.. Credits to Flight for the conversation-handling (adapted from Frog_Solve2). I re-worked the Frog_WalkCenter method because dtm-finding no longer works on the minimap. Added compass handling. Ran it through a few times to make sure everything worked.
You can make the edits Flight recommends to FindTalk; (which handle frogs before you enter the cave) and they will not clash with the frog solver. Frog_Solve2 method is included and does not use cave-walking (because you will not be in the cave when it gets called).
frog.simba
Code:
(*
Frog
====
Stores all the routines to solve the Frog random. None of these routines
should be used throughout scripts. They only need to be called in SRL's random
detection methods.
*)
var
O_MouseSpeed, FROG_ISLAND_DTM, FROG_ISLAND_DTM_BACKUP, FROG_CROWN_BMP, DTM_Royal_Frog: Integer;
Deg : Extended;
const
FROG_YELLOW = 7986172;
FROG_RED = 3097339;
FROG_GREEN = 879885;
FROG_SWAMP = 8031312;
FROG_CROWN = 1095911;
FROG_CROWN_COLOR_BACKUP = 633312;
//function Frog_Speakto: boolean; forward;
function Frog_IsTalkingTo: boolean; forward;
function Frog_FindFrog: boolean; forward;
(*
DoConversationEx
~~~~~~~~~~~~~~
.. code-block:: pascal
function DoConversationEx(resultText: TStringArray; clickresult: boolean): boolean;
Goes through the initial dialog of a random. Will keep clicking to continue
until any of the conversation's 'resultText' is found. Will click to continue when
any 'resultText' is found if 'clickresult' is set to true. Set 'resultText' to ['']
to click continue until conversation is over.
.. note::
Author: Coh3n, Flight
Last Modified: Jun. 15th, 2013 by Flight
Example:
.. code-block:: pascal
if (DoConversationEx(['thank','nk you'], true)) then
writeln('Finished conversation');
*)
function DoConversationEx(resultText: TStringArray): boolean;
var
t,i: integer;
begin
while (t < 25) do // max of 25 "click to continue's"
begin
if (length(resultText) > 0) then
for i:=0 to high(resultText) do
if (findNPCChatText(resultText[i], nothing)) then
begin
result := true;
exit;
end;
// break if there's no more conversation
if (not clickContinue(true)) then
break;
wait(100 + random(200));
inc(t);
end;
end;
(**
* Author: Justin
* Description: Detects if we are in the Frog Random. Small chance it would
* fail to detect due to the frogs being off-screen, checks for Music Track too.
*)
function Frog_Detect(): boolean;
begin
if not (tabExists(TAB_MAGIC)) then
begin
if Length(GetMinimapDots('npc')) >= 4 then
if PercentBlackMM >= 35 then
if (GetMusic = 'Frooland') then
begin
Result := true;
exit;
end;
if (CountColorTolerance(FROG_GREEN, MSX1, MSY1, MSX2, MSY2, 30) >= 100) then
if (CountColorTolerance(FROG_RED, MSX1, MSY1, MSX2, MSY2, 30) >= 20) then
Result := (CountColorTolerance(FROG_YELLOW, MSX1, MSY1, MSX2, MSY2, 30) >= 5);
end;
end;
(**
* Author: Justin
* Description: Gets our player ready to solve the random.
*)
procedure Frog_Setup();
begin
if (not LoggedIn()) then
exit;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('n');
O_MouseSpeed := MouseSpeed;
MouseSpeed := 26;
end;
(**
* Author: Xtrapsp
* Description: Loads the DTMs that are used within the random.
*)
procedure Frog_Set_DTMS;
begin
FROG_ISLAND_DTM := DTMFromString('mrAAAAHic42BgYDjJxsBwA4qvA/EpID4MxLuAeBMQtwDV9ABxNRAXA3EuEBcBcQkQ1wJxaJAdg3lxAk4sB1SDDzMSwDAAAMr5E3M=');
FROG_ISLAND_DTM_BACKUP := DTMFromString('maQEAAHicE2RgYLjGxMDwGIjvMEHY54H4NBSfg+KrQHwTqu4BED8H4idAfAmqfgbQnIlA3AvFE4B4CgNEfB4QLwLipVA8H8qfDZUHqV8JxIGeNgxmRfFw7ONiARYD4RBvWzAGsf3dLVHUIWNWoDmUYkYqYAwAAGpfKPw=');
FROG_CROWN_BMP := BitmapFromString(1, 3, 'meJyTOfnD5NxvmaOfARoQBa8=');
DTM_Royal_Frog := DTMFromString('mbQAAAHicY2VgYLgDxLeB+CYQ34OyeRgZGDgZIbQAEPMD8cpOYYbfZ1QZDs4RYziuKcbw+5wxgxxQLTpmxoLBAAB7VQzf');
end;
(**
* Author: Xtrapsp
* Description: Unloads the DTMs that were used within the random.
*)
procedure Frog_Free_DTMS;
begin
FreeDTM(FROG_ISLAND_DTM);
FreeDTM(Frog_ISLAND_DTM_BACKUP);
FreeBitmap(FROG_CROWN_BMP);
FreeDTM(DTM_Royal_Frog);
end;
(**
* Author: Xtrapsp/Justin
* Description: Walks our player to the center of the map where the
* Frog Princess is located. If the DTM fails, will use TPA failsafe.
*)
function Frog_WalkCenter: boolean;
var
TPA: TPointArray;
T, TPAX, TPAY, sx, sy: Integer;
begin
if (not loggedIn()) then
exit;
MakeCompass('N');
MarkTime(T);
repeat
if findcolortolerance(TPAX,TPAY,5861233, MMX1+random(MMX2-MMX1-2), MMY1+random(MMY2-MMY1-2), MMX2, MMY2, 19) then
if (findcolortolerance(sx,sy,FROG_SWAMP, TPAX - 30, TPAY, TPAX - 15, TPAY, 19) and findcolortolerance(sx,sy,FROG_SWAMP, TPAX + 30, TPAY, TPAX + 45, TPAY, 19)) then
begin
Mouse(TPAX, TPAY-4, 4, 2, mouse_Left);
addToSRLLog('Frog_WalkCenter: Moving to center of cave');
wait(600 + Random(120));
FFlag(0);
result := true;
addToSRLLog('Frog_WalkCenter[Main]: result: ' + BoolToStr(result));
break;
end;
wait(100+random(50));
until(timeFromMark(T) > 6000);
if (not(result = true)) then
begin
addToSRLLog('Frog_WalkCenter: Unable to find main DTM, Falling back onto backup');
if (FindColorsTolerance(TPA, FROG_SWAMP, MMX1, MMY1, MMX2, MMY2, 50)) then
begin
MiddleTPAEx(TPA, TPAX, TPAY);
Mouse(TPAX, TPAY, 8, 8, mouse_Left);
wait(600 + Random(120));
FFlag(0);
result := true;
addToSRLLog('Frog_WalkCenter[Backup]: result: ' + BoolToStr(result));
end;
end;
end;
(**
* Author: Xtrapsp/Justin
* Description: Finds the Frog Princess via DTM with a TPA failsafe.
* If the DTM fails, it will rotate the camera just incase the Frog Princess
* is off the screen.
*)
function Frog_FindFrog: boolean;
var
T, Attempt, tmpCTS, i, fx, fy, arL: integer;
arP: TPointArray;
ararP: T2DPointArray;
P: TPoint;
begin
addToSRLLog('Frog_FindFrog: Attempting to find the Frog Princess');
Marktime(T);
tmpCTS := GetColorToleranceSpeed;
repeat
if FindDTM(DTM_Royal_Frog, fx, fy, MSx1, MSy1, MSx2, MSy2) then
begin
MMouse(fx-2, fy-2, 2, 2);
if WaitUpTextMulti(['Frog','to Fr'], 300) then
begin
Writeln('Frog_Solve2: Found royal frog');
ClickMouse2(mouse_right);
Wait(randomRange(100,250));
result := waitOptionMulti(['Talk-to Frog','to Fr','Frog'], 500);
if result then
begin
Writeln('Frog_Solve2: Talking to royal frog...');
break
end else
MouseBox(MCx1, MCy1, MCx2, MCy2, mouse_move);
end;
end;
if not result then
begin
if FindBitmapToleranceIn(FROG_CROWN_BMP, fx, fy, MSX1, MSY1, MSX2, MSY2, 40) then
begin
MMouse(fx, fy, 4, 4);
addToSRLLog('Frog_FindFrog: Checking multi uptext');
wait(150 + random(100));
if (IsUpTextMultiCustom(['Frog', 'Talk', 'rog'])) then
begin
ClickMouse2(mouse_Right);
Result := WaitOptionMulti(['Talk-to', 'alk-t', 'Frog', 'rog'], 800);
addToSRLLog('Frog_FindFrog[Backup]: result: ' + BoolToStr(result));
wait(600 + Random(120));
FFlag(0);
if (result) then
addToSRLLog('Frog_FindFrog: Found Frog Princess');
exit;
end else
addToSRLLog('Frog_FindFrog: Could not find uptext');
end else
begin
addToSRLLog('Frog_FindFrog: Could not find Frog Princess. Falling onto backup');
MakeCompass(rs_GetCompassAngleDegrees + RandomRange(85, 95));
wait(800+Random(400));
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.76);
if (FindColorsTolerance(arP, FROG_CROWN, MSX1, MSY1, MSX2, MSY2, 12)) then
begin
addToSRLLog('Frog_FindFrog: Found TPA color, Moving mouse to TPA');
SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arP, 8, 8);
arL := High(ararP);
for i := 0 to arL do
begin
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
addToSRLLog('Frog_FindFrog: Checking multi uptext');
Wait(100 + Random(100));
if (IsUpTextMultiCustom(['Frog', 'Talk', 'rog'])) then
begin
ClickMouse2(mouse_Right);
Result := WaitOptionMulti(['Talk-to', 'alk-t', 'Frog', 'rog'], 500);
addToSRLLog('Frog_FindFrog[Backup]: result: ' + BoolToStr(result));
wait(600 + Random(120));
FFlag(0);
exit;
end else
addToSRLLog('Frog_FindFrog: Could not find uptext');
end;
end else
addToSRLLog('Frog_FindFrog[Backup]: Unable to find TPA');
end;
end;
Inc(Attempt);
addToSRLLog('Frog_FindFrog: Attempt: ' + inttostr(Attempt));
until ((Attempt > 5) or (Result));
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
exit;
end;
{(**
* Author: Xtrapsp/Justin
* Description: Handles talking to the Frog Princeess.
*)
function Frog_SpeakTo: boolean;
var
T, Attempt: integer;
TPA: TPointArray;
begin
addToSRLLog('Frog_SpeakTo: Attempting to speak to the Frog Princess');
Marktime(T);
repeat
if ClickDTMRotatedIn(FROG_CROWN_DTM, MSX1, MSY1, MSX2, MSY2, - Pi, Pi, Pi / 30, ['rog'], mouse_Left) then
begin
addToSRLLog('Frog_SpeakTo: Found Frog Princess, Clicking Frog Princess');
result := true;
addToSRLLog('Frog_SpeakTo[Main]: result: ' + BoolToStr(result));
Wait(3500 + Random(1000));
exit;
end
else
begin
addToSRLLog('Frog_SpeakTo: Could not find Frog Princess. Falling onto backup');
if (FindColorsSpiralTolerance(MSCX, MSCY, TPA, FROG_CROWN_COLOR_BACKUP, MSX1, MSY1, MSX2, MSY2, 25)) then
begin
Mouse(TPA[0].X, TPA[0].Y, 2, 2, mouse_Move);
if IsUpTextMultiCustom(['Frog', 'Talk', 'rog']) then
ClickMouse2(mouse_Left);
wait(600 + Random(120));
FFlag(0);
Result := true;
addToSRLLog('Frog_SpeakTo[Backup]: result: ' + BoolToStr(result));
end;
end;
Inc(Attempt);
MakeCompass(rs_GetCompassAngleDegrees + RandomRange(85, 95));
until ((Attempt > 20) or (Frog_IsTalkingTo))
if (Attempt > 20) then
Frog_WalkCenter;
exit;
end;}
(**
* Author: Xtrapsp/Justin
* Description: Detects if we are talking to the Frog Princess or just a Frog.
*)
function Frog_IsTalkingTo: boolean;
var
T, ft, i, Attempt: integer;
responses: TStringArray;
begin
addToSRLLog('Frog_IsTalkingTo: Speaking to the Frog Princess');
responses := ['very','orry','hange','lrigh','Okay','kay.','I supp','pose so','yeah','Yeah','Sure','ure'];
MarkTime(ft);
repeat
if areTalking then break;
wait(100+random(50));
until(timeFromMark(ft) > 6000);
MarkTime(ft);
repeat
if DoConversationEx(responses) then
begin
Writeln('Frog_Solve2: Reached response');
for i:=0 to High(responses) do
if findTextTPA(0, 5, MCx1, MCy1, MCx2, MCy2, responses[i], CharsNPC07, ClickLeft) then
begin
Writeln('Frog_Solve2: Chose correct option');
ClickToContinue;
break;
end;
end;
until(timeFromMark(ft) > 15000);
MarkTime(ft);
repeat
if (not(Frog_Detect())) then
begin
Result := True;
Writeln('Frog_Solve2: Successfully solved the Frog random!');
break;
end;
Wait(100 + Random(50));
until(timeFromMark(ft) > 10000);
if not result then
begin
repeat
Result := FindNPCChatText('Hmph. Have you come to apologize for ignoring me?', Nothing);
if (not(result)) then result:= FindNPCChatText('change', Nothing);
if (Result or (Attempt > 6)) then
begin
addToSRLLog('Frog_IsTalkingTo[backup]: Continuing to chat to Frog Princess');
Wait(1000 + Random(500));
DoConversation('', true);
Wait(1100 + Random(500));
Mouse(137, 399, 252, 7, True);
Wait(1100 + Random(500));
Mouse(153, 449, 130, 5, True);
Wait(1100 + Random(500));
Mouse(243, 450, 130, 4, True);
Wait(2100 + Random(1500));
exit;
end
else
addToSRLLog('Frog_IsTalkingTo[backup]: Could not continue chat with Frog Princess');
until ((Attempt > 7) or (TimefromMark(T) > 50000) or Result);
end;
if (Attempt > 7) then
begin
addToSRLLog('Frog_IsTalkingTo: Attempts are greater than 5');
Wait(3000 + Random(1000));
result := false;
end;
end;
(**
* Author: Justin & Flight
* Modified by: Krazy_Meerkat
* Description: Handles solving the random event.
*)
function Frog_Solve2(): boolean;
begin
if (not loggedIn()) then
exit;
Deg := RS_GetCompassAngleDegrees;
Wait(100 + random(50));
Frog_Setup();
if Frog_FindFrog then
result := Frog_IsTalkingTo;
MouseSpeed := O_MouseSpeed;
if (not result) then
addToSRLLog('Frog_Solve2: Frog solver failed or timed out');
MakeCompass(Deg);
end;
(**
* Author: Justin
* Description: Handles solving the random event.
*)
function Frog_Solve(): boolean;
var
t: integer;
begin
if (not loggedIn()) then
exit;
Deg := RS_GetCompassAngleDegrees;
Wait(100 + random(50));
t := (getSystemTime + (10 * 60000));
Frog_Setup();
repeat
if Frog_WalkCenter then
if Frog_FindFrog then
result := Frog_IsTalkingTo;
until (result or (getSystemTime > t));
MouseSpeed := O_MouseSpeed;
if (not result) then
addToSRLLog('Frog_Solve: Frog solver failed or timed out');
MakeCompass(Deg);
end;
Fixed the pillory cage random. Object scanning was freezing up and returning low values for the locks, added wait times and minimum value requirements. Fixed compass angle issues. Improved cage-finding routine.
pillory.simba
Code:
(*
Pillory
=======
Stores all the routines to solve the Pillory random. None of these routines
should be used throughout scripts. They only need to be called in SRL's random
detection methods.
This solver uses color counting to determine the shape
of the lock and which key to use.
*)
procedure PL_Message(Message: string);
begin
addToSRLLog('[Pillory Random] ' + Message);
end;
function PL_LockScreen: Boolean;
begin
Result := (LoggedIn and (GetColor(497, 34) = 65536));
end;
function PL_Detect: boolean;
var
tpa: TPointArray;
begin
if (not TabExists(TAB_OPTIONS)) and (TabExists(TAB_FRIENDS)) then
begin
// red doors of the cages
FindColorsTolerance(tpa, 235, MMCX - 15, MMCY - 15, MMCX + 15, MMCY + 15, 20);
Result := (inRange(length(tpa), 3, 18));
end;
end;
(**
* Author: DannyRS
* Last modified 15/03/2013 By DannyRS
* Description: Opens Cage Interface
*)
function PL_ClickCage: Boolean;
var
t, x, y: Integer;
begin
Result := False;
t := GetSystemTime;
if (not LoggedIn) then Exit;
Result := PL_LockScreen;
if (not Result) then
begin
repeat
x:= MSCX;
y:= MSCY;
if (not(IsUpTextMultiCustom(['Unlock','lock','Cage','age']))) then
if FindColorSpiralTolerance(x, y, 9738912, MSX1, MSY1, MSX2, MSY2, 19) or FindColorSpiralTolerance(x, y, 1118484, MSX1, MSY1, MSX2, MSY2, 19) then
begin
MMouse(x,y,4,4);
end else
MMouse(243,143,80,65);
Wait(RandomRange(90, 270));
if (IsUpTextMultiCustom(['Unlock','lock','Cage','age'])) then
begin
ClickMouse2(mouse_left);
if (waitFunc(@PL_LockScreen, 50, 5000)) then
begin
PL_Message('[PL_ClickCage] Opened Lock Screen');
Wait(RandomRange(190, 270));
Result := True;
end else
PL_Message('[PL_ClickCage] Failed to open Lock Screen');
end else
MMouse(243,143,80,65);
until (Result) or (GetSystemTime - t > 38000);
end;
end;
(**
* Author: DannyRS
* Last modified 15/03/2013 By DannyRS
* Description: Clicks a key 0-2
*)
function PL_ClickKey(Slot: Integer): Boolean;
var
p: TPoint;
begin
Result := False;
if (not PL_LockScreen) then Exit;
p := Point(209 + (Slot*93), 251);
MMouse(RandomRange(p.x - 2, p.x + 2), RandomRange(p.y - 4, p.y + 4), 0, 0);
ClickMouse2(mouse_left);
Result := True;
end;
(**
* Author: DannyRS
* Last modified 9/04/2013 By DannyRS
* Description: Scans for lock type
*)
function PL_GetLock: String;
var
CNum,Count,CountTime,WatchTime: Integer;
begin
Result := '';
WatchTime := RandomRange(9000,10000);
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.21, 2.01);
MarkTime(CountTime);
Count:= 100;
repeat
CNum := CountColorTolerance(1057067, 60, 65, 150, 150, 10);
if (CNum > Count) then
Count := CNum;
wait(50 + random(50));
until (TimeFromMark(CountTime) > WatchTime);
if (Count > 800) and (Count < 1000) then Result := 'square';
if (Count > 570) and (Count < 799) then Result := 'triangle';
if (Count > 400) and (Count < 569) then Result := 'diamond';
if (Count > 1001) and (Count < 1600) then Result := 'circle';
PL_Message('[PL_GetLock] Lock Found: ' + Result + ' [' + ToStr(Count) + ']');
end;
(**
* Author: DannyRS
* Last modified 9/04/2013 By DannyRS
* Description: Scans for key types
*)
function PL_GetKeys: TStringArray;
var
C1,C2,C3,CNum,Count,WatchTime: Integer;
begin
SetLength(Result, 3);
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.43, 2.81);
MarkTime(WatchTime);
Result[0] := '';
Count := 100; CNum := 0;
repeat
CNum := CountColorTolerance(1516846, 180, 170, 235, 260, 7);
case CNum of
286: Result[0] := 'triangle';
493: Result[0] := 'diamond';
506: Result[0] := 'circle';
729: Result[0] := 'square';
end;
if (CNum > Count) then
Count := CNum;
wait(50 + random(50));
until (not (Result[0] = '')) or (TimeFromMark(WatchTime) > 10000);
if (Result[0] = '') then
begin
if InRange(Count, 250, 350) then Result[0] := 'triangle';
if InRange(Count, 400, 500) then Result[0] := 'diamond';
if InRange(Count, 501, 600) then Result[0] := 'circle';
if InRange(Count, 670, 1300) then Result[0] := 'square';
end;
C1 := Count;
MarkTime(WatchTime);
Result[1] := '';
Count := 100; CNum := 0;
repeat
CNum := CountColorTolerance(1516846, 265, 170, 345, 260, 7);
case CNum of
286: Result[1] := 'triangle';
493: Result[1] := 'diamond';
506: Result[1] := 'circle';
729: Result[1] := 'square';
end;
if (CNum > Count) then
Count := CNum;
wait(50 + random(50));
until (not (Result[1] = '')) or (TimeFromMark(WatchTime) > 10000);
if (Result[1] = '') then
begin
if InRange(Count, 250, 350) then Result[1] := 'triangle';
if InRange(Count, 400, 500) then Result[1] := 'diamond';
if InRange(Count, 501, 600) then Result[1] := 'circle';
if InRange(Count, 670, 1300) then Result[1] := 'square';
end;
C2 := Count;
MarkTime(WatchTime);
Result[2] := '';
Count := 100; CNum := 0;
repeat
CNum := CountColorTolerance(1516846, 365, 170, 430, 260, 7);
case CNum of
286: Result[2] := 'triangle';
493: Result[2] := 'diamond';
506: Result[2] := 'circle';
729: Result[2] := 'square';
end;
if (CNum > Count) then
Count := CNum;
wait(50 + random(50));
until (not (Result[2] = '')) or (TimeFromMark(WatchTime) > 10000);
if (Result[2] = '') then
begin
if InRange(Count, 250, 350) then Result[2] := 'triangle';
if InRange(Count, 400, 500) then Result[2] := 'diamond';
if InRange(Count, 501, 600) then Result[2] := 'circle';
if InRange(Count, 670, 1300) then Result[2] := 'square';
end;
C3 := Count;
PL_Message('[PL_GetKeys] Keys Found: '+
Result[0]+' ['+IntToStr(C1)+']'+' '+
Result[1]+' ['+IntToStr(C2)+']'+' '+
Result[2]+' ['+IntToStr(C3)+']');
end;
(**
* Author: DannyRS
* Last modified 15/03/2013 By DannyRS
* Description: Solves the Pillory Random Event
*)
function PL_Solve: Boolean;
var
i, t, keysolves, tmpCTS: Integer;
tmpHM, tmpSM, Deg: Extended;
lock: String;
keys: TStringArray;
begin
Result := False;
keysolves := 0;
tmpCTS := GetColorToleranceSpeed;
GetToleranceSpeed2Modifiers(tmpHM, tmpSM);
if (not LoggedIn) then Exit;
t := GetSystemTime;
Deg := RS_GetCompassAngleDegrees;
Wait(100 + random(50));
MakeCompass('N');
//if (not PL_ClickCage) then Exit;
repeat
Result := (TabExists(TAB_OPTIONS));
if (Result) then Break;
// open the lock screen if it's not already open
if (not PL_LockScreen) then PL_ClickCage;
lock := PL_GetLock;
keys := PL_GetKeys;
for i := 0 to 2 do
if (keys[i] = '') then
begin
PL_Message('[ERROR] [PL_GetKeys] Failed to get all keys');
Break;
end;
if (lock = '') then
begin
PL_Message('[ERROR] [PL_GetLock] Failed to get lock type');
Continue;
end;
for i := 0 to 2 do
if (keys[i] = lock) then
begin
PL_Message('[PL_Solve] Clicking key : ' + keys[i]);
if PL_ClickKey(i) then
begin
keysolves := keysolves + 1;
Wait(RandomRange(1500, 2000));
end;
end;
Result := ((keysolves > 2) and (not PL_LockScreen)) or
(TabExists(TAB_OPTIONS));
until (Result) or (GetSystemTime - t > 120000);
if (Result) then MakeCompass(Deg);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(tmpHM, tmpSM);
if (not Result) then
begin
if (GetSystemTime - t > 120000) then
PL_Message('[ERROR] Pillory solver timed out');
end else
Wait(RandomRange(800, 1200));
end;
Fixed the drill demon random. Added 1 new bitmap for each sign, had no problems detecting all 4. Ran it through a few times, changing worlds to test colour difference.
demon.simba
Code:
(*
Drill Demon
===========
Stores all the routines to solve the Drill Demon random. None of these routines
should be used throughout scripts. They only need to be called in SRL's random
detection methods.
This solver uses Deformed BMPs to locate the signs
to solve the Drill Demon (Sergeant Damien) random.
*)
procedure DD_Message(Message: String);
begin
addToSRLLog('[DemonDrill Random] ' + Message);
end;
function DD_Detect(): Boolean;
begin
if (not TabExists(TAB_OPTIONS)) and (not TabExists(TAB_EMOTES)) then
Result := (GetMusic = 'CorPoral Punisbment');
end;
(**
* Author: DannyRS
* Last Modified: 17/03/2013 - DannyRS
* Description: Moves the player back to the center of the random
* Note: Inspired by Le Jingle
*)
function DD_ResetPosition: Boolean;
var
WallTPA: TPointArray;
WallATPA: T2DPointArray;
tb: TBox;
p: TPoint;
//pa: TPointArray;
begin
Result := False;
if (not LoggedIn) then Exit;
SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);
FindColorsTolerance(WallTPA, 15593957, 600, 58, 690, 110, 70);
SplitTPAExWrap(WallTPA, 5, 5, WallATPA);
SortATPASize(WallATPA, True);
if (Length(WallATPA) < 1) then Exit;
//SMART_DrawBoxEx(True, False, WallATPA[0], clGreen);
tb := GetTPABounds(WallATPA[0]);
p := MiddleBox(tb);
//Seems white alone is accurate enough to leave this out - Danny
//pa := GetMiniMapDots('yellow');
//if (Length(pa) < 1) then Exit;
//if (not PointInBox(pa[0], tb)) then Exit;
MMouse(p.x, RandomRange(p.y, p.y + 2), 0, 0);
ClickMouse2(mouse_left);
Wait(RandomRange(300, 400));
Flag;
Wait(RandomRange(800, 1200));
Result := True;
end;
function DD_TalkingToDemon: Boolean;
begin
Result := (Trim(GetNPCChatName) = 'SergeantDamien');
end;
(**
* Author: DannyRS
* Last Modified: 17/03/2013 - DannyRS
* Description: Talks to Sergeant Damien
*)
function DD_TalkDemon: Boolean;
var
DemonTPA: TPointArray;
DemonATPA: T2DPointArray;
x, y, i, Attemps: Integer;
begin
Result := False;
if (DD_TalkingToDemon) then
begin
Result := True;
Exit;
end;
repeat
if (Attemps > 6) then Break;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.15, 1.61);
FindColorsTolerance(DemonTPA, 994406, MSX1, MSY1, MSX2, MSY2, 16);
SplitTPAExWrap(DemonTPA, 50, 100, DemonATPA);
SortATPASize(DemonATPA, True);
if (Length(DemonATPA) < 1) then
begin
Attemps := Attemps + 1;
Wait(RandomRange(200, 400));
Continue;
end;
for i := 0 to High(DemonATPA) do
begin
if (Length(DemonATPA[i]) < 50) then Continue;
MiddleTPAEx(DemonATPA[i], x, y);
MMouse(RandomRange(x - 5, x + 5), RandomRange(y - 5, y + 5), 0, 0);
ClickMouse2(mouse_right);
Wait(RandomRange(30, 50));
if (ChooseOptionMulti(['Talk','alk-to'])) then
begin
if (WaitFunc(@DD_TalkingToDemon, 50, 25000)) then
begin
DD_Message('[DD_TalkDemon] Talked to demon');
Result := True;
Exit;
end else
DD_Message('[DD_TalkDemon] Failed to Talked to demon');
end;
end;
Attemps := Attemps + 1;
until (Result) or (Attemps > 6);
end;
(**
* Author: DannyRS
* Last Modified: 17/03/2013 - DannyRS
* Description: Gets the TBoxes of the green signs
*)
function DD_GetSigns: TBoxArray;
var
ESignsTPA: TPointArray;
ESignsATPA: T2DPointArray;
SignsSorted: Boolean;
i: Integer;
begin
SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);
FindColorsTolerance(ESignsTPA, 4553552, MSX1, MSY1, MSX2, MSY2, 30);
SplitTPAExWrap(ESignsTPA, 70, 60, ESignsATPA);
repeat
SignsSorted := True;
for i := 0 to High(ESignsATPA) do
begin
if (Length(ESignsATPA[i]) < 5) then
begin
DeleteValueInATPA(ESignsATPA,i);
SignsSorted := False;
Break;
end;
end;
until (SignsSorted);
SetLength(Result, Length(ESignsATPA));
for i := 0 to high(ESignsATPA) do
begin
Result[i] := GetTPABounds(ESignsATPA[i]);
end;
DD_Message('[DD_GetSigns] Number of signs located : ' +
IntToStr(Length(ESignsATPA)));
end;
(**
* Author: DannyRS
* Last Modified: 17/03/2013 - DannyRS
* Description:
* Compares bitmaps to the signs and tries to
* return it's position, roughly centered
*)
function DD_FindSign(WhichSign: String): TPoint;
var
SB: TBoxArray;
x, y, i, ib, hb: Integer;
Saccuracy: Extended;
SBMP: TIntegerArray;
begin
Result := Point(-1, -1);
SB := DD_GetSigns;
if (Length(SB) < 1) then Exit;
SetLength(SBMP, 5);
hb := High(SBMP);
SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);
case LowerCase(WhichSign) of
'jog': begin
SBMP[0] := BitmapFromString(14, 15, 'meJxzrw1KnFAOQe5IbAgXDRGvEo' +
'6y5zQDEVw7Vlk4wm8UmktooRJNMS4PojkVlxq4p5BDDKsaTBuRVWI' +
'qw2UvVmUE44VaiolMEkAEAE9f+0k=');
SBMP[1] := BitmapFromString(26, 17, 'meJxzqwl0w0AJfWUQhMYmD2E1jR' +
'IDIShrdhMQwa2grmlkGwgxB4IodxVaMFLXNGQDKYwRNM+SHcvIQQf' +
'XS57b0CICOQVSYhSmH8k2jSrxOJhNc0PNVhQiKhYdbuQmKgBkSPbW');
SBMP[2] := BitmapFromString(29, 10, 'meJxzrQ5wJRrF9ZUSr3gwGItsMh' +
'qXbJQ5qxGI4EZRxViImRBjIaZRbizcTGR3UmgsmpnUCltcxlIrVKl' +
'rLNxk4tUDAIc3Qs8=');
SBMP[3] := BitmapFromString(14, 17, 'meJxL6C9PACP3msAEJDYmSiBaJR' +
'xlzWkCIoh6girharAqhhgFQQRNQ3MzdVUi+wuPXqyuhYcbXBDNX/D' +
'gxeN9zOjAqpKg77CqxONfYlRiBg7+ACcm2ImMGgCPpxvW');
SBMP[4] := BitmapFromString(15, 18, 'meJxzrwl0rwlM6C+HIHdsXDSELA' +
'tnE1ScNacJiPArhiOIYiCCG4JHDdxk/GaiOYl2itHU4zEBzdm4VGI' +
'GHVaVmIGGK3bQVOJ3AFaV+COOFoqJTDkkRRnxMQtEANqdPtI=');
end;
'starjumps': begin
SBMP[0] := BitmapFromString(16, 16, 'meJxzrw1yx0CJE8ohCFMKK4Krx9' +
'SSu7AdiEg1H6su/GogXPwIlyHEqMSlnhhH0kg9hS6nonqsyrBqgcQ' +
'7LjOJUY/VXswEhifGkZMfAK38Sfc=');
SBMP[1] := BitmapFromString(33, 17, 'meJxzqwl0Ixol9JUBEfHqSUUQ8+' +
'lmC4Xm5CxohSNaqMeqkSCilo+objhBu6ge0cPAClrHAi4rqGgLHZI' +
'TprHUtQWXsym3Al4Q4XIwsjh5pRa8uMPjWmTzyS4Y4bbgCUZiSngA' +
'a5KX0w==');
SBMP[2] := BitmapFromString(37, 16, 'meJxzrQ5wJR3F9ZXCERnacaHs+S' +
'34raOiXXAbIYjqJhNjKfGIPjbSx5t0C1U6RyI97Ro21tEtNdLHOuR' +
'iCtN8qtuIXDBiNZlGHgQiXMbSIgbh1uGJUyKrJAA7N7QN');
SBMP[3] := BitmapFromString(22, 16, 'meJxzrwl0x4YS+suBCKsUkQhiAj' +
'GG5CxsgyCyTUA2BNMcklQiy+JBxFtBql785pAaCwNuAoUhgCcw6WY' +
'Cpi4iDYGnXqzqiTcBiHAphovjzylwQ3B5EG4RmiEAhx+zZw==');
SBMP[4] := BitmapFromString(24, 17, 'meJxzrwl0JwIl9JcDETEqCRpCuV' +
'EkGZKzsA2CiDQcrh5TFy5xTF0ELcWlnngTiDeKpLCl3ARc5pAX1zR' +
'yDBnmUCV4qWUOpkYijULOOATTOUFzIIiYTIE/wyKbg8e/eAoQADSU' +
'910=');
end;
'situps': begin
SBMP[0] := BitmapFromString(32, 12, 'meJxzrwl0R0U5C9uAyB1DnCoIYj' +
'gdzCfPCoK6KDGfoC5kw0m1ghgtmOYTaQWRWpAVEG8+msm4tGAqI9I' +
'KrBoJBiDWsCKIsJqf0F8GRJiuJcN8ZKOQDYeLE4xugobDzYewSUoY' +
'xBiObD7QBABMTOo0');
SBMP[1] := BitmapFromString(36, 14, 'meJxzqwl0GwQoZ0ErENHNIgrtIl' +
'I73C7yrCNeL7JFZNhFkl40u0iyjiSNmBYRbxepepHVUBIaboRSMpr' +
'J+O3C6gus2km1i3gE0ZvQV0aMO4lxOR4EtAWCkEXgZqJJUWIX3CKs' +
'BqLJEh8pBO1C9g6dEQA0UXaL');
SBMP[2] := BitmapFromString(37, 16, 'meJxzrQ5wHRwoe34LENHTLgqtI1' +
'473DqybSReL7Jd5FlHkl4060i1kSSNmHaRZB2pepGVkWojmnqCGtE' +
'MpyRYiLcOf8ASg4hJMJiyZFsX11cKRMhcuJkQKbgswWRDpF3I1mHa' +
'BZElJpUSaRcEkZSDyLCRVPOHEwIAf3vRcQ==');
SBMP[3] := BitmapFromString(33, 12, 'meJxzrwl0x0A5C9uACFOcWghiPn' +
'2soJEtyOaTbQV+jWhWkGELfl2Y5pNqBUFdyArIsIWgFjQFpFpBjPf' +
'RpEgKLqzOQ1aQ0F8ORJimYY0aggjTCoj5cCsIxj5B8zEDBG4FxBYK' +
'rUBzMIQNAF4A83M=');
SBMP[4] := BitmapFromString(33, 13, 'meJxzrwl0x0A5C9uACFOcWghiPn' +
'2soJEtyOaTZwVBXWhWkGoLQS2Y5pNkCzFakBWQagUxrkJTQJJHiPQ' +
'7mhSuQCOIsMZIQn85EGHaTp75mK6FmA+3hZjYx4OQjSImEsk2H24F' +
'kEFFW5DNh9sCsQIAUoImOg==');
end;
'pushups': begin
SBMP[0] := BitmapFromString(37, 16, 'meJxzrw1KnFAOQe61QXRAdLZuYF' +
'HuwnYIoqddyIjO1tHIakwzaWc1HkNoYSlB7VQMZ+K1ELSUGHMocSF' +
'J9sKLFMpjgZ6pmnaJihJ7aWcjWmTRoQrAtAsAxiXG8w==');
SBMP[1] := BitmapFromString(39, 16, 'meJxzqwl0qwlM6CuDIDcwlz5oYC' +
'2ls73IKGdBKwTR30ZkNCCW0tQBBG2kugOwmkZre/GbQwt7iTeEin6' +
'nRAsZboCUCZSEFalpD7ksonpqHFRZntb2okUina1DthEAClrmig==');
SBMP[2] := BitmapFromString(43, 16, 'meJxzrQ5wBaO4vlI4coUJ0hMhO2' +
'Cg3ICJsue3ANHA2o6MBtZ2OjuGoANo6hhMk+npBjxm0scNBE2jaWg' +
'QbwiNkgcZuqiSVuEFICUBOLAZh57phFqOoacb0OJ6AK3GtB0AjuAl' +
'9Q==');
SBMP[3] := BitmapFromString(35, 15, 'meJxL6C9P6C93rwmkNUoAW0Qfu9' +
'BQzsI2+tiCiehmEdWtJtIWyu1CM4FGduHSTnUP4ldPUqjit5cYh5F' +
'qHZq9kAxLhvdJsgheMtA00VJoMjGIPkXcgNgCANcMfTY=');
SBMP[4] := BitmapFromString(30, 13, 'meJxL6C9P6C93rwmkOkoAm0wjw5' +
'FRzsI2IKKRsciIdiZTxQo8xlJoC5ouahmOSwvlhuNXTLb7iXQGGVF' +
'Ahu9oEdHEW0G2yQRtAQA8T9+u');
end;
end;
for i := 0 to High(SB) do
begin
for ib := 0 to hb do
begin
if (Result.X > 0) or (Result.Y > 0) then Break;
if (SB[i].X1 > SB[i].X2) or (SB[i].Y1 > SB[i].Y2) then Continue;
if FindDeformedBitmapToleranceIn(SBMP[ib], x, y, SB[i].X1-2, SB[i].Y1-2,
SB[i].X2+2, SB[i].Y2+2, 2, 4, False, Saccuracy) then
begin
Result := Point(x + 20, y + 7);
DD_Message('[DD_FindSign] Matching sign found at : ' + ToStr(Result));
Break;
end;
end;
end;
for ib := 0 to hb do
FreeBitmap(SBMP[ib]);
end;
(**
* Author: DannyRS
* Last Modified: 17/03/2013 - DannyRS
* Description: Attemps to solve the Drill Demon random
*)
function DD_Solve(): boolean;
var
p: TPoint;
t, tmpCompass, tmpCTS, MMoves, debugColorCount: Integer;
tmpHM, tmpSM: Extended;
MatName, LastMatt: String;
begin
Result := False;
if (not LoggedIn) then Exit;
t := GetSystemTime;
tmpCTS := GetColorToleranceSpeed;
GetToleranceSpeed2Modifiers(tmpHM, tmpSM);
tmpCompass := Round(rs_GetCompassAngleDegrees);
SetAngle(SRL_ANGLE_LOW);
MakeCompass('N');
repeat
Result := TabExists(TAB_MAGIC);
if (Result) then Break;
if (not DD_TalkDemon) then
begin
DD_ResetPosition;
Continue;
end;
Wait(RandomRange(1200, 1600));
debugColorCount := CountColor(0, MCX1, MCY1, MCX2, MCY2);
case debugColorCount of
687,988,691 : MatName := 'jog';
707,711 : MatName := 'starjumps';
569,573 : MatName := 'situps';
637,938,641 : MatName := 'pushups';
else
begin
ClickToContinue;
Wait(RandomRange(1200, 1500));
Continue;
end;
end;
DD_Message('[DD_Solve] Last color count: ' + inttostr(debugColorCount));
LastMatt := '';
if (LastMatt = MatName) then
begin
MMoves := 0;
DD_Message('[DD_Solve] Already standing on the matt : ' + MatName);
DD_Message('[DD_Solve] Using matt : ' + MatName + ' again');
repeat
MMouse(246, 184, 40, 30);
MMoves := MMoves + 1;
Wait(RandomRange(90, 340));
if (IsUpTextMultiCustom(['Use','xercise','mat'])) then
begin
ClickMouse2(mouse_right);
Wait(RandomRange(40, 90));
if (ChooseOptionMulti(['Use'])) then
begin
Wait(RandomRange(1200, 1500));
if (WaitFunc(@DD_TalkingToDemon, 50, 15000)) then
begin
DD_Message('[DD_Solve] Used matt successfully');
LastMatt := MatName;
Break;
end else
begin
DD_Message('[ERROR] Failed to use matt');
Break;
end;
end;
end;
until (MMoves > 10);
Continue;
end;
DD_Message('[DD_Solve] Walking to center to search for sign');
if (not DD_ResetPosition) then
begin
DD_Message('[ERROR] Failed to walk to center');
Continue;
end;
DD_Message('[DD_Solve] Searching for sign : ' + MatName);
p := DD_FindSign(MatName);
if (p.x < 0) or (p.y < 0) then
begin
DD_Message('[ERROR] Failed to find sign : ' + MatName);
Continue;
end;
MMoves := 0;
DD_Message('[DD_Solve] Searching for matt : ' + MatName);
repeat
MMouse(p.x - 10, p.y + 64, 50, 30);
//SMART_DrawBoxEx(True,False,IntToBox(p.x-10,p.y+64,p.x+40,p.y+94),clGreen);
MMoves := MMoves + 1;
Wait(RandomRange(90, 340));
if (IsUpTextMultiCustom(['Use','xercise','mat'])) then
begin
ClickMouse2(mouse_right);
Wait(RandomRange(40, 90));
if (ChooseOptionMulti(['Use'])) then
begin
Wait(RandomRange(1200, 1500));
if (WaitFunc(@DD_TalkingToDemon, 50, 15000)) then
begin
DD_Message('[DD_Solve] Used matt successfully');
LastMatt := MatName;
Break;
end else
begin
DD_Message('[ERROR] Failed to use matt');
Break;
end;
end;
end;
until (MMoves > 10);
Result := TabExists(TAB_MAGIC);
until (Result) or (GetSystemTime - t > 240000);
if (not Result) then
begin
if (GetSystemTime - t > 240000) then
DD_Message('[ERROR] DrillDemon solver timed out');
end else
Wait(RandomRange(1200, 1600));
SetAngle(SRL_ANGLE_HIGH);
MakeCompass(tmpCompass);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(tmpHM, tmpSM);
end;
Beta fixes
Use at your own risk.
Fixing the strange box random. Changed dtm-finding to bmptol-finding for the box item, fast and accurate. Added wait times and score requirements to the item and number scanning, getting a much higher solve rate, roughly 80% and significantly less extra boxes from in-game time-outs. Call it with SolveBox; because it's not included in the normal random-finding routines.
Known issues: Circle and stars are sometimes confused, as are pentagons and squares (not as commonly). Numberscan has problems reading 6 and 9 sometimes. Numbers and shapes will sometimes be incorrect, around 4/7 boxes will read all shapes and numbers perfectly, the rest are made up of partially correct scans and fast-spinning boxes. Client was lagging-out after doing a few full inventories of boxes, needs more testing. I accidentally left the loadshapes and loadnumbers calls inside a loop and was caching a ton of dtm's. Pretty sure it's fixed now..
box.simba
Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ? Box Routines --//
//-----------------------------------------------------------------//
// * function GambleBox: Boolean; // * by WT-Fakawi
// * function GetBoxSide: Integer; // * by pups/Ashaman88
// * function GetQuestion(var num: Integer; var shape: string): Integer; // * by pups
// * function GetNumber: Integer; // * by Ashaman88
// * function GetShape: String; // * by Ashaman88
// * function OpenBox: Boolean; // * by Ashaman88
// * function SolveBox: Boolean; // * by Ashaman88
//{$I SRL-OSR/SRL/misc/Debug.Simba}
//{$I SRL-OSR/SRL/misc/SmartGraphics.Simba}
var
NumberBounds: TBox;
const
DebugBox=False;
{*******************************************************************************
function GambleNewBox: Boolean;
by: WT-Fakawi (left this in here just in case we want to guess)
Description: A random box clicker. Will try to solve the box ONCE, by a random click
@ any of the three answers. THIS IS NOT A BOXSOLVER, JUST A BOXCLICKER!
*******************************************************************************}
function GambleBox: Boolean;
var
xb, yb, Choise: Integer;
begin
//if FindBitmapToleranceIn(Box, xb, yb, MIX1, MIY1, MIX2, MIY2, 40) then
begin
Mouse(xb, yb, 0, 0, True);
Wait(2000);
Choise:= Random(3);
TakeScreen('Gambling box Choise - '+IntToStr(Choise));
case Choise of
0: Mouse(145, 295, 4, 4, True);
1: Mouse(270, 295, 4, 4, True);
2: Mouse(381, 295, 4, 4, True);
end;
IdleTime(4000, 2000, 1.0);
// if FindBitmapToleranceIn(Box, xb, yb, MIX1, MIY1, MIX2, MIY2, 40) then
begin
WriteLn('Box Missed');
// NOnewboxes := NOnewboxes + 1;
Result := False;
repeat
Logout;
until (not (LoggedIn));
Exit;
end
//else
begin
WriteLn('Box solved');
// newboxes := newboxes + 1;
Result := True;
end;
end;
end;
{*******************************************************************************
function OpenBox: Boolean;
by: Ashaman88
Description: Opens the box.
*******************************************************************************}
function OpenBox : Boolean;
var
x, y, i : Integer;
SBMP: TIntegerArray;
begin
Result := False;
SetLength(SBMP, 1);
GameTab(Tab_Inv);
Wait(100 + Random(50));
SBMP[0] := BitmapFromString(22, 15, 'meJxzdHR3BCMbGycgGR2dTBDp6h' +
'pCtISHxwMRXDsxejG1oyFHmHuwOkZeXhFNb3BwFFZzsBoIR3DZsrJ' +
'GIMJvAi4E0YtsgpdXILIgENnbu0AQMHwgCKt2PCagISsre/wm+PgG' +
'D7gJfv5hA25CQGDEgJsATJwDYgJcBAD7lYWZ');
if FindBitmapToleranceIn(SBMP[0], x, y, MIX1, MIY1, MIX2, MIY2, 40) then
begin
Mouse(x, y, 4, 4, True);
for i := 0 to 9 do
begin
if (GetColor(487, 39) = 13567) and (GetColor(350, 295) = 2304814) then
begin
Result := True;
Break;
end;
Wait(500 + Random(50));
end;
end;
FreeBitmap(SBMP[0]);
end;
type
NumberRotate = record
Number, DTM, BMin, BMax, WMin, WMax: integer;
end;
NumberRotateArray = array of NumberRotate;
var
NumberArray: NumberRotateArray;
{*******************************************************************************
procedure LoadNumbers;
by: Ashaman88
Description: Loadsup all the numbers!
*******************************************************************************}
procedure LoadNumbers;
begin
if Length(NumberArray)<>0 then
Exit;
SetLength(NumberArray,10);
with NumberArray[0] do {Good2}
begin
Number := 0;
DTM := DTMFromString('mYQMAAHic1c5bCsIwFIThExWr9YJ2F766D99dhptRRFREii0i7jDgBH8xFIX2TQMfpyQzaWZm1nNmiXvPvqQfhP2xjGRAtiudSEJ2iJDPZIoJ/VfP4KSFNudp1N8rdpJcLlIyc/aP9sycmTvZIu6G3hVlpR++C87uuFVyh+juNTb8w3tf22q5aKzJ/d/M9c5f5/5A7fUAGciE0g==');
BMin := 125;
BMax := 215;
WMin := 160;
WMax := 30;
end;
with NumberArray[1] do {Good}
begin
Number := 1;
DTM := DTMFromString('mggAAAHicY2NgYGBigABmIGaBshmBmA+IuaFYCirOAcT1mXEMf//8AWMQG4aNgHLYMBMODAEARdcMkQ==');
BMin := 85;
BMax := 130;
WMin := 0;
WMax := 100;
end;
with NumberArray[2] do {Good2}
begin
Number := 2;
DTM := DTMFromString('mygMAAHic1c5bCoJQFIXh43uWkdnNaAY9NKOG0Dyigkq7XyypqCkK/dESojepF4WP7dlu1z5dY4xjGVOGi6pUrHe/BBsFVVt9R72XouZraEgdnjLTLE/ffElnWzp3VNuqTWW6+t9XbnoOufsMcyywxh4RYhxwwgZLrLBFgCnGmOg90MwOR5xxwfVLLNHHrpt2hMp6ZQ4/3OUhSZL8bDToZ/KPnT3unkdWTmV7nhL4nss=');
BMin := 0;
BMax := 1000;
WMin := 0;
WMax := 1000;
end;
with NumberArray[3] do {Good2}
begin
Number := 3;
DTM := DTMFromString('mHgQAAHic3c/PDsFAEAbwGZTwOH0eF2cnT+EiJaJII0gJ4gn92/KNfomN7MVN2uSXndmd/drGIvIAUZGalmuB5Sllr1Rwzvi1412r73SDK+csowktaEMnwPYb+sm5MNu+QXlmGRHUKeKef29KKSwhgxVsIYc9Wb2BNc8zzs9ozt6yJjCihL3tL77yLfcAZ4/1JziS9TvO++9NmTkm59zfSQa9oGG/+xY6i/EvVaAV8fvzApQlvTI=');
BMin := 140;
BMax := 220;
WMin := 300;
WMax := 550;
end;
with NumberArray[4] do {Good2}
begin
Number := 4;
DTM := DTMFromString('mygMAAHic1c5dCoJAFAXga1ipRVnto4eWUguIVhG0loiIDEn7ISSjvQ11Bs7ALXrxoQcHPgauc49nLCKRJ9KliAJoQxN8aEGDt3vfhxhG0FPcPFa5HWa6HJ/ZdhZyb8Asa6i4rFDtv9A7hw1sYQd7SCClDE5whotyVbMjHLh7gwJKKjj7dqcHPKnkt4z/TtjJ9luzY8rOxhhZLWaVLefTj/sXm/0vE3SvI6+mqp033MCMjw==');
BMin := 130;
BMax := 300;
WMin := 200;
WMax := 450;
end;
with NumberArray[5] do {Good2}
begin
Number := 5;
DTM := DTMFromString('mXQQAAHic3c9dDsFAFAXg26pWikosRWIZ3i3DAhBpCFHx/x8RLJMMzo0jGk9Sb23ypbczp/fOVEXkAZYl4oBHDrlgw1009Mq9a8O35nLgQx4KpGtZcsljLoArfr/Jp58dk2FWc2X2878UqUQBZ+p5tmi5J60XtKZNrNb1OczgAMcY/d4xt4QpTCCCPoTQoZCzNDeiAXS534YmtJjtcU8zQxizp85YcfYJLnAGY0wijXrtL0nn/qKCe6WNlUKJnifIELAH');
BMin := 230;
BMax := 300;
WMin := 340;
WMax := 900;
end;
with NumberArray[6] do {Good2B}
begin
Number := 6;
DTM := DTMFromString('mSAQAAHic3c/bCgFRFAbgtYcijyOXbr2DZ5Gc0yTKYXI+xptw52GUGIxJ/t38w+QOd7Pra7da/9qHlIgklEgM4hT98EDmDEc40QXu4vUMZkR5XGxXcphxAzmHtT9jBO6KqHf+xjNs3n8IvMFm3z/XYa0zS1jBHKYwgQFY0IE2daEPY5gxv+A+Yq/HnJ4dMmtRk1rQABPqUIMyFCAPJaiyZ5I/azJfgSLkYA0b/kG/IZtJy363fdH1t4Lz//r3jiT+FCYqZH5ZT1UtpIA=');
BMin := 160;
BMax := 440;
WMin := 300;
WMax := 600;
end;
with NumberArray[7] do {Good2}
begin
Number := 7;
DTM := DTMFromString('mIgMAAHiczc5hCoJAEAXgtyoZQtfwAN2oI3SD0JCIEiuR8KjiRm/wBUu/8k+48LHsvGFmcwAjwQEJrWWldySQTPWYnGqe10sQ9A6aHbKa9dvMlDaaGe79OGJSSkUXaqiljp7UU0En5Td6KGv1rpVZz1U1y86aa3sOgUKZ7bp/7av3u1m893+x5d+WyC3Ub+cNI6GFkQ==');
BMin := 140;
BMax := 220;
WMin := 200;
WMax := 550;
end;
with NumberArray[8] do {Good2}
begin
Number := 8;
DTM := DTMFromString('mtQMAAHic1c7NCoJAFIbhMyJZVibeR5vuo313EAWVVKRUhEVdttA3+AZuhTYKD2eO52dmbmYDZxZJLEPX5CHnCCOZEBPOEX1BS8i87xvTNyXG1HyfiWPXTDKk5CkS3vGbCdhxULqzJh7lTMzlJg+5c76SV/KSZ6vua6UUuMiJPX7/FvvWPSV7K2LB/5y+jayZ87WPvKWu607y1fLvur5hoXf3jeuhTt8X9gh9aA==');
BMin := 130;
BMax := 400;
WMin := 200;
WMax := 450;
end;
with NumberArray[9] do {Good2}
begin
Number := 9;
DTM := DTMFromString('mdgMAAHic1c7NCgFRGMbxM4U0Jh8TwzVYWstOuQTltoTEyCShIffAzk15Tv5Tp0aysDH16z3zdOZ5p2uMqXjGVKUuAecyAvJQWtLkXJMG096JnDzkns3a0kFER0inz46SFFB0dvvOtDtW5iWWDTMmW2BJtpUdcy8nOctFrkjJj9xNZE3HTKaOOXnWn/CN7T7QlfL+uN9yxsP+R5PRIJe96/mFrLunf/0H3p/4/nkC/OhyWw==');
BMin := 160;
BMax := 440;
WMin := 300;
WMax := 600;
end;
End;
{*******************************************************************************
procedure FreeNumbers;
by: Ashaman88
Description: Frees the number dtms!
*******************************************************************************}
procedure FreeNumbers;
var
I: Integer;
begin
for i := 0 to high(NumberArray) do
FreeDTM(NumberArray[i].DTM);
end;
{*******************************************************************************
function GetNumber: Integer;
by: Ashaman88.
Description: Gets the number on the side of the box.
*******************************************************************************}
function GetNumber: Integer;
var
i, maxScore, maxIndex: integer;
CTS,X,Y: Integer;
MidBox: TPoint;
TPA,TPA1,TPA2,TPAW: TPointArray;
ATPA: T2DPointArray;
BrownBox: TBox;
afound: Extended;
scores: TintegerArray;
begin
LoadNumbers;
repeat
result:= -1;
setLength(scores, length(NumberArray));
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.31);
MidBox:=MiddleBox(IntToBox(NumberBounds.X1+5, NumberBounds.Y1+5, NumberBounds.X2-5, NumberBounds.Y2-5));
FindColorsSpiralTolerance(MidBox.X, MidBox.Y, TPA, 6187391, NumberBounds.X1, NumberBounds.Y1, NumberBounds.X2, NumberBounds.Y2, 16);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
ATPA:=FloodFillTPA(TPA);
if Length(ATPA)=0 then
begin
Writeln('No brown found');
Exit;
end;
if DebugBox then
begin
// DebugATPABounds(ATPA);
Writeln('Length of Brown Shape: '+ToStr(Length(ATPA[0])));
End;
BrownBox:=GetTPABounds(ATPA[0]);
FindColorsSpiralTolerance(MSCX, MSCY, TPA1, 16579837, BrownBox.X1, BrownBox.Y1, BrownBox.X2, BrownBox.Y2, 5);
FindColorsSpiralTolerance(MSCX, MSCY, TPA2, 12764106, BrownBox.X1, BrownBox.Y1, BrownBox.X2, BrownBox.Y2, 5);
TPAW:=CombineTPA(TPA1,TPA2);
if DebugBox then
Writeln('Length of White TPA in Brown: '+ToStr(Length(TPAW)));
// loop through fields, scoring each item
for i := 0 to high(NumberArray) do
begin
if inRange(Length(ATPA[0]), NumberArray[i].Bmin, NumberArray[i].BMax) then
scores[i] := scores[i] + 1;
if inRange(Length(TPAW), NumberArray[i].Wmin, NumberArray[i].WMax) then
scores[i] := scores[i] + 1;
if findDTMrotated(NumberArray[i].DTM, x, y, BrownBox.X1-3, BrownBox.Y1-3, BrownBox.X2+3, BrownBox.Y2+3,-Pi,Pi,Pi/30,aFound) then
scores[i] := scores[i] + 5;
//wait(1);
end;
// get the item with the highest score
maxScore := -1;
maxIndex := -1;
for i := 0 to high(scores) do
if (scores[i] > maxScore) then
begin
maxScore := scores[i];
maxIndex := i;
end;
if maxindex<>-1 then
begin
if (NumberArray[maxIndex].number = 1) then
begin
if (scores[maxIndex] < 12) then
begin
writeln('NumberScan: '+ToStr(NumberArray[maxIndex].number) + ', with a score of ' + intToStr(scores[maxIndex]));
result := NumberArray[maxIndex].number;
end;
end else
if ((scores[maxIndex] > 10) or (NumberArray[maxIndex].number = 0) or ((scores[maxIndex] > 3) and (NumberArray[maxIndex].number = 8))) then
begin
writeln('NumberScan: '+ToStr(NumberArray[maxIndex].number) + ', with a score of ' + intToStr(scores[maxIndex]));
result := NumberArray[maxIndex].number;
end;
end;
wait(1);
until(result > -1);
SetLength(ATPA,0);
SetLength(TPA,0);
SetLength(TPA1,0);
SetLength(TPA2,0);
SetLength(TPAW,0);
end;
type
ShapeRotate = record
Shape: String;
SMin, SMax, WMin, WMax, BMin, BMax : integer;
end;
ShapeRotateArray = array of ShapeRotate;
var
ShapeArray: ShapeRotateArray;
{*******************************************************************************
procedure LoadShapes;
by: Ashaman88
Description: Loadsup all the shapes!
*******************************************************************************}
Procedure LoadShapes;
begin
if Length(ShapeArray)<>0 then
Exit;
SetLength(ShapeArray,5);
with ShapeArray[0] do {Good2}
begin
Shape := 'Triangle';
SMin := 10;
SMax := 13;
WMin := 4600;
WMax := 4900;
BMin := 3200;
BMax := 4500;
end;
with ShapeArray[1] do {Good2}
begin
Shape := 'Square';
SMin := 8;
SMax := 13;
WMin := 5000;
WMax := 5800;
BMin := 100;
BMax := 2500;
end;
with ShapeArray[2] do {Good2}
begin
Shape := 'Star';
SMin := 15;
SMax := 17;
WMin := 4100;
WMax := 4400;
BMin := 7500;
BMax := 8400;
end;
with ShapeArray[3] do {Good2}
begin
Shape := 'Circle';
SMin := 17;
SMax := 20;
WMin := 7000;
WMax := 7500;
BMin := 300;
BMax := 1300;
end;
with ShapeArray[4] do {Good}
begin
Shape := 'Pentagon';
SMin := 8;
SMax := 16;
WMin := 4400;
WMax := 4800;
BMin := 1600;
BMax := 2400;
end;
End;
{*******************************************************************************
function GetShape: String;
by: Ashaman88.
Description: Gets the shape on the side of the box.
*******************************************************************************}
Function GetShape: String;
Var
i, maxScore, maxIndex, tries: integer;
CTS: Integer;
TPA,TPA1,TPA2, TPAB: TPointArray;
ATPA,ATPAB: T2DPointArray;
WhiteBox: TBox;
scores: TintegerArray;
begin
LoadShapes;
tries:= 0;
repeat
setLength(scores, length(shapeArray));
Result:='';
FindColorsSpiralTolerance(MSCX, MSCY, TPA1, 16579837, 172, 45, 352, 225, 5);
FindColorsSpiralTolerance(MSCX, MSCY, TPA2, 12764106, 172, 45, 352, 225, 5);
TPA:=CombineTPA(TPA1,TPA2);
ATPA:=FloodFillTPA(TPA);
SortATPASize(ATPA,True);
if DebugBox then
Writeln('Length of Full White ATPA: '+ToStr(Length(ATPA)));
if Length(ATPA)=0 then
begin
Writeln('No white found');
Exit;
End;
//if DebugBox then
// DebugATPABounds(ATPA);
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
WhiteBox:=GetTPABounds(ATPA[0]);
NumberBounds:=WhiteBox;
SetColorSpeed2Modifiers(0.05, 0.31);
FindColorsSpiralTolerance(MSCX, MSCY, TPAB, 6187391, WhiteBox.X1, WhiteBox.Y1, WhiteBox.X2, WhiteBox.Y2, 16);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
SplitTPAWrap(TPAB,10,ATPAB);
SortATPASize(ATPAB,True);
if DebugBox then
begin
Writeln('Length of Shape: '+ToStr(Length(ATPA[0])));
Writeln('Length of OutterBox: '+ToStr(Length(ATPAB[0])));
end;
// loop through fields, scoring each item
for i := 0 to high(ShapeArray) do
begin
if inRange(Length(ATPA[0]), ShapeArray[i].Wmin, ShapeArray[i].WMax) then
scores[i] := scores[i] + 2;
if inRange(Length(ATPAB[0]), ShapeArray[i].Bmin, ShapeArray[i].BMax) then
scores[i] := scores[i] + 1;
if inRange(Length(ATPA), ShapeArray[i].Smin, ShapeArray[i].SMax) then
scores[i] := scores[i] + 4;
//wait(1);
end;
// get the item with the highest score
maxScore := -1;
maxIndex := -1;
for i := 0 to high(scores) do
if (scores[i] > maxScore) then
begin
maxScore := scores[i];
maxIndex := i;
end;
if maxindex<>-1 then
begin
if (ShapeArray[maxIndex].shape = 'Triangle') then
begin
if (scores[maxIndex] > 4) then
begin
writeln('ShapeScan: '+ShapeArray[maxIndex].shape + ', with a score of ' + intToStr(scores[maxIndex]));
result := ShapeArray[maxIndex].shape;
end;
end else
if (ShapeArray[maxIndex].shape = 'Star') then
begin
if (scores[maxIndex] > 4) then
begin
writeln('ShapeScan: '+ShapeArray[maxIndex].shape + ', with a score of ' + intToStr(scores[maxIndex]));
result := ShapeArray[maxIndex].shape;
end;
end else
if (ShapeArray[maxIndex].shape = 'Circle') then
begin
if (scores[maxIndex] > 6) then
begin
writeln('ShapeScan: '+ShapeArray[maxIndex].shape + ', with a score of ' + intToStr(scores[maxIndex]));
result := ShapeArray[maxIndex].shape;
end;
end else
if ((ShapeArray[maxIndex].shape = 'Pentagon') or (ShapeArray[maxIndex].shape = 'Square')) then
begin
if (scores[maxIndex] > 10) then
begin
writeln('ShapeScan: '+ShapeArray[maxIndex].shape + ', with a score of ' + intToStr(scores[maxIndex]));
result := ShapeArray[maxIndex].shape;
end;
end else
if ((scores[maxIndex] > 5) or (tries > 50)) then
begin
writeln('ShapeScan: '+ShapeArray[maxIndex].shape + ', with a score of ' + intToStr(scores[maxIndex]));
result := ShapeArray[maxIndex].shape;
end;
end;
wait(10 + random(5));
tries:= tries + 1;
until(not(result = ''));
SetLength(ATPA,0);
SetLength(TPA,0);
SetLength(TPA1,0);
SetLength(TPA2,0);
SetLength(ATPAB,0);
SetLength(TPAB,0);
end;
{*******************************************************************************
function GetBoxSide: Integer;
by: pups/Ashaman88
Description: Gets Box side and freezes client
*******************************************************************************}
Procedure GetBoxSide;
var
X,Y: Integer;
begin
repeat
wait(100);
if FindColorTolerance(x, y, 16579837, 182, 45, 182, 225, 5) then continue;
if FindColorTolerance(x, y, 16579837, 342, 45, 342, 225, 5) then continue;
if FindColorTolerance(x, y, 16579837, 172, 55, 352, 55, 5) then continue;
if FindColorTolerance(x, y, 16579837, 172, 215, 352, 215, 5) then continue;
if FindColorTolerance(x, y, 12764106, 182, 45, 182, 225, 5) then continue;
if FindColorTolerance(x, y, 12764106, 342, 45, 342, 225, 5) then continue;
if FindColorTolerance(x, y, 12764106, 172, 55, 352, 55, 5) then continue;
if FindColorTolerance(x, y, 12764106, 172, 215, 352, 215, 5) then continue;
Break;
until False;
Freeze;
end;
{*******************************************************************************
function GetQuestion(var num: Integer; var shape: String): Integer;
by: pups
Description: Returns number and type.
*******************************************************************************}
function GetQuestion(var num: Integer; var shape: string): Integer;
var
x, y, i: Integer;
text: string;
begin
num := 10;
shape := '';
for i := 0 to 14 do
begin
case i of
0: text := '0'; //Zero
1: text := '1'; //One
2: text := '2'; //Two
3: text := '3'; //Three
4: text := '4'; //Four
5: text := '5'; //Five
6: text := '6'; //Six
7: text := '7'; //Seven
8: text := '8'; //Eight
9: text := '9'; //Nine
10: text := 'Circle'; //Circle
11: text := 'Triangle'; //Triangle
12: text := 'Square'; //Square
13: text := 'Star'; //Star
14: text := 'Pentagon'; //Pentagon
end;
if (FindText(x, y, Text, upchars07, 110, 250, 415, 275)) then
begin
Result := i;
if (i < 10) then
num := i;
if (i >= 10) then
shape := text;
Exit;
end;
end;
end;
{*******************************************************************************
function SolveBox: Boolean;
by: Ashaman88
Description: Solves the Box!
*******************************************************************************}
function SolveBox: Boolean;
var
st2: Integer;
shapeQ, shape, ans: string;
numQ, num: Integer;
x, y: Integer;
begin
while OpenBox do
begin
WriteLn('Found a box, solving...');
Wait(1000);
GetQuestion(numQ, shapeQ);
if (shapeQ = '') and (numQ = 10) then
exit;
WriteLn('Question is:');
if shapeQ = '' then
WriteLn('Which shape has number ' + IntToStr(numQ))
else
WriteLn('What number is the ' + shapeQ);
st2 := GetSystemTime;
repeat
GetBoxSide;
Shape:=GetShape;
Num:=GetNumber;
UnFreeze;
if DebugBox then
Wait(2000) Else
if (num = numQ) or (shape = shapeQ) then
begin
if num = numQ then
ans := shape
else
ans := IntToStr(num);
WriteLn('Answer is ' + ans);
if FindText(x, y, ans, upchars07, 116, 286, 183, 311) then
MouseBox(123, 290, 179, 308, mouse_left);
Wait(150 + Random(100));
if FindText(x, y, ans, upchars07, 235, 286, 302, 311) then
MouseBox(240, 291, 298, 310, mouse_left);
Wait(150 + Random(100));
if FindText(x, y, ans, upchars07, 350, 286, 417, 311) then
MouseBox(356, 286, 415, 309, mouse_left);
Wait(150 + Random(100));
//ClickMouse2(mouse_left);
WriteLn('******** SOLVED BOX RANDOM ********');
Result := True;
Break;
end;
until GetSystemTime > st2 + 12000;
Wait(1500 + Random(1000));
end;
if Length(NumberArray)>0 then
begin
FreeNumbers;
SetLength(NumberArray,0);
end;
if Length(ShapeArray)>0 then
SetLength(ShapeArray,0);
end;
On the Agenda
These randoms are either broken or disabled and are very common. Suggest any which aren't working for you.
- Forester
- Mime
- Prison Pete
- Molly
- Maze
- Quiz
- Mordaut