BigRedJapan
06-16-2012, 05:40 AM
Someone Post a code that works! Mine wont even start up!
This is for those that are using for silver crafting! very cheap method of fast crafting levels!
{================================================= =============================]
[ [SRL] Al-Kharid Smelter by Narcle ]
[ SRL 5 and Simba ]
[ ]
[ NAME : Narcle's AK Smelter ]
[ WRITER : Narcle ]
[ CATEGORY : Smithing & Crafting ]
[ DESCRIPTION : Smelts ores into bars & make C-balls ]
[ Can craft Silver/Gold bars ]
[ AUTOCOLOR : Yes ]
[ ]
[================================================== ============================]
[ Description. ]
[================================================== ============================]
[ I made this script mainly to make cannonballs. I then expanded on the ]
[ concept and made it into a full fledged smelter. It's a very simple setup ]
[ as I try to keep most of my scripts; the simpler the setup the less likely ]
[ something could go wrong. I hope you use this as well as I have. ]
[ -Narcle ]
[================================================== ============================]
[ Instructions. ]
[================================================== ============================]
[ ]
[ Instructions have changed a bit. Please go to: ]
[ http://villavu.com/forum/showthread.php?t=34507 ]
[ For complete instructions. (first post) ]
[ ]
[================================================== ============================}
{$i srl/srl/misc/Smart.simba}
{$i srl/srl.simba}
{$i SRL/SRL/Misc/Reports.simba}
{$i srl/srl/misc/paintsmart.simba}
{ ATTENTION!!!
To use Forms just push play do NOT put anything in DeclarePlayers.
If you want to use DeclarePlayers fill it in (Forms should NOT come up then)}
procedure DeclarePlayers;
begin
With Players[0] do
begin
Name := ''; //Character Name
Pass := ''; //Character Pass
Active := true; //Use player in script?
Pin := ''; //Pin for bank
Strings[0] := 'steel'; //What to smith/craft? [Create string]
Strings[1] := 'al kharid';//Where are you smithing? [Al Kharid, Edgeville]
//cballs, steeltoball, steel, mith, addy, runite, iron, bronze, silver, gold
Arrays[0] := [1, 2, true, false, '23:00', true, false, false];//Settings array
//Settings array := [1st Bankslot, 2nd Bankslot, Take-Breaks, Take-Sleeps, Sleep-Time 'hh:mm', Rest for run, Use Coal bag];
end;
{
With Players[1] do
begin
Name := '';
Pass := '';
Active := true;
Pin := '';
Strings[0] := ''; //[Create string]
Strings[1] := 'al kharid';
Arrays[0] := [1, 2, true, false, '23:00', true, false, false];
end;
}
end;
//Advance Constants
Const
DebugMode = False;
//Change these if needed
AKBankBooth_Color = 9747935;//Color of the bank booth at AK
GreenHedge_Color = 2056767;
Type
TTPAItem = Record
OutLine, Width, Height, Color: Integer;
end;
Type
TPlayas = Record
WithDrawMain, WithDrawSeco, BaseCount, SecoCount, BagCount, BaseDivi: integer;//Setup
BaseAmount, SecoAmount, FailToSmelt: integer;
XPper: Extended;//Setup
CannonBall, SmeltBars, CraftGold, CraftSilver: boolean;//Setup
BaseItem, SecoItem, CraftedItem: TTPAItem;
Coords: TPoint;
SmeltText, SleepTime, statsStr: string;
TakeBreaks, TakeSleeps, RestForRun, HasCoalBag, DisableAntiBan: Boolean;
BankSlot1, BankSlot2: integer;
EdgeVille, AlKharid, Neitiznot: Boolean;
ClickFurnace: Function(Option: string): boolean;
MyOpenBank: Function: boolean;
end;
var
LogTime, BreakTime: integer;//Timers
TotalBars, TotalXP, TotalCrafted: integer;//Counters
PaceCheck: integer;//Ise this to see how fast they are going.
MyVars: array[0..21] of integer;
Playas: array[0..99] of TPlayas;
const
//don't change these!
stats_Bars = 10;
stats_Crafted = 11;
stats_XP = 12;
stats_XPpH = 13;
version = '1.6.3';
ScriptName = 'Narcle''s AK Smelter';
procedure Debug(S: string);
begin
if DebugMode then
Writeln(S)
else
Debugln(S);
Status(S);
end;
const
FilePath = AppPath + 'AKchars.ini';
formCheckActive = 0;
formCheckBreak = 2;
formCheckSleep = 3;
formCheckRestRun = 1;
var
frmDesign: TForm;
PButtons: Array [0..3] of TButton;
SButtons: Array [0..3] of TButton;
frmLabels: Array of TLABEL;
frmEdits: Array [0..9] of TEDIT;
CreateCombo: TCOMBOBOX;
LocationCombo: TCOMBOBox;
CheckBoxs: Array [0..5] of TCHECKBOX;
CurPlayer: integer;
AKpf_SavePlayers, AKpf_Terminate: boolean;
Procedure SavePlayers(tofile: boolean);
var
i: integer;
begin
With Players[CurPlayer] do
begin
Name := frmEdits[0].Caption;
Pass := frmEdits[1].Caption;
Pin := frmEdits[2].Caption;
Active := CheckBoxs[0].CHECKED;
Strings[0] := CreateCombo.Caption;
Strings[1] := LocationCombo.Caption;
Arrays[0] := [StrToInt(frmEdits[3].Caption), StrToInt(frmEdits[4].Caption), CheckBoxs[2].CHECKED, CheckBoxs[3].CHECKED, frmEdits[5].Caption, CheckBoxs[1].CHECKED, CheckBoxs[4].CHECKED, CheckBoxs[5].CHECKED];
end;
if tofile then
begin
WriteINI('General', 'NumOfPlayers', IntToStr(HowManyPlayers), FilePath);
WriteINI('General', 'statsUser', frmEdits[6].Caption, FilePath);
WriteINI('General', 'statsPass', frmEdits[7].Caption, FilePath);
end;
if tofile then
for i := 0 to HowManyPlayers - 1 do
with Players[i] do
begin
WriteINI('Player['+IntToStr(i)+']', 'Name', Name, FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Pass', Pass, FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Pin', Pin, FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Active', BoolToStr(Active), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Strings[0]', Strings[0], FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Strings[1]', Strings[1], FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][0]', IntToStr(Arrays[0][0]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][1]', IntToStr(Arrays[0][1]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][2]', BoolToStr(Arrays[0][2]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][3]', BoolToStr(Arrays[0][3]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][4]', Arrays[0][4], FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][5]', BoolToStr(Arrays[0][5]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][6]', BoolToStr(Arrays[0][6]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][7]', BoolToStr(Arrays[0][7]), FilePath);
end;
end;
Procedure ShowPlayer(index: integer);
begin
With Players[index] do
begin
frmEdits[0].Caption := Name;
frmEdits[1].Caption := Pass;
frmEdits[2].Caption := Pin;
CheckBoxs[0].CHECKED := Active;
CreateCombo.Caption := Strings[0];
if Strings[1] = '' then
LocationCombo.Caption := 'Al Kharid'
else
LocationCombo.Caption := Strings[1];
frmEdits[3].Caption := IntToStr(Arrays[0][0]);//1st bank slot
frmEdits[4].Caption := IntToStr(Arrays[0][1]);//2nd bank slot
CheckBoxs[2].CHECKED := Arrays[0][2];//Take breaks
CheckBoxs[3].CHECKED := Arrays[0][3];//Sleep boolean
frmEdits[5].Caption := Arrays[0][4];//Sleep time
CheckBoxs[1].CHECKED := Arrays[0][5];//Rest for Run
CheckBoxs[4].CHECKED := Arrays[0][6];//CoalBag
end;
CurPlayer := index;
frmEdits[6].Caption := stats_Username;
frmEdits[7].Caption := stats_UserPass;
frmEdits[8].Caption := IntToStr(CurPlayer);
frmEdits[9].Caption := IntToStr(HowManyPlayers);
end;
Procedure LoadPlayers;
var
i: integer;
begin
HowManyPlayers := StrToIntDef(ReadINI('General', 'NumOfPlayers', FilePath), 1);
stats_Username := ReadINI('General', 'statsUser', FilePath);
stats_UserPass := ReadINI('General', 'statsPass', FilePath);
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
CurPlayer := CurrentPlayer;
for i := 0 to HowManyPlayers - 1 do
with Players[i] do
begin
Name := ReadINI('Player['+IntToStr(i)+']', 'Name', FilePath);
if Name = '' then
begin
Active := false;
Arrays[0] := [1,2,true,false,'hh:mm',false,false];
Strings[0] := 'Select what to make here.';
end
else
begin
Pass := ReadINI('Player['+IntToStr(i)+']', 'Pass', FilePath);
Pin := ReadINI('Player['+IntToStr(i)+']', 'Pin', FilePath);
Active := StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Active', FilePath));
Strings[0] := ReadINI('Player['+IntToStr(i)+']', 'Strings[0]', FilePath);
Strings[1] := ReadINI('Player['+IntToStr(i)+']', 'Strings[1]', FilePath);
try
Arrays[0] := [StrToIntDef(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(0)+']', FilePath), 1),
StrToIntDef(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(1)+']', FilePath), 2),
StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(2)+']', FilePath)),
StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(3)+']', FilePath)),
ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(4)+']', FilePath),
StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(5)+']', FilePath)),
StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(6)+']', FilePath)),
StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0]['+IntToStr(7)+']', FilePath))];
except
Arrays[0] := [1,2,true,false,'hh:mm',false,false,false];
end;
end;
end;
end;
procedure OnLeftClick(Sender: TObject);
var
i: integer;
begin
Case Sender of
SButtons[0]: begin//Start
frmDesign.ModalResult := mrOk;
AKpf_SavePlayers := False;
AKpf_Terminate := False;
Writeln('Start.');
end;
SButtons[1]: begin//Save and start
frmDesign.ModalResult := mrOk;
AKpf_SavePlayers := True;
AKpf_Terminate := False;
Writeln('Save and Start.');
end;
SButtons[2]: begin//Save and Exit
frmDesign.MODALRESULT:= mrOk;
AKpf_SavePlayers := True;
AKpf_Terminate := True;
Writeln('Save and Exit.');
end;
SButtons[3]: begin//Exit
frmDesign.MODALRESULT:= mrOk;
AKpf_SavePlayers := False;
AKpf_Terminate := True;
Writeln('Exit.');
end;
PButtons[0]: begin//Previous player
SavePlayers(false);
if CurPlayer = 0 then
ShowPlayer(HowManyPlayers - 1)
else
ShowPlayer(CurPlayer - 1);
end;
PButtons[1]: begin//New player
Inc(HowManyPlayers);
NumberOfPlayers(HowManyPlayers);
SavePlayers(false);
CurPlayer := HowManyPlayers-1;
for i := 0 to 2 do
begin
frmEdits[i].Caption := '';
CheckBoxs[i].CHECKED := true;
end;
CreateCombo.Caption := 'Select what to make here.';
frmEdits[3].Caption := '1';
frmEdits[4].Caption := '2';
CheckBoxs[3].CHECKED := false;
CheckBoxs[4].CHECKED := false;
CheckBoxs[5].CHECKED := false;
frmEdits[5].Caption := 'hh:mm';
frmEdits[6].Caption := stats_Username;
frmEdits[7].Caption := stats_UserPass;
frmEdits[8].Caption := IntToStr(CurPlayer);
frmEdits[9].Caption := IntToStr(HowManyPlayers);
Writeln('Player '+IntToStr(CurPlayer)+' added.');
end;
PButtons[2]: begin//Next player
SavePlayers(false);
if CurPlayer = HowManyPlayers - 1 then
ShowPlayer(0)
else
ShowPlayer(CurPlayer + 1);
end;
PButtons[3]: begin//Delete player
if (HowManyPlayers > 1) and (CurPlayer = 0) then
Writeln('Can''t delete player 0.')
else
if (HowManyPlayers = 1) then
begin
if not (MessageDlg('Delete?', 'Do you want to reset Player '+ToStr(CurPlayer)+'?', mtWarning, [mbYes,mbNo]) = 6) then
Exit;
Writeln('Player '+ToStr(CurPlayer)+' reset.');
for i := 0 to 2 do
begin
frmEdits[i].Caption := '';
CheckBoxs[i].CHECKED := true;
end;
CreateCombo.Caption := '';
frmEdits[3].Caption := '1';
frmEdits[4].Caption := '2';
CheckBoxs[3].CHECKED := false;
frmEdits[5].Caption := 'hh:mm';
CheckBoxs[5].CHECKED := false;
end
else
if MessageDlg('Delete?', 'Do you want to delete Player '+ToStr(CurPlayer)+'?', mtWarning, [mbYes,mbNo]) = 6 then
begin
Writeln('Player '+ToStr(CurPlayer)+' deleted.');
Swap(Players[CurPlayer], Players[HowManyPlayers - 1]);
IncEx(HowManyPlayers, -1);
ShowPlayer(Max(CurPlayer - 1, 0));
SavePlayers(true);
end;
end;
end;
end;
procedure InitForm;
var
i: integer;
PCaps, CreateComboText, LocationText, Labels: TStringArray;
Ws, Ls, Ts: TIntegerArray;
begin
frmDesign := Tform.Create(nil);
With frmDesign do
begin
setBounds(100, 100, 390, 330);
Caption := 'Narcle''s AK Smelter v'+version;
Color := ClWhite;
Font.Color := ClBlack;
end;
PCaps := ['Previous Player', 'New Player', 'Next Player', 'Delete Player'];
for i := 0 to 3 do
begin
PButtons[i] := TBUTTON.Create(frmDesign);
with PButtons[i] do
begin
Parent := frmDesign;
Height := 22;
if i = 3 then
Width := 80//Delete Player
else
Width := 120;
Left := 10+i*125;
Top := 8;
CAPTION := PCaps[i];
ONCLICK := @OnLeftClick;
if i = 3 then
begin
Left := 135;
Top := 34;
end;
end;
end;
PCaps := ['Start', 'Save and Start', 'Save and Exit', 'Exit'];
for i := 0 to 3 do
begin
SButtons[i] := TBUTTON.Create(frmDesign);
with SButtons[i] do
begin
Parent := frmDesign;
Height := 22;
Width := 90;
Left := 6+i*96;
Top := 300;
FONT.Size := 8;
CAPTION := PCaps[i];
OnClick := @OnLeftClick;
end;
end;
CreateComboText := ['Bronze bars', 'Iron bars', 'Steel bars', 'Silver bars', 'Gold bars',
'Mithril bars', 'Addamantite bars', 'Runite bars', 'Cannonballs from Ores', 'Cannonballs from Bars',
'Silver Holy Symbol', 'Silver Unholy Symbol', 'Silver Sickle', 'Silver Tiara',
'Gold ring', 'Gold necklace', 'Gold amulet', 'Gold bracelet', 'Sapphire ring', 'Sapphire necklace', 'Sapphire amulet',
'Sapphire bracelet', 'Emerald ring', 'Emerald necklace', 'Emerald amulet', 'Emerald bracelet',
'Ruby ring', 'Ruby necklace', 'Ruby amulet', 'Ruby bracelet', 'Diamond ring', 'Diamond necklace',
'Diamond amulet', 'Diamond bracelet', 'Dragonstone ring', 'Dragonstone necklace',
'Dragonstone amulet', 'Dragonstone bracelet'];
CreateCombo := TComboBox.Create(frmDesign);
with CreateCombo do
begin
Parent := frmDesign;
Top := 80;
Left := 200;
Width := 180;
Height := 20;
FONT.Size := 10;
Caption := 'Select what to make here.';
for i := 0 to High(CreateComboText) do
ITEMS.Add(CreateComboText[i]);
end;
LocationText := ['Al Kharid', 'Edgeville'];
LocationCombo := TComboBox.Create(frmDesign);
with LocationCombo do
begin
Parent := frmDesign;
Top := 126;
Left := 200;
Width := 180;
Height := 20;
for i := 0 to High(LocationText) do
Items.Add(LocationText[i]);
end;
Labels := ['Username:', 'Password:', 'Bank Pin:', '1st Bank slot:', '2nd Bank slot:',
'What are you Making:', 'Where are you smelting:',
'Active', 'Rest for Run', 'Take Breaks', 'Sleep : Time ---->', 'Use Coal bag', 'Disable Antiban',
'SRL Stats User:', 'SRL Stats Password:', 'Player:', 'Total Players:'];
SetArrayLength(frmLabels, Length(Labels));
Ts := [62, 108, 156, 186, 216, 62, 108, 156, 178, 200, 222, 244, 266, 250, 280, 38, 38];
Ls := [10, 10, 50, 29, 25, 200, 200, 228, 228, 228, 228, 228, 228, 34, 10, 20, 260];
for i := 0 to High(Labels) do
begin
frmLabels[i] := TLABEL.Create(frmDesign);
with frmLabels[i] do
begin
Parent := frmDesign;
Height := 20;
Width := 50;
Top := Ts[i];
Left := Ls[i];
Font.Size := 8;
Caption := Labels[i];
end;
end;
Ws := [180, 180, 60, 60, 60, 60, 76, 76, 28, 28];
Ts := [ 80, 126, 154, 184, 214, 218, 244, 274, 34, 34];
Ls := [ 10, 10, 100, 100, 100, 320, 112, 112, 60, 330];
for i := 0 to 9 do
begin
frmEdits[i] := TEDIT.Create(frmDesign);
with frmEdits[i] do
begin
Parent := frmDesign;
Height := 21;
Width := Ws[i];
top := Ts[i];
Left := Ls[i];
Font.Size := 8;
if i = 3 then
Caption := '1';
if i = 4 then
Caption := '2';
if i = 5 then
Caption := 'hh:mm';
end;
end;
for i := 0 to 5 do
begin
CheckBoxs[i] := TCHECKBOX.Create(frmDesign);
with CheckBoxs[i] do
begin
Parent := frmDesign;
Top := 154+i*22;
Left := 210;
if InIntArray([0, 1, 2], i) then
Checked := true;
end;
end;
if FileExists(FilePath) then
begin
LoadPlayers;
ShowPlayer(0);
end
else
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
CurPlayer := CurrentPlayer;
frmEdits[8].Caption := IntToStr(CurPlayer);
frmEdits[9].Caption := IntToStr(HowManyPlayers);
end;
frmDesign.ShowModal;
end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
Function Loc(Location: string): Boolean;
begin
Result := Players[CurrentPlayer].Loc = Lowercase(Location);
end;
Procedure SetLoc(Location: string);
begin
Players[CurrentPlayer].Loc := Lowercase(Location);
end;
function TPAItem(cOutLine, cWidth, cHeight, cColor: Integer): TTPAItem;
begin
with Result do
begin
OutLine := cOutLine;
Width := cWidth;
Height := cHeight;
Color := cColor;
end;
end;
function FindTPAItem(Item: TTPAItem; B: TBox): Boolean;
var
TPA: TPointArray;
Bt: TBox;
x,y: integer;
T:TPoint;
begin
FindColorsTolerance(TPA, srl_outline_black, B.x1, B.y1, B.x2, B.y2, 0);
if Length(TPA) < 1 then
Exit;
Bt := GetTPABounds(TPA);
T := MiddleTPA(TPA);
if (Length(TPA) = Item.OutLine) and (iAbs(Bt.x2-Bt.x1) = Item.Width) and (iAbs(Bt.y2-Bt.y1) = Item.Height) then
if Item.Color > -1 then
Result := FindColorTolerance(x, y, Item.Color, T.x, T.y, T.x, T.y, 7)
else
Result := True;
end;
Function UpdateItem(var Item: TTPAItem; InvN: integer; ForcedUpdate: Boolean): Boolean;
var
TPA: TPointArray;
T: TPoint;
B: TBox;
begin
if InvN < 1 then
Exit;
if not ForcedUpdate then
if (Item.OutLine > 0) then
Exit;
if ForcedUpdate then
WriteLn('Item wasn''t detected attempting a TPA update.');
Wait(300+random(200));
B := InvBox(InvN);
FindColorsTolerance(TPA, srl_outline_black, B.x1, B.y1, B.x2, B.y2, 0);
if Length(TPA) < 1 then
Exit;
B := GetTPABounds(TPA);
T := MiddleTPA(TPA);
Item := TPAItem(Length(TPA), iAbs(B.x2-B.x1), iAbs(B.y2-B.y1), GetColor(T.x, T.y));
Result := true;
Writeln('Item := TPAItem('+inttostr(Item.Outline) +', '+inttostr(Item.Width)+', '+inttostr(Item.Height)+', '+inttostr(Item.Color)+');');
Exit;
end;
function iCountArr(Item: TTPAItem): TIntegerArray;
var
i, n: integer;
begin
SetArrayLength(Result, 28);
for i := 1 to 28 do
if FindTPAItem(Item, InvBox(i)) then
begin
Result[n] := i;
Inc(n);
end;
SetArrayLength(Result, n);
end;
function iCount(Item: TTPAItem): integer;
begin
Result := Length(iCountArr(Item));
end;
Function GoldCraftCoords(x, y: integer): TPoint;//x = 0 to 3, y = 0 to 7
begin
Result.y := 101+ 61*y;
if (y = 0) then
Result.x := 110+47*x;//Rings
if InRange(y, 1, 3) and InRange(x, 0, 6) then
Result.x := 125 + 51*x;//others
end;
Function GoldMenu: Boolean;
begin
Result := InRange(CountColor(2071039, MSX1, MSY1, MSX2, MSY1+60), 610, 630);
end;
Function SilverMenu: Boolean;
begin
Result := InRange(CountColor(2070783, MSX1, MSY1, MSX2, MSY1+60), 285, 310);
end;
Procedure ResetTimer(Time: string);
begin
Case LowerCase(Time) of
'logout': LogTime := GetSystemTime+RandomRange(19*60000, 31*60000);
'break': BreakTime := GetSystemTime+RandomRange(50*60000, 180*60000);
end;
end;
procedure Report;
var
i: integer;
begin
if (GetTimeRunning < 60000) then
Exit;
With Playas[CurrentPlayer] do
begin
if CannonBall then
begin
MyVars[0] := Round(MyVars[2]*25.5/4);
IncEx(Players[CurrentPlayer].Integers[11], MyVars[2]);//Players C-balls
IncEx(TotalCrafted, MyVars[2]);//Total
stats_IncVariable('Cannonballs (Made)', MyVars[2]);
end;
if SmeltBars then
begin
MyVars[0] := Round(MyVars[1]*XPper) + MyVars[0];//XP
IncEx(Players[CurrentPlayer].Integers[10], MyVars[1]);//Bars
IncEx(TotalBars, MyVars[1]);
stats_IncVariable(statsStr, MyVars[1]);
end;
if CraftGold or CraftSilver then
begin
MyVars[0] := Round(MyVars[1]*XPper) + MyVars[0];
IncEx(Players[CurrentPlayer].Integers[11], MyVars[1]);//Player Crafted
IncEx(TotalCrafted, MyVars[1]);//Total Crafted
stats_IncVariable(statsStr, MyVars[1]);
end;
end;
With Players[CurrentPlayer] do
begin
Integers[12] := integers[12] + MyVars[0];//XP
IncEx(TotalXP, MyVars[0]);
stats_IncVariable('Total EXP Gained', MyVars[0]);
if ((PlayerWorked(CurrentPlayer)/60000.0) > 0) then
Integers[13] := round( (Integers[12]*60.0)/(PlayerWorked(CurrentPlayer)/60000.0))//XP Per hour
else
Integers[13] := -1;//error number
end;
writeln('');
//ClearReport;
if (HowManyPlayers > 1) then
SRLProgressReport(ResultDebugBox, ScriptName, 'Narcle', version,
['Run Time', 'Total Bars', 'Crafted', 'Total XP'],
[MsToTime(GetTimeRunning, Time_Abbrev), TotalBars, TotalCrafted, TotalXP]);
SRLPlayerReport( ResultDebugBox, 0, False,
[True, True, False, False, False, False],
['Bars', 'Crafted', 'XP', 'XP/Hour'],
[], [stats_Bars, stats_Crafted, stats_XP, stats_XPpH], [], []);
For i := 0 to High(MyVars) do
MyVars[i] := 0;
stats_Commit;
end;
Procedure SetupPlayer;
begin
Debug('Player setup...');
Disguise('AKS: '+Players[CurrentPlayer].Nick);
SetAngle(SRL_ANGLE_HIGH);
ResetTimer('Logout');
RunEnergy(20);
GameTab(tab_Inv);
end;
procedure LogoutSeq(reason:string);
begin
CloseWindow;
if (reason = '') then
nextplayer(true)
else
begin
writeln(reason+', '+Players[CurrentPlayer].Name+' is now inactive.');
SaveScreenshot(AppPath + reason + TheDate(Date_Day) + TheTime+'.bmp');
nextplayer(false);
end;
end;
function TakeABreak: boolean;
var
H, M, S, BreakFor, T: integer;
begin
if ( GetSystemTime >= BreakTime ) then
begin
CloseWindow;
Logout;
result := true;
BreakFor := RandomRange(5 * 60000, 25 * 60000);
ConvertTime(BreakFor, H, M, S);
Writeln('Break for: '+inttostr(M)+ 'm:' +inttostr(S)+ 's');
Logout;
MarkTime(T);
Repeat
wait(1000);
until (BreakFor < TimeFromMark(T))
ResetTimer('Logout');
ResetTimer('Break');
NextPlayer(true);
end;
end;
function TakeASleep(SleepTime: string): boolean;
var
H, M, S, ms: Word;
SleepH, SleepM, SleepFor, Hr, Mr, Sr, T: integer;
begin
SleepH := StrToInt(Copy(SleepTime, 1, 2));
SleepM := StrToInt(Copy(SleepTime, 4, 5));
DecodeTime(Now, H, M, S, ms);
if (H = SleepH) and (M > SleepM) then
begin
Logout;
Result := true;
SleepFor := RandomRange(540 * 60000, 780 * 60000);
ConvertTime(SleepFor, Hr, Mr, Sr);
Writeln('Sleep for: '+inttostr(Hr)+ 'h:'+inttostr(Mr)+ 'm:' +inttostr(Sr)+ 's');
Logout;
MarkTime(T);
Repeat
wait(1000);
until (SleepFor < TimeFromMark(T))
ResetTimer('Logout');
ResetTimer('Break');
NextPlayer(true);
end;
end;
function BuildingOutline: integer;
var
arC, A: TIntegerArray;
i, t, Len, Hi, c: Integer;
H, S, L: Extended;
begin
Result := -1;
t := GetSystemTime;
arC := GetColors(TPAFromBox(IntToBox(MMX1, MMY1, MMX2, MMY2)));
ClearSameIntegers(arC);
SetArrayLength(A, Length(arC));
for i := 0 to High(arC) do
begin
ColorToHSL(arC[i], H, S, L);
if (L >= 90.5) and (L <= 99.0) then
begin
A[Len] := arC[i];
Inc(Len);
end;
end;
For i := 0 to Len do
begin
c := CountColor(A[i], MMX1, MMY1, MMX2, MMY2)
if c > Hi then
begin
Hi := c;
Result := A[i];
end;
end;
Debug('BuildingOutline = ' + IntToStr(Result)+ ' '+IntToStr(GetSystemTime-t)+'ms');
end;
Function AKFindPosition: boolean;
var
TPAG: TPointArray;
B: TBox;
ATPAG: T2DPointArray;
Size: integer;
begin
Result := False;
if BankScreen then
begin
SetLoc('at bank');
Result := true;
Exit;
end;
FindColorsSpiralTolerance(MMCX, MMCY, TPAG, GreenHedge_Color, MMx1, MMy1, MMx2, MMy2, 40);
If (Length(TPAG) < 1) then
Exit;
ATPAG := SplitTPAEx(TPAG, 3, 3);
SortATPASize(ATPAG, True);
if DebugMode then
SMART_DrawDotsEx(True, ATPAG[0], clBlue);
B := GetTPABounds(ATPAG[0]);
Size := Length(ATPAG[0]);
Debug('Size: '+ ToStr(Size) +' Height: '+ToStr(B.y2-B.y1));
if InRange(Size, 130, 500) and InRange(B.y2-B.y1, 20, 69) then
begin
SetLoc('smelted');
Result := True;
Debug('Near Furnace');
end;
if InRange(Size, 200, 800) and InRange(B.y2-B.y1, 70, 120) then
begin
SetLoc('to bank');
Result := True;
Debug('Near Bank');
end;
end;
function ToAKCactus(ToFurnace:boolean): boolean;//This uses the green bush wall
var
z: integer;
B: TBox;
TPA: TpointArray;
ATPA: T2DPointArray;
T, O: TPoint;
begin
if not LoggedIn then
Exit;
Debug('To Cactus...');
if ToFurnace then
begin
O := Point(2, Random(5));
B := IntToBox(MMX1, MMY1, MMX2, MMY2);
end
else
begin
Case Random(2) of
0: O := Point(-6, 15);
1: O := Point(-8, 20);
end;
B := IntToBox(625, MMCY, MMX2, MMY2);
end;
z := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, GreenHedge_Color, B.x1, B.y1, B.x2, B.y2, 40);
ColorToleranceSpeed(z);
if Length(TPA) < 1 then
Exit;
//ATPA := TPAtoATPAEx(TPA, 20, 38);
ATPA := SplitTPA(TPA, 3);
SortATPASize(ATPA, true);
B := GetTPABounds(ATPA[0]);
T := Point(B.x1+O.x, B.y1+O.y);
if DebugMode then
begin
SMART_DrawDotsEx(true, ATPA[0], clBlue);
TPA := TPAFromBox(IntToBox(T.x, T.y, T.x+6, T.y+8 ));
SMART_DrawDotsEx(False, TPA, clRed);
end;
if PointInBox(T, MMBox) then
begin
Mouse(T.x, T.y, 6, 8, true);
FFlag(20);
Result := true;
PaceCheck := GetSystemTime;
end else
Debug('To AK Cactus failed.');
end;
function ToAKFurnace: Boolean;
var
TPA: TPointArray;
B, Ba: TBox;
ATPA: T2DPointArray;
T: TPoint;
YMod: integer;
begin
if not LoggedIn then
Exit;
Debug('To Furnace...');
Result := False;
B := MMBox;
FindColorsSpiralTolerance(MMCX, MMCY, TPA, GreenHedge_Color, B.x1, B.y1, B.x2, B.y2, 40);//green hedge
if (High(TPA) < 1) then
Exit;
ATPA := SplitTPAEx(TPA, 3, 3);
SortATPAFromSize(ATPA, 1000, True);
//SMART_DrawDotsEx(True, ATPA[0], clGreen);
Ba := GetTPABounds(ATPA[0]);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, BuildingOutline, B.x1, B.y1, Ba.x2+6, Ba.y1+12, 0);
if (High(TPA) < 1) then
Exit;
ATPA := SplitTPA(TPA, 15);
SortATPAFromSize(ATPA, 200, True);
B := GetTPABounds(ATPA[0]);
//SMART_DrawDotsEx(True, ATPA[0], clBlue);
Debug('PaceCheck: '+ToStr(GetSystemTime-PaceCheck)+'ms');
Case (GetSystemTime-PaceCheck) of
0..70: Ymod := 4;
71..89: Ymod := 3;
90..129: YMod := 2;
else
YMod := 0;
end;
if (B.y2-B.y1 < 37) then//if the Box is too short, somethigns off
T := Point(Ba.x1-17, Ba.y1-25+YMod)
else
T := Point(B.x2-17, B.y2-30+YMod);
if DebugMode then
begin
SMART_DrawDotsEx(True, ATPA[0], clBlue);
TPA := TPAFromBox(IntToBox(T.x, T.y, T.x+5, T.y+5 ));
SMART_DrawDotsEx(false, TPA, clRed);
end;
If PointInBox(T, MMBox) then
begin
Mouse(T.x, T.y, 5, 5, true);
FFlag(20);
Wait(400+random(100));
FFlag(0);
Result := True;
PaceCheck := GetSystemTime;
Wait(700+random(300));
end else
Debug('To AK Furnace failed.');
end;
function ToAKBank: Boolean;//Uses bankers at bank
var
z, L: integer;
T: TPoint;
B: TBox;
TPA, TPA2: TpointArray;
ATPA, ATPA2: T2Dpointarray;
begin
if not LoggedIn then
Exit;
Debug('To Bank...');
z := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, GreenHedge_Color, MMX1, MMY1, MMX2, MMY2, 40);
ColorToleranceSpeed(z);
if (Length(TPA) < 1) then
Exit;
ATPA := SplitTPAEx(TPA, 2, 2);
SortATPASize(ATPA, true);
B := GetTPABounds(ATPA[0]);
if DebugMode then
SMART_DrawDotsEx(True, ATPA[0], clBlue);
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA2, BuildingOutline, MMX1, B.Y1+9, B.X1, MMY2, 0);
ColorToleranceSpeed(z);
if (Length(TPA2) < 1) then
Exit;
ATPA2 := SplitTPAEx(TPA2, 15, 10);
SortATPASize(ATPA2, True);
L := Length(ATPA2);
if (L = 0) then
Exit;
SetArrayLength(ATPA2, Min(L, 2));
SortATPAFromFirstPoint(ATPA2, Point(B.x1-16, MMY2));
B := GetTPABounds(ATPA2[0]);
Debug('H: '+ToSTR(B.y2-B.y1)+', W: '+ToStr(B.x2-B.x1));
T := Point(B.x2-13, B.y1+(B.y2-B.y1)/2-MAx((35-(B.x2-B.x1))/2, 2));
if DebugMode then
begin
TPA := TPAFromBox(IntToBox(T.x, T.y, T.x+4, T.y+8 ));
SMART_DrawDotsEx(False, ATPA2[0], clGreen);
SMART_DrawDotsEx(False, TPA, clRed);
end;
if PointInBox(T, MMBox) then
begin
Mouse(T.x, T.y, 4, 8, true);
FFlag(20);
Result := true;
if RunEnergy(10) then
Wait(1200+random(600))
else
Wait(2400+random(1200));
end else
Debug('To AK Bank failed.');
end;
function AKClickFurnace(Option: string): boolean;
var
z: integer;
TPoint: TPoint;
TPA, TPA2: TpointArray;
ATPA: T2Dpointarray;
begin
z := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(TPA, 3815997, MSX1, MSY1, MSX2, MSY2, 50);
FindColorsTolerance(TPA2, 1911763, MSX1, MSY1, MSX2, MSY2, 18);
ColorToleranceSpeed(z);
TPA := CombineTPA(TPA, TPA2);
if Length(TPA) < 1 then exit;
ATPA := SplitTPAEx(TPA, 15, 10);
SortATPASize(ATPA, true);
TPA := ATPA[0];
TPoint := MiddleTPA(TPA);
if Length(TPA) > 0 then
begin
MMouse(TPoint.x+10, TPoint.y+10, 1, 1);
if WaitUpText('urnac', 100+random(50)) then
begin
case random(2) of
0: begin
ClickMouse2(mouse_Right);
Result := WaitOption(Option, 200+random(100));
end;
1: begin
ClickMouse2(mouse_Left);
Result := DidClick(True, 100);
end;
end;
If Result then
begin
wait(300+random(200));
Exit;
end;
end;
end;
end;
Function ToEdgeFurnace: Boolean;
var
TPA: TPointArray;
B, Bs: TBox;
ATPA: T2DPointArray;
T: TPoint;
i: integer;
begin
if not LoggedIn then
Exit;
Debug('To Furnace...');
Result := false;
FindColorsSpiralTolerance(MMX2, MMCY, TPA, BuildingOutline, MMx1, MMy1, MMx2, MMy2, 0);
if High(TPA) < 0 then
Exit;
ATPA := SplitTPA(TPA, 16);
For i := 0 to High(ATPA) do
begin
Bs := GetTPABounds(ATPA[i]);
if InRange(Bs.y2-Bs.y1, 23, 28) then
begin
B := Bs;
TPA := ATPA[i];
Break;
end;
end;
if DebugMode then
SMART_DrawDotsEx(true, TPA, clBlue);
T := Point(B.x1+(B.x2-B.x1)/2+3, B.y1+(B.y2-B.y1)/2-5);
if DebugMode then
begin
TPA := TPAFromBox(IntToBox(T.x, T.y, T.x+3, T.y+5 ));
SMART_DrawDotsEx(False, TPA, clRed);
end;
if PointInBox(T, MMBox) then
begin
Mouse(T.x, T.y, 3, 5, true);
FFlag(0);
Result := true;
wait(800+random(400));
end else
Debug('To Edge Furnace failed.');
end;
Function ToEdgeBank: Boolean;
var
TPA: TPointArray;
B,Bs: TBox;
ATPA: T2DPointArray;
T: TPoint;
i: integer;
begin
if not LoggedIn then
Exit;
Debug('To Bank...');
Result := false;
FindColorsSpiralTolerance(MMX1, MMY2, TPA, BuildingOutline, MMx1, MMy1, MMx2, MMy2, 0);
if High(TPA) < 0 then
Exit;
ATPA := SplitTPA(TPA, 17);
For i := 0 to High(ATPA) do
begin
Bs := GetTPABounds(ATPA[i]);
Debug('W: '+ToStr(Bs.y2-Bs.y1)+' H: '+ToStr(Bs.x2-Bs.x1));
if InRange(Bs.y2-Bs.y1, 42, 55) and InRange(Bs.x2-Bs.x1, 23, 36) then
begin
B := Bs;
TPA := ATPA[i];
Break;
end;
end;
if DebugMode then
SMART_DrawDotsEx(true, TPA, clBlue);
T := Point(B.x2-9, B.y1+16);
if DebugMode then
begin
TPA := TPAFromBox(IntToBox(T.x, T.y, T.x+5, T.y+5 ));
SMART_DrawDotsEx(False, TPA, clRed);
end;
if PointInBox(T, MMBox) then
begin
Mouse(T.x, T.y, 2, 3, true);
FFlag(0);
Wait(1200+random(200));
Result := True;
end else
Debug('To Edge Bank failed.');
end;
Function EdgeClickFurnace(Option: string): Boolean;
var
TPA, tpa1, tpa2: TPointArray;
ATPA: T2DPointArray;
B:TBox;
T: TPoint;
begin
FindColorsTolerance(tpa1, 1516193, MSX1, MSY1, MSX2, MSY2, 50);
//SMART_DrawDotsEx(true, tpa1, 255);
if (Length(tpa1) < 1) and (Length(tpa2) < 1) then
Exit;
ATPA := TPAtoATPAEx(tpa1, 30, 40);
SortATPAFromSize(ATPA, 450, true);
//for i := 0 to High(ATPA) do Debug('ATPA['+ToStr(i)+'] Length = '+ToStr(Length(ATPA[i])));
tpa1 := ATPA[0];
B := GetTPABounds(tpa1);
FindColorsTolerance(tpa2, 6121324, B.x1-50, B.y1-20, B.x2, B.y2+30, 50);
if DebugMode then
begin
SMART_DrawDotsEx(true, tpa1, 255);
SMART_DrawDotsEx(False, tpa2, 5026082);
end;
Debug('tpa1 Length = '+ToStr(Length(tpa1))+' || tpa2 Length = '+ToStr(Length(tpa2)));
if (Length(tpa1) < 1) and (Length(tpa2) < 1) then
Exit;
TPA := CombineTPA(tpa1, tpa2);
T := MiddleTPA(TPA);
if PointInBox(T, IntToBox(B.x1-50, B.y1-20, B.x2, B.y2+30)) then
begin
MMouse(T.x-10, T.y-10, 20, 20);
if WaitUpTextMulti(['urnac', 'nace'], 400) then
begin
case random(2) of
0: begin
ClickMouse2(mouse_Right);
Result := WaitOption(Option, 200+random(100));
end;
1: begin
ClickMouse2(mouse_Left);
Result := DidClick(True, 100);
end;
end;
If Result then
begin
wait(300+random(200));
Exit;
end;
end;
end;
end;
Function EdgeOpenBank: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, cts: integer;
T: TPoint;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.33, 0.22);
FindColorsTolerance(TPA, 3688009, MSX1, MSY1, MSX2, MSY2, 3)
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2, 0.2);
if Length(TPA) < 1 then
Exit;
ATPA := SplitTPAEx(TPA, 1, 4);
SortATPASize(ATPA, True);
SetArrayLength(ATPA, Min(3, Length(ATPA)));
SortATPAFromFirstPoint(ATPA, Point(MSCX+30, MSCY));
for i := 0 to High(ATPA) do
begin
T := MiddleTPA(ATPA[i]);
MMouse(T.x-5, T.y-5, 10, 10);
wait(100+Random(100));
if WaitUpText('ooth', 450) then
if random(3) = 0 then
begin
ClickMouse2(mouse_Right);
Result := WaitOptionMulti(['Bank B', 'nk B', 'k Bank'], 250+random(100));
end else
begin
ClickMouse2(mouse_Left);
Result := DidClick(True, 200);
end;
if Result then
Exit;
end;
end;
Function AKOpenBank: Boolean;
var
i, H, L: integer;
T: TPoint;
TPA: TPointArray;
ATPA: T2Dpointarray;
begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, AKBankBooth_Color, MSX1, MSY1, MSX2, MSY2, 30);
if Length(TPA) < 1 then
Exit;
ATPA := TPAtoATPAEx(TPA, 44, 200);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
L := High(ATPA);
If L > 1 then
H := 1 Else H := L;
For i := 0 to H do
begin
T := MiddleTPA(ATPA[i]);
MMouse(T.x, T.y, 1, 1);
if WaitUpText('ooth', 450) then
if random(3) = 0 then
begin
ClickMouse2(mouse_Right);
Result := WaitOptionMulti(['Bank B', 'nk B', 'k Bank'], 250+random(100));
end else
begin
ClickMouse2(mouse_Left);
Result := DidClick(True, 200);
end;
if Result then
Exit;
end;
end;
Function Smelt: boolean;
var
i, s, C, Timer: integer;
iCa: TIntegerArray;
T: TPoint;
Item: TTPAItem;
begin
With Playas[CurrentPlayer] do
begin
Debug('Going to smelt...');
repeat
if SmeltBars then
if (iCount(BaseItem) > 0) then
if ClickFurnace('elt') then
begin
Timer := GetSystemTime + 8000+random(2000);
repeat
Wait(50+random(50));//Waiting for smith options to pop up
if (GetSystemTime > Timer) or not LoggedIn then
Exit;
until FindTextTpaEx(2070783, 0, MCX1, MCY1, MCX2, MCY2, T.x, T.y, SmeltText, statchars, Nothing);
Wait(RandomRange(150, 350));//Don't want a instant click, the text can pop up fast
MouseBox(T.x-20, T.y-30, T.x+20, T.y+8, 1);
Debug('Smelting Ore...');
Timer := GetSystemTime+4000*WithDrawMain;
repeat
If not LoggedIn then
Exit;
if FindNormalRandoms then
Break;
if ClickContinue(true, true) then
Break;
Wait(300+random(200));
until( iCount(BaseItem) < 1) or (GetSystemTime > Timer);
UpdateItem(CraftedItem, 2, False);
if iCount(CraftedItem) < 1 then
UpdateItem(CraftedItem, WithDrawMain+2, True);
end;
if SmeltBars then
Item := CraftedItem
else
Item := BaseItem;
//CannonBall Begin
if CannonBall or CraftGold or CraftSilver then
if ( iCount(Item) > 0 ) then
begin
if CannonBall then
Debug('Making Cannonballs...')
else
Debug('Making '+Players[CurrentPlayer].Strings[0]+'...');
for i := 0 to 3 do
begin
iCa := iCountArr(Item);
s := iCa[random(High(iCa))];
if ExistsItem(s) then
begin
MouseItem(s, mouse_Left);
Break;
end;
end;
if ClickFurnace('bar') then
begin
Timer := GetSystemTime + 8000+random(2000);
repeat
Wait(100+random(100));//Waiting for options to pop up
if (GetSystemTime > Timer) or not LoggedIn then
Exit;
if CannonBall then
if FindTextTpaEx(2070783, 0, MCX1, MCY1, MCX2, MCY2, T.x, T.y, 'nonb',statchars, Nothing) then
begin
Wait(RandomRange(150, 350));
MouseBox(T.x-20, T.y-30, T.x+20, T.y+8, 1);
Break;
end;
until GoldMenu or SilverMenu;
if CraftGold then
begin
T := GoldCraftCoords(Coords.x, Coords.y);
Mouse(T.x, T.y, 8, 8, false);
end;
If CraftSilver then
FindTextTPA(52224, 0, MSX1, MSY1, MSX2, MSY2, SmeltText, StatChars, ClickRight);
if CraftSilver or CraftGold then
if WaitOptionMulti(['ke Al', 'e All', 'ke A', 'All'], 2000) then
begin
Timer := GetSystemTime+4000*WithDrawMain;
repeat
If not LoggedIn then
Exit;
if FindNormalRandoms then
Break;
if ClickContinue(true, true) then
Break;
Wait(300+random(200));
until( iCount(Item) < 1 ) or (GetSystemTime > Timer);
UpdateItem(CraftedItem, 2, false);
if iCount(CraftedItem) < 1 then
UpdateItem(CraftedItem, 2, True);
end;
if CannonBall then
begin
Timer := GetSystemTime+6666*WithDrawMain;
repeat
If not LoggedIn then
Exit;
if FindNormalRandoms then
Break;
if ClickContinue(true, true) then
Break;
Wait(300+random(200));
until( iCount(Item) < 1 ) or (GetSystemTime > Timer);
end;
end;
end;
//CannonBall end;
Inc(C);
if CannonBall then
if ( iCount(BaseItem) > 0 ) then
Continue;
until( iCount(BaseItem) < 1) or ( C > 5 );
Debug('Smelting Done.');
Result := true;
end;//With do end;
end;
Function Bank: boolean;
var
T: TPoint;
B: TBox;
TPA: TPointArray;
W, F, Timer, CBalls, WithDrawIs, A:integer;
Recorded: Boolean;
begin
Debug('Opening Bank...');
Timer := GetSystemTime + 40000;
if Playas[CurrentPlayer].AlKharid or Playas[CurrentPlayer].EdgeVille then
repeat
Wait(800+random(502));
if (PinScreen) or (BankScreen) Then
Break;
if Playas[CurrentPlayer].MyOpenBank() then
Break;
if OpenBankNPC then
Break;
until (GetSystemTime > Timer) or (not LoggedIn);
repeat
Wait(50+random(20));
if InRange(CountColor(2070783, 90, 147, 230, 211), 400, 430) then
if (Players[CurrentPlayer].Pin <> '') then
MouseBox(90, 147, 230, 211, 1)
else
begin
LogoutSeq('Bank Pin settings unknown');
Exit;
end;
until PinScreen or BankScreen or (not LoggedIn) or (GetSystemTime > Timer);
if (GetSystemTime > Timer) or (not LoggedIn) then
begin
SetLoc('Lost');
Exit;
end;
if PinScreen then
begin
Debug('Entering Pin...');
F := 0;
repeat
InPin(Players[CurrentPlayer].Pin);
Inc(F);
until (BankScreen) or ( F > 5 )
if (F > 5) then
begin
LogoutSeq('Failed to enter bank pin');
Exit;
end;
end;
if BankScreen then
with Playas[CurrentPlayer] do
begin
if (iCount(CraftedItem) < 26 ) and InvFull then
Inc(FailToSmelt)
else
FailToSmelt := 0;
if (FailToSmelt > 2) then
begin
LogoutSeq('Failed to smelt 2+ times');
Exit;
end;
repeat
Wait(100+random(100));
Until (CountColor(65535, MBX1, MBY1, MBX2, MBY2) > 20) or not LoggedIn;
if Not Recorded then
begin
if CannonBall then
begin
FindColors(TPA, 65535, MIX1, MIY1, MIX2, MIY2);
B := GetTPABounds(TPA);
CBalls := GetAmountBox(B);
Debug('Cannonballs: '+inttostr(CBalls));
MyVars[2] := MyVars[2] + CBalls;
if SmeltBars then
MyVars[1] := MyVars[1] + Round(CBalls / 4);
end;
if CraftGold or CraftSilver then
MyVars[1] := MyVars[1] + iCount(CraftedItem);
if SmeltBars and not CannonBall then
MyVars[1] := MyVars[1] + iCount(CraftedItem);
Debug('Record Count: '+ToStr(MyVars[1]));
Recorded := true;
end;
repeat
if not LoggedIn then
Exit;
if (InvCount > 0) then
begin
Debug('Banking...');
if HasCoalBag then
Deposit(2, 28, true)
else
DepositAll;
end;
BaseAmount := BaseAmount - WithDrawMain;
if (WithDrawSeco > -1) then
SecoAmount := SecoAmount - WithDrawSeco;
FixBank;
BankTab(1);
Debug('Withdrawing...');
Timer := GetSystemTime + 2000;
Repeat
A := GetAmountBox(BankIndexToMSBox(BankSlot1));
Wait(50+random(50));
until (A > 0) or (GetSystemTime > Timer);
if (A < (WithDrawMain+1)) and ((BaseAmount - WithDrawMain) < (WithDrawMain+1)) then
begin
CloseBank;
LogoutSeq('Ran out of primary');
Exit;
end;
If (A > (WithDrawMain+1)) then
BaseAmount := A;
if (WithDrawSeco > -1) then
begin
Timer := GetSystemTime + 2000;
Repeat
A := GetAmountBox(BankIndexToMSBox(BankSlot2));
Wait(50+random(50));
until (A > 0) or (GetSystemTime > Timer);
if (A < (WithDrawSeco+1)) and ((SecoAmount - WithDrawSeco) < (WithDrawSeco+1)) then
begin
CloseBank;
LogoutSeq('Ran out of secondary');
Exit;
end;
If (A > (WithDrawSeco+1)) then
SecoAmount := A;
end;
if HasCoalBag then//Coal Bag mod
if (WithDrawSeco > 0) then
begin
T := BankIndexToBankPoint(BankSlot2);
Withdraw(T.x, T.y, 0);
Timer := GetSystemTime + 60000;
Repeat
Wait(50);
if (GetSystemTime > Timer) then
Exit;
until (InvFull);
InvMouse(1, mouse_Right);//Coal ore
WaitOptionMulti(['Fill', 'ill', 'll C'], 1000);
Timer := GetSystemTime + 10000;
repeat
wait(50+random(100));
if InChat('already full') then
Deposit(2, 28, true);
if (GetSystemTime > Timer) then
Exit;
until (InvCount = 1);
end;
if (WithDrawMain > 26) then
WithDrawIs := 0
else
WithDrawIs := WithDrawMain;
T := BankIndexToBankPoint(BankSlot1);
Withdraw(T.x, T.y, WithDrawIs);
Timer := GetSystemTime + 60000;
Repeat
Wait(50);
until (GetSystemTime > Timer) or (InvCount >= WithDrawMain);
if (GetSystemTime > Timer) then
Exit;
UpdateItem(BaseItem, 2, False);
if iCount(BaseItem) <> WithDrawMain then
UpdateItem(BaseItem, 2, True);
if (WithDrawSeco > -1) then
if (InvCount >= WithDrawMain) then
begin
if HasCoalBag then
WithDrawIs := 0
else
begin
if WithDrawSeco > 14 then
WithDrawIs := 0
else
WithDrawIs := WithDrawSeco;
end;
T := BankIndexToBankPoint(BankSlot2);
Withdraw(T.x, T.y, WithDrawIs);
Timer := GetSystemTime + 60000;
Repeat
Wait(50);
until (GetSystemTime > Timer) or (InvCount >= 27);
UpdateItem(SecoItem, WithDrawMain+2, False);
if iCount(SecoItem) < 1 then
UpdateItem(SecoItem, WithDrawMain+2, True);
end;
if (GetSystemTime > Timer) then
Exit;
Inc(W);
until(InvCount >= 27) or (W > 10);
if (W > 10) then
begin
LogoutSeq('Banking failed');
Exit;
end;
end;
with Playas[CurrentPlayer] do
begin
if not (iCount(BaseItem) = WithDrawMain) then
begin
LogoutSeq('Counted BaseItem wrong');
Exit;
end;
if HasCoalBag then
A := 1
else
A := WithDrawSeco;
if (WithDrawSeco > -1) then
if not (iCount(SecoItem) >= A) then
begin
LogoutSeq('Counted SecoItem wrong');
Exit;
end;
end;
Debug('Done Banking...');
Case random(3) of
1: CloseBank;
end;
Inc(Players[CurrentPlayer].Banked);
result := true;
//if (ReportTime < GetSystemTime) then
Report;
end;
procedure DoChecks;
var
r: integer;
begin
FindNormalRandoms;
r := round(rs_GetCompassAngleDegrees*100.0);
Debugln('Compass: '+tostr(r/100.0)+' Degrees r := ' + ToStr(r));
if InRange(r, 300, 35699) then
begin
Debug('ClickNorth');
ClickNorth(SRL_ANGLE_HIGH);
end;
if (HowManyPlayers > 1) then
if ( GetSystemTime >= LogTime ) then
LogoutSeq('');
if Playas[CurrentPlayer].TakeSleeps then
TakeASleep(Playas[CurrentPlayer].SleepTime);
if Playas[CurrentPlayer].TakeBreaks then
TakeABreak;
if Playas[CurrentPlayer].RestForRun then
if Loc('banked') then
if not RunEnergy(28+random(13)) then
begin
Debug('Resting...');
RestUntil(50+random(45));
Debug('Done resting.');
end;
RunEnergy(20);
if not LoggedIn then
LogoutSeq('');
if not Playas[CurrentPlayer].DisableAntiBan then
r := Random(60);
if (r < 5) then
Debug('Antiban...');
case r of
10: wait(1000+random(10000));
1,2: if (Playas[CurrentPlayer].SmeltBars) or (Playas[CurrentPlayer].CannonBall) then
HoverSkill('smithing' ,false)
else
HoverSkill('crafting' ,false);
3: PickUpMouse;
4: if (HowManyPlayers = 1) then
if random(20) = 1 then
Wait(RandomRange(29000, 59000));//29-59secs
end;
if (r < 5) then
Debug('End Antiban.');
FindNormalRandoms;
end;
function ArrInStrEx(StrArr: TStringArray; Str: string): integer;//Needed for figuring out crafting
var
i: integer;
begin
Result := -1;
for i := 0 to High(StrArr) do
if Pos(StrArr[i], Str) > 0 then
begin
Result := i
Exit;
end;
end;
procedure EndOfScript;
begin
writeln('');
writeln('Thanks for using my AK Smelter!');
writeln('Please post proggies on forums!');
writeln(' -Narcle');
end;
procedure ScriptStartup;
var
i: integer;
CreateStr: string;
Gem, Kind: TIntegerArray;
begin
Debug('SMART & SRL Loading...');
Smart_Server := 1;
Smart_Members:= true;
Smart_Signed := true;
Smart_SuperDetail := false;
SetupSRL;
SRL_Procs[srl_OnLogIn] := @SetupPlayer;
SRL_Procs[srl_OnLogOut] := @Report;
AddOnTerminate('EndOfScript');
NumberOfPlayers(100);
DeclarePlayers;
if (Players[0].Name = '') then
begin
SafeInitForm;
if AKpf_SavePlayers then
SavePlayers(True);
if AKpf_Terminate then
TerminateScript;
end else
begin
HowManyPlayers := 0;
CurrentPlayer := 0;
DeclarePlayers;
for i := 0 to High(Players) do
if (Players[i].Name <> '') then
Inc(HowManyPlayers)
else
Break;
NumberOfPlayers(HowManyPlayers);
end;
Debug('Player count = '+ToStr(HowManyPlayers));
SetupSRLStats(18, stats_Username, stats_Userpass);
if (stats_Username = '') then
begin
stats_Username := 'Anonymous';
stats_Userpass := 'anon1337';
end;
Gem := [15, 40, 55, 70, 85, 100];//Base gem xp
Kind := [0, 5, 15, 10];//Kind modifiers, Dragonstone Amulet is +50
For i := 0 to HowManyPlayers - 1 do
With Playas[i] do// Playas[CurrentPlayer]
begin
CreateStr := LowerCase(Players[i].Strings[0]);
//All booleans should be false
If Length(Players[i].Name) < 1 then
begin
Writeln('Player '+ToStr(i)+' has no name, making inactive for now.');
Players[i].Active := false;
Continue;
end;
if Players[i].Nick = '' then
Players[i].Nick := Capitalize(Copy(Players[i].Name, 1, 4));
try
BankSlot1 := Players[i].Arrays[0][0];
BankSlot2 := Players[i].Arrays[0][1];
TakeBreaks := Players[i].Arrays[0][2];
TakeSleeps := Players[i].Arrays[0][3];
SleepTime := Players[i].Arrays[0][4];
RestForRun := Players[i].Arrays[0][5];
HasCoalBag := Players[i].Arrays[0][6];
DisableAntiBan := Players[i].Arrays[0][7];
except
Writeln('Player '+ToStr(i)+': Settings array set wrong, setting to defaults.');
BankSlot1 := 1;
BankSlot2 := 2;
TakeBreaks := true;
TakeSleeps := false;
SleepTime := '23:00';
RestForRun := true;
HasCoalBag := false;
DisableAntiBan := false;
end;
Case Lowercase(Players[i].Strings[1]) of
'al kharid': AlKharid := True;
'edgeville', 'edgeville (beta)': EdgeVille := True;
'neitiznot': Neitiznot := True;
else
begin
Writeln('Smelting location not choosen, setting to default (Al Kharid).');
Players[i].Strings[1] := 'al kharid';
AlKharid := true;
end;
end;
if AlKharid then
begin
ClickFurnace := @AKClickFurnace;
MyOpenBank := @AKOpenBank;
Players[i].Loc := 'lost';
end;
if EdgeVille then
begin
ClickFurnace := @EdgeClickFurnace;
MyOpenBank := @EdgeOpenBank;
Players[i].Loc := 'at bank';
end;
WithDrawSeco := -1;
if ArrInStr(['ring', 'necklace', 'bracelet', 'amulet'], CreateStr) then
begin
CraftGold := True;
statsStr := 'Gold Bars Crafted';
Coords.x := ArrInStrEx(['gold','sapphire','emerald','ruby','diamond','drag onstone'], CreateStr);
Coords.y := ArrInStrEx(['ring','necklace','amulet','bracelet'], CreateStr);
if (Coords.x < 0) or (Coords.y < 0) then
begin
Writeln('');
Writeln('Player '+ToStr(i)+' create string not setup correctly, please fix.');
TerminateScript;
end;
if (Pos('dragonstone', CreateStr)>0) and (Pos('amulet', CreateStr)>0) then
XPper := 150.0//Dragonstone Amulet xp
else
XPper := Gem[Coords.x]+Kind[Coords.y];
if (Coords.x = 0) then
WithDrawMain := 28
else
begin
WithDrawMain := 14;
WithDrawSeco := 14;
end;
end;
if (Pos('silver', CreateStr) > 0) and not(Pos('bars', CreateStr) > 0) then
begin
CraftSilver := True;
XPper := 50.0;
WithDrawMain := 28;
statsStr := 'Silver Bars Crafted';
Case CreateStr of
'silver holy symbol':
SmeltText := 'aradom';
'silver unholy symbol':
SmeltText := 'nholy';
'silver sickle':
SmeltText := 'ickle';
'silver tiara':
begin
SmeltText := 'iara';
XPper := 52.5;
end;
else
begin
Writeln('');
Writeln('Player '+ToStr(i)+' create string not setup correctly, please fix.');
TerminateScript;
end;
end;
end;
BagCount := 28;
if (not CraftSilver) and (not CraftGold) then
Case CreateStr of
'cball','cballs', 'cannonballs', 'cannonballs from ores':
begin
BaseDivi := 3;
XPper := 17.5;//steel
SmeltText := 'teel';
SmeltBars := True;
CannonBall := True;
statsStr := 'Steel Bars Melted';
end;
'steeltoball', 'bartoballs', 'steeltocballs', 'steeltoballs', 'cannonballs from bars':
begin
BaseDivi := 1;
XPper := 17.5;//steel
CannonBall := True;
HasCoalBag := false;
end;
'iron', 'iron bars':
begin
BaseDivi := 1;
SmeltText := 'ron';//set
XPper := 12.5;
SmeltBars := True;
statsStr := 'Iron Bars Melted';
HasCoalBag := false;
end;
'steel', 'steel bars':
begin
BaseDivi := 3;
SmeltText := 'teel';//set
XPper := 17.5;
SmeltBars := True;
statsStr := 'Steel Bars Melted';
end;
'mith','mithril', 'mithril bars':
begin
BaseDivi := 5;
SmeltText := 'ithril';
XPper := 30.0;
SmeltBars := True;
statsStr := 'Mithril Bars Melted';
end;
'addy','addamite','addamantite','addamantite bars':
begin
BaseDivi := 7;
SmeltText := 'damant';//set
XPper := 37.5;
SmeltBars := True;
statsStr := 'Adamant Bars Melted';
end;
'rune','runite', 'runite bars':
begin
BaseDivi := 9;
SmeltText := 'une';//set
XPper := 50.0;
SmeltBars := True;
statsStr := 'Runite Bars Melted';
end;
'copper', 'tin', 'bronze', 'bronze bars':
begin
BaseDivi := 2;
SmeltText := 'ronze';//set
XPper := 6.2;
SmeltBars := True;
statsStr := 'Bronze Bars Melted';
HasCoalBag := false;
end;
'gold', 'gold bars':
begin
BaseDivi := 1;
SmeltText := 'old'
XPper := 22.5;
SmeltBars := True;
statsStr := 'Gold Bars Melted';
HasCoalBag := false;
end;
'silver', 'silver bars':
begin
BaseDivi := 1;
SmeltText := 'ilver';
XPper := 13.7;
SmeltBars := True;
statsStr := 'Silver Bars Melted';
HasCoalBag := false;
end;
else
begin
Writeln('');
Writeln('Player '+ToStr(i)+' create string not setup correctly, please fix.');
TerminateScript;
end;
end;
if WithDrawMain < 1 then
begin
if HasCoalBag then
BagCount := BagCount + 26;//Coal bag takes one spot so -1 for invy space
WithDrawMain := BagCount / BaseDivi;
if BaseDivi <> 1 then
WithDrawSeco := (BaseDivi-1)*WithDrawMain
else
WithDrawSeco := -1;
end;
Debug('WithDrawMain: '+ToStr(WithDrawMain));
Debug('WithDrawSeco: '+ToStr(WithDrawSeco));
end;
for i := 0 to HowManyPlayers-1 do
if Players[i].Active then
begin
CurrentPlayer := i;
Break;
end;
Writeln('CurrentPlayer = '+Players[CurrentPlayer].Name);
WRiteln('AK Smelter v'+version);
Writeln(' By Narcle');
Debug('Runescape Loading...');
While not RSReady do
Wait(100);
Debug('Logging in...');
ResetTimer('Break');
LoginPlayer;
end;
begin
ScriptStartup;
repeat
if Playas[CurrentPlayer].AlKharid then
Case Players[CurrentPlayer].Loc of
'lost':
if not AKFindPosition then
LogoutSeq('Couldn''t find position');
'at bank':
if Bank then
SetLoc('banked');
'banked':
if ToAKCactus(true) then
SetLoc('to furnace');
'to furnace':
if ToAKFurnace then
SetLoc('at furnace');
'at furnace':
if Smelt then
SetLoc('smelted');
'smelted':
if ToAKCactus(False) then
SetLoc('to bank');
'to bank':
if ToAKBank then
SetLoc('at bank');
end;
if Playas[CurrentPlayer].Edgeville then
Case Players[CurrentPlayer].Loc of
'at bank':
if Bank then
SetLoc('to furnace');
'to furnace':
if ToEdgeFurnace then
SetLoc('at furnace');
'at furnace':
if Smelt then
SetLoc('to bank');
'to bank':
if ToEdgeBank then
SetLoc('at bank');
'lost': LogoutSeq('Couldn''t find position');
end;
DoChecks;
until (AllPlayersInactive);
end.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.