SRL Archive - SRL Archives

function CutGem(Amount, GemType: String)


The Claw

2007-10-29 07:52:13

Just something I made up tonight:

program New;
{.include SRL/SRL.scar}

var
GemColor, GemTolerance: Integer;

function LoadGemDDTM: Integer;

var
GemDDTM: TDTM;
GemMain: TDTMPointDef;
GemSubs: Array of TDTMPointDef;

begin
SetLength(GemSubs, 5);

GemMain.x := 331;
GemMain.y := 77;
GemMain.AreaSize := 1;
GemMain.AreaShape := 0;
GemMain.Color := GemColor;
GemMain.Tolerance := GemTolerance;

GemSubs[0].x := 329;
GemSubs[0].y := 68;
GemSubs[0].AreaSize := 1;
GemSubs[0].AreaShape := 0;
GemSubs[0].Color := 65536;
GemSubs[0].Tolerance := 0;

GemSubs[1].x := 338;
GemSubs[1].y := 76;
GemSubs[1].AreaSize := 1;
GemSubs[1].AreaShape := 0;
GemSubs[1].Color := 65536;
GemSubs[1].Tolerance := 0;

GemSubs[2].x := 335;
GemSubs[2].y := 89;
GemSubs[2].AreaSize := 1;
GemSubs[2].AreaShape := 0;
GemSubs[2].Color := 65536;
GemSubs[2].Tolerance := 0;

GemSubs[3].x := 323;
GemSubs[3].y := 88;
GemSubs[3].AreaSize := 1;
GemSubs[3].AreaShape := 0;
GemSubs[3].Color := 65536;
GemSubs[3].Tolerance := 0;

GemSubs[4].x := 319;
GemSubs[4].y := 78;
GemSubs[4].AreaSize := 1;
GemSubs[4].AreaShape := 0;
GemSubs[4].Color := 65536;
GemSubs[4].Tolerance := 0;

GemDDTM.MainPoint := GemMain;
GemDDTM.SubPoints := GemSubs;
Result := AddDTM(GemDDTM);
end;

function CutGem(Amount, GemType: String; MaxTime: Integer): Boolean;

var
GemDTM, GemDTM2, i, x, y, Cx, Cy, Waiting, Waiting2, Chisel: Integer;
Forced, Typing: Boolean;
GemText: Array of String;
GemCol: Array of Integer;

begin
GemTolerance := 50;
Forced := False;
Typing := False;

case LowerCase(GemType) of
'any', 'all': begin
GemColor := 0;
GemTolerance := 255;
end;
's', 'sapphire': GemColor := 7212812;
'e', 'emerald': GemColor := 944396;
'r', 'ruby': GemColor := 726649;
'd', 'diamond': GemColor := 11316660;
end;

GemDTM := LoadGemDDTM;
Chisel := DTMFromString('78DA63CC66626078CE8002ACD419184480342' +
'310FF0702C642A09A1B0C6880118904D2C54035F708A8C902AAF9' +
'40404D0A50CD7B026AD2806A5EE357030003840C79');

While FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2) do
begin
if not LoggedIn then Break;
if Typing then Break;
if not FindDTM(Chisel, Cx, Cy, MIX1, MIY1, MIX2, MIY2) then
Break;
MMouse(Cx, Cy, 5, 5);
Wait(200 + Random(100));
GetMousePos(Cx, Cy);
if IsUpText('hisel') then
Mouse(Cx, Cy, 0, 0, True)
else Writeln('no uptext');
Wait(250 + Random(250));
if not FindColorSpiral(Cx, Cy, 16777215, Cx - 30, Cy - 30, Cx + 30, Cy + 30) then
Break; //Just a check that we clicked it succesfully.
Mouse(x, y, 5, 5, True)

GemTolerance := 20;
GemText := ['app', 'mer', 'uby', 'iam'];
GemCol := [8065038, 944396, 726649, 11316660]

for i := 0 to 3 do
if IsUpText(GemText[i]) then
begin
GemColor := GemCol[i];
Break;
end;

if Forced then
FreeDTM(GemDTM2);

GemDTM2 := LoadGemDDTM;
Forced := True;

Wait(500 + Random(500));

if GetColor(36, 373) = 9343516 then //Do we have more than 1 gem.
begin
Mouse(256, 411, 10, 10, False) //Co-ords of middle of invent screen
Wait(500 + Random(500));

case LowerCase(Amount) of
'all': begin
ChooseOption('All');
Typing := False;
end;
else
begin
Typing := True;
ChooseOption('X');
Wait(500 + Random(500));
TypeSend(Amount);
end;
end;

