PDA

View Full Version : help plz.. its mt first script.. :P



ålle
04-21-2007, 08:31 PM
:cartman: can some1 tell me whata f*** i did wrong with my first script? plz :spongebob: :confused:

program RimmingtonIronMinerAndBanker;

{.include SSI2.txt}
{.include KSI2.txt}
{.include BoxBreaker.txt}

const
{ *** Setup *** }

User = ''; // Username here.

Pass = ''; // Password here.

Run = 'N'; // What direction do u want to run when attacked.
// Change if you want.

UsePick = True; // Where do u want to keep pick. True = Equip tab.
// False = 1st slot in inv.

MaxWait = 6500; // Maximum time to wait when Mining A Rock.
// In MilliSeconds.

TypeOfRock = 0; // What Rock do you want to mine. 0 = Iron, 1 = Tin,
// 2 = Copper

UseForm = True; // True if you want to use forms.

Look4Gas = True; // True if you want to look for gas.

{ LOOK DOWN BELOW FOR MORE SETUP OPTIONS! }


{ *** Color Setup *** }
{ You can leave colors at 0 to let the script find. However,
Note: The RoadColor find works all the time now. Thanks to
SDouble. }

RoadColor = 0; // Color Of Road. On MiniMap.
BankSymbol = 0 ; // Color Of The Bank Symbol. On MiniMap.
Water = 0; // Color of Water. On Minimap.
MMPick = 0; // Color Of the pick symbol in mines. On MiniMap.
MMRock = 0; // Color Of Grey Rocks in the mine. On MiniMap.

//<<********************** Ore Colors ***************************>>

RockColor1= 0; //Colors of rocks in main screen.
RockColor2= 0;
RockColor3= 0;

//////////////////////////////////////////////////////
// Do Not Change the Following //
//////////////////////////////////////////////////////
const

Version = 1.18;

var
gOreColor, gCounter : Integer;
gNumtrip, gOres : Integer;
OreCol, OreTol1, OreTol2: Integer;
gXP, gOreXP: Extended;
UsersLoaded, EquipPick: Boolean;
RockType: Integer;
gLostPick : Boolean;
Mark: Integer;
report, report2 : Integer;
MapPick, BankIcon, MapRock, RoadCol, WaterColor : Integer;
ScriptStarted: Boolean;

frmDesign : TForm;
Label1 : TLabel;
Label2 : TLabel;
MyUser : TEdit;
MyPass : TEdit;
Button1 : TButton;
CheckBox1 : TCheckBox;
MyRockType : TComboBox;


{ *** MORE SETUP STUFF HERE *** }

procedure Setup;
begin
if(not(User = ''))or(not(Pass = ''))then
begin
UsersLoaded := True;
Username := User; //Username.
Password := Pass; //Password.
end;
end;

//>>------------ Copied From Stupid3ooo's Powerminer -------------<<

procedure GetOreType;
begin
if(RockType = 0)then//0-Iron
begin
OreCol := 2898528;
OreTol1 := 5;
OreTol2 := 25;
gOreXP := 35;
end;
if(RockType = 1)then//1-Tin
begin
OreCol := 10198184;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
if(RockType = 2)then//2-Copper
begin
OreCol := 7512298;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
end;




{ *** Progress Report *** }

procedure ProgressReport; // A Stupid3ooo procedure modified by Kernel Klink.
var
AverageTime:longint;
RHours, Minutes, Seconds, RMinutes, RSeconds:LongInt;
Time:String;
begin
if(GetSystemTime-report2 > report*60000)then
begin
Seconds:=(GetSystemTime-ST) div 1000;
Minutes:=Seconds div 60;
AverageTime:= Seconds/gNumTrip;
gXP := gOres*gOreXP;
RHours:=Minutes div 60;
Time:=IntToStr(Seconds)+' Seconds';
if Minutes<>0 then
begin
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(Minutes)+' Minutes and '+IntToStr(RSeconds)+' Seconds';
end;
if RHours<>0 then
begin
RMinutes:=Minutes Mod (RHours*60);
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(RHours)+' Hours, '+IntToStr(RMinutes)+' Minutes and '
+IntToStr(RSeconds)+' Seconds';
end;
begin
ClearReport;
ChangeReportWidth(500);
AddToReport('-----------Progress Report--------------');
AddToReport('------------Version ' + (FloatToStr(Version)) + ' --------------');
AddToReport('Worked For ' + Time);
AddToReport('Made ' + (IntToStr(gNumtrip)) + ' Trips');
AddToReport('Banked ' + (IntToStr(gOres)) + ' Ores');
AddToReport('Gained ' + (FloatToStr(gXP)) + ' XP');
AddToReport('Currently Averaging At '+ (IntToStr(3600/AverageTime*(gOres/gNumtrip)))+
' ores and '+(FloatToStr(3600/AverageTime*(35*(gOres/gNumtrip))))+ ' xp an hour.');
AddToReport('Random Event Report:');
if(fights>0)then AddToReport(' Avoided '+IntToStr(Fights)+' Fight[s].');
if(Doctors>0)then AddToReport(' Completed '+IntToStr(Doctors)+' Doctor[s].');
if(talks>0)then AddToReport(' Talked to '+IntToStr(Talks)+' Random event[s].');
if(lamps>0)then AddToReport(' Used lamps '+IntToStr(Lamps)+' time[s].');
if(boxes>0)then AddToReport(' Solved '+IntToStr(boxes)+' box[es].');
if(logs>0)then AddToReport(' Logged in '+IntToStr(Logs)+' time[s].');
AddToReport('<======================================>');
end;
end;
end;


{ *** Misc Procedures *** }

procedure SetVariables;
begin
MapPick := MMPick;
BankIcon := BankSymbol;
MapRock := MMRock;
EquipPick := UsePick;
RockType := TypeOfRock;
RoadCol := RoadColor;
WaterColor := Water;
OreColor1:= RockColor1;
OreColor2:= RockColor2;
OreColor3:= RockColor3;
end;

procedure ResetColors;
begin
OreColor1:= 0;
OreColor2:= 0;
OreColor3:= 0;
end;

procedure CantFindColors;
begin
KlinkDebug('Sorry, the colors could not be found. Please Start The Script over' +
' or set the colors yourself.', False);
LogOut;
TerminateScript;
end;

procedure LoadMemory; // Loads Bitmaps And DTM's.

begin
end;



function InBank: Boolean;
begin
if(FindColorSpiral(x, y, BankIcon, M1, M2, M3, M4))then
Result:= True;
end;



procedure ToBankCounter; // A Stupid3ooo Procedure Modified by Kernel Klink

var
c, ax, ay: Integer;
begin
while c<30 do
begin
c:=c+5;
if(FindMMColor(BankIcon))then
begin
if(FindColorSpiralTolerance(ax, ay, 195836, x-c, y-c, x+c, y+c, 10))then
begin
x:=ax;
y:=ay;
MouseFindFlag(x, y-3, 0, -2);
FlagAtColor(BankIcon);
Wait(1000+Random(100));
Break;
end;
end;
end;
end;
{ *** ColorFinding Procedures *** }

procedure GetOreColors;
var
Count: Integer;
begin
if(OreColor1 = 0)or(OreColor2 = 0)or(OreColor3 = 0)then
begin
Count:= 0;
repeat
if(FindOreColors(2305871, 8, 16))then
break;
Count:= Count + 1
if (Count > 49) then
CantFindColors;
until(Count > 49);
end;
end;

Function FindWaterColor : Integer; // From Fakawi. Thanks.
var
C,TX,TY,
bmpFaladorWater: Integer;

begin
bmpFaladorWater := BitmapFromString(6, 6, 'z78DA33733677B' +
'174351B7624000B723409');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(bmpFaladorWater, TX, TY, MMCX-75, MMCY+20, MMCX-20, MMCY+30, C)) then
begin
Result := GetColor(TX,TY);
break;
end;
end;
FreeBitMap(bmpFaladorWater);
if(Result = 0)then
writeln('ERROR: Watercolor NOT Found');
end;

function FindRoadColor: Integer; // by WT-Fakawi

var C,TX,TY,FaladorRoad:integer;

begin
FaladorRoad := BitmapFromString(6, 6, 'z78DA3373363301' +
'C261470200DE652ED5');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(FaladorRoad, TX, TY, MMCX, MMCY-20, MMCX+30, MMCY+20, C))then
begin
Result := GetColor(TX,TY);
break;
end;
end;
if(Result = 0)then
writeln('ERROR: RoadColor NOT Found');
FreeBitMap(FaladorRoad);
end;

function FindMapOreColor: Integer;//Completely Copied from Stupid's GuildMiner
var
MapOre, MapOre2 : Integer;
begin
MapOre := BitmapFromString(3, 3,
'3D2C345948546D5D624A39416D5D626D5D625948546D5D626 D5D62' +
'');
MapOre2 := BitmapFromString(3, 3,
'061115222D35364243131E22364243364243222D353642433 64243' +
'');

if(FindBitmapsProgressiveTol(MapOre, MapOre2, 0, 0, 0, 65, 5, 587, 41, 705, 118))then
Result:=GetColor(x+1, y+1);
Freebitmap(MapOre);
Freebitmap(MapOre2);
end;


procedure FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
var
Count: Integer;
begin
Count:=0;
if(MapRock = 0)or(MapPick=0)then
begin
KlinkDebug('Finding colors at Mine please Wait...', False);
while(MapRock=0)or(MapPick=0)do
begin
Count:= Count + 1;
if(MapRock = 0)then // Checks to see if the colors have already been set.
MapRock:= FindMapOreColor;
if(MapPick = 0)then
MapPick:= GetSymbolColor('mining spot');
if(Count>20)then
CantFindColors;
end;
KlinkDebug('MMOre:' + IntToStr(MapRock)+ // Prints the colors found.
' MMPick:' + IntToStr(MapPick), False);
end;
end;

procedure FindColorsAtBank; // Searches for colors at bank
// (RoadColor, BankSymbol).

var
Count: Integer;
begin
Count:=0;
if(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)then
begin
KlinkDebug('Finding colors at bank please Wait...', False);
while(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)do
begin
Count:= Count + 1;
if(RoadCol = 0)then // Checks to see if the colors have already been set.
RoadCol := FindRoadColor;
if(BankIcon = 0)then
BankIcon := GetSymbolColor('bank');
if(WaterColor = 0)then
WaterColor := FindWaterColor;
if(Count>20)then
CantFindColors;
end;
KlinkDebug('RoadColor:'+IntToStr(RoadCol)+
' BankColor:'+ IntToStr(BankIcon) +
' WaterColor: ' + IntToStr(WaterColor), False);
end;
end;


{ *** Anti Randoms ***
*** Stuff for scheduler *** }

procedure RunAwayFromRandoms;
begin
SetRun(true);
RunAwayDirection(Run);
wait(15000 + random(5000));
RunBack;
end;

function InMine: Boolean;
begin
Result := False;
if(FindMMColor(MapPick))then
Result := True;
end;

procedure CheckFight; // Checks to see if you are in a fight. If it does, it
// will run away and back.
begin
if(FindFight)then
RunAwayFromRandoms;
end;

procedure CheckRandoms;
begin
FindNormalRandoms;
AntiBan;
CheckFight;
FindDoctor;
FindBox;
if(InMine)then
begin
if(not(FindPick))then // Checks to see if your pickhead flew off.
// It will try to find it, but if it doesn't, it
// will withdraw any spare picks at the bank.

