SRL Archive - First Scripts

Mezz's Crafting Guild Gold Miner


Mezzanine

2012-06-28 01:51:14

Mezzanine's Crafting Guild Gold Miner
Description

[INDENT]So I've been working on this script for the past week or so and I feel its finally at a presentable point. So what it does if you couldn't figure it out from the title is mine gold in the Crafting Guild south of Falador. You can choose to either powermine the gold, or to bank it through the use of a Ring of Kinship and a Clan Vexillium. When powermining you can choose to either keep or drop any gems you get. It has a progress report as well. I soon plan on adding alternate banking for those who don't want to use the quick Daemonheim banking method, and also an alternate dropping method using YoHoJo's mouse key drop method. [/INDENT]

program MezzGoldMiner;
{$i SRL/SRL/misc/smart.simba}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$i ObjectDTM\ObjDTMInclude.simba}
{
//===========================================\\
|| Mezzanine's Crafting Guild Gold Miner ||
\\===========================================//
|| How to use ||
|| Powermining: ||
|| ||
|| 1. Equip a brown apron ||
|| ||
|| 2. Have your pick equipped or in the ||
|| first slot of your inventory ||
|| ||
|| 3. Place your character inside the ||
|| crafting guild gold mine ||
|| ||
|| 4. Fill out the script setup below ||
|| (Banking = False) ||
|| ||
|| 5. Hit run! ||
|| ||
|| Banking: ||
|| ||
|| 1. Equip your Clan Vexillium, Ring of ||
|| Kinship, and a brown apron ||
|| ||
|| 2. Have your pickaxe of choice in the ||
|| first slot of your inventory ||
|| ||
|| 3. Place your character inside the ||
|| crafting guild gold mine ||
|| ||
|| 4. Fill out the script setup below ||
|| (Banking = True) ||
|| ||
|| 5. Hit run! ||
|| ||
//===========================================\\
|| CAUTION: If you set loads to 0, you ||
|| will have to stop it manually and ||
|| won't get a cool progress report! ||
\\===========================================//


\\==================//
|| Script Setup ||
\\==================//
}
const

Pin = '1911'; // Only if you're banking and do have a pin
Loads = 2; // How many loads do you want to mine? (0 = forever)
Banking = True; // True : Bank , False : Powermine

KeepSapphire = True;
KeepEmerald = True; // Only for powermining; True : Keep, False : Drop
KeepRuby = True;
KeepDiamond = True;

Member = False; // Are you a member?

AntibanAmnt = 1; // How much do you want to antiban?
{ 0 : Practically never
1 : Not too often (Recommended)
2 : Often
3 : All the time }

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin

Name := 'username'; // Player username
Pass := 'ToHellWithBoundaries'; // Player password

BoxRewards := ['XP']; // What reward do you want from randoms?
LampSkill := SKILL_MINING; // What skill do you want from XP lamps?

Active := True;
end;
end;
{
//====================================================================\\
|| End of Script Setup | Only pass if you know what you're doing! ||
//====================================================================\\
}




var
x, y, FirstTele, GoldTimer, LoadsMined, GoldOreDTM, RunePickDTM, SapphireDTM, EmeraldDTM,
RubyDTM, DiamondDTM, GoldOreInLoad, SapphiresInLoad, EmeraldsInLoad,
RubiesInLoad, DiamondsInLoad, TotalGoldOre, TotalSapphires, TotalEmeralds,
TotalRubies, TotalDiamonds, RandomEvents: Integer;

procedure DTMSetup;
begin
GoldOreDTM := DTMFromString('mrAAAAHic42BgYBAAYkYg5mSAACmomDwQiwExL5RmBmI+IBYFYkkgZoeqX98tASSZcGIuBvyAkQCGAQAQtAJd');
SapphireDTM := DTMFromString('mbQAAAHicY2VgYDjExMBwGIi3AvEBID4FxE+A4h8YIPQtIH4OxPxC+UCSCQVzMWACRiwYDADzgAj0');
EmeraldDTM := DTMFromString('mggAAAHicY2NgYDjExMBwAIj3AvFJIN4KxKeA+DFQ7hYQf4Die0D8BIh5YvmBJBMG5mLADhhxYAgAAC1fCos=');
RubyDTM := DTMFromString('mggAAAHicY2NgYMhlYmDIAeJEIC4F4lQgLgNidkYGhn9AeU4gLQLEwowQsRBBHqAoEwbmYsAOGHFgCAAAz0cEaQ==');
DiamondDTM := DTMFromString('mggAAAHicY2NgYHBhYmBwBGJPIPYFYgsgNgdiTkYGhn9AeREgzQXEPEDMBMSTe3uBokwYmIsBO2DEgSEAALh3BJw=');
RunePickDTM := DTMFromString('mbQAAAHicY2VgYLBjYmBwBGJrIPYFYmMgfgwUvwbEn4H4LhBfB2JXEzkgyYSCWRkwASMWDAYA92gGUw==');
//AddyPickDTM :=
end;


procedure CameraSetup;
begin
if not LoggedIn then Exit;
Wait(RandomRange(90, 140));
MakeCompass('S');
SetAngle(0);
end;

function TimeGet: string;
begin
Result := MsToTime(GetTimeRunning, Time_Abbrev);
end;

procedure TimeStamp(WaitTime: Integer); //Credit goes to p1ng for this proc.
var
T: Integer;
Ticker: String;
begin
MarkTime(T);
while (WaitTime > TimeFromMark(T)) do
begin
Wait(500);
Ticker := MsToTime(WaitTime - TimeFromMark(T), Time_Abbrev);
Status('Break remaining: ' + Ticker);
end;
end;

