SRL Archive - Jr. Member General Help and Discussion

Noob Scripter Welcoming Criticism


srlMW

2015-06-06 01:22:24



Hey guys, I have just started to learn to script in lape and have been able to use everything so far to make this. (This is a learn and build type thing) Please excuse the terrible lape grammar and my horrible use of pretty much everything. :)

If you guys could help me with criticism I would greatly appreciate it!

To Implement
  • Fail safes for *every action
  • An auto updater
  • Auto download for the paint

UPDATE
Updated script to the work in progress V399. ATM I am cleaning up the code, removing the unneeded lines and improving procedures so that everything is 100% bug free and failsafed. I would appreciate suggestions for the script, so that I may learn more, not really knowing what to add anymore.

Added logging in and once finished logging out, going to start working on the auto downloaders now and break handler. Any tips, tricks and examples are welcome as usual, treading into unknown waters again. :unsure:


program masterTreeChopperv399;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint3.png');

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := '';
scriptSettingsPath := '';
editBoxLabels := ['Run for (amount)'];
editBoxDefaults := ['18000000'];
editBoxHints := ['| 5hrs: 18000000 |'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
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]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
stats_Timer: integer;
stats_ID, stats_Pass, stats_ScriptID: string;
stats_Vars: array of TStats_Vars;

procedure stats_Setup(_ScriptID: string);
var
id, pass: string;
begin
if (not directoryExists(stats_Path)) then
begin
forceDirectories(stats_Path);
writeINI('General', 'Stats_ID', '', stats_Path + stats_File);
writeINI('General', 'Stats_Pass', '', stats_Path + stats_File);
end;
id := readINI('General', 'Stats_ID', stats_Path + stats_File);
pass := readINI('General', 'Stats_Pass', stats_Path + stats_File);
if id = '' then
begin
case MessageBox('No Stats ID found, would you like to register?', 'Stats', 1) of
1: openWebPage('http://stats.grats.pw/reg.php');
end;
end;
stats_ID := id;
stats_Pass := pass;
stats_ScriptID := _ScriptID;
stats_Timer := getSystemTime();
end

procedure stats_InitVariable(VarName: string; InitValue: Integer);
var
len: Integer;
begin
len := Length(stats_Vars);
SetArrayLength(stats_Vars, len + 1);
stats_Vars[len].Name := LowerCase(VarName);
stats_Vars[len].Value := InitValue;
end;

procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);
if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := NewValue;
Exit;
end;
stats_InitVariable(VarName, NewValue);
end;

procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);
if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := stats_Vars[i].Value + Value;
Exit;
end;
stats_InitVariable(VarName, Value);
end;

function stats_Commit(): Boolean;
var
S: string;
Client, i, Worked, ExtraTime: integer;
begin
ExtraTime := getSystemTime() - stats_Timer;
Worked := ExtraTime div 60000;
if Worked < 5 then
Exit;
ExtraTime := ExtraTime - (Worked * 60000);
stats_Timer := GetSystemTime - ExtraTime;
Client := InitializeHTTPClient(False);
ClearPostData(Client);
if (stats_ID = '') then
begin
stats_ID := '5';
stats_Pass := 'anon1337';
end;
AddPostVariable(Client, 'user_id', STATS_ID);
AddPostVariable(Client, 'password', STATS_PASS);
AddPostVariable(Client, 'script_id', STATS_SCRIPTID);
AddPostVariable(Client, 'timeamount', toStr(Worked));
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
AddPostVariable(Client, Name, toStr(Min(Value, 30000)));
end;
S := PostHTTPPageEx(Client, 'http://stats.grats.pw/POST.php');
FreeHTTPClient(Client);
case StrToIntDef(ExtractFromStr(S, Numbers), - 1) of
42: Result := True;
9001: writeln('Stats: Invalid user ID/Password.');
1337: writeln('Stats: Invalid Script ID.');
255, 496: writeln('Stats: Committing too fast; shame on you!');
else
writeln('Stats: No POST return');
end;
if Result then
begin
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
Value := 0;
end;
end;
end;

procedure speedAntiBan();
begin
case random(8) of
0..2:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(2, 15, 25);
end;
3..4:
begin
randomMouseSpeed(3, 8, 18);
end;
5..6:
begin
randomMouseSpeed(4, 24, 37);
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(3, 9, 19);
end;
3..4:
begin
randomMouseSpeed(2, 25, 30);
end;
5..6:
begin
randomMouseSpeed(4, 16, 26);
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(3, 7, 17);
end;
3..4:
begin
randomMouseSpeed(4, 13, 23);
end;
5..6:
begin
randomMouseSpeed(2, 20, 28);
end;
end;
end;
end;
end;

procedure checkSkills();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(GaussRangeInt(700, 2000));
end;
3..4:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(GaussRangeInt(550, 1750));
end;
5..6:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(GaussRangeInt(900, 2500));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(GaussRangeInt(700, 2000));
end;
3..4:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(GaussRangeInt(600, 1600));
end;
5..6:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(GaussRangeInt(345, 970));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_FLETCHING);
Wait(GaussRangeInt(400, 1500));
end;
3..4:
begin
hoverSkill(SKILL_FLETCHING);
Wait(GaussRangeInt(500, 1500));
end;
5..6:
begin
hoverSkill(SKILL_FLETCHING);
Wait(GaussRangeInt(1000, 2100));
end;
end;
end;
end;
end;

procedure afkingBurning();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(GaussRangeInt(125000, 135000));
end;
3..4:
begin
mouseOffClient(4);
Wait(GaussRangeInt(115000, 125000));
end;
5..6:
begin
mouseOffClient(4);
Wait(GaussRangeInt(105000, 115000));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(GaussRangeInt(75000, 95000));
end;
3..4:
begin
mouseOffClient(4);
Wait(GaussRangeInt(85000, 100000));
end;
5..6:
begin
mouseOffClient(4);
Wait(GaussRangeInt(91000, 105000));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(GaussRangeInt(89000, 129000));
end;
3..4:
begin
mouseOffClient(4);
Wait(GaussRangeInt(110000, 120000));
end;
5..6:
begin
mouseOffClient(4);
Wait(GaussRangeInt(100000, 120000));
end;
end;
end;
end;
end;