gLostPick:= True;
if(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220))then
begin
if(Look4Gas)then
begin
if(FindGas(x,y))then
begin
Mouse(MMCX, MMCY, r, r, True)
Flag;
end;
end;
end;
end;
end;


{ *** Important Procedures *** }


{^^^^^^^^^^^^^^^^^ FINDROCK ^^^^^^^^^^^^^^^^^^^^^^^}
{ Copied and Modded from Squig }
{^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^}

//**************** Credits for TPoints go to Fakawi *********************//

function FindRock(RockType : Integer) : TPoint;
var
RockColor, Tol : Integer;
XY: TPoint;
begin
Tol := 5;
case(RockType)of
0 : RockColor:= 2240076;
1 : RockColor:= 4088199;
2 : RockColor:= 6184550;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end else
begin
case(RockType)of
0 : Rockcolor:= 593178;
1 : Rockcolor:= 10000804;
2 : RockColor:= 5212637;
end;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end;
gOreColor := RockColor;
end;


procedure Bank; // Will bank all your ores and withdraw a new pickaxe if needed.

begin
if(InBank)then
begin
KlinkDebug('Banking', False);
gOres:= gOres + CountItemBmpTol(Ore, 50); // Counts the amount of ores you
// mined.

OpenBank;
if(BankScreen)then
begin
if(gLostPick=True)then
Withdraw(1, 1, 1); // If you lost your pick, withdraw a new one.

if(EquipPick=True)then
Deposit(1, 28, 2)
else
Deposit(2, 28, 2);
end;
CloseWindow;
if(gLostPick=true)and(EquipPick=true)then // If you lost your pick,
// do the following.

begin
FindPickHeadColor; // Find colors of new pickhead colors if you lost one.

ClickItemColor(hc1, true); // If EquipPick is true, Equip it.

end;
gNumTrip:= gNumTrip + 1;
end;
end;


{>>---------------- Copied From Stupid's Powerminer ---------------------}
procedure Mine;
var
WaitMax: Integer;
InvC: Integer;


begin
InvC := InventoryCount;
SetRandomOreColor;
if(FindObj('Mine', OreColor, 5))then
begin
if(not(FindGas(x,y)))then
begin
Mouse(x, y, R, R, true);
KlinkDebug('Mining', True)
if(FlagPresent)then
begin
Flag;
Wait(500+Random(500));
end;
MarkTime(WaitMax);
begin
repeat
if(not(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220)))then
Break;
CheckRandoms;
Wait(500+Random(500));
until(not(GetColor(109,430)=0)and(not(GetColor(195 ,426)=0))or // checks 100% for the words
// "you have succesfully...".
(not(InvC = InventoryCount))or(TimeFromMark(WaitMax) >= MaxWait));
end;
end;
end;
end;

{ *** Mapwalking *** }


procedure ToRocks;
begin
KlinkDebug('Going to rocks.', False);
if(RockType = 0)then
begin
RadialWalk(MapRock, 225, 315, 48, +1, 0);
end;
if(RockType = 1)then
begin
RadialWalk(MapRock, 60, 135, 48, -1, 0);
end;
if(RockType = 2)then
begin
RadialWalk(MapRock, 405, 330, 48, 0, 1);
end;
FindOreColors(OreCol, OreTol1, OreTol2);
end;



procedure ToMines; // Walks To rimmington mines.
var
C: Integer;
CX, CY: Integer;
begin
CheckRandoms;
C := 0;
if(FindMMColor(BankIcon))then
begin
RadialWalk(RoadCol, 150, 220, 35, -1, -1);
C := C + 1;
repeat
if(C < 5)then
RadialWalk(RoadCol, 150, 220, 53, -1, -1)
else
RadialWalk(RoadCol, 150, 220, 40, -1, -1)
C := C+1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] Towards Water - Bisect in Road', False)
until(FindMMColor(WaterColor))and(C > 4);
KlinkDebug ('At Water - Water Found.', False)
RadialWalk(RoadCol, 150, 220, 35, -1, -1)
C := 0;
repeat
RadialWalk(RoadCol, 230, 310, 45, 1, 0)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] West', False);
until(FindColor(CX, CY, RoadCol, MMCX - 75, MMCY + 25, MMCX , MMCY + 25))
and(C > 1)or(C>4);
KlinkDebug('SouthWest Turn Found', False);
RadialWalk(RoadCol, 180, 250, 55, 1, -1);
C := 0;
repeat
Mouse(646, 151, r, r, true);
Flag;
C := C+1
until(C >= 1);
KlinkDebug('At entrance to mine.', False)
end;
while(not(FindSymbol('mining spot')))do
begin
Mouse(646, 135, r, r, True);
Flag;
end;
FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
if(FindMMColor(MapPick))then
begin
Mouse(x, y, r, r, true);
Flag;
end;
end;

procedure ToBank; // Walks To Bank.

