SRL Archive - OSR Help

Need Help finding NPC


kenddy3

2012-12-09 19:58:53

Hey guys making a Monkfish Bot but need help I noticed that Bank (NPC) moves around a lot and I think that the script/bot will say could not find banker and will terminate the script and I need help what should I do so that the script will find the banker and will bank all the monkfish every single time it goes to bank

King

2012-12-09 20:47:21

From: kenddy3
Hey guys making a Monkfish Bot but need help I noticed that Bank (NPC) moves around a lot and I think that the script/bot will say could not find banker and will terminate the script and I need help what should I do so that the script will find the banker and will bank all the monkfish every single time it goes to bank


Use a TPA like so.

Example from my beer buyer

Function FindBartender:Boolean;
var
tmpCTS, i, l, r, counter: integer;// Name your variables
BTTPA:TPointArray; // This is the name of the array
begin tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.06, 0.34); // Hue and saturation from ACA
FindColorsTolerance(BTTPA,//TPA name 6973285,//Color MSX1, MSY1, MSX2, MSY2,//Search area, main screen 10//Tolerance);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02); // Set modifiers back to normal
L := High(BTTPA) // Search the TPA
marktime(counter);
for i := 0 to L do // For i to L(random point) search for the color
begin
r := random(L);
wait(randomrange(60, 200));
mmouse(BTTPA[r].x, BTTPA[r].y, 2, 2); //Moves the mouse to the color found, with a offset of 2 each axis
if waituptext('tender', 300) then // Checks uptext
Break;
if timefrommark(counter) > 3000 then // Time failsafe
begin
writeln('Failed to find the bartender'); // If it fails, debugs
end;
end;
writeln('Found the bartender'); // Debug
clickmouse2(mouse_right); // Right clicks on him
WaitOption('Talk-to', 500); // Chooses the option to talk to him
MarkTime(b); // Mark the time
repeat
wait(50+random(5)); // Repeats the wait until he responds ("yer") or time is 2000ms or 2 seconds after
until((FindNPCChatText('yer', nothing)) or (TimeFromMark(b) > 2000));
end;


Hoep I explained it well enough :P Also, log in and out multiple times when using ACA to get a good tolerance.

euphemism

2012-12-09 21:20:20

kenddy3, follow SRLKing's advice in terms of using ACA to get the best color to use when searching for this NPC. Use CTS2 with hue/sat mods as shown in the code above; however, SRLKing, your code is no better than not using TPAs.

SRLKing, you simply loop through every point that was determined to be within tolerance of the specified color that was searched (and at that, you aren't even guaranteeing that you mouse over every point because you use r := random(L) in your loop).

kenddy3, once a TPA is acquired of every point that has been determined to be within tolerance of the specified color, you need to move on and use something like SplitTPA in order to break the points up into groups based on a specified maximum distance between points. From there, it becomes much easier to find what it is you are looking for, as you can filter these groups by a known size and other qualifiers.

kenddy3, go to the Tutorial Island section of the forum and look through the intermediate/advanced tutorial sections for TPA/ATPA tutorials.

Roflme

2012-12-09 22:34:40

You could try something like this…

function FindObjR(Colors:TIntegerArray; tol:Integer; Hue, Sat:Extended; x1, y1, x2, y2:Integer; Sort:Boolean; Point:TPoint; minCount:Integer; Text:TStringArray):Boolean;
var
tCTS, I: Integer;
TPA: TPointArray;
ATPA, rATPA: T2DPointArray;
myPoint: TPoint;
begin
Result := False;
if not LoggedIn then
Exit;
tCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(Hue, Sat);
SetLength(rATPA, Length(Colors));
for I := 0 to High(Colors) do
begin
FindColorsSpiralTolerance(MSCX, MSCY, rATPA[i], Colors[i], x1, y1, x2, y2, tol);
end;
TPA := MergeATPA(rATPA);
if Length(TPA) = 0 then
begin
ColorToleranceSpeed(tCTS);
Exit;
end;
ATPA := TPAtoATPAEx(TPA, 6, 6);
if Sort then
SortATPAFrom(ATPA, Point);
SetLength(TPA, 0);
For I := 0 to High(ATPA) do
begin
if Length(ATPA) < minCount then
Continue;
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 1, 1);
if IsUpTextMultiCustom(Text) then
begin
Result := True;
ColorToleranceSpeed(tCTS);
Writeln('FindObjR was successfull');
Exit;
end;
end;
ColorToleranceSpeed(tCTS);
end;

I made this (before I knew there was FindObjTPAMulti :fiery: :( :(). They're similar but this uses CTS2 instead.

My code can use improvement. But for what I use it for it works fine.

I'd highly suggest reading TPA tutorials. TPAs are wonderful :D

(euphemism/any SRL members, not to steal this thread but can you critique the above code :p to help the OP and myself by suggesting improvements :D).