NiCbaZ
2008-11-17 05:34:09
Mining Guild BETA.
Thanks to
Jukka
Shermantor
for some use of procedures.
This is BETA and not that stable yet.
I may have a new vertion on my laptop i think? il post it if i do..
Thanks to
Jukka
Shermantor
for some use of procedures.
This is BETA and not that stable yet.
I may have a new vertion on my laptop i think? il post it if i do..
program GuildMiner;
{.include SRl/SRl.scar}
{.include SRL\SRL\misc\NewAutoColor.scar}
{.include SRL\SRL\skill\mining.scar}
{.include srl/srl/misc/users.scar}
// Big Credits To masterKill, Jukka and Shermanator for uses of there procedurs and idea's
var
x,y,loads,gas: integer;
procedure Main; forward;
function AutoColor(huh: string): integer;
var
H,S,L,X,Y,Z : Extended;
R,G,B,A,TestColor : Integer;
TPA : TPointArray;
begin
case huh of
'RoadColor':
begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 5926261, MMX1, MMY1, MMX2, MMY2, 63)
for A := 0 to High(TPA) do
begin
if RS_OnMinimap(TPA[A].X, TPA[A].Y) then
begin
TestColor := GetColor(TPA[A].X, TPA[A].Y);
if SimilarColors(TestColor, 5926261, 50) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);
if InRange(R - G, -12, 28) then
if InRange(R - B, 7, 47) then
if InRange(G - B, -1, 39) then
if InRange(Round(X) - Round(Y), -7, 7) then
if InRange(Round(Y) - Round(Z), -4, 10) then
if GetColor(TPA[A].X + 2, TPA[A].Y + 2) = TestColor then
if GetColor(TPA[A].X + 1, TPA[A].Y + 1) = TestColor then
begin
Writeln('FallyMM_RoadColor =' +Inttostr(TestColor));
Result := TestColor;
Exit;
end;
end;
end;
Result := 0;
end;
end;
'LaddarColor':
begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 10837, MMX1, MMY1, MMX2, MMY2, 63)
for A := 0 to High(TPA) do
begin
if RS_OnMinimap(TPA[A].X, TPA[A].Y) then
begin
TestColor := GetColor(TPA[A].X, TPA[A].Y);
if SimilarColors(TestColor, 10837, 50) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);
if InRange(R - G, 23, 63) then
if InRange(R - B, 65, 105) then
if InRange(G - B, 22, 62) then
if InRange(Round(X) - Round(Y), -6, 8) then
if InRange(Round(Y) - Round(Z), -3, 11) then
if GetColor(TPA[A].X + 2, TPA[A].Y + 2) = TestColor then
if GetColor(TPA[A].X + 1, TPA[A].Y + 1) = TestColor then
begin
Writeln('FallyMM_Laddar = '+Inttostr(TestColor));
Result := TestColor;
Exit;
end;
end;
end;
Result := 0;
end;
end;
end;
end;
function WalkDDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [1..4] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 1094;
dtmMainPoint.y := 414;
dtmMainPoint.AreaSize := 4;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := AutoColor('LaddarColor');
dtmMainPoint.Tolerance := 0;
dtmSubPoints[1].x := 1083;
dtmSubPoints[1].y := 404;
dtmSubPoints[1].AreaSize := 4;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := AutoColor('RoadColor');
dtmSubPoints[1].Tolerance := 0;
dtmSubPoints[2].x := 1111;
dtmSubPoints[2].y := 408;
dtmSubPoints[2].AreaSize := 4;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := AutoColor('RoadColor');
dtmSubPoints[2].Tolerance := 0;
dtmSubPoints[3].x := 1082;
dtmSubPoints[3].y := 422;
dtmSubPoints[3].AreaSize := 4;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := AutoColor('RoadColor');
dtmSubPoints[3].Tolerance := 0;
dtmSubPoints[4].x := 1108;
dtmSubPoints[4].y := 420;
dtmSubPoints[4].AreaSize := 4;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := AutoColor('RoadColor');
dtmSubPoints[4].Tolerance := 0;
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;
procedure DebugATPA(aPoints: T2DPointArray); // Some Creds To Wizzup
var
ClientBMP, I, I2: Integer;
B: TBox;
Begin
B := GetATPABounds(aPoints);
DisplayDebugImgWindow(B.x2 - B.x1, B.y2 - B.y1);
ClientBMP := BitmapFromString(B.x2 - B.x1, B.y2 - B.y1, '');
CopyClientToBitmap(ClientBMP, B.x1, B.y1, b.x2, b.y2);
for I := 0 to High(aPoints) do
begin
for I2 := 0 to High(aPoints[i]) do
FastSetPixel(ClientBMP, aPoints[i][I2].X - b.x1, aPoints[i][I2].Y - b.y1, Random(839894));
end;
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
try
FreeBitmap(ClientBMP);
except
end;
end;
function FindLaddar(colo:integer): Boolean;
var
z,x,y,cts : Integer;
TPA: TPointArray;
TP : TPoint;
D2TPA: T2DPointArray;
begin
Result:= False;
SetAngle(True);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(628+random(20),428+random(20), TPA, colo, MSX1 + 20, MSY1 + 20, MSX2 - 20, MSY2 - 20, 3);
D2TPA:= TPAtoATPAEx(TPA,5,5);
DebugATPA(D2TPA);
For z:= 0 to length(D2TPA) - 1 Do
begin
TP:= MiddleTPA(D2TPA[Z]);
x := TP.x;
y := TP.y;
MMouse (x, y, 3, 3);
if IsUpText('adder') then
begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, True);
Result := True;
Flag;
Exit;
end;
Wait(350+random(350));
end;
Result := False;
end;
function InGuild : Boolean;
begin
Result:= CountColor(65536,mmx1,mmy1,mmx2,mmy2) > 800;
end;
Function FindRock(colz: integer): Boolean; //Nicbaz + jukka
Var
I,x,y,gx,gy: Integer;
TP: TPoint;
TPA: TPointArray;
TPAA2: Array Of TPointArray;
T2Darray: T2DPointArray;
Begin
SetArrayLength(TPAA2, 2);
FindColorsSpiralTolerance(MSCX, MSCY, TPAA2[I], colz, MSX1, MSY1, MSX2, MSY2, 4);
TPA := CombineTPA(TPAA2[0], TPAA2[1]);
T2Darray := SplitTPAEx(TPA, 10, 10);
if FindGas(gx,gy) then
begin
Mouse(660+random(10), 95+ random(10), 3, 3, true);
Writeln('Gas Found ');
inc(gas);
Exit;
end;
FindNormalRandoms;
For I:= 0 To High(T2Darray) Do
Begin
TP := MiddleTPA(T2Darray[I]);
Begin
MMouse(TP.X, TP.Y, 0, 0);
Wait(100+Random(50));
If IsUpText('ine') then
Begin
Result := True;
TP.X:= X;
TP.Y:= Y;
Exit;
End;
End;
End;
End;
Function CheckPickaxe: Boolean; // MasterKill
var
PickaxeStick,
BrokenPickaxe,
PickaxeD: Integer;
begin
PickaxeStick := DTMFromString('78DA6314666060906140038C4824901601124' +
'204D44801095E026A40F2CA04D408000929026A048184220135E2' +
'404214BF1A00B23A014A');
BrokenPickaxe := DTMFromString('78DA6334676660A8656440058C4824907603A' +
'A2926A0C61BA8A688801A3BA09A4C026A8C806A728950D34A408D' +
'13504D3E7E3500C8FC050A');
PickaxeD := DTMFromString('78DA6314606060E06540038C4824909605125' +
'C04D470020976026A40662810502302245808A801B9590CBF1A00' +
'612000CF');
GameTab(4);
If FindDTM(PickaxeStick, x, y, 532, 183, 751, 485) Then
Begin
Writeln('Lost Pick');
Result:= True;
Exit;
End;
If FindDTM(BrokenPickaxe, x, y, 532, 183, 751, 485) Then
Begin
Result := True;
Writeln('Sorry, but ' + Players[CurrentPlayer].Nick + ' broke your pickaxe');
Exit;
End;
If Not FindDTM(PickaxeD, x, y, 532, 183, 751, 485) Then
Result := True;
FreeDTM(PickaxeD);
FreeDTM(PickaxeStick);
FreeDTM(BrokenPickaxe);
End;
procedure MineCoal;
var
x,y,z,w,p,gx,gy,v: integer;
i : Integer;
Deg: Variant;
begin
Players[CurrentPlayer].Loc := 'Mining';
If Not LoggedIn Then
Exit;
repeat
z:= InvCount;
If Not(GetColor(MMCx, MMcy + 50) = 65536) then
begin
if not RadialWalk(FindRockColor, 150, 220, 60, 10, 10)then
Mouse(638,143,5,5,true);
Flag;
writeln('At door');
end;
if FindRock(2900289) then
begin
Case random(2) of
0:
begin
GetMousePos(x,y)
Mouse(x, y, 0, 0, True);
FindNormalRandoms;
Flag;
Wait(200+random(300));
end;
1:
begin
GetMousePos(x,y)
Mouse(x, y, 0, 0, False);
Wait(100+ random(300));
ChooseOption('Mine');
FindNormalRandoms;
Flag;
Wait(100+random(500));
end;
end;
MarkTime(p);
repeat
if CheckPickaxe then
begin
Players[CurrentPlayer].Loc := 'No PickAxe - In Mine';
NextPlayer(true);
Loads:= 0;
Main;
Exit;
end;
Wait(100+random(200));
if FindNpcChatText('ickaxe', Nothing) then
begin
Writeln('We have No PickAxe');
Players[CurrentPlayer].Loc := 'No PickAxe - In Mine';
NextPlayer(False);
Loads:= 0;
Main;
Exit;
end;
if InChat('ore') then
MineCoal;
w:= InvCount;
if w > z then
Break;
if InvFull then
Break;
if Not LoggedIn then
Exit;
x:= Random(5)
if x = 3 then
begin
Deg := rs_GetCompassAngleDegrees;
for i := 1 to (3 + Random(11)) do
begin
if w > z then
Break;
if FindGas(gx,gy) then
begin
Mouse(660+random(10), 95+ random(10), 3, 3, true);
Inc(gas);
end;
MMouse(Random(MSX2), Random(MSY2), 0, 0);
if IsUpText('opti') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
ChooseOption('Examine');
end;
FindNormalRandoms;
case Random(6) of
0: SendArrowSilentWait(((Random(2) * 2) + 1), 1000 + Random(200));
1: SendArrowSilentWait(((Random(2) * 2)), 1000 + Random(200));
2: SendArrowSilentWait(((Random(2) * 2) + 1), 200 + Random(200));
3: SendArrowSilentWait(((Random(2) * 2)), 200 + Random(200));
4: SendArrowSilentWait(((Random(2) * 2) + 1), 20 + Random(20));
5: SendArrowSilentWait(((Random(2) * 2)), 20 + Random(20));
end;
FindNormalRandoms;
end;
if (Deg <> 0) then
MakeCompass(IntToStr(Round(Deg)))
else
MakeCompass('N');
SendArrowSilentWait(0, 750 + Random(500));
end else
begin
Wait(1000+random(3000));
if w > z then
Break;
case random(4) of
0: begin idleTime(500+random(500),800+random(200),0.01); FindNormalRandoms; end;
1: begin gametab(random(14)); FindNormalRandoms; end;
2:
begin
FindNormalRandoms;
mouse(random(msx2),random(msy2),0,0,false);
chooseOption('xamin');
end;
3: wait(1000+random(2000));
end;
FindNormalRandoms;
end;
if w > z then
begin
case Random(7) of
0,6: Mouse(660+random(10), 95+ random(10), 3, 3, true);
end;
end;
if TimeFromMark(p) > 11000 then
Break;
until(w > z)or(InvFull) or Not LoggedIn;
end;
v:= InvCount;
if not z > v then
Break;
until(InvFull)or(not(LoggedIn));
end;
procedure WalkToMine;
var
Time: integer;
mmGreyRock: integer;
begin
CheckPickaxe;
Players[CurrentPlayer].Loc := 'Walking To Mine';
MakeCompass('N');
if FindSymBol(x,y,'mining spot') then
Exit;
case random(2) of
0: SetRun(False);
1: SetRun(true);
end;
// If not FindDTM(WalkDDTM,x,y, MMX1, MMY1, MMX2, MMY2) then
begin
if not RadialWalk(AutoColor('RoadColor'),160,170,90,2,2) then
if not RadialWalk(AutoColor('RoadColor'),130,190,90,2,2) then
begin
Writeln('DTM and RW Failed');
wait(300+random(200));
if not RadialWalk(AutoColor('LaddarColor'),130,190,90,2,2) then
begin
case random(2) of
1:
begin
Mouse(666, 106, 5, 5, true);
Flag;
Mouse(652, 148, 5 , 5,true);
end;
2:Mouse(652, 148, 5 , 5,true);
end;
end;
end;
end;
If not FlagPresent then
Begin
MarkTime(Time);
Repeat
Wait(500+random(300));
if FlagPresent then
Break;
if TimeFromMark(Time) > 10000 then
Break;
Until(FlagPresent)
FFlag(0);
end;
wait(500+random(300));
if not FindLaddar(3365743) then
begin
Writeln('Lost');
Players[CurrentPlayer].Loc := 'Loast - Near Ladder';
NextPlayer(false);
Loads:= 0;
Main;
end else
begin
wait(1000+random(300));
if Not InGuild then
begin
Writeln(' Lost In Mine');
Nextplayer(false);
Loads:= 0;
Main;
end;
Writeln('In Mine');
Wait(600+random(500));
SetupNewAutoColor;
mmGreyRock := srl_AutoGetColor('grey rock');
if mmGreyRock = 0 then
begin
//Writeln('MM Rock AutoColor Failed');
// Mouse(649,31,10,10,true);
// flag;
end;
if not RadialWalk(mmGreyRock,80,120,50+random(20),2,2) then
Mouse(698, 99,6,6,true);
Wait(600+random(300));
end;
end;
procedure WalkToFloor;
var
X,Y: Integer;
mmGreyRock: integer;
mmLadder: integer;
mmFloorCol: integer;
AutoColorInfo: TAutoColorInfo;
i, R, G, B, tmpCTS, GC, TestColor: Integer;
P: TPointArray;
begin
with AutoColorInfo do
begin
Name := 'Ladder';
MinCount := 10;
Color := 600408;
HueMod := 0.38;
SatMod := 2.32;
LumTol := 8;
MinR := 58; MaxR := 113;
MinG := 13; MaxG := 67;
MinB := 0; MaxB := 25;
MinX := 1.94; MaxX := 8.74;
MinY := 1.22; MaxY := 7.40;
MinZ := 0.12; MaxZ := 1.68;
end;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.39, 0.25);
GC := 5403005;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 8);
for i:=0 to High(p)-1 do
begin
if rs_OnMinimap(P[i].x,P[i].y) then
begin
TestColor := GetColor(P[i].x,P[i].y);
ColorToRGB(TestColor, R, G, B);
if (R >= 103) and (R <= 146) and (G >= 93) and (G <= 132) and (B >= 65) and (B <= 100) then
if GetColor(P[i].x + 5, P[i].y + 5) = TestColor then
if GetColor(P[i].x + 3, P[i].y + 3) = TestColor then
if GetColor(P[i].x, P[i].y + 5) = TestColor then
if GetColor(P[i].x + 5, P[i].y) = TestColor then
if GetColor(P[i].x, P[i].y + 3) = TestColor then
if GetColor(P[i].x + 3, P[i].y) = TestColor then
if GetColor(P[i].x + 5, P[i].y + 3) = TestColor then
if GetColor(P[i].x + 3, P[i].y + 5) = TestColor then
mmFloorCol := TestColor;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
SetupNewAutoColor;
If Not(GetColor(MMCx, MMcy + 50) = 65536) then
begin
if not RadialWalk(FindRockColor, 150, 220, 60, 10, 10)then
Mouse(338,143,5,5,true);
Flag;
writeln('At door');
end;
mmGreyRock:= mmFloorCol;
if mmGreyRock = 0 then
mmGreyRock := FindRockColor;
RadialWalk(mmGreyRock, 190, 310, 40 + Random(20), 1, -1);
RadialWalk(mmGreyRock, 190, 310, 40 + Random(20), 1, -1);
mmLadder:= FindSToneColor;
if mmLadder = 0 then
mmLadder:= FindColorRecord(x, y, AutoColorInfo);
if FindColor(x, y, mmLadder, MMX1 + 30, MMY1, MMX2, MMY2) then
begin
Mouse(x,y,2,2,true);
Flag;
end else
begin
mmLadder := FindStoneColor;
if FindColorTolerance(x, y, mmLadder, MMx1, MMy1, MMx2, MMy2, 1)then
Mouse(x-5, y-3, 5, 5, True);
Flag;
end;
end;
procedure WalkToBank;
var
Time,Time2,Time3: integer;
DTM: Integer;
begin
DTM := DTMFromString('78DA63B46661604864640001260608F8FFFF3' +
'FC37F20CD0861FF673406AAC94455F3F52B03033F540D08309A21' +
'D4C0C4FEFC6142556385690E861A3BA09A2C026A9C08AB01002FD' +
'B1619');
Flag;
if InGuild then
begin
Writeln(' Lost In Mine');
Nextplayer(false);
Loads:= 0;
Main;
end;
wait(1500+random(400));
If Not RadialWalk(AutoColor('RoadColor'),55,68,50,2,2) then
if not RadialWalk(AutoColor('RoadColor'),45,75,50,2,2) then
begin
Mouse(571, 56,5,5,true);
If not FlagPresent then
Begin
MarkTime(Time);
Repeat
Wait(500+random(300));
if FlagPresent then
Break;
if TimeFromMark(Time) > 10000 then
Break;
Until(FlagPresent)
FFlag(0);
end;
end;
case random(2) of
0: Mouse(589,46,5,5,true);
1: Mouse(600,75,5,5,true);
end;
If not FlagPresent then
Begin
MarkTime(Time2);
Repeat
Wait(500+random(300));
if FlagPresent then
Break;
if TimeFromMark(Time2) > 10000 then
Break;
Until(FlagPresent)
FFlag(0);
end;
Flag;
SymbolAccuracy := 0.8;
if DtmRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2) then
begin
Mouse(x + 10, y, 0, 0, True);
Writeln('DTM');
Sleepandmovemouse(1000+random(2000));
If not FlagPresent then
Begin
MarkTime(Time3);
Repeat
Wait(500+random(300));
if FlagPresent then
Break;
if TimeFromMark(Time3) > 10000 then
Break;
Until(FlagPresent)
FFlag(0);
end;
wait(100+random(200));
end else
if FindSymBol(x,y,'bank') then
begin
Mouse(x,y,3,3,true);
If not FlagPresent then
Begin
MarkTime(Time);
Repeat
Wait(500+random(300));
if FlagPresent then
Break;
if TimeFromMark(Time) > 10000 then
Break;
Until(FlagPresent)
FFlag(0);
end;
Writeln('At Bank');
end;
if not OPenBank('feb',True,True)then
begin
Writeln('Failed To Find Bank');
Players[CurrentPlayer].Loc := 'Failed To Find Bank';
Nextplayer(false);
Main;
Exit;
end else
begin
Writeln('Banking');
Wait(500+random(300));
Deposit(2, 28, True);
Wait(500+random(300));
CloseBank;
Wait(500+random(300));
Writeln('Banked');
Players[CurrentPlayer].Loc := 'Mining';
end;
FreeDTM(DTM);
end;
procedure Main;
var
Coal,RandomSleep,TotalSleep,I : integer;
Active : string;
Sec: Extended;
begin
repeat
if Not LoggedIn Then
Exit;
WalkToMine;
MineCoal;
WalkToFloor;
if not FindLaddar(2241340) then
begin
Writeln('Laddar Failed');
NextPlayer(False);
Main;
end;
wait(1500+random(500));
MakeCompass('n');
WalkToBank;
MakeCompass('n');
ClearDebug;
if Loads = 0 then
begin
Writeln('Getting Mining Lvl');
Players[CurrentPlayer].Integers[10] := GetSkillLevel('Mining');
end;
inc(loads);
coal:= coal + 27;
Sec := GetTimeRunning div 1000+1;
Writeln('[------------------------------------------------------------------------------]');
WriteLn('[ ]');
Writeln('[ Nicbaz Guild Miner ]');
Writeln('[------------------------------------------------------------------------------]')
Writeln('[ Worked For : ' + TimeRunning );
Writeln('[ Banked : ' + IntToStr( Loads )+ ' Loads');
Writeln('[ Banks per hour : ' + IntToStr(Round(3600*Loads/Sec)));
WriteLn('[ Coal Ores Mined : '+ Inttostr(Coal));
WriteLn('[');
Writeln('[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-]');
WriteLn('[ Players ]');
WriteLn('[ ]');
WriteLn('[ # | Nick | Active | Level ]');
for I := 0 to (HowManyPlayers - 1) do
begin
if (Players[I].Active = True) then
Active := 'T'
else
Active := 'F';
end;
HowManyPlayers:= 2;
For I:= 0 To HowManyPlayers - 1 Do
WriteLn('[ '+ Padr(IntToStr(I), 3) + '| '+ Padr(Players[I].Nick, 6) + '| ' + Padr(Active, 6)+ '| ' + Padr(IntToStr(Players[I].Integers[10]),6)+' ]');
WriteLn('[ ]');
Writeln('[------------------------------------------------------------------------------]');
WriteLn('[ ]');
Writeln(' Nicbaz Guild Miner ]');
Writeln('[------------------------------------------------------------------------------]');
until Loads = players[currentplayer].integers[2];
if (players[currentplayer].Booleans[0]=false) then
begin
NextPlayer(True);
sendsrlreport;
Loads:= 0;
end else
if (players[currentplayer].Booleans[0]=true) then
begin
RandomSleep:=players[currentplayer].integers[1]*60000;
TotalSleep:=players[currentplayer].integers[0]*60000;
logout;
writeln('Sleeping now!');
Disguise('Sleeping!');
sleep(TotalSleep+random(RandomSleep));
NextPlayer(true);
Loads:= 0;
end;
end;
begin
SetupSRL;
SrlPlayerForm(true,['Sleep'],['Minutes to sleep', 'Random sleep in minutes','Loads'],[],[' Stats User', ' Stats Pass']);
LoginPlayer;
repeat
Main;
Until(False);
end.