var
CX, CY : Integer;
Walks, C: Integer;
begin
Walks := 0;
C := 0;
if(FindMMColor(MapPick))then
begin
KlinkDebug('Walking to Bank', True);
KlinkDebug('Heading out of mines.', False);
MouseFindFlag(x, y - 35, 0, +1); // Clicks 35 coordinates away from the
// MM Pick symbol on the Y axis.
Flag;
end;
repeat
RadialWalk(RoadCol, 420, 325, 55, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps NorthEast', False);
until(FindColor(CX, CY, RoadCol, MMCX + 15, MMCY - 10, MMCX + 70, MMCY + 35))
and(C >= 1);
C := 0;
repeat
RadialWalk(RoadCol, 135, 45, 50, 0, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps East', False);
until(FindMMColor(WaterColor))or(C >= 3);
KlinkDebug('Reached water - heading North', False);
C := 0;
repeat
if(FindMMColor(WaterColor))and(C > 2)then
begin
RadialWalk(RoadCol, 440, 315, 40, -1, -1)
C := C + 1
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end else
begin
RadialWalk(RoadCol, 405, 315, 50, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end;
until(FindMMColor(BankIcon));
RadialWalk(RoadCol, 405, 315, 35, -1, -1);
KlinkDebug('Reached bank - Heading into bank.', False);
ToBankCounter; // Positions you near the bank booths and counters.
end;

//******************************* Forms ********************************// }



procedure MyShowFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('MyInitForm', v);
setarraylength(V, 0);
ThreadSafeCall('MyShowFormModal', v);
end;

procedure StartScript(sender: TObject);
begin
if((not(MyUser.text = ''))and(UsersLoaded))or((not(MyPass.text = ''))and(UsersLoaded))then
begin
Username := MyUser.text;
PassWord := MyPass.text;
end;
EquipPick := CheckBox1.state;
case(MyRockType.Text)of
'Iron': RockType := 0;
'Tin': RockType := 1;
'Copper': RockType := 2;
end;
frmDesign.Caption:= frmDesign.Caption + '.';
ScriptStarted:= True;
frmDesign.ModalResult:= mrOk;
end;

procedure MyInitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 367;
frmDesign.Top := 209;
frmDesign.Width := 203;
frmDesign.Height := 241;
frmDesign.Caption := 'IronMiner/Banker';
frmDesign.Color := clWhite;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.Left := 68;
Label1.Top := 15;
Label1.Width := 48;
Label1.Height := 13;
Label1.Caption := 'Username';
Label2 := TLabel.Create(frmDesign);
Label2.Parent := frmDesign;
Label2.Left := 70;
Label2.Top := 57;
Label2.Width := 46;
Label2.Height := 13;
Label2.Caption := 'Password';
MyUser := TEdit.Create(frmDesign);
MyUser.Parent := frmDesign;
MyUser.Left := 36;
MyUser.Top := 33;
MyUser.Width := 121;
MyUser.Height := 21;
MyUser.Hint := 'Type your username here.';
MyUser.TabOrder := 1;
MyUser.Text := '';
if(not(User = ''))then
MyUser.Text := User;
MyPass := TEdit.Create(frmDesign);
MyPass.Parent := frmDesign;
MyPass.Left := 36;
MyPass.Top := 72;
MyPass.Width := 121;
MyPass.Height := 21;
MyPass.Hint := 'Type your password here';
MyPass.PasswordChar := '*';
MyPass.TabOrder := 2;
MyPass.Text := '';
if(not(Pass = ''))then
MyPass.Text := Pass;
Button1 := TButton.Create(frmDesign);
Button1.OnClick:= @StartScript;
Button1.Parent := frmDesign;
Button1.Left := 58;
Button1.Top := 173;
Button1.Width := 75;
Button1.Height := 25;
Button1.Caption := 'Start';
Button1.TabOrder := 5;
CheckBox1 := TCheckBox.Create(frmDesign);
CheckBox1.Parent := frmDesign;
CheckBox1.Left := 58;
CheckBox1.Top := 105;
CheckBox1.Width := 77;
CheckBox1.Height := 17;
CheckBox1.Hint := 'Is your pickaxe equipped?';
CheckBox1.Caption := 'EquipPick?';
CheckBox1.TabOrder := 3;
if(EquipPick)then
CheckBox1.State := True;
MyRockType := TComboBox.Create(frmDesign);
MyRockType.Parent := frmDesign;
MyRockType.Left := 25;
MyRockType.Top := 139;
MyRockType.Width := 145;
MyRockType.Height := 21;
MyRockType.Hint := 'Which rock are you going to mine?';
MyRockType.ItemHeight := 13;
MyRockType.TabOrder := 4;
MyRockType.Text := 'RockType';
MyRockType.Items.Add('Iron');
MyRockType.Items.Add('Tin');
MyRockType.Items.Add('Copper');
case(RockType)of
0: MyRockType.Text := 'Iron';
1: MyRockType.Text := 'Tin';
2: MyRockType.Text := 'Copper';
end;
end;

procedure SetupForm;
begin
if(UseForm)then
begin
SafeShowForm;
if(ScriptStarted = False)then
TerminateScript;
ActivateClient;
end;
end;

//******************************* Main *********************************//

begin
SetupSSI;
Setup;
SetVariables;
SetupForm;
PrepClient;
GetOreType;
FindPickHeadColor;
LoadMemory;
FindColorsAtBank;
RColor:= RoadCol;
gCounter:=0;
repeat
SetRun(True);
ToMines; // Go To Mines
ToRocks; // Go to the rocks in the mine.

Wait(1000 + Random(500));
SetRun(False);
Wait(500 + random(1000))
MarkTime(Mark);
repeat
CheckRandoms;
Mine;
until(InventoryFull)or(gLostPick = True)or(TimeFromMark(Mark)>1200000)

ToBank; // Go to the East Fallidor bank.

Bank; // Bank your ores and get a new pick if needed.

ProgressReport; // Progress Report. Info on what happened. Please post
// them on the thread for this script.

gCounter := gCounter + 1;
until(False);
end.





program RimmingtonIronMinerAndBanker;

{.include SSI2.txt}
{.include KSI2.txt}
{.include BoxBreaker.txt}

const
{ *** Setup *** }

User = ''; // Username here.

Pass = ''; // Password here.

Run = 'N'; // What direction do u want to run when attacked.
// Change if you want.

UsePick = True; // Where do u want to keep pick. True = Equip tab.
// False = 1st slot in inv.

MaxWait = 6500; // Maximum time to wait when Mining A Rock.
// In MilliSeconds.

TypeOfRock = 0; // What Rock do you want to mine. 0 = Iron, 1 = Tin,
// 2 = Copper

UseForm = True; // True if you want to use forms.

Look4Gas = True; // True if you want to look for gas.

{ LOOK DOWN BELOW FOR MORE SETUP OPTIONS! }


{ *** Color Setup *** }
{ You can leave colors at 0 to let the script find. However,
Note: The RoadColor find works all the time now. Thanks to
SDouble. }

RoadColor = 0; // Color Of Road. On MiniMap.
BankSymbol = 0 ; // Color Of The Bank Symbol. On MiniMap.
Water = 0; // Color of Water. On Minimap.
MMPick = 0; // Color Of the pick symbol in mines. On MiniMap.
MMRock = 0; // Color Of Grey Rocks in the mine. On MiniMap.

//<<********************** Ore Colors ***************************>>

RockColor1= 0; //Colors of rocks in main screen.
RockColor2= 0;
RockColor3= 0;

//////////////////////////////////////////////////////
// Do Not Change the Following //
//////////////////////////////////////////////////////
const

Version = 1.18;

var
gOreColor, gCounter : Integer;
gNumtrip, gOres : Integer;
OreCol, OreTol1, OreTol2: Integer;
gXP, gOreXP: Extended;
UsersLoaded, EquipPick: Boolean;
RockType: Integer;
gLostPick : Boolean;
Mark: Integer;
report, report2 : Integer;
MapPick, BankIcon, MapRock, RoadCol, WaterColor : Integer;
ScriptStarted: Boolean;

frmDesign : TForm;
Label1 : TLabel;
Label2 : TLabel;
MyUser : TEdit;
MyPass : TEdit;
Button1 : TButton;
CheckBox1 : TCheckBox;
MyRockType : TComboBox;


{ *** MORE SETUP STUFF HERE *** }

procedure Setup;
begin
if(not(User = ''))or(not(Pass = ''))then
begin
UsersLoaded := True;
Username := User; //Username.
Password := Pass; //Password.
end;
end;

//>>------------ Copied From Stupid3ooo's Powerminer -------------<<

procedure GetOreType;
begin
if(RockType = 0)then//0-Iron
begin
OreCol := 2898528;
OreTol1 := 5;
OreTol2 := 25;
gOreXP := 35;
end;
if(RockType = 1)then//1-Tin
begin
OreCol := 10198184;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
if(RockType = 2)then//2-Copper
begin
OreCol := 7512298;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
end;




{ *** Progress Report *** }

procedure ProgressReport; // A Stupid3ooo procedure modified by Kernel Klink.
var
AverageTime:longint;
RHours, Minutes, Seconds, RMinutes, RSeconds:LongInt;
Time:String;
begin
if(GetSystemTime-report2 > report*60000)then
begin
Seconds:=(GetSystemTime-ST) div 1000;
Minutes:=Seconds div 60;
AverageTime:= Seconds/gNumTrip;
gXP := gOres*gOreXP;
RHours:=Minutes div 60;
Time:=IntToStr(Seconds)+' Seconds';
if Minutes<>0 then
begin
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(Minutes)+' Minutes and '+IntToStr(RSeconds)+' Seconds';
end;
if RHours<>0 then
begin
RMinutes:=Minutes Mod (RHours*60);
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(RHours)+' Hours, '+IntToStr(RMinutes)+' Minutes and '
+IntToStr(RSeconds)+' Seconds';
end;
begin
ClearReport;
ChangeReportWidth(500);
AddToReport('-----------Progress Report--------------');
AddToReport('------------Version ' + (FloatToStr(Version)) + ' --------------');
AddToReport('Worked For ' + Time);
AddToReport('Made ' + (IntToStr(gNumtrip)) + ' Trips');
AddToReport('Banked ' + (IntToStr(gOres)) + ' Ores');
AddToReport('Gained ' + (FloatToStr(gXP)) + ' XP');
AddToReport('Currently Averaging At '+ (IntToStr(3600/AverageTime*(gOres/gNumtrip)))+
' ores and '+(FloatToStr(3600/AverageTime*(35*(gOres/gNumtrip))))+ ' xp an hour.');
AddToReport('Random Event Report:');
if(fights>0)then AddToReport(' Avoided '+IntToStr(Fights)+' Fight[s].');
if(Doctors>0)then AddToReport(' Completed '+IntToStr(Doctors)+' Doctor[s].');
if(talks>0)then AddToReport(' Talked to '+IntToStr(Talks)+' Random event[s].');
if(lamps>0)then AddToReport(' Used lamps '+IntToStr(Lamps)+' time[s].');
if(boxes>0)then AddToReport(' Solved '+IntToStr(boxes)+' box[es].');
if(logs>0)then AddToReport(' Logged in '+IntToStr(Logs)+' time[s].');
AddToReport('<======================================>');
end;
end;
end;


{ *** Misc Procedures *** }

procedure SetVariables;
begin
MapPick := MMPick;
BankIcon := BankSymbol;
MapRock := MMRock;
EquipPick := UsePick;
RockType := TypeOfRock;
RoadCol := RoadColor;
WaterColor := Water;
OreColor1:= RockColor1;
OreColor2:= RockColor2;
OreColor3:= RockColor3;
end;

procedure ResetColors;
begin
OreColor1:= 0;
OreColor2:= 0;
OreColor3:= 0;
end;

procedure CantFindColors;
begin
KlinkDebug('Sorry, the colors could not be found. Please Start The Script over' +
' or set the colors yourself.', False);
LogOut;
TerminateScript;
end;

procedure LoadMemory; // Loads Bitmaps And DTM's.

begin
end;



function InBank: Boolean;
begin
if(FindColorSpiral(x, y, BankIcon, M1, M2, M3, M4))then
Result:= True;
end;



procedure ToBankCounter; // A Stupid3ooo Procedure Modified by Kernel Klink

var
c, ax, ay: Integer;
begin
while c<30 do
begin
c:=c+5;
if(FindMMColor(BankIcon))then
begin
if(FindColorSpiralTolerance(ax, ay, 195836, x-c, y-c, x+c, y+c, 10))then
begin
x:=ax;
y:=ay;
MouseFindFlag(x, y-3, 0, -2);
FlagAtColor(BankIcon);
Wait(1000+Random(100));
Break;
end;
end;
end;
end;
{ *** ColorFinding Procedures *** }

procedure GetOreColors;
var
Count: Integer;
begin
if(OreColor1 = 0)or(OreColor2 = 0)or(OreColor3 = 0)then
begin
Count:= 0;
repeat
if(FindOreColors(2305871, 8, 16))then
break;
Count:= Count + 1
if (Count > 49) then
CantFindColors;
until(Count > 49);
end;
end;

Function FindWaterColor : Integer; // From Fakawi. Thanks.
var
C,TX,TY,
bmpFaladorWater: Integer;

begin
bmpFaladorWater := BitmapFromString(6, 6, 'z78DA33733677B' +
'174351B7624000B723409');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(bmpFaladorWater, TX, TY, MMCX-75, MMCY+20, MMCX-20, MMCY+30, C)) then
begin
Result := GetColor(TX,TY);
break;
end;
end;
FreeBitMap(bmpFaladorWater);
if(Result = 0)then
writeln('ERROR: Watercolor NOT Found');
end;

function FindRoadColor: Integer; // by WT-Fakawi

var C,TX,TY,FaladorRoad:integer;

begin
FaladorRoad := BitmapFromString(6, 6, 'z78DA3373363301' +
'C261470200DE652ED5');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(FaladorRoad, TX, TY, MMCX, MMCY-20, MMCX+30, MMCY+20, C))then
begin
Result := GetColor(TX,TY);
break;
end;
end;
if(Result = 0)then
writeln('ERROR: RoadColor NOT Found');
FreeBitMap(FaladorRoad);
end;

function FindMapOreColor: Integer;//Completely Copied from Stupid's GuildMiner
var
MapOre, MapOre2 : Integer;
begin
MapOre := BitmapFromString(3, 3,
'3D2C345948546D5D624A39416D5D626D5D625948546D5D626 D5D62' +
'');
MapOre2 := BitmapFromString(3, 3,
'061115222D35364243131E22364243364243222D353642433 64243' +
'');

if(FindBitmapsProgressiveTol(MapOre, MapOre2, 0, 0, 0, 65, 5, 587, 41, 705, 118))then
Result:=GetColor(x+1, y+1);
Freebitmap(MapOre);
Freebitmap(MapOre2);
end;


procedure FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
var
Count: Integer;
begin
Count:=0;
if(MapRock = 0)or(MapPick=0)then
begin
KlinkDebug('Finding colors at Mine please Wait...', False);
while(MapRock=0)or(MapPick=0)do
begin
Count:= Count + 1;
if(MapRock = 0)then // Checks to see if the colors have already been set.
MapRock:= FindMapOreColor;
if(MapPick = 0)then
MapPick:= GetSymbolColor('mining spot');
if(Count>20)then
CantFindColors;
end;
KlinkDebug('MMOre:' + IntToStr(MapRock)+ // Prints the colors found.
' MMPick:' + IntToStr(MapPick), False);
end;
end;

procedure FindColorsAtBank; // Searches for colors at bank
// (RoadColor, BankSymbol).

var
Count: Integer;
begin
Count:=0;
if(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)then
begin
KlinkDebug('Finding colors at bank please Wait...', False);
while(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)do
begin
Count:= Count + 1;
if(RoadCol = 0)then // Checks to see if the colors have already been set.
RoadCol := FindRoadColor;
if(BankIcon = 0)then
BankIcon := GetSymbolColor('bank');
if(WaterColor = 0)then
WaterColor := FindWaterColor;
if(Count>20)then
CantFindColors;
end;
KlinkDebug('RoadColor:'+IntToStr(RoadCol)+
' BankColor:'+ IntToStr(BankIcon) +
' WaterColor: ' + IntToStr(WaterColor), False);
end;
end;


{ *** Anti Randoms ***
*** Stuff for scheduler *** }

procedure RunAwayFromRandoms;
begin
SetRun(true);
RunAwayDirection(Run);
wait(15000 + random(5000));
RunBack;
end;

function InMine: Boolean;
begin
Result := False;
if(FindMMColor(MapPick))then
Result := True;
end;

procedure CheckFight; // Checks to see if you are in a fight. If it does, it
// will run away and back.
begin
if(FindFight)then
RunAwayFromRandoms;
end;

procedure CheckRandoms;
begin
FindNormalRandoms;
AntiBan;
CheckFight;
FindDoctor;
FindBox;
if(InMine)then
begin
if(not(FindPick))then // Checks to see if your pickhead flew off.
// It will try to find it, but if it doesn't, it
// will withdraw any spare picks at the bank.

gLostPick:= True;
if(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220))then
begin
if(Look4Gas)then
begin
if(FindGas(x,y))then
begin
Mouse(MMCX, MMCY, r, r, True)
Flag;
end;
end;
end;
end;
end;


{ *** Important Procedures *** }


{^^^^^^^^^^^^^^^^^ FINDROCK ^^^^^^^^^^^^^^^^^^^^^^^}
{ Copied and Modded from Squig }
{^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^}

//**************** Credits for TPoints go to Fakawi *********************//

