SRL Archive - Senior Scripts and Snippets

Master farmer thiever


marpis

2011-01-28 06:38:45

The profit in the proggy below is very sucky indeed, but if you have 58 agility and 80+ thieving you can get 400k+ per hour. I mainly use this for experience for now.

  • Start with food in inventory at the Draynor square
  • Have food in the first bankslot


program MasterThief;
{.include SRL/SRL/misc/smart.scar}
{.include SRL/SRL.scar}
{.include reflection/reflection.simba}


const
ANIMATION_STEALING = 881;
ANIMATION_STUNNED = 11974;

WATERMELON = 0;
RANARR = 1;
TOADFLAX = 2;
IRIT = 3;
AVANTOE = 4;
KWUARM = 5;
SNAPDRAGON = 6;
CADANTINE = 7;
LANTADYME = 8;
DWARFWEED = 9;
TORSTOL = 10;

const
FOOD_NAME = 'Lobster';
FOOD_AMOUNT = 4;
SERVER = 151;
SIGNED = True;
RUN_MINUTES = 240; // Max runtime in minutes
TAKE_BREAKS = True; // Take ~10 minute breaks every hour?
CHANGE_WORLDS = True; // Change world if the word 'bot' appears in chat?

var
Prices: Array [0..10] of integer;
FailTimer, Slept, NextBreakTime, StartXP, StartLevel: integer;

procedure DeclarePlayer;
begin
NumberOfPlayers(1);

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

Prices[WATERMELON] := 2500;
Prices[RANARR] := 13000;
Prices[TOADFLAX] := 1800;
Prices[IRIT] := 240;
Prices[AVANTOE] := 1800;
Prices[KWUARM] := 3450;
Prices[SNAPDRAGON] := 56000;
Prices[CADANTINE] := 1350;
Prices[LANTADYME] := 21000;
Prices[DWARFWEED] := 20000;
Prices[TORSTOL] := 280000;

end;

procedure CheckRandoms;
begin
if FindNormalRandoms then
FailTimer := GetSystemTime;
//R_FindRandoms;
end;

// From SRL, modified to use Reflection GetUptext and ChooseOption
function R_WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
FixBank;
FixBankTab;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 3);

if (Length(Uptexts) > 0) then
if (not R_WaitUptextMulti(Uptexts, 500)) then
Exit;

ClickMouse2(Amount = 1);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

if (Amount = 0) then
Result := R_WaitOptionMulti(['Withdraw-All', 'w-A'], 300)
else
Result := R_WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);

if (not (Result)) and (Amount > 0) then
begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 2);
if R_WaitOptionMulti(['Withdraw-X', 'w-X'], 500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(75, 400));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;


function WaitForSteal: boolean;
var
t, A: integer;
begin
if (not LoggedIn) then Exit;

t := GetSystemTime + 1000 + random(500);

while (GetSystemTime < t) do
begin
A := GetAnimation;
if (A = ANIMATION_STEALING) or (A = ANIMATION_STUNNED) then
begin
Result := True;
Exit;
end;
Wait(5);
end;

end;

procedure HandleGuard;
var
Me: TMe;
begin
if InterActingWithme(GetNPC('Market guard')) then
repeat
Wait(5);
Me := GetMe;
until(not Me.InFight);
end;

function Pickpocket: boolean;
var
Farmer: TNPC;
B: TBox;
MS: TPoint;
Left: boolean;
begin
if (not LoggedIn) then Exit;
CheckRandoms;
Farmer := GetNPC('Master Farmer');
B := IntToBox(95, 88, 404, 262);

if distanceFrom(Farmer.Tile) > 45 then
begin
Writeln('Master Farmer not found!');
Exit;
end;

MS := TileToMS(Farmer.Tile, Farmer.Height / 2);
if not PointInBox(MS, B) then
begin
//Writeln('Walking to Master Farmer...');
if not WalkToTile(Farmer.Tile, 0, 0) then
Writeln('Walking to Master Farmer failed!');
Exit;
end;

//Writeln('Clicking Master Farmer...');

if not R_IsUptext('Pickpocket Master Farmer') then
MMouse(MS.X, MS.Y, 5, 10);

Left := R_IsUptext('Pickpocket Master Farmer');
GetMousePos(MS.X, MS.Y);
Mouse(MS.X, MS.Y, 0, 0, Left);
if (not Left) then
if not R_WaitOption('Pickpocket Master Farmer', 500 + random(100)) then
Exit;


Result := WaitForSteal;
if Result then
Wait(100 + Random(50));
HandleGuard;
end;


function LowHP: boolean;
begin
if (not LoggedIn) then Exit;
// Green lifepoint numbers
Result := CountColor(65280, 725, 30, 740, 37) = 0;
end;

