PDA

View Full Version : Laake's FindObjOnScreen Guide



laakerules
02-11-2012, 10:04 PM
FindObjOnScreen

What this allows you to do?

Have one function with the availability of to use it for many many many many many many many many many things! :)

This is my first TUT So dont hate! :)


Things Needed:
ACA/Auto Color Aid found Here (http://villavu.com/forum/showthread.php?t=26944&highlight=Auto+Color)
Simba


First step:

The function itself! :)

Function FindObjOnScreen(Up:Array of String;Color,Tolerance:Integer;MC2:Variant;Hmod,Sm od:Extended): Boolean;
var
X,Y:Integer;
CTS,I,T: Integer;
TPA: TPointArray;
begin
repeat
Result := False;
CTS := GetColorToleranceSpeed;

ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(Hmod,Smod);//These are the modifiers you got from the ACA

FindColorsSpiralTolerance(MSCX, MSCY, TPA,(Color), MSX1, MSY1, MSX2, MSY2, Tolerance);//This finds the actual item on screen calls the color and the tolerance when finding the o0bject.
ColorToleranceSpeed(CTS);

if (Length(TPA) < 1) then
Exit;

MMouse(TPA[0].X, TPA[0].Y, 5, 5);
if WaitUpTextMulti(Up, 400) then//This is the uptext that it waits to see.
begin
GetMousePos(X, Y);//this goes to the declared position from FindColorsSpiralTolerance
ClickMouse2(MC2);//This is the Is the type of mouse Click that you want it to do.
ChooseOptionMulti(Options);//If the MC2 Was false then you use this to choose the options!
Result := True;
Exit;
end;

Until(Result = True);
end;


Now that is the function that does all the work! :)


2nd Step:
Calling that function into use!

This is part from my ghouler. As you can see i called it here, you can use it whereever you want as long as its below the actual function that we declared ^^^^^ there

begin
Startup;
SetupChar;
LoadBMP;
LoadVars;
repeat
ToGhouls;
repeat
DoThePainting;
KillGhouls;
MarkTime(P);
Repeat
PickupCharms;
Until (TimeFromMark(P) > 500);
FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);//Here is the function.
until (hppercent<50);
ToBank;
Proggy;
OpenBankNPC;
if BankScreen then
begin
DoThePainting;
DepositAll;
wait(50 + Random(250));
DoThePainting;
Withdraw(0, 0, 28);
wait(50 + Random(250));
DoThePainting;
Deposit(1,1,false);
wait(50 + Random(250));
DoThePainting;
CloseBank;
end;
FindNormalRandoms;
until not LoggedIn
writeln('stopping script');
Proggy;
TerminateScript;
end.


Now what each one of those things are! :)

FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
..........................................^^^ Is the up text it looks for! :)

FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
.................................................. ..............^^^^^ The color you found with ACA

FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
.................................................. .......................^^The 1 is the color tolerance that ACA showed you.

FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
.................................................. ..............................^^^True is for it to left Click false is for it to right click! :)

FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
.................................................. .....................................^^1.73 is the Hue Mod

FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
.................................................. ...........................................^^^ is the Saturation modifier!


Earlier in the Tut i had the function posted and in the function i had put The Mutliple Option choice, now for step 3 which shows you how this works! :)

Step 3:
Multiple uptext! :)

In the running of your script usually located at the bottom and has a
begin
end.
with the period you need to put this

LoadVars;


What that does is make sure that the variable load into the script, the ones that we will declare like this!


procedure LoadVars;
begin
Options:=['old charm','ffigy', 'rimson charm', 'reen charm', 'lue charm']

end;

This is an array of uptexts that we use, you put the text you want inbeetween 2 'like this' and seperate those by commas 'o','k','a','y','','e','t','c','.',

Drops:=['old charm','ffigy', 'rimson charm', 'reen charm', 'lue charm']

You can call it whatever you want, in my scripts i mainly use this for many different drops, or many different objects, ex rocks water table then furnace and so on! :)

Now for you not to get compile errors of not finding that variable you need to go to the top of your script.

the top should be something like this

program WoodCutter;

{$DEFINE SMART}
{$i SRL/srl.simba}
{$i sps/sps.simba}
{$i SRL/SRL/misc/paintsmart.simba}

//put
Var

Options: Array of String;//or whatever you want to call it instead of Options! :)
//Unless you already have your Variables declared up here! :)



procedure DeclarePlayers;

and so on! :)





And thats the end of the TuT, this is good to have a cleaner script that is more accurate! :)

I got the base of this function from Flight! :)

This is my first TuT so please dont hate. :duh:

I take no credit for ACA, the creators of that are in freaking sanely smart! :)
:spot:

Striken
02-12-2012, 12:06 AM
This will for sure help out those who need help :p

begginer
02-12-2012, 12:40 AM
Thanks for this awesome tut

Vinyl Scratch
02-12-2012, 03:20 AM
Great tut! You should make more!

jatex
02-12-2012, 05:46 AM
I'll try this out on my Chaos Druid script, good guide :P.

drawboy11
02-12-2012, 05:53 AM
Amazing! aha, my zammy wine grabber now works flawlessly(: Thanks laake!

laakerules
02-12-2012, 06:24 AM
Yup your welcome guys, this is my first tut and it was hard to write without using my own laake terms! :P So hope you guys enjoy!

euphemism
02-12-2012, 06:35 AM
It's good to see you writing your own custom finding functions. That is a step in the right direction. A few things you might want to change though:

Repeat
Until(Result)

What is this? An infinite loop is what it is. If you never find the uptext, the script using this function will be forced into an infinite loop, moving the mouse all over the screen. Not good.

MMouse(TPA[0].X, TPA[0].Y, 5, 5);

Within your infinite loop, you find the color and then do this. ^ You move to the first pixel in the TPA no matter what. and if your character is not moving, it's likely that as you loop over and over again, you'll just be mousing to the same exact point. Over and over.

If anything, try getting rid of your infinite loop, and looping through your TPA instead. That way, you'll be sure to mouse over all found instances of the color.

Tip: Grouping the points in your TPA into an ATPA will greatly increase speed, accuracy, and reliability. Try looking at this tutorial (http://villavu.com/forum/showthread.php?t=42428) for a better understanding of TPAs and how to use them more effectively.

Up:String
and
if WaitUpText(Up, 400) then

Try using a string array along with 'WaitUpTextMulti' you are more likely to find 'ele', or 'eto', or 'kel', or 'el', or even 'k' than you are the complete word 'Skeleton'. (If you were looking for a Skeleton archer, for example.)

ChooseOptionMulti(Options)

What is 'Options'? You have no options parameter.

----

Just a few things I saw with a quick look-over. You're off to a good start though.

laakerules
02-12-2012, 07:20 AM
THanks euphanism! :)

The options, i changed it when writing the TuT. And forgot to change it down below when declaring the Vars and in the Var.! :)

And ill look into that infinite loop thingy. didnt notice i was doing that! :P


Updated it, thanks Euphanism! :)

Still working on atpa though will do tomorow! :)

[XoL]
02-12-2012, 11:20 PM
Great job! I will remember your effort here! wink wink. :)