SRL Archive - Research & Development Lounge

Ellis Gold Digger [Al Kharid Tanning - First Script]


rickhunley

2015-05-19 18:14:01

Hi Everyone,

Thought I'd post my developments here. First time scripting. I'm epic noob, and will no doubt need epic help.

I'm mostly using @Twinki script, trying to modify it so it works with Ellis.

This will be for Runescape 3.

Proggy Update


Here is script so far:

Update: Ellis now works after renaming haha.

Update: Banker selection rate seems to have improved, focused colour on green pants. Changed exclude distance to 100. Banker bug below still exists

New bugs:

SUPER BUG 1.1 - Banker identification isn't too bad, but sometimes finds banker and then misclicks open bank, even though they are right in front of the character. Has a high tendency to choose the banker on the far left which screws the pathway. Is bank selection random or is there something in the code that's making it pick the one on the left? If it chooses the banker from the far left, or second to left, it then sets the pathway to the left of Al Kharid, instead of going North to the tanner. Advice please?

SUPER BUG 1.2 - Pathfinding is not consistent. When you run to Ellis, sometimes the pathfind clicks to the far left of the bank, as if you're going to Lumbridge, when the tanner is dead north.

BUG 1.3 - When reaches Ellis, Ellis can sometimes be under the door way and not detect his head (only colour that was safe). Possible to rotate camera angle to east or west which will detect him?

BUG 1.4 - By the time Ellis has been detected, and the mouse goes to that hotspot, and then tries to right click, Ellis has moved. How to fix?

Improvements: Identifies Ellis colour, but mouse movement to reach that colour, and by the time Ellis moves is slow, and misses the right click action a lot of the time. How do I improve mouse speed?

Improvements: Instead of script terminating, extend time to find Ellis, and repeat loops again.

Please help with bugs and improvements Going to test it again…

Feels like it's almost done. Been going all day!

Thanks for help


program RickHunley;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}
{------------------------------------------------------------------------------)
Thanks to all those people who motivated me to write my first script.

Twinki, this is his original script modified for Al Kharid
furrykittens, for the motivation.

Thank you guys in the IRC for pointing out some mistakes and improvements that could be made
(------------------------------------------------------------------------------}
{--- Constants that can easily be updated * No touchy, unless you know what you're doing--}
Const
{--- Banker / Bank Booth---}
B_HUE := 0.23;
B_SAT := 0.35;
B_COLOR := 5142827;
B_TOL := 8;
B_FILTER := 15; //ATPA Filter
{--- Relative Object for Banker ---}
rB_HUE := 0.23;
rB_SAT := 0.35;
rB_COLOR := 5142827;
rB_TOL := 8;
rB_EXCLUDE := 100; //Exclude Distance
{--- Ellis the Tanner ---}
E_HUE := 0.62;
E_SAT := 0.70;
E_COLOR := 3291714;
E_TOL := 5;
E_FILTER := 3; //ATPA Filter
{--- Relative Object for Ellis ---}
rE_HUE := 0.62;
rE_SAT := 5.98;
rE_COLOR := 3291714;
rE_TOL := 3;
rE_EXCLUDE := 150; //Exclude Distance

Var
HardLeatherDTM, GreenLeatherDTM, BlueLeatherDTM, RedLeatherDTM,
BlackLeatherDTM, RoyalLeatherDTM, TotalTannedLeather, scriptPaintBMP: Integer;
BotStatus: String;
scriptSMARTDebug: boolean;

procedure initPlayerForm();
begin
with playerForm do
begin
name := 'RickHunley';
scriptHelpThread := '';
editBoxLabels := ['Amount to Tan: ', 'Bank Preset'];
editBoxDefaults := ['100000', '1'];
editBoxHints := ['Amount of Hide to Tan', 'Bank Preset to use (1 or 2)'];

checkBoxLabels := ['Draw on SMART', 'RickHunley SMART Debug'];
checkBoxDefaults := ['True', 'False'];
checkBoxHints := ['Do you want do draw some debug information on SMART?', 'Turns on RickHunley SMART Debug'];
end;
end;

procedure declarePlayers();
var
i: Integer;
begin
players.setup(playerForm.playerNames, playerForm.playerFile);
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]);

smartEnableDrawing := strToBool(playerForm.players[i].settings[2]);
scriptSMARTDebug := strToBool(playerForm.players[i].settings[3]);
end;
end;
{------------------------------------------------------------------------------)
Function: CheckIfFrozen
Description: Checks if the screen is frozen/is in a loading screen by using PixelShift
Credits: Twinki
(------------------------------------------------------------------------------}
function CheckIfFrozen(MarkerWaitTime: Integer = 5000): boolean;
Var
pS, i: Integer;
FrozenTimer: TTimeMarker;
begin
FrozenTimer.start();
result := true;
repeat
pS := getPixelShift(mainscreen.getBounds(), 500);
if scriptSMARTDebug then
WriteLn('Current PixelShift: '+toStr(pS));
if Ps <= 100 then
begin
repeat
Wait(randomRange(250, 750));
pS := getPixelShift(mainscreen.getBounds(), 500);
until (Ps >= 500) or (FrozenTimer.getTime() >= 10000);
end;
if not (minimap.isPlayerMoving()) and (Ps >= 500) then
break();
until FrozenTimer.getTime() >= MarkerWaitTime;
end;
{------------------------------------------------------------------------------)
Function: FindTheTwinki
Description: Custom FindObject. Anyone is welcome to use this, I just ask you provide credits where it's due!
Credits: Twinki (Thank you TheMayor, hoodz, Ross, and BMWxi for the help!)
(------------------------------------------------------------------------------}
function FindTheTwinki(Hue, Sat: extended; Color, Tolerance, Filter, clickType: Integer; mouseOverText, chooseOptions: array of string;
FindRelativeObject: boolean = false; rHue, rSat: extended = 0; rColor, rTolerance: Integer = 0; excludePointsDist: Integer = 150; Cluster: boolean = false; ClusterDist: Integer = 50): boolean;
Var
X, Y, i: integer;
rTPA, TPA: TPointArray;
ATPA: T2DPointArray;
rPoint: TPoint;

