Code:
program MahoganyTableMaker;
{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SRL/SRL/Misc/Smartgraphics.simba}
{-------------------------------------------------------------------------------
| * * * * * * * * * * * * * * * * Credit * * * * * * * * * * * * * * * * * |
--------------------------------------------------------------------------------
| * Ashaman88 for his FindButler function. |
| * YoHoJo for his mousekey simulation technique. |
| * ProphesyOfWolf for his TPAFinder function in his awesome tutorial about |
| Custom TPA Finding & ColorToleranceSpeed(2) Modifiers. |
-------------------------------------------------------------------------------}
{==============================================================================|
| Mahogany Table Maker by Sir Eska Eau V0.4 |
|==============================================================================|
| |
| Disclaimer: This script was made in a single day and is the first script I |
| release on simba. It does not have AntiBan nor AntiRandom. |
| AntiBan kills the XP/hour and AntiRandom isn't really needed |
| since you cannot get a random while in your POH with building |
| mode ON. The fact that it does not feature Antiban means that |
| you should refrain from using this script for very long period |
| of time. Due to time constraints, not much testing was put into |
| this script. You SHOULD, and MUST babysit this script. |
| |
| YOU HAVE BEEN WARNED |
| |
| You MUST read the instructions in the thread related to this |
| script. To find the details on how to set up the script, please |
| visit : |
| http://villavu.com/forum/showthread.php?t=77529 |
| |
| |
| Mahogany |
| Table |
| Maker : This script will make mahogany plank in a dinning room pretty |
| much as fast as it can get. The script use simulated mousekeys, |
| timeOut FailSafe and recursivity. Only the demon Butler is |
| suported. |
| HAPPY BONUS XP WEEKEND! |
| |
{==============================================================================|
| CHANGE HISTORY |
|==============================================================================|
| |
| V0.1 : * Initial release |
| |
| V0.2 : * Removed DTM and replaced them with TPA. Failing to find the butler |
| should be a thing of the past. |
| |
| V.03: * Made proper ATPA, failing to find the butler should REALLY be a | |
| thing of the past now. |
| * Fixed a small graphical glitch that was causing the on screen |
| progress report to go negative once you reach 600k+ xp. | |
| * Slowed down the mouse. I think it was causing alot of problem with |
the UpText. |
| * The LAG_FACTOR is now applied anywhere there is a Wait() |
| * Removed SRL Stats since they can't work with this script anyway | |
| (XP rate is too high and SRL Stats refuse to accept the data) |
| * Adjusted some Wait() and fixed some dead code that had the task to |
| search for the butler again if it wasn't found the first time. |
| |
| V0.4 * Added a color check before attemping to build or destroy a table. |
| That should fix most of the timing problems and increase XP/hour |
| since the bot should never missclick and go through the timeout |
| failsafe of some loops. |
| * Changed and removed some wait in an attempt to fix timing issues. |
| * We only call the butler every 4 cycle instead of 3. This increase |
| the XP/hour and decrease the cost of the butler over time |
| * Added a constant WAIT_FOR_BUTLER to help user fix their timing |
| problems with the butler interupting them. |
| |
-------------------------------------------------------------------------------}
{-------------------------------------------------------------------------------
| * * * * * * * * * * * * * DO NOT CHANGE THOSE * * * * * * * * * * * * * * |
-------------------------------------------------------------------------------}
var// |
loopTimeOut: integer;// |
{------------------------------------------------------------------------------}
{-------------------------------------------------------------------------------
| * * * * * * * * * * * * * Adjust as needed * * * * * * * * * * * * * * * *|
-------------------------------------------------------------------------------}
const
// Change this if you are laging.
LAG_FACTOR = 1; // Are you lagging? 1 = no lag, 5 = WTF LAG!!!
// Increase this if the bot often missclick even
// if you don't seem to be really lagging.
// Obviously, a LAG_FACTOR of 1 will give you the
// best XP/hour if your computer can support it.
// Change this if the butler interupt you!
WAIT_FOR_BUTLER= 700; // 1000 = 1 seconds.
//
// If the butler interupt you while you are
// destroying a table, REDUCE this until the
// script is done destroying the table once the
// butler comes back. If it still dosen't work at 0,
// INCREASE this until the script attempt to
// destroy the table once the butler comes back.
//
// If the butler interupt you while you are BUILDING
// a table, INCREASE this until the script is done
// destroying the table once the butler comes back.
procedure LoadUserVars;
begin
// Smart_Server := 0; // The server you want to login into. 0 = random
end;
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := ''; // Username
Pass := ''; // Password
Nick := ''; // 3-4 lower case letters of your character's name
Pin := ''; // Bank pin
Member := True;
Active := True;
end;
end;
{*******************************************************************************
* * * * DO NOT CHANGE ANYTHING BELLOW UNLESS YOU KNOW WHAT YOU ARE DOING * * * *
*******************************************************************************}
var
timeSinceLastCommit,
oldXP, previousXP, x, y, xxx1, yyy1, xxx2, yyy2,
failToFindButlerCount, failToBuildTableCount, failToDestroyTableCount: integer;
const
SCRIPT_NAME = 'MahoganyTableMaker';
SCRIPT_VERSION = 'V0.4';
SIGNED = True;
DrawDebugs = True;
ATTEMPT_TIMEOUT = 10;
// *****
// * FindMahoganyTableBuilt : Returns true if it find the table color.
// *
function FindMahoganyTableBuilt: Boolean;
var
CTS: Integer;
begin
CTS := GetColorToleranceSpeed; // To restore the color tolerance later
SetColorspeed2Modifiers(0.1, 0.2);
Result:= FindColorTolerance(x, y, 3491678, xxx1, yyy1, xxx2, yyy2, 15)
ColorToleranceSpeed(CTS); // Restore previous color tolerance speed
end;
function FindWindow(Title: String): Boolean;
begin
result:= true;
end;
// *****
// * BuildTable : Find the table hotspot using blind check, then use mousekeys
// * to quickly build a table.
// *
procedure BuildTable;
var t: integer;
begin
if failToBuildTableCount > ATTEMPT_TIMEOUT then
begin
Writeln('Couldn''t build tables for ' + inttostr(ATTEMPT_TIMEOUT)
+ ' attempts, loging out.');
LogOut;
TerminateScript;
end;
MarkTime(t);
repeat
until not FindMahoganyTableBuilt
or (TimeFromMark(t) > loopTimeOut)
if not (TimeFromMark(t) > loopTimeOut) then
begin
MouseBox(xxx1, yyy1, xxx2, yyy2, 3);
previousXP:= GetXPBarTotal;
if IsUptext('alk here / 2 more options') and not FindMahoganyTableBuilt then
GetMousePos(x, y);
Mouse(x, y, 0, 0, False); // Right click
Wait(LAG_FACTOR * 20 + Random(20));
MoveMouse(x, y+42); // Simulate mouse key jump to the second option.
Wait(LAG_FACTOR * 50 + random(20));
ClickMouse2(true); // Left click on whatever option was there.
Wait(LAG_FACTOR * 100 + 400 + Random(50));
end;
MarkTime(t);
repeat
until FindWindow('elect a piece of furniture to build.')
or (TimeFromMark(t) > loopTimeOut)
if FindWindow('elect a piece of furniture to build.') then
begin
Wait(LAG_FACTOR * 100 + Random(20));
MouseBox(290, 128, 320, 152, 3);
Wait(LAG_FACTOR * 30 + Random(20));
MarkTime(t);
repeat
until IsUpTextMultiCustom(['ahogany', 'table'])
or (TimeFromMark(t) > loopTimeOut)
if IsUpTextMultiCustom(['ahogany', 'table']) then
begin
ClickMouse2(true);
Wait(LAG_FACTOR * 100 + 100 + Random(100));
if(previousXP < GetXPBarTotal) then
failToBuildTableCount:= 0 // Reset
end else
begin
inc(failToBuildTableCount);
end;
end else
begin
if FindNPCChatText('Yes', Nothing) then
begin
TypeSend('1');
Wait(LAG_FACTOR * 200 + Random(300));
inc(failToBuildTableCount);
end;
end;
end;
// *****
// * DestroyTable : Find the table hotspot using blind check, then use mousekeys
// * to quickly destroy the table.
// *
procedure DestroyTable;
var t: integer;
begin
if failToDestroyTableCount > ATTEMPT_TIMEOUT then
begin
Writeln('Couldn''t destroy the table for ' + inttostr(ATTEMPT_TIMEOUT)
+ ' attempts, loging out.');
LogOut;
TerminateScript;
end;
MarkTime(t);
repeat
until FindMahoganyTableBuilt
or (TimeFromMark(t) > loopTimeOut)
if not (TimeFromMark(t) > loopTimeOut) then
begin
Wait(LAG_FACTOR * 50 + Random(50));
MouseBox(xxx1, yyy1, xxx2, yyy2, 3);
if IsUptext('alk here / 2 more options')
and FindMahoganyTableBuilt then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False); // Right click
Wait(LAG_FACTOR * 20 + Random(20));
MoveMouse(x, y + 42); // Simulate mouse key jump to the option.
Wait(LAG_FACTOR * 50 + random(20));
ClickMouse2(true); // Left click on whatever option was there.
Wait(LAG_FACTOR * 100 + Random(50));
end;
MarkTime(t);
repeat
until FindNPCChatText('Yes', Nothing) or (TimeFromMark(t) > loopTimeOut)
if TimeFromMark(t) < loopTimeOut then
begin
if FindNPCChatText('Yes', Nothing) then
begin
Wait(LAG_FACTOR * 50 + Random(50));
TypeSend('1');
Wait(LAG_FACTOR * 100 + RandomRange(300, 500));//(700, 900));
failToDestroyTableCount:= 0; // We reset
end else
begin
inc(failToDestroyTableCount);
end;
end else
begin
if FindWindow('elect a piece of furniture to build.') then
begin
MouseBox(290, 128, 320, 152, 3);
Wait(LAG_FACTOR * 100 + Random(20));
MarkTime(t);
repeat
until IsUpTextMultiCustom(['ahogany', 'table'])
or (TimeFromMark(t) > loopTimeOut)
if IsUpTextMultiCustom(['ahogany', 'table']) then
begin
ClickMouse2(true);
failToBuildTableCount:= 0 // Reset
end;
end;
end;
end;
end;
// *****
// * LocateButler : Return true if it found location of the demon butler using
// * TPAs.
// *
// * Originaly named: TPAFinder
// * By: ProphesyOfWolf
// * Edited by: Sir_eska_eau
// *
function LocateButler(x, y: Integer): Boolean;
var
CTS, I, B: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed; // To restore the color tolerance later
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.52, 5.16);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2371157, MSX1, MSY1, MSX2, MSY2, 5);
ColorToleranceSpeed(CTS); // Restore previous color tolerance speed
ATPA := TPAToATPAEx(TPA, 20, 20);
B:= High(ATPA);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
Wait(LAG_FACTOR * 100);
If(IsUpTextMultiCustom(['emon', 'butler', 'utler', 'tler'])) then
begin
Result := True;
GetMousePos(x, y);
Break; // We found the object so we exit the loop
end;
end;
end;
// *****
// * FindButler : Return true if it found the demon butler. Fetch plank from the
// * bank and pays the butler if needed.
// * By: Ashaman88
// * Edited by: Sir_eska_eau
// * Description: Edited to fit my needs, comply with my standards, add timeout
// * failsafe, add recursivity, add mousekeys and add a little
// * optimisation.
// *
function FindButler: Boolean;
var
x, y, t: Integer;
foundButler: Boolean;
begin
if failToFindButlerCount > ATTEMPT_TIMEOUT then
begin
Writeln('Couldn''t find the demon butler 5 times. Loging out.');
LogOut;
TerminateScript;
end;
if not LoggedIn then
TerminateScript;
foundButler:= LocateButler(x, y);
if not foundButler then
begin
Writeln('Coudn''t find demon butler.');
MMouse(200,200,100,100);
inc(failToFindButlerCount);
Result := False;
end else
begin
GetMousePos(x, y);
if (IsUpTextMultiCustom(['emon', 'butler', 'utler', 'tler'])) then
begin
Wait(LAG_FACTOR * 100 + Random(50));
ClickMouse2(false); // Right click
Wait(LAG_FACTOR * 100 + Random(10));
MoveMouse(x, y + 42); // Simulate mouse key jump to the option.
Wait(LAG_FACTOR * 300 + Random(50));
ClickMouse2(true); // Left click on whatever option was there.
Wait(LAG_FACTOR * 100 + 200+Random(50));
end;
MarkTime(t);
repeat
until ((FindNPCChatText('coins', nothing))
or (FindNPCChatText('nother', nothing))
or (TimeFromMark(t) > loopTimeOut));
if (FindNPCChatText('coins', nothing)) then
begin
ClickContinue(true, true);
Wait(LAG_FACTOR * 50 + Random(50));
TypeSend('1');
Wait(LAG_FACTOR * 100 + RandomRange(700, 900));
MMouse(x, y, 2, 2);
Wait(LAG_FACTOR * 50 + Random(50));
MarkTime(t);
repeat
MMouse(x, y, 5, 5);
Wait(LAG_FACTOR * 100);
until (IsUpTextMultiCustom(['emon', 'butler', 'utler', 'tler']))
or (TimeFromMark(t) > loopTimeOut);
if (IsUpTextMultiCustom(['emon', 'butler', 'utler', 'tler'])) then
begin
Wait(LAG_FACTOR * 50 + Random(50));
ClickMouse2(false); // Right click
Wait(LAG_FACTOR * 100 + Random(50));
MoveMouse(x, y + 42); // Simulate mouse key jump to the option.
Wait(LAG_FACTOR * 100 + Random(50));
ClickMouse2(true); // Left click on whatever option was there.
end;
end;
MarkTime(t);
repeat
until (FindNPCChatText('nother', nothing))
or (TimeFromMark(t) > loopTimeOut);
if (FindNPCChatText('nother', nothing)) then
begin
TypeSend('1');
Wait(WAIT_FOR_BUTLER + Random(100));
failToFindButlerCount:= 0; // reset because the butler is on the way.
Result := true;
end;
if not foundButler or (TimeFromMark(t) > (loopTimeOut + 2000)) then
begin
Result:= false;
inc(failToFindButlerCount);
FindButler; // Recursivity
end;
end;
end;
// *****
// * DisplayOnScreenProgressReport : Display some interesting information
// * directly on the runescape client.
// *
procedure DisplayOnScreenProgressReport;
var
infoTimeRunning, infoTotalXp, infoXpHour: String;
background, currentXP: integer;
begin
currentXP:= GetXPBarTotal;
infoTimeRunning:= 'Running for ' + TimeRunning;
infoTotalXp:= 'Total xp gained ' + inttoStr(currentXP - oldXP) + 'xp';
infoXpHour:= 'Currently gaining ' + inttoStr(Round(((currentXP - oldXP)
/ (GetTimeRunning / 1000)) * 3600))
+ 'xp per hour';
background:= BitmapFromString(24, 21, 'meJxjYBgFo2AUjIJRMJwBAAXoAAE=');
SMART_DrawBitmap(true, background,Point(5,290));
FreeBitmap(background);
SMART_DrawText(8,270,SmallChars,infoTimeRunning,clAqua);
SMART_DrawText(8,290,SmallChars,infoTotalXp,clAqua);
SMART_DrawText(8,310,SmallCharsNS,infoXpHour,clAqua);
end;
procedure MainLoop;
var i: integer;
begin
repeat
inc(i);
previousXP:= GetXpBarTotal;
BuildTable;
Wait((LAG_FACTOR * 100) + 900 + Random(300));
if FindBlackChatMessage('ou don') then
FindButler;
if (GetXPBarTotal = previousXP) then
begin
inc(failToBuildTableCount);
end else
begin
failToBuildTableCount:= 0;
end;
DisplayOnScreenProgressReport;
DestroyTable;
Wait((LAG_FACTOR * 100) + Random(200));
if(i = 6) then
FindButler;
until (i = 7);
end;
// *****
// * SetUpScript : Define some mandatory variables for the script
// *
procedure SetUpScript;
begin
ClearReport;
ClearDebug;
SetupSRL;
ActivateClient;
DeclarePlayers;
LoadUserVars; // Load user defined bariables
MouseSpeed:= 12 + Random(3);
SetupRandomTool(10000 + Random(10000), 2, 'C:/Simba/alarm.wav');
if not (LoggedIn) then
LoginPlayer;
wait(LAG_FACTOR * 100 + 400 + random(400));
ToggleXPBar(True);
wait(LAG_FACTOR * 100 + 400 + random(400));
If IsXPBarOpen Then OldXP := GetXPBarTotal;
failToFindButlerCount:= 0;
failToBuildTableCount:= 0;
failToDestroyTableCount:= 0;
MarkTime(timeSinceLastCommit);
loopTimeOut:= ((((LAG_FACTOR * LAG_FACTOR) * 4) // *FailSafe* To break out of
/ (1 + LAG_FACTOR)) * 1000); // loops when something
// goes wrong.
xxx1:= MSCX-15; // To find the table.
xxx2:= MSCX+15; // To find the table.
yyy1:= MSCY+20; // To find the table.
yyy2:= MSCY+60; // To find the table.
if (LAG_FACTOR < 1) then
begin
WriteLn('LAG_FACTOR cannot be lower than 1, go change it.');
TerminateScript;
end;
Wait(LAG_FACTOR * 100 + 400 + Random(1000));
end;
// *****
// * Main program
// *
begin
SetUpScript;
If IsXPBarOpen Then OldXP := GetXPBarTotal;
repeat
MainLoop;
until(not LoggedIn);
end.