function CheckItemInSlotByDTM(DTM, slot: integer; write: boolean): boolean;
var
pointX, pointY, itemSlot: integer;
begin
if not LoggedIn then Exit;
if (ExistsItemDTM(DTM, pointX, pointY)) then
begin
itemSlot := (CoordsToItem(pointX, pointY));
if (itemSlot = slot) then
begin
if (write) then
writeln('An item with a matching DTM exists in the inventory slot ' + IntToStr(slot));
result := true;
end else
begin
if (write) then
writeln('An item with a matching DTM exists in the inventory, but not in slot ' + IntToStr(slot));
end;
end else
begin
if (write) then
writeln('An item with a matching DTM does not exist in the inventory');
end;
end;

procedure Antiban;
var
a: integer;
begin
if not LoggedIn then Exit;
case AntibanAmnt of
0: a := 5000;
1: a := 800;
2: a := 300;
3: a := 100;
end;
if FindNormalRandoms then
inc(RandomEvents);
case Random(a) of
1: begin
writeln('Checking our mining skill ' + TimeGet);
HoverSkill('mining', False);
end;
2: begin
writeln('Checking a random skill ' + TimeGet);
HoverSkill('random', False);
end;
3: begin
writeln('Bored human ' + TimeGet);
Boredhuman;
Wait(RandomRange(200, 400));
CameraSetup;
end;
4: begin
writeln('Small antiban wait... ' + TimeGet);
TimeStamp(RandomRange(2500, 7000));
end;
5: begin
writeln('Picked up the mouse ' + TimeGet);
PickUpMouse;
end;
6: begin
writeln('Random movement ' + TimeGet);
RandomMovement;
Wait(RandomRange(200, 400));
CameraSetup;
end;
end;
end;

procedure AntibanBreaking;
var
a: integer;
begin
if not LoggedIn then Exit;
case AntibanAmnt of
0: a := 5000;
1: a := 1500;
2: a := 1000;
3: a := 500;
end;
if FindNormalRandoms then
inc(RandomEvents);
case Random(1500) of
1: begin
writeln('Not broken, just antiban-breaking! ' + TimeGet);
TimeStamp(RandomRange(40634, 60127));
writeln('Finished breaking! ' + TimeGet);
end;
2: begin
writeln('Not broken, just antiban-breaking! ' + TimeGet);
TimeStamp(RandomRange(32052, 64844));
writeln('Finished breaking! ' + TimeGet);
end;
3: begin
writeln('Not broken, just antiban-breaking! ' + TimeGet);
TimeStamp(RandomRange(34655, 50874));
writeln('Finished breaking! ' + TimeGet);
end;
4: begin
writeln('Not broken, just antiban-breaking! ' + TimeGet);
TimeStamp(RandomRange(19011, 35109));
writeln('Finished breaking! ' + TimeGet);
end;
5: begin
writeln('Not broken, just antiban-breaking! ' + TimeGet);
TimeStamp(RandomRange(19491, 42931));
writeln('Finished breaking! ' + TimeGet);
end;
6: begin
writeln('Not broken, just antiban-breaking! ' + TimeGet);
TimeStamp(RandomRange(19774, 31830));
writeln('Finished breaking! ' + TimeGet);
end;
end;
if not (LoggedIn) then
LogInPlayer;
if FindNormalRandoms then
inc(RandomEvents);
end;

procedure Failsafe(reason: string);
begin
writeln('Reason for failsafe : ' + reason);
Logout;
TerminateScript;
end;

function AtDaemon: boolean;
begin
result := ObjDTM_InArea('80:80:4:10:7:28:67:10:7:44:67:6:7:48:114:6:7:60:114:5:18:48:18:109:143:110:143:48:112:48', true);
end;

procedure GuildTele;
begin
if not LoggedIn then Exit;
writeln('Teleporting to the clan grounds ' + TimeGet);
MouseEquippedItem('weapon', 0);
ChooseOption('Tel');
repeat
Wait(100);
until(FindNPCChatText('Yes', Nothing));
FindNPCChatText('Yes', ClickLeft);
Wait(RandomRange(5000, 5500));
end;

procedure BankTele;
begin
if not LoggedIn then Exit;
Inc(FirstTele);
writeln('Teleporting to bank ' + TimeGet);
MouseEquippedItem('ring', 0);
if (FirstTele = 1) then
begin
Wait(RandomRange(75, 150))
ClickMouse2(mouse_Right);
end;
ChooseOption('Tel');
Wait(RandomRange(7800, 8200));
end;

procedure WalkToBank;
var
PathToBank: TPointArray;
begin
if not LoggedIn then Exit;
writeln('Walking to the bank ' + TimeGet);
SPS_Setup(RUNESCAPE_SURFACE,['14_4', '13_4', '14_5', '14_3']);
PathToBank := [Point(5634, 1824), Point(5634, 1777)];
SPS_WalkPath(PathToBank);
Wait(RandomRange(1500, 2100));
end;

procedure WalkToGuild;
begin
if not LoggedIn then Exit;
writeln('Walking to the guild ' + TimeGet)
ObjDTM_Walk('28:38:4:10:7:89:59:10:7:66:47:1:7:30:71:1:7:66:127', 5, 100, 3, true);
Wait(RandomRange(250, 500));
ObjDTM_Walk('34:74:3:1:7:41:57:1:7:20:73:1:7:44:103:4:27:69:42:70:35:84:26:79', 5, 100, 3, true);
Wait(RandomRange(250, 500));
ObjDTM_Walk('76:105:3:1:7:102:82:1:7:90:79:1:7:66:83', 1, 100, 3, True);
end;