begin
if not isLoggedIn() then
exit;
CheckIfFrozen(randomRange(2500, 3500));
if FindRelativeObject then
begin
findColorsSpiralTolerance(X, Y, rTPA, rColor, mainScreen.getBounds(), rTolerance, colorSetting(2, rHue, rSat));
if length(rTPA) < 1 then
exit(false);
if scriptSMARTDebug then
smartImage.debugTPA(rTPA, false);
rPoint := middleTPA(rTPA);
end;

findColorsSpiralTolerance(X, Y, TPA, Color, mainScreen.getBounds(), Tolerance, colorSetting(2, Hue, Sat)); //NOTE: Core of this function
if length(TPA) < 1 then
exit(false);

if FindRelativeObject then
TPA.excludePointsDist(0, excludePointsDist, rPoint.x, rPoint.y);
if Cluster then
ATPA := ClusterTPA(TPA, ClusterDist)
else
ATPA := TPA.toATPA(30, 30);

ATPA.filterBetween(1, Filter);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
if scriptSMARTDebug then
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
if scriptSMARTDebug then
smartImage.drawText('ATPA Length: '+IntToStr(length(ATPA[i])), point(ATPA[i][0].x+10, ATPA[i][0].y+10), clLime);
if (length(ATPA[i]) <= 10) then
Continue; //NOTE: *Will go to the next index if the current TPA length (in the ATPA) is less than 10

pickUpMouse();
case random(50) of
1..30: Mouse(ATPA[i].getBounds().getRandomPoint(), MOUSE_MOVE);
31..50: missMouse(ATPA[i].getBounds().getRandomPoint(), true);
end;
if isMouseOverText(mouseOverText, 150) then
begin
fastClick(clickType);
Wait(randomRange(250, 750));
if (clickType = MOUSE_RIGHT) and (chooseOption.optionsExist(chooseOptions)) then
if not chooseOption.select(chooseOptions, 1000) then
Continue;
exit(true);
end
else
Continue;
end;
if scriptSMARTDebug then
smartImage.clear();
end;
{------------------------------------------------------------------------------)
Procedure: Proggy
Description: Draws a progress report on SMART
Credits: Clarity, for the right coordinates :D
(------------------------------------------------------------------------------}
procedure Proggy;
begin
if not smartEnableDrawing then
begin
WriteLn('***************TwinkiTanner***************');
WriteLn('* Time Running: '+ToStr(TimeRunning));
WriteLn('* Leathers Tanned: '+ToStr(TotalTannedLeather));
WriteLn('* STATUS: ',+BotStatus);
WriteLn('******************************************');
end
else
begin
smartImage.clear;
smartImage.drawBitmap(scriptPaintBMP, point(actionbar.x1 + 390, actionbar.y1 - 185));
smartImage.drawText('TwinkiTanner', point(mainscreen.x1 + 5, mainscreen.y1 + 5), 'LoginChars', true, clWhite);
smartImage.drawText('Time Running:', point(mainscreen.x1 + 15, mainscreen.y1 + 25), 'SmallChars', true, clYellow);
smartImage.drawText(toStr(TimeRunning), point(mainscreen.x1 + 96, mainscreen.y1 + 25), 'SmallChars', true, clWhite);
smartImage.drawText('Tanned:', point(mainscreen.x1 + 15, mainscreen.y1 + 50), 'SmallChars', true, clYellow);
smartImage.drawText(toStr(TotalTannedLeather) + ' hides', point(mainscreen.x1 + 61, mainscreen.y1 + 50), 'SmallChars', true, clWhite);
smartImage.drawText('STATUS: ', point(actionbar.x1 + 5, actionbar.y1 - 20), 'Loginchars', true, clWhite);
smartImage.drawText(BotStatus, point(actionbar.x1 + 68, actionbar.y1 - 20), 'Loginchars', true, clYellow);
end;
end;
{------------------------------------------------------------------------------)
Procedure: RunToEllis
Description: Runs to Ellis the Tanner
(------------------------------------------------------------------------------}
procedure RunToEllis;
Var
PathToEllis: TPointArray;
begin
if not isLoggedIn() then
exit;
BotStatus := 'Running to Ellis the Tanner';
Proggy;
PathToEllis := [Point(66, 212), Point(74, 187), Point(79, 150), Point(66, 112)] //Thanks giavanni6 for suggestion
if not SPS.walkPath(PathToEllis) then
begin
ClearDebug();
BotStatus := 'ERROR: Hmph, we failed running to Ellis.. our legs must be broken';
Proggy;
WriteLn('ERROR: Hmph, we failed running to Ellis.. our legs must be broken'); //PrintError(1);
TerminateScript();
end;
end;
{------------------------------------------------------------------------------)
Procedure: RunToBank
Description: Runs to Al Kharid Bank
(------------------------------------------------------------------------------}
procedure RunToBank;
Var
PathToBank: TPointArray;
begin
if not isLoggedIn() then
exit;
BotStatus := 'Running to the Al Kharid Banker';
Proggy;
PathToBank := [Point(86, 138), Point(76, 176), Point(51, 213)]
if not SPS.walkPath(PathToBank) then
begin
ClearDebug();
BotStatus := 'ERROR: Hmph, we failed running to the bank.. our legs must be broken';
Proggy;
WriteLn('ERROR: Hmph, we failed running to the bank.. our legs must be broken');
TerminateScript();
end;
end;
{------------------------------------------------------------------------------)
Function: FindBanker
Description: Finds the Al Kharid Banker in Al Kharid, returns True if found, uses FindTheTwinki
(------------------------------------------------------------------------------}
function FindBanker(): boolean;
Var
BankSymbol: TPoint;
alkharidBankerTimer: TTimeMarker;
begin
if not isLoggedIn() then
exit();
if bankScreen.isOpen() then
exit(true);
BotStatus := 'Trying to find the Al Kharid Banker';
Proggy;
alkharidBankerTimer.start();