function EatFood: boolean;
var
Item: TInvItem;
begin
if (not LoggedIn) then Exit;
if not R_ItemNameExists(Item, FOOD_NAME) then
begin
Writeln('We are out of food!');
Exit;
end;

MouseItem(Item.Slot, True);
Result := True;
end;

function HandleEating: boolean;
var
t: integer;
begin
if (not LoggedIn) then Exit;
Result := True;
if not LowHP then Exit;

t := GetSystemTime + 30000;
while LowHP do
begin
if (GetSystemTime > t) then
begin
Writeln('Eating has taken too long!');
Result := False;
Exit;
end;

if not EatFood then
begin
Result := False;
Exit;
end;
end;

end;


function MyTileWalk(TheTile: TTile; Rand: integer): boolean;
var
P: TPoint;
begin
P := TileToMM(TheTile);
P.X := P.X - Rand + Random(2*Rand + 1);
P.Y := P.Y - Rand + Random(2*Rand + 1);

if not rs_OnMinimap(P.X, P.Y) then
Exit;

Mouse(P.X, P.Y, 0, 0, True);
Result := WaitToMove(5000);
Flag;
end;



function WalkToBank: boolean;
var
SquareTile, BankTile: TTile;
MM: TPoint;
t: integer;
begin
if (not LoggedIn) then Exit;
CheckRandoms;
SquareTile := Tile(3083, 3249);
BankTile := Tile(3094, 3243);

if WaitForSteal then
Wait(5000 + Random(1000));

t := GetSystemTime + 60000;
while (DistanceFrom(BankTile) >= 3) and (GetSystemTime < T) do
begin
MM := TileToMM(BankTile);
if InCircle(MM.X, MM.Y, MMCX, MMCY, 60) then
begin
Writeln('Walking straight to bank...');
Result := MyTileWalk(BankTile, 3);
end else
begin
Writeln('Walking first to Square, then to bank...');
if MyTileWalk(SquareTile, 5) then
Result := MyTileWalk(BankTile, 3);
end;
end;

end;

function ReturnToSpot: boolean;
var
SquareTile: TTile;
begin
if (not LoggedIn) then Exit;
CheckRandoms;
SquareTile := Tile(3083, 3249);
Result := MyTileWalk(SquareTile, 10);
end;

function MyOpenBank: boolean;
var
Banker: TNPC;
MS: TPoint;
t: integer;
begin
if (not LoggedIn) then Exit;
t := GetSystemTime + 40000;
while (not Result) and (GetSystemTime < t) do
begin
CheckRandoms;
Banker := GetNPC('Banker');
MS := TileToMS(Banker.Tile, Banker.Height / 2);
if not PointInBox(MS, MSBox) then
begin
Writeln('Bankers not found!');
Exit;
end;

Mouse(MS.X, MS.Y, 5, 15, False);
if R_WaitOptionMulti(['Bank Banker', 'Use-quickly'], 3500) then
Result := WaitFunc(@BankScreen, 10, 10000);
end;

if not Result then
Writeln('Failed opening the bank!');

end;

procedure CountSeeds;
var
TSA: TStringArray;
I: integer;
Item: TInvItem;
begin
TSA := ['Watermelon', 'Ranarr', 'Toadflax', 'Irit', 'Avantoe', 'Kwuarm',
'Snapdragon', 'Cadantine', 'Lantadyme', 'Dwarf weed', 'Torstol'];
for I := WATERMELON to TORSTOL do
begin
if not R_ItemNameExists(Item, TSA[I]) then
Continue;
IncEx(Players[0].Integers[I], Item.StackSize);
end;
end;



function HandleBanking: boolean;
begin
if (not LoggedIn) then Exit;
CountSeeds;
DepositAll;
Result := R_WithdrawEx(0, 0, FOOD_AMOUNT, [FOOD_NAME]);
if not Result then
Writeln('R_WithdrawEx failed!');
end;

procedure ProgressReport;
var
TSA: TStringArray;
H: Extended;
TotalProfit, I, ExpGained, LevelsGained: integer;
Me: TMe;
begin
TSA := ['Watermelon', 'Ranarr', 'Toadflax', 'Irit', 'Avantoe', 'Kwuarm',
'Snapdragon', 'Cadantine', 'Lantadyme', 'Dwarf weed', 'Torstol'];
H := GetTimeRunning / 3600.0 / 1000.0;
Me := GetMe;
ExpGained := Me.Experience[SKILL_THIEVING] - StartXP;
LevelsGained := Me.Levels[SKILL_THIEVING] - StartLevel;

//ClearDebug;
Writeln('');
Writeln('<~~ Master Thief ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');

for I := WATERMELON to TORSTOL do
if (Players[0].Integers[I] > 0) then
begin
Writeln(' o '+TSA[I]+' seed stolen: '+ToStr(Players[0].Integers[I]));
Writeln(' -> Profit: '+GroupDigits(Players[0].Integers[I]*Prices[I], ','));
IncEx(TotalProfit, Players[0].Integers[I]*Prices[I]);
end;

