SRL Archive - Archive

nivek1989 - SRL Member Application


Kevin

2013-01-06 23:40:02

How Long have You Played Runescape?
7 Year(s) (granted, I probably wasn't playing 5 of these 7 years, but that is how old my main account is).


Are you affilated in anyway with Jagex LTD?
No

Were you Referred to SRL?

No

What is your general programming knowledge?
C/C++, C#, Java, MIPS, ARM, SQL, Verilog and Javascript.


Are you a member of any other communities?
Nope.


Tell us about yourself…
From: nivek1989
I live in the United States, more specifically Minnesota (although that's only been true ~8 months, I'm from Iowa). I just graduated college with a degree in Computer Engineering and picked up Runescape again alongside that for two reasons. I can play it in the background while on Skype with my girlfriend without her getting annoyed like if I played anything else and I wanted to practice writing my own bots just because I can. I started doing just that in Java and I got a basic smelter down, but it wasn't terribly accurate and it took forever creating my own framework as I went along. While researching new techniques of faster methods of reading pixels on the screen and the possibility of simulating a mouse (so I could continue to use my own mouse while running the script), I finally stumbled across a YoHoJo introduction to Simba which linked me to Villavu.

As for outside interests, I enjoy bowling, tennis, racquetball, League of Legends, social interaction, and well… most video games actually, while heavily preferring multiplayer games.



Please show us one (or multiple) of your scripts.
Little more updated with better standards than the second.

program BeginnerThiever;
{$DEFINE SMART}
{$i SRL/srl.simba}
{$i ObjectDTM/ObjDTMInclude.simba}
{$I SRL/SRL/Skill/Fighting.Simba}
const
Version = '1.0';
numDebugMessages = 5;
var
TimeBegan, StartingXP, minutesTillBreakMin, minutesTillBreakMax, breakLengthMin, breakLengthMax, breakLength, timeToBreak, GoldEarned, minutesTillDone, timeDone, HealthToEat: integer;
SmartDebug, TextDebug, LetDie, EverFinish: Boolean;
PlayerName, PlayerPassword: String;
DebugMessages: array[0..(numDebugMessages-1)] of String;
FoodLocations: array[0..27] of boolean;

procedure UserSettings;
begin
LetDie:= True; //A death based return exists, so death does not hurt script. However if you prefer to eat food/logout if low, set false.
HealthToEat:= 100; //Low health recommended as pickpocket failures result in a loss of health based on remaining. (More efficient the lower this number is. do not go less than 11 though!)
SmartDebug:= False;
TextDebug:= False;
minutesTillBreakMin:= 180; //How long script runs before a break is based off a random value between these two values.
minutesTillBreakMax:= 210;
breakLengthMin:= 15; //How long script breaks for is based off a random value between these two values in minutes.
breakLengthMax:= 30;
EverFinish:= True; //Set to false if you want this script to run forever. Makes the minutesTillDone variable useless.
minutesTillDone:= 600;
PlayerName:= '';
PlayerPassword:= '';
end;

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

Players[0].Name := PlayerName;
Players[0].Pass := PlayerPassword;
Players[0].Pin := '';
Players[0].Nick := '';
Players[0].Active:=True;
end;

procedure Updater();//Most work taken from SuperUser and edited for my setup.
var
version_remote: string;
fh: integer;
begin
WriteLn('Update check...');
version_remote := GetPage('https://beginner-thiever.googlecode.com/svn/trunk/version.txt');
if version_remote <> VERSION then
begin
if MessageBox('Kevin''s Beginner Thiever v' + version_remote + ' is available. Do you wish to update?', 'Newer version available', 1) = 1 then
begin
try
begin
fh := Rewritefile(ScriptPath + 'BeginnerThiever.simba', true);
WriteFileString(fh, GetPage('https://beginner-thiever.googlecode.com/svn/trunk/BeginnerThiever.simba'));
MessageBox('Successfully updated Kevin''s Beginner Thiever to v' + version_remote + '! Please reload the script.', 'Success', 0);
end;
except
begin
MessageBox('An error occurred while trying to update!', 'Error', 0);
end;
finally
begin
CloseFile(fh);
end;
end;
end;
TerminateScript();
end;
WriteLn('No update needed.');
end;

procedure RunTextDebug(Message: String);
begin
if(TextDebug)then
begin
WriteLn(Message);
end;
end;

procedure RunSmartDebug(Message: String);
var
i: integer;
begin
if(SmartDebug=True)then
begin
i:= numDebugMessages;
while(i >= 2) do
begin
DebugMessages[i-1]:= DebugMessages[i-2];
Dec(i);
end;
DebugMessages[0]:= Message;
SMART_ClearCanvas;
for i:=0 to (numDebugMessages-1) do//Draw the list of debug order newest at top.
begin
SMART_DrawTextEx(False, 12, (120 + (15 * i)), LoginChars, DebugMessages[i], 13158600);
end;
end;
end;

procedure FreeEverything;
begin
SMART_FreeDebug;
end;

procedure MiniBreak;
var
timeStarted: integer;
begin
RunSmartDebug('MiniBreak');
logout;
MarkTime(timeStarted);
repeat
SMART_DrawTextEx(True, 12, 250, LoginChars, MsToTime((TimeFromMark(timeStarted) - breakLength), Time_Bare), 13158600);
until(TimeFromMark(timeStarted) > breakLength);
TimeToBreak:= GetSystemTime + (RandomRange(minutesTillBreakMin, minutesTillBreakMax) * 60000);
breakLength:= (RandomRange(breakLengthMin, breakLengthMax) * 60000);
WriteLn('Time Script Started: ' + MsToTime(timeBegan, Time_Bare));
WriteLn('Time Method Started: ' + MsToTime(timeStarted, Time_Bare));
WriteLn('Time Current: ' + MsToTime(GetSystemTime, Time_Bare));
WriteLn('Time Till Break: ' + MsToTime(TimeToBreak, Time_Bare));
SMART_ClearCanvas;
loginPlayer;
FindNormalRandoms;
ToggleMoneyPouch(False);
ToggleXPBar(True);
ExitSquealOfFortune();
ClickNorth(SRL_ANGLE_HIGH);
end;

procedure DetermineFoodLocations;
var
i: integer;
begin
for i:=1 to 28 do
begin
FoodLocations[i-1]:= False;
if(ExistsItem(i))then
begin
InvMouse(i, 3);
if (IsUpText('Eat')) then
begin;
FoodLocations[i-1] := True;
end;
end;
end;
end;

procedure SetupVariables;
var
i: integer;
begin
timeToBreak:= GetSystemTime + (RandomRange(minutesTillBreakMin, minutesTillBreakMax) * 60000);
timeDone:= GetSystemTime + (minutesTillDone * 60000);
GoldEarned:= 0;
breakLength:= (RandomRange(breakLengthMin, breakLengthMax) * 60000);
if(SmartDebug=True)then
begin
for i:=0 to (numDebugMessages-1) do
begin
DebugMessages[i]:= '';
end;
end;
DetermineFoodLocations;
end;

procedure FailOutOfCode(message: String);
begin
If(not (LoggedIn)) then
begin
LogInPlayer;
end else
begin
WriteLn(message);
Logout;
TerminateScript;
end;
end;

procedure EatFood
var
i: integer;
ate: boolean;
begin
for i:=1 to 28 do
begin
if(FoodLocations[i-1])then
begin
InvMouse(i, moust_left);
FoodLocations[i-1] := False;
ate:= True;
Break;
end;
end;
if(not ate)then
begin
FailOutOfCode('Ran out of food and low on health!');
end;
end;

procedure WaitUntilThere;
var
x: integer;
begin
x:=0;
repeat
Wait(randomrange(10,20));
Inc(x);
until((not IsMoving) or (x > 500));
if(x=500)then
begin
FailOutOfCode('We never stopped moving.');
Exit;
end;
end;

procedure SearchSymbol(var count, x, y: integer; symbol: string);
begin
if(FindSymbol(x, y, symbol))then
begin
Inc(count);
end;
end;

procedure GoToDestination(mousex, mousey, ranx, rany: integer);
begin
RunSmartDebug('GoToDestination');
Mouse(mousex, mousey, ranx, rany, True);
wait(1000+random(50));
WaitUntilThere;
end;

procedure TeleportToTaverley;
var
x, y, SymbolCount: integer;
begin
RunSmartDebug('TeleportToTaverley');
SymbolCount:= 0;
SearchSymbol(SymbolCount, x, y, 'water');
SearchSymbol(SymbolCount, x, y, 'portal');
SearchSymbol(SymbolCount, x, y, 'bar');
SearchSymbol(SymbolCount, x, y, 'lodestone');
SearchSymbol(SymbolCount, x, y, 'quest');
if(SymbolCount<= 2)then
begin
LodestoneTeleport('Taverley');
wait(randomrange(14500,15500));
end else
begin
GoToDestination(x, y, 4, 4);
end;
end;

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

if not(FindColorsTolerance(arP, 13659714, MSX1, MSY1, MSX2, MSY2, 23)) then
begin
RunTextDebug('Failed to find the color, nothing similar to the merchant was found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (R >= 47) and (R <= 140) and (G >= 48) and (G <= 197) and (B >= 109) and (B <= 251) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 5.11) and (X <= 47.66) and (Y >= 3.93) and (Y <= 51.89) and (Z >= 15.22) and (Z <= 97.94) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;

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

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

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

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

GetMousePos(fx, fy);
end;

procedure PickpocketMerchants;
var
x, y, i, j, k: integer;
FoundMerch: boolean;
money, chat: String;
GoldSuccess: boolean;
begin
RunSmartDebug('PickpocketMerchants');
FoundMerch:= False;
for i:=0 to 4 do
begin
money:='0';
findMod;
findSpinTicket;
GoldSuccess:= True;
if(FindMerchant(x, y))then
begin
FoundMerch:= True;
ClickMouse2(False);
if(WaitOptionMulti(['pocket','ocke','ick'],1000))then
begin
wait(650);
repeat
wait(randomrange(10,20));
until(not ismoving);
x:=0;
repeat
wait(randomrange(10,20));
Inc(x);
until(InFight or (x > 200) or InChat('coins have been added'));
if(InFight)then
begin
if ((not LetDie) and (GetMMLevels('hp', chat) < HealthToEat)) then
begin
EatFood;
end;
repeat
wait(randomRange(10,20));
until (not InFight);
end else if(InChat('coins have been added'))then
begin
for j:=8 downto 4 do
begin
chat:= GetChatBoxText(8, clMessage);
chat:= Replace(chat, ' coins have been added to your money pouch', '');
for k:=1 to (Length(chat) -1) do
begin
try
money[k]:= chat[k];
except
GoldSuccess:= False;
end;
end;
if(GoldSuccess)then
begin
RunTextDebug('New gold this steal: ' + money + '.');
GoldEarned:= GoldEarned + StrToInt(money);
break;
end;
end;
end;
end;
end;
end;
if(not FoundMerch) then
begin
RunTextDebug('Did not find merchant');
TeleportToTaverley;
end;
end;

procedure ProgressReport;
var
ThiefExp, newSteals, ThiefExpHr, TimeRan, Steals, StealsHr, GoldHour: integer;
begin
ClearDebug;
ThiefExp:= GetXpBarTotal - StartingXp;
TimeRan:= ((1 + GetSystemTime - TimeBegan) / 1000); //Seconds
newSteals:= Steals;
Steals:= ThiefExp / 8;
RunTextDebug('New thefts: ' + intToStr(newSteals));
StealsHr:= Round((Steals * 3600) / TimeRan);
ThiefExpHr:= Round((ThiefExp * 3600) / TimeRan);
GoldHour:= Round((GoldEarned * 3600) / TimeRan);
WriteLn('*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
WriteLn('*Kevin''s Beginner Thiever.');
WriteLn('*Time elapsed: ' + TimeRunning);
WriteLn('*We have gained ' + IntToStr(ThiefExp) + ' Thieving Experience! (' + IntToStr(ThiefExpHr) + ' per hour)');
WriteLn('*We have successfully stolen ' + IntToStr(Steals) + ' times! (' + IntToStr(StealsHr) + ' per hour)');
WriteLn('*We have earned ' + IntToStr(GoldEarned) + ' gold! (' + IntToStr(GoldHour) + ' per hour)');
WriteLn('*Our next break will start in ' + MsToTime((TimeToBreak - GetSystemTime), Time_Bare));
if(EverFinish)then
begin
WriteLn('*Script will finish in ' + MsToTime((TimeDone - GetSystemTime), Time_Bare));
end;
WriteLn('*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
end;

begin
Updater;
Smart_FixSpeed := True;
SRL_SixHourFix := True;
SetUpSRL;

UserSettings;
SetupVariables;
ActivateClient;
DeclarePlayers;
LoginPlayer;
AddOnTerminate('FreeEverything');

FindNormalRandoms;

ToggleMoneyPouch(False);
ToggleXPBar(True);
StartingXP:= GetXPBarTotal;
TimeBegan:= GetSystemTime;
ExitSquealOfFortune();
ClickNorth(SRL_ANGLE_HIGH);

repeat
FindSpinTicket;
ProgressReport;
PickpocketMerchants;
if(TimeToBreak < GetSystemTime)then
begin
MiniBreak;
end;
if((EverFinish) and (TimeDone < GetSystemTime))then
begin
FailOutOfCode('Successfully completed your run!');
end;
until(False);
end.


program EdgevilleCrafter;
{$DEFINE SMART}
{$i SRL/srl.simba}
{$i ObjectDTM/ObjDTMInclude.simba}

const
numDebugMessages = 5;
VERSION = '1.6';
var
TimeBegan, StartingXP, Stuck, CBXMin, CBXMax, CBYMin, CBYMax, actionsPerRun, runs, goalRuns, UncutGemValue, CutGemValue, GoldOreValue, GoldBarValue, CraftedItemValue, GemDTM, GoldBarDTM, GoldOreDTM, WalkToBankDTM, BankDTM, WalkToFurnaceDTM, FurnaceDTM: integer;
xpPerJewelryAction, xpPerGemAction, xpPerSmeltingAction: Double;
firstRun, leeching, doneRunning, cuttingGems, makingJewelry, smeltingGold, enchanting, debugMode: Boolean;
CraftingWhat, GemEncrusted, enchantment: String;
DebugMessages: array[0..(numDebugMessages-1)] of String;
aFound: extended;
///////////////////////////PLAYER SETUP//////////////////////////////////

// Gold bars or ores or gems MUST be visible in bank (of currently open tab)!

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

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

procedure UserSettings;
var
goalActions: integer;
goldSmithingGauntlets: Boolean;
begin
CraftingWhat := 'Ring'; //Ring, Amulet, Necklace, Bracelet
GemEncrusted := 'Emerald'; //None, Sapphire, Emerald, Ruby, Diamond, Dragonstone

goalRuns := 0; //How many trips?
goalActions := 15000; //How many items? Will change trip amount so if last trip
//would not have a full trip, it won't do it.
//Also leave at 0 to run until all gone.

makingJewelry := True;
cuttingGems := False; //Does nothing for now, will matter soon
smeltingGold := False; //Do you want to smelt gold (will EVENTUALLY be done same trip as making jewelry if both set to true)
enchanting:= False;
goldSmithingGauntlets := False; //Do you have them equipped currently? Future version should withdraw for you if needed.
debugMode := True; //Prints debug info to SMART screen. Use for debugging issues.
//Don't edit below this line!
if(makingJewelry = True) and (not (GemEncrusted = 'None')) then
begin
actionsPerRun := 14;
end else if (enchanting=True) then
begin
actionsPerRun := 27;
end else begin
actionsPerRun := 28;
end;

if(goalActions > 0)then
begin
goalRuns:= (goalActions / actionsPerRun);
end else if (goalRuns = 0) then
begin
goalRuns := 100000;
end;
if(smeltingGold = True) then
begin
if(goldSmithingGauntlets = True) then
begin
xpPerSmeltingAction := 56.2;
end else begin
xpPerSmeltingAction := 22.5;
end;
end;
end;

//Bounds of the Crafting scroll bar (Crafting Menu Scroll)
const
CMSX1 = 228;
CMSX2 = 231;
CMSY1 = 87;
CMSY2 = 293;
CMSY3 = 205; //Bottom of scroll bar when at top
CMSY4 = 173; //Top of scroll bar when at bottom
//Bounds of the top left selectable crafting box (Crafting Box Position)
const
CBPX1 = 24;
CBPX2 = 63;
CBPY1 = 80;
CBPY2 = 119;
//Distance between crafting boxes (Crafting Box Distance)
const
CBDX = 50;
CBDY = 50;
//Absolute Y value limit for crafting box (Craftin Box Maximum)
const
CBMY = 307;
//Crafting action bar boundaries
const
CABX1 = 97;
CABX2 = 421;
CABY1 = 77;
CABY2 = 165;
//Action Bar button 1
const
ABX1 = 45;
ABX2 = 78;
ABY1 = 305;
ABY2 = 338;

function GetItemValue(id: integer): integer; //Written by SuperIrony, edited by me.
var
s: string;
begin
s := GetPage('http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=' + IntToStr(id));
s := Copy(s, Pos('guide price', s) + 22, 9);
s := ReplaceRegExpr('[^0-9KkMm\.]', s, '', true);

if (Pos('k', s) > 0) or (Pos('K', s) > 0) then begin
s := Copy(s, 0, Length(s) - 1);
result := Round(StrToFloat(s) * 1000);
end else if (Pos('m', s) > 0) or (Pos('M', s) > 0) then begin
s := Copy(s, 0, Length(s) - 1);
result := Round(StrToFloat(s) * 1000000);
end else begin
result := Round(StrToFloat(s));
end;
end;

procedure Updater();//Most work taken from SuperUser and edited for my setup.
var
version_remote: string;
fh: integer;
begin
WriteLn('Update check...');
version_remote := GetPage('https://edgeville-aio-crafter.googlecode.com/svn/trunk/version.txt');
if version_remote <> VERSION then
begin
if MessageBox('Kevin''s Edgeville AIO Crafter v' + version_remote + ' is available. Do you wish to update?', 'Newer version available', 1) = 1 then
begin
try
begin
fh := Rewritefile(ScriptPath + 'EdgevilleCrafter.simba', true);

WriteFileString(fh, GetPage('https://edgeville-aio-crafter.googlecode.com/svn/trunk/EdgevilleCrafter.simba'));

MessageBox('Successfully updated Kevin''s Edgeville AIO Crafter to v' + version_remote + '! Please reload the script.', 'Success', 0);
end;
except
begin
MessageBox('An error occurred while trying to update!', 'Error', 0);
end;
finally
begin
CloseFile(fh);
end;
end;
end;
TerminateScript();
end;
WriteLn('No update needed.');
end;

procedure SetupVariables;
var
i: integer;
begin
if(cuttingGems = True) then
begin
WriteLn('Gem cutting is not yet implemented completely! Please don''t try.');
TerminateScript;
end;
if(enchanting = True) then
begin
if((smeltingGold=True) or (makingJewelry=True) or (cuttingGems=True)) then
begin
WriteLn('Enchanting is not supported in the same run as the other activities.');
TerminateScript;
end;
end;

doneRunning := false;
firstRun := true;
runs := 0;

WalkToBankDTM := DTMFromString('mrAAAAHic42BgYGAFYjUgVgBiNigfBliAWAaIdYFYHiqmCcVKULFAH3sG72IzBqVIITBOjvZleP+XE47/A9XIIWENND4jEDPhwTAAAHpLDRw=');
BankDTM := DTMFromString('m6wAAAHic42ZgYFAD4kgGCNAAYiYg9gRieyAWQKLnATELAypgA2J2IOYAYlYgZoRikDpfT2uGD2/OM1y9uJ3hxdMTYD4ybu/qBWM3DwUGEaB6OSQsgoaRxUHmM0MxE5KdMMwExayoTgUA2PATHg==');
WalkToFurnaceDTM := DTMFromString('mlwAAAHicY2dgYDABYh0g5gZieSA2BWIlBgiQhtJcQGwExK5A7ATEQkD84cF9hsAALzA2ThBmaOudxuBTYMygHMbP8B8oL4eENZDYjEiYCQ1DAQDhRgvs');
FurnaceDTM := DTMFromString('mlwAAAHicY2dgYDBhZGBwAGJ7KO0NxAFAHAHEMxgguAmIVwPxdCCeAsTzgDgtKYKhV1aYwdragsHAQI+hUwbCnikvymAElMeFgcYyMOHAUAAAq60M0g==');

GoldBarValue := GetItemValue(2357);
if(makingJewelry = True) then
begin
GoldBarDTM := DTMFromString('mlwAAAHicY2dgYHBiYmCwB2J3IHYFYmcgDgRiEyB+AJR/BsSPgfgWEH8A4odA/AKIFzWIMcR48jJcWi4L5DGhYBEgCcOsaJgRD4YCAN+0DAY=');
end;
if(smeltingGold = True) then
begin
GoldOreDTM := DTMFromString('mAAEAAHic42FgYPgKxIyMDAz/gfRPIP4MxG+B+BUQPwHil0D8B4g/APEnIJ4HxHOAeBEQLwXi1UC8AsqeD8WLgXg5EM8G4i39kkCSCSeOcDNkWNMpAaYnlYgycDHgB5JomJFEjAwAkOoX9w==');
GoldOreValue := GetItemValue(444);
end;

if(cuttingGems= True) then //Use uncut DTMs
begin
case GemEncrusted of
'Sapphire': begin
GemDTM := DTMFromString('');
xpPerGemAction := 50;
UncutGemValue:= GetItemValue(1623);
end;
'Emerald': begin
GemDTM := DTMFromString('');
xpPerGemAction := 67.5;
UncutGemValue:= GetItemValue(1621);
end;
'Ruby': begin
GemDTM := DTMFromString('');
xpPerGemAction := 85;
UncutGemValue:= GetItemValue(1619);
end;
'Diamond': begin
GemDTM := DTMFromString('');
xpPerGemAction := 107.5;
UncutGemValue:= GetItemValue(1617);
end;
'Dragonstone': begin
GemDTM := DTMFromString('');
xpPerGemAction := 137.5;
end;
end;
end else begin //Cut DTMs
xpPerGemAction := 0;
case GemEncrusted of
'None': begin
CBYMin:= CBPY1;
CBYMax:= CBPY2;
CutGemValue:= 0;
end;
'Sapphire': begin
GemDTM := DTMFromString('mlwAAAHicY2dgYJAAYnkglgJiASDmAWJ+KFsMiIWBWA6IFaBqhKDifAKpQJIJAwuJNjMYMWAHIHFGPBgKAAcXAt8=');
CBYMin:= (CBPY1 + CBDY);
CBYMax:= (CBPY2 + CBDY);
CutGemValue:= GetItemValue(1607);
end;
'Emerald': begin
GemDTM := DTMFromString('mrAAAAHic42BgYHAEYk8gdgViSyA2A2IrIHaB0mJALAzEskAsD8SSQCwIxOJQNm8SP5BkwsAgcaFmUQYjBuzACIoZCWAYAAA/wQUM');
CBYMin:= (CBPY1 + (CBDY * 2));
CBYMax:= (CBPY2 + (CBDY * 2));
CutGemValue:= GetItemValue(1605);
end;
'Ruby': begin
GemDTM := DTMFromString('mrAAAAHic42BgYJgLxEuAeDGUPRmIpwDxNCCeB8TFQJwPxBVAXAPE1VB+CRCXAXGIIA+QZMLAq5LjwXJGDNiBERQzEsAwAACWmAuF');
CBYMin:= (CBPY1 + (CBDY * 3));
CBYMax:= (CBPY2 + (CBDY * 3));
CutGemValue:= GetItemValue(1603);
end;
'Diamond': begin
GemDTM := DTMFromString('mwQAAAHic42RgYOAGYn4gZoViEGABYh4gFgFiYSBmA2J2IOaCynMAsQBUH0iMCYiry8rAeMncuVARTMwFVQ8zBxtgJALDAQCDYQWO');
CBYMin:= (CBPY1 + (CBDY * 4));
CBYMax:= CBMY;
CutGemValue:= GetItemValue(1601);
end;
'Dragonstone': begin
GemDTM := DTMFromString('');
end;
end;
end;

case CraftingWhat of
'Ring':
begin
CBXMin:= CBPX1;
CBXMax:= CBPX2;
case GemEncrusted of
'None': begin
xpPerJewelryAction := 15;
CraftedItemValue:= GetItemValue(1635);
end;
'Sapphire': begin
xpPerJewelryAction := 40;
CraftedItemValue:= GetItemValue(1637);
enchantment:= 'Ring of';
end;
'Emerald': begin
xpPerJewelryAction := 55;
CraftedItemValue:= GetItemValue(1639);
enchantment:= 'Ring of';
end;
'Ruby': begin
xpPerJewelryAction := 70;
CraftedItemValue:= GetItemValue(1641);
enchantment:= 'Ring of';
end;
'Diamond': begin
xpPerJewelryAction := 85;
CraftedItemValue:= GetItemValue(1643);
enchantment:= 'Ring of';
end;
'Dragonstone': xpPerJewelryAction := 100;
end;
end;
'Necklace':
begin
CBXMin:= (CBPX1 + CBDX);
CBXMax:= (CBPX2 + CBDX);
case GemEncrusted of
'None': begin
xpPerJewelryAction := 20;
CraftedItemValue:= GetItemValue(1654);
end;
'Sapphire': begin
xpPerJewelryAction := 55;
CraftedItemValue:= GetItemValue(1656);
enchantment:= 'Games N';
end;
'Emerald': begin
xpPerJewelryAction := 60;
CraftedItemValue:= GetItemValue(1658);
enchantment:= 'Binding';
end;
'Ruby': begin
xpPerJewelryAction := 75;
CraftedItemValue:= GetItemValue(1660);
enchantment:= 'Digsite';
end;
'Diamond': begin
xpPerJewelryAction := 90;
CraftedItemValue:= GetItemValue(1662);
enchantment:= 'Phoenix';
end;
'Dragonstone': xpPerJewelryAction := 105;
end;
end;
'Amulet':
begin
CBXMin:= (CBPX1 + (CBDX * 3));
CBXMax:= (CBPX2 + (CBDX * 3));
case GemEncrusted of
'None': begin
xpPerJewelryAction := 30;
CraftedItemValue:= GetItemValue(1673);
end;
'Sapphire': begin
xpPerJewelryAction := 65;
CraftedItemValue:= GetItemValue(1675);
enchantment:= 'Amulet O';
end;
'Emerald': begin
xpPerJewelryAction := 70;
CraftedItemValue:= GetItemValue(1677);
enchantment:= 'Amulet O';
end;
'Ruby': begin
xpPerJewelryAction := 85;
CraftedItemValue:= GetItemValue(1679);
enchantment:= 'Amulet O';
end;
'Diamond': begin
xpPerJewelryAction := 100;
CraftedItemValue:= GetItemValue(1681);
enchantment:= 'Amulet O';
end;
'Dragonstone': xpPerJewelryAction := 150;
end;
end;
'Bracelet':
begin
CBXMin:= (CBPX1 + (CBDX * 2));
CBXMax:= (CBPX2 + (CBDX * 2));
case GemEncrusted of
'None': begin
xpPerJewelryAction := 25;
CraftedItemValue:= GetItemValue(11069);
end;
'Sapphire': begin
xpPerJewelryAction := 60;
CraftedItemValue:= GetItemValue(11072);
enchantment:= 'Bracelet O';
end;
'Emerald': begin
xpPerJewelryAction := 65;
CraftedItemValue:= GetItemValue(11076);
enchantment:= 'Castle W';
end;
'Ruby': begin
xpPerJewelryAction := 80;
CraftedItemValue:= (11085);
enchantment:= 'Inoculation';
end;
'Diamond': begin
xpPerJewelryAction := 95;
CraftedItemValue:= GetItemValue(11092);
enchantment:= 'Forinthry';
end;
'Dragonstone': xpPerJewelryAction := 110;
end;
end;
end;

if(debugMode=True)then
begin
for i:=0 to (numDebugMessages-1) do
begin
DebugMessages[i]:= '';
end;
end;
end;

procedure Leech;
begin
if(leeching) then
begin
Wait(5000);
end;
end;

procedure AntiBan;
begin

if not(LoggedIn)then
Exit;

case Random(80) of
0: RandomRClick;
1: HoverSkill('Smithing', false);
2: PickUpMouse;
3: begin
RandomMovement;
ClickNorth(SRL_ANGLE_HIGH);
end;
4: HoverSkill('Crafting', false);
5: ExamineInv;
6: RandomRClick;
7: PickUpMouse;
8: RandomMovement;
9: BoredHuman;
10:wait(25000+random(5000));//slight afk, up to 20 seconds after done
end;

end;

procedure RunDebug(Message: String);
var
i: integer;
begin
if(debugMode=True)then
begin
i:= numDebugMessages;
while(i >= 2) do
begin
DebugMessages[i-1]:= DebugMessages[i-2];
Dec(i);
end;
DebugMessages[0]:= Message;
SMART_DrawTextEx(True, 0, 0, LoginChars, '', 13158600);//This will clear the debug screen.
for i:=0 to (numDebugMessages-1) do//Draw the list of debug order newest at top.
begin
SMART_DrawTextEx(False, 12, (120 + (15 * i)), LoginChars, DebugMessages[i], 13158600);
end;
end;
end;

procedure FreeMyDTMs;
begin
FreeDTM(FurnaceDTM);
FreeDTM(WalkToBankDTM);
FreeDTM(BankDTM);
FreeDTM(WalkToFurnaceDTM);
SMART_FreeDebug();
if(makingJewelry = True) then
begin
FreeDTM(GoldBarDTM);
if not (GemEncrusted = 'None') then
begin
FreeDTM(GemDTM);
end;
end;
if(smeltingGold = True) then
begin
FreeDTM(GoldOreDTM);
end;
end;

procedure FailOutOfCode(message: String);
begin
If(not (LoggedIn)) then
begin
LogInPlayer;
end else
begin
WriteLn(message);
FreeMyDTMs;
Logout;
TerminateScript;
end;
end;

procedure InitializeBankX(action, actionLetter, quantity: String);
var
totalAction, totalActionLetter: String;
x: integer;
begin
totalAction:= action + '-X';
totalActionLetter:= actionLetter + '-X';
if WaitOptionMulti([totalAction, totalActionLetter], 500) then
begin
x := 0;
while (x <= 200) and (not (InRange(CountColorTolerance(0, 250, 396, 307, 410, 1), 155, 165))) do
begin
Wait(50);
Inc(x);
end;
Wait(randomRange(50,100));
TypeSend(quantity);
end;
end;

procedure RandomizeBankX(action, actionLetter, quantity: String);
var
totalAction, actionShrunk: String;
begin
totalAction:= action + '-';
actionShrunk:= totalAction + '-' + quantity;
case Random(3) of
0:begin
WaitOptionMulti([action+quantity, actionShrunk], 500);
end;
1:begin
WaitOptionMulti([action+'All', actionLetter+'-A'], 500);
end;
2:begin
WaitOptionMulti([action+'All but', 'l b'], 500);
end;
end;
end;

procedure RunToBank;
var
x, y: integer;
begin
RunDebug('RunToBank method');
if FindDTMRotated(WalkToBankDTM, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/30, aFound)then
begin
Mouse(x, y, 2, 2, True);
Wait(1000 + random(50));
while (IsMoving) do (Wait(1));
end;
end;


procedure OpenBankBooth;
var
x, y, Tried: integer;
begin
if (BankScreen)then
begin
Exit;
end;
RunDebug('OpenBankBooth method');

begin
repeat
Inc(Tried);
Leech;
//Wait(150 + random(100)); TEMP REMOVAL?
//x := MSCX;
//y := MSCY;
if FindDTMRotated(BankDTM, x, y, MSX1, MSY1, MSX2, MSY2, -Pi, Pi, Pi/30, aFound)then
begin
Mouse(x, y, 10, 10, True);
Flag;
Wait(1000 + random(100));
end;
until (BankScreen) or (PinScreen) or (Tried > 10);
end;

begin
if PinScreen then
begin
if (Players[CurrentPlayer].Pin <> '')then
begin
InPin(Players[CurrentPlayer].Pin)
end else
begin
FailOutOfCode('No pin given');
end;
end;
end;
end;


function FindEdgeBankerTemp(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
R, G, B: Integer;
X, Y, Z: Extended;
begin
RunDebug('FindEdgeBankersTemp method');
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.18, 0.63);

if not(FindColorsTolerance(arP, 3745067, MSX1, MSY1, MSX2, MSY2, 13)) then
begin
// Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (R >= 12) and (R <= 74) and (G >= 9) and (G <= 65) and (B >= 17) and (B <= 96) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 0.36) and (X <= 6.67) and (Y >= 0.33) and (Y <= 5.93) and (Z >= 0.60) and (Z <= 11.63) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;

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

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

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

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

GetMousePos(fx, fy);
end;

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

if not(FindColorsTolerance(arP, 11721439, MSX1, MSY1, MSX2, MSY2, 12)) then
begin
//Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (R >= 182) and (R <= 248) and (G >= 179) and (G <= 245) and (B >= 157) and (B <= 215) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 42.00) and (X <= 82.86) and (Y >= 45.16) and (Y <= 89.35) and (Z >= 38.83) and (Z <= 76.50) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;

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

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

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

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

GetMousePos(fx, fy);
end;

procedure OpenBankTemp;
var
x, y: integer;
begin
RunDebug('OpenBankTemp method');
if (FindEdgeBankerTemp(x, y)) then
begin
mouse(x, y, 3, 3, false);
WaitOption('ank B', 500);
FFlag(1);
wait(500+random(150));
if (PinScreen) then InPin(Players[CurrentPlayer].Pin);
end else
begin
if (FindEdgeCounterTemp(x, y)) then
begin
mouse(x, y, 5, 5, true);
FFlag(1);
wait(500+random(150));
if (PinScreen) then InPin(Players[CurrentPlayer].Pin);
end;
end;
wait(500+random(150));
end;

procedure Banking;
var
x, y, Tried, Tried2, InvCountGold: integer;
actionsPerTrip: String;
begin
RunDebug('Banking method');

Tried := 0;
Tried2 := 0;
actionsPerTrip:= IntToStr(actionsPerRun);
repeat
Inc(Tried);
if(Tried > 1) then
begin
ClickNorth(SRL_ANGLE_HIGH);
end;
Leech;
OpenBankTemp;
Wait(300 + random(400));
until (BankScreen) or (Tried > 5);

Inc(Tried2);
if(BankScreen)then
begin
DepositAll;
repeat
if (smeltingGold = True) then
begin
if FindDTM(GoldOreDTM, x, y, MBX1, MBY1, MBX2, MBY2)then
begin
Mouse(x, y, 10, 10, false);
Wait(350 + random(150));
end else
begin
FailOutOfCode('Failed to find the gold ores in your bank');
Exit;
end;
end else if(makingJewelry = True) then
begin
if FindDTM(GoldBarDTM, x, y, MBX1, MBY1, MBX2, MBY2)then
begin
Mouse(x, y, 10, 10, false);
Wait(350 + random(150));
end else
begin
FailOutOfCode('Failed to find the gold bars in your bank');
Exit;
end;
end else if (cuttingGems = True) then
begin
if FindDTM(GemDTM, x, y, MBX1, MBY1, MBX2, MBY2)then
begin
Mouse(x, y, 10, 10, false);
Wait(350 + random(150));
end else
begin
FailOutOfCode('Failed to find the gems in your bank');
Exit;
end;
end else
begin
FailOutOfCode('I have no idea what you want to do if not jewelry crafting, gold smelting or gem cutting.');
Exit;
end;
if(firstRun) then
begin
InitializeBankX('Withdraw', 'w', actionsPerTrip);
end else
begin
WaitOptionMulti(['Withdraw-'+actionsPerTrip, 'w-'+actionsPerTrip], 500);
end;
x:= 0;
while((InvCount = 0) and (x < 100)) do
begin
Wait(randomrange(25,50));
Inc(x);
end;
until (InvCount > 0) or (Tried2 > 3);
InvCountGold := InvCount;
if(actionsPerRun < 15) then //Only jewelry crafting will grab 2 different items
begin
repeat
if FindDTM(GemDTM, x, y, MBX1, MBY1, MBX2, MBY2)then
begin
Mouse(x, y, 10, 10, false);
Wait(randomrange(100,200));
end else
begin
FailOutOfCode('Failed to find the gems in your bank');
Exit;
end;
RandomizeBankX('Withdraw', 'w', actionsPerTrip);
x:= 0;
while((InvCount = InvCountGold) and (x < 100)) do
begin
Wait(50);
Inc(x);
end;
until (InvCount > InvCountGold) or (Tried2 > 6) or (InvCount = 28);
end;
end;

if(Tried > 5)then
begin
FailOutOfCode('Failed to open bank');
end;

if(Tried2 > 6)then
begin
FailOutOfCode('Failed to find Gold or Gem')
end;
end;

procedure BankingEnchantment(Count: integer);
var
x, y, Tried, Tried2: integer;
actionsPerTrip: String;
begin
RunDebug('BankingEnchantment method');

if(Count=3) then
begin
FailOutOfCode('Failed to correctly withdraw the jewelry to enchant.');
Exit;
end;

Tried := 0;
Tried2 := 0;
repeat
Inc(Tried);
if(Tried > 1) then
begin
ClickNorth(SRL_ANGLE_HIGH);
end;
Leech;
OpenBankTemp;
Wait(300 + random(400));
until (BankScreen) or (Tried > 5);

actionsPerTrip:= IntToStr(actionsPerRun);
if(BankScreen)then
begin
if(InvCount > 2) then
begin
InvMouse(2, mouse_right);//Does not seem to right-click, only move mouse to desired position...
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
WaitOptionMulti(['Deposit-All', 'd-A'], 500);
x:=0;
repeat
wait(Randomrange(25,50));
Inc(x);
until(InvCount=1) or (x=100);
if(x=100) then //Did something else somehow end up in the inventory?
begin
x:= 0;
for x:= 2 to 28 do
begin
if ExistsItem(x) then
begin
InvMouse(x, mouse_left);
end;
end;
end;
end;
repeat
Inc(Tried2);
MouseBankSlot(2, mouse_Right);
if(firstRun=True)then
begin
InitializeBankX('Withdraw', 'w', actionsPerTrip);
end else
begin
RandomizeBankX('Withdraw', 'w', actionsPerTrip);
end;
x:= 0;
repeat
Inc(x);
wait(RandomRange(25,50));
until(InvCount > 1) or (x>=100);
until(tried2 > 5) or (InvCount > 1);
if(InvCount=1)then
begin
Inc(Count);
BankingEnchantment(0);
end;
end;
CloseBank;
repeat
wait(RandomRange(25,50));
until(IsActionBarOpen);
if(Tried > 5)then
begin
FailOutOfCode('Failed to open bank');
end;

if(Tried2 > 6)then
begin
FailOutOfCode('Failed to withdraw jewelry')
end;
end;


procedure RunToFurnace;
var
x, y: integer;
begin
if not(InvCount = 28)then
begin
Exit;
end;

RunDebug('RunToFurnace method');
if FindDTMRotated(WalkToFurnaceDTM, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/30, aFound)then
begin
Mouse(x, y, 2, 2, True);
Wait(1000 + random(100));
while (IsMoving) do (Wait(1));
end;
end;


function BarsInInv: Boolean;
var
x, y: integer;
begin

Leech;
if FindDTM(GoldBarDTM, x, y, MIX1, MIY1, MIX2, MIY2)then
begin
Result := True;
end;

end;

function IsWorking: Boolean;
begin
if((CountColorTolerance(855309, CABX1, CABY1, CABX2, CABY2, 25)) > 6000) then
begin
Result := True;
end;
end;

procedure SelectFurnace(Count: integer);
var
x, y: integer;
begin
RunDebug('SelectFurnace method');
Leech;
if(Count > 3) then begin
FailOutOfCode('Was looking for furnace and failed to open it.');
Exit;
end;

if FindDTMRotated(FurnaceDTM, x, y, MSX1, MSY1, MSX2, MSY2, -Pi, Pi, Pi/30, aFound)then
begin
Mouse(x, y, 10, 10, true);
Wait(1500 + random(100));
while(IsMoving) do (Wait(1));
x:= 0;
while ((x < 200) and (CountColorTolerance(3911923, CMSX1, CMSY1, CMSX2, CMSY3, 2) < 80)) Do
begin
wait(50);
Inc(x);
end;
if(x = 200) then begin
RunToFurnace;
Inc(Count);
SelectFurnace(Count);
end;
end else
begin
WriteLn('Failed to find furnace, exiting');
Exit;
end;
end;

procedure Craft(Count: integer);
var
x, color: integer;
begin
if(Count > 3) then
begin
FailOutOfCode('Could not complete a crafting attempt.');
Exit;
end;
SelectFurnace(0);
RunDebug('Craft method');
if(GemEncrusted = 'Dragonstone') then
begin
end else begin
x:=0;
if(CountColorTolerance(3911923, CMSX1, CMSY1, CMSX2, CMSY3, 2) < 90) then
begin
WriteLn('Crafting screen never opened for some reason');
Exit;
end;
if(firstRun=True)then begin
//While bar at bottom, 101 is read on top, 353 read on bottom
//While bar at top, 355 is read on top, 98 read on bottom
while ((CountColorTolerance(3911923, CMSX1, CMSY1, CMSX2, CMSY3, 2) < 340) and (x < 200)) Do
begin
Inc(x);
Mouse(RandomRange(CMSX1, CMSX2), (CMSY1 + Random(40)), 0, 0, true);
wait(50);
end;
Mouse(RandomRange(CBXMin, CBXMin), RandomRange(CBYMin, CBYMin), 0, 0, true);
x := 0;
color:= 0;
while ( not (SimilarColors(color, 1290732, 10)) and (x < 100)) do
begin
color:= GetColor(CBXMin, CBYMin);
wait(randomrange(25,50));
Inc(x);
end;
if(x >= 100) then
begin
FailOutOfCode('Could not select desired jewelry craft.');
end;
end;
end;
//Initialize Crafting
Mouse(371, 313, 112, 11, true);
x:=0;
repeat
wait(randomrange(25,50));
Inc(x);
until(IsWorking) or (x >= 100);
if (IsWorking)then
begin
repeat
begin
Stuck := 0;
AntiBan;
Wait(2500 + random(1000));
end;
until (IsWorking = False);
end else
begin
RunToFurnace;
SelectFurnace(0);
Inc(Count);
Craft(Count);
end;
end;

procedure Smith(Count: integer);
var
x: integer;
begin
if(Count > 3) then
begin
FailOutOfCode('Could not complete a smithing attempt.');
Exit;
end;

SelectFurnace(0);
RunDebug('Smith method');

if(CountColorTolerance(3911923, CMSX1, CMSY1, CMSX2, CMSY3, 2) < 90) then
begin
WriteLn('Smithing screen never opened for some reason');
Exit;
end;

Mouse(371, 313, 112, 11, true);
x:=0;
repeat
wait(randomrange(25,50));
Inc(x);
until(IsWorking) or (x >= 100);
Wait(1000 + random(100));
if (IsWorking)then
begin
repeat
begin
Stuck := 0;
AntiBan;
Wait(2500 + random(1000));
end;
until (IsWorking = False);
end else
begin
RunToFurnace;
SelectFurnace(0);
Inc(Count);
Smith(Count);
end;
end;

procedure Enchant(Count: integer);
var
i, x, y, decAction, decEnchanted: integer;
upText: boolean;
begin
RunDebug('Now Enchanting');
invmouse(2, 3);
for i := 2 to 28 do
begin
upText:= True;
SendKeys('1', 50, 25);
x:= 0;
y:= 0;
decAction:= 0;
decEnchanted:= 0;
{ repeat
wait(randomrange(25, 50));
Inc(x);
until (SimilarColors(13158600, GetColor(ABX1, ABY1), 1) or (x >= 100));
if(x>=100)then
begin
Dec(i);
Inc(decAction);
if(decAction=3)then
begin
FailOutOfCode('Failed to select the enchantment.');
Exit;
end;
end;
} repeat
wait(randomRange(25, 50));
Inc(y);
until ((WaitUpTextMulti(['Cast ', 'ast '], 10)) or (y >= 100));
InvMouse(i, 1);
// y:= 0;
upText:= WaitUpText(enchantment, 500);// not (WaitUpTextMulti(['Wear Ri', 'ear Ri'], 10));
{ repeat
wait(randomrange(10,20));
Inc(y);
//upText:=(WaitUpTextMulti(['Wear Sa','ear Sa'],10) or WaitUpTextMulti(['Wear Em','ear Em'],10) or WaitUpTextMulti(['Wear Ru','ear Ru'],10) or WaitUpTextMulti(['Wear Di','ear Di'],10) or WaitUpTextMulti(['Cast ','ast '],10));
until ((upText) or (y >= 100));
} if(not upText)then
begin
Dec(i);
Inc(decEnchanted);
if(decEnchanted=3)then
begin
FailOutOfCode('Failed to enchant some piece of jewelry.');
Exit;
end;
end;
end;
Stuck := 0;
end;

//Only left clicks your gems, doesn't do anything else yet. Meaning this doesn't work.
procedure CutGems;
var
x, y: integer;
begin
RunDebug('CutGems method');
if FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2)then
begin
Mouse(x, y, 10, 10, true);
Wait(650 + random(150));
end else
begin
WriteLn('Failed to find the gems, exiting');
Exit;
end;
end;

procedure ProggressReport;
var
CraftExp, SmithExp, SmithExpHr, CraftExpHr, TimeRan, ItemsCrafted, ItemsCraftedHr, GoldLost, GoldEarned, GoldChange, GoldChangeHour: integer;
GemType: String;
CraftExpPerAction: Double;
begin

TimeRan := ((1 + GetSystemTime - TimeBegan) / 1000); //Seconds
ItemsCrafted := Round(runs * actionsPerRun);
ItemsCraftedHr := Round((ItemsCrafted * 3600) / (TimeRan));
CraftExpPerAction := xpPerJewelryAction + xpPerGemAction;
CraftExp := Round(ItemsCrafted * CraftExpPerAction);
CraftExpHr := Round((CraftExp * 3600) / (TimeRan));
SmithExp := Round(ItemsCrafted * xpPerSmeltingAction);
SmithExpHr := Round((SmithExp * 3600) / (TimeRan));
if(smeltingGold = True)then
begin
GoldLost:= ((GoldOreValue - GoldBarValue) * ItemsCrafted);
end;
if(makingJewelry = True) then
begin
GoldEarned:= ((CraftedItemValue - CutGemValue - GoldBarValue) * ItemsCrafted);
end;
GoldChange:= (GoldEarned - GoldLost);
GoldChangeHour:= Round((GoldChange / TimeRan) * 3600);
if(GemEncrusted = 'None') then
begin
GemType := '';
end else begin
GemType := GemEncrusted + ' ';
end;
ClearDebug;
WriteLn('*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
WriteLn('*Kevin''s Edgeville Crafter.');
WriteLn('*Time elapsed: ' + TimeRunning);
if(makingJewelry=True) or (cuttingGems=True) then
begin
WriteLn('*We have gained ' + IntToStr(CraftExp) + ' Craft Experience! (' + IntToStr(CraftExpHr) + ' per hour)');
WriteLn('*We have crafted ' + IntToStr(ItemsCrafted) + ' ' + GemType + CraftingWhat + 's! (' + IntToStr(ItemsCraftedHr) + ' per hour)');
WriteLn('*We have earned ' + IntToStr(GoldEarned) + ' gold crafting!');
end;
if(smeltingGold=True) then
begin
WriteLn('*We have gained ' + IntToStr(SmithExp) + ' Smithing Experience! (' + IntToStr(SmithExpHr) + ' per hour)');
WriteLn('*We have smelted ' + IntToStr(ItemsCrafted) + ' gold bars! (' + IntToStr(ItemsCraftedHr) + ' per hour)');
WriteLn('*We have spent ' + IntToStr(GoldLost) + ' gold on smelting!');
end;
if(enchanting=True) then
begin
WriteLn('*We have enchanted ' + IntToStr(ItemsCrafted) + ' pieces of jewlery! (' + IntToStr(ItemsCraftedHr) + ' per hour)');
end;
WriteLn('*We have gone: ' + IntToStr(runs) + ' trips of a total of ' + IntToStr(goalRuns) + ' goal trips!');
WriteLn('*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');

if(runs >= goalRuns) then
begin
doneRunning := True;
end;
end;

begin
Updater;
Smart_FixSpeed := True;
SRL_SixHourFix := True;
SetUpSRL;

UserSettings;
SetupVariables;
Addonterminate('FreeMyDTMs');
leeching := True;
ActivateClient;
DeclarePlayers;
LoginPlayer;

ToggleMoneyPouch(False);
ToggleXPBar(False);
StartingXP := (GetXPBarTotal);
TimeBegan := GetSystemTime;
ExitSquealOfFortune();
ClickNorth(SRL_ANGLE_HIGH);
RunToBank;
repeat
if not (LoggedIn)then
begin
TerminateScript;
end;
Inc(Stuck);
if(enchanting=True)then
begin
BankingEnchantment(0);
Enchant(0);
end else
begin
RunToBank;
Banking;
RunToFurnace;
if(smeltingGold = True) then
begin
Smith(0);
end;
if(makingJewelry = True)then
begin
Craft(0);
end;
end;
Inc(runs);
FindSpinTicket();
Proggy;
firstRun := false;
Leech;
if(doneRunning = True) then
begin
RunDebug('DONE!');
FailOutOfCode('Goal accomplished!');
end;
if (Stuck > 3)then
begin
FailOutOfCode('We are stuck on something, logging out')
end;
until(AllPlayersInactive);
end.

Justin

2013-01-06 23:40:47

Hi nivek1989,
Could you please post your scripts in SIMBA tags in this thread?
Thanks
Justin.

Kevin

2013-01-06 23:52:54

Sorry about that, I was thinking I should link to them. Fixed!
Thanks,
-Kevin

xtrapsp

2013-01-07 05:32:44

Voting no PURELY on activity, didn't even read the script because of this.

I suggest getting your post count up with QUALITY posts as well as on a semi-regular basis. Doesn't have to be every day but seeing you a little more would make my vote count as a yes :)

[XoL]

2013-01-07 11:11:25

From: xtrapsp
Voting no PURELY on activity, didn't even read the script because of this.

I suggest getting your post count up with QUALITY posts as well as on a semi-regular basis. Doesn't have to be every day but seeing you a little more would make my vote count as a yes :)


This ^
Sorry, but activity is KEY and unless you are producing the most amazing scripts on these forums (zmon) you need activity to boost the app :)

Tbh id perfer active smart members > Genius inactive members

Kevin

2013-01-07 11:33:38

I suppose I can definitely understand that reasoning. And if that's the reason I don't get approved now (or for a long time for that matter), that won't kill me. Although I would also like any pointers anyone may have to offer on my scripts since I most definitely already have [some of] your attentions?

masterBB

2013-01-07 13:45:22

Hi, I only read quickly through your first scripts. Personally I think it is not advanced enough, but will wait with voting till I had time to read the second one. I do have a few questions though I hope you can answer.

- Can you think of way to shorten this? Or make it less repetive?

if(FindSymbol(x, y, 'water'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'portal'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'bar'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'lodestone'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'quest'))then
begin
SymbolCount:= SymbolCount + 1;
end;

- Is it possible for you to create a function/procedure so you don't have to repeat this so often?

  if(TextDebug)then
begin
WriteLn(x);
end;

- Can you think of a few try..except statements that aren't nessecary? Which can be removed? (Tip: You don't have to look into the version updater)

Kevin

2013-01-07 15:12:20

From: masterBB
Hi, I only read quickly through your first scripts. Personally I think it is not advanced enough, but will wait with voting till I had time to read the second one. I do have a few questions though I hope you can answer.

- Can you think of way to shorten this? Or make it less repetive?

if(FindSymbol(x, y, 'water'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'portal'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'bar'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'lodestone'))then
begin
SymbolCount:= SymbolCount + 1;
end;
if(FindSymbol(x, y, 'quest'))then
begin
SymbolCount:= SymbolCount + 1;
end;

- Is it possible for you to create a function/procedure so you don't have to repeat this so often?

  if(TextDebug)then
begin
WriteLn(x);
end;

- Can you think of a few try..except statements that aren't nessecary? Which can be removed? (Tip: You don't have to look into the version updater)


Simplified both of your first 2 recommendations and removed 1 of the try..except statements that was entirely useless. In fact, I reorganized how that method (PickpocketMerchants) was handled in relation to the GoldSuccess value.

The other try..except statement in that method is useful for special circumstances: it is possible for a single thieving attempt to earn more than the typical 3 gold and can earn 20 instead. I have no idea what facts separate the situations, but I know my main account gets 20 while my test account gets 3. I know I could hard code the situation so the base string starts '00' instead of '0', but then the add later says '30' instead of '3'. The except situation could add 1 more to the length of the string, then read in the correct value, but that's still a hard-coded solution. Is there some method of improving the length of a current string or somehow otherwise handling the variable length that won't throw exceptions?

Sin

2013-01-07 15:20:54

At the FindSymbol part, i'd recommend adding the strings into an array and looking through them like this:


var
t:TStringArray;
i:integer;
begin
{add strings to array here}
SetLength(t,4);
t[0] := '';
t[1] := '';
t[2] := '';

for i := 0 to 2 do
if FindSymbol(x,y,t[i]) then
etc;

Sin

2013-01-07 17:48:28

Voted yes on the account that he's willing to learn :)

Kevin

2013-01-07 17:54:17

Thanks, and definitely trying to learn all around, hence the code review requests. :)

