SRL Archive - Research & Development Lounge

Handle Furnace


Richard

2008-05-12 13:06:38

This is just a basic function that I made for my smelter, just so it could find the furnace more reliably than FindObjTPA. And I thought it might be useful to people making smelters, just incase they don't know TPAs. Its my first proper TPA usage so don't insult it too much :p

Function HandleFurnace:Boolean;
Var
TPA: TPointArray;
Temp: T2DPointArray;
h, x, y, MouseSpeed2, z, t, CTS: Integer;
begin
If not LoggedIn then Exit;
MouseSpeed2 := MouseSpeed;
MouseSpeed := 25;
t := GetSystemTime;
CTS := ColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(x, y, TPA, 2500137, MSX1, MSY1, MSX2, MSY2, 5);
Temp := TPAtoATPAex(TPA, 40, 40);
SortATPASize(Temp, True);
h := High(Temp);
For z := 0 to h do
Begin
If Length(z) >= 10 then //10 a good ammount?
Continue;
MiddleTPAex(Temp[z], x, y);
MMouse(x, y, 5, 5);
Result := IsUpText('melt');
If Result then
Begin
WriteLN('Found the furnace in '+IntToStr((GetSystemTime) - t)+' msecs');
break;
end;
Wait(100);
end;
If Result then
Begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
end;
If Not Result then
WriteLN('Couldn'#39't find a furnace');
MouseSpeed := MouseSpeed2;
ColorToleranceSpeed(CTS);
end;

Example of how quickly it finds it:

Found the furnace in 477 msecs

Thats one of the slower times, it once did it in 138 I think, somewhere near that.

NOTE: I've only testing in Al Kharid, I think all furnaces are the same, but if they aren't this may only work there.

Thanks to Hermpie for helping me learn TPAs.

ShowerThoughts

2008-05-12 13:34:17

U are a copycat using higher mousespeed like 25 u do is detectable i should delete it k :p

Richard

2008-05-12 14:12:15

From: Hermpie
U are a copycat using higher mousespeed like 25 u do is detectable i should delete it k :p


I find its better, makes is less detectable really. And is only for like half a second so it doesn't matter.

Cazax

2008-05-15 17:32:59

Set your ColorToleranceSpeed as it was before changing it.

R0b0t1

2008-05-15 21:26:22

You could accomplish the same thing and still make it faster.

Richard

2008-05-16 15:38:03

From: Cazax
Set your ColorToleranceSpeed as it was before changing it.


Done

MylesMadness

2008-05-16 17:43:56

From: R0b0t1
You could accomplish the same thing and still make it faster.
Well could you not spam and tell us how…

nielsie95

2008-05-16 17:54:53

I suggest looking at the length of an array before doing a MiddleTPA. What if the length is 3, are you still sure it might be a furnace? ;)

Wizzup?

2008-05-16 18:25:58

From: nielsie95
I suggest looking at the length of an array before doing a MiddleTPA. What if the length is 3, are you still sure it might be a furnace? ;)


It might be Pi, Rounded! :rolleyes:
What Nielsie means is basically:

  For z := 0 to h do
Begin
if length(Temp[z]) < 10 then // 10?
continue;
MiddleTPAex(Temp[z], x, y);
MMouse(x, y, 5, 5);
Result := IsUpText('melt');
If Result then
Begin
WriteLN('Found the furnace in '+IntToStr((GetSystemTime) - t)+' msecs');
break;
end;
Wait(100);
end;

Richard

2008-05-17 09:37:20

From: nielsie95
I suggest looking at the length of an array before doing a MiddleTPA. What if the length is 3, are you still sure it might be a furnace? ;)


Ok, I get what you mean, I'll edit it now.

From: Wizzup?
It might be Pi, Rounded! :rolleyes:
What Nielsie means is basically:

  For z := 0 to h do
Begin
if length(Temp[z]) < 10 then // 10?
continue;
MiddleTPAex(Temp[z], x, y);
MMouse(x, y, 5, 5);
Result := IsUpText('melt');
If Result then
Begin
WriteLN('Found the furnace in '+IntToStr((GetSystemTime) - t)+' msecs');
break;
end;
Wait(100);
end;


What would you say is a good length, because furnaces are quite big?

