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
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!




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