repeat
if FindTheTwinki(B_HUE, B_SAT, B_COLOR, B_TOL, B_FILTER, random(2), ['anker','ank','ooth'], ['ank', 'ooth'], true, rB_HUE, rB_SAT, rB_COLOR, rB_TOL, rB_EXCLUDE, true, 40) then
begin
BotStatus := 'Found Banker';
Proggy;
exit(true);
end
else if (minimap.findSymbol(BankSymbol, MM_SYMBOL_BANK, minimap.getBounds())) and (alkharidBankerTimer.getTime() >= 10000) then
begin
BotStatus := 'Couldn''t find banker, clicking BankSymbol and trying again';
Proggy;
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
Mouse(point(BankSymbol.x + gaussRangeInt( - 5, 5), BankSymbol.y + gaussRangeInt( - 5, 5)), MOUSE_LEFT, MOUSE_HUMAN);
Wait(randomRange(250, 750));
if FindTheTwinki(B_HUE, B_SAT, B_COLOR, B_TOL, B_FILTER, random(2), ['anker','ank','ooth'], ['ank', 'ooth'], true, rB_HUE, rB_SAT, rB_COLOR, rB_TOL, rB_EXCLUDE, true, 40) then
begin
BotStatus := 'Found Banker';
Proggy;
exit(true);
end;
end;
until alkharidBankerTimer.getTime() >= 30000;

ClearDebug();
BotStatus := 'ERROR: Could not find the Al Kharid Banker';
Proggy;
WriteLn('ERROR: Could not find the Al Kharid Banker');
TerminateScript();
end;

{------------------------------------------------------------------------------)
Procedure: FindEllis
Description: Finds Ellis the Tanner using FindTheTwinki
(------------------------------------------------------------------------------}
function FindEllis(): boolean;
Var
TannerSymbol: TPoint;
ellisOvalTimer: TTimeMarker;
begin
if not isLoggedIn() then
exit();
if productionScreen.isOpen() then
productionscreen.close();

BotStatus := 'Trying to find Ellis the Tanner';
Proggy;
ellisOvalTimer.start();
repeat
if FindTheTwinki(E_HUE, E_SAT, E_COLOR, E_TOL, E_FILTER, MOUSE_RIGHT, ['Ellis','llis'], ['an', 'ide'], true, rE_HUE, rE_SAT, rE_COLOR, rE_TOL, rE_EXCLUDE, true, 30) then
begin
BotStatus := 'Found Ellis';
Proggy;
exit(true);
end
else if (minimap.findSymbol(TannerSymbol, MM_SYMBOL_TANNER, minimap.getBounds())) and (ellisOvalTimer.getTime() >= 10000) then
begin
BotStatus := 'Couldn''t find Ellis, clicking Tanner Symbol and trying again';
Proggy;
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
Mouse(point(TannerSymbol.x + gaussRangeInt( - 5, 5), TannerSymbol.y + gaussRangeInt( - 5, 5)), MOUSE_LEFT, MOUSE_HUMAN);
Wait(randomRange(250, 750));
if FindTheTwinki(E_HUE, E_SAT, E_COLOR, E_TOL, E_FILTER, MOUSE_RIGHT, ['Ellis','llis'], ['an', 'ide'], true, rE_HUE, rE_SAT, rE_COLOR, rE_TOL, rE_EXCLUDE, true, 30) then
mouseBox(mainScreen.playerBox);
if (isMouseOverText(['Ellis','llis'])) then
begin
fastClick(MOUSE_RIGHT);
Wait(randomRange(250, 750));
chooseOption.select(['an', 'ide'], 1000);
BotStatus := 'Found Ellis';
Proggy;
exit(true);
end;
end;
until ellisOvalTimer.getTime() >= 30000;

ClearDebug();
BotStatus := 'ERROR: Could not find Ellis';
Proggy;
WriteLn('ERROR: Could not find Ellis');
TerminateScript();
end;


{------------------------------------------------------------------------------)
Procedure: BankHides
Description: Uses Bank Presets to quickly deposit and take out Hides
(------------------------------------------------------------------------------}
procedure BankHides;
Var
i, attempts: Integer;
bankScreenTimer: TTimeMarker;
begin
if not bankScreen.isOpen() then
if FindBanker then
begin
bankScreenTimer.start();
repeat
begin
Wait(randomRange(100, 250));
BotStatus := 'Waiting for Bank Screen to open';
Proggy;
if bankScreenTimer.getTime() > 20000 then
begin
ClearDebug();
BotStatus := 'ERROR: We ran out of time waiting for the Bank Screen to open';
Proggy;
WriteLn('ERROR: We ran out of time waiting for the Bank Screen to open');
TerminateScript();
end;
end;
until bankScreen.isOpen();

