SRL Archive - SRL Archives

[Function]FindAObject


Avaphi

2007-01-31 00:32:31

Here it is, It is atm, untested, but imho, I think it will be hawt. Here it is:

//**Find A Object**\\
program FindAObject;
{.include Srl\Srl.Scar}

function FindAObject(S1, S2, S3 : String; Colors:Array Of integer; Tolerance : integer): Boolean;
begin
var i : integer;

for (i:=0 to GetArrayLength(Colors)-1) do
begin
if FindColorSpiralTolerance(Ax, Ay, Colors[i], MSX1, MSY1, MSX2, MSY2, Tolerance) then
MMouse(Ax, Ay, 0, 0);
if IsUpTextMulti(S1, S2, S3) then
begin
writeln('We found the correct object ! Z0mg!');
Mouse(Ax, Ay, 0, 0, True);
end;
writeln('We got fux0rd, Someone contact Avaphi !');
end;

begin
SetupSrl;
If(FindAObject('Your', 'Strings', 'Here!', [color1,color2,color3,color4,color5], Tol))Then
begin
writeln('I found the object dood');
end;
end.

Got any questions? Just ask :)

NOTES: You need to change the arguments of the function in the main loop(the hawtcolors and the strings) if you want to use it.

Pyro

2007-01-31 03:35:02

Hmmm maybe ill write a tut on how to use findcolorsspiral. Basically this will work ok if there is just the one color on the screen. Or i guess it will scroll through colors so it may move mouse. But otherwise say you need a red that is at the bottem right and you spriral from top left and there is a red in the middle of screen. You will always go to the red. And you wont move past it.

Basically you need to use findcolorsspiral. It stores all co ords of all the pixels that match into a array. It should be in the scar manual correct me if im wrong and ill help a bit more.

Avaphi

2007-01-31 10:54:42

Its okies, I will be writing a different one when I get home, but feel free to if you want !

Yakman

2007-01-31 18:31:02

why only 5 colors? arrays can hold any number, change it to this..



function FindAObject(S1, S2, S3 : String;Colors:Array Of integer; Tolerance : integer): Boolean;
begin

for f:=0 to GetArrayLength(colors)-1 do
//..


use like this



if( FindAObject('alk','to','ank',[34564,23453,21342,645324,23435],10) )then


Avaphi

2007-01-31 22:48:22

Updated for infinite colors~

Avaphi

2007-03-04 15:55:57

Pyro, you really should write a tut on findcolorsspiraltolerance…. I would love it :)… get on msn once in awile and dont be a stranger ;)

WT-Fakawi

2007-03-04 17:39:44

Your function will now do IsUpTextMulti every time, even when there is no colormatch :)

You forgot to add an extra begin; and end;

if FindColorSpiralTolerance(Ax, Ay, Colors[i], MSX1, MSY1, MSX2, MSY2, Tolerance) then
begin
MMouse(Ax, Ay, 0, 0);
if IsUpTextMulti(S1, S2, S3) then
begin
writeln('We found the correct object ! Z0mg!');
Mouse(Ax, Ay, 0, 0, True);
end;
end


and if you want to add a lil' offset to the thing do this:

if FindColorSpiralTolerance(Ax, Ay, Colors[i], MSX1, MSY1, MSX2, MSY2, Tolerance) then
begin
MMouse(Ax, Ay, RandX, RandY);
if IsUpTextMulti(S1, S2, S3) then
begin
writeln('We found the correct object ! Z0mg!');
GetMousePos(Ax,Ay);
Mouse(Ax, Ay, 0, 0, True);
end;
end


Good Work!

Avaphi

2007-03-04 17:51:18

Thanks Fawk. My original intention for this was to be a NPC finder. So after I got some more experience under my belt… I redesigned it and came up with this:

Function FindNPC(var NPCx, NPCy : integer; Colors: Array Of integer; NPCName : string): boolean;
var i : integer;
begin
MouseSpeed := 8;
for i := 0 to GetArrayLength(Colors) do
begin
if (FindColorSpiralTolerance(NPCx, NPCy, Colors[i], MSX1, MSY1, MSX2, MSY2, 30)) then
begin
Mmouse(NPCx, NPCy, 0, 0);
Wait(10);
if (IsUpText(NPCName)) then
begin
Result := True;
Break;
end;
end;
end;
MouseSpeed := DefaultMS;
end;

Works VERY well for all the Guides on tutorial island :) I purposely edit the mouse speed because when I do play legit I notice that I go to the monster very quickly. Please, give it a try ;)

Pyro

2007-03-04 19:05:18

Woops. Sorry forgot all about this. In return about the tut. Yeah. Well ill help you on msn. Im on sometimes :p Computer networking is more interesting then scar nowadays :p Boo! to cisco qualifications which are so damn hard. But yeah ill get you next time your on msn