function FindDaemonBank(Attempt: Integer; var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
colorMods, colorX, colorY, colorZ: TExtendedArray;
ararP: T2DPointArray;
color, colorTol, tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
Current: String;
begin
if not LoggedIn then Exit;
case Attempt of
1:
begin
color := 7884603;
colorTol := 9;
colorMods := [0.04, 0.65];
colorX := [4.68, 12.76];
colorY := [4.67, 12.78];
colorZ := [9.87, 27.79];
current := 'One';
end;
2:
begin
color := 7884603;
colorTol := 9;
colorMods := [0.04, 0.65];
colorX := [4.68, 12.76];
colorY := [4.67, 12.78];
colorZ := [9.87, 27.79];
current := 'Two';
end;
3:
begin
current := 'Three';
color := 9589567;
colorTol := 8;
colorMods := [0.04, 0.10];
colorX := [7.03, 14.47];
colorY := [6.37, 12.96];
colorZ := [18.93, 40.27];
end;
4:
begin
current := 'Four';
color := 9592129
colorTol := 6
colorMods := [0.05, 0.09]
colorX := [8.17, 14.87]
colorY := [7.92, 14.37]
colorZ := [20.81, 38.56]
end;
end;

tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(colorMods[0], colorMods[1]);

if not(FindColorsTolerance(arP, color, MSX1, MSY1, MSX2, MSY2, colorTol)) then
begin
//WriteLn('Failed to find the bank on attempt ' + current);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= colorX[0]) and (X <= colorX[1]) and (Y >= colorY[0]) and (Y <= colorY[1]) and
(Z >= colorZ[0]) and (Z <= colorZ[1]) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
if WaitUptext('ank', 500) then
begin;
Result := True;
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
//Writeln('FindBank could not find the bank on attempt ' + current);
Exit;
end;

GetMousePos(fx, fy);
end;

procedure CountInventory(cType: Integer); // 0 : for banking
var // 1 : for dropping
sappC, emeC, rubiC, diaC: integer;
begin
if not LoggedIn then Exit;
case cType of
0:
begin
sappC := SapphiresInLoad;
emeC := EmeraldsInLoad;
rubiC := RubiesInLoad;
diaC := DiamondsInLoad;
end;
1:
begin
sappC := (SapphiresInLoad - TotalSapphires);
emeC := (EmeraldsInLoad - TotalEmeralds);
rubiC := (RubiesInLoad - TotalRubies);
diaC := (DiamondsInLoad - TotalDiamonds);
end;
end;

GoldOreInLoad := CountItems('dtm', GoldOreDTM, []);
SapphiresInLoad := CountItems('dtm', SapphireDTM, []);
EmeraldsInLoad := CountItems('dtm', EmeraldDTM, []);
RubiesInLoad := CountItems('dtm', RubyDTM, []);
DiamondsInLoad := CountItems('dtm', DiamondDTM, []);
TotalGoldOre := (TotalGoldOre + GoldOreInLoad)
TotalSapphires := (TotalSapphires + sappC)
TotalEmeralds := (TotalEmeralds + emeC)
TotalRubies := (TotalRubies + rubiC)
TotalDiamonds := (TotalDiamonds + diaC)

end;

procedure OpenDaemonBank;
begin
ClickMouse2(mouse_right);
WaitOption('Ban', 100);
repeat
wait(100);
until(BankScreen) or (PinScreen)
if (PinScreen) then
InPin(Pin);
writeln('Currently banking ' + TimeGet);
CountInventory(0)
Deposit(2, 28, true);
Wait(RandomRange(500, 800));
CloseBank;
case random(3) of
0:Antiban;
1:Antiban;
2:AntibanBreaking;
end;
end;

function AtBank: boolean;
begin
result := ObjDTM_InArea('80:80:3:10:7:77:75:10:7:93:75:10:7:97:59:5:94:70:94:97:60:97:60:60:94:60', true);
end;

procedure Bank;
var
t, a: integer;
opened: boolean;
begin
if not LoggedIn then Exit;
MakeCompass('N');
SetAngle(1);
BankTele;
if not (AtDaemon) then
BankTele;
WalkToBank;
if not (AtBank) then
begin
MakeCompass('N')
ObjDTM_Walk('71:82:3:10:7:77:75:10:7:93:75:10:7:97:59:4:77:84:64:84:64:64:78:65', 1, 1000, 2, True);
end;
MarkTime(t);
for a := 1 to 4 do
begin
repeat
if not (opened) then
begin
if (FindDaemonBank(a, x, y)) then
begin
OpenDaemonBank;
opened := true;
end;
end;
until(TimeFromMark(t) > 10000) or (opened);
end;
if not (opened) then
begin
writeln('Could not find the banker!');
TerminateScript;
end;
end;

function AtMine: boolean;
begin
result := ObjDTM_InArea('82:80:4:1:7:74:108:1:7:101:109:1:7:108:87:1:7:99:60:6:56:90:56:104:57:123:119:118:108:60:56:61', true);
end;

procedure BackToMine;
var
t, dx, dy: integer;
begin
GuildTele;
WalkToGuild;
Wait(RandomRange(2000, 3000));
writeln('Looking for the door');
MarkTime(t);
if (FindObjTPA(dx, dy, 1790573, 15, 1, 20, 15, 200, ['pen'])) then
begin
writeln('Found the door')
ClickMouse2(mouse_Left)
Wait(RandomRange(2000, 3000))
ObjDTM_Walk('109:118:3:1:7:126:98:1:7:130:79:5:7:115:126', 1, 1000, 2, True)
{if not (AtMine)then
ObjDTM_Walk('109:118:3:1:7:126:98:1:7:130:79:5:7:115:126', 1, 1000, 2, True);}
SetAngle(0);
end else
Failsafe('Could not find the door!');
end;



function FindOre(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
R, G, B: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 2.21);

if not(FindColorsTolerance(arP, 4898790, MSX1, MSY1, MSX2, MSY2, 10)) then
begin
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);