if bankScreen.isOpen() then
begin
bankScreenTimer.reset();
BotStatus := 'Bank Screen is open, taking out hides';
Proggy;
if players[i].integers[1] = 1 then
begin
case random(1, 2) of
1: bankScreen.clickButton(BANK_BUTTON_PRESET_1, true);
2: bankScreen.clickButton(BANK_BUTTON_PRESET_1, false);
end;
end
else
if players[i].integers[1] = 2 then
begin
case random(1, 2) of
1: bankScreen.clickButton(BANK_BUTTON_PRESET_2, true);
2: bankScreen.clickButton(BANK_BUTTON_PRESET_2, false);
end;
end
else
begin
ClearDebug();
BotStatus := 'ERROR: Something went wrong in the Bank Button Presets';
Proggy;
WriteLn('ERROR: Something went wrong in the Bank Button Presets');
TerminateScript();
end;
Wait(randomRange(1500, 2500));
if not tabbackpack.isItemInSlot(1) then
begin
ClearDebug();
BotStatus := 'ERROR: We''re either out of Leather or you didn''t setup your Bank Preset correctly';
Proggy;
WriteLn('ERROR: We''re either out of Leather or you didn''t setup your Bank Preset correctly');
TerminateScript();
end;
end
else
begin
ClearDebug();
BotStatus := 'ERROR: Could not Bank Hides';
Proggy;
WriteLn('ERROR: Could not Bank Hides');
TerminateScript();
end;
end;
end;

{------------------------------------------------------------------------------)
Procedure: DepositLast
Description: Depososits the last Tanned Leather then logs out
(------------------------------------------------------------------------------}
procedure DepositLast;
Var
i: Integer;
bankScreenTimer: TTimeMarker;
begin
if not bankScreen.isOpen() then
if FindBanker then
begin
bankScreenTimer.start();
repeat
begin
Wait(randomRange(100, 250));
BotStatus := 'Waiting for Bank Screen to open';
Proggy;
if bankScreenTimer.getTime() > 20000 then
begin
ClearDebug();
BotStatus := 'ERROR: We ran out of time waiting for the Bank Screen to open';
Proggy;
WriteLn('ERROR: We ran out of time waiting for the Bank Screen to open');
TerminateScript();
end;
end;
until bankScreen.isOpen();

if bankScreen.isOpen() then
begin
bankScreenTimer.reset();
BotStatus := 'Bank Screen is open, depositing and logging out';
Proggy;
Wait(randomRange(500, 750));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
bankScreen.close();
players[currentPlayer].logout();
smartImage.clear();
smartEnableDrawing := false;
Proggy;
TerminateScript();
end;
end;
end;

{------------------------------------------------------------------------------)
Procedure: CountTannedLeather
Description: Counts Tanned Leather using DTM's
(------------------------------------------------------------------------------}
function CountTannedLeather(): boolean;
Var
i: Integer;
DTMArray: TIntegerArray;
begin
DTMArray := [HardLeatherDTM, GreenLeatherDTM, BlueLeatherDTM, RedLeatherDTM, BlackLeatherDTM, RoyalLeatherDTM];

for i := 0 to high(DTMArray) do
begin
if tabBackpack.countDTM(DTMArray[i]) > 1 then
begin
if scriptSMARTDebug then
smartImage.debugDTM(DTMArray[i], tabBackpack.getBounds, clLime);
if tabBackpack.countDTM(DTMArray[i]) < 28 then
begin
BotStatus := 'Found less than 28 Tanned Leather, depositing and logging out';
Proggy;
TotalTannedLeather := TotalTannedLeather + tabBackpack.countDTM(DTMArray[i]);
DepositLast;
end;
TotalTannedLeather := TotalTannedLeather + tabBackpack.countDTM(DTMArray[i]);
result := true
end;
end;
end;

{------------------------------------------------------------------------------)
Procedure: TanHides
Description: Tans Hides at Ellis
(------------------------------------------------------------------------------}
procedure TanHides;
Var
i: Integer;
productionScreenTimer: TTimeMarker;
CraftSymbol: TPoint;
begin
if not productionScreen.isOpen() then
if FindEllis then
begin
productionScreenTimer.start();
repeat
begin
Wait(randomRange(100, 250));
BotStatus := 'Waiting for Production Screen to show up';
Proggy;
if productionScreenTimer.getTime() > 25000 then
begin
ClearDebug();
BotStatus := 'ERROR: We ran out of time waiting for the Production Screen to open';
Proggy;
WriteLn('ERROR: We ran out of time waiting for the Production Screen to open');
TerminateScript();
end;
end;
until productionScreen.isOpen();

if productionScreen.isOpen then
begin
productionScreenTimer.reset();
BotStatus := 'Production Screen is Open, tanning hides';
Proggy;
case random(1, 2) of
1: productionScreen.clickStart(true);
2: productionScreen.clickStart(false);
end;
Wait(randomRange(500, 750));
end
else
begin
ClearDebug();
BotStatus := 'ERROR: Production Screen at Ellis failure';
Proggy;
WriteLn('ERROR: Production Screen at Ellis failure');
TerminateScript();
end;
end;
end;

{------------------------------------------------------------------------------)
Procedure: checkForImages
Description: Downloads the SPS map and/or paint picture if you don't have them.
Credits: Kevin
(------------------------------------------------------------------------------}
procedure checkForImages(path, link, item: string);
var
progFile: longInt;
picName: string;

begin
picName := AppPath + path;

try
if not fileExists(picName) then
begin
writeLn('NOTIFICATION: ' + item + ' does not exist - Downloading it now!.');
progFile := createFile(picName);
end else
exit;

closeFile(progFile);

progFile := rewriteFile(picName, false);
writeFileString(progFile, getPage(link));
writeLn('NOTIFICATION: ' + item + ' has been download to Simba folder!');
writeLn('');
finally
if (progFile > 0) then
closeFile(progFile);
end;
end;