MarkTime(Waiting);
MarkTime(Waiting2);
while TimeFromMark(Waiting2) < MaxTime do
begin
Wait(250 + Random(250));
if not FindDTM(GemDTM2, x, y, MIX1, MIY1, MIX2, MIY2) then
Break;
if TimeFromMark(Waiting) > 10000 + Random(5000) then
begin
MMouse(RandomRange(0, 700), RandomRange(0, 500), 25, 25);
MarkTime(Waiting);
end;
ClickContinue(True, True);
end;
Wait(250 + Random(250));
end else
Wait(750 + Random(500));
end;

if not Typing then
Result := not FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2)
else
Result := True;

if Forced then
FreeDTM(GemDTM2);
FreeDTM(GemDTM);
FreeDTM(Chisel);
end;

begin
SetupSRL;
CutGem('1', 'sapphire', 15000);
CutGem('all', 'all', 15000);
end.

Works pretty good, please test, and post results/feedback :)

Bobarkinator

2007-10-29 08:14:03

Why do you click the chisel twice?

The Claw

2007-10-29 08:22:22

You mean this part?

While FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2) do
begin
if not LoggedIn then Break;
if not FindDTM(Chisel, Cx, Cy, MIX1, MIY1, MIX2, MIY2) then
Exit;
Mouse(Cx, Cy, 5, 5, True);
if not FindColorSpiral(Cx, Cy, 16777215, Cx - 30, Cy - 30, Cx + 30, Cy + 30) then
Exit; //Just a check that we clicked it succesfully.
if IsUpText('hisel') then
Mouse(x, y, 5, 5, True)
else Break;

I dont, lol. Cx, Cy and x, y.

Wizzup?

2007-10-29 09:36:52

From: The Claw
You mean this part?

While FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2) do
begin
if not LoggedIn then Break;
if not FindDTM(Chisel, Cx, Cy, MIX1, MIY1, MIX2, MIY2) then
Exit;
Mouse(Cx, Cy, 5, 5, True);
if not FindColorSpiral(Cx, Cy, 16777215, Cx - 30, Cy - 30, Cx + 30, Cy + 30) then
Exit; //Just a check that we clicked it succesfully.
if IsUpText('hisel') then
Mouse(x, y, 5, 5, True)
else Break;

I dont, lol. Cx, Cy and x, y.


Add a wait after the Mouse(Cx, Cy);

JuKKa

2007-10-29 09:40:40

Good timing!
Oh and add "GameTab(4);"


n3ss3s

2007-10-29 09:42:35

0mg JuKKa… Add a time marker and tell how fast it did them xD

JuKKa

2007-10-29 09:44:36

From: n3ss3s
0mg JuKKa… Add a time marker and tell how fast it did them xD

Would have to switch all all my gems to my old main x_X

Eicca

2007-10-29 10:26:02

Sounds like cool, could someone cut my gems after few weeks? Already got like ~300 gems.

ShowerThoughts

2007-10-29 10:30:46

i will do it for you i can use the crafting

Nice job ;)

mat_de_b

2007-10-29 14:25:01

why the DDTM?, could you make it do a for i:=0 to 6 do and then make it look for each gem, that way it will do all of them automatically?

The Claw

2007-10-29 16:57:26

From: mat_de_b
why the DDTM?, could you make it do a for i:=0 to 6 do and then make it look for each gem, that way it will do all of them automatically?


CutGem('all', 'all') already does them all automatically

Special Ed

2007-10-29 17:52:19

Jeeze Claw… That was a suggestion for an MSI function :D You really are a Dev aren't you… lol.

Good job though, and instead of having

 
if IsUpText('app') then
GemColor := 8065038
else
if IsUpText('mer') then
GemColor := 944396
else
if IsUpText('uby') then
GemColor := 726649
else
if IsUpText('iam') then
GemColor := 11316660;

would it be better to just have

    GemText:= ['app','mer','uby','iam'];
GemCol:= [8065038, 944396, 726649, 11316660];
for i:= 0 to 3 do
if(IsUpText(GemText[i]))then
begin
GemColor:= GemCol[i];
Break;
end;

Its up to you but its a suggestion.

The Claw

2007-10-30 01:55:52

yup good idea, i'll put that in

Jeeze Claw… That was a suggestion for an MSI function :D You really are a Dev aren't you… lol.


Whats that meant to mean? :p you guys feel free to make your own, i only made this cause fawki wanted one made. not trying to steal your ideas or anything, lol

The Claw

2007-10-30 04:45:25

OK Updated, lots better and works near perfect i think

Special Ed

2007-10-30 18:10:19

Nice double post :D Also, I was just saying that you make a lot of useful stuff like a "Dev" should.

And the only reason I said it was from MSI is because I was hoping we'd get something in the MSI Functions / Scripts section. Thats all.