Thanks Wizzy and Nielsie for help :) (I repped you both).

drizzt

2008-05-17 09:50:54

just comment the length check out for a time, and make it print the length of the TPA each time it finds it. do that 10 times or so, take the lowest and the highest it prints, and viola, you have an accurate length check

Richard

2008-05-17 09:54:12

From: drizzt
just comment the length check out for a time, and make it print the length of the TPA each time it finds it. do that 10 times or so, take the lowest and the highest it prints, and viola, you have an accurate length check


How would you print out the length of the TPA. Sorry I'm new to TPAs.

drizzt

2008-05-17 11:02:10

Function HandleFurnace:Boolean;
Var
TPA: TPointArray;
Temp: T2DPointArray;
h, x, y, MouseSpeed2, z, t, CTS: Integer;
begin
If not LoggedIn then Exit;
MouseSpeed2 := MouseSpeed;
MouseSpeed := 25;
t := GetSystemTime;
CTS := ColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(x, y, TPA, 2500137, MSX1, MSY1, MSX2, MSY2, 5);
Temp := TPAtoATPAex(TPA, 40, 40);
SortATPASize(Temp, True);
h := High(Temp);
For z := 0 to h do
Begin
If Length(z) >= 10 then //10 a good ammount?
Continue;
MiddleTPAex(Temp[z], x, y);
MMouse(x, y, 5, 5);
Result := IsUpText('melt');
If Result then
Begin
WriteLN('Found the furnace in '+IntToStr((GetSystemTime) - t)+' msecs');
Writeln(inttostr(Length(Temp[z])) + ' is the length of the TPA');
break;
end;
Wait(100);
end;
If Result then
Begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
end;
If Not Result then
WriteLN('Couldn'#39't find a furnace');
MouseSpeed := MouseSpeed2;
ColorToleranceSpeed(CTS);
end;

also, 40*40 is pretty huge..thats a possible 1600 points, so 10 is definately not a good length

Richard

2008-05-17 11:34:28

Well I don't know, I'm rubbish at all this TPA stuff. I might make it 20 by 20. Then I'd made the legnth something higher. But what it is at the moment seems to work fine, its never not found it, and its never gone to click on something other than the furnace.

ShowerThoughts

2008-05-17 12:05:55

From: Dude Richard
Well I don't know, I'm rubbish at all this TPA stuff. I might make it 20 by 20. Then I'd made the legnth something higher. But what it is at the moment seems to work fine, its never not found it, and its never gone to click on something other than the furnace.


See i said 40*40 was good :)

nielsie95

2008-05-17 12:47:19

First off, continue makes a loop hold (not continue).


program New;
var
i: Integer;
begin
for i := 0 to 3 do
begin
if (i = 2) then
Continue;
WriteLn(IntToStr(i));
end;
end.


If Length(z) <= 10 then //Why check for z here?
Continue;

You have a double array, which means you have an array of an array. You loop through the first array to find an array that matches your needs. If you keep checking the same array, it wont work ;) Check the array you are going to use if it's a possible furnace. To find a proper length, let it write it out a few times:


Function HandleFurnace:Boolean;
Var
TPA: TPointArray;
Temp: T2DPointArray;
h, x, y, MouseSpeed2, z, t, CTS: Integer;
begin
If not LoggedIn then Exit;
MouseSpeed2 := MouseSpeed;
MouseSpeed := 25;
t := GetSystemTime;
CTS := ColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(x, y, TPA, 2500137, MSX1, MSY1, MSX2, MSY2, 5);
Temp := TPAtoATPAex(TPA, 40, 40);
SortATPASize(Temp, True);
h := High(Temp);
For z := 0 to h do
Begin
WriteLn(IntToStr(Length(Temp[z])));
MiddleTPAex(Temp[z], x, y);
MMouse(x, y, 5, 5);
Result := IsUpText('melt');
If Result then
Begin
WriteLN('Found the furnace in '+IntToStr((GetSystemTime) - t)+' msecs');
Writeln(inttostr(Length(Temp[z])) + ' is the length of the TPA');
break;
end;
Wait(100);
end;
If Result then
Begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
end;
If Not Result then
WriteLN('Couldn'#39't find a furnace');
MouseSpeed := MouseSpeed2;
ColorToleranceSpeed(CTS);
end;