{------------------------------------------------------------------------------)
Procedure: MainLoop
Description: The main loop of this script, don't touch it!
(------------------------------------------------------------------------------}
procedure MainLoop;
Var
i: Integer;
begin
BotStatus := 'Booting up';
repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
Wait(randomRange(2000, 3000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
exitTreasure();
closePollWindow();
end;

Proggy;
BankHides;
RunToEllis;
TanHides;
RunToBank;
if not CountTannedLeather then
begin
WriteLn('ERROR: Couldn''t count Tanned Leather');
TerminateScript();
end;

until (TotalTannedLeather >= players[i].integers[0]);
DepositLast;
end;

procedure LoadDTMs;
begin
HardLeatherDTM := DTMFromString('mlwAAAHicY2dgYOABYk4gFgVicSBmZYAAGSDmg7IZgVgKKs8LxToaskCSCYoZkdhMDFwMuAEjHgwFAIsvAVE=');
GreenLeatherDTM := DTMFromString('mrAAAAHic42BgYBAAYhEgZgViWQYIYANiKSDmBWJuIJYBYhYgZoeKSQKxGFQthxUXkGTCghnBtCQDfsBIAMMAAKrkAWQ=');
BlueLeatherDTM := DTMFromString('mlwAAAHicY2dgYOAEYiEGCBAAYiYgZgdiCSAWBGJmIGYDYhkgloSq4wVibl4fqGpMDFOHDTDiwVAAAIALAUA=');
RedLeatherDTM := DTMFromString('mlwAAAHicY2dgYOABYjEglmKAAFYglgFiPiDmh4qDxHiBWAKIhaDqbHk5gSQTGmYE05IMuAEjHgwFAI95AVY=');
BlackLeatherDTM := DTMFromString('mrAAAAHic42BgYOAFYiYgFgdiUQYIkAFiYSDmAWIuIGYHYkYglgBiIagYCEgCsbysLNQEZMwIZ7Mz4AeMBDAMAACkAwFT');
RoyalLeatherDTM := DTMFromString('mlwAAAHicY2dgYOBngAAZIBYHYk4gZgViQSDmBWI+IOYBYgkglgRiZqh6R5koIMmEFUsy4AaMeDAUAACpPQGn');
end;

procedure FreeTheDTMs;
begin
FreeDTM(HardLeatherDTM);
FreeDTM(GreenLeatherDTM);
FreeDTM(BlueLeatherDTM);
FreeDTM(RedLeatherDTM);
FreeDTM(BlackLeatherDTM);
FreeDTM(RoyalLeatherDTM);
FreeBitmap(scriptPaintBMP);
end;

begin
//Setup
ClearDebug();
initPlayerForm();
runPlayerForm();
if not playerForm.isScriptReady then
exit;
declarePlayers();
smartShowConsole := false;
DisableSRLDebug := true;
SetupSRL();
AddOnTerminate('FreeTheDTMs');
LoadDTMs;
CheckForImages('Includes/SPS/img/runescape_other/ALKHARID_TAN.png', 'http://i.imgur.com/m3Xx1nU.png', 'SPS map');
SPS.setup('ALKHARID_TAN', RUNESCAPE_OTHER, 4, 600.0, 0.40);
//Script Paint
if smartEnableDrawing then
begin
CheckForImages('\Scripts\RickHunley\scriptpaint.png', 'http://i.imgur.com/AtFd4qK.png', 'Script Paint');
scriptPaintBMP := loadBitmap(appPath + '\Scripts\RickHunley\scriptpaint.png');
FastReplaceColor(scriptPaintBmp, 0, 1);
FastReplaceColor(scriptPaintBmp, 2188575, 65280);
FastReplaceColor(scriptPaintBmp, 2066708, 65280);
FastReplaceColor(scriptPaintBmp, 327168, 65280);
FastReplaceColor(scriptPaintBmp, 130816, 65280);
SetTransparentcolor(scriptPaintBMP, 65280);
end;

while players.getActive > 0 do
mainLoop;
end.

Citrus

2015-05-19 18:37:49

putting simba tags around your code makes it a lot easier to read


program RickHunley;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}
{------------------------------------------------------------------------------)
Thanks to all those people who motivated me to write my first script.

furrykittens, for the motivation.
code, for his sense of humour
Ben, for being God of Simba
My parents, for their sexy time resulting in my life

Thank you guys in the IRC for pointing out some mistakes and improvements that could be made.
(------------------------------------------------------------------------------}
{--- Constants that can easily be updated * No touchy, unless you know what you're doing--}
Const //[all of the below are wrong and I need to find out how to update it...:P]
{--- Banker / Bank Booth---}
B_HUE := 0.65;
B_SAT := 0.89;
B_COLOR := 13624282;
B_TOL := 15;
B_FILTER := 15; //ATPA Filter
{--- Relative Object for Banker ---}
rB_HUE := 0.10;
rB_SAT := 0.36;
rB_COLOR := 5528700;
rB_TOL := 9;
rB_EXCLUDE := 150; //Exclude Distance
{--- Ellis the Tanner ---}
J_HUE := 0.12;
J_SAT := 0.70;
J_COLOR := 2908960;
J_TOL := 10;
J_FILTER := 10; //ATPA Filter
{--- Relative Object for Jack ---}
rJ_HUE := 1.12;
rJ_SAT := 8.11;
rJ_COLOR := 15397620;
rJ_TOL := 2;
rJ_EXCLUDE := 150; //Exclude Distance

KeepBotting

2015-05-19 18:41:29

Your constants are 10/10, huge props there. That's something that a lot of people don't do for their first scripts, and it'll make swapping out color values a ton easier.

Although … I don't see any actual code yet? All you have in the OP are the constants. Post some more code and we can provide more feedback.

If you need help with anything specific, don't hesitate to PM or quote me.

StickToTheScript

2015-05-19 18:42:09

Great to see your interest in scripting!

If you ever get stuck, remember that there is always the RS3 Help Section. If you need tutorials, there is a really good one located here.

Good luck and have fun!

rickhunley

2015-05-19 18:42:58

Could someone please explain the _Exclude and _Filter variables, and how do I define them?

Thanks

rickhunley

2015-05-19 18:44:19

From: StickToTheScript
Great to see your interest in scripting!

If you ever get stuck, remember that there is always the RS3 Help Section. If you need tutorials, there is a really good one located here.

Good luck and have fun!


Thanks :)

rickhunley

2015-05-19 18:47:19

In the original there is a constant for the tanner Jack and also for his object, I'm just wondering what the difference is?

{— Ellis the Tanner —}
J_HUE := 0.12;
J_SAT := 0.70;
J_COLOR := 2908960;
J_TOL := 10;
J_FILTER := 10; //ATPA Filter
{— Relative Object for Ellis —}
rJ_HUE := 1.12;
rJ_SAT := 8.11;
rJ_COLOR := 15397620;
rJ_TOL := 2;
rJ_EXCLUDE := 150; //Exclude Distance

And are rJ specific Simba variables, or can I change it to rE with the E obviously representing Ellis

Turpinator

2015-05-19 22:26:54

From: KeepBotting
Your constants are 10/10, huge props there. That's something that a lot of people don't do for their first scripts, and it'll make swapping out color values a ton easier.


**Twinki's constants.

yourule97

2015-05-19 22:27:50

The "findTheTwinki" method uses relative objects to find NPCs. Say that the NPC's clothes are a shade a brown that is barely distinguishable from the NPC's environment. By using a relative color which can be easily found, finding the NPC will be much easier. Here's an explanation of it in much better detail: https://villavu.com/forum/showthread.php?t=110546

Also, for you SPS pathing problem, I see that your SPS image has very little detail. In an uniform area such as Al-Kharid, SPS has trouble determining where one is on the map. You can either:

1. Make sure your symbols for the minimap are turned on. This allows for better position recognition
2. Click on the map using symbols and such.

I personally prefer using the latter option now because I feel that its a bit faster and it seems to have less problems than with SPS maps.

rickhunley

2015-05-19 22:40:23

New bug: Sometimes detects Ellis's white apron, but won't click it…help please. The red dot goes to the white apron but never clicks it. Ellis is moving all the time :S

New bug: If first or second banker is clicked from the far left, it screws up the pathfinding (sends character to the left). Would appreciate advice.

yourule97

2015-05-19 22:52:29


ellisOvalTimer.start();
repeat
if FindTheTwinki(E_HUE, E_SAT, E_COLOR, E_TOL, E_FILTER, MOUSE_RIGHT, ['ack','val'], ['an', 'ide'], true, rE_HUE, rE_SAT, rE_COLOR, rE_TOL, rE_EXCLUDE, true, 30) then
begin


You forgot to change ['ack','val'] to ['Ellis', 'llis']

Twinki

2015-05-19 23:08:55

Errr… this looks an awful lot like my Tanner…

Well, not going to tell you not to do that, I'm all for it if you're using it as a learning experience.

If you plan on releasing this publicly as a full script, I just ask you provide credits where it's due.

EDIT: Finally got around to reading OP, again perfectly fine with it, just provide credits where it's due :)

rickhunley

2015-05-19 23:28:48

Thanks :)