function FindRock(RockType : Integer) : TPoint;
var
RockColor, Tol : Integer;
XY: TPoint;
begin
Tol := 5;
case(RockType)of
0 : RockColor:= 2240076;
1 : RockColor:= 4088199;
2 : RockColor:= 6184550;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end else
begin
case(RockType)of
0 : Rockcolor:= 593178;
1 : Rockcolor:= 10000804;
2 : RockColor:= 5212637;
end;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end;
gOreColor := RockColor;
end;


procedure Bank; // Will bank all your ores and withdraw a new pickaxe if needed.

begin
if(InBank)then
begin
KlinkDebug('Banking', False);
gOres:= gOres + CountItemBmpTol(Ore, 50); // Counts the amount of ores you
// mined.

OpenBank;
if(BankScreen)then
begin
if(gLostPick=True)then
Withdraw(1, 1, 1); // If you lost your pick, withdraw a new one.

if(EquipPick=True)then
Deposit(1, 28, 2)
else
Deposit(2, 28, 2);
end;
CloseWindow;
if(gLostPick=true)and(EquipPick=true)then // If you lost your pick,
// do the following.

begin
FindPickHeadColor; // Find colors of new pickhead colors if you lost one.

ClickItemColor(hc1, true); // If EquipPick is true, Equip it.

end;
gNumTrip:= gNumTrip + 1;
end;
end;


{>>---------------- Copied From Stupid's Powerminer ---------------------}
procedure Mine;
var
WaitMax: Integer;
InvC: Integer;


begin
InvC := InventoryCount;
SetRandomOreColor;
if(FindObj('Mine', OreColor, 5))then
begin
if(not(FindGas(x,y)))then
begin
Mouse(x, y, R, R, true);
KlinkDebug('Mining', True)
if(FlagPresent)then
begin
Flag;
Wait(500+Random(500));
end;
MarkTime(WaitMax);
begin
repeat
if(not(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220)))then
Break;
CheckRandoms;
Wait(500+Random(500));
until(not(GetColor(109,430)=0)and(not(GetColor(195 ,426)=0))or // checks 100% for the words
// "you have succesfully...".
(not(InvC = InventoryCount))or(TimeFromMark(WaitMax) >= MaxWait));
end;
end;
end;
end;

{ *** Mapwalking *** }


procedure ToRocks;
begin
KlinkDebug('Going to rocks.', False);
if(RockType = 0)then
begin
RadialWalk(MapRock, 225, 315, 48, +1, 0);
end;
if(RockType = 1)then
begin
RadialWalk(MapRock, 60, 135, 48, -1, 0);
end;
if(RockType = 2)then
begin
RadialWalk(MapRock, 405, 330, 48, 0, 1);
end;
FindOreColors(OreCol, OreTol1, OreTol2);
end;



procedure ToMines; // Walks To rimmington mines.
var
C: Integer;
CX, CY: Integer;
begin
CheckRandoms;
C := 0;
if(FindMMColor(BankIcon))then
begin
RadialWalk(RoadCol, 150, 220, 35, -1, -1);
C := C + 1;
repeat
if(C < 5)then
RadialWalk(RoadCol, 150, 220, 53, -1, -1)
else
RadialWalk(RoadCol, 150, 220, 40, -1, -1)
C := C+1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] Towards Water - Bisect in Road', False)
until(FindMMColor(WaterColor))and(C > 4);
KlinkDebug ('At Water - Water Found.', False)
RadialWalk(RoadCol, 150, 220, 35, -1, -1)
C := 0;
repeat
RadialWalk(RoadCol, 230, 310, 45, 1, 0)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] West', False);
until(FindColor(CX, CY, RoadCol, MMCX - 75, MMCY + 25, MMCX , MMCY + 25))
and(C > 1)or(C>4);
KlinkDebug('SouthWest Turn Found', False);
RadialWalk(RoadCol, 180, 250, 55, 1, -1);
C := 0;
repeat
Mouse(646, 151, r, r, true);
Flag;
C := C+1
until(C >= 1);
KlinkDebug('At entrance to mine.', False)
end;
while(not(FindSymbol('mining spot')))do
begin
Mouse(646, 135, r, r, True);
Flag;
end;
FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
if(FindMMColor(MapPick))then
begin
Mouse(x, y, r, r, true);
Flag;
end;
end;

procedure ToBank; // Walks To Bank.

