SRL Archive - First Scripts

Powerminer


uncfan1119

2009-11-02 17:37:45

I'll be improving this every chance I get.

Things to improve:
+Antiban
+Antirandoms


program New; //by uncfan1119
{.include SRL/SRL.scar}
{.include SRL/SRL/skill/Mining.scar}

var
clicks: integer;

function CopperColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;

begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 2439763, MSX1, MSY1, MSX2, MSY2, 108);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the copper color.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);

if (H >= 0.00) and (H <= 7.89) and (S >= 0.00) and (S <= 38.55) and (L >= 0.00) and (L <= 46.88) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 0.00) and (X <= 23.02) and (Y >= 0.00) and (Y <= 21.01) and (Z >= 0.00) and (Z <= 9.34) then
begin
Result := arC[i];
Writeln('CopperColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the copper color.');
end;

function TinColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 8750475, MSX1, MSY1, MSX2, MSY2, 25);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the tin color.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);

if (H >= 0.00) and (H <= 2.40) and (S >= 2.04) and (S <= 3.34) and (L >= 47.63) and (L <= 58.65) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 18.22) and (X <= 28.78) and (Y >= 18.79) and (Y <= 29.74) and (Z >= 20.10) and (Z <= 31.43) then
begin
Result := arC[i];
Writeln('TinColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the tin color.');
end;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;

{ Players[1].Name := '';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Active := False;

Players[2].Name := '';
Players[2].Pass := '';
Players[2].Nick := '';
Players[2].Active := False;

Players[3].Name := '';
Players[3].Pass := '';
Players[3].Nick := '';
Players[3].Active := False;

Players[4].Name := '';
Players[4].Pass := '';
Players[4].Nick := '';
Players[4].Active := False; }
end;


procedure DropOres;
var
i: Integer;
begin
for i := 2 to 28 do
begin
if existsitem(i) then
dropitem(i);
end;
wait(1000+random(500));
end;

procedure PowerMine;

var
x, y: Integer;
clicks: integer;

begin
if FindColorSpiralTolerance(X, Y, TinColor, MSX1, MSY1, MSX2, MSY2, 25) or FindColorSpiralTolerance(X, Y, CopperColor, MSX1, MSY1, MSX2, MSY2, 108) then
begin
mmouse( x, y, 6, 6 );
wait(100+random(300));
if IsUpText('ine') then
begin
getmousepos(x, y);
wait(100+random(300))
mouse(x, y, 2, 2, true);
clicks := clicks + 1;
repeat
wait(50+random(200));
until(findblackchatmessage('ana'));
end;
end;
end;

procedure MainLoop;
begin
repeat
repeat
PowerMine;
until(clicks = 28);
DropOres;
until(false);
end;

begin
SetupSRL;
DeclarePlayers;
ActivateClient;
LoginPlayer;
Wait(1000);
MainLoop;
end.


note to self: make new script just do
if (findblackchatmessage('ana'))) then wrriteln('1')
repeat until false taht ^
and run it
to check if the damn func is even working
you can just maek a DTM of the text also :D
Functiion DidIMine:Bollean
begin
result:=FindDTM(mined ore dtm)
end;
repeat
antiban
antirandoms
wait(500)
until DidIMine

Kyle Undefined

2009-11-02 18:26:27

Not bad, but don't you need to set the points for the variable "arP"? Won't it always equal 0 in length? As for your drop procedure, here is a better way of doing it:

procedure DropOre;
var
I : Integer;
begin
for I := 1 to 28 do
begin
if(ExistsItem(I))then
begin
MMouseItem(I);
Wait(400 + Random(100));
if(not(IsUpText('pick')))then
DropItem(I);
end;
end;
end;
It sees if there is an item in the spots 1 to 28. If there is an item, it sees what its UpText is. If it's the pick, then it keeps it, otherwise it drops it.

Another way of improving this, would be to add what type of rock they want to mine in the DeclarePlayers. Then use that to determine what to look for. Example:

var
RockToMine : Integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Strings[0] := 'Tin'; // Type of rock to mine. Tin or Copper.
end;
end;

procedure SetRock;
begin
case Lowercase(Players[CurrentPlayer].Strings[0]) of
'tin' : RockToMine := TinColor;
'copper' : RockToMine := CopperColor;
end
end;

procedure PowerMine;
var
x, y, Clicks : Integer;
begin
SetRock;
if(FindColorSpiralTolerance(X, Y, RockToMine, MSX1, MSY1, MSX2, MSY2, 25))then
begin
MMouse(x, y, 6, 6);
Wait(100 + Random(300));
if(IsUpText('ine'))then
begin
GetMousePosition(x, y);
Wait(100 + Random(300));
Mouse(x, y, 2, 2, True);
Inc(Clicks);
repeat
Wait(50 + Random(200));
until(FindBlackChatMessage('ana'));
end;
end;
end;

You need to work on your standards as well. They're not bad, just need a little work. Also, never use repeat…until(false); it's a bad habit, use repeat…until(AllPlayersInactive); or repeat…until(LoggedOut); even though it's not much better.

If you ever need help in the future, just PM me. Good luck :)

~Camo

code841

2009-11-02 18:36:50

There should be a max wait time to break that loop instead of just "FindBlackChatMessage('ana');".
Of course it's only Tin/Copper which respawn fast, but still, another player could be taking the ore before you even get to it.

Ghostman

2009-11-02 21:17:10

Nice but declareplayers be on the first things to make it more user friendly

crezzur

2009-11-05 05:30:37

looks good going to test it for sure!