Simba Code:
program Doughmaker;
//######################################################################//
// //
// Longfinmako's Doughmaker (pastry) //
// //
// Makes dough in Lumbridge, please start the script while //
// you are near the bank chest in Lumbridge. The bank symbol //
// has to be visible on your minimap for this script to work. //
// //
//######################################################################//
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$i srl-6/lib/misc/srlplayerform.simba}
// User settings: You may edit code in this section but ONLY IF NEEDED
// if your script runs flawlessly then you don't have to touch this part
// These seting work for me, if they don't work for you you might want to change
// them using ACA
const
FOUNTAIN_COLOR := 12965058; //good job with these!!
FOUNTAIN_TOL := 3;
FOUNTAIN_HUE := 2.70;
FOUNTAIN_SAT := 2.01;
ANTI_BAN_FREQUENCE := 75;
//##################################################################################
procedure initPlayerForm();
begin
with playerForm do
begin
name := 'Doughmaker';
scriptHelpThread := '';
scriptSettingsPath := '';
editBoxLabels := ['Time before taking a break', 'Duration of a break', 'Loads to make'];
editBoxDefaults := ['0', '0', '0'];
end;
end;
procedure declarePlayers();
var
i: integer;
begin
players.setup(playerForm.players);
currentPlayer := 0;
for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
integers[1] := strToInt(playerForm.players[i].settings[1]);
integers[2] := strToInt(playerForm.players[i].settings[2]);
end;
end;
procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Minutes to run: ', players[i].integers[0]);
writeln('Minutes before breaking: ', players[i].integers[1]);
writeln('Dough to make: ', players[i].integers[2]);
writeln('');
end;
end;
procedure performAntiBan()
var
randomAntiBan, chance: integer;
begin
chance := randomRange(0,101);
writeln('Anti-ban chance: ' + intToStr(chance));
if(chance > 75) then // you can just do 'if (random(101) > 75) then' here, no need for the extra lines
begin
writeln('Performing Anti-ban.');
randomAntiBan := random(7);
case randomAntiBan of //you can just do case random(7) of here
0: randomRClickItem();
1: sleepAndMoveMouse(600 + random(2800));
2: pickUpMouse();
3: mouseOffClient(OFF_CLIENT_RANDOM);
4: randomCameraAngle(MS_ANGLE_HIGH);
5: boredHuman(true);
6: mouseMovingObject();
end;
writeln('Resuming normal actions');
end
else begin
writeln('Not performing Anti-ban actions');
end;
end;
procedure goToBanker(); //I suggest you learn about SPS for the walking
var //if for some reason the icon isn't shown on the minimap, the script will be stuck in the loop
p, r: TPoint
begin
if(not isLoggedIn()) then
exit();
minimap.setAngle(MM_DIRECTION_SOUTH);
wait(randomRange(256,1024));
repeat
//Here! IF we don't find the symbol were kind of screwed, because then we wont create point p
if not minimap.findSymbol(p, MM_SYMBOL_BANK , minimap.getBounds()) then
writeln('Could not find the bank symbol.');
//dont need to create an extra TPoint here
//you can just do mouse(p.randRange(-3,3), MOUSE_LEFT) this will apply the randomness to both the x and the y values of point p and click it
r.create(p.X + randomRange(-3,3), p.Y + randomRange(-3,3));
mouse(r,MOUSE_LEFT);
until minimap.findSymbol(p, MM_SYMBOL_BANK , minimap.getBounds());
wait(randomRange(450,980));
if randomRange(0,2) > 0 then
begin
minimap.setAngle(MM_DIRECTION_WEST);
end
else begin
minimap.setAngle(MM_DIRECTION_EAST);
end;
minimap.waitPlayerMoving(1000);
wait(randomRange(500,1200));
writeln('We are now at the bank');
end;
procedure clickBanker()
var
x, y, i, counter: integer;
TPA: TPointArray;
ATPA : T2DPointArray;
begin
if(not isLoggedIn()) then
exit;
repeat //this is a permanent loop, you might get stuck in this loop
//if for some reason it fails to open the bank and it fails to find the symbol to click it
//I suggest adding a timer as a failsafe here so it doesn't get stuck
writeln('Looking for banker');
counter := 0;
repeat
inc(counter);
if bankscreen.open(BANK_CHEST_LUMBRIDGE) then
break();
until counter > 5
if counter > 5 then
goToBanker();
until bankscreen.isOpen(200);
//why deposit then preset, just do preset, It will deposit everything while withdrawing your preset.
if bankscreen.isOpen() then
begin
bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
bankscreen.clickButton(BANK_BUTTON_PRESET_1);
end;
end;
procedure goToWater(); // same as gotobanker
var
p, r: TPoint
begin
if(not isLoggedIn()) then
exit();
minimap.setAngle(MM_DIRECTION_NORTH);
wait(randomRange(124,512));
repeat
if not minimap.findSymbol(p, MM_SYMBOL_WATER , minimap.getBounds()) then
writeln('Could not find the water symbol.');
r.create(p.X + randomRange(-3,3), p.Y + randomRange(-3,3));
mouse(r,MOUSE_MOVE);
wait(randomRange(50,200));
fastClick(MOUSE_LEFT);
until minimap.findSymbol(p, MM_SYMBOL_WATER , minimap.getBounds());
//mouse(r.rand(500,300), MOUSE_MOVE, MOUSE_HUMAN);
minimap.waitPlayerMoving(1000);
wait(randomRange(800,2000));
end;
procedure makeDough()
var
x, y, i: integer;
TPA: TPointArray;
ATPA : T2DPointArray;
begin
if(not isLoggedIn()) then
exit();
writeln('Looking for water');
findColorsSpiralTolerance(x, y, TPA, FOUNTAIN_COLOR, intToBox(0,0,575,400), FOUNTAIN_TOL, colorSetting(2, FOUNTAIN_HUE, FOUNTAIN_SAT));
if(length(TPA) < 1) then
begin
writeln('No color found');
exit();
end;
ATPA := TPA.toATPA(30,30);
ATPA.filterBetween(0,20);
smartImage.debugATPA(ATPA);
if(length(ATPA) < 1) then
begin
writeln('Not enough colors found!');
exit();
end;
//dont need these two lines
if not tabBackpack.isOpen() then
tabBackpack.open();
//this line will check and open the backpack if it isnt open
tabBackpack.mouseSlot(1, MOUSE_LEFT)
for i:= 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]),MOUSE_MOVE);
//the over text here is too vague, if you mouse over anything it will say that
if isMouseOverText(['se Pot of flour'], 500) then
begin
writeln('Found the watersource!');
fastClick(MOUSE_LEFT);
smartImage.clear;
//I suggest you take this part out of the loop, so the loop is only for clicking.
minimap.waitPlayerMoving(1000);
if(productionScreen.isOpen(2000)) then
begin
productionScreen.selectBox(2);
productionScreen.clickStart();
end;
repeat
wait(randomRange(1000,2000));
until not progressScreen.isOpen(1000);
break;
end
else
begin
writeln('Watersource not found.');
end;
end;
performAntiBan();
smartImage.clear;
end;
//global variables go in at the beginning of the script, right after the constants, before the first procedure.
var
loads, goalLoads, breakDuration, lastBreak, breakTime: integer;
runTimer: TTimeMarker;
begin
clearDebug();
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then // Does not let the script run if the playerform wasn't filled in properly
exit;
declarePlayers(); // all sorts of setting up
debugSPFSettings();
smartEnableDrawing := true;
setupSRL();
runTimer.start();
//storing setings in variables
loads := 0;
lastBreak := 0;
breakTime := players[currentPlayer].integers[0]; //This is in MINUTES not in seconds!
breakDuration := players[currentPlayer].integers[1]; //This is in MINUTES not in seconds!
goalLoads := players[currentPlayer].integers[2];
if isLoggedIn() then // Sets up your screen to start out
begin
mainscreen.setAngle(MS_ANGLE_HIGH);
end
//this part of this check isnt needed as it is repeated in the following loop
else
begin
players[currentPlayer].login(); //failsafe to make sure you're logged in
minimap.setAngle(MM_DIRECTION_SOUTH);
end;
repeat
if not isLoggedIn() then //failsafe to check your login status, repeated every loop to
begin // make sure the scripy doesn't try to make dough when not logged in.
players[currentPlayer].login();
wait(randomRange(15000,17000));
mainscreen.setAngle(MS_ANGLE_HIGH);
end;
//##################################################################################
goToBanker(); //This is the actual 'dough making run'
clickBanker(); //The other code is either setup stuff or anti-ban stuff
inc(loads);
goToWater(); //The procedures used are to be found at te top of the program
makeDough();
//##################################################################################
performAntiBan(); //Performs random anti-ban actions
if (loads >= goalLoads) then //player form functionality: resting and terminating
begin
goToBanker();
clickBanker();
write('We have reached the goal amount of ' + intToStr(goalLoads) + ' loads, terminating script');
players[currentPlayer].logout();
exit();
end;
if (runTimer.getTime() > breakTime*60000) then
begin
writeln('Running for ' + intToStr(breakTime) + ', taking a break.');
players[currentPlayer].logout();
runTimer.pause();
writeln('Resting for approximately ' + intToStr(breakDuration) + ' minutes.');
wait((breakDuration + randomRange(-3,3))*60000);
runTimer.reset(); // runTimer.start is enough, no need to reset it
runTimer.start();
end;
until false;
end.