PDA

View Full Version : Drill Demon



Justin
03-18-2013, 06:19 AM
Solver seems broken

http://puu.sh/2jJv5/fbcac3ac30


***** Found Random: Drill Demon *****
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [DD_TalkDemon] Talked to demon
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [ERROR] Failed to find sign : jog
[DemonDrill Random] [ERROR] DrillDemon solver timed out
***** Failed Random: Drill Demon *****
Successfully executed.
The following bitmaps were not freed: [3, 4]


DannyRS Let me know if you want the account to test.

DannyRS
03-18-2013, 09:22 AM
I think it's the bitmap for jog, that sign looks much more clear in that position, hmm, might have to add two for it, or tweak the deformed tolerance, if I could borrow the acc it would help ;)

DannyRS
03-18-2013, 02:28 PM
Justin,

Tweaked and changed a few things, left you in random so you can do a full run-time test before I pull, it's a tad slower but more accurate :p


program new;

{$DEFINE SMART8}
{$I SRL-OSR/SRL.simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;

begin
DeclarePlayers;
SetupSRL;
LoginPlayer;
FindNormalRandoms;
end.



(*
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, 2);

hb := High(SBMP);

SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);

case LowerCase(WhichSign) of
'jog': begin
SBMP[0] := BitmapFromString(26, 17, 'meJxzqwl0w0AJfWUQhMYmD2E1jR' +
'IDIShrdhMQwa2grmlkGwgxB4IodxVaMFLXNGQDKYwRNM+SHcv IQQf' +
'XS57b0CICOQVSYhSmH8k2jSrxOJhNc0PNVhQiKhYdbuQmKgBk SPbW');
SBMP[1] := BitmapFromString(29, 10, 'meJxzrQ5wJRrF9ZUSr3gwGItsMh' +
'qXbJQ5qxGI4EZRxViImRBjIaZRbizcTGR3UmgsmpnUCltcxlI rVKl' +
'rLNxk4tUDAIc3Qs8=');
end;
'starjumps': begin
SBMP[0] := BitmapFromString(33, 17, 'meJxzqwl0Ixol9JUBEfHqSUUQ8+' +
'lmC4Xm5CxohSNaqMeqkSCilo+objhBu6ge0cPAClrHAi4rqGg LHZI' +
'TprHUtQWXsym3Al4Q4XIwsjh5pRa8uMPjWmTzyS4Y4bbgCUZi SngA' +
'a5KX0w==');
SBMP[1] := BitmapFromString(37, 16, 'meJxzrQ5wJR3F9ZXCERnacaHs+S' +
'34raOiXXAbIYjqJhNjKfGIPjbSx5t0C1U6RyI97Ro21tEtNdL HOuR' +
'iCtN8qtuIXDBiNZlGHgQiXMbSIgbh1uGJUyKrJAA7N7QN');
end;
'situps': begin
SBMP[0] := BitmapFromString(36, 14, 'meJxzqwl0GwQoZ0ErENHNIgrtIl' +
'I73C7yrCNeL7JFZNhFkl40u0iyjiSNmBYRbxepepHVUBIaboR SMpr' +
'J+O3C6gus2km1i3gE0ZvQV0aMO4lxOR4EtAWCkEXgZqJJUWIX 3CKs' +
'BqLJEh8pBO1C9g6dEQA0UXaL');
SBMP[1] := BitmapFromString(37, 16, 'meJxzrQ5wHRwoe34LENHTLgqtI1' +
'473DqybSReL7Jd5FlHkl4060i1kSSNmHaRZB2pepGVkWojmnq CGtE' +
'MpyRYiLcOf8ASg4hJMJiyZFsX11cKRMhcuJkQKbgswWRDpF3I 1mHa' +
'BZElJpUSaRcEkZSDyLCRVPOHEwIAf3vRcQ==');
end;
'pushups': begin
SBMP[0] := BitmapFromString(39, 16, 'meJxzqwl0qwlM6CuDIDcwlz5oYC' +
'2ls73IKGdBKwTR30ZkNCCW0tQBBG2kugOwmkZre/GbQwt7iTeEin6' +
'nRAsZboCUCZSEFalpD7ksonpqHFRZntb2okUina1DthEAClrm ig==');
SBMP[1] := BitmapFromString(43, 16, 'meJxzrQ5wBaO4vlI4coUJ0hMhO2' +
'Cg3ICJsue3ANHA2o6MBtZ2OjuGoANo6hhMk+npBjxm0scNBE2 jaWg' +
'QbwiNkgcZuqiSVuEFICUBOLAZh57phFqOoacb0OJ6AK3GtB0A juAl' +
'9Q==');
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: 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));