if (R >= 196) and (R <= 254) and (G >= 162) and (G <= 213) and (B >= 61) and
(B <= 100) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 36.97) and (X <= 65.60) and (Y >= 38.39) and (Y <= 68.52) and
(Z >= 10.00) and (Z <= 21.59) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(RandomRange(100, 200));
if (IsUpText('ine')) then
begin;
Result := True;
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Antiban;
Exit;
end;

GetMousePos(fx, fy);
end;

procedure MineOre;
var
mineTimer, GoldInInven: integer;
begin
if not (AtMine) then
begin
MakeCompass('N')
ObjDTM_Walk('109:118:3:1:7:126:98:1:7:130:79:5:7:115:126', 1, 1000, 2, True);
end;
MakeCompass('S');
SetAngle(0);
if (FindOre(x, y)) then
begin
GoldInInven := (CountItems('dtm', GoldOreDTM, []));
case random(3) of
0: ClickMouse2(mouse_left);
1: ClickMouse2(mouse_left);
2: begin
ClickMouse2(mouse_right)
WaitOption('Min', 100)
end;
end;
MarkTime(mineTimer);
repeat
if FindNormalRandoms then
inc(RandomEvents);
Antiban;
Wait(500);
until
((CountItems('dtm', GoldOreDTM, [])) = (GoldInInven + 1))
or ((TimeFromMark(mineTimer)) > (RandomRange(15000, 16500)))
or (FindBlackChatMessage('no ore')) or (InvFull)
end;
if ((CountItems('dtm', GoldOreDTM, [])) = (GoldInInven + 1)) then
MarkTime(GoldTimer)
else
if (TimeFromMark(GoldTimer) > (RandomRange(900000, 960000))) then
Failsafe('You havent mined any gold ore in at least 15 minutes');
if not (InvFull) then
begin
case Random(3) of
0: Antiban;
1: Antiban;
2: AntibanBreaking;
end;
end;
end;

procedure DropInven;
var
I: integer;
DropPatt: TIntegerArray;
InvSlotTBox: TBox;
begin
DropPatt := [1,5,9,13,17,21,25,2,6,10,14,18,22,26,3,7,11,15,19,23,27,4,8,12,16,20,24,28];
CountInventory(1)
for I := 0 to 27 do
begin
InvSlotTBox := InvBox(DropPatt[I]);
if findDTM(GoldOreDTM, x, y, InvSlotTBox.X1, InvSlotTBox.Y1, InvSlotTBox.X2, InvSlotTBox.Y2) then
DropItem(DropPatt[I]);
if not (KeepSapphire) then
begin
if findDTM(SapphireDTM, x, y, InvSlotTBox.X1, InvSlotTBox.Y1, InvSlotTBox.X2, InvSlotTBox.Y2) then
DropItem(DropPatt[I]);
end;
if not (KeepEmerald) then
begin
if findDTM(EmeraldDTM, x, y, InvSlotTBox.X1, InvSlotTBox.Y1, InvSlotTBox.X2, InvSlotTBox.Y2) then
DropItem(DropPatt[I]);
end;
if not (KeepRuby) then
begin
if findDTM(RubyDTM, x, y, InvSlotTBox.X1, InvSlotTBox.Y1, InvSlotTBox.X2, InvSlotTBox.Y2) then
DropItem(DropPatt[I]);
end;
if not (KeepDiamond) then
begin
if findDTM(DiamondDTM, x, y, InvSlotTBox.X1, InvSlotTBox.Y1, InvSlotTBox.X2, InvSlotTBox.Y2) then
DropItem(DropPatt[I]);
end;
end;
end;

procedure PickCheck;
begin
if (Banking) then
begin
writeln('Looking for your pick...')
if (CheckItemInSlotByDTM(RunePickDTM, 1, false)) then
begin
writeln('Found pick in inventory slot 1')
end else
Failsafe('There isnt a pick in the first inventory slot!');
end;
end;

procedure FreeTheDTMs;
begin
FreeDTM(GoldOreDTM);
FreeDTM(SapphireDTM);
FreeDTM(EmeraldDTM);
FreeDTM(RubyDTM);
FreeDTM(DiamondDTM);
FreeDTM(RunePickDTM);
end;
procedure SetupSmart;
begin
Smart_Server := 11;
Smart_Members := Member;
Smart_Signed := True;
Smart_SuperDetail := False;
end;

procedure ScriptSetup;
begin
MouseSpeed := (RandomRange(13, 16));
FirstTele := 0;
LoadsMined := 1;
TotalGoldOre := 0;
TotalSapphires := 0;
TotalEmeralds := 0;
TotalRubies := 0;
TotalDiamonds := 0;
RandomEvents := 0;
GoldTimer := 0;
DTMSetup;
ActivateClient;
DeclarePlayers;
if not (LoggedIn) then
LoginPlayer;
PickCheck;
if not (AtMine) then
begin
MakeCompass('N')
ObjDTM_Walk('109:118:3:1:7:126:98:1:7:130:79:5:7:115:126', 1, 1000, 2, True);
end;
CameraSetup;
SetChat('All', 0)
end;