procedure afkingFletching();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(50000, 65000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(67000, 80000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(48000, 53000));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(40000, 45000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(55000, 60000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(75000, 85000));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(70000, 76000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(45000, 50000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(50000, 55000));
end;
end;
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..10: boredHuman(true);
11..15: pickUpMouse();
16..25: smallRandomMouse();
51..65:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
66..70: randomGameTab(true);
71..80: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := logsCut;
fletchedBows := logsFletched * 28;
logsBurnt := logsBurned * 28;
xpGained := ((logsBurned * 28 * 50) + (logsfletched * 28 * 5) + (logsCut * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(372, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(34, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(267, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(148, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(506, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure loggingIn();
begin
if (not isLoggedIn()) then
players[currentPlayer].login();
end;

procedure dropBows();
begin
speedAntiBan();
if tabBackPack.isEmpty then
exit
else if (not tabBackPack.isEmpty) then
case random(4) of
1: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
2: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
3: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
4: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure checkBag();
begin
if (not tabBackPack.isEmpty) then
dropBows();
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(2) of
0..1:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 10 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
speedAntiBan();
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
pickUpMouse();
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
pickUpMouse();
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
pickUpMouse();
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(14000, 15000)) or (cutTimer.getTime > 15000);
if (cutTimer.getTime > (randomRange(14000, 15000))) then
noColour();
inc(logsCut);
stats_IncVariable('29', 1);
stats_IncVariable('80', 25);
paintDisplay();
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
speedAntiBan();
startTimer.start;
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
while tabBackpack.isItemInSlot(slot) or (startTimer.getTime > 5000) do
begin
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
end;
addingTimer.start;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
while (not tabBackpack.waitCount(26, 2000 + random(500))) or (addingTimer.getTime > 7500) do
begin
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(300, 500));
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
while (not tabBackPack.isEmpty) or (burnTimer.getTime > 120000) do
begin
paintDisplay();
case random(13) of
1..10: afkingBurning();
11..13: boredHuman();
end;
end;
inc(logsBurned);
stats_IncVariable('23', 28);
stats_IncVariable('79', 28 * 50);
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 1) then
begin
speedAntiBan();
repeat
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(13) of
1..10: afkingFletching();
11..13: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
stats_IncVariable('65', 28 * 5);
stats_IncVariable('142', 28);
dropBows();
end;
end;
end;

procedure fletchNBurn();
begin
case random(4) of
0..2:
begin
fletchLogs();
end;
3..4:
begin
burnLogs();
end;
end;
end;

procedure fletchingOnly();
begin
fletchLogs();
dropBows();
end;

procedure burningOnly();
begin
burnLogs();
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut;
fletchedBows := logsFletched * 28;
logsBurnt := logsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
speedAntiBan();
findNormalRandoms();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
begin
if players[currentPlayer].booleans[0] and players[currentPlayer].booleans[1] then
fletchNBurn()
else if players[currentPlayer].booleans[0] then
fletchingOnly()
else if players[currentPlayer].booleans[1] then
burningOnly();
end;
paintDisplay();
progressReport();
stats_commit();
end;

begin
addOnTerminate('freeTheDTMs');
clearDebug();
smartEnableDrawing := true;
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
stats_Setup('30');
initDTMs();
stats_commit();
loggingIn();
beginPic();
findNormalRandoms();
checkBag();
walk2Begin();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > players[currentPlayer].integers[0]);
writeln('Ran for inputed time. Finishing up');
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
players[currentPlayer].logout();
freeTheDTMs();
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

Citrus

2015-06-06 02:36:26

I rewrote the first part of your script the way I would do it (not necessarily the best way). Everything was from the top of my head, so it probably won't compile as is.

PLEASE use some kind of logical indentation standard. It's really easy and it helps a LOT.
Get familiar with SRL-6 and try to understand WHY specific functions are used and WHEN to use them (e.g. you used chooseOption after left clicking).

I didn't look at the rest of the code because I really need to sleep, but hopefully you get the idea.

From: indirectMW

program masterTreeChopper;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure changeAngleBoss();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH); //this is all you need
{mainScreen.setAngle(MS_ANGLE_HIGH);
wait(randomRange(100, 200));
minimap.setAngle(MM_DIRECTION_NORTH); //this isn't accurate
wait(randomRange(1000, 2000));}
end;

procedure isBagFull();
begin
tabBackPack.mouseSlot(1, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then //always better to check if the screen is open
if toolScreen.select('Tinderbox') then //might as well check if the option was selected
begin
if tabBackPack.waitSlotPixelChange(1, gaussRangeInt(3000, 5000)) then //there's probably a better way to check this
begin
tabBackPack.mouseSlot(2, MOUSE_MOVE);
if isMouseOverText(['raft Logs'], 345) then
begin
fastClick(MOUSE_LEFT);
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then
if toolScreen.select('Add to bonfire') then
tabBackPack.waitSlotPixelChange(28, 75000); //however long it takes to do an inv of logs;
//a better method that I've used in the past is to loop through
//and check each slot as it is used
end;
end;
end;
end;
end;
{chooseOption.select(['raft Logs']); //this line is literally doing nothing. chooseOption is for right clicking
wait(randomRange(1000, 2000));
toolScreen.select('Tinderbox');
wait(randomRange(5400, 6000));
begin
tabBackPack.mouseSlot(2, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(2000, 4000));
toolScreen.select('Add to bonfire');
wait(randomRange(70000, 80000));

end; <--
end; <-- this made me cry :'(
end; <--
end;}

srlMW

2015-06-06 02:42:50

From: evilcitrus
I rewrote the first part of your script the way I would do it (not necessarily the best way). Everything was from the top of my head, so it probably won't compile as is.

PLEASE use some kind of logical indentation standard. It's really easy and it helps a LOT.
Get familiar with SRL-6 and try to understand WHY specific functions are used and WHEN to use them (e.g. you used chooseOption after left clicking).

I didn't look at the rest of the code because I really need to sleep, but hopefully you get the idea.


Thank you! I will examine the changes now. :biggrin: Sleep well

E: Never mind the compass worked second time…

adc

2015-06-06 03:14:07

Definitely need to work on standardizing, but a good start!

program masterTreeChopper;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure changeAngleBoss();
begin
mainScreen.setAngle(MS_ANGLE_HIGH);
wait(randomRange(100, 200));
minimap.setAngle(MM_DIRECTION_NORTH);
wait(randomRange(1000, 2000));
end;

procedure isBagFull();
begin
tabBackPack.mouseSlot(1, MOUSE_MOVE);

if isMouseOverText(['raft Logs']) then
begin

fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(1000, 2000));
toolScreen.select('Tinderbox');
wait(randomRange(5400, 6000));
tabBackPack.mouseSlot(2, MOUSE_MOVE);

if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(2000, 4000));
toolScreen.select('Add to bonfire');
wait(randomRange(70000, 80000));
end;
end;
end;

procedure clickTree();

var
x, y: integer;
begin
if not isLoggedIn() then
exit;
if mainscreen.findObject(x, y, 1190434, 23, ['vergreen'], MOUSE_RIGHT) then
begin
writeLn('We right clicked a tree!');
chooseOption.select(['hop down']);
tabBackPack.waitForShift(randomRange(10000, 15000));
end;
end;

begin
clearDebug();
setupSRL();
changeAngleBoss();
isBagFull();

repeat
repeat
clickTree();
until tabBackPack.isFull();

wait(randomRange(2000,3000));
tabBackPack.mouseSlot(3, MOUSE_MOVE);

if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(1000, 2000));
toolScreen.select('Tinderbox');
wait(randomRange(5400, 6000));
begin
tabBackPack.mouseSlot(7, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(2000, 4000));
toolScreen.select('Add to bonfire');
wait(randomRange(70000, 80000));
end;
end;
end;
until false; //Forever? I'm not sure what it's repeating until.

tabBackPack.mouseSlot(28, MOUSE_MOVE); //Not sure what the code under here is for,
//as it'll never run.
isMouseOverText(['raft Logs']) = false;

repeat
clickTree();
until tabBackPack.isFull();
end.

Went through it quickly and removed some unnecessary begins/ends and indented it. It makes it significantly easier to read (I hope you'll be able to see that reading through this compared to your first post).

I don't have much commentary on the code itself, as I haven't delved into TPAs yet (though I suggest you doing so at some point; I believe they're more accurate for finding objects than findObject would be, when used appropriately). I would like to offer a word of advice for all coding, and that's to separate your pure decision making code from your actual "do things" code. As an example (here's my horn: toot toot), here's a short script I released a few days ago:

https://villavu.com/forum/showthread.php?t=113336

If I wanted to, I could take all the code from the three procedures I call in mainLoop() (namely, makeHides, openBank and progressReport), copy and past it in order in the main loop and let it run - and it would run identically to the way it currently runs. There would be no noticeable difference, in terms of execution. But the way I separated the code, with the main loop dictating what should be done in what order and the procedures themselves handling the actual work, it makes it far easier to do pretty much everything. Debugging is simpler (you can pinpoint which procedure is giving you an error, for example), the code looks cleaner and is easier to read, and most of all - if you find yourself wanting to take code from one script and move it to another, you can do so much more easily. Instead of having to root through code you might have written a year ago and figure out what does what, you have (assuming you follow proper naming and commenting conventions) well documented code in which you can easily find the needed procedure or function and take it.

Thomas

2015-06-06 04:33:07

I first started with some notes:

program masterTreeChopper;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
//can replace the procedure with this
procedure changeAngleBoss(); //minimap.clickCompass(false);
begin
mainScreen.setAngle(MS_ANGLE_HIGH);
wait(randomRange(100, 200));
minimap.setAngle(MM_DIRECTION_NORTH);
wait(randomRange(1000, 2000));
end;

procedure isBagFull();
begin
tabBackPack.mouseSlot(1, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']); //chooseOption isn't even open when you left click.
wait(randomRange(1000, 2000));
toolScreen.select('Tinderbox');
wait(randomRange(5400, 6000));
begin
tabBackPack.mouseSlot(2, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(2000, 4000));
toolScreen.select('Add to bonfire');
wait(randomRange(70000, 80000));
end;
end;
end;
end;

procedure clickTree();
var
x, y: integer;
begin
if not isLoggedIn() then
exit;
if mainscreen.findObject(x, y, 1190434, 23, ['vergreen'], MOUSE_RIGHT) then //use an ATPA for this.
begin
writeLn('We right clicked a tree!');
chooseOption.select(['hop down']);
tabBackPack.waitForShift(randomRange(10000, 15000)); //what will happen if you chop down the tree first tick?
end;
end;

begin
clearDebug();
setupSRL();
changeAngleBoss();
isBagFull(); //just put this in the repeat
repeat
begin //what will happen if something went wrong during these repeats?
repeat //you dont have any failsafe exits
clickTree();
until tabBackPack.isFull();
wait(randomRange(2000, 3000));
end;
begin
tabBackPack.mouseSlot(3, MOUSE_MOVE); //why would you do this here and before?
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(1000, 2000));
toolScreen.select('Tinderbox');
wait(randomRange(5400, 6000));
begin
tabBackPack.mouseSlot(7, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(2000, 4000));
toolScreen.select('Add to bonfire');
wait(randomRange(70000, 80000));
end;
end;
end;
end;
until tabBackPack.mouseSlot(28, MOUSE_MOVE); //this wont work, it'll just loop until the mouse has been moved to slot 28.
isMouseOverText(['raft Logs']) = false; //i'm sorry, but what is false?

repeat //
clickTree(); // //why would you do this a second time?
until tabBackPack.isFull(); //
end.

Then realised I could have just rewritten it:

program masterTreeChopper;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure burnLogs();
begin
tabBackPack.mouseSlot(1, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
wait(randomRange(1000, 2000));
toolScreen.select('Tinderbox');
wait(randomRange(5000, 6000));
tabBackPack.mouseSlot(2, MOUSE_MOVE);
if isMouseOverText(['raft Logs']) then
begin
fastClick(MOUSE_LEFT);
chooseOption.select(['raft Logs']);
wait(randomRange(2000, 4000));
if toolScreen.select('Add to bonfire') then
waitTypeFunc(@ tabBackpack.isEmpty, random(500), randomRange(70000, 100000))
end;
end;
end;

procedure clickTree();
var
x, y: integer;
begin
if not isLoggedIn() then
exit;
if mainscreen.findObject(x, y, 1190434, 23, ['vergreen'], MOUSE_RIGHT) then
begin
writeLn('We right clicked a tree!');
if chooseOption.select(['hop down']) then
tabBackPack.waitForShift(randomRange(10000, 15000));
end;
end;

procedure mainloop();
begin
while (not tabBackPack.isFull()) do
clickTree();
burnLogs();
end;

procedure setup();
begin
clearDebug();
setupSRL();
minimap.clickCompass(false);
end;

begin
setup();
while isLoggedIn() do
mainLoop();
end.


Have a look at my basic combine script (junior rs3 section) for the following:
-rotating map/compass when no banker (in your case tree) has been found
-failsafes to exit loops
-srl player form
-drawing a basic paint on smart and in simba console
-basic antiban
-basic breaking system
-loginchecks
-closing squeel/claiming tickets etc

It's written pretty read-able imo, so shouldn't be hard to addept.

srlMW

2015-06-06 05:35:38

Updated procedures setCompass() and isBagFull()

Question, when he is adding logs to bonfire and it dies, how do you detect that has happened and then make him light another one? Cheers

program masterTreeChopper;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure setCompass();
begin
Minimap.clickCompass(); //clicks compass
mainscreen.setAngle(MS_ANGLE_HIGH); //sets angle to high
end;

procedure isBagFull();
begin
if tabBackpack.isFull then //checks to see if backpack is full
writeln('Your Backpack is full!');
if not tabBackpack.isFull then //checks to see if backpack is not full
exit; //skips to next procedure
begin
if tabBackpack.mouseSlot(6, MOUSE_MOVE) then //moves mouse to slot 6
writeln('We have moved the mouse to backpack slot 6');
if tabBackpack.mouseSlot(1, MOUSE_MOVE) then //moves mouse to slot 1
writeln('We have moved the mouse to backpack slot 1');
begin
fastClick(MOUSE_LEFT) //clicks the first slot
begin
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then //checks to see if tool screen is open
writeln('The tool screen is open!')
if toolScreen.select('Tinderbox') then //selects tinderbox option
writeln('We have made fire!*cavemen noises*');
begin
if TabBackPack.waitSlotPixelChange(1, 10000) then //waits till slot 1 has changed
writeln('First log has changed!');
begin
if tabBackpack.mouseSlot(2, MOUSE_MOVE) then //moves mouse to slot 2
writeln('We have moved the mouse to backpack slot 2');
begin
fastClick(MOUSE_LEFT) //clicks the second slot
begin
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then //checks to see if tool screen is open
writeln('The tool screen is open!');
begin
if toolScreen.select('Add to bonfire') then //selects tinderbox option
writeln('We are making more fire!*more cavemen noises*');
begin
if TabBackPack.waitSlotPixelChange(28, 100000) then //waits till slot 28 has changed
writeln('All good to start chopping!');

end;
end;
end;
end;
end;
end;
end;
end;
end;
end;

Thomas

2015-06-06 05:58:20

Try avoiding waitpixelshift unless it is needed.
Use things like; is item in slot x? Invent count < 28 etc.

That if.. then - begin..end writing method is horrible to read.

Ditch the useless writeLn's.

Combine 2 if..thens for example:
If mouseovertext (blabla) and mouseclick(left) then
While toolscreen.isopen(1000) do
Select.tinderbox;

Dont do mouse move if you arent going to check for an uptext before you click.

srlMW

2015-06-06 08:09:21

Updated the entire script from original

Will now start to improve script based on previous comments! Pull this one apart at will. :)

E: The bot never completes a full bag on the bonfire(gets to 18ish), and then just stands still. What should I implement to change this?

program masterTreeChopperv2;
{$DEFINE SMART} // comment this line out if you don't want to use SMART
{$i srl-6/srl.simba}

procedure setCompass();
begin
Minimap.clickCompass(); //clicks compass
mainscreen.setAngle(MS_ANGLE_HIGH); //sets angle to high
end;

procedure isBagFull();
begin
if tabBackpack.isFull then //checks to see if backpack is full
writeln('Your Backpack is full!');
if not tabBackpack.isFull then //checks to see if backpack is not full
exit; //skips to next procedure
begin
if tabBackpack.mouseSlot(6, MOUSE_MOVE) then //moves mouse to slot 6
writeln('We have moved the mouse to backpack slot 6');
if tabBackpack.mouseSlot(1, MOUSE_MOVE) then //moves mouse to slot 1
writeln('We have moved the mouse to backpack slot 1');
begin
fastClick(MOUSE_LEFT) //clicks the first slot
begin
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then //checks to see if tool screen is open
writeln('The tool screen is open!')
if toolScreen.select('Tinderbox') then //selects tinderbox option
writeln('We have made fire!*cavemen noises*');
begin
if TabBackPack.waitSlotPixelChange(1, 5000) then //waits till slot 1 has changed
writeln('First log has changed!');
begin
wait(randomRange(1000, 2000));
if tabBackpack.mouseSlot(2, MOUSE_MOVE) then //moves mouse to slot 2
writeln('We have moved the mouse to backpack slot 2');
begin
fastClick(MOUSE_LEFT) //clicks the second slot
begin
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then //checks to see if tool screen is open
writeln('The tool screen is open!');
begin
if toolScreen.select('Add to bonfire') then //selects tinderbox option
writeln('We are making more fire!*more cavemen noises*');
begin
if TabBackPack.waitSlotPixelChange(28, 100000) then //waits till slot 28 has changed
writeln('All good to start chopping!');

end;
end;
end;
end;
end;
end;
end;
end;
end;
end;


procedure cutTrees();

var
x, y: integer;

begin
if not tabBackpack.isFull then //checks if bag isn't full
if mainscreen.findObject(x, y, 1652524, 4, ['vergreen']) then MOUSE_LEFT //finds evergreen tree
begin
wait(randomRange(5000, 7000))
begin
writeln('Started to cut an evergreen!');

end;
end;
end;

procedure bonfireLogs();
begin
if tabBackpack.isFull then //checks to see if backpack is full
writeln('Your Backpack is full!');
if not tabBackpack.isFull then //checks to see if backpack is not full
exit; //skips to next procedure
begin
if tabBackpack.mouseSlot(6, MOUSE_MOVE) then //moves mouse to slot 6
writeln('We have moved the mouse to backpack slot 6');
if tabBackpack.mouseSlot(1, MOUSE_MOVE) then //moves mouse to slot 1
writeln('We have moved the mouse to backpack slot 1');
begin
fastClick(MOUSE_LEFT) //clicks the first slot
begin
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then //checks to see if tool screen is open
writeln('The tool screen is open!')
if toolScreen.select('Tinderbox') then //selects tinderbox option
writeln('We have made fire!*cavemen noises*');
begin
if TabBackPack.waitSlotPixelChange(1, 5000) then //waits till slot 1 has changed
writeln('First log has changed!');
begin
wait(randomRange(1000, 2000));
if tabBackpack.mouseSlot(2, MOUSE_MOVE) then //moves mouse to slot 2
writeln('We have moved the mouse to backpack slot 2');
begin
fastClick(MOUSE_LEFT) //clicks the second slot
begin
if toolScreen.isOpen(gaussRangeInt(1000, 2000)) then //checks to see if tool screen is open
writeln('The tool screen is open!');
begin
if toolScreen.select('Add to bonfire') then //selects tinderbox option
writeln('We are making more fire!*more cavemen noises*');
begin
if TabBackPack.waitSlotPixelChange(28, 100000) then //waits till slot 28 has changed
writeln('All good to start chopping!');

end;
end;
end;
end;
end;
end;
end;
end;
end;
end;

procedure mainLoop();

begin
while not tabBackPack.isFull() do
cutTrees();
bonfireLogs();

end;



begin
clearDebug();
setupSRL();
setCompass();
isBagFull();
cutTrees();
mainLoop();
bonfireLogs();
end.

Thomas

2015-06-06 09:27:49

You didn't implement it like I suggested.. It does not repeat the mainloop.

The bonfirelogs replaces the isbagfull.
Why would you need them both?

Try looking at every line of code, and ask yourself; does the script actually need this line?
Example for the cutTree procedure you dont have to check backpack twice (once in mainloop, once in the procedure itself)
You also dont need the repeat within the procedure itself, as it already repeats it due to the mainloop while..do

Citrus

2015-06-06 10:27:45

Here is a way to check if the bonfire is still active:

for i := 1 to 28 do
if tabBackPack.isItemInSlot(i) then break(); //this sets i to the first item in your backpack
repeat
if tabBackPack.waitSlotPixelShift(i, 4000) then //each log takes 6 game ticks
inc(i)
else exit(); //or break or whatever
until i > 28;

Your indentation is much better, but you're still not quite getting the standard. Look at the finished script at the end of this tutorial and check out how beautiful it is.

srlMW

2015-06-06 18:06:22

From: evilcitrus
Here is a way to check if the bonfire is still active:

for i := 1 to 28 do
if tabBackPack.isItemInSlot(i) then break(); //this sets i to the first item in your backpack
repeat
if tabBackPack.waitSlotPixelShift(i, 4000) then //each log takes 6 game ticks
inc(i)
else exit(); //or break or whatever
until i > 28;

Your indentation is much better, but you're still not quite getting the standard. Look at the finished script at the end of this tutorial and check out how beautiful it is.


I am unsure of how to add that code in and make use of it? Would an example be out of the question? :confused:

adc

2015-06-06 18:11:33

From: indirectMW
I am unsure of how to add that code in and make use of it? Would an example be out of the question? :confused:


Basically it just loops through each inventory slot, waiting for a pixel shift; if this pixel shift doesn't happen within 4 seconds, it breaks out of the loop assuming the bonfire has disappeared; otherwise, it increments i and repeats for the next inventory slot.

J_R

2015-06-06 18:13:20

If you're worried about indentation and all that other stuff but aren't overly fond of your comments, I have a solution for you!

Just open up simba and…
1. go to view -> extensions
2. enable formatter.sex
3. go to parser in the top menu and click format script
4. watch in amazement as it opens up a new nicely indented/formatted version of the script for you! (except the comments are gone, might want to add them back in the first time and then keep the script looking pretty so you don't need to do it again!)

Just thought I'd say this since you were overly worrying about indentation and wasting too much energy there than towards fixing functionality (which is more important when learning at least).

srlMW

2015-06-07 05:32:08

UPDATE
Currently working on a brand new completely rewritten script with numerous new procedures and features.


Question: I am currently trying to implement an anti ban with these features so that when the procedure is called on it will randomly choose one of them. Like assigning a set number to each one then having the simba choose one at random etc. picks between x and x then does it type of thing. All help is appreciated! :thumbsup::thumbsup:
  
hoverSkill(SKILL_WOODCUTTING);
hoverSkill(SKILL_FIREMAKING);
mouseMovingObject();
randomGameTab(true);
randomCameraAngle(MS_ANGLE_HIGH);
randomMouseSpeed(3, 10, 20);
smallRandomMouse();
mouseOffClient(OFF_CLIENT_RANDOM);
pickUpMouse();
sleepAndMoveMouse(1000 + random(2000));

adc

2015-06-07 14:48:44

Use case:


i = randomRange(0, 500);
case i of
1..100: //do one thing
101..200: //do another thing

Thomas

2015-06-07 16:08:14

From: adc
Use case:


i = randomRange(0, 500);
case i of
1..100: //do one thing
101..200: //do another thing

No need to use another variable for this.
You also dont have to use a randomRange whenever you have a min of 0.

Case random(10) of
0..5: doStuff();
6..9: doOtherStuff();
End;


Anyway if the OP would just look at the basicCombine script like I suggested he wouldnt even have to ask such a question.

adc

2015-06-07 17:06:45

From: lovebotter
No need to use another variable for this.
You also dont have to use a randomRange whenever you have a min of 0.

Case random(10) of
0..5: doStuff();
6..9: doOtherStuff();
End;


Anyway if the OP would just look at the basicCombine script like I suggested he wouldnt even have to ask such a question.


I just pulled an example out of the script I'm currently running, since I couldn't remember off the top of my head. Good to know.

srlMW

2015-06-07 19:55:09

Cheers guys for all the help, implementing it now!

PS. lovebotter: I didn't understand what that was for in your script, now I do since a purpose/function was given to it. I have been learning from yours and many other peoples scripts non stop. :)

From: lovebotter
Anyway if the OP would just look at the basicCombine script like I suggested he wouldnt even have to ask such a question.

srlMW

2015-06-08 07:50:58

UPDATE
Updated script to the work in progress V3 with brand new completely rewritten procedures and features.


program masterTreeChopperv3;
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
LoadsDone: integer;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..25:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
26..51:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.open()) then
tabBackPack.open;
end;

begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
begin
end;

procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
findColorsSpiralTolerance(x, y, TPA, 793880, mainScreen.getBounds(), 10, colorSetting(2, 0.86, 1.68));
ATPA := TPA.toATPA(30, 30);
ATPA.filterBetween(0, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE, MOUSE_HUMAN);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
tabBackpack.waitForShift(randomRange(5000, 7000));
until tabBackpack.isFull();
inc(LoadsDone);
end;

procedure chopTrees();
begin
end;

procedure burnLogs();
begin
end;

procedure fletchLogs();
begin
end;

procedure dropLogs();
begin
end;

procedure progressReport();
var
choppedTrees: integer;
begin
choppedTrees := LoadsDone * 28;
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|Chopped Trees: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
clearScreen();
setCompass();
while not tabBackPack.isFull() do
begin
checkSkills();
speedAntiBan();
locateTrees();
chopTrees();
end;
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
speedAntiBan();
checkskills();
randomHumanBehaviour();
clearScreen();
setCompass();
locateTrees();
chopTrees();
progressReport();
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

Thomas

2015-06-08 08:09:30

I much prefer using cluster over toATPA to make an ATPA out of a TPA.
Try using this:
ATPA := TPA.cluster(20);


You'll also have to make sure your ATPA wont be empty before going through the options.
if (length(ATPA) < 1) then
exit();

What's the point of this line in your current script:
tabBackpack.waitForShift(randomRange(5000, 7000));
It serves no point at all currently.
This is because you use your checks for a fullbackpack wrong.
You don't have to check them twice. Currently it'll just keep looping your locating of the tree until backpack is full.
It won't do the antiban. During that loop.

So to solve:
repeat locating of tree (and clickig) until waitforshift.
And just check for inventisfull in mainloop.

You'll also have to perfom things like open backpack during your mainloop.
Also it wont even do the mainloop currently, you aren't calling it.

srlMW

2015-06-08 08:37:23

From: lovebotter
I much prefer using cluster over toATPA to make an ATPA out of a TPA.
Try using this:
ATPA := TPA.cluster(20);


You'll also have to make sure your ATPA wont be empty before going through the options.
if (length(ATPA) < 1) then
exit();

What's the point of this line in your current script:
tabBackpack.waitForShift(randomRange(5000, 7000));
It serves no point at all currently.
This is because you use your checks for a fullbackpack wrong.
You don't have to check them twice. Currently it'll just keep looping your locating of the tree until backpack is full.
It won't do the antiban. During that loop.

So to solve:
repeat locating of tree (and clickig) until waitforshift.
And just check for inventisfull in mainloop.

You'll also have to perfom things like open backpack during your mainloop.
Also it wont even do the mainloop currently, you aren't calling it.


Testing out the changes you said above, everything compiles correctly but then when running it stumps here "Error: Access violation at line 107". Here is the procedure
procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA := TPA.cluster (20);
begin
repeat
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.toATPA(30, 30);
ATPA.filterBetween(0, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
if (length(ATPA) < 1) then
exit();
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
until tabBackpack.isFull();
inc(LoadsDone);
end;

Not sure if I need to edit more for the changes you have suggested. :confused:

fady

2015-06-08 09:33:42

From: indirectMW
SNIP


I think he meant something like this.



//You are repeating this procedure in your mainloop, while not the backpack is full.
//Then we dont have to repeat it in here untill the backpack is full because if it was, the mainloop wouldn't call this procedure.
//So we dont need to repeat this until the backpack is full. He suggested repeating till pixel shift occurs, so you might want to try it.
//I dont think it is necessary tho.
procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: ; T2DPointArray;
begin
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34)); //this part finds the colors and stores them in the Var TPA
ATPA := TPA.cluster(20); //This part groups all TPA's that are within 20 pixels of each other and converts them into an ATPA.
if (length(ATPA) < 1) then // If the length of the ATPA that we made is less than 1 which means that our ATPA is empty.
exit(); // The procedure will exit.
ATPA.sortFromMidPoint(mainscreen.playerPoint); //This sorts your ATPA by which one is closer to your char.
smartImage.debugTPA(TPA, false); //This line draws boxes for your ATPA on your screen (Notice how they are numbered, with the box labeled 0 being the one closes to your char)

//Ok so now that I have found my colors and stored them into a TPA, clustered them and converted them into an ATPA, then made sure my ATPA was not empty
//then sorted my ATPA so the box labeled 0 (the first box the script tries to click) is the one closest to the char. I can now start to do whatever I want to the boxes the script found.

for i := 0 to high(ATPA) do //will start with box 0 and attempt to do the same thing on the rest of the boxes in order.
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE); //moves the mouse to the middle of the box
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then //if the mouseOverText shows we're hovering over a tree
begin
fastClick(MOUSE_LEFT); //Then we left click it.
smartImage.clear; //We also clear the boxes drawn on smart.
break; //And we break out of the loop, so it doesn't have to keep looking at the other ATPAs because we have already found a tree.
end;
end;
inc(LoadsDone);
end;


EDIT: If this helps you out LMK, I'll take a look at the rest of your script and label it for you. I wont fix it so you will get a chance to attempt at makin it work, ill just label everything so you can see exactly what each procedure is doing.

Thomas

2015-06-08 10:07:15

@fady
Yes. That is pretty much what I meant. Thanks!

But you forgot to also filter the small TPA's from the ATPA. Should do that before checking the length.
Or you can ditch that step and just sort the TPA's in our ATPA by size. So the TPA with the most tpoints (our color points) will be 0. This means its most often the correct array we are looking for and often a close to mainpoint TPA (more pixels/model closer to the player).

On the ATPA length check; the whole point of exiting when its empty is to prevent errors in the script when you run trough the possible TPA's (for 0 to high(ATPA) do), so that when the script did not find any colors it doesnt crash.

For finding the colors and putting them into a TPA, I also prefer using 'gatherIn' over 'findspiralcolortol', as I think it looks cleaner, and you dont use the X, Y integers anyway.

srlMW

2015-06-09 01:48:57

UPDATE
Updated script to the work in progress V3.1. It now drops and loops!


program masterTreeChopperv3.1;
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
LoadsDone: integer;
LogsLoad: integer;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(300) of
0..25:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
26..51:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.open()) then
tabBackPack.open;
end;

begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
begin
end;

procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if tabBackPack.isfull then
exit;
begin
repeat
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
if tabBackpack.waitForShift(randomRange(7000, 8000)) then
inc(LoadsDone);
break;
end;
end;
begin
case random(6) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;
until tabBackPack.isFull();
end;
end;

procedure burnLogs();
begin
end;

procedure fletchLogs();
begin
end;

procedure dropLogs();
begin
repeat
if tabBackPack.isFull() then
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
begin
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
end;
inc(LogsLoad);
end;

procedure progressReport();
var
choppedTrees: integer;
logsDropped: integer;
begin
choppedTrees := LoadsDone;
logsDropped := LogsLoad * 27;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|Chopped Trees: ' + intToStr(choppedTrees));
writeLn('|Logs Dropped: ' + intToStr(logsDropped));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
repeat
clearScreen();
setCompass();
while not tabBackPack.isFull() do
begin
locateTrees();
dropLogs();
end;
until LoadsDone = 1000
begin
if LoadsDone = 1000 then
progressReport();
end;
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
repeat
speedAntiBan();
checkskills();
clearScreen();
setCompass();
locateTrees();
dropLogs();
progressReport();
until LoadsDone = 1000
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

Thomas

2015-06-09 07:08:44

You still check for backpack.isfull more then you need to.
Just stop with the useless coding and start asking yourself if the script actually needs the lines and checks you use.

begin
if not (tabBackPack.open()) then
tabBackPack.open;
end;

What is the point of this? Do you understand what this will do?
In essence it will open the backpack once, and if for some weird reason it doesnt open it, the script will try a second time.

I suggest you have a look at my tutorial in the beginners rs3 section.
I havent had time to update it though, but it should help you clean up your script.

srlMW

2015-06-09 08:43:13

UPDATE
Updated script to the work in progress V3.2. It now drops, fletches and loops!


program masterTreeChopperv3.2;
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
LoadsDone: integer;
LogsLoad: integer;
LogsCrafted: integer;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(300) of
0..25:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
26..51:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.open()) then
tabBackPack.open;
end;

begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
begin
end;

procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if tabBackPack.isfull then
exit;
begin
repeat
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
if tabBackpack.waitForShift(randomRange(7000, 8000)) then
inc(LoadsDone);
break;
end;
end;
begin
case random(6) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;
until tabBackPack.isFull();
end;
end;

procedure burnLogs();
begin
end;

procedure fletchLogs();
begin
if tabBackPack.isFull() then
case random(11) of
0..2:
begin
tabBackpack.mouseSlot(2, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
end;
3..5:
begin
tabBackpack.mouseSlot(6, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
end;
6..8:
begin
tabBackpack.mouseSlot(3, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
exit;
end;
9..11:
begin
tabBackpack.mouseSlot(28, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
exit;
end;
end;
end;

procedure dropLogs();
begin
repeat
if tabBackPack.isFull() then
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
begin
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
end;
inc(LogsLoad);
exit;
end;

procedure progressReport();
var
choppedTrees: integer;
logsDropped: integer;
craftedShafts: integer;
begin
choppedTrees := LoadsDone;
logsDropped := LogsLoad * 27;
craftedShafts := LogsCrafted;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|Logs Dropped: ' + intToStr(logsDropped));
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
repeat
clearScreen();
setCompass();
while not tabBackPack.isFull() do
begin
locateTrees();
case random(8) of
0..8: fletchLogs();
end;
end;
until LoadsDone = 1000
begin
if LoadsDone = 1000 then
progressReport();
end;
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
repeat
speedAntiBan();
checkskills();
clearScreen();
setCompass();
locateTrees();
fletchLogs();
progressReport();
until LoadsDone = 1000
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!


From: lovebotter
You still check for backpack.isfull more then you need to.
Just stop with the useless coding and start asking yourself if the script actually needs the lines and checks you use.

begin
if not (tabBackPack.open()) then
tabBackPack.open;
end;

What is the point of this? Do you understand what this will do?
In essence it will open the backpack once, and if for some weird reason it doesnt open it, the script will try a second time.

I suggest you have a look at my tutorial in the beginners rs3 section.
I havent had time to update it though, but it should help you clean up your script.


I'll do a clean up of the script when I finish adding in all procedures. :)

fady

2015-06-09 12:09:07

From: indirectMW
UPDATE
Updated script to the work in progress V3.2. It now drops, fletches and loops!


program masterTreeChopperv3.2;
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
LoadsDone: integer;
LogsLoad: integer;
LogsCrafted: integer;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(300) of
0..25:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
26..51:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.open()) then
tabBackPack.open;
end;

begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
begin
end;

procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if tabBackPack.isfull then
exit;
begin
repeat
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
if tabBackpack.waitForShift(randomRange(7000, 8000)) then
inc(LoadsDone);
break;
end;
end;
begin
case random(6) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;
until tabBackPack.isFull();
end;
end;

procedure burnLogs();
begin
end;

procedure fletchLogs();
begin
if tabBackPack.isFull() then
case random(11) of
0..2:
begin
tabBackpack.mouseSlot(2, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
end;
3..5:
begin
tabBackpack.mouseSlot(6, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
end;
6..8:
begin
tabBackpack.mouseSlot(3, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
exit;
end;
9..11:
begin
tabBackpack.mouseSlot(28, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341));
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000));
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then
exit;
begin
repeat
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
exit;
end;
end;
end;

procedure dropLogs();
begin
repeat
if tabBackPack.isFull() then
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
begin
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
end;
inc(LogsLoad);
exit;
end;

procedure progressReport();
var
choppedTrees: integer;
logsDropped: integer;
craftedShafts: integer;
begin
choppedTrees := LoadsDone;
logsDropped := LogsLoad * 27;
craftedShafts := LogsCrafted;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|Logs Dropped: ' + intToStr(logsDropped));
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
repeat
clearScreen();
setCompass();
while not tabBackPack.isFull() do
begin
locateTrees();
case random(8) of
0..8: fletchLogs();
end;
end;
until LoadsDone = 1000
begin
if LoadsDone = 1000 then
progressReport();
end;
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
repeat
speedAntiBan();
checkskills();
clearScreen();
setCompass();
locateTrees();
fletchLogs();
progressReport();
until LoadsDone = 1000
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!




I'll do a clean up of the script when I finish adding in all procedures. :)


working on the whole script. Give me a couple of minutes i'll comment with my suggestions and comments.

Hoodz

2015-06-09 12:25:48

please watch out if you use repeat until loops for infinite loops.

fady

2015-06-09 12:59:44

From: indirectMW
SNIP


Ok! lets work on making this script easy to read and clean while also making sure that we don't have any redundant code in there. I'm going to break the script apart into pieces and do it piece by piece as I go along. I probably won't include fail-safes for now, once you get the hang of it, we can work on implementing fail-safes and breaking out of infinite loops and other things to make sure the script doesn't mess up or get stuck.

var
LoadsDone: integer;
LogsLoad: integer;
LogsCrafted: integer;

//Since all three variables are the same type (Integer), we can just shrink this into one line

var
loadsDone, logsLoad, logsCrafted: integer;

//Notice how I slightly changed the capitalization on them. The first letter should always be small, but that isn't really a big deal.
Moving on.
procedure clearScreen();
begin
if not (tabBackPack.open()) then //If it fails at opening the backpack tab.
tabBackPack.open; //It will try again.
end;
Some general themes in the SRL include is that when anything is .open, That means that the function will attempt the open whatever is selected then return true if it was successful or false if it was not. So looking at your code we can see, that tabBackPack.open is going to open the backpack and then return true or false depending on success, and if it wasn't successful, it will try the same function again. Maybe what you are looking for is the function tabBackPack.isOpen, as this will only check to see if it is open and not attempt to open it.
procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then //This will ONLY check to see if the backpack is open, wont attempt to open it.
tabBackPack.open; //If it is not open, it will open it.
end;
Maybe that wasn't an error and was intentional as a failsafe, I don't know, but I just found it unusual.

Moving on we find a block of code that is just floating in the script and not part of a procedure, because the previous one was ended already, and these are not part of the following procedure.

begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;
we can either change that it its own procedures and call it for instance findNormalRandoms, or include it in a separate procedure with your other setup code. for now, we'll just make it its own procedure like so.

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;
Ok the next thing that I see is in the locateTrees procedure.

//As it stands, this procedure is going to find then click a tree.
//Then wait for a backpack shift, if it happens will inc loadsDone by 1.
//After finding and clicking a tree or a failure it will do some antiban.
//and this whole loop is going to repeat until the backpack is full.
procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if tabBackPack.isfull then
exit;
begin //You dont need this begin and its coupled end because the script will read through the whole procedure unless told otherwise.
repeat
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
if tabBackpack.waitForShift(randomRange(7000, 8000)) then
inc(LoadsDone);
break;
end;
end;
begin //again dont need this begin..end because nothing is telling the script not to read it
case random(6) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;
until tabBackPack.isFull();
end;
end;
Now I don't recommend you do it that way, because theres a failsafe implemented where if the ATPA that I gathered was empty then the script with exit the whole procedure (We should not change that part). So now if that does happen, the script will stop cutting trees and move on to the next procedure. I recommend changing from trying to chop trees till the backpack is full to only having it chop and obtain 1 log then do some antiban. We can then have the whole procedure repeated later on in the script.

//As it stands now this snippet is going to repeat trying to find a tree, and left clicking it.
//Then stops the loop if the backpack count changes within 7-8 seconds of clicking the tree.
//After backpack count changes (Obtaining a log), it will do a little antiban.
//This procedure will not only obtain ONE log before moving on.
procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if tabBackPack.isfull then
exit;
repeat
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear; //removed the wait for shift from this part
inc(loadsDone);
break;
end;
end;
until tabBackpack.waitForShift(randomRange(7000, 8000)); //and moved it to here so the script loops until this function returns true.
case random(6) of //after finding a tree and obtaining a log it will do antiban.
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;
In the next procedure you have a block of code that is being repeated over and over, with the only difference being the inventory slot. This can be easily obtained in much much fewer lines by add a local integer variable and naming it 'slot'. then depending on the result of the random number, 'slot' is assigned a diff number. Then performing the block of code. Other comments have also been added
We are gona go from

procedure fletchLogs();
begin
if tabBackPack.isFull() then
case random(11) of
0..2:
begin
tabBackpack.mouseSlot(2, MOUSE_LEFT);
if toolScreen.isOpen() then
if toolScreen.__find() then //You dont need this line, the previous line does the same thing.
(toolScreen.select('Knife'));
wait(randomRange(500, 1000));
mouse(point(387, 341)); //Static coordinates are very very very big no! I'm going to assume that this is your script pressing the start button.
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(randomRange(3500, 4000)); //If the progress screen opened then we can assume that a shift will happen so the following lines are not needed
if not tabBackpack.waitForShift(randomRange(3500, 4000)) then //this line
exit; //and this line
begin //Again a begin..end block that is not needed.
repeat
if progressScreen.isOpen() then //I suggest adding a wait time between repeats so the script doesnt keep looping through antiban with no downtime.
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
end;
inc(LogsCrafted);
end;
3..5: //the rest is just repeated code of the same thing.
I'm going to modify that to this.

procedure fletchLogs();
var
slot: Integer; //our local slot variable
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2; //assigns backpack slot 2
3..5: slot := 6; //assigns backpack slot 6
6..8: slot := 3; //assigns backpack slot 3
9..11: slot := 28; //assigns backpack slot 28
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT); //this will move the mouse to the assigned slot selected above.
if toolScreen.isOpen(1000) then //If the tool screen is open within 1 second.
toolScreen.select('Knife'); //it will select the knife option.
wait(randomRange(500, 1000)); //waits between 0.5-1 seconds
if productionScreen.isOpen(1000) then //If the production screen is open within 1 second
productionScreen.clickStart(); //it will click the start button in the production screen.
if progressScreen.isOpen(randomRange(3500, 4000)) then //if the progress screen is open within 3.5-4 seconds then
begin //I need a begin..end; here so both the wait and inc(logsCrafted) are included under the if statement.
repeat // will wait and do antiban if the progress screen is still open, until the progress screen is not open.
wait(randomRange(500, 1000);
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
inc(logsCrafted);
end;
end;
end;
the next procedure (dropLogs) is good, I just have a few comments tho.

procedure dropLogs();
begin
repeat //we can get stuck in this loop, if the backpack isn't full when we enter the procedure.
if tabBackPack.isFull() then
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
begin //no need for begin..end here.
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
end;
inc(LogsLoad);
exit; //dont need the exit here as it is already the end of the procedure
end;
we can add a backpack check at the beginning of the procedure to make sure that it is full before starting, then once we know for sure, we dont need to check for it again.

procedure dropLogs();
begin
if not tabBackPack.isFull() then
exit;
repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
inc(logsLoad);
end;
Now to the mainloop procedure.

procedure mainLoop();
begin
repeat //no need to loop here because we will have the script repeat the mainloop below.
clearScreen();
setCompass();
while not tabBackPack.isFull() do //we changed the wait locate trees works in the beginning so now we have to adjust this too.
begin
locateTrees();
case random(8) of //this will always do fletchLogs, you dont need a case statement here
0..8: fletchLogs();
end;
end;
until LoadsDone = 1000
begin
if LoadsDone = 1000 then
progressReport(); //the progress report will only be called when the loads done are over 1000
end;
end;

We can change this to

procedure mainLoop();
begin
clearScreen();
setCompass();
while not tabBackPack.isFull() do // will repeat only locateTrees until the backpack is full
begin
locateTrees();
end;
progressReport(); //calls a progress report
fletchLogs(); //calls feltchLogs
progressReport(); //calls the progress report again after fletch logs
end;

now to the final thing which is the actual main loop of the script.

begin //we aren't even calling the mainloop procedure we made above, so this has to change a little.
clearDebug();
smartEnableDrawing := true;
setupSRL();
repeat
speedAntiBan(); //this is not needed here as it is called many times within the script
checkskills(); //same thing with this
clearScreen(); //the mainloop already starts with a clearScreen procedure so this isnt needed
setCompass(); //same thing with this one.
locateTrees(); //again in the mainloop
fletchLogs(); //same
progressReport(); //and same
until LoadsDone = 1000
end.

so now we end up having the following.

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
findNormalRandoms(); //calls the procedure we made above, to close all the popups from jagex before startin
repeat //will repeat the mainloop until loadsDone is more than a 1000
mainLoop();
until (LoadsDone > 1000);
end.


for a complete finished script that looks like:

program masterTreeChopperv32; //changed the name because you have a '.' in the name
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
loadsDone, logsLoad, logsCrafted: integer;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(300) of
0..25:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
26..51:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
begin
end;

procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if tabBackPack.isfull then
exit;
repeat
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
inc(LoadsDone);
break;
end;
end;
until tabBackpack.waitForShift(randomRange(7000, 8000));
case random(6) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
begin
end;

procedure fletchLogs();
var
slot: Integer; //our local slot variable
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2; //assigns backpack slot 2
3..5: slot := 6; //assigns backpack slot 6
6..8: slot := 3; //assigns backpack slot 3
9..11: slot := 28; //assigns backpack slot 28
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT); //this will move the mouse to the assigned slot selected above.
if toolScreen.isOpen(1000) then //If the tool screen is open within 1 second.
toolScreen.select('Knife'); //it will select the knife option.
wait(randomRange(500, 1000)); //waits between 0.5-1 seconds
if productionScreen.isOpen(1000) then //If the production screen is open within 1 second
productionScreen.clickStart(); //it will click the start button in the production screen.
if progressScreen.isOpen(randomRange(3500, 4000)) then //if the progress screen is open within 3.5 - 4 seconds then
begin //does the wait loop and increases logsCrafted.
repeat // will wait and do antiban if the progress screen is still open, until the progress screen is not open.
wait(randomRange(500, 1000));
if progressScreen.isOpen() then
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
inc(LogsCrafted);
end;
end;
end;

procedure dropLogs();
begin
if not tabBackPack.isFull() then
exit;
repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
inc(LogsLoad);
end;

procedure progressReport();
var
choppedTrees: integer;
logsDropped: integer;
craftedShafts: integer;
begin
choppedTrees := LoadsDone;
logsDropped := LogsLoad * 27;
craftedShafts := LogsCrafted;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|Logs Dropped: ' + intToStr(logsDropped));
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
clearScreen();
setCompass();
while not tabBackPack.isFull() do
begin
locateTrees();
end;
progressReport();
fletchLogs();
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
findNormalRandoms();
repeat
mainLoop();
until LoadsDone = 1000;
end.


I have not tested this script. So I dont recommend you use it as a game ready script. Also I apologize if my notes got sloppy towards the end. PM me if anything was unclear or if you have any questions.

srlMW

2015-06-10 00:14:23

Questions:
- I am going to work now on implementing failsafes procedure. Any tips?

UPDATE
Updated script to the work in progress V3.3. Cleaner, faster and with semi paint!


Longest time I've ever run the bot… Broke a few times and needed manual help, but ill be implementing failsafes now!
| * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|================MWs Master Tree Chopper================|
| * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|Time Run: 27 Minutes and 10 Seconds
|_______________________________________________________|
|Trees Chopped: 111
|_______________________________________________________|
|Shafts Crafted: 81
|_______________________________________________________|
|Logs Burnt: 54
|_______________________________________________________|
|_______________________________________________________|


program masterTreeChopperv33;
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
loadsDone, logsLoad, logsCrafted, logsBurned: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint.png');

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(300) of
0..25:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
26..51:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
begin
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 463));
end;

procedure locateTrees();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if tabBackPack.isfull then
exit;
repeat
findColorsSpiralTolerance(x, y, TPA, 794135, mainScreen.getBounds(), 10, colorSetting(2, 1.00, 1.51));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
until tabBackpack.waitForShift(randomRange(7000, 8000));
inc(loadsDone);
paintDisplay();
case random(6) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
slot, slot2: integer;
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
case random(11) of
0..2: slot2 := 4;
3..5: slot2 := 5;
6..8: slot2 := 7;
9..11: slot2 := 23;
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT);
if toolScreen.isOpen(1000) then
(toolScreen.select('Tinderbox'));
wait(randomRange(500, 1000));
tabBackpack.mouseSlot(slot2, MOUSE_LEFT);
if toolScreen.isOpen() then
(toolScreen.select('Add to bonfire'));
begin
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until tabBackpack.waitCount(1, 120000 + random(500));
inc(logsBurned);
end;
end;
end;

procedure fletchLogs();
var
slot: Integer;
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(500, 1000));
if productionScreen.isOpen(1000) then
productionScreen.clickStart();
if progressScreen.isOpen(randomRange(3500, 4000)) then
begin
repeat
wait(randomRange(500, 1000));
if progressScreen.isOpen() then
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
inc(logsCrafted);
end;
end;
end;