case CountColor(0, MCX1, MCY1, MCX2, MCY2) of
687,988 : MatName := 'jog';
707 : MatName := 'starjumps';
569 : MatName := 'situps';
637,938 : MatName := 'pushups';
else
begin
ClickToContinue;
Wait(RandomRange(1200, 1500));
Continue;
end;
end;

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;

Justin
03-18-2013, 09:38 PM
Justin,

Tweaked and changed a few things, left you in random so you can do a full run-time test before I pull, it's a tad slower but more accurate :p


program new;

{$DEFINE SMART8}
{$I SRL-OSR/SRL.simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;

begin
DeclarePlayers;
SetupSRL;
LoginPlayer;
FindNormalRandoms;
end.



(*
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, 2);

hb := High(SBMP);

SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);

case LowerCase(WhichSign) of
'jog': begin
SBMP[0] := BitmapFromString(26, 17, 'meJxzqwl0w0AJfWUQhMYmD2E1jR' +
'IDIShrdhMQwa2grmlkGwgxB4IodxVaMFLXNGQDKYwRNM+SHcv IQQf' +
'XS57b0CICOQVSYhSmH8k2jSrxOJhNc0PNVhQiKhYdbuQmKgBk SPbW');
SBMP[1] := BitmapFromString(29, 10, 'meJxzrQ5wJRrF9ZUSr3gwGItsMh' +
'qXbJQ5qxGI4EZRxViImRBjIaZRbizcTGR3UmgsmpnUCltcxlI rVKl' +
'rLNxk4tUDAIc3Qs8=');
end;
'starjumps': begin
SBMP[0] := BitmapFromString(33, 17, 'meJxzqwl0Ixol9JUBEfHqSUUQ8+' +
'lmC4Xm5CxohSNaqMeqkSCilo+objhBu6ge0cPAClrHAi4rqGg LHZI' +
'TprHUtQWXsym3Al4Q4XIwsjh5pRa8uMPjWmTzyS4Y4bbgCUZi SngA' +
'a5KX0w==');
SBMP[1] := BitmapFromString(37, 16, 'meJxzrQ5wJR3F9ZXCERnacaHs+S' +
'34raOiXXAbIYjqJhNjKfGIPjbSx5t0C1U6RyI97Ro21tEtNdL HOuR' +
'iCtN8qtuIXDBiNZlGHgQiXMbSIgbh1uGJUyKrJAA7N7QN');
end;
'situps': begin
SBMP[0] := BitmapFromString(36, 14, 'meJxzqwl0GwQoZ0ErENHNIgrtIl' +
'I73C7yrCNeL7JFZNhFkl40u0iyjiSNmBYRbxepepHVUBIaboR SMpr' +
'J+O3C6gus2km1i3gE0ZvQV0aMO4lxOR4EtAWCkEXgZqJJUWIX 3CKs' +
'BqLJEh8pBO1C9g6dEQA0UXaL');
SBMP[1] := BitmapFromString(37, 16, 'meJxzrQ5wHRwoe34LENHTLgqtI1' +
'473DqybSReL7Jd5FlHkl4060i1kSSNmHaRZB2pepGVkWojmnq CGtE' +
'MpyRYiLcOf8ASg4hJMJiyZFsX11cKRMhcuJkQKbgswWRDpF3I 1mHa' +
'BZElJpUSaRcEkZSDyLCRVPOHEwIAf3vRcQ==');
end;
'pushups': begin
SBMP[0] := BitmapFromString(39, 16, 'meJxzqwl0qwlM6CuDIDcwlz5oYC' +
'2ls73IKGdBKwTR30ZkNCCW0tQBBG2kugOwmkZre/GbQwt7iTeEin6' +
'nRAsZboCUCZSEFalpD7ksonpqHFRZntb2okUina1DthEAClrm ig==');
SBMP[1] := BitmapFromString(43, 16, 'meJxzrQ5wBaO4vlI4coUJ0hMhO2' +
'Cg3ICJsue3ANHA2o6MBtZ2OjuGoANo6hhMk+npBjxm0scNBE2 jaWg' +
'QbwiNkgcZuqiSVuEFICUBOLAZh57phFqOoacb0OJ6AK3GtB0A juAl' +
'9Q==');
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: 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));