masterBB

2013-01-07 18:35:10

I am afraid I will have to vote no. I do like the energy you put in to this script and your willingness to learn. Two very important characteristics I search for in a new Member. However with becoming an SRL member also comes perks like having access to our market and private script. It is not that I don't trust you, it is just that I don't know you yet.

On the coding part, your are obviously somebody who has still some space to improve. The script itself doesn't meet my requirements of an SRL script yet, but I like the additions you made. The problems I see are a lack of own made solutions to the obstacles you faced as well as not using advanced techniques like interesting tpa sorting. I am sure this will come with time.

improvements:
  • You don't have to write a begin or end for every if statement. If such a statement body contains only one command or just one other statement you can just leave it away.
if(FindSymbol(x, y, symbol))then
begin
Inc(count);
end;

to

if(FindSymbol(x, y, symbol))then
Inc(count);

  • I see very few functions and none returning other types than Boolean. Try to place more functions at smart locations.

to

function SearchSymbol(x, y: integer; symbols: Array of String): Integer;
var
I: Integer;
begin
for I := o to High(symbols) do
if(FindSymbol(x, y, symbols[i]))then
Inc(count);
end;

  • Try to simplify or split procedure with a lot of code in it. This will make the code a lot cleaner. Also check if all code is actually being used.

for j:=8 downto 4 do //no function