Sorry Twinki :)

Thanks!

Need help if you don't mind?

Update: Ellis now works after renaming haha.

New bugs: Takes a long time to identify banker, even though they are right in front of the character. If it chooses the banker from the far left, or second to left, it then sets the pathway to the left of Al Kharid, instead of going North to the tanner. Advice please?

Feels like it's almost done. Been going all day!

rickhunley

2015-05-19 23:54:41

Proggy Update


Here is script so far:

Update: Ellis now works after renaming haha.

Update: Banker selection rate seems to have improved, focused colour on green pants. Changed exclude distance to 100. Banker bug below still exists

New bugs: Takes a long time to identify banker, even though they are right in front of the character. If it chooses the banker from the far left, or second to left, it then sets the pathway to the left of Al Kharid, instead of going North to the tanner. Advice please?

Improvements: Identifies Ellis colour, but mouse movement to reach that colour, and by the time Ellis moves is slow, and misses the right click action a lot of the time. How do I improve mouse speed?

Improvements: Instead of script terminating, extend time to find Ellis, and repeat loops again.

Please help with bugs and improvements :( :( Going to test it again…:(

rickhunley

2015-05-20 16:53:50

Has anyone been able to look at the script code for me re: the bugs? ;)

Thanks - I appreciate the input, this is a nice community :)

rickhunley

2015-05-20 17:11:24

@TheMayor - could you possible help with my pathfinding and banking issues? Thanks :)

yourule97

2015-05-20 19:05:13

Wow, I did not realize how many bots do this method. Like 6 overall level 35's running in my home world.

Anyways, let me help you a bit with your pathfinding. Here is my preferred method of walking.



procedure walkToEllis();
var
p: TPoint;
begin
p := minimap.getBounds().getMiddle(); //Rough estimate of where your player is standing
p := p.offset(point(10, -60)); //Offsets your point on the minimap to somewhere closer to the upper-middle-left. This is not
//the actual numbers. I just made something up
mouse(p, MOUSE_LEFT); //Move the mouse to that point and click
minimap.waitPlayerMoving(); //Wait while moving

if minimap.findSymbol(p, MM_SYMBOL_TANNER, minimap.getBounds()) then //If there is a Tanner symbol on the minimap, then store that value into variable 'p'
begin
mouse(p, MOUSE_LEFT); //Move and click on that point
minimap.waitPlayerMoving();
end;
end;


I hope this helps, but it isn't perfect. Alter values as needed. I often offset TPoints with a few degrees of randomness just for antiban reasons.

Also, reducing the size of your SPS map to only what you need might help if you insist on using SPS.

For finding a moving NPC, you could possibly try to use Camel's method here: https://villavu.com/forum/showthread.php?t=111795

I'll leave it to you to find out how to use it. His instructions are pretty good for doing it. I would suggest using maybe using Ellis' hair or apron color with that method.

rickhunley

2015-05-20 19:37:20