procedure MainLoop;
begin
repeat
if (FindNormalRandoms) then
inc(RandomEvents);
MineOre;
if (InvFull) then
begin
if (Banking) then
begin
Inc(LoadsMined)
Bank;
BackToMine;
if not (LoadsMined = Loads + 1) then
writeln('Starting on load ' + ToStr(LoadsMined));
end else
begin
Inc(LoadsMined);
DropInven;
if not (LoadsMined = Loads + 1) then
writeln('Starting on load ' + ToStr(LoadsMined));
end;
end;
until(LoadsMined = Loads + 1);
end;

procedure ProgressReport;
begin
writeln('')
writeln('//==========================================================//')
writeln('|| Time Running: ' + TimeRunning)
writeln('|| Random events encountered: ' + IntToStr(RandomEvents))
if (banking) then
begin
writeln('|| ' + IntToStr(Loads) + ' Loads banked')
writeln('|| ' + IntToStr(TotalGoldOre) + ' Gold ore banked')
writeln('|| ' + IntToStr(TotalSapphires) + ' Sapphires banked')
writeln('|| ' + IntToStr(TotalEmeralds) + ' Emeralds banked')
writeln('|| ' + IntToStr(TotalRubies) + ' Rubies banked')
writeln('|| ' + IntToStr(TotalDiamonds) + ' Diamonds banked')
writeln('|| ' + IntToStr(TotalGoldOre * 35) + ' Mining XP gained')
end;
if not (banking) then
begin
writeln('|| ' + IntToStr(Loads) + ' Loads dropped')
writeln('|| ' + IntToStr(TotalGoldOre) + ' Gold ore dropped')
writeln('|| ' + IntToStr(TotalGoldOre * 35) + ' Mining XP gained')
if (KeepSapphire) then
writeln('|| ' + IntToStr(TotalSapphires) + ' Sapphires kept');
if not (KeepSapphire) then
writeln('|| ' + IntToStr(TotalSapphires) + ' Sapphires dropped');
if (KeepEmerald) then
writeln('|| ' + IntToStr(TotalEmeralds) + ' Emeralds kept');
if not (KeepEmerald) then
writeln('|| ' + IntToStr(TotalEmeralds) + ' Emeralds dropped');
if (KeepRuby) then
writeln('|| ' + IntToStr(TotalRubies) + ' Rubies kept');
if not (KeepRuby) then
writeln('|| ' + IntToStr(TotalRubies) + ' Rubies dropped');
if (KeepDiamond) then
writeln('|| ' + IntToStr(TotalDiamonds) + ' Diamonds kept');
if not (KeepDiamond) then
writeln('|| ' + IntToStr(TotalDiamonds) + ' Diamonds dropped');
end;
writeln('\\==========================================================\\')
writeln('|| Thank you for using Mezzanine' + 's Crafting Guild Gold Miner!')
writeln('//==========================================================//')
end;

begin
ClearDebug;
SetupSmart;
SetupSRL;
ObjDTM_Setup;
ScriptSetup;
MainLoop;
LogOut;
ProgressReport;
FreeTheDTMs;
end.

{
//==========================================================//
|| Time Running: 3 Hours, 18 Minutes and 47 Seconds
|| 20 Loads banked
|| 532 Gold ore banked
|| 7 Sapphires banked
|| 1 Emeralds banked
|| 0 Rubies banked
|| 0 Diamonds banked
|| 18620 Mining XP gained
\\==========================================================\\
|| Thank you for using Mezzanines Crafting Guild Gold Miner!
//==========================================================//

//==========================================================//
|| Time Running: 1 Hours, 20 Minutes and 34 Seconds
|| 267 Gold ore banked
|| 0 Sapphires banked
|| 3 Emeralds banked
|| 0 Rubies banked
|| 0 Diamonds banked
|| 9345 Mining XP gained
\\==========================================================\\
|| Thank you for using Mezzanines Crafting Guild Gold Miner!
//==========================================================//

//==========================================================//
|| Time Running: 1 Hours, 19 Minutes and 13 Seconds
|| 256 Gold ore dropped
|| 8960 Mining XP gained
|| 4 Sapphires kept
|| 10 Emeralds kept
|| 0 Rubies kept
|| 0 Diamonds kept
\\==========================================================\\
|| Thank you for using Mezzanines Crafting Guild Gold Miner!
//==========================================================/


[INDENT]I took inspiration from YoHoJo's tutorials (along with many others, but not as much as his) as well as Runaway's ClayCraftBank's banking method. I put a lot of time into this and I hope that you guys enjoy it as much as I have![/INDENT]

Thanks for checking it out,
Mezzanine

[INDENT]Edit: I've updated the code with Runaway's suggestions as well as applying what he taught me throughout (Thank you!) I believe I've also fixed the bug where after a while it would walk the wrong direction when trying to go to the guild. I've also added a feature to adjust how much it antibans.[/INDENT]

YesMan

2012-06-28 06:57:41

This seem promissing, I'll give it a test today :)

Sir Ducksworthy

2012-06-28 07:14:51

Nice first script good on you!

YesMan

2012-06-28 07:51:47

Works great.
Mines quickly, teleports quickly, banks quickly and didn't missed the door from the Crafting Guild yet.

Very good for first Script. I'll definitely use this, thanks :)

Mezzanine

2012-06-28 09:04:33

Thank you for the feedback and Im glad that you guys like it :)
I ran into a problem doing my long trial test (20 loads :P) and that if it lags at opening the door you'll most likely get stuck outside the guild :( I'll make sure to put the fix out tomorrow morning since it's 3.00 here ;)

YesMan

2012-06-28 13:46:55

