Foundry
2013-11-11 21:32:02
I'm having trouble using pointers again… When I run the following it will work up to the point where it displays the proggy and then it will throw this error at me.
When I tried commenting that out and just trying to see the value with writeLn it gave me this.
So I'm sort of stuck on what to do here… help?
Script below
Exception in Script: Runtime error: "Access violation" at line 464, column 26
all of the stuff about bmps not being freed, etc.When I tried commenting that out and just trying to see the value with writeLn it gave me this.
Exception in Script: Runtime error: "Privileged instruction" at line 464, column 27
all of the stuff about bmps not being freed, etc.So I'm sort of stuck on what to do here… help?
Script below
program HardcorFletcher;
{$DEFINE SMART}
{$i srl-6/srl.simba}
const
HowLongToRun = 300; // How long (in minutes) do you want the script to run?
AntibanLevel = 'high'; // How frequently do you want the script to call the antiban procedure?
ScriptOption = 0; // 0 = Will make headless arrows.
// 1 = Will only make shafts.
// 2 = Will only gather feathers (not yet implemented).
// SHAFT MAKING OPTIONS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DepositShafts = 2; // While crafting the shafts, do you wish to deposit them (false is more human-like, true is not).
AmountToMake = 999999; // How many do you want to make before stopping (leave alone if you want to make them until you run out of logs).
var
AddButtonBMP, CancelButtonBMP, LockBMP, FletchBMP, ScriptRunTime,
AntibanInt, DesiredRunTime, ABCounter, LogsDTM, ShaftsDTM,
FeathersDTM: Integer;
AddBox, CanBox: Tbox;
SettingUp: Boolean;
GeneralTimer: TTimeMarker;
procedure handlePlayers;
begin
setlength(players, 1);
with Players[0] do
begin
LoginName := ''; // USERNAME / EMAIL
Password := ''; // PASSWORD
isActive := true;
isMember := false; // IS THE ACCOUNT MEMBERS?
end;
players[0].login();
Wait(randomrange(1000, 2000));
mainscreen.setAngle(MS_ANGLE_HIGH);
end;
procedure Antiban;
var
FletchBox: Tbox;
XPoint: TPoint;
AntibanLvl: String;
begin
if SettingUp then
begin
AntibanLvl := AntibanLevel;
case AntibanLvl of
'low':
begin
AntibanInt := 4400;
end;
'mid':
begin
AntibanInt := 4000;
end;
'high':
begin
AntibanInt := 3600;
end;
else
begin
WriteLn('Not a valid frequency level for antiban!');
TerminateScript;
end;
end;
exit
end;
case random(AntibanInt) of
0..20:
begin
WriteLn('AB1 - Sleep And Move Mouse');
sleepAndMoveMouse(randomrange(3000, 6000));
inc(ABCounter);
end;
21..30:
begin
WriteLn('AB2 - Random R Click Item');
randomRClickItem;
inc(ABCounter);
end;
31..40:
begin
if ScriptOption = 0 then
begin
WriteLn('AB3 - Camera Angle Low');
randomCameraAngle(MS_ANGLE_LOW);
inc(ABCounter);
end;
end;
41..50:
begin
WriteLn('AB4 - General Skill Check');
tabStats.open();
Wait(randomrange(1300, 2700));
tabBackpack.open();
inc(ABCounter);
end;
51..60:
begin
WriteLn('AB5 - Random Mouse Point');
XPoint.create(Random(500), Random(500));
mouse(XPoint, MOUSE_MOVE);
inc(ABCounter);
end;
61..70:
begin
WriteLn('AB6 - Mouse Off Client');
mouseOffClient(OFF_CLIENT_RANDOM);
inc(ABCounter);
end;
71..80:
begin
WriteLn('AB7 - Small Random Mouse Move');
smallRandomMouse(100);
inc(ABCounter);
end;
81..90:
begin
if ScriptOption = 0 then
begin
WriteLn('AB8 - Random Compass');
randomCompass(3, 200, true);
inc(ABCounter);
end;
end;
101..110:
begin
WriteLn('AB9 - Mouse Moving Object');
mouseMovingObject();
inc(ABCounter);
end;
111..120:
begin
WriteLn('AB10 - Camera Angle High');
randomCameraAngle(MS_ANGLE_HIGH);
inc(ABCounter);
end;
end;
end;
procedure bmpBoxWait (bmp, tol, minWait, maxWait, maxMaxWait: Integer; bool1, bool2, AB: Boolean; box: Tbox);
var
Timer: TTimeMarker;
begin
Timer.start();
if box.bitmapExists(bmp, tol) = bool1 then
repeat
wait(randomrange(minWait, maxWait));
if AB then
begin
Antiban;
end;
until((box.bitmapExists(bmp, tol) = bool2) or (Timer.getTime() > maxMaxWait));
end;
procedure proggy(ProggyType, MadeSoFar, Goal: Integer);
var
PerHr, XPPerHr: Integer;
Msg: String;
begin
case ProggyType of
0:
begin
PerHr := round((MadeSoFar * 150000) / (GeneralTimer.getTime() / 3600));
Msg := 'Headless arrows';
XPPerHr := PerHr;
end;
1:
begin
PerHr := round((MadeSoFar * 1000) / (GeneralTimer.getTime() / 3600));
Msg := 'Shafts';
end;
end;
wait(randomrange(200, 350));
smartEnableDrawing := true;
smartImage.clearArea(IntToBox(10, 10, 300, 100));
smartImage.drawBox(IntToBox(10, 10, 300, 100), true, clGreen);
smartImage.drawText(' Been making ' + Msg + ' for ' + msToTime(GeneralTimer.getTime, TIME_SHORT), point(10,10), upchars, false, clOrange);
smartImage.drawText(' Amount per hour: ' + IntToStr(PerHr), point(10, 25), upchars, false, clOrange);
if ProggyType = 1 then
begin
PerHr := round(((MadeSoFar / 15) * 1000) / (GeneralTimer.getTime() / 3600));
XPPerHr := PerHr * 5;
end;
smartImage.drawText(' XP per hour: ' + IntToStr(XPPerHr), point(10, 40), upchars, false, clOrange);
smartImage.drawText(' Time ''til done: ' + msToTime(round((Goal / PerHr) * 3600000), TIME_SHORT), point(10, 55), upchars, false, clOrange);
smartImage.drawText(' Antiban total: ' + IntToStr(ABCounter), point(10, 70), upchars, false, clOrange);
smartImage.drawText(' Antiban per hour: ' + FloatToStr(round((ABCounter * 1000) / (GeneralTimer.getTime() / 60000))), point(10, 85), upchars, false, clOrange);
end;
procedure makeShafts(Amount: Integer);
var
LogsInInv, ShaftsMade, ShaftBMP, KnifeBMP, LogsLeft, RN, LogSlot: Integer;
pnt: TPoint;
LogBox, LockBox, Box: TBox;
FoundBank: Boolean;
begin
RN := randomrange(20, 30);
FoundBank := true;
GeneralTimer.reset();
GeneralTimer.start();
LockBox.setBounds(810, 290, 870, 340);
if not tabBackpack.getQuickInventorySlot(QUICK_INVENTORY_B) = 2 then
tabBackpack.setQuickInventorySlot(2, QUICK_INVENTORY_B);
SettingUp := true;
repeat
if mainscreen.findObject(pnt.x, pnt.y, 2974066, 7, colorSetting(2, 0.19, 0.36), point(475, 325), 7, 18, 100, ['ank'], MOUSE_LEFT) then
begin
if FoundBank = false then
FoundBank := true;
repeat
wait(randomrange(300, 540));
until(bankscreen.isOpen());
if SettingUp then
begin
wait(randomrange(300, 540));
if not findDTM(LogsDTM, pnt.x, pnt.y, intToBox(bankscreen.getBounds.x1, bankscreen.getBounds.y1, bankscreen.getBounds.x2 - 200, bankscreen.getBounds.y2)) and
isMouseOverMenuOpen(bankscreen.getBounds) then
mouse(point(bankscreen.getbounds.x1 - random(10), bankscreen.getbounds.y1 - random(10)), MOUSE_MOVE);
if findDTM(LogsDTM, pnt.x, pnt.y, intToBox(bankscreen.getBounds.x1, bankscreen.getBounds.y1, bankscreen.getBounds.x2 - 200, bankscreen.getBounds.y2)) then
begin
writeLn('Found logs in the bank!');
LogSlot := bankscreen.pointToSlot(pnt);
LogBox := bankScreen.getBankSlotBox(LogSlot);
end
else
begin
writeLn('Couldn''t find the logs in the bank... perhaps scroll up?');
terminateScript;
end;
end
else
begin
if DepositShafts = 1 then
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
if DepositShafts = 2 and random(1, RN) < 5 then
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
end;
wait(randomrange(300, 540));
LogsLeft := getItemAmount(LogBox);
case random(10) of
0..6:
bankscreen.withdraw(LogSlot, WITHDRAW_AMOUNT_ALL, ['Logs']);
7..8:
bankscreen.withdraw(LogSlot, 28, ['Logs']);
9:
bankscreen.withdraw(LogSlot, WITHDRAW_AMOUNT_ALL_BUT_ONE, ['Logs']);
end;
wait(randomrange(100, 300));
if not bankscreen.close() then
repeat
bankscreen.close();
until(bankscreen.isOpen = false);
bmpBoxWait(LockBMP, 15, 200, 300, 9999, true, false, false, LockBox);
LogsInInv := tabBackpack.countDTM(LogsDTM);
if tabBackpack.isFull then
begin
case random(7) of
0..5:
tabBackpack.mouseSlot(randomrange(5, 20), MOUSE_LEFT);
6:
begin
actionBar.clickSlot(14);
getMousePos(pnt.x, pnt.y);
if not SettingUp then
mouse(point(pnt.x + randomrange(20, 40), pnt.y + randomrange(20, 40)), MOUSE_MOVE);
end;
end;
if SettingUp then
begin
Box.setBounds(445, 300, 520, 370);
KnifeBMP := BitmapFromString(12, 11, 'meJxt0M0KgkAUBWBpGfQOvkDQ3j' +
'LNDMnlgMho4l9E71CbcBViSRE9bgcvHCIazmZmPs4dxrFdb+Uhju0' +
'qpRKdjAwjz/eI1lnbPrC1rLkYBKYqKxyW5SHLqijSNMhiaIMRgJI4' +
'Tm/3F7amOaNZ+1uaNC2a5iqARibisK6PMqXv32LCMKRBlbwWT+26J' +
'0vE4FbAeOojp/OFAOU0BBJOwQo2gTzjG0yWBY0a1k8JAYLbIt/Jj/' +
'0F+HDmA74kWp8=');
ShaftBMP := BitmapFromString(20, 15, 'meJyzNpCyNpDi0vRgEZRjZGCwhn' +
'GBJJyLzIZIQdTDRYCycAWY5lijWgFRT5KlcI1w9cRbCjEHrh6PpWg' +
'OINVSTDOR1SNrJMlStDAhyVLMiCPeUmREqqWY4Y8rfsm2FDM6cFmK' +
'Zj5+S5Et4jWLg5tPkqWYsYbfUgDU+GyJ');
bmpBoxWait(KnifeBMP, 15, 300, 600, 2000, false, true, false, Box);
if not findBitmapToleranceIn(KnifeBMP, pnt.x, pnt.y, Box, 15) then
begin
WriteLn('Couldn''t find the knife in the menu...');
freeBitmap(KnifeBMP);
Box.setBounds(230, 180, 730, 460);
if not Box.bitmapExists(ShaftBMP, 50) then
begin
freeBitmap(KnifeBMP);
terminateScript;
end;
end else
begin
mouse(pnt.rand(7), MOUSE_LEFT);
freeBitmap(KnifeBMP);
end;
Box.setBounds(345, 180, 570, 315);
wait(randomrange(500, 800));
if not findBitmapToleranceIn(ShaftBMP, pnt.x, pnt.y, Box, 60) then
begin
Box.setBounds(230, 220, 285, 270);
if not findBitmapToleranceIn(ShaftBMP, pnt.x, pnt.y, Box, 110) then
begin
WriteLn('Couldn''t correctly set up shafts as crafting item...');
freeBitmap(ShaftBMP);
terminateScript;
end;
mouse(pnt.rand(4), MOUSE_LEFT);
end;
freeBitmap(ShaftBMP);
end;
bmpBoxWait(FletchBMP, 50, 400, 600, 3000, false, true, false, AddBox);
AddBox.mouse(MOUSE_LEFT);
wait(randomrange(3000, 4000));
bmpBoxWait(CancelButtonBMP, 15, 600, 840, 99999, true, false, true, CanBox);
ShaftsMade := ShaftsMade + (LogsInInv * 15);
proggy(1, ShaftsMade, LogsLeft);
end else
begin
if SettingUp then
WriteLn('You probably input the wrong bank slot for your logs.')
else
WriteLn('Ran out of logs...');
terminateScript;
end;
end else
begin
if FoundBank = true then
begin
writeLn('Can''t find nearby bank, gonna move the mouse and try again.');
mouse(point(randomrange(75, 125), randomrange(75, 125)), MOUSE_MOVE);
FoundBank := false;
end
else
begin
writeLn('Couldn''t find bank... terminating script.');
terminateScript;
end;
end;
if SettingUp then
SettingUp := false;
until((ShaftsMade > Amount) or ((GetTimeRunning() / 60000) > DesiredRunTime));
end;
function amountLeft(Slot: Integer): Integer;
var
x, y: Integer;
begin
wait(200);
if isMouseOverMenuOpen(tabBackpack.getBounds()) or
isMouseOverMenuOpen(mainscreen.getBounds()) then
begin
getMousePos(x, y);
mouse(point(x - randomrange(70, 100), y - randomrange(70, 100)), MOUSE_MOVE);
end;
result := getItemAmount(tabBackpack.getSlotBox(Slot));
if result <= 1 then
begin
WriteLn('Ran out of shafts... terminating script');
terminateScript;
end;
end;
function DTMToSlot(var Slot, DTM: Integer): Boolean;
var
SlotIndex: TIntegerArray;
begin
SlotIndex := findItem(DTM, tabBackpack.getSlotBoxes, true);
Slot := SlotIndex[0] + 1;
end;
procedure setup;
begin
DesiredRuntime := HowLongToRun;
disableSRLDebug := true;
SettingUp := true;
Antiban;
SettingUp := false;
AddBox.setbounds(480, 455, 695, 475);
CanBox.setbounds(444, 212, 517, 228);
end;
procedure promptMenu(Slot1, Slot2: Integer);
begin
case random(2) of
0:
begin
tabBackpack.mouseSlot(Slot1, MOUSE_LEFT);
wait(randomrange(120, 371));
tabBackpack.mouseSlot(Slot2, MOUSE_LEFT);
end;
1:
begin
tabBackpack.mouseSlot(Slot2, MOUSE_LEFT);
wait(randomrange(120, 371));
tabBackpack.mouseSlot(Slot1, MOUSE_LEFT);
end;
end;
wait(randomrange(120, 225));
end;
procedure menuHandler;
begin
bmpBoxWait(AddButtonBMP, 15, 250, 410, 9999, false, true, false, AddBox);
AddBox.mouse(MOUSE_LEFT);
wait(randomrange(3000, 4000)); // This is a failsafe in the case of the blue button persisting through the fletching cycle.
bmpBoxWait(CancelButtonBMP, 15, 600, 840, 99999, true, false, true, CanBox);
end;
procedure setUpResources;
begin
ShaftsDTM := DTMFromString('mwQAAAHic42RgYBBggABBIBYBYlYgZgZiNiDmBWIeqDwnEHNDaTYozQXEfEDMAcQu6pwMPLKqQBYjEDOh4GhTXjAWAvIkGbADbihmJALDAQBE+AMB');
LogsDTM := DTMFromString('mwQAAAHic42RgYJjJxMDQC8RdQDwFiOcD8XIgXgLEK4C4G4gXMzIwzAPi1UC8AYjXAPEqqNhiKA51UAOaxoQXizAQBoxEYDgAADv+DEQ=');
FeathersDTM := DTMFromString('mrAAAAHic42BgYDjDwsBwA4gvA/FZID4MxEeB+CAQHwDim4wQ/ACInwHxcyC+DsR3gfgREK9fsQJoCiMaZoJjfgb8AF0nOoYBAA/wD5M=');
LockBMP := BitmapFromString(11, 10, 'meJwz1pEyBiM9DQkgUpIVTI5yhS' +
'MgFyKupSIKVAMkZSX5Y0IcIbJABlCBoaYYRAqCtNUk0RQAtQMVAMU' +
'hJMQEOAIqgIhDtAO5QAXB3tYQ2ahAW6AI3HCIAyRFeQPcLYBqIAio' +
'YPHcDjxoxuSOnCRvXKgkM6CpIgGPAghKj/XAhSAKAChGXkg=');
AddButtonBMP := BitmapFromString(20, 15, 'meJxL92ZLByN+JfXzZx5jRUCpdJ' +
'gyZFQYxApBcL1ABhqCq0FD1RFQhKwXLoiJkM1sS2SHIGS9cEE0hOa' +
'viZkcEITHzVgVABlzCjkgCH9YYTV5QQknBOGxF1kWGS0q44QgZL1w' +
'QayycLSsghOCkGXhgvhlV9dwQRCyLFwQGWFaTbxeZDUQtL6BC44gp' +
'iGLYCJk/25u5hpyCADDqmjR');
CancelButtonBMP := BitmapFromString(20, 11, 'meJyVkTEKgDAMRZcGCh28g4sHdH' +
'T3OJ5E6AEcO3oJA6GfT9IOwkd+fvLaEkX2Zd3q3fQr3ZvUm7hkn/M' +
'BFh6lS1y3lBMstzSHrIVJDOR8DVnNo9wbROqQ1TyKt8FIYJ8od++c' +
'bVB/YXMDZlBGfLZnY1Gm9P76v4413O1keDIfbiDE2+Auhx/YGAGu');
FletchBMP := BitmapFromString(17, 6, 'meJzjV1LnB6PqCFY4AnLPn3kMRPz' +
'YZCFSENm2RHYggqtHRsiyEAQXn5jJAUSYtiCLY+qaU8iBxoUgrLZD' +
'1Cwo4UTWAuRCEKbVELSojBOIkGUhIsiCAKvSgTg=');
addOnTerminate('freeResources');
end;
procedure freeResources;
begin
freeDTM(LogsDTM);
freeDTM(FeathersDTM);
freeDTM(ShaftsDTM);
freeBitmaps([CancelButtonBMP, AddButtonBMP, LockBMP, FletchBMP]);
end;
procedure makeHAs;
var
HACounter, FeatherSlot, ShaftSlot: Integer;
LimitingAmount: function(): Integer;
begin
GeneralTimer.reset();
GeneralTimer.start();
if DTMToSlot(FeatherSlot, FeathersDTM) = false or
DTMToSlot(ShaftSlot, ShaftsDTM) = false then
begin
writeLn('Failed to set up slots for feathers or shafts');
terminateScript;
end;
if amountLeft(FeatherSlot) > amountLeft(ShaftSlot) then
LimitingAmount := @amountLeft(ShaftSlot)
else
LimitingAmount := @amountLeft(FeatherSlot);
repeat
promptMenu(FeatherSlot, ShaftSlot);
menuHandler;
inc(HACounter);
writeLn(LimitingAmount);
//proggy(0, HACounter, LimitingAmount);
until((GetTimeRunning() / 60000) > DesiredRunTime);
end;
begin
smartEnableDrawing := true;
SetupSRL();
handlePlayers();
setUpResources;
setup;
if ScriptOption = 1 then
makeShafts(AmountToMake)
else
makeHAs;
end.