Simba Code:
program AshamanHerblore;
{$DEFINE SMART}
{$DEFINE FAILSAFE}
{$I SRL-6/SRL.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}
var
itemCount, xp, slot, startingXP, itemsPH, xph, bir, bfr, stacks, stackCheck, slots: integer;
itemType, typeEdit: string;
timeout, currentBTime: TTimeMarker;
W, X, Y, Z, realBTime, breakRounds, totalbreaks, antiB, mouseB, profit, totalProfit: integer;
debug, normalBank: Boolean;
newValues, oldValues: array [0..2] of integer;
statsTimer: TTimeMarker;
const
SCRIPT_VERSION = '2.6';
procedure declareplayers();
var
i,j: integer;
begin
players.setup(playerForm.playerNames, playerForm.playerFile); // load the SPF players from the SRL Player Manager
currentPlayer := 0; // player to use first
// set player attributes based on the settings from the form
for i := 0 to high(players) do
with players[i] do
begin
// convert the integers
integers[0] := strToInt(playerForm.players[i].settings[1]); //minutes until break
integers[1] := strToInt(playerForm.players[i].settings[2]); //minutes to break
for j := 0 to high(playerForm.comboBoxItems[1]) do
if (playerForm.players[i].settings[11] = playerForm.comboBoxItems[1][j]) then
integers[2] := j; //bankinglocation
Stacks := strToInt(playerForm.players[i].settings[4]); //number of stacks
World := strToInt(playerForm.players[i].settings[3]); //world
ismember:=true;
if (playerForm.players[i].settings[12] = 'Normal') then
normalBank := true;
if not normalBank then
for j := 0 to high(playerForm.comboBoxItems[2]) do //quickload
if (playerForm.players[i].settings[12] = playerForm.comboBoxItems[2][j]) then
integers[4] := j+2;
// booleans
booleans[0] := strToBool(playerForm.players[i].settings[6]); //takebreaks
booleans[1] := strToBool(playerForm.players[i].settings[7]); //switchworlds
FindMod := strToBool(playerForm.players[i].settings[8]); //mods
debug := strToBool(playerForm.players[i].settings[9]); //debug
// any other data types you've decided to use
strings[0] := playerForm.players[i].settings[0]; //quickkey
strings[1] := playerForm.players[i].settings[10]; //cleanorpots
if (not normalbank) and (strings[1] = 'Pots') then
slots := 14 else
slots := 28;
if (playerForm.players[i].settings[5] = '') then
begin
writeln('No UserAgent detected. Opening up webpage to get userAgent');
openWebPage('http://whatsmyuseragent.com/');
writeln('Copy your useragent text and paste it into the form');
writeln('Restart script');
terminateScript;
end else
smartUserAgent := playerForm.players[i].settings[5]; //useragent
print('slots: ' + toStr(slots));
end;
end;
// initiates the SRL player form (you aren't restricted to the procedure name; it can be whatever you want)
procedure initPlayerForm();
begin
with playerForm do
begin
name := 'AshamanHerblore v'+toStr(SCRIPT_VERSION); // the title of the SPF, usually the name of your script
scriptHelpThread := ''; // a link to a help thread, if set to '' will link to my setup guide
scriptSettingsPath := ''; // where you want the settings file to be saved; saved in script's path by default
editBoxLabels := ['QuickKey', 'Minutes until break', '# of Minutes to break', 'World', '#ofStacks', 'Client UserAgent']; // edit boxes are created for each array element
editBoxDefaults := [ '0', '600', '15','0', '1', '']; // optional default values for each edit box; array length must equal editBoxLabel length
editBoxHints := ['if cleaning herbs, which key do you have the herb set to in the action bar?',
'How many minutes do you want to run the script before you break?',
'How many minutes do you want to break for?',
'Which world do you want to login to? 0 is random',
'How many stacks of herbs do you want to mix?',
'If you don''t know this, a popup will walk you through it after you hit start'];
checkBoxLabels := ['Take breaks', 'Switch Worlds (After break)', 'Logout if Mod is near', 'Debug']; // same as editBoxLabels but for check boxes
checkBoxDefaults := ['True','True','True', 'False'];
checkBoxHints := ['Do you want to take breaks?',
'Do you want to switch worlds after you break?',
'Do you want to logout if a jmod is detected near you?',
'Do you want to run in debug mode? It prints out more debug and onscreen debug if there are issues'];
comboBoxLabels := ['CleanOrPots','Location','QuickLoad']; // same as editBoxLabels but for combo boxes (drop down boxes)
comboBoxDefaults := ['Clean','NPC_BLUE','Normal'];
comboBoxHints := ['Are you cleaning herbs or mixing pots?',
'Which banking location are you using?',
'Do you want to use the Preset buttons for banking? Select which one'];
// this needs to be done for every element in the comboBoxLabels array
setLength(comboBoxItems, length(comboBoxLabels));
comboBoxItems[0] := ['Clean', 'Pots']; // all the options available for the first combo box
comboBoxItems[1] := ['NPC_BLUE', 'NPC_GREY', 'NPC_GREEN', 'NPC_DRAYNOR', 'BANK_BOOTH', 'CHEST_SW', 'CHEST_SHANTAY', 'CHEST_DUEL', 'CHEST_CW', 'CHEST_GROTTO', 'CHEST_LUMBRIDGE', 'TABLE_BURTHORPE', 'BANK_GE', 'PRIFDDINAS']; // all the options available for the first combo box
comboBoxItems[2] := ['Normal', 'PRESET_1', 'PRESET_2'];
end;
end;
procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
writeln('Player file: ', playerForm.playerFile);
for i := 0 to high(players) do
begin
writeln('QuickKey: ', players[i].strings[0]);
writeln('Minutes until break: ', players[i].integers[0]);
writeln('# of Minutes to break: ', players[i].integers[1]);
writeln('Take breaks: ', players[i].booleans[0]);
writeln('Switch Worlds (After break): ', players[i].booleans[1]);
writeln('Logout if Mod is near: ', players[i].findmod);
writeln('CleanOrPots: ', players[i].strings[1]);
writeln('Location: ', players[i].integers[2]);
writeln('');
end;
end;
{*******************************************************************************
function AutoupdateMe;
By: Shuttleu
Edited By: Ashaman88
Description: Autoupdates Script.
*******************************************************************************}
procedure autoUpdateMe;
var
Neifile: integer;
OnlineVersion, NewScript, NeiFeilNennen: String;
begin
WriteLn('You have the latest version of the script!');
end;
procedure findNormalrandoms;
begin
exitTreasure();
claimTicket();
end;
procedure antiban;
var
i: integer;
begin
i := random(600);
case i of
1: boredHuman(false);
2..7:
begin
hoverSkill(Skill_Herblore);
wait(gaussRangeInt(1000, 2000));
end;
8..50: mouseMovingObject;
51..100: sleepAndMoveMouse(randomRange(100, mouseB));
101..400:
begin
mouseOffClient(4);
wait(randomRange(2000, mouseB));
end;
501..600: wait(randomRange(1000, 2000));
end;
wait(gaussRangeInt(0, antiB));
end;
{ Calculated stats before sending to server by the Mayor} // Removed since my server is expired ~TM 10/aug/15
{
procedure calculateStats();
var
i: integer;
calcValues: Array [0..2] of integer;
begin
calcValues := [round(getTimeRunning() / 60000), ItemCount, XP];
for i := 0 to high(NewValues) do
begin
newValues[i] := calcValues[i] - oldValues[i];
oldValues[i] := calcValues[i];
end;
end;
}
{ Sends stats to server by the Mayor}
{
function sendStats(): boolean;
var
c, i: integer;
statvars: Array [0..2] of string;
begin
statvars := ['Time', 'Items', 'XP'];
c := initializeHTTPClient(false);
for i := 0 to high(statvars) do
addPostvariable(c, statvars[i], intToStr(newValues[i]));
result := pos('true', lowercase(postHTTPPageEx(c, 'http://srlmayor.com/mayorstats/asha/AshaStats.php'))) <> 0;
freeHTTPClient(c);
if result then
calculateStats();
end;
}
procedure progressReport;
var
ttb, profitPH: integer;
method: String;
begin
clearDebug;
ttb := (((W) + (Y) + breakRounds) - getTimeRunning);
xp := (chatBox.getXPBar - startingXP);
xph := round(xp * (3600.0 / (getTimeRunning / 1000.0)));
totalProfit := (itemCount * profit);
profitPH := round((totalProfit * (3600.0 / (getTimeRunning / 1000.0))));
itemsPH := round((itemCount * (3600.0 / (getTimeRunning / 1000.0))));
case players[currentPlayer].strings[1] of
'Clean': method := 'Cleaned';
'Pots': method := 'Made';
end;
writeln('|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|');
writeln('| AshamanHerblore v'+padR(toStr(SCRIPT_VERSION), 24), '|');
writeln('|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|');
writeln(padR('| Running For: '+ timeRunning, 60)+'|');
writeln(padR('| '+ itemType + '''s ' + method + ': ' + groupDigits(itemCount, ','), 37) + padR(method + '/H: ' + groupDigits(itemsPH, ','), 23) + '|');
writeln(padR('| Exp Earned: ' + groupDigits(xp, ','), 37) + padR('Exp/Hour: ' + groupDigits(xph, ','), 23) + '|');
writeln(padR('| Profit: ' + groupDigits(profit,','), 37) + padR('Profit/Hour: ' + groupDigits(profitPH,','), 23) + '|');
writeln('|___________________________________________________________|');
disguise(itemType + '''s ' + method + ': ' + groupDigits(itemCount, ','));
if players[currentPlayer].booleans[0] then
writeln('Time until break: '+ msToTime(ttb, Time_Bare));
{
if statsTimer.getTime() > 300000 then
if sendStats() then
statsTimer.start() else
writeLn('Failed to send stats');
}
end;
function getProfit(herb, page: string): integer; // credit to euphemism
var
potString, potProfit: string;
options: TReplaceFlags;
begin
options := [rfReplaceAll, rfIgnoreCase];
potString := replace(herb, ' ', '_', options);
potString := between('<a href="/wiki/' + potString + '"', '</tr>', getPage(page));
potProfit := between('*', '<', potString);
potProfit := replace(potProfit, ',', '', []);
result := strToIntDef(potProfit, -1);
writeln('Profit per ' + herb + ': '+toStr(result));
end;
function breakHandler(breakIn, breakFor, randbreakIn, randbreakFor: integer): Boolean;
var
H,M,S: integer;
begin
if not isLoggedIn then
exit;
if (getTimeRunning < ((W) + (Y) + breakRounds)) then
exit Else
if (getTimeRunning > ((W) + (Y) + breakRounds)) then
begin
RealBTime := Round((X+Z)/60000);
writeln('Taking a break for about ' + IntToStr(RealBTime) + ' minutes.');
players[currentPlayer].Logout;
currentBTime.Reset;
currentBTime.start;
repeat
wait(21000);
ConvertTime((X+Z)-currentBTime.getTime,H,M,S);
writeln('breaktime left: '+IntToStr(H)+':'+IntToStr(M)+':'+IntToStr(S));
until(currentBTime.getTime>(X+Z));
writeln('Logging in.');
if players[currentPlayer].booleans[1] then
players[currentPlayer].world := 0;
players[currentPlayer].login;
wait(4000);
timeout.start;
Result := isLoggedIn;
minimap.setAngle(MM_DIRECTION_EAST);
mainScreen.setAngle(MS_ANGLE_HIGH);
IncEx(breakRounds, (W) + (X));
Inc(Totalbreaks);
writeln('The next break will occur in about ' + IntToStr(breakIn) + ' minutes.');
W := (breakIn * 60000);
X := (breakFor * 60000);
Y := randomRange(-BIR * 60000, BIR * 60000);
Z := randomRange(-BFR * 60000, BFR * 60000);
end;
end;
function banking: boolean;
var
t: TTimeMarker;
time: integer;
begin
if not isLoggedIn then
exit;
t.start;
SRL_Events[EVENT_ANTIBAN] := nil;
time := gaussRangeInt(15000, 24000);
repeat
wait(random(100));
if bankscreen.open(players[currentPlayer].integers[2]) then
break else
begin
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
end;
if (t.getTime > time) or (not isLoggedIn) then
exit;
until (bankScreen.isOpen);
SRL_Events[EVENT_ANTIBAN] := @antiban;
if normalBank then
if bankScreen.GetPackCount > 0 then
bankScreen.QuickDeposit(QUICK_DEPOSIT_INVENTORY);
case players[currentPlayer].strings[1] of
'Clean':
begin
t.start;
time := gaussRangeInt(8000, 12000);
repeat
if normalBank then
begin
if bankScreen.withdraw(10, WITHDRAW_AMOUNT_ALL, ['']) then
break;
end else
if bankScreen.clickButton(players[currentPlayer].integers[4]) then
break;
if (t.getTime > time) or (not isLoggedIn) then
exit;
wait(gaussRangeInt(0, 1500));
until false;
end;
'Pots':
begin
t.start;
time := gaussRangeInt(8000, 12000);
repeat
if normalBank then
begin
if bankScreen.withdraw(10, 14, ['']) then
break;
end else
if bankScreen.clickButton(players[currentPlayer].integers[4]) then
break;
if (t.getTime > time) or (not isLoggedIn) then
exit;
wait(gaussRangeInt(0, 1500));
until false;
if normalBank then
begin
t.start;
time := gaussRangeInt(8000, 12000);
repeat
if bankScreen.withdraw(9, 14, ['']) then
break;
if (t.getTime > time) Or (not isLoggedIn) then
exit;
wait(gaussRangeInt(0, 1500));
until false;
end;
end;
end;
if normalBank then
bankScreen.close else
begin
t.start;
time := gaussRangeInt(4000, 8000);
repeat
if not bankScreen.__find() then
break;
if (t.getTime > time) Or (not isLoggedIn) then
exit;
wait(gaussRangeInt(0, 200));
until false;
end;
if players[currentPlayer].strings[1] = 'Pots' then
begin
case random(10) of
0..7: slot := 11;
8..9: slot := 12;
end;
tabBackpack.mouseSlot(slot, MOUSE_MOVE);
end;
wait(gaussRangeInt(0, 100));
t.start;
repeat
if (tabBackpack.isItemInSlot(slots)) then
break;
wait(gaussRangeInt(0, 100));
if (t.getTime > 8000) then
begin
if (stacks > 1) And (stackCheck < stacks) then
begin
inc(stackCheck);
exit;
end;
writeln('Failed withdrawing, shutting down - took a screenshot, send pic to ashaman (in the logs folder)');
if debug then
saveScreenshot(scriptPath + timeRunning() + '_' + 'HerbFail.png');
players[currentPlayer].logout;
terminateScript;
end;
if not isLoggedIn then
exit;
until (tabBackpack.isItemInSlot(slots));
if chatbox.findTextOnLines(['could not be'], [0]) then
if countColorTolerance(66033, chatbox.lineBoxes[0], 10) > 100 then
begin
writeln('Failed withdrawing, shutting down - took a screenshot, send pic to ashaman (in the scripts folder)');
if debug then
saveScreenshot(scriptPath + timeRunning() + '_' + 'HerbFail.png');
players[currentPlayer].logout;
terminateScript;
end;
if players[currentPlayer].strings[1] = 'Clean' then
wait(gaussRangeInt(400, 800));
result := true;
end;
function makeItems: boolean;
var
time,X,Y, i: integer;
T: TTimeMarker;
begin
if not isLoggedIn then
exit;
case players[currentPlayer].strings[1] of
'Clean':
begin
antiB := randomRange(0, 500);
mouseB := randomRange(0, 3000);
for i := 0 to 3 do
begin
wait(gaussRangeInt(0, 200));
print('Sending quickkey to open menu');
sendKeys(players[currentPlayer].strings[0], 60 + random(60), 60 + random(60));
wait(gaussRangeInt(0, 100));
print('waiting for production or tool menu');
t.start;
time := gaussRangeInt(4000, 7000);
repeat
wait(gaussRangeInt(0, 100));
if t.getTime > time then
break;
until productionscreen.isOpen or toolscreen.isOpen;
if productionscreen.isOpen or toolscreen.isOpen then
break;
end;
wait(gaussRangeInt(0, 200));
if itemType = '' then
begin
itemType := productionScreen.getSelectedBoxText;
itemType := copy(itemType, 7, length(itemType));
typeEdit := toStr(itemType[1]);
itemType := copy(itemType, 2, length(itemType));
itemType := (uppercase(typeEdit) + itemType);
itemType := trim(itemType);
profit := getProfit(itemType, 'http://runescape.wikia.com/wiki/Calculator:Herblore/Herbs');
end;
print('HerbMenu is here');
productionScreen.clickStart;
print('waiting for StatusMenu');
SRL_Events[EVENT_ANTIBAN] := nil;
if not tabBackpack.waitSlotPixelChange(3, gaussRangeInt(10000, 20000)) then
begin
SRL_Events[EVENT_ANTIBAN] := @antiban;
exit;
end;
SRL_Events[EVENT_ANTIBAN] := @antiban;
wait(gaussRangeInt(0, 1500));
timeout.start;
if not tabBackpack.waitSlotPixelChange(28, gaussRangeInt(25000, 45000)) then
exit;
print('last slot changed');
itemCount := itemCount + 28;
end;
'Pots':
begin
antiB := 3000;
mouseB := 6000;
getMousePOS(x, y);
if slot = 0 then
slot := 1;
if not pointInBox(point(x, y), tabBackpack.getSlotBox(11)) and not pointInBox(point(x, y), tabBackpack.getSlotBox(12)) then
begin
case random(10) of
0..7: slot := 11;
8..9: slot := 12;
end;
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT);
wait(gaussRangeInt(0, 100));
case random(10) of
0..7: slot := 16;
8..9: slot := 17;
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT);
wait(gaussRangeInt(0, 200));
t.start;
time := gaussRangeInt(6000, 12000);
repeat
if productionScreen.isOpen then
break;
wait(gaussRangeInt(0, 500));
if (not isLoggedIn) Or (t.getTime > time) then
exit;
until productionScreen.IsOpen;
wait(gaussRangeInt(0, 400));
if itemType = '' then
begin
itemType:= productionScreen.getSelectedBoxText;
profit := getProfit(itemType, 'http://runescape.wikia.com/wiki/Calculator:Herblore/Unfinished_potions');
end;
productionScreen.clickStart;
if not tabBackpack.waitForShift(randomRange(2000, 4000)) then
exit;
wait(gaussRangeInt(0, 1500));
timeout.start;
t.start;
time := gaussRangeInt(25000, 45000);
repeat
wait(gaussRangeInt(0, 900));
antiBan;
if (not isLoggedIn) or (t.getTime > time) then
exit;
until not (tabBackpack.IsItemInSlot(28));
itemCount := itemCount + 14;
end;
else
begin
writeln('CleanOrPots type wrong, shutting down');
terminateScript;
end;
end;
result := true;
end;
procedure setup;
begin
clearDebug;
disableSRLLog := true;
autoUpdateMe;
initPlayerForm(); // initiate your settings
runPlayerForm(); // run the form
// use this so the script doesn't continue if the user exits out of the form
if (not playerForm.isScriptReady) then
terminatescript;
declareplayers();
smartShowConsole := false;
if not debug then
disableSRLDebug := true else
disableSRLDebug := false;
smartEnableDrawing := true;
SRL_Events[EVENT_ANTIBAN] := @antiban;
setupSRL;
if not isLoggedIn then
begin
if not players[currentPlayer].login then
terminateScript;
writeln('Just loggedin, waiting a bit');
wait(randomRange(6000, 10000));
end;
clearDebug;
mainScreen.setAngle(MS_ANGLE_HIGH);
findNormalrandoms;
timeout.start;
stackCheck := 1;
bir := 13; // ***random minutes to add/subtract from how long until we break***
bfr := 7; // ***random minutes to add/subjtract from break duraction***
W := (players[currentPlayer].integers[0] * 60000);
X := (players[currentPlayer].integers[1] * 60000);
Y := randomRange(-BIR * 60000, BIR * 60000);
Z := randomRange(-BFR * 60000, BFR * 60000);
if conversationBox.continue(true, true) then
wait(randomRange(3000, 2000));
statsTimer.start();
startingXP := chatBox.getXPBar;
findNormalrandoms;
print('slots: ' + toStr(slots));
end;
procedure mainloop;
var
i: integer;
begin
if not isLoggedIn then
begin
wait(5000);
writeln('Attempting to log back in');
disableSRLDebug := false;
repeat
try
players[currentPlayer].login;
inc(i);
except
end;
if (i = 7) then
begin
i := 0;
players.next(false);
end;
until isLoggedIn;
disableSRLDebug := true;
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_EAST);
end;
if banking then
begin
findNormalrandoms;
if makeItems then
begin
progressReport;
findNormalrandoms;
end;
end;
if timeout.getTime > 200000 then
begin
writeln('Problem Occurred, Relogging');
players[currentPlayer].Logout;
end;
if timeout.getTime > 300000 then
begin
writeln('nothing has happened for too long, shutting down!- took a screenshot, send pic to ashaman (in the logs folder)');
if debug then
saveScreenshot(scriptPath + timeRunning() + '_' + 'HerbFail.png');
terminateScript;
end;
if players[currentPlayer].Booleans[0] then
breakHandler(players[currentPlayer].integers[0], players[currentPlayer].integers[1], bir, bfr);
end;
begin
setup;
while (players.getActive() > 0) do
mainloop;
end.