procedure dropLogs();
begin
if not tabBackPack.isFull() then
exit;
repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
inc(logsLoad);
end;

procedure progressReport();
var
choppedTrees, craftedShafts, logsBurnt: integer;
begin
choppedTrees := LoadsDone;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
clearScreen();
setCompass();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
case random(4) of
0..2: fletchLogs();
3..4: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
findNormalRandoms();
repeat
mainLoop();
until (LoadsDone > 1000);
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

fady

2015-06-10 00:59:46

From: indirectMW
SNIP


When you say broke a few times, where exactly did the script fail? If we are going to start working on failsafes, then we need to know how it failed so that we can try and figure out a way to fix it. Also I apologize ahead of time, because I wont be able to respond after this until the morning.

The most important thing that needs to be understood, is infinite loops. Look at every repeat..until loop in your script, and see if something in the middle can go wrong, causing the script to never exit the loop. Usually, we use TTimeMarkers and Integers to break out of loops if they go on for too long. Try working on that yourself, and take a look at my AIO portables script. I'll show you how Tomorrow morning.

srlMW

2015-06-10 02:42:53

From: fady
When you say broke a few times, where exactly did the script fail? If we are going to start working on failsafes, then we need to know how it failed so that we can try and figure out a way to fix it. Also I apologize ahead of time, because I wont be able to respond after this until the morning.

The most important thing that needs to be understood, is infinite loops. Look at every repeat..until loop in your script, and see if something in the middle can go wrong, causing the script to never exit the loop. Usually, we use TTimeMarkers and Integers to break out of loops if they go on for too long. Try working on that yourself, and take a look at my AIO portables script. I'll show you how Tomorrow morning.


These are just the ones I can think of off my head.

Failsafes needed for when:
- opens up the fletching screen then skips pressing the start button(common)
- got stuck dragging the skills tab (once)
- when all trees are cut on screen it still searches (my solution is to add a original starting area and when no trees are found withing x time it will walk back to it)
- might misclick an interface button and then not know what to do(once)
- when bonfire goes out but bag has more logs(solution: Have it detect the colours for bonfire and when no longer there it lights another[BONUS is that it can use this to detect if fire is already down])
- if tree is cut down by other it just stands there waiting for backpack shift/count to change(my solution is to add in this… if it detects the colours of tree base(whencut) and it's x close to player it will go to next tree)

I will add more as I see them

fady

2015-06-10 12:04:37

From: indirectMW
These are just the ones I can think of off my head.

Failsafes needed for when:
- opens up the fletching screen then skips pressing the start button(common).
- got stuck dragging the skills tab (once)
- when all trees are cut on screen it still searches (my solution is to add a original starting area and when no trees are found withing x time it will walk back to it)
- might misclick an interface button and then not know what to do(once)
- when bonfire goes out but bag has more logs(solution: Have it detect the colours for bonfire and when no longer there it lights another[BONUS is that it can use this to detect if fire is already down])
- if tree is cut down by other it just stands there waiting for backpack shift/count to change(my solution is to add in this… if it detects the colours of tree base(whencut) and it's x close to player it will go to next tree)

I will add more as I see them


Ok! Lets start with the first issue.

-opens up the fletching screen then skips pressing the start button(common).
We can tell that the portion of the script that is related to that error, is the following.

tabBackpack.mouseSlot(slot, MOUSE_LEFT); //clicks the designated slot
if toolScreen.isOpen(1000) then //if the toolScreen is open within 1 second
toolScreen.select('Knife'); //it will select the Knife option
wait(randomRange(500, 1000)); //will wait for 0.5-1 second
if productionScreen.isOpen(1000) then //if the prouctionScreen is open within 1 second
productionScreen.clickStart(); //it will click the start button

now how can I improve the previous so that If something goes wrong, the script doesn't break! There are multiple things that I can do. The simplest of which, is repeating the previous piece of code until the progress screen is open. But first, lets add a little note after the production screen check so we know if it was successful.

repeat
tabBackpack.mouseSlot(slot, MOUSE_LEFT); //clicks the designated slot
if toolScreen.isOpen(1000) then //if the toolScreen is open within 1 second
toolScreen.select('Knife'); //it will select the Knife option
wait(randomRange(500, 1000)); //will wait for 0.5-1 second
if productionScreen.isOpen(1000) then //if the prouctionScreen is open within 1 second
begin
writeLn('The production screen is open'); //So we know that it was successful
productionScreen.clickStart(); //it will click the start button
end;
until progressScreen.isOpen(randomRange(3500,4500)); //at the end of every loop, the script will wait 3.5-4.5 seconds for the progress screen to open, before repeating.
So, now we've worked on fixing that issue. However, looking at that loop, we can see that if something goes wrong and the progress screen never opens, we would get stuck inside it infinitely. To make sure that doesn't happen, we are going to add a type of variable called a TTimeMarker and name it failTimer. We will start the timer at the beginning of the procedure, and keep the repeat loop going, until either the progress screen is open, or until fail timer reaches a certain time. That way we wont get stuck in the loop until infinity. So now we have

procedure fletchLogs();
var
slot: Integer;
failTimer: TTimeMarker; //My new Timer variable
begin
if tabBackPack.isFull() then
begin
failTimer.start; //Starts the timer
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
repeat
tabBackpack.mouseSlot(slot, MOUSE_LEFT); //clicks the designated slot
if toolScreen.isOpen(1000) then //if the toolScreen is open within 1 second
toolScreen.select('Knife'); //it will select the Knife option
wait(randomRange(500, 1000)); //will wait for 0.5-1 second
if productionScreen.isOpen(1000) then //if the prouctionScreen is open within 1 second
begin
writeLn('The production screen is open'); //So we know that it was successful
productionScreen.clickStart(); //it will click the start button
end;
until (progressScreen.isOpen(randomRange(3500,4500))) or (failTimer.getTime > 45000);
//will still wait 3.5-4.5 seconds for the progress screen at the end of every loop
// but will now also check if failTimer has been running for more than 45 seconds
// and if it is, the script will exit the loop.
if progressScreen.isOpen() then //We dont need the wait here anymore, because if nothing went wrong, the progress screen should already be open
begin
repeat
wait(randomRange(500, 1000));
if progressScreen.isOpen() then
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
inc(logsCrafted);
end;
end;
end;

Now we've learned how to implement a basic failsafe for any procedure, and at the same time learned how to avoid infinite loops.

moving on.

- got stuck dragging the skills tab (once)
I dont know what you mean by that, but I'm assuming it has something to do with the Anti-ban. I don't recommend repeating antiban procedures like that without an accompanying wait time for downtime.

- when all trees are cut on screen it still searches (my solution is to add a original starting area and when no trees are found withing x time it will walk back to it)
Thats is a good idea to look into implementing, sadly SPS is not my strong point, so I can't help you much with that. Another Idea tho, would be rotating the camera and/or changing the camera height, to look around for more trees. If you would rather implement that, let me know. We'll figure it out.

- might misclick an interface button and then not know what to do(once)
We just learned how to implement failsafes, try to hone in on the part of the script that caused the problem, and see how you can do similar fixes to it.

- when bonfire goes out but bag has more logs(solution: Have it detect the colours for bonfire and when no longer there it lights another[BONUS is that it can use this to detect if fire is already down])
Yes. That is a very possible option to implement. However, if bonfire colors exist anywhere around the screen, we might keep getting a false positive that the bonfire is still here. I know some fire making scripts had something similar implemented, so i recommend you look them and see how they did it. I would do it another way tho. Right now this is what we have in the burn logs procedure

procedure burnLogs();
var
slot, slot2: integer;
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 26;
end;
case random(11) of
0..2: slot2 := 4;
3..5: slot2 := 5;
6..8: slot2 := 7;
9..11: slot2 := 23;
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT);
if toolScreen.isOpen(1000) then
(toolScreen.select('Tinderbox'));
wait(randomRange(500, 1000)); //If lighting the fire takes longer than this, the script will break.
tabBackpack.mouseSlot(slot2, MOUSE_LEFT);
if toolScreen.isOpen() then //no wait time here for the toolscreen to open
(toolScreen.select('Add to bonfire'));
begin //Again we don't need a begin..end here, because there isn't a conditional statement before it.
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until tabBackpack.waitCount(1, 120000 + random(500)); //The bonfire goes out before the inventory is finished.
inc(logsBurned);
end;
end;
end;

My suggestion to try and fix this, would be making use of the fact that, the chatbox tells you when a tinderbox burns a log. Then for adding logs to the bonfire, I'd have the script repeat a wait untill no change in the backpack count is detected within within 7.5+ seconds (because a log usually takes around 7 seconds to add to bonfire). Then repeating the whole procedure until the backpack is empty. For this to work easily tho, I suggest using the actionbar to click the logs and not the backpack. Which would need whoever is using the script to add the logs to action bar slot 1

If we implement all of the above, we end up having

procedure burnLogs();
var
tinderboxTimer, burnTimer: TTimeMarker; //failsafe Timers
begin
if tabBackPack.isFull() then
begin
burnTimer.start; //Starts the procedure timer.
repeat //procedure repeat
actionbar.clickSlot(1); //Click slot 1 on the action bar
if toolScreen.isOpen(1000) then
begin
tinderboxTimer.start; //starts the tinderbox Timer
toolScreen.select('Tinderbox');
repeat //Tinderbox wait repeat
wait(randomRange(200,600)); //repeats a 0.2-0.6 second wait
until (chatbox.findText(['he fire catches','ogs begin to burn'])) or (tinderboxTimer.getTime > 15000); //until the chatbox says that the log burned or until tinderbox timer reaches 15 seconds.
end;
actionbar.clickSlot(1); //Click slot 1 on the action bar
if toolScreen.isOpen(1000) then //Added a wait time here to wait for the toolscreen to open
begin
toolScreen.select('Add to bonfire');
repeat //antiban bonfire loop
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not tabBackpack.waitForShift(randomRange(7500,8500))); //Will repeat the antiban loop until the backpack count doesnt change within 7.5-8.5 seconds
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 300000); //repeats procedure until the backpack is empty or until the burn timer reaches 5+ minutes
inc(logsBurned);
end;
end;


I have to go now, I'll look at the rest of them later today.

srlMW

2015-06-10 22:24:19

From: fady
I have to go now, I'll look at the rest of them later today.


Cheers fady, you are one heck of a legend!

srlMW

2015-06-10 23:32:07

UPDATE
Updated script to the work in progress V35 with improved procedures, failsafes, completed paint(basically) and I fixed the issue with the script getting stuck at the fletching production screen! Reason was because when using the action bar it was automatically going to fletching but it was on firemaking procedure… Just changed firemaking quite dramatically but I like it! :) Bonus, it now takes a screenshot once script has finished to capture that glorious proggy! :stirthepot:


program masterTreeChopperv35;
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
loadsDone, logsLoad, logsCrafted, logsBurned: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint.png');

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
var
choppedTrees, craftedShafts, logsBurnt, xpGained, logsHR, shaftsHR, burntHR: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
xpGained := ((LogsBurned * 27 * 50) + (LogsCrafted * 27 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
shaftsHR := Round(craftedShafts * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
begin
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(ToStr(timeRunning), point(168, 450), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(choppedTrees), point(170, 470), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(craftedShafts), point(246, 510), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(logsBurnt), point(156, 545), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(xpGained) + ' XP', point(510, 400), 'xpchars', true, clSilver);
smartImage.drawText(ToStr(logsHR), point(145, 489), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(shaftsHR), point(124, 527), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(burntHR), point(172, 564), 'smallchars', true, clAqua);
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
if tabBackPack.isfull then
exit;
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 794135, mainScreen.getBounds(), 10, colorSetting(2, 1.00, 1.51));
ATPA := TPA.cluster(20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
case random(6) of
0..2:
begin
mainscreen.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
3..4:
begin
mainscreen.setAngle(MM_DIRECTION_EAST);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
5..6:
begin
mainscreen.setAngle(MM_DIRECTION_WEST);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
7..8:
begin
mainscreen.setAngle(MM_DIRECTION_NORTH);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
end;
until tabBackPack.isFull;
inc(loadsDone);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
tinderboxTimer, burnTimer: TTimeMarker;
x, y, slot, slot2: integer;
TPA: TPointArray;
begin
repeat
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
case random(11) of
0..2: slot2 := 3;
3..5: slot2 := 7;
6..8: slot2 := 8;
9..11: slot2 := 26;
end;
burnTimer.start;
repeat
tabBackpack.mouseSlot(slot, MOUSE_HUMAN);
chooseOption.select(['ight logs', 'light logs']);
until (chatbox.findText(['he fire catches', 'ogs begin to burn'])) or (tinderboxTimer.getTime > 15000);
tabBackpack.mouseSlot(slot2, MOUSE_HUMAN);
chooseOption.select(['se Logs', 'Use Logs']);
findColorsSpiralTolerance(x, y, TPA, 948930, mainScreen.getBounds(), 10, colorSetting(2, 0.27, 0.26));
if isMouseOverText(['Logs->Fire', 'ogs->Fire'], (randomRange(100, 500))) then
fastClick(MOUSE_RIGHT);
chooseOption.select(['Logs->Fire', 'ogs->Fire']);
tabBackPack.waitForShift(randomRange(3600, 4000));
end;
begin
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not tabBackpack.waitForShift(randomRange(4000, 5000)));
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 250000);
inc(logsBurned);
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
if toolScreen.isOpen(2000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
repeat
if productionScreen.isOpen(1000) then
begin
writeLn('The production screen is open');
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 45000);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
if progressScreen.isOpen() then
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
inc(logsCrafted);
end;
end;
end;

procedure dropLogs();
begin
if not tabBackPack.isFull() then
exit;
repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
inc(logsLoad);
end;

procedure progressReport();
var
choppedTrees, craftedShafts, logsBurnt: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
clearScreen();
setCompass();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
minimap.toggleRun(true);
locateTrees();
end;
progressReport();
case random(4) of
0..2: fletchLogs();
3..4: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
findNormalRandoms();
repeat
mainLoop();
until (LoadsDone > 1000);
paintDisplay();
takeScreenshot('FinalShot.png');
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

srlMW

2015-06-11 01:11:52

This happens nearly right after I begin… Any help would be appreciated!

Here is the debug error:
---- minimap.mouseOffCompass(): Succesfully moved mouse off of compass
---- TRSMinimap.clickCompass(): Clicked compass
Error: Unknown Clicktype (7) passed. at line 312
Execution failed.

Here is the what isn't working:
(*
fastClick
~~~~~~~~~

.. code-block:: pascal

procedure fastClick(button: integer);

Quickly click the mouse with any button.

.. note::

- by Flight

Example:

.. code-block:: pascal

fastClick(MOUSE_LEFT);

*)
procedure fastClick(button: integer);
var
x, y: integer;
begin
if (button = MOUSE_MOVE) then
Exit;

getMousePos(x, y);
holdMouse(x, y, button); //line 312 is here <<<---

wait(randomRange(60, 150));

getMousePos(x, y);
releaseMouse(x, y, button);
end;

fady

2015-06-11 02:06:24

From: indirectMW
This happens nearly right after I begin… Any help would be appreciated!

Here is the debug error:
---- minimap.mouseOffCompass(): Succesfully moved mouse off of compass
---- TRSMinimap.clickCompass(): Clicked compass
Error: Unknown Clicktype (7) passed. at line 312
Execution failed.

Here is the what isn't working:
(*
fastClick
~~~~~~~~~

.. code-block:: pascal

procedure fastClick(button: integer);

Quickly click the mouse with any button.

.. note::

- by Flight

Example:

.. code-block:: pascal

fastClick(MOUSE_LEFT);

*)
procedure fastClick(button: integer);
var
x, y: integer;
begin
if (button = MOUSE_MOVE) then
Exit;

getMousePos(x, y);
holdMouse(x, y, button); //line 312 is here <<<---

wait(randomRange(60, 150));

getMousePos(x, y);
releaseMouse(x, y, button);
end;


I think the error might be from, but I might be wrong.

repeat
tabBackpack.mouseSlot(slot, MOUSE_HUMAN);
chooseOption.select(['ight logs', 'light logs']);
until (chatbox.findText(['he fire catches', 'ogs begin to burn'])) or (tinderboxTimer.getTime > 15000);
tabBackpack.mouseSlot(slot2, MOUSE_HUMAN);

MOUSE_HUMAN is not a click type, it is a mouse movement type. The function for tabBackpack.MouseSlot accepts click types, which are MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE or MOUSE_MOVE

A tip. Whenever you write a new procedure, try taking down comments next to each line to show what they are supposed to be doing, that way you can easily visualize your script in words, not just code. I know it makes it much easier for me.

srlMW

2015-06-11 02:22:43

From: fady
I think the error might be from, but I might be wrong.

repeat
tabBackpack.mouseSlot(slot, MOUSE_HUMAN);
chooseOption.select(['ight logs', 'light logs']);
until (chatbox.findText(['he fire catches', 'ogs begin to burn'])) or (tinderboxTimer.getTime > 15000);
tabBackpack.mouseSlot(slot2, MOUSE_HUMAN);

MOUSE_HUMAN is not a click type, it is a mouse movement type. The function for tabBackpack.MouseSlot accepts click types, which are MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE or MOUSE_MOVE

A tip. Whenever you write a new procedure, try taking down comments next to each line to show what they are supposed to be doing, that way you can easily visualize your script in words, not just code. I know it makes it much easier for me.


Tried changing it but still the same error… This is puzzling.:duh:

E: FIXED IT!

srlMW

2015-06-11 09:48:00

UPDATE
Updated script to the work in progress V37 with improved procedures, failsafes, completed paint(basically) and I fixed firemaking so it works 110%!


program masterTreeChopperv37;
{$DEFINE SMART}
{$i srl-6/srl.simba}

var
loadsDone, logsLoad, logsCrafted, logsBurned: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint.png');

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
var
choppedTrees, craftedShafts, logsBurnt, xpGained, logsHR, shaftsHR, burntHR: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
xpGained := ((LogsBurned * 27 * 50) + (LogsCrafted * 27 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
shaftsHR := Round(craftedShafts * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
begin
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(ToStr(timeRunning), point(168, 450), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(choppedTrees), point(170, 470), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(craftedShafts), point(246, 510), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(logsBurnt), point(156, 545), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(xpGained) + ' XP', point(510, 400), 'xpchars', true, clSilver);
smartImage.drawText(ToStr(logsHR), point(145, 489), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(shaftsHR), point(124, 527), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(burntHR), point(172, 564), 'smallchars', true, clAqua);
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 794135, mainScreen.getBounds(), 10, colorSetting(2, 1.00, 1.51));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
case random(6) of
0..2:
begin
mainscreen.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
3..4:
begin
mainscreen.setAngle(MM_DIRECTION_EAST);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
5..6:
begin
mainscreen.setAngle(MM_DIRECTION_WEST);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
7..8:
begin
mainscreen.setAngle(MM_DIRECTION_NORTH);
mainscreen.setAngle(MS_ANGLE_LOW + random(30));
end;
end;
until tabBackPack.isFull;
inc(loadsDone);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
tinderboxTimer, burnTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
repeat
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
case random(11) of
0..2: slot2 := 4;
3..5: slot2 := 5;
6..8: slot2 := 7;
9..11: slot2 := 23;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
wait(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(1000, 1500));
begin
repeat
if mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT) then
chooseOption.select(['Use Logs -> Fire']);
until tabBackPack.waitForShift(randomRange(3000, 4000));
begin
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not tabBackpack.waitForShift(randomRange(4000, 5000)));
end;
end;
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
if toolScreen.isOpen(2000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
repeat
if productionScreen.isOpen(1000) then
begin
writeLn('The production screen is open');
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 45000);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
if progressScreen.isOpen() then
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
inc(logsCrafted);
end;
end;
end;

procedure dropLogs();
begin
if not tabBackPack.isFull() then
exit;
repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
inc(logsLoad);
end;

procedure progressReport();
var
choppedTrees, craftedShafts, logsBurnt: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
clearScreen();
setCompass();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
case random(5) of
0..2: fletchlogs();
3..5: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
findNormalRandoms();
repeat
mainLoop();
until (LoadsDone > 1000);
paintDisplay();
takeScreenshot('FinalShot.png');
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

srlMW

2015-06-11 20:39:23

I've got an idea that I would like to implement into my script but have absolutely no know how, if anyone would be able to help in any way whatsoever… I would be really grateful!

The problem::fiery::thumbsdown:
My script often follows the trail of trees till it reaches an end or gets stuck. This is a problem if people are going to not be babysitting the whole time… I tried making a solution that basically if it doesn't find and cut a tree within x time it rotates the screen and changes the angle to low. This worked for a bit till the current problem occurred.

The solution::garfield::thumbsup:
The script starts in a area that is x by y, if the script wanders out that is okay… but if the script doesn't cut a tree within x time it will walk itself back to the area.

If anyone is able to show me how to do that in code form or point me in the right direction, please do! (:

Citrus

2015-06-11 20:53:06

From: indirectMW
I've got an idea that I would like to implement into my script but have absolutely no know how, if anyone would be able to help in any way whatsoever… I would be really grateful!

The problem::fiery::thumbsdown:
My script often follows the trail of trees till it reaches an end or gets stuck. This is a problem if people are going to not be babysitting the whole time… I tried making a solution that basically if it doesn't find and cut a tree within x time it rotates the screen and changes the angle to low. This worked for a bit till the current problem occurred.

The solution::garfield::thumbsup:
The script starts in a area that is x by y, if the script wanders out that is okay… but if the script doesn't cut a tree within x time it will walk itself back to the area.

If anyone is able to show me how to do that in code form or point me in the right direction, please do! (:


You could easily do that with SPS.
https://villavu.com/forum/showthread.php?t=99716
https://villavu.com/forum/showthread.php?t=107757
https://github.com/SRL/SPS/blob/master/lib/sps-rs3.simba

If there are any minimap symbols in the area, those work well too.

edit:
you have this:

0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
Why not use the built-in drop patterns?

const
DROP_PATTERN_REGULAR: TIntegerArray = [1..28];
DROP_PATTERN_BACKWARDS: TIntegerArray = [28..1];
DROP_PATTERN_SNAKE: TIntegerArray = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 20, 19, 18, 17, 16, 21, 22, 23, 24, 25, 28, 27, 26];
DROP_PATTERN_UP_DOWN: TIntegerArray = [1, 6, 11, 16, 21, 26, 2, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25];

srlMW

2015-06-11 21:29:58

From: evilcitrus
You could easily do that with SPS.
https://villavu.com/forum/showthread.php?t=99716
https://villavu.com/forum/showthread.php?t=107757
https://github.com/SRL/SPS/blob/master/lib/sps-rs3.simba

If there are any minimap symbols in the area, those work well too.

edit:
you have this:

0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
Why not use the built-in drop patterns?

const
DROP_PATTERN_REGULAR: TIntegerArray = [1..28];
DROP_PATTERN_BACKWARDS: TIntegerArray = [28..1];
DROP_PATTERN_SNAKE: TIntegerArray = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 20, 19, 18, 17, 16, 21, 22, 23, 24, 25, 28, 27, 26];
DROP_PATTERN_UP_DOWN: TIntegerArray = [1, 6, 11, 16, 21, 26, 2, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25];


From my understanding don't you have to create the spot you're going to be at? Like start at x(beginning) then walk to y(end)? I'm trying to get it to walk to y(end) from a universal x(anywhere). Not sure If I'm just not getting it correctly… :wacko:

Please help me:duh:

Hoodz

2015-06-11 22:35:36

just wanted to let you know @indirectMW; that this is a very good way to learn scripting, by making a thread like this and ask for improvements. GJ!

srlMW

2015-06-11 22:50:23

From: hoodz
just wanted to let you know @indirectMW; that this is a very good way to learn scripting, by making a thread like this and ask for improvements. GJ!


Cheers man! I really have a thrive to constantly improve my projects and never release something that's 99%, so I figured what better way to do that than with help from experienced and knowledged scripters!

fady

2015-06-11 23:20:53

From: indirectMW
From my understanding don't you have to create the spot you're going to be at? Like start at x(beginning) then walk to y(end)? I'm trying to get it to walk to y(end) from a universal x(anywhere). Not sure If I'm just not getting it correctly… :wacko:

Please help me:duh:


not necessarily, the SPS include has a function that is TSPSArea.walkToPos(TPoint), which takes you to a point determined on the map.

EDIT: Sorry I havent been responding to your posts lately, I've been working on a script of my own. Once I'm done I'll give you all my comments if I have any.

srlMW

2015-06-11 23:29:26

From: fady
not necessarily, the SPS include has a function that is TSPSArea.walkToPos(TPoint), which takes you to a point determined on the map.

EDIT: Sorry I havent been responding to your posts lately, I've been working on a script of my own. Once I'm done I'll give you all my comments if I have any.


Ahh okay, is there a reference index for all the sps functions?

All good man! Best of luck with your script! :staycool:

fady

2015-06-12 00:05:29

From: indirectMW
Ahh okay, is there a reference index for all the sps functions?

All good man! Best of luck with your script! :staycool:


Open Simba/includes/sps/lib/sps-rs3.simba

srlMW

2015-06-12 00:07:45

From: fady
Open Simba/includes/sps/lib/sps-rs3.simba


Thanks man! :norris:

Citrus

2015-06-12 01:21:17

From: indirectMW
Ahh okay, is there a reference index for all the sps functions?


Cmon man… I gave you that link..

Anyway, you can use blindWalk() to get to any point in the area as long as you are also in the area

srlMW

2015-06-12 01:25:45

From: evilcitrus
Cmon man… I gave you that link..

Anyway, you can use blindWalk() to get to any point in the area as long as you are also in the area


Geesh, flew right past that GitHub link, I apologise. Thanks for the tip, trying to sort out now which one will work the best.

fady

2015-06-12 01:28:26

From: indirectMW
Geesh, flew right past that GitHub link, I apologise. Thanks for the tip, trying to sort out now which one will work the best.


dont forget to include SPS at the beginning of your script like so

{$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files 

Citrus

2015-06-12 01:43:18

From: indirectMW
Geesh, flew right past that GitHub link, I apologise. Thanks for the tip, trying to sort out now which one will work the best.


No worries, I probably should have said what the links were instead of just throwing them in there.

If you are going with SPS, I'd do it like this:
-make your map centered around the point you want to return to
-define that point as the return point
-check your SPS position every now and then and return to that point if you get too far from it

Something like this:

returnPoint := point(___, ___); //use the SPS tool thingy to get this point
if distance(returnPoint, SPS.getPlayerPos()) > __ then SPS.blindWalk(returnPoint); //figure out a reasonable radius
Make sure your map file is SIGNIFICANTLY bigger than the area you want to stay inside.

Also, something that a lot of people don't pick up on at first: you can define your own TSPSArea variable. You don't have to always use SPS.whatever(); You just have to declare the variable.

var
treeArea: TSPSArea; //probably best to make it global
then

treeArea.setup('TREEMAP', RUNESCAPE_SURFACE); //where TREEMAP is a picture of the area
and now you can do

p := treeArea.getPlayerPos();
treeArea.blindWalk(point(123, 456));
//etc.

srlMW

2015-06-12 02:00:55

From: fady
dont forget to include SPS at the beginning of your script like so

{$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files 


Tried testing it out and was wondering why it wasn't working, checked a tut and saw my mistake. Cheers for posting it… That way if I forget all I have to do is look here. :)

srlMW

2015-06-12 02:01:56

From: evilcitrus
No worries, I probably should have said what the links were instead of just throwing them in there.

If you are going with SPS, I'd do it like this:
-make your map centered around the point you want to return to
-define that point as the return point
-check your SPS position every now and then and return to that point if you get too far from it

Something like this:

returnPoint := point(___, ___); //use the SPS tool thingy to get this point
if distance(returnPoint, SPS.getPlayerPos()) > __ then SPS.blindWalk(returnPoint); //figure out a reasonable radius
Make sure your map file is SIGNIFICANTLY bigger than the area you want to stay inside.

Also, something that a lot of people don't pick up on at first: you can define your own TSPSArea variable. You don't have to always use SPS.whatever(); You just have to declare the variable.

var
treeArea: TSPSArea; //probably best to make it global
then

treeArea.setup('TREEMAP', RUNESCAPE_SURFACE); //where TREEMAP is a picture of the area
and now you can do

p := treeArea.getPlayerPos();
treeArea.blindWalk(point(123, 456));
//etc.


This sounds very promising, I'll add it in now! :stirthepot:

srlMW

2015-06-12 02:59:02

Have to head out for a few hours, will fully implement the newest feature and post the updated script once I get back.

E: Once again, I really appreciate everything you guys help me with! Without it… I'd have never gotten this far! :redface:

bonsai

2015-06-12 03:34:12

From: hoodz
just wanted to let you know @indirectMW; that this is a very good way to learn scripting, by making a thread like this and ask for improvements. GJ!


I agree. Excellent thread.

srlMW

2015-06-12 07:37:05

Having some trouble fully understanding the said code below thus making it very difficult to use… Would anyone be able to explain what it does and how I should set it up? Feeling like a nag atm, sorry! :unsure::pinch:

From: evilcitrus
No worries, I probably should have said what the links were instead of just throwing them in there.

If you are going with SPS, I'd do it like this:
-make your map centered around the point you want to return to
-define that point as the return point
-check your SPS position every now and then and return to that point if you get too far from it

Something like this:

returnPoint := point(___, ___); //use the SPS tool thingy to get this point
if distance(returnPoint, SPS.getPlayerPos()) > __ then SPS.blindWalk(returnPoint); //figure out a reasonable radius
Make sure your map file is SIGNIFICANTLY bigger than the area you want to stay inside.

Also, something that a lot of people don't pick up on at first: you can define your own TSPSArea variable. You don't have to always use SPS.whatever(); You just have to declare the variable.

var
treeArea: TSPSArea; //probably best to make it global
then

treeArea.setup('TREEMAP', RUNESCAPE_SURFACE); //where TREEMAP is a picture of the area
and now you can do

p := treeArea.getPlayerPos();
treeArea.blindWalk(point(123, 456));
//etc.

srlMW

2015-06-12 08:22:38

Below is the little testing procedure I've made just to see if it works. Now when I hit run, the script never runs the right direction… I just don't get it. Perhaps it's something to do with the SPS map I made but from what I understand, all I need to do is click once at the point I want to be where it returns to? Help is appreciated!

program new;
{$DEFINE SMART} // comment this line out if you don't want to use SMART
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure walk();
var
returnPoint := point(171, 177);
begin

sps.setup('tree_map', RUNESCAPE_SURFACE);
if distance(returnPoint, SPS.getPlayerPos()) > 50 then
SPS.blindWalk(returnPoint);
end;

begin
clearDebug();
setupSRL();
walk();
end.

fady

2015-06-12 08:27:09

From: indirectMW
Below is the little testing procedure I've made just to see if it works. Now when I hit run, the script never runs the right direction… I just don't get it. Perhaps it's something to do with the SPS map I made but from what I understand, all I need to do is click once at the point I want to be where it returns to? Help is appreciated!

program new;
{$DEFINE SMART} // comment this line out if you don't want to use SMART
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure walk();
var
returnPoint : TPoint; //Define the type of variable first.
begin
returnPoint := point(171, 177); // Then define the points for it inside the begin..end Loop
sps.setup('tree_map', RUNESCAPE_SURFACE);
if distance(returnPoint, SPS.getPlayerPos()) > 50 then
SPS.blindWalk(returnPoint);
end;

begin
clearDebug();
setupSRL();
walk();
end.


show us the map you are using, also use sps.walkToPos(returnPoint); instead of blind walk

EDIT: I modified your snippet a bit, in the quote. Take a look at it.

EDIT2 : Actually, give me a few minutes, I have to check something.

EDIT3 : Ok NVM try the edits mentioned above and let me know.

srlMW

2015-06-12 08:33:51

From: fady
show us the map you are using, also use sps.walkToPos(returnPoint); instead of blind walk

EDIT: I modified your snippet a bit, in the quote. Take a look at it.


Here it is:

E: Just tried your changes to no avail. Thanks for the grammar tips though!

fady

2015-06-12 08:46:28

From: Stuobd_k
Here it is:

E: Just tried your changes to no avail. Thanks for the grammar tips though!


I dont see what is wrong with the map, but again SPS isn't my strongest point. Show me the debug then please.

srlMW

2015-06-12 09:01:30

From: fady
I dont see what is wrong with the map, but again SPS isn't my strongest point. Show me the debug then please.


Here you go
—- Client is ready.
—- Setup SRL in 0 Seconds
– setupSRL(): True
– sps.init()
—- Path exists (C:\Simba\Includes\SPS\img\runescape_surface\tree_map.png)
—- Setup area "tree_map" in 47ms
– sps.init()
– sps.getPlayerPos(): Angle is at 181.587880563575, Setting angle to 0 degrees
– TRSChooseOption._select():
—- Options found: [Face North, Face South, Cancel]
—- Found option "Face No" in "Face North"
– TRSChooseOption.select() result = true
—- minimap.mouseOffCompass(): Succesfully moved mouse off of compass
—- TRSMinimap.clickCompass(): Clicked compass
– sps.getPlayerPos(): result = {X = 258, Y = 98}, took 3407 ms
– sps.getPlayerPos(): result = {X = 258, Y = 98}, took 203 ms
– sps.getPlayerPos(): result = {X = 258, Y = 98}, took 204 ms
– sps.getPlayerPos(): result = {X = 270, Y = 98}, took 187 ms
– sps.getPlayerPos(): result = {X = 222, Y = 214}, took 219 ms
—- Waiting while the player is moving…
– sps.walkPath(): result = True
– sps.blindWalk(): result = True
– Succesfully freed SMART[9180]
Successfully executed.

Citrus

2015-06-12 12:21:03

From: Stuobd_k
Below is the little testing procedure I've made just to see if it works. Now when I hit run, the script never runs the right direction… I just don't get it. Perhaps it's something to do with the SPS map I made but from what I understand, all I need to do is click once at the point I want to be where it returns to? Help is appreciated!

program new;
{$DEFINE SMART} // comment this line out if you don't want to use SMART
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure walk();
var
returnPoint := point(171, 177); //this is fine imo
begin
if distance(returnPoint, SPS.getPlayerPos()) > 50 then
SPS.blindWalk(returnPoint); //stick with blindWalk(), not walkToPos();
end;

begin
clearDebug();
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE); //put this here. you only need to setup once
walk();
end.


You only need to setup once: see above

You map is upside down. SPS maps must me made when your player is facing north.

srlMW

2015-06-12 21:45:49

From: evilcitrus
You only need to setup once: see above

You map is upside down. SPS maps must me made when your player is facing north.


Did the trick, thanks!

srlMW

2015-06-13 02:47:22

Just a small update. The script is running really smoothly now, tree detection rate is higher and just the overall efficiency and flow has improved.

E: Just realised that "efficiency" breaks the "i" before "e" unless after "c" rule… :norris:

KeepBotting

2015-06-13 02:49:08

From: srlMW
Just a small update. The script is running really smoothly now, tree detection rate is higher and just the overall efficiency and flow has improved.

E: Just realised that "efficiency" breaks the "i" before "e" unless after "c" rule… :norris:


Can we get a "Previously known as"in your signature please :)?

Nice progress, also.

srlMW

2015-06-13 02:51:30

From: KeepBotting
Can we get a "Previously known as"in your signature please :)?