var
CX, CY : Integer;
Walks, C: Integer;
begin
Walks := 0;
C := 0;
if(FindMMColor(MapPick))then
begin
KlinkDebug('Walking to Bank', True);
KlinkDebug('Heading out of mines.', False);
MouseFindFlag(x, y - 35, 0, +1); // Clicks 35 coordinates away from the
// MM Pick symbol on the Y axis.
Flag;
end;
repeat
RadialWalk(RoadCol, 420, 325, 55, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps NorthEast', False);
until(FindColor(CX, CY, RoadCol, MMCX + 15, MMCY - 10, MMCX + 70, MMCY + 35))
and(C >= 1);
C := 0;
repeat
RadialWalk(RoadCol, 135, 45, 50, 0, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps East', False);
until(FindMMColor(WaterColor))or(C >= 3);
KlinkDebug('Reached water - heading North', False);
C := 0;
repeat
if(FindMMColor(WaterColor))and(C > 2)then
begin
RadialWalk(RoadCol, 440, 315, 40, -1, -1)
C := C + 1
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end else
begin
RadialWalk(RoadCol, 405, 315, 50, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end;
until(FindMMColor(BankIcon));
RadialWalk(RoadCol, 405, 315, 35, -1, -1);
KlinkDebug('Reached bank - Heading into bank.', False);
ToBankCounter; // Positions you near the bank booths and counters.
end;

//******************************* Forms ********************************// }



procedure MyShowFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('MyInitForm', v);
setarraylength(V, 0);
ThreadSafeCall('MyShowFormModal', v);
end;

procedure StartScript(sender: TObject);
begin
if((not(MyUser.text = ''))and(UsersLoaded))or((not(MyPass.text = ''))and(UsersLoaded))then
begin
Username := MyUser.text;
PassWord := MyPass.text;
end;
EquipPick := CheckBox1.state;
case(MyRockType.Text)of
'Iron': RockType := 0;
'Tin': RockType := 1;
'Copper': RockType := 2;
end;
frmDesign.Caption:= frmDesign.Caption + '.';
ScriptStarted:= True;
frmDesign.ModalResult:= mrOk;
end;

procedure MyInitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 367;
frmDesign.Top := 209;
frmDesign.Width := 203;
frmDesign.Height := 241;
frmDesign.Caption := 'IronMiner/Banker';
frmDesign.Color := clWhite;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.Left := 68;
Label1.Top := 15;
Label1.Width := 48;
Label1.Height := 13;
Label1.Caption := 'Username';
Label2 := TLabel.Create(frmDesign);
Label2.Parent := frmDesign;
Label2.Left := 70;
Label2.Top := 57;
Label2.Width := 46;
Label2.Height := 13;
Label2.Caption := 'Password';
MyUser := TEdit.Create(frmDesign);
MyUser.Parent := frmDesign;
MyUser.Left := 36;
MyUser.Top := 33;
MyUser.Width := 121;
MyUser.Height := 21;
MyUser.Hint := 'Type your username here.';
MyUser.TabOrder := 1;
MyUser.Text := '';
if(not(User = ''))then
MyUser.Text := User;
MyPass := TEdit.Create(frmDesign);
MyPass.Parent := frmDesign;
MyPass.Left := 36;
MyPass.Top := 72;
MyPass.Width := 121;
MyPass.Height := 21;
MyPass.Hint := 'Type your password here';
MyPass.PasswordChar := '*';
MyPass.TabOrder := 2;
MyPass.Text := '';
if(not(Pass = ''))then
MyPass.Text := Pass;
Button1 := TButton.Create(frmDesign);
Button1.OnClick:= @StartScript;
Button1.Parent := frmDesign;
Button1.Left := 58;
Button1.Top := 173;
Button1.Width := 75;
Button1.Height := 25;
Button1.Caption := 'Start';
Button1.TabOrder := 5;
CheckBox1 := TCheckBox.Create(frmDesign);
CheckBox1.Parent := frmDesign;
CheckBox1.Left := 58;
CheckBox1.Top := 105;
CheckBox1.Width := 77;
CheckBox1.Height := 17;
CheckBox1.Hint := 'Is your pickaxe equipped?';
CheckBox1.Caption := 'EquipPick?';
CheckBox1.TabOrder := 3;
if(EquipPick)then
CheckBox1.State := True;
MyRockType := TComboBox.Create(frmDesign);
MyRockType.Parent := frmDesign;
MyRockType.Left := 25;
MyRockType.Top := 139;
MyRockType.Width := 145;
MyRockType.Height := 21;
MyRockType.Hint := 'Which rock are you going to mine?';
MyRockType.ItemHeight := 13;
MyRockType.TabOrder := 4;
MyRockType.Text := 'RockType';
MyRockType.Items.Add('Iron');
MyRockType.Items.Add('Tin');
MyRockType.Items.Add('Copper');
case(RockType)of
0: MyRockType.Text := 'Iron';
1: MyRockType.Text := 'Tin';
2: MyRockType.Text := 'Copper';
end;
end;

procedure SetupForm;
begin
if(UseForm)then
begin
SafeShowForm;
if(ScriptStarted = False)then
TerminateScript;
ActivateClient;
end;
end;

//******************************* Main *********************************//

begin
SetupSSI;
Setup;
SetVariables;
SetupForm;
PrepClient;
GetOreType;
FindPickHeadColor;
LoadMemory;
FindColorsAtBank;
RColor:= RoadCol;
gCounter:=0;
repeat
SetRun(True);
ToMines; // Go To Mines
ToRocks; // Go to the rocks in the mine.

Wait(1000 + Random(500));
SetRun(False);
Wait(500 + random(1000))
MarkTime(Mark);
repeat
CheckRandoms;
Mine;
until(InventoryFull)or(gLostPick = True)or(TimeFromMark(Mark)>1200000)

ToBank; // Go to the East Fallidor bank.

Bank; // Bank your ores and get a new pick if needed.

ProgressReport; // Progress Report. Info on what happened. Please post
// them on the thread for this script.

gCounter := gCounter + 1;
until(False);
end.


:sasmokin: plz? :cartman:

Rune Hacker
04-21-2007, 08:40 PM
Please either put it in scar and tags and/or add it as an attachment in the advanced options menu at the bottom. Then i will go through it.

me_ntal
04-21-2007, 11:05 PM
Um helps to use more upto date resources, that script is acient

1-DUB
04-22-2007, 12:30 AM
ill do it for him...

program RimmingtonIronMinerAndBanker;

{.include SSI2.txt}
{.include KSI2.txt}
{.include BoxBreaker.txt}

const
{ *** Setup *** }

User = ''; // Username here.

Pass = ''; // Password here.

Run = 'N'; // What direction do u want to run when attacked.
// Change if you want.

UsePick = True; // Where do u want to keep pick. True = Equip tab.
// False = 1st slot in inv.

MaxWait = 6500; // Maximum time to wait when Mining A Rock.
// In MilliSeconds.

TypeOfRock = 0; // What Rock do you want to mine. 0 = Iron, 1 = Tin,
// 2 = Copper

UseForm = True; // True if you want to use forms.

Look4Gas = True; // True if you want to look for gas.

{ LOOK DOWN BELOW FOR MORE SETUP OPTIONS! }


{ *** Color Setup *** }
{ You can leave colors at 0 to let the script find. However,
Note: The RoadColor find works all the time now. Thanks to
SDouble. }

RoadColor = 0; // Color Of Road. On MiniMap.
BankSymbol = 0 ; // Color Of The Bank Symbol. On MiniMap.
Water = 0; // Color of Water. On Minimap.
MMPick = 0; // Color Of the pick symbol in mines. On MiniMap.
MMRock = 0; // Color Of Grey Rocks in the mine. On MiniMap.

//<<********************** Ore Colors ***************************>>

RockColor1= 0; //Colors of rocks in main screen.
RockColor2= 0;
RockColor3= 0;

//////////////////////////////////////////////////////
// Do Not Change the Following //
//////////////////////////////////////////////////////
const

Version = 1.18;

var
gOreColor, gCounter : Integer;
gNumtrip, gOres : Integer;
OreCol, OreTol1, OreTol2: Integer;
gXP, gOreXP: Extended;
UsersLoaded, EquipPick: Boolean;
RockType: Integer;
gLostPick : Boolean;
Mark: Integer;
report, report2 : Integer;
MapPick, BankIcon, MapRock, RoadCol, WaterColor : Integer;
ScriptStarted: Boolean;

frmDesign : TForm;
Label1 : TLabel;
Label2 : TLabel;
MyUser : TEdit;
MyPass : TEdit;
Button1 : TButton;
CheckBox1 : TCheckBox;
MyRockType : TComboBox;


{ *** MORE SETUP STUFF HERE *** }

procedure Setup;
begin
if(not(User = ''))or(not(Pass = ''))then
begin
UsersLoaded := True;
Username := User; //Username.
Password := Pass; //Password.
end;
end;

//>>------------ Copied From Stupid3ooo's Powerminer -------------<<

procedure GetOreType;
begin
if(RockType = 0)then//0-Iron
begin
OreCol := 2898528;
OreTol1 := 5;
OreTol2 := 25;
gOreXP := 35;
end;
if(RockType = 1)then//1-Tin
begin
OreCol := 10198184;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
if(RockType = 2)then//2-Copper
begin
OreCol := 7512298;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
end;




{ *** Progress Report *** }

procedure ProgressReport; // A Stupid3ooo procedure modified by Kernel Klink.
var
AverageTime:longint;
RHours, Minutes, Seconds, RMinutes, RSeconds:LongInt;
Time:String;
begin
if(GetSystemTime-report2 > report*60000)then
begin
Seconds:=(GetSystemTime-ST) div 1000;
Minutes:=Seconds div 60;
AverageTime:= Seconds/gNumTrip;
gXP := gOres*gOreXP;
RHours:=Minutes div 60;
Time:=IntToStr(Seconds)+' Seconds';
if Minutes<>0 then
begin
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(Minutes)+' Minutes and '+IntToStr(RSeconds)+' Seconds';
end;
if RHours<>0 then
begin
RMinutes:=Minutes Mod (RHours*60);
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(RHours)+' Hours, '+IntToStr(RMinutes)+' Minutes and '
+IntToStr(RSeconds)+' Seconds';
end;
begin
ClearReport;
ChangeReportWidth(500);
AddToReport('-----------Progress Report--------------');
AddToReport('------------Version ' + (FloatToStr(Version)) + ' --------------');
AddToReport('Worked For ' + Time);
AddToReport('Made ' + (IntToStr(gNumtrip)) + ' Trips');
AddToReport('Banked ' + (IntToStr(gOres)) + ' Ores');
AddToReport('Gained ' + (FloatToStr(gXP)) + ' XP');
AddToReport('Currently Averaging At '+ (IntToStr(3600/AverageTime*(gOres/gNumtrip)))+
' ores and '+(FloatToStr(3600/AverageTime*(35*(gOres/gNumtrip))))+ ' xp an hour.');
AddToReport('Random Event Report:');
if(fights>0)then AddToReport(' Avoided '+IntToStr(Fights)+' Fight[s].');
if(Doctors>0)then AddToReport(' Completed '+IntToStr(Doctors)+' Doctor[s].');
if(talks>0)then AddToReport(' Talked to '+IntToStr(Talks)+' Random event[s].');
if(lamps>0)then AddToReport(' Used lamps '+IntToStr(Lamps)+' time[s].');
if(boxes>0)then AddToReport(' Solved '+IntToStr(boxes)+' box[es].');
if(logs>0)then AddToReport(' Logged in '+IntToStr(Logs)+' time[s].');
AddToReport('<==================================== ==>');
end;
end;
end;


{ *** Misc Procedures *** }

procedure SetVariables;
begin
MapPick := MMPick;
BankIcon := BankSymbol;
MapRock := MMRock;
EquipPick := UsePick;
RockType := TypeOfRock;
RoadCol := RoadColor;
WaterColor := Water;
OreColor1:= RockColor1;
OreColor2:= RockColor2;
OreColor3:= RockColor3;
end;

procedure ResetColors;
begin
OreColor1:= 0;
OreColor2:= 0;
OreColor3:= 0;
end;

procedure CantFindColors;
begin
KlinkDebug('Sorry, the colors could not be found. Please Start The Script over' +
' or set the colors yourself.', False);
LogOut;
TerminateScript;
end;

procedure LoadMemory; // Loads Bitmaps And DTM's.

begin
end;



function InBank: Boolean;
begin
if(FindColorSpiral(x, y, BankIcon, M1, M2, M3, M4))then
Result:= True;
end;



procedure ToBankCounter; // A Stupid3ooo Procedure Modified by Kernel Klink

var
c, ax, ay: Integer;
begin
while c<30 do
begin
c:=c+5;
if(FindMMColor(BankIcon))then
begin
if(FindColorSpiralTolerance(ax, ay, 195836, x-c, y-c, x+c, y+c, 10))then
begin
x:=ax;
y:=ay;
MouseFindFlag(x, y-3, 0, -2);
FlagAtColor(BankIcon);
Wait(1000+Random(100));
Break;
end;
end;
end;
end;
{ *** ColorFinding Procedures *** }

procedure GetOreColors;
var
Count: Integer;
begin
if(OreColor1 = 0)or(OreColor2 = 0)or(OreColor3 = 0)then
begin
Count:= 0;
repeat
if(FindOreColors(2305871, 8, 16))then
break;
Count:= Count + 1
if (Count > 49) then
CantFindColors;
until(Count > 49);
end;
end;

Function FindWaterColor : Integer; // From Fakawi. Thanks.
var
C,TX,TY,
bmpFaladorWater: Integer;

begin
bmpFaladorWater := BitmapFromString(6, 6, 'z78DA33733677B' +
'174351B7624000B723409');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(bmpFaladorWater, TX, TY, MMCX-75, MMCY+20, MMCX-20, MMCY+30, C)) then
begin
Result := GetColor(TX,TY);
break;
end;
end;
FreeBitMap(bmpFaladorWater);
if(Result = 0)then
writeln('ERROR: Watercolor NOT Found');
end;

function FindRoadColor: Integer; // by WT-Fakawi

var C,TX,TY,FaladorRoad:integer;

begin
FaladorRoad := BitmapFromString(6, 6, 'z78DA3373363301' +
'C261470200DE652ED5');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(FaladorRoad, TX, TY, MMCX, MMCY-20, MMCX+30, MMCY+20, C))then
begin
Result := GetColor(TX,TY);
break;
end;
end;
if(Result = 0)then
writeln('ERROR: RoadColor NOT Found');
FreeBitMap(FaladorRoad);
end;

function FindMapOreColor: Integer;//Completely Copied from Stupid's GuildMiner
var
MapOre, MapOre2 : Integer;
begin
MapOre := BitmapFromString(3, 3,
'3D2C345948546D5D624A39416D5D626D5D625948546D5D626 D5D62' +
'');
MapOre2 := BitmapFromString(3, 3,
'061115222D35364243131E22364243364243222D353642433 64243' +
'');

if(FindBitmapsProgressiveTol(MapOre, MapOre2, 0, 0, 0, 65, 5, 587, 41, 705, 118))then
Result:=GetColor(x+1, y+1);
Freebitmap(MapOre);
Freebitmap(MapOre2);
end;


procedure FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
var
Count: Integer;
begin
Count:=0;
if(MapRock = 0)or(MapPick=0)then
begin
KlinkDebug('Finding colors at Mine please Wait...', False);
while(MapRock=0)or(MapPick=0)do
begin
Count:= Count + 1;
if(MapRock = 0)then // Checks to see if the colors have already been set.
MapRock:= FindMapOreColor;
if(MapPick = 0)then
MapPick:= GetSymbolColor('mining spot');
if(Count>20)then
CantFindColors;
end;
KlinkDebug('MMOre:' + IntToStr(MapRock)+ // Prints the colors found.
' MMPick:' + IntToStr(MapPick), False);
end;
end;

procedure FindColorsAtBank; // Searches for colors at bank
// (RoadColor, BankSymbol).

var
Count: Integer;
begin
Count:=0;
if(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)then
begin
KlinkDebug('Finding colors at bank please Wait...', False);
while(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)do
begin
Count:= Count + 1;
if(RoadCol = 0)then // Checks to see if the colors have already been set.
RoadCol := FindRoadColor;
if(BankIcon = 0)then
BankIcon := GetSymbolColor('bank');
if(WaterColor = 0)then
WaterColor := FindWaterColor;
if(Count>20)then
CantFindColors;
end;
KlinkDebug('RoadColor:'+IntToStr(RoadCol)+
' BankColor:'+ IntToStr(BankIcon) +
' WaterColor: ' + IntToStr(WaterColor), False);
end;
end;


{ *** Anti Randoms ***
*** Stuff for scheduler *** }

procedure RunAwayFromRandoms;
begin
SetRun(true);
RunAwayDirection(Run);
wait(15000 + random(5000));
RunBack;
end;

function InMine: Boolean;
begin
Result := False;
if(FindMMColor(MapPick))then
Result := True;
end;

procedure CheckFight; // Checks to see if you are in a fight. If it does, it
// will run away and back.
begin
if(FindFight)then
RunAwayFromRandoms;
end;

procedure CheckRandoms;
begin
FindNormalRandoms;
AntiBan;
CheckFight;
FindDoctor;
FindBox;
if(InMine)then
begin
if(not(FindPick))then // Checks to see if your pickhead flew off.
// It will try to find it, but if it doesn't, it
// will withdraw any spare picks at the bank.

gLostPick:= True;
if(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220))then
begin
if(Look4Gas)then
begin
if(FindGas(x,y))then
begin
Mouse(MMCX, MMCY, r, r, True)
Flag;
end;
end;
end;
end;
end;


{ *** Important Procedures *** }


{^^^^^^^^^^^^^^^^^ FINDROCK ^^^^^^^^^^^^^^^^^^^^^^^}
{ Copied and Modded from Squig }
{^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^}

//**************** Credits for TPoints go to Fakawi *********************//

function FindRock(RockType : Integer) : TPoint;
var
RockColor, Tol : Integer;
XY: TPoint;
begin
Tol := 5;
case(RockType)of
0 : RockColor:= 2240076;
1 : RockColor:= 4088199;
2 : RockColor:= 6184550;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end else
begin
case(RockType)of
0 : Rockcolor:= 593178;
1 : Rockcolor:= 10000804;
2 : RockColor:= 5212637;
end;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end;
gOreColor := RockColor;
end;