I ran to that problem after ~30 loads.
You might get stuck sometimes outside the Crafting Guild or else near the bank of Daemonhein, on the side of the Dungeon tutor. Can you fix this Mezzanine?

Besides that, the Script works great, pretty good job

Mezzanine

2012-06-28 14:58:07

You ran more than 30 loads?! You must have more minerals than I do, I get scared running any script past 20 :P So the fix will make the banking process (finding the bank, finding the door) a little bit slower, but I think it will be much more accurate :) Make sure to post any and all progress reports!

Thanks,
Mezzanine

Runaway

2012-06-28 16:19:55

Alright, so I've got a few suggestions/feedback on your code. I'll just list them in order of appearance. Most are tips to condense your code since a decent chuck of it is repetitive code with different variables. Here we go!

1) I see that you've been using a lot of:


if This then
begin
// ...
end;
if not This then
begin
// ...
end;

You can achieve the same thing (and without having to check that statement twice) by using an else statement. Here's an example in your CheckItemInSlotByDTM and PickCheck functions:


function CheckItemInSlotByDTM(DTM, slot: integer; write: boolean): boolean;
var
pointX, pointY, itemSlot: integer;
begin
if (ExistsItemDTM(DTM, pointX, pointY)) then
begin
itemSlot := (CoordsToItem(pointX, pointY));
if (itemSlot = slot) then
begin
if (write) then
writeln('An item with a matching DTM exists in the inventory slot ' + IntToStr(slot));
result := true;
end else // Same as doing the below statement
{if not (itemSlot = slot) then}
begin
if (write) then
writeln('An item with a matching DTM exists in the inventory, but not in slot ' + IntToStr(slot));
end;
end else // Same as doing the below statement
{if not (ExistsItemDTM(DTM, pointX, pointY)) then}
begin
if (write) then
writeln('An item with a matching DTM does not exist in the inventory');
end;
end;


procedure PickCheck; //accurate pick check (needs testing)
begin
if (Banking) then
begin
writeln('Looking for your pick...')
if (CheckItemInSlotByDTM(RunePickDTM, 1, false)) then
writeln('Found pick in inventory slot 1')
else // This again
{if not (CheckItemInSlotByDTM(RunePickDTM, 1, false)) then}
begin
writeln('Did not find pick in inventory slot 1!');
//Terminate;
end;
end;
end;

2) Just a suggestion, instead of your Failsafe procedure, I like to add a string along with it so you can mention what caused the script to terminate:


procedure Terminate(Reason: String);
begin
writeln('Error! '+ Reason);
Logout;
TerminateScript;
end;

That way you can simply call:

Terminate('Failed to bank!');

When you want to terminate the script and give a reason why it was terminated.

3) Semi-colons! I'm not exactly sure what not using them will do, but it's good to get in the habit of using them when they are needed. It's all through the script, but here's a snippet of what I mean:


procedure GuildTele;
begin
MouseEquippedItem('weapon', 0); // <- Semi-colons!
ChooseOption('Tel'); // <-
repeat
Wait(100); // <-
until(FindNPCChatText('Yes', Nothing)); // ...
FindNPCChatText('Yes', ClickLeft); // You get the point.
Wait(RandomRange(5000, 5500));
end;

4) Always use randomness. I see that you've done it quite a bit throughout, but you missed a few places, such as in your WalkToGuild function. Especially with walking, you should always make sure you're using random Wait values:


procedure WalkToGuild;
begin
ObjDTM_Walk('25:37:3:1:7:26:70:10:7:62:48:10:7:86:59:4:32:30:34:48:17:48:17:31', 5, 100, 3, True);
Wait(RandomRange(250, 500)); // Randomness is win
ObjDTM_Walk('34:74:3:1:7:41:57:1:7:20:73:1:7:44:103:4:27:69:42:70:35:84:26:79', 5, 100, 3, True);
Wait(RandomRange(250, 500)); // <-
ObjDTM_Walk('76:105:3:1:7:102:82:1:7:90:79:1:7:66:83', 1, 100, 3, True);
end;

5) This is a big one. You had four separate FindBankxxxx functions that were all using the same structure, but with different variables. This is when a case statement really saves you tons of time and space. I don't have much to explain for it, just take a look through the code and I'm sure you'll understand what's going on. If not, there are plenty of tutorials that include case statements and their usage. So, here is the new FindBank function:


function FindBank(Which: Integer; var fx, fy: Integer): Boolean;
// ^ Parameter to determine which bank vars to use
var
arP, arAP: TPointArray;
ColorsMods, arC, arUC: TIntegerArray;
ColorX, ColorY, ColorZ: TExtendedArray;
ararP: T2DPointArray;
Color, ColorTol, tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
Current: String;
// ^ Added all the case junk up here
begin
if not LoggedIn then Exit;
case Which of // Allows for dynamic variables
1: // this is essentially the same as the statement:
// if (Which = 1) then
// begin
// ...
// end;
begin
Current := 'one';
Color := 7884603;
ColorTol := 9;
ColorMods := [0.04, 0.65];
ColorX := [4.68, 12.76];
ColorY := [4.67, 12.78];
ColorZ := [9.87, 27.79];
end;
2:
begin
Current := 'two';
Color := 9200206;
ColorTol := 6;
ColorMods := [0.05, 0.18];
ColorX := [9.00, 16.20];
ColorY := [9.06, 16.25];
ColorZ := [19.02, 34.64];
end;
3:
begin
// etc ...
end;
4:
begin
// ...
end;
end;
writeln('Searching for bank '+ Current);
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(ColorMod[0], ColorMod[1]); // <-