Nice progress, also.


Sorry about all that, name endangered accounts so I changed it only to realise the new one did also… This is my final name!
Just call me MW… srlMW. :norris:

KeepBotting

2015-06-13 02:55:08

From: srlMW
Sorry about all that, name endangered accounts so I changed it only to realise the new one did also… This is my final name!
Just call me MW… srlMW. :norris:


Oh, I see. No need then.

Einstein breaks the rule twice btw

srlMW

2015-06-13 04:21:51

UPDATE
Updated script to the work in progress V38. Overall efficiency and smoothness has been improved dramatically as well as tree detection rate.


program masterTreeChopperv38;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

var
returnPoint := point (285, 181);
loadsDone, logsLoad, logsCrafted, logsBurned: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint.png');

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
var
choppedTrees, craftedShafts, logsBurnt, xpGained, logsHR, shaftsHR, burntHR: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
xpGained := ((LogsBurned * 27 * 50) + (LogsCrafted * 27 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
shaftsHR := Round(craftedShafts * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
begin
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(ToStr(timeRunning), point(168, 450), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(choppedTrees), point(170, 470), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(craftedShafts), point(246, 510), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(logsBurnt), point(156, 545), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(xpGained) + ' XP', point(510, 400), 'xpchars', true, clSilver);
smartImage.drawText(ToStr(logsHR), point(145, 489), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(shaftsHR), point(124, 527), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(burntHR), point(172, 564), 'smallchars', true, clAqua);
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1190434, mainScreen.getBounds(), 10, colorSetting(2, 0.32, 0.72));
begin
if (not findColorsSpiralTolerance(x, y, TPA, 1190434, mainScreen.getBounds(), 10, colorSetting(2, 0.32, 0.72))) then
SPS.getPlayerPos();
SPS.blindWalk(returnPoint);
minimap.waitPlayerMoving();
wait(randomRange(500, 999));
end;
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 30);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(5000, 6000)) or (cutTimer.getTime > 8000);
until tabBackPack.isFull;
inc(loadsDone);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
tinderboxTimer, burnTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
repeat
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
case random(11) of
0..2: slot2 := 4;
3..5: slot2 := 5;
6..8: slot2 := 7;
9..11: slot2 := 23;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
wait(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(1000, 1500));
begin
repeat
if mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT) then
chooseOption.select(['Use Logs -> Fire']);
until tabBackPack.waitForShift(randomRange(3000, 4000));
begin
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not tabBackpack.waitForShift(randomRange(4000, 5000)));
end;
end;
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
if toolScreen.isOpen(2000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
repeat
if productionScreen.isOpen(1000) then
begin
writeLn('The production screen is open');
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 45000);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
if progressScreen.isOpen() then
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen());
inc(logsCrafted);
end;
end;
end;

procedure dropLogs();
begin
if not tabBackPack.isFull() then
exit;
repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
inc(logsLoad);
end;

procedure progressReport();
var
choppedTrees, craftedShafts, logsBurnt: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
clearScreen();
setCompass();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
case random(5) of
0..2: fletchlogs();
3..5: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
findNormalRandoms();
repeat
mainLoop();
until (LoadsDone > 1000);
paintDisplay();
takeScreenshot('FinalShot.png');
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

Citrus

2015-06-13 04:42:35

From: KeepBotting
Einstein breaks the rule twice btw


Why would English spelling conventions apply to a German name? :p

In German ei = eye; ie = eee
Their rules are a bit more consistent than ours

srlMW

2015-06-13 04:55:08

From: KeepBotting
Oh, I see. No need then.

Einstein breaks the rule twice btw


“Know the rules well, so you can break them effectively.” Dalai Lama or Chuck Norris :norris:

Ian

2015-06-13 04:55:14

From: evilcitrus
Why would English spelling conventions apply to a German name? :p

In German ei = eye; ie = eee
Their rules are a bit more consistent than ours


English borrows from so many other languages that there are many rules that are useless. German as a language is more pure so the rules actually are useful.

srlMW

2015-06-13 05:34:19

Hey guys just a quick question. Can some please explain to me what the variables represent in each of the following?

ATPA := TPA.cluster(10);
ATPA.filterBetween(35, 50);

Cheers

Thomas

2015-06-13 05:57:55

https://villavu.com/forum/showthread.php?t=49067

Cluster is the same as splitTPAEx, just uses a different method for same result and should be faster.

srlMW

2015-06-13 06:21:53

From: Thomas
https://villavu.com/forum/showthread.php?t=49067

Cluster is the same as splitTPAEx, just uses a different method for same result and should be faster.


Must of used the wrong term, was meaning the numbers inside the brackets… Sorry.

E: Thanks for the thread though, looks like an interesting read!

srlMW

2015-06-13 07:43:54

I am currently using the code below to turn the compass when no trees are found since wide view is bigger.
How I feel it is very machine like and would like to improve it.
minimap.setAngle(MM_DIRECTION_EAST);
I remember seeing a while back something like the below code but cant seem to find it anywhere. Basically all its doing is turning the camera to the first number plus the random value which is somewhere between 0 to 10.
minimap.setAngle(45 + (random(0, 10));
All help is appreciated!

Thomas

2015-06-13 08:29:09

From: srlMW
Must of used the wrong term, was meaning the numbers inside the brackets… Sorry.

E: Thanks for the thread though, looks like an interesting read!



Arent they explained in the thread? Ill edit this post later if they arent and explain.

srlMW

2015-06-13 08:33:15

From: Thomas
Arent they explained in the thread? Ill edit this post later if they arent and explain.


Yep, they were! I found out that they are the width and height of the object it's looking for… Too bad evergreens are all different.

E:
From: srlMW
I am currently using the code below to turn the compass when no trees are found since wide view is bigger.
How I feel it is very machine like and would like to improve it.
minimap.setAngle(MM_DIRECTION_EAST);
I remember seeing a while back something like the below code but cant seem to find it anywhere. Basically all its doing is turning the camera to the first number plus the random value which is somewhere between 0 to 10.
minimap.setAngle(45 + (random(0, 10));
All help is appreciated!

Thomas

2015-06-13 09:23:03

From: srlMW
Yep, they were! I found out that they are the width and height of the object it's looking for… Too bad evergreens are all different.

E:


That is why you use cluster or splitATPA… Those don't need width/height of an object. Those values mean the distance (radius or X/Y-coordinates) between TPoints in your TPA.

KeepBotting

2015-06-13 09:45:42

From: evilcitrus
Why would English spelling conventions apply to a German name? :p

In German ei = eye; ie = eee
Their rules are a bit more consistent than ours


Oh, it doesn't/shouldn't. More like "if you apply our weird English spelling conventions to this German word, it breaks the rule twice."

Citrus

2015-06-13 13:18:54

From: srlMW
I am currently using the code below to turn the compass when no trees are found since wide view is bigger.
How I feel it is very machine like and would like to improve it.
minimap.setAngle(MM_DIRECTION_EAST);
I remember seeing a while back something like the below code but cant seem to find it anywhere. Basically all its doing is turning the camera to the first number plus the random value which is somewhere between 0 to 10.
minimap.setAngle(45 + (random(0, 10));
All help is appreciated!


Do somethine like

minimap.setAngle(minimap.getAngleDegrees() + gaussRangeInt(15, 30));
so you're consistently turning in one direction instead of randomly all over the place

As others have said, tpa.cluster() is usually the best way to get a good atpa
http://docs.villavu.com/srl-6/tpointarrays.html#tpointarray-cluster

The Mayor

2015-06-13 14:06:16

Just saw this now. Great thread!


E:I would consider moving this public

srlMW

2015-06-14 01:29:38

From: evilcitrus
Do somethine like

minimap.setAngle(minimap.getAngleDegrees() + gaussRangeInt(15, 30));
so you're consistently turning in one direction instead of randomly all over the place

As others have said, tpa.cluster() is usually the best way to get a good atpa
http://docs.villavu.com/srl-6/tpointarrays.html#tpointarray-cluster


Thanks, this is much better!

srlMW

2015-06-14 01:31:34

From: The Mayor
Just saw this now. Great thread!


E:I would consider moving this public


Made it JR because I didn't want new guys plugging this in and using it while I am still developing. Will definitely have it moved after I finish though!

srlMW

2015-06-14 05:42:49

UPDATE
Updated script to the work in progress V39. Implemented returning to point after no trees found within x.


WOOT! First time running past 1 hour without any bugs!
PS. Paint is just a makeshift for now…
WOOT WOOT! 2 hours strong!


Question: I am currently trying to introduce grats tracking to the script and am just wondering if anyone can give me a example of implementation? Thanks! :huh:

Script Name:
[30] MW's Master Tree Chopper
Vars:
[23] Normal Logs (Burned), [29] Normal Logs (Chopped), [65] Fletching Xp (Gained), [79] Firemaking Xp
(Gained), [80] Woodcutting Xp (Gained)

program masterTreeChopperv39;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

var
myScriptTimer: TTimeMarker;
returnPoint := Point (244, 180);
loadsDone, logsLoad, logsCrafted, logsBurned: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint.png');

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure fallBacks();
begin
end;

procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;

procedure paintDisplay();
var
choppedTrees, craftedShafts, logsBurnt, xpGained, logsHR, shaftsHR, burntHR: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
xpGained := ((LogsBurned * 27 * 50) + (LogsCrafted * 27 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
shaftsHR := Round(craftedShafts * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
begin
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(ToStr(timeRunning), point(168, 450), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(choppedTrees), point(170, 470), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(craftedShafts), point(246, 510), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(logsBurnt), point(156, 545), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(xpGained) + ' XP', point(510, 400), 'xpchars', true, clSilver);
smartImage.drawText(ToStr(logsHR), point(145, 489), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(shaftsHR), point(124, 527), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(burntHR), point(172, 564), 'smallchars', true, clAqua);
end;
end;

procedure noColour();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
exit;
end;
if distance(returnPoint, SPS.getPlayerPos()) > 10 then
SPS.blindWalk(returnPoint);
wait(randomRange(500, 999));
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20);
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(5000, 6000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 9000) then
noColour();
until tabBackPack.isFull;
inc(loadsDone);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
repeat
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
case random(11) of
0..2: slot2 := 4;
3..5: slot2 := 5;
6..8: slot2 := 7;
9..11: slot2 := 23;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
wait(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(1000, 1500));
begin
repeat
if mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT) then
chooseOption.select(['Use Logs -> Fire']);
until tabBackPack.waitForShift(randomRange(3000, 4000));
begin
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not tabBackpack.waitForShift(randomRange(4000, 5000)));
end;
end;
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() then
begin
case random(11) of
0..2: slot := 2;
3..5: slot := 6;
6..8: slot := 3;
9..11: slot := 28;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
if toolScreen.isOpen(2000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
repeat
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 45000);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
if progressScreen.isOpen() then
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsCrafted);
end;
end;
end;

procedure dropLogs();
begin
if not tabBackPack.isFull() then
exit;
repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));
case random(100) of
0..46:
begin
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomRange(5000, 7000));
minimap.clickCompass();
end;
47..100: speedAntiBan();
end;
inc(logsLoad);
end;

procedure progressReport();
var
choppedTrees, craftedShafts, logsBurnt: integer;
begin
choppedTrees := LoadsDone * 27;
craftedShafts := LogsCrafted * 27;
logsBurnt := LogsBurned * 27;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Shafts Crafted: ' + intToStr(craftedShafts));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
clearScreen();
setCompass();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
noColour();
locateTrees();
end;
progressReport();
case random(5) of
0..2: fletchlogs();
3..5: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
takeScreenshot('SessionStart.png');
sps.setup('tree_map', RUNESCAPE_SURFACE);
findNormalRandoms();
myScriptTimer.start();
repeat
mainLoop();
until (myScriptTimer.getTime() > 10000);
paintDisplay();
takeScreenshot('SessionResult.png');
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

srlMW

2015-06-14 08:20:55

Hey guys, is there anyway to get the screenshot to capture the paint?
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
takeScreenshot('SessionStart.png');
sps.setup('tree_map', RUNESCAPE_SURFACE);
findNormalRandoms();
myScriptTimer.start();
repeat
mainLoop();
until (myScriptTimer.getTime() > 10000);
paintDisplay();
takeScreenshot('SessionResult.png');
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
end
Also, I am currently trying to introduce grats tracking to the script and am just wondering if anyone can give me a example of implementation? Thanks!

Citrus

2015-06-14 09:02:40

From: srlMW
Also, I am currently trying to introduce grats tracking to the script and am just wondering if anyone can give me a example of implementation? Thanks!


Stole this directly from @Taric's Jewelry Smelter.

{-----grats' stats!-----}
{
=====
Stats
=====
}

Const
stats_Path = AppPath+'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
stats_Timer : integer;
stats_ID,stats_Pass,
stats_ScriptID : string;
stats_Vars : Array of TStats_Vars;


procedure stats_Setup(_ScriptID : String);
var
id,pass : String;
begin
if (not directoryExists(stats_Path)) then
begin
forceDirectories(stats_Path);
writeINI('General', 'Stats_ID', '', stats_Path+stats_File);
writeINI('General', 'Stats_Pass', '', stats_Path+stats_File);
end;

id := readINI('General', 'Stats_ID', stats_Path+stats_File);
pass := readINI('General', 'Stats_Pass', stats_Path+stats_File);

if id = '' then
begin
case MessageBox('No Stats ID found, would you like to register?','Stats',1) of
1: openWebPage('http://stats.grats.pw/reg.php');
end;
end;

stats_ID := id;
stats_Pass := pass;
stats_ScriptID := _ScriptID;
stats_Timer := getSystemTime();
end

procedure stats_InitVariable(VarName: String; InitValue: Integer);
var
len: Integer;
begin
len := Length(stats_Vars);
SetArrayLength(stats_Vars, len + 1);
stats_Vars[len].Name := LowerCase(VarName);
stats_Vars[len].Value := InitValue;
end;

procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := NewValue;
Exit;
end;

stats_InitVariable(VarName, NewValue);
end;

procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := stats_Vars[i].Value + Value;
Exit;
end;

stats_InitVariable(VarName, Value);
end;

function stats_Commit(): Boolean;
var
S : String;
Client,i,Worked,
ExtraTime : integer;
begin
ExtraTime := getSystemTime() - stats_Timer;
Worked := ExtraTime div 60000;

if Worked < 5 then Exit;
ExtraTime := ExtraTime - (Worked*60000);

stats_Timer := GetSystemTime - ExtraTime;

Client := InitializeHTTPClient(False);
ClearPostData(Client);

if (stats_ID = '') then
begin
stats_ID := '5';
stats_Pass := 'anon1337';
end;

AddPostVariable(Client, 'user_id', STATS_ID);
AddPostVariable(Client, 'password', STATS_PASS);
AddPostVariable(Client, 'script_id', STATS_SCRIPTID);
AddPostVariable(Client, 'timeamount', toStr(Worked));

if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;

AddPostVariable(Client, Name, toStr(Min(Value, 30000))); //Capped at 30000
end;

// Get & translate the return code
S := PostHTTPPageEx(Client, 'http://stats.grats.pw/POST.php');
FreeHTTPClient(Client);

case StrToIntDef(ExtractFromStr(S, Numbers), -1) of
42 : Result := True;
// 666 : writeln('Stats: User ID/Password not setup.'); // Disabled because of the default name ID & pass given above
9001: writeln('Stats: Invalid user ID/Password.');
1337: writeln('Stats: Invalid Script ID.');
255,
496 : writeln('Stats: Committing too fast; shame on you!');
else
writeln('Stats: No POST return');
end;

if Result then
begin
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
Value := 0; //Clear for next commit
end;
end;
end;
{-----grats' stats-----}

idk about the screenshot thing, sorry.

srlMW

2015-06-14 22:47:46

From: evilcitrus
Stole this directly from @Taric's Jewelry Smelter.

{-----grats' stats!-----}
{
=====
Stats
=====
}

Const
stats_Path = AppPath+'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
stats_Timer : integer;
stats_ID,stats_Pass,
stats_ScriptID : string;
stats_Vars : Array of TStats_Vars;


procedure stats_Setup(_ScriptID : String);
var
id,pass : String;
begin
if (not directoryExists(stats_Path)) then
begin
forceDirectories(stats_Path);
writeINI('General', 'Stats_ID', '', stats_Path+stats_File);
writeINI('General', 'Stats_Pass', '', stats_Path+stats_File);
end;

id := readINI('General', 'Stats_ID', stats_Path+stats_File);
pass := readINI('General', 'Stats_Pass', stats_Path+stats_File);

if id = '' then
begin
case MessageBox('No Stats ID found, would you like to register?','Stats',1) of
1: openWebPage('http://stats.grats.pw/reg.php');
end;
end;

stats_ID := id;
stats_Pass := pass;
stats_ScriptID := _ScriptID;
stats_Timer := getSystemTime();
end

procedure stats_InitVariable(VarName: String; InitValue: Integer);
var
len: Integer;
begin
len := Length(stats_Vars);
SetArrayLength(stats_Vars, len + 1);
stats_Vars[len].Name := LowerCase(VarName);
stats_Vars[len].Value := InitValue;
end;

procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := NewValue;
Exit;
end;

stats_InitVariable(VarName, NewValue);
end;

procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := stats_Vars[i].Value + Value;
Exit;
end;

stats_InitVariable(VarName, Value);
end;

function stats_Commit(): Boolean;
var
S : String;
Client,i,Worked,
ExtraTime : integer;
begin
ExtraTime := getSystemTime() - stats_Timer;
Worked := ExtraTime div 60000;

if Worked < 5 then Exit;
ExtraTime := ExtraTime - (Worked*60000);

stats_Timer := GetSystemTime - ExtraTime;

Client := InitializeHTTPClient(False);
ClearPostData(Client);

if (stats_ID = '') then
begin
stats_ID := '5';
stats_Pass := 'anon1337';
end;

AddPostVariable(Client, 'user_id', STATS_ID);
AddPostVariable(Client, 'password', STATS_PASS);
AddPostVariable(Client, 'script_id', STATS_SCRIPTID);
AddPostVariable(Client, 'timeamount', toStr(Worked));

if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;

AddPostVariable(Client, Name, toStr(Min(Value, 30000))); //Capped at 30000
end;

// Get & translate the return code
S := PostHTTPPageEx(Client, 'http://stats.grats.pw/POST.php');
FreeHTTPClient(Client);

case StrToIntDef(ExtractFromStr(S, Numbers), -1) of
42 : Result := True;
// 666 : writeln('Stats: User ID/Password not setup.'); // Disabled because of the default name ID & pass given above
9001: writeln('Stats: Invalid user ID/Password.');
1337: writeln('Stats: Invalid Script ID.');
255,
496 : writeln('Stats: Committing too fast; shame on you!');
else
writeln('Stats: No POST return');
end;

if Result then
begin
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
Value := 0; //Clear for next commit
end;
end;
end;
{-----grats' stats-----}

idk about the screenshot thing, sorry.


Thanks still pulling it all apart as I speak, got a basic stats system setup for now. All it does it commits… still have to get variables working.

E: Found the original page by @grats; with all the information. HERE

The Mayor

2015-06-15 05:14:19

Found some time to look at your script. Here is my feedback:


procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

tabBackpack.isOpen() already checks that the pack is open before opening it, so you could delete the first line.


procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

closeAddWindow() actually redirects to closePopup(), so there is no need for it. It will most probably be removed from the include at some point.

You have an extra begin/end in procedure paintDisplay() and in procedure locateTrees();, and 2 in procedure burnLogs();

With your colour finding stuff, I'm pretty sure: ATPA := TPA.cluster(20); will result in an error if TPA is empty. Maybe add a length check?

From what I can see, there is a small logic error in procedure locateTrees();: if the length of the ATPA is > 0, but none of the TPAs match the mouseOverText, it will still wait 5-6 seconds for the backpack count to shift.

This is an infinite loop (in burnLogs):


repeat
if mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT) then
chooseOption.select(['Use Logs -> Fire']);
until tabBackPack.waitForShift(randomRange(3000, 4000));


Any reason why you made this check twice? It will only ever evaluate the second isOpen() if the first one is true (and it's obviously already open)


if toolScreen.isOpen(1000) then
if toolScreen.isOpen(2000) then
toolScreen.select('Knife');

When you see it:


repeat
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 45000);

For procedure dropLogs():


repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));

did you see srl-6 dropping patterns? e.g tabBackpack.dropItems(DROP_PATTERN_SNAKE); and what if you have 2 items that you can't drop, like a spin ticket?

srlMW

2015-06-15 05:46:29

First off, thanks Mayor for checking out my script… Appreciation there!

From: The Mayor

procedure clearScreen();
begin
if not (tabBackPack.isOpen()) then
tabBackPack.open;
end;

tabBackpack.isOpen() already checks that the pack is open before opening it, so you could delete the first line.

Seen this a few times just forgot to fix it up as have been working on other features, will do that now so I don't forget!

From: The Mayor

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closeAdWindow();
closePopup();
end;

closeAddWindow() actually redirects to closePopup(), so there is no need for it. It will most probably be removed from the include at some point.

Didn't know that, changing now!

From: The Mayor
You have an extra begin/end in procedure paintDisplay() and in procedure locateTrees();, and 2 in procedure burnLogs();
Always nice to find unneeded code, shortening as we speak.

From: The Mayor
With your colour finding stuff, I'm pretty sure: ATPA := TPA.cluster(20); will result in an error if TPA is empty. Maybe add a length check?
Pretty sure this is already added in, will check though.

From: The Mayor
From what I can see, there is a small logic error in procedure locateTrees();: if the length of the ATPA is > 0, but none of the TPAs match the mouseOverText, it will still wait 5-6 seconds for the backpack count to shift.
Nice catch!

From: The Mayor
This is an infinite loop (in burnLogs):


repeat
if mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT) then
chooseOption.select(['Use Logs -> Fire']);
until tabBackPack.waitForShift(randomRange(3000, 4000));
Haven't seen it failed at this so never really thought about it, better safe than sorry though!