procedure Bank; // Will bank all your ores and withdraw a new pickaxe if needed.

begin
if(InBank)then
begin
KlinkDebug('Banking', False);
gOres:= gOres + CountItemBmpTol(Ore, 50); // Counts the amount of ores you
// mined.

OpenBank;
if(BankScreen)then
begin
if(gLostPick=True)then
Withdraw(1, 1, 1); // If you lost your pick, withdraw a new one.

if(EquipPick=True)then
Deposit(1, 28, 2)
else
Deposit(2, 28, 2);
end;
CloseWindow;
if(gLostPick=true)and(EquipPick=true)then // If you lost your pick,
// do the following.

begin
FindPickHeadColor; // Find colors of new pickhead colors if you lost one.

ClickItemColor(hc1, true); // If EquipPick is true, Equip it.

end;
gNumTrip:= gNumTrip + 1;
end;
end;


{>>---------------- Copied From Stupid's Powerminer ---------------------}
procedure Mine;
var
WaitMax: Integer;
InvC: Integer;


begin
InvC := InventoryCount;
SetRandomOreColor;
if(FindObj('Mine', OreColor, 5))then
begin
if(not(FindGas(x,y)))then
begin
Mouse(x, y, R, R, true);
KlinkDebug('Mining', True)
if(FlagPresent)then
begin
Flag;
Wait(500+Random(500));
end;
MarkTime(WaitMax);
begin
repeat
if(not(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220)))then
Break;
CheckRandoms;
Wait(500+Random(500));
until(not(GetColor(109,430)=0)and(not(GetColor(195 ,426)=0))or // checks 100% for the words
// "you have succesfully...".
(not(InvC = InventoryCount))or(TimeFromMark(WaitMax) >= MaxWait));
end;
end;
end;
end;

{ *** Mapwalking *** }


procedure ToRocks;
begin
KlinkDebug('Going to rocks.', False);
if(RockType = 0)then
begin
RadialWalk(MapRock, 225, 315, 48, +1, 0);
end;
if(RockType = 1)then
begin
RadialWalk(MapRock, 60, 135, 48, -1, 0);
end;
if(RockType = 2)then
begin
RadialWalk(MapRock, 405, 330, 48, 0, 1);
end;
FindOreColors(OreCol, OreTol1, OreTol2);
end;



procedure ToMines; // Walks To rimmington mines.
var
C: Integer;
CX, CY: Integer;
begin
CheckRandoms;
C := 0;
if(FindMMColor(BankIcon))then
begin
RadialWalk(RoadCol, 150, 220, 35, -1, -1);
C := C + 1;
repeat
if(C < 5)then
RadialWalk(RoadCol, 150, 220, 53, -1, -1)
else
RadialWalk(RoadCol, 150, 220, 40, -1, -1)
C := C+1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] Towards Water - Bisect in Road', False)
until(FindMMColor(WaterColor))and(C > 4);
KlinkDebug ('At Water - Water Found.', False)
RadialWalk(RoadCol, 150, 220, 35, -1, -1)
C := 0;
repeat
RadialWalk(RoadCol, 230, 310, 45, 1, 0)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] West', False);
until(FindColor(CX, CY, RoadCol, MMCX - 75, MMCY + 25, MMCX , MMCY + 25))
and(C > 1)or(C>4);
KlinkDebug('SouthWest Turn Found', False);
RadialWalk(RoadCol, 180, 250, 55, 1, -1);
C := 0;
repeat
Mouse(646, 151, r, r, true);
Flag;
C := C+1
until(C >= 1);
KlinkDebug('At entrance to mine.', False)
end;
while(not(FindSymbol('mining spot')))do
begin
Mouse(646, 135, r, r, True);
Flag;
end;
FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
if(FindMMColor(MapPick))then
begin
Mouse(x, y, r, r, true);
Flag;
end;
end;

procedure ToBank; // Walks To Bank.