if not(FindColorsTolerance(arP, Color, MSX1, MSY1, MSX2, MSY2, ColorTol)) then
begin
//Writeln('Failed to find the Bank.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= ColorX[0]) and (X <= ColorX[1]) and (Y >= ColorY[0]) and
(Y <= ColorY[1]) and (Z >= ColorZ[0]) and (Z <= ColorZ[1]) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
{Wait(RandomRange(100, 200));
if (IsUpText('ank')) then}
if WaitUptext(500, 'ank') then // More efficient than the above
begin;
Result := True;
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
//Writeln('FindBankOne could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

6) Another suggestion, I see that you've included your inventory counting code twice. Once when banking, and once when dropping. When you're going to use a big chunk of the exact same code, it's good to make a procedure out of it. Like this:


procedure HandleInventory;
begin
GoldOreInLoad := CountItems('dtm', GoldOreDTM, []);
SapphiresInLoad := CountItems('dtm', SapphireDTM, []);
EmeraldsInLoad := CountItems('dtm', EmeraldDTM, []);
RubiesInLoad := CountItems('dtm', RubyDTM, []);
DiamondsInLoad := CountItems('dtm', DiamondDTM, []);
TotalGoldOre := (TotalGoldOre + GoldOreInLoad);
TotalSapphires := (TotalSapphires + SapphiresInLoad);
TotalEmeralds := (TotalEmeralds + EmeraldsInLoad);
TotalRubies := (TotalRubies + RubiesInLoad);
TotalDiamonds := (TotalDiamonds + DiamondsInLoad);
end;

Then you can call HandleInventory whenever you want to check how many things are in your inventory. You could also call ProgressReport after everything within HandleInventory, as I see you've only called it after the script is terminated.

7) Since case statements are being used with FindBank now, you have to also update the Bank procedure to handle it properly. I've also included a few other tweaks (like a pin failsafe):


function Bank: Boolean; // Made this a function to utilize the result with the
// FindBank loop.
var
i: Integer;
begin
Result := False;
MakeCompass('N'); // <- You know the drill :P
SetAngle(1); // <-
writeln('Teleporting to bank ' + TimeGet); // ...
BankTele;
writeln('Walking to the bank ' + TimeGet);
WalkToBank;
FindNormalRandoms;
for i := 1 to 4 do
begin
if FindBank(i, x, y) then
begin
writeln('Found the bank!');
Wait(500+Random(500));
Result := True;
Break;
end else
writeln('Couldnt find the bank');
end;
if not Result then
begin
writeln('Failed to find to bank');
//Terminate;
// Or whatever you want to do if it's not at the bank
end;
FindNormalRandoms
writeln('Currently banking ' + TimeGet);
ClickMouse2(mouse_right); // Is there a point to the (x, y) coords coming from
// the FindBank function if you're not using them?
WaitOption('Ban', 1000); // Longer wait is better here, if you lagged for 1/10th
// of a second, the script would break.
repeat
wait(100);
until(BankScreen) or (PinScreen)
if (PinScreen) then
begin
if (Pin = '') then // Pin failsafe
//Terminate;
InPin(Pin);
end;
HandleInventory; // Less code = win!
Deposit(2, 28, true) ;
Wait(RandomRange(500, 800));
CloseBank;
case random(3) of
0:Antiban;
1:Antiban;
2:AntibanBreaking;
end;
end;

8) repeat..until failsafes with a MarkTime before and an until of TimeFromMark are extremely useful for almost anything; and especially object finding. I've added such a thing into your BackToMine procedure to search for the door for 10 seconds (or until the door is found). It's outrageously useful:


procedure BackToMine;
var
t, dx, dy: integer;
begin
writeln('Teleporting to the clan grounds ' + TimeGet);
GuildTele;
writeln('Walking to the guild ' + TimeGet);
WalkToGuild;
Wait(RandomRange(2000, 3000));
writeln('Looking for the door');
MarkTime(t); // Searches for the door for a maximum of 10 seconds
repeat
if (FindObjTPA(dx, dy, 1790573, 15, 1, 20, 15, 200, ['pen'])) then
begin
writeln('Found the door');
ClickMouse2(mouse_Left);
Wait(RandomRange(1000, 2000));
Break;
end else
writeln('Could not find the door!');
Wait(RandomRange(100, 300));
until(TimeFromMark(t) > (10 * 1000));
ObjDTM_Walk('109:118:3:1:7:126:98:1:7:130:79:5:7:115:126', 1, 1000, 2, True);
if not (AtMine)then
ObjDTM_Walk('109:118:3:1:7:126:98:1:7:130:79:5:7:115:126', 1, 1000, 2, True);
Wait(100);
SetAngle(0);
end;

9) And lastly, a final suggestion. If you're going to make a separate procedure for setting up SMART, you mine as well use parameters:


procedure SetupSmart(Server: Integer; Members: Boolean);
begin
Smart_Server := Server;
Smart_Members := Members;
Smart_Signed := True;
Smart_SuperDetail := False;
end;

On a final note, I'd like to mention that I don't necessarily expect you to use this code. I simply wanted to give you examples, relevant to your own code, of concepts that are useful. So don't feel obligated to use whatever I posted here, I just hope that you will digest and use the new knowledge posted above!

Well, that's it! You've definitely got a great start. I suggest you look at some tutorials on more advanced concepts, like TPA/ATPA's, types, cases, and loops. Let me know if you need any help with anything, and good luck :)

YesMan

2012-06-28 17:20:38

It would be nice if you followed Runaway's advices, pretty good code there

More than 30 Loads? Hell yeah I did, I put 200 loads, muahaha xD
btw, after 50~ Loads you start walking to the South of the Clan Camp and not to the East as it should be, can you fix that too?