[INDENT]and[/INDENT]

If doActionA then
begin
If doActionB then
begin
writeln('jeej');
end else
if doActionB_Fix then
begin
Exit;
end;

to

If not(doActionA) then
if not(doActionA_fix) then
Exit;

If not(doActionB) then
if not(doActionB_fix) then
Exit;

  • Some variables like the players name and pass word are so important that it is better not to make your own variables with it and just put it in the standard declare player function.

Therefor I suggest if you don't make it, just hang around for a bit, try to work on your coding techniques and you will get there in no time.

Kevin

2013-01-07 19:09:23

As for the trust issue… I might possibly be a little more offended, had I not seen what djv did this past week, really kinda ruining a lot of trust even the JMems had. After that, it's pretty easy to see how some people want more trust built up first before Member. In fact, I'd be a tad surprised if I earned Member now because of that; however, coding is something I can at least work on in the meanwhile.

From: masterBB

improvements:
  • You don't have to write a begin or end for every if statement. If such a statement body contains only one command or just one other statement you can just leave it away.
if(FindSymbol(x, y, symbol))then
begin
Inc(count);
end;

to

if(FindSymbol(x, y, symbol))then
Inc(count);

I understand that, but isn't it better practice to include it since it doesn't change runtime at all?
From: masterBB


  • Try to simplify or split procedure with a lot of code in it. This will make the code a lot cleaner. Also check if all code is actually being used.