case CountColor(0, MCX1, MCY1, MCX2, MCY2) of
687,988 : MatName := 'jog';
707 : MatName := 'starjumps';
569 : MatName := 'situps';
637,938 : MatName := 'pushups';
else
begin
ClickToContinue;
Wait(RandomRange(1200, 1500));
Continue;
end;
end;

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;


if (ChooseOptionMulti(['Use'])) then
Why ChooseOptionMulti if you only use 1 option

DannyRS
03-18-2013, 11:16 PM
Why ChooseOptionMulti if you only use 1 option

I removed the others because it should be 100% accurate on 07 and forgot to change, does the solver work lol ?

Anyways it's late here, I'm away to bed, if it works, send a Pull :p

Ashaman88
03-19-2013, 03:10 AM
I removed the others because it should be 100% accurate on 07 and forgot to change, does the solver work lol ?

Anyways it's late here, I'm away to bed, if it works, send a Pull :p

***** Found Random: Drill Demon *****
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [DD_GetSigns] Number of signs located : 4
[DemonDrill Random] [DD_FindSign] Matching sign found at : (69, 97)
[DemonDrill Random] [DD_Solve] Searching for matt : jog
[DemonDrill Random] [DD_Solve] Used matt successfully
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : pushups
[DemonDrill Random] [DD_GetSigns] Number of signs located : 3
[DemonDrill Random] [DD_FindSign] Matching sign found at : (303, 119)
[DemonDrill Random] [DD_Solve] Searching for matt : pushups
[DemonDrill Random] [DD_Solve] Used matt successfully
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [DD_GetSigns] Number of signs located : 4
[DemonDrill Random] [DD_FindSign] Matching sign found at : (58, 97)
[DemonDrill Random] [DD_Solve] Searching for matt : jog
[DemonDrill Random] [DD_Solve] Used matt successfully
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : starjumps
[DemonDrill Random] [DD_GetSigns] Number of signs located : 4
[DemonDrill Random] [DD_FindSign] Matching sign found at : (189, 107)
[DemonDrill Random] [DD_Solve] Searching for matt : starjumps
[DemonDrill Random] [DD_Solve] Used matt successfully
[DemonDrill Random] [DD_Solve] Walking to center to search for sign
[DemonDrill Random] [DD_Solve] Searching for sign : jog
[DemonDrill Random] [DD_GetSigns] Number of signs located : 3
[DemonDrill Random] [DD_FindSign] Matching sign found at : (74, 97)
[DemonDrill Random] [DD_Solve] Searching for matt : jog
[DemonDrill Random] [DD_Solve] Used matt successfully
***** Solved Random: Drill Demon *****

worked for me :) Gj!

DannyRS
03-19-2013, 02:18 PM
worked for me :) Gj!

Great ;)

If theres a whole tonne of people / broken bots in front of the signs, then you would probably fail lol, but Idk what can be done for that in color, detecting the signs is hard enough when you can see them ;)

Theres also the camera angle swap, if a scripter needs it low, then they'll have to manually change it back after a random event, because it's pretty impossible to detect signs at high camera angle, it's even hard actually doing it yourself, I saved the compass direction, and the default angle is reset to high, because who really uses low :p, theres no way to save what angle their using right?

Ashaman88
03-19-2013, 02:23 PM
Great ;)

If theres a whole tonne of people / broken bots in front of the signs, then you would probably fail lol, but Idk what can be done for that in color, detecting the signs is hard enough when you can see them ;)

Theres also the camera angle swap, if a scripter needs it low, then they'll have to manually change it back after a random event, because it's pretty impossible to detect signs at high camera angle, it's even hard actually doing it yourself, I saved the compass direction, and the default angle is reset to high, because who really uses low :p, theres no way to save what angle their using right?

Not that I know of, but I'm not positive. It didn't have any trouble solving it for me :)

DannyRS
03-19-2013, 02:39 PM
Not that I know of, but I'm not positive. It didn't have any trouble solving it for me :)

I'll send a pull when I get on my PC :)