From: yourule97
Wow, I did not realize how many bots do this method. Like 6 overall level 35's running in my home world.

Anyways, let me help you a bit with your pathfinding. Here is my preferred method of walking.



procedure walkToEllis();
var
p: TPoint;
begin
p := minimap.getBounds().getMiddle(); //Rough estimate of where your player is standing
p := p.offset(point(10, -60)); //Offsets your point on the minimap to somewhere closer to the upper-middle-left. This is not
//the actual numbers. I just made something up
mouse(p, MOUSE_LEFT); //Move the mouse to that point and click
minimap.waitPlayerMoving(); //Wait while moving

if minimap.findSymbol(p, MM_SYMBOL_TANNER, minimap.getBounds()) then //If there is a Tanner symbol on the minimap, then store that value into variable 'p'
begin
mouse(p, MOUSE_LEFT); //Move and click on that point
minimap.waitPlayerMoving();
end;
end;


I hope this helps, but it isn't perfect. Alter values as needed. I often offset TPoints with a few degrees of randomness just for antiban reasons.

Also, reducing the size of your SPS map to only what you need might help if you insist on using SPS.

For finding a moving NPC, you could possibly try to use Camel's method here: https://villavu.com/forum/showthread.php?t=111795

I'll leave it to you to find out how to use it. His instructions are pretty good for doing it. I would suggest using maybe using Ellis' hair or apron color with that method.


Thank-you for this! It's one of the fastest ways to make $ without requiring XP. I shall go and test your additions :)

rickhunley

2015-05-20 20:00:30

