SRL Archive - OSR Help

Preventing reclicking from TPA's


NKN

2012-04-20 17:02:23

Alright, how do you make it delete the points where it fails/clicked already, so it won't click there again.
Here's the code.

EDIT:No idea if I got it or not…

function Create(var x,y:Integer):Boolean;
var
i,a,Herbs:Integer;
TPA:TPointArray;
ATPA:T2DPointArray;
MP:TPoint;
Box:TBox;
begin
if(Act = 'Clean') then
begin
Herbs := DTMFromString('mggAAAHicY2NgYFBnZGCQAWIRKG0IxKpAnAnE2UCcDMSJUDoaiO2NpIG6mLBg7IARB4YAAGfrA84=');
MouseSpeed := 50
Repeat
FindDTMS(Herbs,TPA,MIX1,MIY1,MIX2,MIY2);
SortTPAFrom(TPA,Point(MICX,MICY));
ATPA := TPAtoATPAEx(TPA, 15, 15);

for a:= 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
Box := IntToBox((MP.x - 20),(MP.y - 20), (MP.x + 20),(MP.y + 20));
SMART_DrawBoxEx(True,Box,clYellow);
MMouse(MP.x,MP.y,4,4);
if(WaitUpText('imy',100))then
begin
x := MP.X; y := MP.Y;
Result := True;
Mouse(x,y,3,3,True);
SMART_ClearCanvas;
Break;
end;
end;
Until not(FindDTM(Herbs,x,y,MIX1,MIY1,MIX2,MIY2))
FreeDTM(Herbs);
end;
end;

I want it to click all the grimy herbs, but it clicks the Clean herbs also.

Abu

2012-04-20 17:05:07

Maybe you should just use the Herbs DTM? That way it won't ever click the clean ones unless your DTM is crap.

NKN

2012-04-20 17:06:40

It takes a second for the herbs to change though, so it'll click them again, slowing the script down.

Abu

2012-04-20 17:07:19

From: NKN
It takes a second for the herbs to change though, so it'll click them again, slowing the script down.


Add a Wait(100 + Random(60)); before searching again?

NKN

2012-04-20 17:12:33

It would be faster though. :|

Abu

2012-04-20 17:13:59

From: NKN
It would be faster though. :|


Faster vs Safer

That is the question…

NKN

2012-04-20 17:16:59

I think I found it.

Tell me if this -could- work.

If I stored the last clicked point into a Tpoint, then used:
NearbyPointInArray to check, and if it was, just had it continue?

Sex

2012-04-20 17:24:47

for i := 0 to 27 do
begin
b := InvBox(i + 1);
if FindDTM(x, y, HerbDTM, b.x1, b.y1, b.x2, b.y2) then
begin
Mouse(x, y, 4, 4, mouse_Left);
Wait(200 + random(100));
end;
end;
Try that? :)

NKN

2012-04-20 17:33:13

Still about as fast as InvMouse

Sex

2012-04-20 17:34:25

Remove the wait and change the MouseSpeed. If you want it faster, just get the center pixel of every inventory slot and see if it is similar to the color of the unclean herb. If it is, click and continue.

Brandon

2012-04-20 17:42:59


DeleteValueInTPA // Deletes a value in a tpa at the specified position which requires that you loop through the TPA.
ItemActivated // Will tell you if an item is clicked or activated.. All items when clicked with the use option will have a white outline.
DidClick //Check for a red or yellow click

all functions you may find quite useful..

The below will remove all OR one of a point from a TPA and return the removed TPA.. If nothing was removed, it will return the original TPA.

Function RemovePointsFromTPA(TPA: TPointArray; Point: TPoint; DeleteAll: Boolean): TPointArray;
var
I, L: Integer;
begin
L:= High(TPA);

For I:= 0 To L do
if (TPA[I] = Point) then
begin
DeleteValueInTPA(TPA, I);
if (Not DeleteAll) then
break;
end;
Result:= TPA;
end;


This function will give you a record of all the slots the TPA is in.. Unique slots that is.

Function TPAToSlots(TPA: TPointArray): TIntegerArray;
var
I, L: Integer;
begin
L:= High(TPA);
SetLength(Result, L + 1);

For I:= 0 To L do
Result[I]:= CoordsToItem(TPA[I].X, TPA[I].Y);

ClearSameIntegers(Result);
end;

Get your TPA of items, Pass it to this function, it will return all slots that contain the TPA points.. Iterate through each slot clicking each item once.. After Clicking a slot, Remove that slot from the ArrayOfSlots.. Simple.

NKN

2012-04-20 18:02:26

Edit:
No idea how to use any of those, and now it's lagging epicly, then stops. -nod-