Writeln('<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');
Writeln(' Total profit: '+GroupDigits(TotalProfit, ','));
Writeln(' Profit per hour: '+GroupDigits(Round(TotalProfit / H), ','));
Writeln(' XP Gained: '+GroupDigits(ExpGained, ','));
if (LevelsGained > 0) then
WriteLn(' Levels Gained: '+ToStr(LevelsGained));
Writeln(' XP per hour: '+GroupDigits(Round(ExpGained / H), ','));
Writeln(' We have slept '+ToStr(Slept)+' times');
Writeln(' Total runtime: '+TimeRunning);
Writeln('<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');
Writeln('');
end;

function GetMoreFood: boolean;
begin
if WalkToBank then
if MyOpenBank then
if HandleBanking then
if ReturnToSpot then
begin
Writeln('Got food!');
FailTimer := GetSystemTime;
Result := True;
ProgressReport;
end;
end;

procedure Antiban;
begin
case random(1000) of
0..9: PickUpMouse;
10..19: MakeCompass(Random(360));
end;
end;

procedure Mainloop;
begin
if (not LoggedIn) then
begin
Writeln('We are not logged in! Terminating...');
TerminateScript;
end;

if Pickpocket then
FailTimer := GetSystemTime
else
if ((GetSystemTime - FailTimer) > 60000) then
begin
Writeln('Spent one minute without success, terminating!');
TerminateScript;
end;

if (not HandleEating) or (InvFull) then
if not GetMoreFood then
begin
Writeln('Getting more food failed!');
TerminateScript;
end;
end;


procedure TakeBreaks;
var
t, Hours, Mins, Secs: integer;
begin
if (GetSystemTime > NextBreakTime) then
begin
WriteLn('TAKING A BREAK!');
Logout;
t := GetSystemTime + RandomRange(1000*60*5, 1000*60*15);
while (GetSystemTime < t) do
begin
ConvertTime(t - GetSystemTime, Hours, Mins, Secs);
Disguise(ToStr(Mins)+'m, '+ToStr(Secs)+'s');
Wait(999);
end;

LoginPlayer;
SetAngle(True);
NextBreakTime := GetSystemTime + RandomRange(1000*60*50, 1000*60*70);
FailTimer := GetSystemTime;
Inc(Slept);
end;
end;

procedure Starter;
var
Me: TMe;
begin
NumberOfPlayers(1);
SMART_SERVER := SERVER;
SMART_SIGNED := SIGNED;
SetupSRL;
DeclarePlayer;

if not Loggedin then
LoginPlayer;
SetAngle(True);

NextBreakTime := GetSystemTime + RandomRange(1000*60*50, 1000*60*70);
FailTimer := GetSystemTime;
Me := GetMe;
StartXP := Me.Experience[SKILL_THIEVING];
StartLevel := Me.Levels[SKILL_THIEVING];
end;


begin
Starter;
repeat
Mainloop;
Antiban;
TakeBreaks;
until (GetTimeRunning > (RUN_MINUTES*60000));

end.
<~~ Master Thief ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
o Watermelon seed stolen: 1
-> Profit: 2,500
o Toadflax seed stolen: 3
-> Profit: 5,400
o Avantoe seed stolen: 2
-> Profit: 3,600
o Kwuarm seed stolen: 1
-> Profit: 3,450
o Lantadyme seed stolen: 1
-> Profit: 21,000
<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
Total profit: 35,950
Profit per hour: 26,912
XP Gained: 33,712
Levels Gained: 1
XP per hour: 25,236
We have slept 1 times
Total runtime: 1 Hours, 20 Minutes and 9 Seconds
<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>

BraK

2011-01-31 04:24:12

I'll see about testing it when I get home as I have 60 Agility and 80+ thieving. Funny I haven't logged on to my account in like a month or two. I'll probably have a couple hour progress report later.

~BraK

E: Does it auto drop the garbage seeds? I looked through the code and didn't see a line in there for it. One of the things I did towards the end when training it was had one of each seed I wanted in the INV already and food filling the rest. This stopped me from getting garbage seeds in the first place.

Bebe

2011-01-31 04:29:20

Thank you so much :) I'll post a proggy once I get something good :p

edit: I had the same question as Brak but you answered it already.

marpis

2011-01-31 04:31:18

From: BraK
I'll see about testing it when I get home as I have 60 Agility and 80+ thieving. Funny I haven't logged on to my account in like a month or two. I'll probably have a couple hour progress report later.

~BraK

E: Does it auto drop the garbage seeds?


Nope, I think it's fast enough to just bank everything

BraK

2011-02-02 18:30:14

Any Particular Type of food or does it not matter?

~BraK

marpis

2011-02-03 02:18:13

anything goes