From: The Mayor
Any reason why you made this check twice? It will only ever evaluate the second isOpen() if the first one is true (and it's obviously already open)


if toolScreen.isOpen(1000) then
if toolScreen.isOpen(2000) then
toolScreen.select('Knife');

When you see it:


repeat
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 45000);

Fixed the whole procedure, had a few things that didn't make sense.

From: The Mayor
For procedure dropLogs():


repeat
case random(6) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
end;
until tabBackpack.waitCount(1, 1000 + random(500));

did you see srl-6 dropping patterns? e.g tabBackpack.dropItems(DROP_PATTERN_SNAKE); and what if you have 2 items that you can't drop, like a spin ticket?

People have mentioned this a few times but it hasn't been on the priority list because I decided to leave it out of the final, though now that I'm changing it to craft bows, I'll fix it and add it in to drop them.

Thanks Mayor! Glad you did this, I feel privileged since it was your guide that got me started! :redface:

srlMW

2015-06-15 23:20:00

UPDATE
Updated script to the work in progress V392. ATM I am cleaning up the code, removing the unneeded lines and improving procedures so that everything is 100% bug free and failsafed. I've changed from shafts to bows because I don't want to support influx of massive amounts of items and since this change I have now had to implement DTMs… Which is not working out well at all. Help is appreciated, keep in mind code will be changing a lot. Moving on to v4 after all I've finished the above, v4 will not change the functionality at all unless needed.


program masterTreeChopperv392;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

Const
stats_Path = AppPath+'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
myScriptTimer: TTimeMarker;
returnPoint := Point (244, 180);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint.png');

{ procedure processGratsStats(); //deleted the rest of stats stuff
var //because going to be doing it in v4
choppedTrees, craftedShafts, logsBurnt: integer; //which will happen after i clean
begin //this up and improve it to it's max
stats_IncVariable('29', (choppedTrees)); //kept this because they are the basics
stats_IncVariable('23', (logsBurnt));
stats_IncVariable('65', (craftedShafts * 15));
stats_IncVariable('79', (logsBurnt * 50));
stats_IncVariable('80', (choppedTrees * 25));
begin
stats_commit();
end;
end; }

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
wait(randomRange(1000, 10000));
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setCompass();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 27;
fletchedBows := LogsFletched * 27;
logsBurnt := LogsBurned * 27;
xpGained := ((LogsBurned * 27 * 50) + (Logsfletched * 27 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(ToStr(timeRunning), point(168, 450), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(choppedTrees), point(170, 470), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(fletchedBows), point(246, 510), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(logsBurnt), point(156, 545), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(xpGained) + ' XP', point(510, 400), 'xpchars', true, clSilver);
smartImage.drawText(ToStr(logsHR), point(145, 489), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(bowsHR), point(124, 527), 'smallchars', true, clAqua);
smartImage.drawText(ToStr(burntHR), point(172, 564), 'smallchars', true, clAqua);
end;

procedure noColour();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20)
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
exit;
end;
if distance(returnPoint, SPS.getPlayerPos()) > 10 then
SPS.blindWalk(returnPoint);
wait(randomRange(500, 999));
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20)
if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(5000, 6000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 9000) then
noColour();
until tabBackPack.isFull;
inc(logsCut);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
repeat

if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) <= 20) then
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
wait(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(1000, 1500));
begin
addingTimer.start;
repeat
if mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT) then
chooseOption.select(['Use Logs -> Fire']);
until tabBackPack.waitForShift(randomRange(3000, 4000)) or (addingtimer.getTime > 5000);
end;
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not tabBackpack.waitForShift(randomRange(4000, 5000)));
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure dropBows();
var
slot, bowDTM, x, y: integer;
dropTimer: TTimeMarker;
begin
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
if tabBackPack.isFull() and (tabBackpack.countDTM(bowDTM) <= 20) then
begin
dropTimer.start;
case random(18) of
0..2: slot := 2;
3..4: slot := 6;
5..6: slot := 3;
7..8: slot := 28;
10..12: slot := 12;
13..14: slot := 17;
15..16: slot := 21;
17..18: slot := 8;
end
begin
repeat
case random(33) of
0..3: tabBackpack.dropItems([2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2]);
7..9: tabBackpack.dropItemsExcept([1]);
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
20..23: tabBackpack.dropItemsExcept([slot]);
24..26: tabBackpack.dropItemsExcept([slot], DROP_PATTERN_SNAKE);
27..29: tabBackpack.dropItemsExcept([slot], DROP_PATTERN_BACKWARDS);
30..33: tabBackpack.dropItemsExcept([slot], DROP_PATTERN_UP_DOWN);
end;
until tabBackpack.waitCount(1, 1000 + random(500)) or (dropTimer.getTime > 9999999)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) <= 20) then
begin
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2)= 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
dropbows();
end;
end;
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
setCompass();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
noColour();
locateTrees();
end;
progressReport();
case random(5) of
0..2: fletchlogs();
3..5: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
//stats_Setup('30');
takeScreenshot('SessionStart.png');
sps.setup('tree_map', RUNESCAPE_SURFACE);
findNormalRandoms();
myScriptTimer.start();
repeat
mainLoop();
//processGratsStats();
until (myScriptTimer.getTime() > 99999999);
paintDisplay();
takeScreenshot('SessionResult.png');
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

Citrus

2015-06-15 23:37:25

What problems are you having with DTMs?

I noticed you didn't define them globally, which you should. You also need to free them.
This is a common way to do both

procedure initDTMs();
begin
logDTM := ...;
bowDTM := ...;
end;

procedure freeDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;
then you need to add them to the script

begin
addOnTerminate('freeDTMs'); //add this to free the DTMs when the script stops
clearDebug();
smartEnableDrawing := true;
setupSRL();
//stats_Setup('30');
takeScreenshot('SessionStart.png');
sps.setup('tree_map', RUNESCAPE_SURFACE);
initDTMs(); //initialize the DTMs here
findNormalRandoms();
myScriptTimer.start();
repeat
mainLoop();
//processGratsStats();
until (myScriptTimer.getTime() > 99999999);
paintDisplay();
takeScreenshot('SessionResult.png');
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
end.

srlMW

2015-06-16 06:28:35

From: evilcitrus
What problems are you having with DTMs?

I noticed you didn't define them globally, which you should. You also need to free them.
This is a common way to do both

procedure initDTMs();
begin
logDTM := ...;
bowDTM := ...;
end;

procedure freeDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;
then you need to add them to the script

begin
addOnTerminate('freeDTMs'); //add this to free the DTMs when the script stops
clearDebug();
smartEnableDrawing := true;
setupSRL();
//stats_Setup('30');
takeScreenshot('SessionStart.png');
sps.setup('tree_map', RUNESCAPE_SURFACE);
initDTMs(); //initialize the DTMs here
findNormalRandoms();
myScriptTimer.start();
repeat
mainLoop();
//processGratsStats();
until (myScriptTimer.getTime() > 99999999);
paintDisplay();
takeScreenshot('SessionResult.png');
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
end.


Got DTMs working because of you, thanks a heap! :spot:

srlMW

2015-06-16 06:29:36

UPDATE
Updated script to the work in progress V393. ATM I am cleaning up the code, removing the unneeded lines and improving procedures so that everything is 100% bug free and failsafed. I've now added two new procedures #1 walks to best area to start. #2 will drop everything in the bag before it starts mainloop. Going to update the paint now.


program masterTreeChopperv393;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint2.png');

{ procedure processGratsStats(); //deleted the rest of stats stuff
var //because going to be doing it in v4
choppedTrees, craftedShafts, logsBurnt: integer; //which will happen after i clean
begin //this up and improve it to it's max
stats_IncVariable('29', (choppedTrees)); //kept this because they are the basics
stats_IncVariable('23', (logsBurnt));
stats_IncVariable('65', (craftedShafts * 15));
stats_IncVariable('79', (logsBurnt * 50));
stats_IncVariable('80', (choppedTrees * 25));
begin
stats_commit();
end;
end; }

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 27;
fletchedBows := LogsFletched * 27;
logsBurnt := LogsBurned * 27;
xpGained := ((LogsBurned * 27 * 50) + (Logsfletched * 27 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(ToStr(TimeRunning(TIME_SHORT)), point(355, 399), 'xpchars', true, clGreen);
smartImage.drawText(ToStr(choppedTrees, logsHR), point(38, 399), 'xpchars', true, clSilver);
smartImage.drawText(ToStr(fletchedBows, bowsHR), point(246, 399), 'xpchars', true, clYellow);
smartImage.drawText(ToStr(logsBurnt, logsHR), point(137, 399), 'xpchars', true, clRed);
smartImage.drawText(ToStr(xpGained) + ' XP', point(482, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure checkBag();
begin
while (not tabBackPack.isEmpty) do
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(50) of
0..5:
begin
if (not findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34))) then
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 1 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
wait(randomRange(500, 999));
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
repeat
if minimap.isPlayerMoving() then
cutTimer.pause;
until (not minimap.isPlayerMoving());
cutTimer.start;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 8000) then
noColour();
until tabBackPack.isFull;
inc(logsCut);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
repeat
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 20) then
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
burnTimer.start;
startTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
tabBackPack.waitForShift(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
tabBackPack.waitForShift(randomRange(1000, 1500));
if (startTimer.getTime > 6000) then
exit
else
begin
repeat
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
until tabBackPack.waitForShift(randomRange(3000, 4000));
end;
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not tabBackpack.waitForShift(randomRange(4000, 5000)));
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
if tabBackPack.isFull() then
begin
dropTimer.start;
case random(18) of
0..2: slot := 2;
3..4: slot := 6;
5..6: slot := 3;
7..8: slot := 28;
10..12: slot := 12;
13..14: slot := 17;
15..16: slot := 21;
17..18: slot := 8;
end
begin
repeat
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
until tabBackpack.waitCount(1, 1000 + random(500)) or (dropTimer.getTime > 9999999)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
begin
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
end;
end;
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
findNormalRandoms();
setup();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
noColour();
locateTrees();
end;
progressReport();
case random(5) of
0..2:
begin
fletchlogs();
dropBows();
end;
3..5: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
addOnTerminate('freeDTMs');
clearDebug();
smartEnableDrawing := true;
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
walk2Begin();
initDTMs();
findNormalRandoms();
beginPic();
checkBag();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > 99999999);
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

srlMW

2015-06-17 06:14:02

The beta design for the new paint, it still needs some adjusting but I like the way it's progressing. Sits over the top of the action bar.


E: Would of got longer but accidentally closed SMART, ran smoothly for the whole time!

Now onto the actual scripting… ATM I am trying to implement a player form that allows the user to choose how long to run the script for, if they want to fletch, burn or both. Below is all I've got so far…

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := 'https://villavu.com/forum/showthread.php?t=107572';
scriptSettingsPath := '';

editBoxLabels := ['Run for (amount) milliseconds'];
editBoxDefaults := ['600000'];
editBoxHints := ['1000 = 1 second, 60000 = 1 minute, 600000 = 1 hour'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
end;
end;

procedure declarePlayers();
var
i: integer;
begin
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]);
booleans[0] := strToBool(playerForm.players[i].settings[3]);
booleans[1] := strToBool(playerForm.players[i].settings[4]);
booleans[2] := strToBool(playerForm.players[i].settings[5]);
strings[0] := playerForm.players[i].settings[7];

end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');

for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

begin
clearDebug();
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
//setupSRL();
end.

Now you can probably tell I have no idea at all whatsoever to how to do this properly so help is appreciated! :redface:

E: This is my current script below
program masterTreeChopperv393;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