var
CX, CY : Integer;
Walks, C: Integer;
begin
Walks := 0;
C := 0;
if(FindMMColor(MapPick))then
begin
KlinkDebug('Walking to Bank', True);
KlinkDebug('Heading out of mines.', False);
MouseFindFlag(x, y - 35, 0, +1); // Clicks 35 coordinates away from the
// MM Pick symbol on the Y axis.
Flag;
end;
repeat
RadialWalk(RoadCol, 420, 325, 55, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps NorthEast', False);
until(FindColor(CX, CY, RoadCol, MMCX + 15, MMCY - 10, MMCX + 70, MMCY + 35))
and(C >= 1);
C := 0;
repeat
RadialWalk(RoadCol, 135, 45, 50, 0, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps East', False);
until(FindMMColor(WaterColor))or(C >= 3);
KlinkDebug('Reached water - heading North', False);
C := 0;
repeat
if(FindMMColor(WaterColor))and(C > 2)then
begin
RadialWalk(RoadCol, 440, 315, 40, -1, -1)
C := C + 1
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end else
begin
RadialWalk(RoadCol, 405, 315, 50, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end;
until(FindMMColor(BankIcon));
RadialWalk(RoadCol, 405, 315, 35, -1, -1);
KlinkDebug('Reached bank - Heading into bank.', False);
ToBankCounter; // Positions you near the bank booths and counters.
end;

//******************************* Forms ********************************// }



procedure MyShowFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('MyInitForm', v);
setarraylength(V, 0);
ThreadSafeCall('MyShowFormModal', v);
end;

procedure StartScript(sender: TObject);
begin
if((not(MyUser.text = ''))and(UsersLoaded))or((not(MyPass.text = ''))and(UsersLoaded))then
begin
Username := MyUser.text;
PassWord := MyPass.text;
end;
EquipPick := CheckBox1.state;
case(MyRockType.Text)of
'Iron': RockType := 0;
'Tin': RockType := 1;
'Copper': RockType := 2;
end;
frmDesign.Caption:= frmDesign.Caption + '.';
ScriptStarted:= True;
frmDesign.ModalResult:= mrOk;
end;

procedure MyInitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 367;
frmDesign.Top := 209;
frmDesign.Width := 203;
frmDesign.Height := 241;
frmDesign.Caption := 'IronMiner/Banker';
frmDesign.Color := clWhite;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.Left := 68;
Label1.Top := 15;
Label1.Width := 48;
Label1.Height := 13;
Label1.Caption := 'Username';
Label2 := TLabel.Create(frmDesign);
Label2.Parent := frmDesign;
Label2.Left := 70;
Label2.Top := 57;
Label2.Width := 46;
Label2.Height := 13;
Label2.Caption := 'Password';
MyUser := TEdit.Create(frmDesign);
MyUser.Parent := frmDesign;
MyUser.Left := 36;
MyUser.Top := 33;
MyUser.Width := 121;
MyUser.Height := 21;
MyUser.Hint := 'Type your username here.';
MyUser.TabOrder := 1;
MyUser.Text := '';
if(not(User = ''))then
MyUser.Text := User;
MyPass := TEdit.Create(frmDesign);
MyPass.Parent := frmDesign;
MyPass.Left := 36;
MyPass.Top := 72;
MyPass.Width := 121;
MyPass.Height := 21;
MyPass.Hint := 'Type your password here';
MyPass.PasswordChar := '*';
MyPass.TabOrder := 2;
MyPass.Text := '';
if(not(Pass = ''))then
MyPass.Text := Pass;
Button1 := TButton.Create(frmDesign);
Button1.OnClick:= @StartScript;
Button1.Parent := frmDesign;
Button1.Left := 58;
Button1.Top := 173;
Button1.Width := 75;
Button1.Height := 25;
Button1.Caption := 'Start';
Button1.TabOrder := 5;
CheckBox1 := TCheckBox.Create(frmDesign);
CheckBox1.Parent := frmDesign;
CheckBox1.Left := 58;
CheckBox1.Top := 105;
CheckBox1.Width := 77;
CheckBox1.Height := 17;
CheckBox1.Hint := 'Is your pickaxe equipped?';
CheckBox1.Caption := 'EquipPick?';
CheckBox1.TabOrder := 3;
if(EquipPick)then
CheckBox1.State := True;
MyRockType := TComboBox.Create(frmDesign);
MyRockType.Parent := frmDesign;
MyRockType.Left := 25;
MyRockType.Top := 139;
MyRockType.Width := 145;
MyRockType.Height := 21;
MyRockType.Hint := 'Which rock are you going to mine?';
MyRockType.ItemHeight := 13;
MyRockType.TabOrder := 4;
MyRockType.Text := 'RockType';
MyRockType.Items.Add('Iron');
MyRockType.Items.Add('Tin');
MyRockType.Items.Add('Copper');
case(RockType)of
0: MyRockType.Text := 'Iron';
1: MyRockType.Text := 'Tin';
2: MyRockType.Text := 'Copper';
end;
end;

procedure SetupForm;
begin
if(UseForm)then
begin
SafeShowForm;
if(ScriptStarted = False)then
TerminateScript;
ActivateClient;
end;
end;

//******************************* Main *********************************//

begin
SetupSSI;
Setup;
SetVariables;
SetupForm;
PrepClient;
GetOreType;
FindPickHeadColor;
LoadMemory;
FindColorsAtBank;
RColor:= RoadCol;
gCounter:=0;
repeat
SetRun(True);
ToMines; // Go To Mines
ToRocks; // Go to the rocks in the mine.

Wait(1000 + Random(500));
SetRun(False);
Wait(500 + random(1000))
MarkTime(Mark);
repeat
CheckRandoms;
Mine;
until(InventoryFull)or(gLostPick = True)or(TimeFromMark(Mark)>1200000)

ToBank; // Go to the East Fallidor bank.

Bank; // Bank your ores and get a new pick if needed.

ProgressReport; // Progress Report. Info on what happened. Please post
// them on the thread for this script.

gCounter := gCounter + 1;
until(False);
end.





program RimmingtonIronMinerAndBanker;

{.include SSI2.txt}
{.include KSI2.txt}
{.include BoxBreaker.txt}

const
{ *** Setup *** }

User = ''; // Username here.

Pass = ''; // Password here.

Run = 'N'; // What direction do u want to run when attacked.
// Change if you want.

UsePick = True; // Where do u want to keep pick. True = Equip tab.
// False = 1st slot in inv.

MaxWait = 6500; // Maximum time to wait when Mining A Rock.
// In MilliSeconds.

TypeOfRock = 0; // What Rock do you want to mine. 0 = Iron, 1 = Tin,
// 2 = Copper

UseForm = True; // True if you want to use forms.

Look4Gas = True; // True if you want to look for gas.

{ LOOK DOWN BELOW FOR MORE SETUP OPTIONS! }


{ *** Color Setup *** }
{ You can leave colors at 0 to let the script find. However,
Note: The RoadColor find works all the time now. Thanks to
SDouble. }

RoadColor = 0; // Color Of Road. On MiniMap.
BankSymbol = 0 ; // Color Of The Bank Symbol. On MiniMap.
Water = 0; // Color of Water. On Minimap.
MMPick = 0; // Color Of the pick symbol in mines. On MiniMap.
MMRock = 0; // Color Of Grey Rocks in the mine. On MiniMap.

//<<********************** Ore Colors ***************************>>

RockColor1= 0; //Colors of rocks in main screen.
RockColor2= 0;
RockColor3= 0;

//////////////////////////////////////////////////////
// Do Not Change the Following //
//////////////////////////////////////////////////////
const

Version = 1.18;

var
gOreColor, gCounter : Integer;
gNumtrip, gOres : Integer;
OreCol, OreTol1, OreTol2: Integer;
gXP, gOreXP: Extended;
UsersLoaded, EquipPick: Boolean;
RockType: Integer;
gLostPick : Boolean;
Mark: Integer;
report, report2 : Integer;
MapPick, BankIcon, MapRock, RoadCol, WaterColor : Integer;
ScriptStarted: Boolean;

frmDesign : TForm;
Label1 : TLabel;
Label2 : TLabel;
MyUser : TEdit;
MyPass : TEdit;
Button1 : TButton;
CheckBox1 : TCheckBox;
MyRockType : TComboBox;


{ *** MORE SETUP STUFF HERE *** }

procedure Setup;
begin
if(not(User = ''))or(not(Pass = ''))then
begin
UsersLoaded := True;
Username := User; //Username.
Password := Pass; //Password.
end;
end;

//>>------------ Copied From Stupid3ooo's Powerminer -------------<<

procedure GetOreType;
begin
if(RockType = 0)then//0-Iron
begin
OreCol := 2898528;
OreTol1 := 5;
OreTol2 := 25;
gOreXP := 35;
end;
if(RockType = 1)then//1-Tin
begin
OreCol := 10198184;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
if(RockType = 2)then//2-Copper
begin
OreCol := 7512298;
OreTol1 := 15;
OreTol2 := 35;
gOreXP := 17.5;
end;
end;




{ *** Progress Report *** }

procedure ProgressReport; // A Stupid3ooo procedure modified by Kernel Klink.
var
AverageTime:longint;
RHours, Minutes, Seconds, RMinutes, RSeconds:LongInt;
Time:String;
begin
if(GetSystemTime-report2 > report*60000)then
begin
Seconds:=(GetSystemTime-ST) div 1000;
Minutes:=Seconds div 60;
AverageTime:= Seconds/gNumTrip;
gXP := gOres*gOreXP;
RHours:=Minutes div 60;
Time:=IntToStr(Seconds)+' Seconds';
if Minutes<>0 then
begin
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(Minutes)+' Minutes and '+IntToStr(RSeconds)+' Seconds';
end;
if RHours<>0 then
begin
RMinutes:=Minutes Mod (RHours*60);
RSeconds:=Seconds Mod (Minutes*60);
Time:=IntToStr(RHours)+' Hours, '+IntToStr(RMinutes)+' Minutes and '
+IntToStr(RSeconds)+' Seconds';
end;
begin
ClearReport;
ChangeReportWidth(500);
AddToReport('-----------Progress Report--------------');
AddToReport('------------Version ' + (FloatToStr(Version)) + ' --------------');
AddToReport('Worked For ' + Time);
AddToReport('Made ' + (IntToStr(gNumtrip)) + ' Trips');
AddToReport('Banked ' + (IntToStr(gOres)) + ' Ores');
AddToReport('Gained ' + (FloatToStr(gXP)) + ' XP');
AddToReport('Currently Averaging At '+ (IntToStr(3600/AverageTime*(gOres/gNumtrip)))+
' ores and '+(FloatToStr(3600/AverageTime*(35*(gOres/gNumtrip))))+ ' xp an hour.');
AddToReport('Random Event Report:');
if(fights>0)then AddToReport(' Avoided '+IntToStr(Fights)+' Fight[s].');
if(Doctors>0)then AddToReport(' Completed '+IntToStr(Doctors)+' Doctor[s].');
if(talks>0)then AddToReport(' Talked to '+IntToStr(Talks)+' Random event[s].');
if(lamps>0)then AddToReport(' Used lamps '+IntToStr(Lamps)+' time[s].');
if(boxes>0)then AddToReport(' Solved '+IntToStr(boxes)+' box[es].');
if(logs>0)then AddToReport(' Logged in '+IntToStr(Logs)+' time[s].');
AddToReport('<==================================== ==>');
end;
end;
end;


{ *** Misc Procedures *** }

procedure SetVariables;
begin
MapPick := MMPick;
BankIcon := BankSymbol;
MapRock := MMRock;
EquipPick := UsePick;
RockType := TypeOfRock;
RoadCol := RoadColor;
WaterColor := Water;
OreColor1:= RockColor1;
OreColor2:= RockColor2;
OreColor3:= RockColor3;
end;

procedure ResetColors;
begin
OreColor1:= 0;
OreColor2:= 0;
OreColor3:= 0;
end;

procedure CantFindColors;
begin
KlinkDebug('Sorry, the colors could not be found. Please Start The Script over' +
' or set the colors yourself.', False);
LogOut;
TerminateScript;
end;

procedure LoadMemory; // Loads Bitmaps And DTM's.

begin
end;



function InBank: Boolean;
begin
if(FindColorSpiral(x, y, BankIcon, M1, M2, M3, M4))then
Result:= True;
end;



procedure ToBankCounter; // A Stupid3ooo Procedure Modified by Kernel Klink

var
c, ax, ay: Integer;
begin
while c<30 do
begin
c:=c+5;
if(FindMMColor(BankIcon))then
begin
if(FindColorSpiralTolerance(ax, ay, 195836, x-c, y-c, x+c, y+c, 10))then
begin
x:=ax;
y:=ay;
MouseFindFlag(x, y-3, 0, -2);
FlagAtColor(BankIcon);
Wait(1000+Random(100));
Break;
end;
end;
end;
end;
{ *** ColorFinding Procedures *** }

procedure GetOreColors;
var
Count: Integer;
begin
if(OreColor1 = 0)or(OreColor2 = 0)or(OreColor3 = 0)then
begin
Count:= 0;
repeat
if(FindOreColors(2305871, 8, 16))then
break;
Count:= Count + 1
if (Count > 49) then
CantFindColors;
until(Count > 49);
end;
end;

Function FindWaterColor : Integer; // From Fakawi. Thanks.
var
C,TX,TY,
bmpFaladorWater: Integer;

begin
bmpFaladorWater := BitmapFromString(6, 6, 'z78DA33733677B' +
'174351B7624000B723409');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(bmpFaladorWater, TX, TY, MMCX-75, MMCY+20, MMCX-20, MMCY+30, C)) then
begin
Result := GetColor(TX,TY);
break;
end;
end;
FreeBitMap(bmpFaladorWater);
if(Result = 0)then
writeln('ERROR: Watercolor NOT Found');
end;

function FindRoadColor: Integer; // by WT-Fakawi

var C,TX,TY,FaladorRoad:integer;

begin
FaladorRoad := BitmapFromString(6, 6, 'z78DA3373363301' +
'C261470200DE652ED5');
while (C<65) do
begin
C:=C+5;
if(FindBitMapToleranceIn(FaladorRoad, TX, TY, MMCX, MMCY-20, MMCX+30, MMCY+20, C))then
begin
Result := GetColor(TX,TY);
break;
end;
end;
if(Result = 0)then
writeln('ERROR: RoadColor NOT Found');
FreeBitMap(FaladorRoad);
end;

function FindMapOreColor: Integer;//Completely Copied from Stupid's GuildMiner
var
MapOre, MapOre2 : Integer;
begin
MapOre := BitmapFromString(3, 3,
'3D2C345948546D5D624A39416D5D626D5D625948546D5D626 D5D62' +
'');
MapOre2 := BitmapFromString(3, 3,
'061115222D35364243131E22364243364243222D353642433 64243' +
'');

if(FindBitmapsProgressiveTol(MapOre, MapOre2, 0, 0, 0, 65, 5, 587, 41, 705, 118))then
Result:=GetColor(x+1, y+1);
Freebitmap(MapOre);
Freebitmap(MapOre2);
end;


procedure FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
var
Count: Integer;
begin
Count:=0;
if(MapRock = 0)or(MapPick=0)then
begin
KlinkDebug('Finding colors at Mine please Wait...', False);
while(MapRock=0)or(MapPick=0)do
begin
Count:= Count + 1;
if(MapRock = 0)then // Checks to see if the colors have already been set.
MapRock:= FindMapOreColor;
if(MapPick = 0)then
MapPick:= GetSymbolColor('mining spot');
if(Count>20)then
CantFindColors;
end;
KlinkDebug('MMOre:' + IntToStr(MapRock)+ // Prints the colors found.
' MMPick:' + IntToStr(MapPick), False);
end;
end;

procedure FindColorsAtBank; // Searches for colors at bank
// (RoadColor, BankSymbol).

var
Count: Integer;
begin
Count:=0;
if(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)then
begin
KlinkDebug('Finding colors at bank please Wait...', False);
while(BankIcon=0)or(RoadCol=0)or(WaterColor = 0)do
begin
Count:= Count + 1;
if(RoadCol = 0)then // Checks to see if the colors have already been set.
RoadCol := FindRoadColor;
if(BankIcon = 0)then
BankIcon := GetSymbolColor('bank');
if(WaterColor = 0)then
WaterColor := FindWaterColor;
if(Count>20)then
CantFindColors;
end;
KlinkDebug('RoadColor:'+IntToStr(RoadCol)+
' BankColor:'+ IntToStr(BankIcon) +
' WaterColor: ' + IntToStr(WaterColor), False);
end;
end;


{ *** Anti Randoms ***
*** Stuff for scheduler *** }

procedure RunAwayFromRandoms;
begin
SetRun(true);
RunAwayDirection(Run);
wait(15000 + random(5000));
RunBack;
end;

function InMine: Boolean;
begin
Result := False;
if(FindMMColor(MapPick))then
Result := True;
end;

procedure CheckFight; // Checks to see if you are in a fight. If it does, it
// will run away and back.
begin
if(FindFight)then
RunAwayFromRandoms;
end;

procedure CheckRandoms;
begin
FindNormalRandoms;
AntiBan;
CheckFight;
FindDoctor;
FindBox;
if(InMine)then
begin
if(not(FindPick))then // Checks to see if your pickhead flew off.
// It will try to find it, but if it doesn't, it
// will withdraw any spare picks at the bank.

gLostPick:= True;
if(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220))then
begin
if(Look4Gas)then
begin
if(FindGas(x,y))then
begin
Mouse(MMCX, MMCY, r, r, True)
Flag;
end;
end;
end;
end;
end;


{ *** Important Procedures *** }


{^^^^^^^^^^^^^^^^^ FINDROCK ^^^^^^^^^^^^^^^^^^^^^^^}
{ Copied and Modded from Squig }
{^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^}

//**************** Credits for TPoints go to Fakawi *********************//

function FindRock(RockType : Integer) : TPoint;
var
RockColor, Tol : Integer;
XY: TPoint;
begin
Tol := 5;
case(RockType)of
0 : RockColor:= 2240076;
1 : RockColor:= 4088199;
2 : RockColor:= 6184550;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end else
begin
case(RockType)of
0 : Rockcolor:= 593178;
1 : Rockcolor:= 10000804;
2 : RockColor:= 5212637;
end;
end;
If(FindObj('Mine', RockColor, Tol))Then
begin
GetMousePos(XY.x, XY.y);
Result := XY;
end;
gOreColor := RockColor;
end;


procedure Bank; // Will bank all your ores and withdraw a new pickaxe if needed.

begin
if(InBank)then
begin
KlinkDebug('Banking', False);
gOres:= gOres + CountItemBmpTol(Ore, 50); // Counts the amount of ores you
// mined.

OpenBank;
if(BankScreen)then
begin
if(gLostPick=True)then
Withdraw(1, 1, 1); // If you lost your pick, withdraw a new one.

if(EquipPick=True)then
Deposit(1, 28, 2)
else
Deposit(2, 28, 2);
end;
CloseWindow;
if(gLostPick=true)and(EquipPick=true)then // If you lost your pick,
// do the following.

begin
FindPickHeadColor; // Find colors of new pickhead colors if you lost one.

ClickItemColor(hc1, true); // If EquipPick is true, Equip it.

end;
gNumTrip:= gNumTrip + 1;
end;
end;


{>>---------------- Copied From Stupid's Powerminer ---------------------}
procedure Mine;
var
WaitMax: Integer;
InvC: Integer;


begin
InvC := InventoryCount;
SetRandomOreColor;
if(FindObj('Mine', OreColor, 5))then
begin
if(not(FindGas(x,y)))then
begin
Mouse(x, y, R, R, true);
KlinkDebug('Mining', True)
if(FlagPresent)then
begin
Flag;
Wait(500+Random(500));
end;
MarkTime(WaitMax);
begin
repeat
if(not(FindColorSpiral(x, y, OreColor, 210, 130, 300, 220)))then
Break;
CheckRandoms;
Wait(500+Random(500));
until(not(GetColor(109,430)=0)and(not(GetColor(195 ,426)=0))or // checks 100% for the words
// "you have succesfully...".
(not(InvC = InventoryCount))or(TimeFromMark(WaitMax) >= MaxWait));
end;
end;
end;
end;

{ *** Mapwalking *** }


procedure ToRocks;
begin
KlinkDebug('Going to rocks.', False);
if(RockType = 0)then
begin
RadialWalk(MapRock, 225, 315, 48, +1, 0);
end;
if(RockType = 1)then
begin
RadialWalk(MapRock, 60, 135, 48, -1, 0);
end;
if(RockType = 2)then
begin
RadialWalk(MapRock, 405, 330, 48, 0, 1);
end;
FindOreColors(OreCol, OreTol1, OreTol2);
end;



procedure ToMines; // Walks To rimmington mines.
var
C: Integer;
CX, CY: Integer;
begin
CheckRandoms;
C := 0;
if(FindMMColor(BankIcon))then
begin
RadialWalk(RoadCol, 150, 220, 35, -1, -1);
C := C + 1;
repeat
if(C < 5)then
RadialWalk(RoadCol, 150, 220, 53, -1, -1)
else
RadialWalk(RoadCol, 150, 220, 40, -1, -1)
C := C+1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] Towards Water - Bisect in Road', False)
until(FindMMColor(WaterColor))and(C > 4);
KlinkDebug ('At Water - Water Found.', False)
RadialWalk(RoadCol, 150, 220, 35, -1, -1)
C := 0;
repeat
RadialWalk(RoadCol, 230, 310, 45, 1, 0)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' Step[s] West', False);
until(FindColor(CX, CY, RoadCol, MMCX - 75, MMCY + 25, MMCX , MMCY + 25))
and(C > 1)or(C>4);
KlinkDebug('SouthWest Turn Found', False);
RadialWalk(RoadCol, 180, 250, 55, 1, -1);
C := 0;
repeat
Mouse(646, 151, r, r, true);
Flag;
C := C+1
until(C >= 1);
KlinkDebug('At entrance to mine.', False)
end;
while(not(FindSymbol('mining spot')))do
begin
Mouse(646, 135, r, r, True);
Flag;
end;
FindColorsAtMine; // Gets the colors at the mine.
// (The MiniMap Pick and MM Ores.)
if(FindMMColor(MapPick))then
begin
Mouse(x, y, r, r, true);
Flag;
end;
end;