It determined p := minimap.getBounds().getMiddle(); as an unknown declaration :(

Turpinator

2015-05-20 21:54:46

From: rickhunley
It determined p := minimap.getBounds().getMiddle(); as an unknown declaration :(


Should work. be sure you have everything spelled correctly/srl6 included/etc.

rickhunley

2015-05-20 22:51:00

From: Turpinator
Should work. be sure you have everything spelled correctly/srl6 included/etc.


Quick question:

Do I replace the code you gave me with this, or do I include it with the code that's already there?

Thanks

{——————————————————————————)
Procedure: RunToEllis
Description: Runs to Ellis the Tanner
(——————————————————————————}
procedure RunToEllis;
Var
PathToEllis: TPointArray;
begin
if not isLoggedIn() then
exit;
BotStatus := 'Running to Ellis the Tanner';
Proggy;
PathToEllis := [Point(59, 162), Point(76, 145), Point(91, 107), Point(98, 69), Point(74, 62)]
if not SPS.walkPath(PathToEllis) then
begin
ClearDebug();
BotStatus := 'ERROR: Hmph, we failed running to Ellis.. our legs must be broken';
Proggy;
WriteLn('ERROR: Hmph, we failed running to Ellis.. our legs must be broken'); //PrintError(1);
TerminateScript();
end;
end;

rickhunley

2015-05-20 23:02:06

From: Turpinator
Should work. be sure you have everything spelled correctly/srl6 included/etc.


The code works, but I don't think the script works because you can't see the symbol from the bank. Therefore it just goes to a room just above the bank, and doesn't click the symbol :(

rickhunley

2015-05-20 23:26:25

From: yourule97
Wow, I did not realize how many bots do this method. Like 6 overall level 35's running in my home world.

Anyways, let me help you a bit with your pathfinding. Here is my preferred method of walking.



procedure walkToEllis();
var
p: TPoint;
begin
p := minimap.getBounds().getMiddle(); //Rough estimate of where your player is standing
p := p.offset(point(10, -60)); //Offsets your point on the minimap to somewhere closer to the upper-middle-left. This is not
//the actual numbers. I just made something up
mouse(p, MOUSE_LEFT); //Move the mouse to that point and click
minimap.waitPlayerMoving(); //Wait while moving

if minimap.findSymbol(p, MM_SYMBOL_TANNER, minimap.getBounds()) then //If there is a Tanner symbol on the minimap, then store that value into variable 'p'
begin
mouse(p, MOUSE_LEFT); //Move and click on that point
minimap.waitPlayerMoving();
end;
end;


I hope this helps, but it isn't perfect. Alter values as needed. I often offset TPoints with a few degrees of randomness just for antiban reasons.

Also, reducing the size of your SPS map to only what you need might help if you insist on using SPS.

For finding a moving NPC, you could possibly try to use Camel's method here: https://villavu.com/forum/showthread.php?t=111795

I'll leave it to you to find out how to use it. His instructions are pretty good for doing it. I would suggest using maybe using Ellis' hair or apron color with that method.


Thanks for the help. I tried reducing the minimap size


And updating the pathways. When the player withdraws from the bank, it simply puts the flag one path outside the bank, then tries to find Ellis, obviously Ellis is further up. Mmm. Any ideas?

Turpinator

2015-05-20 23:31:51

From: rickhunley
Thanks for the help. I tried reducing the minimap size


And updating the pathways. When the player withdraws from the bank, it simply puts the flag one path outside the bank, then tries to find Ellis, obviously Ellis is further up. Mmm. Any ideas?



rickhunley

2015-05-21 00:04:42

lol. so I'm screwed?

rickhunley

2015-05-21 00:46:07

From: yourule97
Wow, I did not realize how many bots do this method. Like 6 overall level 35's running in my home world.

Anyways, let me help you a bit with your pathfinding. Here is my preferred method of walking.



procedure walkToEllis();
var
p: TPoint;
begin
p := minimap.getBounds().getMiddle(); //Rough estimate of where your player is standing
p := p.offset(point(10, -60)); //Offsets your point on the minimap to somewhere closer to the upper-middle-left. This is not
//the actual numbers. I just made something up
mouse(p, MOUSE_LEFT); //Move the mouse to that point and click
minimap.waitPlayerMoving(); //Wait while moving

if minimap.findSymbol(p, MM_SYMBOL_TANNER, minimap.getBounds()) then //If there is a Tanner symbol on the minimap, then store that value into variable 'p'
begin
mouse(p, MOUSE_LEFT); //Move and click on that point
minimap.waitPlayerMoving();
end;
end;


I hope this helps, but it isn't perfect. Alter values as needed. I often offset TPoints with a few degrees of randomness just for antiban reasons.

Also, reducing the size of your SPS map to only what you need might help if you insist on using SPS.

For finding a moving NPC, you could possibly try to use Camel's method here: https://villavu.com/forum/showthread.php?t=111795

I'll leave it to you to find out how to use it. His instructions are pretty good for doing it. I would suggest using maybe using Ellis' hair or apron color with that method.


@yourule97 - could you please explain how do I store the Tanner symbol variable into p? Is it p: TannerSymbol; under Var?

Thanks

Okay I edited the part that you said to this, it doesn't click on the TannerSymbol though, I figured I've done something wrong :S Thanks for your patience…:)


procedure RunToEllis;
Var
TannerSymbol: TPoint
begin
TannerSymbol := minimap.getBounds().getMiddle();
TannerSymbol := TannerSymbol.offset (point(10, -60));

mouse (TannerSymbol, MOUSE_LEFT); //the actual numbers. I just made something up //Move the mouse to that point and click
minimap.waitPlayerMoving(); //Wait while moving

if minimap.findSymbol(TannerSymbol, MM_SYMBOL_TANNER, minimap.getBounds()) then //If there is a Tanner symbol on the minimap, then store that value into variable 'p'
begin
mouse(TannerSymbol, MOUSE_LEFT); //Move and click on that point
minimap.waitPlayerMoving();
end;
end;

Okay I updated the Procedure: FindEllis with TanningSymbol, unfortunately the tanning symbol places you outside the tanning shop itself.

Help greatly appreciated. Need pathfinding bug fixed :(


{------------------------------------------------------------------------------)
Procedure: FindEllis
Description: Finds Ellis the Tanner using FindTheTwinki
(------------------------------------------------------------------------------}
function FindEllis(): boolean;
Var
TannerSymbol: TPoint;
ellisOvalTimer: TTimeMarker;
begin
if not isLoggedIn() then
exit();
if productionScreen.isOpen() then
productionscreen.close();

BotStatus := 'Trying to find Ellis the Tanner';
Proggy;
ellisOvalTimer.start();
repeat
if FindTheTwinki(E_HUE, E_SAT, E_COLOR, E_TOL, E_FILTER, MOUSE_RIGHT, ['Ellis','llis'], ['an', 'ide'], true, rE_HUE, rE_SAT, rE_COLOR, rE_TOL, rE_EXCLUDE, true, 30) then
begin
BotStatus := 'Found Ellis';
Proggy;
exit(true);
end
else if (minimap.findSymbol(TannerSymbol, MM_SYMBOL_TANNER, minimap.getBounds())) and (ellisOvalTimer.getTime() >= 10000) then
begin
BotStatus := 'Couldn''t find Ellis, clicking Tanner Symbol and trying again';
Proggy;
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
Mouse(point(TannerSymbol.x + gaussRangeInt( - 5, 5), TannerSymbol.y + gaussRangeInt( - 5, 5)), MOUSE_LEFT, MOUSE_HUMAN);
Wait(randomRange(250, 750));
if FindTheTwinki(E_HUE, E_SAT, E_COLOR, E_TOL, E_FILTER, MOUSE_RIGHT, ['Ellis','llis'], ['an', 'ide'], true, rE_HUE, rE_SAT, rE_COLOR, rE_TOL, rE_EXCLUDE, true, 30) then
mouseBox(mainScreen.playerBox);
if (isMouseOverText(['Ellis','llis'])) then
begin
fastClick(MOUSE_RIGHT);
Wait(randomRange(250, 750));
chooseOption.select(['an', 'ide'], 1000);
BotStatus := 'Found Ellis';
Proggy;
exit(true);
end;
end;
until ellisOvalTimer.getTime() >= 30000;

ClearDebug();
BotStatus := 'ERROR: Could not find Ellis';
Proggy;
WriteLn('ERROR: Could not find Ellis');
TerminateScript();
end;

yourule97

2015-05-21 08:42:28

I don't think I was clear enough in m post. Let me try to break it down into steps.

1. Assume the bot starts at the bank
2. Since you can't see the tanner symbol at the bank, click somewhere to the north east.
3. Wait while the bot moves.
4. The tanner symbol should be visible now.
5. Find the tanner symbol.
6. Click on the tanner symbol.
7. Wait while the bot moves.

It seems that you kinda get the gist about the code, but I hope this helps. Also, I'd like to explain a little bit more about what the minimap.findSymbol(p, SYMBOL, BOX) method. http://docs.villavu.com/srl-6/minimap.html#trsminimap-findsymbol

You pass the method a variable "p" which stores the point at which it finds the variable "symbol." However, this won't place you at directly where you need to be. Therefore, you'll need to offset that variable p (this is independent of the previous use of offset until your bot walks into the right area.

I hope you'll also understand why you shouldn't really call "p", "TannerSymbol"

I'm not entirely familiar with the conventions in SRL yet, but I think that scripters usually make a global variable "p" which is a universal point that gets altered at the programmer's will. I hope this helps.

teigrgwyn

2015-05-21 14:54:53

I wouldn't know if you're able to speed up the mouse faster than:
procedure fastClick(button: integer);
Maybe you can instead check to make sure it hit its target?
function didClick(Red: Boolean; Time: Integer = 1000): boolean;

rickhunley

2015-05-22 10:06:14

Thanks for the additions guys. I've decided to go through the code line by line, and add the additions you have, and then come back.

One thing that is irritating is the NPC Ellis that has a tendency to walk around A LOT.