{ procedure processGratsStats(); //deleted the rest of stats stuff
var //because going to be doing it in v4
choppedTrees, craftedShafts, logsBurnt: integer; //which will happen after i clean
begin //this up and improve it to it's max
stats_IncVariable('29', (choppedTrees)); //kept this because they are the basics
stats_IncVariable('23', (logsBurnt));
stats_IncVariable('65', (craftedShafts * 15));
stats_IncVariable('79', (logsBurnt * 50));
stats_IncVariable('80', (choppedTrees * 25));
begin
stats_commit();
end;
end; }

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint2.png');

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
xpGained := ((LogsBurned * 28 * 50) + (Logsfletched * 28 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(355, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(38, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(246, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(137, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(482, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure checkBag();
begin
while (not tabBackPack.isEmpty) do
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(50) of
0..5:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 1 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
wait(randomRange(500, 999));
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 8000) then
noColour();
until tabBackPack.isFull;
inc(logsCut);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
startTimer.start;
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 20) then
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
repeat
burnTimer.start;
startTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
tabBackPack.waitForShift(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
tabBackPack.waitForShift(randomRange(1000, 1500));
begin
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
until tabBackPack.waitCount(26, 1000 + random(500)) or (startTimer.getTime > 6000);
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
if tabBackPack.isFull() then
begin
dropTimer.start;
case random(18) of
0..2: slot := 2;
3..4: slot := 6;
5..6: slot := 3;
7..8: slot := 28;
10..12: slot := 12;
13..14: slot := 17;
15..16: slot := 21;
17..18: slot := 8;
end
begin
repeat
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
until tabBackpack.waitCount(0, 1000 + random(500)) or (dropTimer.getTime > 45000)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
begin
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
end;
end;
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
findNormalRandoms();
setup();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
case random(5) of
0..2:
begin
fletchlogs();
dropBows();
end;
3..5: burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
addOnTerminate('freeDTMs');
clearDebug();
smartEnableDrawing := true;
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
walk2Begin();
initDTMs();
findNormalRandoms();
beginPic();
checkBag();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > 99999999);
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
end.

The Mayor

2015-06-17 07:08:37

From: srlMW
The beta design for the new paint, it still needs some adjusting but I like the way it's progressing. Sits over the top of the action bar.



Now onto the actual scripting… ATM I am trying to implement a player form that allows the user to choose how long to run the script for, if they want to fletch or burn or both. Below is all I've got so far…

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := 'https://villavu.com/forum/showthread.php?t=107572';
scriptSettingsPath := '';

editBoxLabels := ['Run for (amount) milliseconds'];
editBoxDefaults := ['600000'];
editBoxHints := ['1000 = 1 second, 60000 = 1 minute, 600000 = 1 hour'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
end;
end;

procedure declarePlayers();
var
i: integer;
begin
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]);
booleans[0] := strToBool(playerForm.players[i].settings[3]);
booleans[1] := strToBool(playerForm.players[i].settings[4]);
booleans[2] := strToBool(playerForm.players[i].settings[5]);
strings[0] := playerForm.players[i].settings[7];

end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');

for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

begin
clearDebug();
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
//setupSRL();
end.

Now you can probably tell I have no idea at all whatsoever to how to do this properly so help is appreciated! :redface:


You only have 3 settings (inputs) in your playerForm (settings[0], settings[1], and settings[2]), but you are assigning settings[3..7] to the player's boolean/integer placeholders too. You should only be assigning:


integers[0] := strToInt(playerForm.players[i].settings[0]); // Run Time
booleans[0] := strToBool(playerForm.players[i].settings[1]); // Fletch
booleans[1] := strToBool(playerForm.players[i].settings[2]); // Bonfire


Everything else looks OK though. I would suggest making the run time input minutes as using milliseconds is pretty silly really as people will have to pull out their casio calculators each time they run your script.

To actually use the settings you've assigned you would go:


if players[currentPlayer].booleans[0] then // boolean[0] was fletching
begin
fletchBows();
dropBows();
end;

srlMW

2015-06-17 07:28:07

From: The Mayor
You only have 3 settings (inputs) in your playerForm (settings[0], settings[1], and settings[2]), but you are assigning settings[3..7] to the player's boolean/integer placeholders too. You should only be assigning:


integers[0] := strToInt(playerForm.players[i].settings[0]); // Run Time
booleans[0] := strToBool(playerForm.players[i].settings[1]); // Fletch
booleans[1] := strToBool(playerForm.players[i].settings[2]); // Bonfire


Everything else looks OK though. I would suggest making the run time input minutes as using milliseconds is pretty silly really as people will have to pull out their casio calculators each time they run your script.

To actually use the settings you've assigned you would go:


if players[currentPlayer].booleans[0] then // boolean[0] was fletching
begin
fletchBows();
dropBows();
end;


10/10 :thumbsup:

This really helped! On the topic of doing minutes instead of milliseconds though, how would I have the script do that? At them moment it just gets script time and I believe that is by default ms?

E: Is this what you meant? Not sure how to do if player wants fletch and burn, do i go [0, 1], [0 and 1] or [0] and [1] etc? Not quite sure… ATM there is an error on line 431 (first if players) stating
Error: Operator "Index" not compatible with types "(False=0, True=1)" and "Int32" at line 431
program masterTreeChopperv393;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint2.png');

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := 'https://villavu.com/forum/showthread.php?t=107572';
scriptSettingsPath := '';
editBoxLabels := ['Run for (amount) milliseconds'];
editBoxDefaults := ['600000'];
editBoxHints := ['1000 = 1 second, 60000 = 1 minute, 600000 = 1 hour'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
end;
end;

procedure declarePlayers();
var
i: integer;
begin
currentPlayer := 0;
for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
xpGained := ((LogsBurned * 28 * 50) + (Logsfletched * 28 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(355, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(38, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(246, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(137, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(482, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure checkBag();
begin
while (not tabBackPack.isEmpty) do
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(50) of
0..5:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 1 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
wait(randomRange(500, 999));
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 8000) then
noColour();
until tabBackPack.isFull;
inc(logsCut);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
startTimer.start;
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 20) then
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
repeat
burnTimer.start;
startTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
tabBackPack.waitForShift(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
tabBackPack.waitForShift(randomRange(1000, 1500));
begin
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
until tabBackPack.waitCount(26, 1000 + random(500)) or (startTimer.getTime > 6000);
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
if tabBackPack.isFull() then
begin
dropTimer.start;
case random(18) of
0..2: slot := 2;
3..4: slot := 6;
5..6: slot := 3;
7..8: slot := 28;
10..12: slot := 12;
13..14: slot := 17;
15..16: slot := 21;
17..18: slot := 8;
end
begin
repeat
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
until tabBackpack.waitCount(0, 1000 + random(500)) or (dropTimer.getTime > 45000)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
begin
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
end;
end;
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
findNormalRandoms();
setup();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
if players[currentPlayer].booleans[0][1] then
begin
case random(4) of
0..2:
begin
fletchLogs();
dropBows();
end;
3..4:
begin
burnLogs();
end;
end;
end
else if players[currentPlayer].booleans[0] then
begin
fletchLogs();
dropBows();
end
else if players[currentPlayer].booleans[1] then
begin
burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
addOnTerminate('freeDTMs');
clearDebug();
smartEnableDrawing := true;
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
walk2Begin();
initDTMs();
findNormalRandoms();
beginPic();
checkBag();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > 99999999);
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
end.

fady

2015-06-17 09:52:46

From: srlMW
10/10 :thumbsup:

This really helped! On the topic of doing minutes instead of milliseconds though, how would I have the script do that? At them moment it just gets script time and I believe that is by default ms?

E: Is this what you meant? Not sure how to do if player wants fletch and burn, do i go [0, 1], [0 and 1] or [0] and [1] etc? Not quite sure… ATM there is an error on line 431 (first if players) stating
Error: Operator "Index" not compatible with types "(False=0, True=1)" and "Int32" at line 431
program masterTreeChopperv393;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint2.png');

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := 'https://villavu.com/forum/showthread.php?t=107572';
scriptSettingsPath := '';
editBoxLabels := ['Run for (amount) milliseconds'];
editBoxDefaults := ['600000'];
editBoxHints := ['1000 = 1 second, 60000 = 1 minute, 600000 = 1 hour'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
end;
end;

procedure declarePlayers();
var
i: integer;
begin
currentPlayer := 0;
for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
xpGained := ((LogsBurned * 28 * 50) + (Logsfletched * 28 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(355, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(38, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(246, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(137, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(482, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure checkBag();
begin
while (not tabBackPack.isEmpty) do
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(50) of
0..5:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 1 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
wait(randomRange(500, 999));
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 8000) then
noColour();
until tabBackPack.isFull;
inc(logsCut);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
startTimer.start;
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 20) then
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
repeat
burnTimer.start;
startTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
tabBackPack.waitForShift(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
tabBackPack.waitForShift(randomRange(1000, 1500));
begin
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
until tabBackPack.waitCount(26, 1000 + random(500)) or (startTimer.getTime > 6000);
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
if tabBackPack.isFull() then
begin
dropTimer.start;
case random(18) of
0..2: slot := 2;
3..4: slot := 6;
5..6: slot := 3;
7..8: slot := 28;
10..12: slot := 12;
13..14: slot := 17;
15..16: slot := 21;
17..18: slot := 8;
end
begin
repeat
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
until tabBackpack.waitCount(0, 1000 + random(500)) or (dropTimer.getTime > 45000)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
begin
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
end;
end;
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
findNormalRandoms();
setup();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
if players[currentPlayer].booleans[0][1] then
begin
case random(4) of
0..2:
begin
fletchLogs();
dropBows();
end;
3..4:
begin
burnLogs();
end;
end;
end
else if players[currentPlayer].booleans[0] then
begin
fletchLogs();
dropBows();
end
else if players[currentPlayer].booleans[1] then
begin
burnLogs();
end;
paintDisplay();
progressReport();
end;

begin
addOnTerminate('freeDTMs');
clearDebug();
smartEnableDrawing := true;
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
walk2Begin();
initDTMs();
findNormalRandoms();
beginPic();
checkBag();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > 99999999);
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
end.


  if players[currentPlayer].booleans[0][1] then

Just do
   if players[currentPlayer].booleans[0] and players[currentPlayer].booleans[1] then    // This Checks that both booleans have to be true

srlMW

2015-06-17 20:05:48

From: fady
  if players[currentPlayer].booleans[0][1] then

Just do
   if players[currentPlayer].booleans[0] and players[currentPlayer].booleans[1] then    // This Checks that both booleans have to be true


Not sure how I didn't think of this, my last solution was to just make fletching & burning also an option haha. :)

srlMW

2015-06-17 21:21:11

The script cuts the logs but when it goes to do the selected player choice it gets and stops… Not sure what it is meaning as everything compiles correctly.
ERROR: Access violation at line 458
Here is my code atm, obviously I've done something wrong but with my lack of experience in player forms I've got no idea…
E: I've tried everything I can think of, might resort to leaving the player form out till I can solve it
program masterTreeChopperv393;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint2.png');

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := 'https://villavu.com/forum/showthread.php?t=107572';
scriptSettingsPath := '';
editBoxLabels := ['Run for (amount) milliseconds'];
editBoxDefaults := ['600000'];
editBoxHints := ['1000 = 1 second, 60000 = 1 minute, 600000 = 1 hour'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
end;
end;

procedure declarePlayers();
var
i: integer;
begin
currentPlayer := 0;
for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
xpGained := ((LogsBurned * 28 * 50) + (Logsfletched * 28 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(355, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(38, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(246, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(137, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(482, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure checkBag();
begin
while (not tabBackPack.isEmpty) do
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(50) of
0..5:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 1 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
wait(randomRange(500, 999));
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 8000) then
noColour();
until tabBackPack.isFull;
inc(logsCut);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
startTimer.start;
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 20) then
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
repeat
burnTimer.start;
startTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
tabBackPack.waitForShift(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
tabBackPack.waitForShift(randomRange(1000, 1500));
begin
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
until tabBackPack.waitCount(26, 1000 + random(500)) or (startTimer.getTime > 6000);
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
if tabBackPack.isFull() then
begin
dropTimer.start;
case random(18) of
0..2: slot := 2;
3..4: slot := 6;
5..6: slot := 3;
7..8: slot := 28;
10..12: slot := 12;
13..14: slot := 17;
15..16: slot := 21;
17..18: slot := 8;
end
begin
repeat
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
until tabBackpack.waitCount(0, 1000 + random(500)) or (dropTimer.getTime > 45000)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
begin
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
end;
end;
end;

procedure fletchNBurn();
begin
case random(4) of
0..2:
begin
fletchLogs();
dropBows();
end;
3..4:
begin
burnLogs();
end;
end;
end;

procedure fletchingOnly();
begin
fletchLogs();
dropBows();
end;

procedure burningOnly();
begin
burnLogs();
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
findNormalRandoms();
setup();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
begin
if players[currentPlayer].booleans[0] and players[currentPlayer].booleans[1] then //error is here <--
fletchNBurn()
else if players[currentPlayer].booleans[0] then
fletchingOnly()
else if players[currentPlayer].booleans[1] then
burningOnly();
end;
paintDisplay();
progressReport();
end;

begin
addOnTerminate('freeDTMs');
clearDebug();
smartEnableDrawing := true;
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
walk2Begin();
initDTMs();
findNormalRandoms();
beginPic();
checkBag();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > 99999999);
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
end.

srlMW

2015-06-18 03:03:23

From: srlMW
The script cuts the logs but when it goes to do the selected player choice it gets and stops… Not sure what it is meaning as everything compiles correctly.
ERROR: Access violation at line 458
Here is my code atm, obviously I've done something wrong but with my lack of experience in player forms I've got no idea…
E: I've tried everything I can think of, might resort to leaving the player form out till I can solve it
program masterTreeChopperv393;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint2.png');

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := 'https://villavu.com/forum/showthread.php?t=107572';
scriptSettingsPath := '';
editBoxLabels := ['Run for (amount) milliseconds'];
editBoxDefaults := ['600000'];
editBoxHints := ['1000 = 1 second, 60000 = 1 minute, 600000 = 1 hour'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
end;
end;

procedure declarePlayers();
var
i: integer;
begin
currentPlayer := 0;
for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

procedure speedAntiBan();
begin
case random(100) of
0..67:
begin
randomMouseSpeed(2, 15, 30);
writeln('* * * changing mouse speed * * *');
end;
end;
end;

procedure checkSkills();
begin
case random(100) of
0..10:
begin
hoverSkill(SKILL_WOODCUTTING);
writeln('* * * checking woodcutting skill * * *');
end;
11..21:
begin
hoverSkill(SKILL_FIREMAKING);
writeln('* * * checking firemaking skill * * *');
end;
23..23:
begin
hoverSkill(SKILL_FLETCHING);
writeln('* * * checking fletching skill * * *');
end;
end;
end;

procedure afkingKid();
begin
case random(100) of
0..80:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
writeln('* * * moved mouse off screen * * *');
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..20: boredHuman(true);
21..30: pickUpMouse();
31..50: smallRandomMouse();
51..70:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
71..85: randomGameTab(true);
86..99: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
xpGained := ((LogsBurned * 28 * 50) + (Logsfletched * 28 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(355, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(38, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(246, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(137, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(482, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure checkBag();
begin
while (not tabBackPack.isEmpty) do
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(50) of
0..5:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 1 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
wait(randomRange(500, 999));
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
repeat
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(7000, 8000)) or (cutTimer.getTime > 8000);
if (cutTimer.getTime > 8000) then
noColour();
until tabBackPack.isFull;
inc(logsCut);
paintDisplay();
case random(10) of
0..2: checkSkills();
3..4: speedAntiBan();
5..6: randomHumanBehaviour();
end;
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
startTimer.start;
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 20) then
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
repeat
burnTimer.start;
startTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
tabBackPack.waitForShift(randomRange(1000, 3000));
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
tabBackPack.waitForShift(randomRange(1000, 1500));
begin
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
until tabBackPack.waitCount(26, 1000 + random(500)) or (startTimer.getTime > 6000);
repeat
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (tabBackPack.isEmpty) or (burnTimer.getTime > 120000);
inc(logsBurned);
end;

procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
if tabBackPack.isFull() then
begin
dropTimer.start;
case random(18) of
0..2: slot := 2;
3..4: slot := 6;
5..6: slot := 3;
7..8: slot := 28;
10..12: slot := 12;
13..14: slot := 17;
15..16: slot := 21;
17..18: slot := 8;
end
begin
repeat
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
until tabBackpack.waitCount(0, 1000 + random(500)) or (dropTimer.getTime > 45000)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
begin
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(16) of
0..4: speedAntiBan();
5..8: afkingKid();
9..12: checkSkills();
13..16: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
end;
end;
end;

procedure fletchNBurn();
begin
case random(4) of
0..2:
begin
fletchLogs();
dropBows();
end;
3..4:
begin
burnLogs();
end;
end;
end;

procedure fletchingOnly();
begin
fletchLogs();
dropBows();
end;

procedure burningOnly();
begin
burnLogs();
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
findNormalRandoms();
setup();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
begin
if players[currentPlayer].booleans[0] and players[currentPlayer].booleans[1] then //error is here <--
fletchNBurn()
else if players[currentPlayer].booleans[0] then
fletchingOnly()
else if players[currentPlayer].booleans[1] then
burningOnly();
end;
paintDisplay();
progressReport();
end;

begin
addOnTerminate('freeDTMs');
clearDebug();
smartEnableDrawing := true;
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
walk2Begin();
initDTMs();
findNormalRandoms();
beginPic();
checkBag();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > 99999999);
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
end.


Could the access violation be because the booleans aren't globals?

The Mayor

2015-06-18 04:41:59

From: srlMW
Could the access violation be because the booleans aren't globals?


Probably because the 'players' array is empty. Normally in declare players you would setLength(players, 1). You don't have to do this if you're using the player form because it does it for you depending on how many players you setup in the form.

It looks like you are missing:

players.setup(playerForm.players);

So your declare players would look like this:


procedure declarePlayers();
var
i: integer;
begin
players.setup(playerForm.players); // missing this
currentPlayer := 0;

for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

srlMW

2015-06-18 05:23:54

From: The Mayor
Probably because the 'players' array is empty. Normally in declare players you would setLength(players, 1). You don't have to do this if you're using the player form because it does it for you depending on how many players you setup in the form.

It looks like you are missing:

players.setup(playerForm.players);

So your declare players would look like this:


procedure declarePlayers();
var
i: integer;
begin
players.setup(playerForm.players); // missing this
currentPlayer := 0;

for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;


I cannot verbally express how I feel right now… so here.


srlMW

2015-06-18 21:53:57

UPDATE
Updated script to the work in progress V398. ATM I am cleaning up the code, removing the unneeded lines and improving procedures so that everything is 100% bug free and failsafed.

Still upgrading all the antibans at the moment and just now added in Grats stat tracking! Variable page & Commit page. Working on auto the downloaders now and break handler.


Best proggy to date got 2HRS n 50MINS but turned off because it reached input run time… Whoops. :/


program masterTreeChopperv398;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint3.png');

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := 'https://villavu.com/forum/showthread.php?t=107572';
scriptSettingsPath := '';
editBoxLabels := ['Run for (amount)'];
editBoxDefaults := ['600000'];
editBoxHints := [''];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
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]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
stats_Timer: integer;
stats_ID, stats_Pass, stats_ScriptID: string;
stats_Vars: array of TStats_Vars;

procedure stats_Setup(_ScriptID: string);
var
id, pass: string;
begin
if (not directoryExists(stats_Path)) then
begin
forceDirectories(stats_Path);
writeINI('General', 'Stats_ID', '', stats_Path + stats_File);
writeINI('General', 'Stats_Pass', '', stats_Path + stats_File);
end;
id := readINI('General', 'Stats_ID', stats_Path + stats_File);
pass := readINI('General', 'Stats_Pass', stats_Path + stats_File);
if id = '' then
begin
case MessageBox('No Stats ID found, would you like to register?', 'Stats', 1) of
1: openWebPage('http://stats.grats.pw/reg.php');
end;
end;
stats_ID := id;
stats_Pass := pass;
stats_ScriptID := _ScriptID;
stats_Timer := getSystemTime();
end

procedure stats_InitVariable(VarName: string; InitValue: Integer);
var
len: Integer;
begin
len := Length(stats_Vars);
SetArrayLength(stats_Vars, len + 1);
stats_Vars[len].Name := LowerCase(VarName);
stats_Vars[len].Value := InitValue;
end;

procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);
if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := NewValue;
Exit;
end;
stats_InitVariable(VarName, NewValue);
end;

procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);
if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := stats_Vars[i].Value + Value;
Exit;
end;
stats_InitVariable(VarName, Value);
end;

function stats_Commit(): Boolean;
var
S: string;
Client, i, Worked, ExtraTime: integer;
begin
ExtraTime := getSystemTime() - stats_Timer;
Worked := ExtraTime div 60000;
if Worked < 5 then
Exit;
ExtraTime := ExtraTime - (Worked * 60000);
stats_Timer := GetSystemTime - ExtraTime;
Client := InitializeHTTPClient(False);
ClearPostData(Client);
if (stats_ID = '') then
begin
stats_ID := '5';
stats_Pass := 'anon1337';
end;
AddPostVariable(Client, 'user_id', STATS_ID);
AddPostVariable(Client, 'password', STATS_PASS);
AddPostVariable(Client, 'script_id', STATS_SCRIPTID);
AddPostVariable(Client, 'timeamount', toStr(Worked));
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
AddPostVariable(Client, Name, toStr(Min(Value, 30000)));
end;
S := PostHTTPPageEx(Client, 'http://stats.grats.pw/POST.php');
FreeHTTPClient(Client);
case StrToIntDef(ExtractFromStr(S, Numbers), - 1) of
42: Result := True;
9001: writeln('Stats: Invalid user ID/Password.');
1337: writeln('Stats: Invalid Script ID.');
255, 496: writeln('Stats: Committing too fast; shame on you!');
else
writeln('Stats: No POST return');
end;
if Result then
begin
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
Value := 0;
end;
end;
end;

procedure speedAntiBan();
begin
case random(8) of
0..2:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(2, 15, 25);
end;
3..4:
begin
randomMouseSpeed(3, 8, 18);
end;
5..6:
begin
randomMouseSpeed(4, 24, 37);
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(3, 9, 19);
end;
3..4:
begin
randomMouseSpeed(2, 25, 30);
end;
5..6:
begin
randomMouseSpeed(4, 16, 26);
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(3, 7, 17);
end;
3..4:
begin
randomMouseSpeed(4, 13, 23);
end;
5..6:
begin
randomMouseSpeed(2, 20, 28);
end;
end;
end;
end;
end;

procedure checkSkills();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(randomRange(700, 2000));
end;
3..4:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(randomRange(550, 1750));
end;
5..6:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(randomRange(900, 2500));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(randomRange(700, 2000));
end;
3..4:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(randomRange(600, 1600));
end;
5..6:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(randomRange(345, 970));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_FLETCHING);
Wait(randomRange(400, 1500));
end;
3..4:
begin
hoverSkill(SKILL_FLETCHING);
Wait(randomRange(500, 1500));
end;
5..6:
begin
hoverSkill(SKILL_FLETCHING);
Wait(randomRange(1000, 2100));
end;
end;
end;
end;
end;

procedure afkingBurning();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(125000, 135000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(115000, 125000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(105000, 115000));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(75000, 95000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(85000, 100000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(91000, 105000));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(890000, 129000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(110000, 120000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(100000, 120000));
end;
end;
end;
end;
end;

procedure afkingFletching();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(50000, 65000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(67000, 80000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(48000, 53000));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(40000, 45000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(55000, 60000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(75000, 85000));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(70000, 76000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(45000, 50000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(50000, 55000));
end;
end;
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..10: boredHuman(true);
11..15: pickUpMouse();
16..25: smallRandomMouse();
51..65:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
66..70: randomGameTab(true);
71..80: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := LogsCut * 28;
fletchedBows := LogsFletched * 28;
logsBurnt := LogsBurned * 28;
xpGained := ((LogsBurned * 28 * 50) + (Logsfletched * 28 * 5) + (choppedTrees * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(372, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(34, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(267, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(148, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(506, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure checkBag();
begin
while (not tabBackPack.isEmpty) do
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems();
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(2) of
0..1:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 1 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
wait(randomRange(500, 999));
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
speedAntiBan();
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
pickUpMouse();
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
pickUpMouse();
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
pickUpMouse();
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(12000, 15000)) or (cutTimer.getTime > 15000);
if (cutTimer.getTime > (randomRange(13000, 15000))) then
noColour();
inc(logsCut);
stats_IncVariable('29', 28);
stats_IncVariable('80', 28 * 25);
paintDisplay();
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
speedAntiBan();
startTimer.start;
while tabBackpack.isItemInSlot(slot) or (startTimer.getTime > 5000) do
begin
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
end;
addingTimer.start;
while tabBackpack.isItemInSlot(slot2) or (addingTimer.getTime > 7500) do
begin
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(300, 500));
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
while (not tabBackPack.count = 0) or (burnTimer.getTime > 120000) do
begin
paintDisplay();
case random(13) of
1..10: afkingBurning();
11..13: boredHuman();
end;
end;
inc(logsBurned);
stats_IncVariable('23', 28);
stats_IncVariable('79', 28 * 50);
end;

procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
if tabBackPack.isFull() then
begin
speedAntiBan();
dropTimer.start;
begin
repeat
case random(19) of
0..3: tabBackpack.dropItems([1, 2, 6, 11, 16, 21, 26, 7, 12, 17, 22, 27, 3, 8, 13, 18, 23, 28, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25]);
4..6: tabBackpack.dropItems([25, 20, 15, 10, 5, 24, 19, 14, 9, 4, 28, 23, 18, 13, 8, 3, 27, 22, 17, 12, 7, 26, 21, 16, 11, 6, 2, 1]);
7..9: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
10..13: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
14..16: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
17..19: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
20..23: tabBackPack.dropItems([05, 10, 11, 12, 25, 04, 21, 28, 08, 07, 16, 06, 19, 14, 26, 13, 17, 24, 22, 18, 09, 15, 20, 23, 27, 03, 02]);
24..26: tabBackPack.dropItems([27, 20, 19, 16, 26, 24, 08, 28, 05, 06, 12, 22, 11, 25, 14, 01, 10, 03, 18, 21, 17, 09, 13, 04, 02, 07, 15]);
end;
until tabBackpack.waitCount(0, 1000 + random(500)) or (dropTimer.getTime > 45000)
end;
end;
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
begin
speedAntiBan();
repeat
case random(11) of
0..2: slot := 1;
3..5: slot := 15;
6..8: slot := 19;
9..11: slot := 15;
end;
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(13) of
1..10: afkingFletching();
11..13: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
stats_IncVariable('65', 28 * 5);
end;
end;
end;

procedure fletchNBurn();
begin
case random(4) of
0..2:
begin
fletchLogs();
dropBows();
end;
3..4:
begin
burnLogs();
end;
end;
end;

procedure fletchingOnly();
begin
fletchLogs();
dropBows();
end;

procedure burningOnly();
begin
burnLogs();
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut * 28;
fletchedBows := logsFletched * 28;
logsBurnt := logsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
case random(5) of
0..3: speedAntiBan();
end;
findNormalRandoms();
setup();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
begin
if players[currentPlayer].booleans[0] and players[currentPlayer].booleans[1] then
fletchNBurn()
else if players[currentPlayer].booleans[0] then
fletchingOnly()
else if players[currentPlayer].booleans[1] then
burningOnly();
end;
paintDisplay();
progressReport();
stats_commit();
end;

begin
addOnTerminate('freeDTMs');
clearDebug();
smartEnableDrawing := true;
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
setupSRL();
stats_Setup('30');
stats_commit();
sps.setup('tree_map', RUNESCAPE_SURFACE);
walk2Begin();
initDTMs();
findNormalRandoms();
beginPic();
checkBag();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > players[currentPlayer].integers[0]);
writeln('Ran for inputed time. Finishing up');
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

srlMW

2015-06-18 23:33:52

Does anyone know what this means? Got the error after it used the log on the fire.
-- ERROR: **gaussian failed**

The Mayor

2015-06-19 04:14:55

From: srlMW
Does anyone know what this means? Got the error after it used the log on the fire.
-- ERROR: **gaussian failed**


That is normally nothing to worry about. It's a message the function gaussRangeExt( ) prints when the value it returns is not between the minimum and maximum values. Looking at your script, I'd guess it would be this line, do you know why?


Wait(GaussRangeInt(890000, 129000));

srlMW

2015-06-19 20:30:35

From: The Mayor
That is normally nothing to worry about. It's a message the function gaussRangeExt( ) prints when the value it returns is not between the minimum and maximum values. Looking at your script, I'd guess it would be this line, do you know why?


Wait(GaussRangeInt(890000, 129000));


No idea, I've changed it to randomRange now to see if it makes a difference.

J_R

2015-06-19 20:39:09

From: srlMW
No idea, I've changed it to randomRange now to see if it makes a difference.


Hint, look at the numbers!

srlMW

2015-06-19 20:44:10

From: J_R
Hint, look at the numbers!


E: Oh I see, must of typed an extra zero by accident… Thanks both!

srlMW

2015-06-20 03:54:49

UPDATE
Updated script to the work in progress V399. ATM I am cleaning up the code, removing the unneeded lines and improving procedures so that everything is 100% bug free and failsafed. I would appreciate suggestions for the script, so that I may learn more, not really knowing what to add anymore.

Added logging in and once finished logging out, going to start working on the auto downloaders now and break handler. Any tips, tricks and examples are welcome as usual, treading into unknown waters again. :unsure:


Questions:
- What is the default player form run time? I assumed ms because that is how everything else is.
- For learning purpose I want to be able to make the script generate a random slot to drop till it is empty, is there a way to have it remember past numbers and cut them out or not do them etc?

Problems:
- Currently this is happening when it attempts to burnlogs, not quite sure why it happens.
-- tabBackpack.countDTM(): Counted 28 items
-- ERROR: tabBackpack(): The slot "0" is an incorrect slot. Use a slot between 1..28
-- ERROR: tabBackpack(): The slot "0" is an incorrect slot. Use a slot between 1..28
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
The script is also failing to drop the bows
-- ERROR: dropItems: You didnt enter any slots to drop.
Here is the drop procedure
procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
speedAntiBan();
if tabBackPack.isEmpty then
exit
else if (not tabBackPack.isEmpty) then
case random(4) of
1: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
2: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
3: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
4: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;
Here is the burnprocedure
procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
speedAntiBan();
startTimer.start;
while tabBackpack.isItemInSlot(slot) or (startTimer.getTime > 5000) do
begin
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
end;
addingTimer.start;
while tabBackpack.isItemInSlot(slot2) or (addingTimer.getTime > 7500) do
begin
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(300, 500));
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
while (not tabBackPack.isEmpty) or (burnTimer.getTime > 120000) do
begin
paintDisplay();
case random(13) of
1..10: afkingBurning();
11..13: boredHuman();
end;
end;
inc(logsBurned);
stats_IncVariable('23', 28);
stats_IncVariable('79', 28 * 50);
end;

program masterTreeChopperv398;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

var
myScriptTimer: TTimeMarker;
returnPoint := Point (206, 167);
logsCut, logsFletched, logsBurned, bowDTM, logDTM: integer;
paintBMP := loadBitmap (appPath + '/Scripts/MWsMasterTreeChopperv1/Paint3.png');

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'MWs Master Tree Chopper | v1';
scriptHelpThread := '';
scriptSettingsPath := '';
editBoxLabels := ['Run for (amount)'];
editBoxDefaults := ['18000000'];
editBoxHints := ['| 5hrs: 18000000 |'];
checkBoxLabels := ['Flecthing', 'Bonfiring'];
checkBoxDefaults := ['True', 'True'];
checkBoxHints := ['Cuts -> Fletches -> Drops', 'Cuts -> Burns'];
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]);
booleans[0] := strToBool(playerForm.players[i].settings[1]);
booleans[1] := strToBool(playerForm.players[i].settings[2]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for i := 0 to high(players) do
begin
writeln('Running for: ', players[i].integers[0]);
writeln('Fletching bows: ', players[i].booleans[0]);
writeln('Burning logs: ', players[i].booleans[1]);
end;
end;

const
stats_Path = AppPath + 'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
stats_Timer: integer;
stats_ID, stats_Pass, stats_ScriptID: string;
stats_Vars: array of TStats_Vars;

procedure stats_Setup(_ScriptID: string);
var
id, pass: string;
begin
if (not directoryExists(stats_Path)) then
begin
forceDirectories(stats_Path);
writeINI('General', 'Stats_ID', '', stats_Path + stats_File);
writeINI('General', 'Stats_Pass', '', stats_Path + stats_File);
end;
id := readINI('General', 'Stats_ID', stats_Path + stats_File);
pass := readINI('General', 'Stats_Pass', stats_Path + stats_File);
if id = '' then
begin
case MessageBox('No Stats ID found, would you like to register?', 'Stats', 1) of
1: openWebPage('http://stats.grats.pw/reg.php');
end;
end;
stats_ID := id;
stats_Pass := pass;
stats_ScriptID := _ScriptID;
stats_Timer := getSystemTime();
end

procedure stats_InitVariable(VarName: string; InitValue: Integer);
var
len: Integer;
begin
len := Length(stats_Vars);
SetArrayLength(stats_Vars, len + 1);
stats_Vars[len].Name := LowerCase(VarName);
stats_Vars[len].Value := InitValue;
end;

procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);
if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := NewValue;
Exit;
end;
stats_InitVariable(VarName, NewValue);
end;

procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);
if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := stats_Vars[i].Value + Value;
Exit;
end;
stats_InitVariable(VarName, Value);
end;

function stats_Commit(): Boolean;
var
S: string;
Client, i, Worked, ExtraTime: integer;
begin
ExtraTime := getSystemTime() - stats_Timer;
Worked := ExtraTime div 60000;
if Worked < 5 then
Exit;
ExtraTime := ExtraTime - (Worked * 60000);
stats_Timer := GetSystemTime - ExtraTime;
Client := InitializeHTTPClient(False);
ClearPostData(Client);
if (stats_ID = '') then
begin
stats_ID := '5';
stats_Pass := 'anon1337';
end;
AddPostVariable(Client, 'user_id', STATS_ID);
AddPostVariable(Client, 'password', STATS_PASS);
AddPostVariable(Client, 'script_id', STATS_SCRIPTID);
AddPostVariable(Client, 'timeamount', toStr(Worked));
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
AddPostVariable(Client, Name, toStr(Min(Value, 30000)));
end;
S := PostHTTPPageEx(Client, 'http://stats.grats.pw/POST.php');
FreeHTTPClient(Client);
case StrToIntDef(ExtractFromStr(S, Numbers), - 1) of
42: Result := True;
9001: writeln('Stats: Invalid user ID/Password.');
1337: writeln('Stats: Invalid Script ID.');
255, 496: writeln('Stats: Committing too fast; shame on you!');
else
writeln('Stats: No POST return');
end;
if Result then
begin
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
Value := 0;
end;
end;
end;

procedure speedAntiBan();
begin
case random(8) of
0..2:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(2, 15, 25);
end;
3..4:
begin
randomMouseSpeed(3, 8, 18);
end;
5..6:
begin
randomMouseSpeed(4, 24, 37);
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(3, 9, 19);
end;
3..4:
begin
randomMouseSpeed(2, 25, 30);
end;
5..6:
begin
randomMouseSpeed(4, 16, 26);
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
randomMouseSpeed(3, 7, 17);
end;
3..4:
begin
randomMouseSpeed(4, 13, 23);
end;
5..6:
begin
randomMouseSpeed(2, 20, 28);
end;
end;
end;
end;
end;

procedure checkSkills();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(GaussRangeInt(700, 2000));
end;
3..4:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(GaussRangeInt(550, 1750));
end;
5..6:
begin
hoverSkill(SKILL_WOODCUTTING);
Wait(GaussRangeInt(900, 2500));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(GaussRangeInt(700, 2000));
end;
3..4:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(GaussRangeInt(600, 1600));
end;
5..6:
begin
hoverSkill(SKILL_FIREMAKING);
Wait(GaussRangeInt(345, 970));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
hoverSkill(SKILL_FLETCHING);
Wait(GaussRangeInt(400, 1500));
end;
3..4:
begin
hoverSkill(SKILL_FLETCHING);
Wait(GaussRangeInt(500, 1500));
end;
5..6:
begin
hoverSkill(SKILL_FLETCHING);
Wait(GaussRangeInt(1000, 2100));
end;
end;
end;
end;
end;

procedure afkingBurning();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(GaussRangeInt(125000, 135000));
end;
3..4:
begin
mouseOffClient(4);
Wait(GaussRangeInt(115000, 125000));
end;
5..6:
begin
mouseOffClient(4);
Wait(GaussRangeInt(105000, 115000));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(GaussRangeInt(75000, 95000));
end;
3..4:
begin
mouseOffClient(4);
Wait(GaussRangeInt(85000, 100000));
end;
5..6:
begin
mouseOffClient(4);
Wait(GaussRangeInt(91000, 105000));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(GaussRangeInt(89000, 129000));
end;
3..4:
begin
mouseOffClient(4);
Wait(GaussRangeInt(110000, 120000));
end;
5..6:
begin
mouseOffClient(4);
Wait(GaussRangeInt(100000, 120000));
end;
end;
end;
end;
end;

procedure afkingFletching();
begin
case random(9) of
0..2:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(50000, 65000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(67000, 80000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(48000, 53000));
end;
end;
end;
3..4:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(40000, 45000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(55000, 60000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(75000, 85000));
end;
end;
end;
5..6:
begin
case random(7) of
0..2:
begin
mouseOffClient(4);
Wait(randomRange(70000, 76000));
end;
3..4:
begin
mouseOffClient(4);
Wait(randomRange(45000, 50000));
end;
5..6:
begin
mouseOffClient(4);
Wait(randomRange(50000, 55000));
end;
end;
end;
end;
end;

procedure randomHumanBehaviour();
begin
case random(100) of
0..10: boredHuman(true);
11..15: pickUpMouse();
16..25: smallRandomMouse();
51..65:
begin
randomCameraAngle(MS_ANGLE_HIGH);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
66..70: randomGameTab(true);
71..80: mouseMovingObject();
end;
end;

procedure findNormalRandoms();
begin
claimTicket();
exitTreasure();
closePopup();
end;

procedure setup();
begin
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
tabBackPack.open;
end;

procedure walk2Begin();
var
walkingTimer: TTimeMarker;
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 30 then
SPS.blindWalk(returnPoint)
else
exit;
if (walkingTimer.getTime > 10000) then
exit;
end;

procedure paintDisplay();
var
choppedTrees, fletchedBows, logsBurnt, xpGained, logsHR, bowsHR, burntHR: integer;
begin
choppedTrees := logsCut;
fletchedBows := logsFletched * 28;
logsBurnt := logsBurned * 28;
xpGained := ((logsBurned * 28 * 50) + (logsfletched * 28 * 5) + (logsCut * 25));
logsHR := Round(choppedTrees * (3600.0 / (GetTimeRunning / 1000.0)));
bowsHR := Round(fletchedBows * (3600.0 / (GetTimeRunning / 1000.0)));
burntHR := Round(logsBurnt * (3600.0 / (GetTimeRunning / 1000.0)));
smartImage.clear;
smartImage.drawBitmap(paintBMP, Point(0, 388));
smartImage.drawText(toStr(TimeRunning(TIME_ABBREV)), point(372, 399), 'smallcharsns', true, clGreen);
smartImage.drawText(toStr(choppedTrees) + ' :: ' + toStr(logsHR), point(34, 399), 'smallcharsns', true, clSilver);
smartImage.drawText(toStr(fletchedBows) + ' :: ' + toStr(bowsHR), point(267, 399), 'smallcharsns', true, clYellow);
smartImage.drawText(toStr(logsBurnt) + ' :: ' + toStr(burntHR), point(148, 399), 'smallcharsns', true, clRed);
smartImage.drawText(toStr(xpGained) + ' XP', point(506, 399), 'xpchars', true, clPurple);
end;

procedure initDTMs();
begin
logDTM := DTMFromString('mAAEAAHic42FgYEgH4gwgLgLiciAuBeJiIM4B4hQgjgXiGCCOBOIEKDsdKgfiRwNxKBAHAnEIlB0FlQeZG+6oBiSZiMaSDKQBRhIxMgAAFccKPw==');
bowDTM := DTMFromString('mwQAAAHic42RgYHAAYjMgdgdiVyC2AmIDIDaEinkBsSgQSwMxLxALA7EUEMtDaQ4gZgfiJHuQLBNeLMlAGDASgeEAAD7vA8o=');
end;

procedure freeTheDTMs();
begin
freeDTM(logDTM);
freeDTM(bowDTM);
end;

procedure loggingIn();
begin
if (not isLoggedIn()) then
players[currentPlayer].login();
end;

procedure dropBows();
begin
speedAntiBan();
if tabBackPack.isEmpty then
exit
else if (not tabBackPack.isEmpty) then
case random(4) of
1: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
2: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
3: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
4: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

procedure checkBag();
begin
if (not tabBackPack.isEmpty) then
dropBows();
end;

procedure noColour();
var
walkingTimer, findTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
begin
case random(2) of
0..1:
begin
walkingTimer.start;
if distance(returnPoint, SPS.getPlayerPos()) > 10 then
SPS.blindWalk(returnPoint);
smartImage.clear;
if (walkingTimer.getTime > 10000) then
exit;
end;
end;
end;

procedure locateTrees();
var
cutTimer: TTimeMarker;
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
speedAntiBan();
minimap.toggleRun(true);
if tabBackPack.isfull then
exit;
begin
cutTimer.start;
findColorsSpiralTolerance(x, y, TPA, 1253921, mainScreen.getBounds(), 10, colorSetting(2, 1.72, 2.34));
pickUpMouse();
ATPA := TPA.cluster(20);
ATPA.filterBetween(0, 20) if (length(ATPA) < 1) then
exit();
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugTPA(TPA, false);
pickUpMouse();
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], (randomRange(100, 500))) then
begin
fastClick(MOUSE_LEFT);
pickUpMouse();
smartImage.clear;
break;
end;
end;
end;
tabBackpack.waitForShift(randomRange(14000, 15000)) or (cutTimer.getTime > 15000);
if (cutTimer.getTime > (randomRange(14000, 15000))) then
noColour();
inc(logsCut);
stats_IncVariable('29', 1);
stats_IncVariable('80', 25);
paintDisplay();
end;

procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
speedAntiBan();
startTimer.start;
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
while tabBackpack.isItemInSlot(slot) or (startTimer.getTime > 5000) do
begin
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
end;
addingTimer.start;
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
while (not tabBackpack.waitCount(26, 2000 + random(500))) or (addingTimer.getTime > 7500) do
begin
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(300, 500));
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
while (not tabBackPack.isEmpty) or (burnTimer.getTime > 120000) do
begin
paintDisplay();
case random(13) of
1..10: afkingBurning();
11..13: boredHuman();
end;
end;
inc(logsBurned);
stats_IncVariable('23', 28);
stats_IncVariable('79', 28 * 50);
end;

procedure fletchLogs();
var
failTimer: TTimeMarker;
slot: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) >= 1) then
begin
speedAntiBan();
repeat
actionbar.clickSlot(1);
if toolScreen.isOpen(1000) then
toolScreen.select('Knife');
wait(randomRange(1000, 2000));
if productionScreen.isOpen(1000) then
failTimer.start;
begin
writeLn('The production screen is open');
productionScreen.selectBox(2);
if (productionScreen._getSelectedBox(2) = 2) then
productionScreen.clickStart();
end;
until (progressScreen.isOpen(randomRange(3500, 4500))) or (failTimer.getTime > 7500);
if progressScreen.isOpen() then
begin
repeat
wait(randomRange(500, 1000));
paintDisplay();
case random(13) of
1..10: afkingFletching();
11..13: boredHuman();
end;
until (not progressScreen.isOpen()) or (failTimer.getTime > 55000);
inc(logsFletched);
stats_IncVariable('65', 28 * 5);
stats_IncVariable('142', 28);
dropBows();
end;
end;
end;

procedure fletchNBurn();
begin
case random(4) of
0..2:
begin
fletchLogs();
end;
3..4:
begin
burnLogs();
end;
end;
end;

procedure fletchingOnly();
begin
fletchLogs();
dropBows();
end;

procedure burningOnly();
begin
burnLogs();
end;

procedure beginPic();
begin
tabStats.open();
takeScreenshot('PreSession.png');
end;

procedure endPic();
begin
tabStats.open();
takeScreenshot('PostSession.png');
end;

procedure progressReport();
var
choppedTrees, fletchedBows, logsBurnt: integer;
begin
choppedTrees := logsCut;
fletchedBows := logsFletched * 28;
logsBurnt := logsBurned * 28;
writeln('Have any suggestions or bugs? Post them on the scripts thread!');
writeln('_________________________________________________________');
writeLn('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|================MWs Master Tree Chopper================|');
writeln('| * * * * * * * * * * * * * * * * * * * * * * * * * * * |');
writeLn('|Time Run: ' + timeRunning);
writeLn('|_______________________________________________________|');
writeLn('|Trees Chopped: ' + intToStr(choppedTrees));
writeLn('|_______________________________________________________|');
writeLn('|Bows Fletched: ' + intToStr(fletchedBows));
writeLn('|_______________________________________________________|');
writeLn('|Logs Burnt: ' + intToStr(logsBurnt));
writeLn('|_______________________________________________________|');
writeLn('|_______________________________________________________|');
end;

procedure mainLoop();
begin
speedAntiBan();
findNormalRandoms();
paintDisplay();
while not tabBackPack.isFull() do
begin
paintDisplay();
locateTrees();
end;
progressReport();
begin
if players[currentPlayer].booleans[0] and players[currentPlayer].booleans[1] then
fletchNBurn()
else if players[currentPlayer].booleans[0] then
fletchingOnly()
else if players[currentPlayer].booleans[1] then
burningOnly();
end;
paintDisplay();
progressReport();
stats_commit();
end;

begin
addOnTerminate('freeTheDTMs');
clearDebug();
smartEnableDrawing := true;
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
debugSPFSettings();
setupSRL();
sps.setup('tree_map', RUNESCAPE_SURFACE);
stats_Setup('30');
initDTMs();
stats_commit();
loggingIn();
beginPic();
findNormalRandoms();
checkBag();
walk2Begin();
myScriptTimer.start();
paintDisplay();
repeat
mainLoop();
until (myScriptTimer.getTime() > players[currentPlayer].integers[0]);
writeln('Ran for inputed time. Finishing up');
endPic();
writeln('View your sessions results here @ Simba/Includes/srl-6/logs');
paintDisplay();
players[currentPlayer].logout();
freeTheDTMs();
end.

DISCLAIMER:
I highly recommend none use this script as it is strictly only for learning purposes!

fady

2015-06-20 08:29:52

From: srlMW
UPDATE
Updated script to the work in progress V399. ATM I am cleaning up the code, removing the unneeded lines and improving procedures so that everything is 100% bug free and failsafed. I would appreciate suggestions for the script, so that I may learn more, not really knowing what to add anymore.

Added logging in and once finished logging out, going to start working on the auto downloaders now and break handler. Any tips, tricks and examples are welcome as usual, treading into unknown waters again. :unsure:


Questions:
- What is the default player form run time? I assumed ms because that is how everything else is.
- For learning purpose I want to be able to make the script generate a random slot to drop till it is empty, is there a way to have it remember past numbers and cut them out or not do them etc?

Problems:
- Currently this is happening when it attempts to burnlogs, not quite sure why it happens.
-- tabBackpack.countDTM(): Counted 28 items
-- ERROR: tabBackpack(): The slot "0" is an incorrect slot. Use a slot between 1..28
-- ERROR: tabBackpack(): The slot "0" is an incorrect slot. Use a slot between 1..28
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
---- TRSChooseOption.close(): result = true
The script is also failing to drop the bows
-- ERROR: dropItems: You didnt enter any slots to drop.
Here is the drop procedure
procedure dropBows();
var
slot, x, y: integer;
dropTimer: TTimeMarker;
begin
speedAntiBan();
if tabBackPack.isEmpty then
exit
else if (not tabBackPack.isEmpty) then
case random(4) of
1: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
2: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
3: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
4: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;
Here is the burnprocedure
procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
speedAntiBan();
startTimer.start;
while tabBackpack.isItemInSlot(slot) or (startTimer.getTime > 5000) do
begin
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
end;
addingTimer.start;
while tabBackpack.isItemInSlot(slot2) or (addingTimer.getTime > 7500) do
begin
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(300, 500));
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
while (not tabBackPack.isEmpty) or (burnTimer.getTime > 120000) do
begin
paintDisplay();
case random(13) of
1..10: afkingBurning();
11..13: boredHuman();
end;
end;
inc(logsBurned);
stats_IncVariable('23', 28);
stats_IncVariable('79', 28 * 50);
end;



Questions:
- What is the default player form run time? I assumed ms because that is how everything else is.

Yes it is in ms. So, 600000 is going to be a run time of 10 minutes long. 3600000 would be 1 hour

- For learning purpose I want to be able to make the script generate a random slot to drop till it is empty, is there a way to have it remember past numbers and cut them out or not do them etc?

Maybe use global variables. A variable that is defined inside a procedure, is "forgotten" once the procedure is done. A global variable defined outside procedures are "remembered" until they are redefined.


procedure burnLogs();
var
burnTimer, startTimer, addingTimer: TTimeMarker;
slot, slot2, x, y: integer;
begin
if tabBackPack.isFull() and (tabBackpack.countDTM(logDTM) = 28) then
speedAntiBan();
startTimer.start;
while tabBackpack.isItemInSlot(slot) or (startTimer.getTime > 5000) do //The script looks for an item in "slot" before it has been defined.
//A variable that has not been defined has a value of 0. Try defining the value of the variable before using it.
begin
case random(11) of
0..2: slot := 1;
3..5: slot := 5;
6..8: slot := 9;
9..11: slot := 24;
end;
burnTimer.start;
tabBackpack.mouseSlot(slot, MOUSE_RIGHT);
chooseOption.select(['ight']);
end;
addingTimer.start;
while tabBackpack.isItemInSlot(slot2) or (addingTimer.getTime > 7500) do //same thing here. If you want the script to "remember" slot and slot2, try declaring them as global variables instead and define them before you use them.
//also make sure you only have 1 "slot" and 1 "slot2" variable in your whole script if you decide to declare them globally.
begin
case random(11) of
0..2: slot2 := 13;
3..5: slot2 := 18;
6..8: slot2 := 11;
9..11: slot2 := 23;
end;
tabBackpack.mouseSlot(slot2, MOUSE_RIGHT);
chooseOption.select(['se']);
wait(randomRange(300, 500));
mainscreen.findObject(x, y, 817304, 21, ['Use Logs -> Fire'], MOUSE_RIGHT);
chooseOption.select(['Use Logs -> Fire']);
end;
while (not tabBackPack.isEmpty) or (burnTimer.getTime > 120000) do
begin
paintDisplay();
case random(13) of
1..10: afkingBurning();
11..13: boredHuman();
end;
end;
inc(logsBurned);
stats_IncVariable('23', 28);
stats_IncVariable('79', 28 * 50);
end;

as for the dropLogs procedure, I can't tell what is wrong with it.

srlMW

2015-06-21 01:23:08

WooHoo! 3 hours of running, ran into one bug but already fixed with a few key changes!
E: Just after the 3 hour mark it had a problem with the sps and it started wandering north east till it hit wildy and then kept trying to go further… Any ideas? It's happened before a few times.

E: It got to (\/below\/) and ended up in the G.E… Any clues to why the sps messes up like this?

The Mayor

2015-06-21 11:33:58


procedure dropBows();
var
slot, x, y: integer; // None of these are used
dropTimer: TTimeMarker;
begin
//speedAntiBan();
if tabBackPack.isEmpty then
exit // No need to evaluate .isEmpty() twice
else if (not tabBackPack.isEmpty) then
case random(4) of // ran(4) = 0, 1, 2 or 3
1: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
2: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
3: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
4: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

You could just write:

procedure dropBows(); override;
begin
speedAntiBan();

if not tabBackPack.isEmpty() then
case random(4) of
0: tabBackpack.dropItems(DROP_PATTERN_REGULAR);
1: tabBackpack.dropItems(DROP_PATTERN_SNAKE);
2: tabBackpack.dropItems(DROP_PATTERN_BACKWARDS);
3: tabBackpack.dropItems(DROP_PATTERN_UP_DOWN);
end;
end;

-- ERROR: dropItems: You didnt enter any slots to drop.

That is fixed in the latest srl-6 revision (was actually a lape bug).

rj

2015-06-21 12:24:29

@srlMW; I shortened your antiban procedure from 255 lines to 86 lines.

procedure speedAntiBan();
begin
case random(8) of
0..2:
begin
case random(7) of
0..2: randomMouseSpeed(2, 15, 25);
3..4: randomMouseSpeed(3, 8, 18);
5..6: randomMouseSpeed(4, 24, 37);
end;
end;
3..4:
begin
case random(7) of
0..2: randomMouseSpeed(3, 9, 19);
3..4: randomMouseSpeed(2, 25, 30);
5..6: randomMouseSpeed(4, 16, 26);
end;
end;
5..6:
begin
case random(7) of
0..2: randomMouseSpeed(3, 7, 17);
3..4: randomMouseSpeed(4, 13, 23);
5..6: randomMouseSpeed(2, 20, 28);
end;
end;
end;
end;

procedure checkSkills();
begin
case random(3) of
0: hoverSkill(SKILL_WOODCUTTING);
1: hoverSkill(SKILL_FIREMAKING);
2: hoverSkill(SKILL_FLETCHING);
end;
case random(3) of
0: Wait(randomRange(700, 2000));
1: Wait(randomRange(550, 1750));
2: Wait(randomRange(900, 2500));
end;
end;


procedure afkingBurning();
begin
case random(9) of
0..6:
begin
mouseOffClient(4);
case random(9) of
0: Wait(randomRange(125000, 135000));
1: Wait(randomRange(115000, 125000));
2: Wait(randomRange(105000, 115000));
3: Wait(randomRange(75000, 95000));
4: Wait(randomRange(85000, 100000));
5: Wait(randomRange(91000, 105000));
6: Wait(randomRange(890000, 129000));
7: Wait(randomRange(110000, 120000));
8: Wait(randomRange(100000, 120000));
end;
end;
end;
end;

procedure afkingFletching();
begin
case random(9) of
0..6:
mouseOffClient(4);
begin
case random(7) of
0: Wait(randomRange(50000, 65000));
1: Wait(randomRange(67000, 80000));
2: Wait(randomRange(48000, 53000));
3: Wait(randomRange(40000, 45000));
4: Wait(randomRange(55000, 60000));
5: Wait(randomRange(75000, 85000));
6: Wait(randomRange(70000, 76000));
7: Wait(randomRange(45000, 50000));
8: Wait(randomRange(50000, 55000));
end;
end;
end;