procedure ToBank; // Walks To Bank.

var
CX, CY : Integer;
Walks, C: Integer;
begin
Walks := 0;
C := 0;
if(FindMMColor(MapPick))then
begin
KlinkDebug('Walking to Bank', True);
KlinkDebug('Heading out of mines.', False);
MouseFindFlag(x, y - 35, 0, +1); // Clicks 35 coordinates away from the
// MM Pick symbol on the Y axis.
Flag;
end;
repeat
RadialWalk(RoadCol, 420, 325, 55, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps NorthEast', False);
until(FindColor(CX, CY, RoadCol, MMCX + 15, MMCY - 10, MMCX + 70, MMCY + 35))
and(C >= 1);
C := 0;
repeat
RadialWalk(RoadCol, 135, 45, 50, 0, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps East', False);
until(FindMMColor(WaterColor))or(C >= 3);
KlinkDebug('Reached water - heading North', False);
C := 0;
repeat
if(FindMMColor(WaterColor))and(C > 2)then
begin
RadialWalk(RoadCol, 440, 315, 40, -1, -1)
C := C + 1
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end else
begin
RadialWalk(RoadCol, 405, 315, 50, -1, -1)
C := C + 1;
KlinkDebug('Taken ' + IntToStr(C) + ' steps North', False);
end;
until(FindMMColor(BankIcon));
RadialWalk(RoadCol, 405, 315, 35, -1, -1);
KlinkDebug('Reached bank - Heading into bank.', False);
ToBankCounter; // Positions you near the bank booths and counters.
end;

//******************************* Forms ********************************// }



procedure MyShowFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('MyInitForm', v);
setarraylength(V, 0);
ThreadSafeCall('MyShowFormModal', v);
end;

procedure StartScript(sender: TObject);
begin
if((not(MyUser.text = ''))and(UsersLoaded))or((not(MyPass.text = ''))and(UsersLoaded))then
begin
Username := MyUser.text;
PassWord := MyPass.text;
end;
EquipPick := CheckBox1.state;
case(MyRockType.Text)of
'Iron': RockType := 0;
'Tin': RockType := 1;
'Copper': RockType := 2;
end;
frmDesign.Caption:= frmDesign.Caption + '.';
ScriptStarted:= True;
frmDesign.ModalResult:= mrOk;
end;

procedure MyInitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 367;
frmDesign.Top := 209;
frmDesign.Width := 203;
frmDesign.Height := 241;
frmDesign.Caption := 'IronMiner/Banker';
frmDesign.Color := clWhite;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.Left := 68;
Label1.Top := 15;
Label1.Width := 48;
Label1.Height := 13;
Label1.Caption := 'Username';
Label2 := TLabel.Create(frmDesign);
Label2.Parent := frmDesign;
Label2.Left := 70;
Label2.Top := 57;
Label2.Width := 46;
Label2.Height := 13;
Label2.Caption := 'Password';
MyUser := TEdit.Create(frmDesign);
MyUser.Parent := frmDesign;
MyUser.Left := 36;
MyUser.Top := 33;
MyUser.Width := 121;
MyUser.Height := 21;
MyUser.Hint := 'Type your username here.';
MyUser.TabOrder := 1;
MyUser.Text := '';
if(not(User = ''))then
MyUser.Text := User;
MyPass := TEdit.Create(frmDesign);
MyPass.Parent := frmDesign;
MyPass.Left := 36;
MyPass.Top := 72;
MyPass.Width := 121;
MyPass.Height := 21;
MyPass.Hint := 'Type your password here';
MyPass.PasswordChar := '*';
MyPass.TabOrder := 2;
MyPass.Text := '';
if(not(Pass = ''))then
MyPass.Text := Pass;
Button1 := TButton.Create(frmDesign);
Button1.OnClick:= @StartScript;
Button1.Parent := frmDesign;
Button1.Left := 58;
Button1.Top := 173;
Button1.Width := 75;
Button1.Height := 25;
Button1.Caption := 'Start';
Button1.TabOrder := 5;
CheckBox1 := TCheckBox.Create(frmDesign);
CheckBox1.Parent := frmDesign;
CheckBox1.Left := 58;
CheckBox1.Top := 105;
CheckBox1.Width := 77;
CheckBox1.Height := 17;
CheckBox1.Hint := 'Is your pickaxe equipped?';
CheckBox1.Caption := 'EquipPick?';
CheckBox1.TabOrder := 3;
if(EquipPick)then
CheckBox1.State := True;
MyRockType := TComboBox.Create(frmDesign);
MyRockType.Parent := frmDesign;
MyRockType.Left := 25;
MyRockType.Top := 139;
MyRockType.Width := 145;
MyRockType.Height := 21;
MyRockType.Hint := 'Which rock are you going to mine?';
MyRockType.ItemHeight := 13;
MyRockType.TabOrder := 4;
MyRockType.Text := 'RockType';
MyRockType.Items.Add('Iron');
MyRockType.Items.Add('Tin');
MyRockType.Items.Add('Copper');
case(RockType)of
0: MyRockType.Text := 'Iron';
1: MyRockType.Text := 'Tin';
2: MyRockType.Text := 'Copper';
end;
end;

procedure SetupForm;
begin
if(UseForm)then
begin
SafeShowForm;
if(ScriptStarted = False)then
TerminateScript;
ActivateClient;
end;
end;

//******************************* Main *********************************//

begin
SetupSSI;
Setup;
SetVariables;
SetupForm;
PrepClient;
GetOreType;
FindPickHeadColor;
LoadMemory;
FindColorsAtBank;
RColor:= RoadCol;
gCounter:=0;
repeat
SetRun(True);
ToMines; // Go To Mines
ToRocks; // Go to the rocks in the mine.

Wait(1000 + Random(500));
SetRun(False);
Wait(500 + random(1000))
MarkTime(Mark);
repeat
CheckRandoms;
Mine;
until(InventoryFull)or(gLostPick = True)or(TimeFromMark(Mark)>1200000)

ToBank; // Go to the East Fallidor bank.

Bank; // Bank your ores and get a new pick if needed.

ProgressReport; // Progress Report. Info on what happened. Please post
// them on the thread for this script.

gCounter := gCounter + 1;
until(False);
end.

3Garrett3
04-22-2007, 01:36 PM
Why is he using these?

{.include SSI2.txt}
{.include KSI2.txt}
{.include BoxBreaker.txt}

? This is a SRL community, and you should be using SRL as the include..

EDIT: I looked through, and are all your procedures copied from somewhere?

ålle
04-22-2007, 06:59 PM
Why is he using these?

{.include SSI2.txt}
{.include KSI2.txt}
{.include BoxBreaker.txt}

? This is a SRL community, and you should be using SRL as the include..

EDIT: I looked through, and are all your procedures copied from somewhere?

______________________________

lol.. its was my friend i think. he helped me with it :D so.............. it was him.. lol XD .. he did the most work.. becasue im a noob on this..lol..i dont know why he used that?

3Garrett3
04-24-2007, 08:55 PM
Use
{.include SRL/SRL.scar} and it would be better, i dont know what SSI2 and KSI2 are.. :p

Deni_mulic
04-24-2007, 11:14 PM
Its not his script

Smartzkid
04-24-2007, 11:24 PM
What you talkin about man! Stop dissin' da poor kid's first script, I mean, common!

*sarcasm*

@alle: You don't have to lie to get help around here...