for j:=8 downto 4 do //no function

[INDENT]and[/INDENT]

If doActionA then
begin
If doActionB then
begin
writeln('jeej');
end else
if doActionB_Fix then
begin
Exit;
end;

to

If not(doActionA) then
if not(doActionA_fix) then
Exit;

If not(doActionB) then
if not(doActionB_fix) then
Exit;

I can agree with splitting up long methods some more, yea. But as for the first comment having no function:
for j:=8 downto 4 do //no function
It has 2-fold use. If a pickpocket occurs as the very first thing, the verification occurs on line 4, not line 8. Also, if somehow something new is written on the screen (someone talking) at the perfect timing, it can push the read to line 7 prior to it actually being read, as opposed to line 8, the bottom of the chat box.

From: masterBB

  • Some variables like the players name and pass word are so important that it is better not to make your own variables with it and just put it in the standard declare player function.


Actually, that's a standard I only recently adopted, having seen it in a variety of other scripts. I see it as a manner of simplifying the amount of space needed for settings for the user. I suppose they could just be constants followed immediately by the DeclarePlayers method.

-Kevin

Daniel

2013-02-04 06:28:08

Hey nivek1989,

It appears you won't be getting in this time :( Please take note of what other members have suggested to improve your script/activity for next time.

Given the date of closure, you may apply again whenever you wish.