Mezzanine

2012-06-28 17:32:46

Thank you so much for that! I had always seen else being used, but could never get it to always work for myself. I also would have never thought of using a case like that, I've only ever thought of using them for choosing things randomly. I will definitely implement these things in this script and certainly in future scripts :) Thank you for taking time to do this, it really taught me a lot!

Sincerely,
Mezzanine

Mezzanine

2012-06-28 17:37:20

From: YesMan
Hell yeah I did, I put 200 loads?

Jesus mate! And could you elaborate on what you mean by walkin to the south?

YesMan

2012-06-28 17:48:06

Instead of walking to the East, passing that blue orb or whatever, towards the Crafting Guild no, it went down, to the road, near some trees and just stood there, moving the camera forever, not being able to found the path to the Crafting Guild

Runaway

2012-06-28 17:51:44

From: Mezzanine
Thank you so much for that! I had always seen else being used, but could never get it to always work for myself. I also would have never thought of using a case like that, I've only ever thought of using them for choosing things randomly. I will definitely implement these things in this script and certainly in future scripts :) Thank you for taking time to do this, it really taught me a lot!

Sincerely,
Mezzanine


No problem! I didn't really say anything about this in the original post, so I guess I'll say it here. I'll give you a little overview of how else / end else statements work (when I first learned about then, these are things I wish someone had told me :p) to save you the hassle/frustration:

>> else

You use an else statement when you have a single line of code / procedure after the if..then statement. For example:


if Whatever then
This
else
That;

^ You do not use a semi-colon after the procedure between the if..then and the else. Doing so will cause an error. This is because it is technically one line of code, and there is no difference between the above, and this:

if Whatever then This else That;

You can also use an else statement when you're nesting something:


if Whatever then
if not This then
Terminate
else
That;

^ You can do this because the nested statement is technically one line of code (only one semi-colon). There is no difference between the above and this:

if not This then Terminate

>> end else

You use an end else statement when you have more than one line of code / procedure, or when you have a begin after the if..then statement (which is the same thing). For example:


if Whatever then
begin
This;
That;
end else
Terminate;

Note that you should use semi-colons after everything when using an if..then..end else statement.

else / end else are really useful and can cut down on a lot of down. Use them as much as you can!

Mezzanine

2012-06-28 18:53:30

I've been updating this script with everything you've taught me and I noticed you defined the ColorMods as an integer array, as opposed to an extended int array. Why is this? I thought that any non real numbers had to be extended?

Runaway

2012-06-28 19:34:20

From: Mezzanine
I've been updating this script with everything you've taught me and I noticed you defined the ColorMods as an integer array, as opposed to an extended int array. Why is this? I thought that any non real numbers had to be extended?


Oops :duh: Don't know why I went and did that! You're right, it should be a TExtendedArray.

Mezzanine

2012-06-28 20:53:26

Oh alright :)

YesMan

2012-07-01 10:22:43

Will you improve the Script my friend?

Mezzanine

2012-07-01 20:31:10

I updated the script and I believe I fixed your walking problem :)

YesMan

2012-08-05 14:34:28

Mezz, how do I fix this?
[Error] C:\Simba\Includes\SRL/SRL/misc/smart.simba(53:19): Invalid number of parameters at line 52
Compiling failed.

Mezzanine

2012-08-07 20:01:54

It's an awfully common error, and I find completely restarting Simba fixes it most of the time.

Punkgi

2012-08-10 12:43:29

Hello there I was trying to test out your script (looks good) and I get this error
Exception in Script: Unable to find file 'ObjectDTM\ObjDTMInclude.simba' used from ''

I'm not sure what's wrong with that.

YesMan

2012-08-11 05:25:53

Search for ODTM here and install that extension ( http://villavu.com/forum/showthread.php?t=68112 )
Since I'm kind, go here: http://villavu.com/forum/attachment.php?attachmentid=13068&d=1330763221

boonjian

2012-10-20 20:44:12

Guys! Why is there a error on perimeter line 45

Mezzanine

2012-10-24 21:17:11

Hey guys, uni and internships had started up and I haven't had much time on my hands to keep the code up to date. Just curious as to whether anyone is still using it, or even if it still works! I plan on writing and releasing something within the next month if time permits.

Mezzanine

night fox6928

2012-11-08 17:51:22

i get this

Exception in Script: Unable to find file 'ObjectDTM\ObjDTMInclude.simba' used from 'C:\Users\BIGK~1\AppData\Local\Temp\Mezz Crafting Guild Gold Miner 0.2.simba'


whats that mean

Ian

2012-11-08 19:01:41

It means you need to go to this thread and read it. Then do what it says.

night fox6928

2012-11-10 17:23:05

From: BMWxi
It means you need to go to this thread and read it. Then do what it says.


thanks

night fox6928

2012-11-10 17:30:36

now i get this

[Error] C:\Simba\Includes\SRL/SRL/misc/smart.simba(46:19): Invalid number of parameters at line 45
Compiling failed.

The Killer

2012-11-10 17:35:52

From: night fox6928
now i get this

[Error] C:\Simba\Includes\SRL/SRL/misc/smart.simba(46:19): Invalid number of parameters at line 45
Compiling failed.


force update your smart or do the proper fix which is to remove the +1 and put ''
(two seperate ' )

DCana60

2013-05-06 15:32:04

I solved the line 45 parameter problem by updating my smart then i get this error:

[Error] C:\Simba\Includes\SRL\SRL\misc\smart.simba(56:19): Invalid number of parameters at line 55
Compiling failed.

t4q

2013-05-06 15:59:11

Look at the date of this script, I don't think it works :/