Nemesis3X
02-23-2012, 10:22 PM
Hello Everyone! I don't know if any of you ever had problems with moving NPC's or Monster, but I've had Problems with them and I am willing to simplify Your life with a Tutorial on How to Find a Moving NPC or Monster without any more Headache. If you are Tired to see Your bot Trying to find Your NPC, but can't because someone is near you and He has the Same color as your Script, so Your bot keeps Hovering the mouse on this guy because he is the closest to you until he get's further away and Finally allow to script to find the Real NPC you Wanted to find! than you are in the Right place.
Why Would you Want to Use This Method?
Well, I am not here to Force you to use My method, but It is very effective. You can continue to use Simple Method like
if (findobjcustom(x,y,['Wilderness'],[2172972],5)) then
But like I said, If I come Near You with the Same Color as your Script, You will have a lot of Fun Watching your Bot hovering the Mouse on me Trying to find the Target as You can see on this Picture! That I don't have :O
How to do it:
Basically, At the end of this Tutorial, Your Function for Finding the NPC will look like the Function Below. In this case, I was searching a NPC and I had to Click and Choose an Option on him.
Function TalkingToMages: Boolean;
Var
TPAA: T2DPointArray; // The Variables of the Functions
TPA: TPointArray;
CTS, I, Retry: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, YourColorHere, MSX1, MSY1, MSX2, MSY2, Tolerance); // Enter the Color and Tolerance Here at the Right place.
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, Width, Heigh); //Put the Width and Heigh here
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 5 Then // Set How Much Points you need for your function to take Action
Begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], X, Y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['age', 'amorak'])) then // Enter The name of Your NPC or Monster
Begin
Result := True;
GetMousePos(X, Y);
mouse(x,y,3,3,false);
wait(100 + random(200));
ChooseOption('elep');
wait(5000 + random(1000));
Break;
End;
until (Retry = 2);
Break;
end;
end;
This May look Scary for Now, but It will become A lot Easier After I explain to You Step by Step of What to do!
Lets Get started!
Step 1 : Get Your Color!
Since NPC's or Monsters Move, You want to get Pick your color on His head, It will be a lot Easier for Your Script to Find out the NPC like that, because If you Pick a color that is only visible on the Chest (Chest of the Monster or NPC you want to find)This can Lead to Your Function Returning False because You cannot find the NPC since the color You Picked is not in the Angle of Your screen.
For this Reason, I decided to Pick goblins as an Exemple for This Script.
http://img32.imageshack.us/img32/3542/goblinhead.png (http://imageshack.us/photo/my-images/32/goblinhead.png/)
As You see, The Color of The Head of This goblin is 5940087. For tolerance, It is pretty much testing what works best, I would always recommend Starting with a Tolerance of 7 and If you don't like the Result, You can adjust it to your liking/which ever works for you. If you are Wondering What happens when You reduce your tolerance, It will search for Colors that are near to the one your Picked. If you rise it, It will search for Colors that are more likely the Same as Your color.
With Your color and Tolerance, You have to to put them into the function. Here is a Picture on Where to Put them :
http://img836.imageshack.us/img836/3162/colorandtolerance.png (http://imageshack.us/photo/my-images/836/colorandtolerance.png/)
Step 2 : Get the Width and Heigh
This is by far, The most important Part of This function. The End Result will Depend on how good you do it. So, let me explain how we get this. Did you always wonder How People Were getting their Distance in the Game, since there is no option that Tells us the Exact distance between points? Well, there is a way to know how Far Each points is from Each Other and It is with Picking the Color. Before I explain How do it, Take a look at this Picture I posted Below This Text!
http://img811.imageshack.us/img811/3618/mouseclick1.png (http://imageshack.us/photo/my-images/811/mouseclick1.png/)
http://img191.imageshack.us/img191/5078/mouseclick2.png (http://imageshack.us/photo/my-images/191/mouseclick2.png/)
Why are we doing this? We want to Make a Box, so When our Script Does the Function, our function will find Dots of our Color and If there is Enough Dots To make the Same box as Us, the function will return True and Check if it is the Right NPC, if it is, it will click in the middle of the Box and if it is now, it will move to another to see if it is our NPC. Now, lets get into the Topic, how to get theses values. As you can see, We don't see my Mouse on the Screen, So I made a Red Dot to Indicate Where My mouse was!
What you want to do: First, Get beside your NPC (like I did) then Click on Pick Color on Simba. The screen will freeze and that's exactly what we want. What We want to do is Get the Dimension of the Head. As your see, I moved my Mouse to What Would be my bottom Right corner and I took note of the Coordinates that were in the Red Box(638,624). After, I did the Same, but on the opposite side, So I moved my Mouse to What would be my Top Left Corner and Took note of the coordinates (635,771). So, Now do you see the Box I was Talking About?
The Next Step is to get Width and Height. First, Put the value of the same Type Together, so 638 with 635 and 624 with 771 = (638,635) and (624,771). If you are wondering why My second Value is so High, it is Because I took a Picture and get the coordinates from the picture, but I didn't place paint in the same arena as I took the Coordinates with the first picture and it wasn't on the same place on my Main screen, so I got coordinates that are wrong, but it won't happen if you do it on your Playing Screen. For this Reason, We will change our 771 for 625. Now, it should be (638,635) and (624,625).
Why do we need These Values. If you do 638 - 635 = 3 and this is our Width. 624 - 625 = -1, but we can't have a negative Value, so we turn it into apositive value by which I mean 1 and this is our Height. Wow! We are almost done! Enter The Width and Height to their Respective Place shown on the Picture below and When you Script use this function, It will seach for array that will allow him to make a Box like this on this Picture.
http://img641.imageshack.us/img641/354/boxgoblin.png (http://imageshack.us/photo/my-images/641/boxgoblin.png/)
http://img269.imageshack.us/img269/4356/width.png (http://imageshack.us/photo/my-images/269/width.png/)
Step3 - Get the Up Text
http://img23.imageshack.us/img23/693/uptext.png (http://imageshack.us/photo/my-images/23/uptext.png/)
As you see on the picture, When you move your Mouse Over the Goblin, There is an Up Text. My indication. Never Use the First letter, because it will make it longer for your Bot to Detect if it is the Right Npc. So, Here is what our Uptext would be : oblin that we would add on here on this picture below.
http://img15.imageshack.us/img15/2900/nameez.png (http://imageshack.us/photo/my-images/15/nameez.png/)
So, Our Script Should look like this now
Function TalkingToMages: Boolean;
Var
TPAA: T2DPointArray; // The Variables of the Functions
TPA: TPointArray;
CTS, I, Retry: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5940048, MSX1, MSY1, MSX2, MSY2, 7); // Enter the Color and Tolerance Here at the Right place.
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 3, 1); //Put the Width and Heigh here
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 5 Then // Set How Much Points you need for your function to take Action
Begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], x, y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['oblin'])) then // Enter The name of Your NPC or Monster
Begin
Result := True;
GetMousePos(X, Y);
mouse(x,y,3,3,false);
wait(100 + random(200));
ChooseOption('elep');
wait(5000 + random(1000));
Break;
End;
until (Retry = 15);
Break;
end;
end;
In this Case, My function was Click on A NPC that I had to Talk and Choose an option to Teleport. Here, We want to Attack a goblin, so We are going to change the End of this Function to attack instead of Trying to Find the Option Teleport on Goblin.
Function TalkingToMages: Boolean;
Var
TPAA: T2DPointArray; // The Variables of the Functions
TPA: TPointArray;
CTS, I, Retry: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5940048, MSX1, MSY1, MSX2, MSY2, 7); // Enter the Color and Tolerance Here at the Right place.
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 3, 1); //Put the Width and Heigh here
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 5 Then // Set How Much Points you need for your function to take Action
Begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], x, y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['oblin'])) then // Enter The name of Your NPC or Monster
Begin
Result := True;
GetMousePos(X, Y);
mouse(x,y,3,3,true);
wait(5000 + random(1000));
Writeln('We have found our Goblin, Yeh!');
Break;
End;
until (Retry = 2);
Break;
end;
end;
Now, We are Good. Also, I added what we Call a FailSafe, so If the Script Doesn't find the goblin after 2 attempts, it will end. That's where You can enter in Your script a procedure to Walk To a New place to Try to find Another NPC or change the Angle of the compass.This method Can also be used to find Object in Runescape like Door or stairs. So, I hope I helped you out to Make a better Script with the Ability to find NPC's Way easier without any more Trouble.
Why Would you Want to Use This Method?
Well, I am not here to Force you to use My method, but It is very effective. You can continue to use Simple Method like
if (findobjcustom(x,y,['Wilderness'],[2172972],5)) then
But like I said, If I come Near You with the Same Color as your Script, You will have a lot of Fun Watching your Bot hovering the Mouse on me Trying to find the Target as You can see on this Picture! That I don't have :O
How to do it:
Basically, At the end of this Tutorial, Your Function for Finding the NPC will look like the Function Below. In this case, I was searching a NPC and I had to Click and Choose an Option on him.
Function TalkingToMages: Boolean;
Var
TPAA: T2DPointArray; // The Variables of the Functions
TPA: TPointArray;
CTS, I, Retry: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, YourColorHere, MSX1, MSY1, MSX2, MSY2, Tolerance); // Enter the Color and Tolerance Here at the Right place.
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, Width, Heigh); //Put the Width and Heigh here
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 5 Then // Set How Much Points you need for your function to take Action
Begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], X, Y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['age', 'amorak'])) then // Enter The name of Your NPC or Monster
Begin
Result := True;
GetMousePos(X, Y);
mouse(x,y,3,3,false);
wait(100 + random(200));
ChooseOption('elep');
wait(5000 + random(1000));
Break;
End;
until (Retry = 2);
Break;
end;
end;
This May look Scary for Now, but It will become A lot Easier After I explain to You Step by Step of What to do!
Lets Get started!
Step 1 : Get Your Color!
Since NPC's or Monsters Move, You want to get Pick your color on His head, It will be a lot Easier for Your Script to Find out the NPC like that, because If you Pick a color that is only visible on the Chest (Chest of the Monster or NPC you want to find)This can Lead to Your Function Returning False because You cannot find the NPC since the color You Picked is not in the Angle of Your screen.
For this Reason, I decided to Pick goblins as an Exemple for This Script.
http://img32.imageshack.us/img32/3542/goblinhead.png (http://imageshack.us/photo/my-images/32/goblinhead.png/)
As You see, The Color of The Head of This goblin is 5940087. For tolerance, It is pretty much testing what works best, I would always recommend Starting with a Tolerance of 7 and If you don't like the Result, You can adjust it to your liking/which ever works for you. If you are Wondering What happens when You reduce your tolerance, It will search for Colors that are near to the one your Picked. If you rise it, It will search for Colors that are more likely the Same as Your color.
With Your color and Tolerance, You have to to put them into the function. Here is a Picture on Where to Put them :
http://img836.imageshack.us/img836/3162/colorandtolerance.png (http://imageshack.us/photo/my-images/836/colorandtolerance.png/)
Step 2 : Get the Width and Heigh
This is by far, The most important Part of This function. The End Result will Depend on how good you do it. So, let me explain how we get this. Did you always wonder How People Were getting their Distance in the Game, since there is no option that Tells us the Exact distance between points? Well, there is a way to know how Far Each points is from Each Other and It is with Picking the Color. Before I explain How do it, Take a look at this Picture I posted Below This Text!
http://img811.imageshack.us/img811/3618/mouseclick1.png (http://imageshack.us/photo/my-images/811/mouseclick1.png/)
http://img191.imageshack.us/img191/5078/mouseclick2.png (http://imageshack.us/photo/my-images/191/mouseclick2.png/)
Why are we doing this? We want to Make a Box, so When our Script Does the Function, our function will find Dots of our Color and If there is Enough Dots To make the Same box as Us, the function will return True and Check if it is the Right NPC, if it is, it will click in the middle of the Box and if it is now, it will move to another to see if it is our NPC. Now, lets get into the Topic, how to get theses values. As you can see, We don't see my Mouse on the Screen, So I made a Red Dot to Indicate Where My mouse was!
What you want to do: First, Get beside your NPC (like I did) then Click on Pick Color on Simba. The screen will freeze and that's exactly what we want. What We want to do is Get the Dimension of the Head. As your see, I moved my Mouse to What Would be my bottom Right corner and I took note of the Coordinates that were in the Red Box(638,624). After, I did the Same, but on the opposite side, So I moved my Mouse to What would be my Top Left Corner and Took note of the coordinates (635,771). So, Now do you see the Box I was Talking About?
The Next Step is to get Width and Height. First, Put the value of the same Type Together, so 638 with 635 and 624 with 771 = (638,635) and (624,771). If you are wondering why My second Value is so High, it is Because I took a Picture and get the coordinates from the picture, but I didn't place paint in the same arena as I took the Coordinates with the first picture and it wasn't on the same place on my Main screen, so I got coordinates that are wrong, but it won't happen if you do it on your Playing Screen. For this Reason, We will change our 771 for 625. Now, it should be (638,635) and (624,625).
Why do we need These Values. If you do 638 - 635 = 3 and this is our Width. 624 - 625 = -1, but we can't have a negative Value, so we turn it into apositive value by which I mean 1 and this is our Height. Wow! We are almost done! Enter The Width and Height to their Respective Place shown on the Picture below and When you Script use this function, It will seach for array that will allow him to make a Box like this on this Picture.
http://img641.imageshack.us/img641/354/boxgoblin.png (http://imageshack.us/photo/my-images/641/boxgoblin.png/)
http://img269.imageshack.us/img269/4356/width.png (http://imageshack.us/photo/my-images/269/width.png/)
Step3 - Get the Up Text
http://img23.imageshack.us/img23/693/uptext.png (http://imageshack.us/photo/my-images/23/uptext.png/)
As you see on the picture, When you move your Mouse Over the Goblin, There is an Up Text. My indication. Never Use the First letter, because it will make it longer for your Bot to Detect if it is the Right Npc. So, Here is what our Uptext would be : oblin that we would add on here on this picture below.
http://img15.imageshack.us/img15/2900/nameez.png (http://imageshack.us/photo/my-images/15/nameez.png/)
So, Our Script Should look like this now
Function TalkingToMages: Boolean;
Var
TPAA: T2DPointArray; // The Variables of the Functions
TPA: TPointArray;
CTS, I, Retry: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5940048, MSX1, MSY1, MSX2, MSY2, 7); // Enter the Color and Tolerance Here at the Right place.
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 3, 1); //Put the Width and Heigh here
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 5 Then // Set How Much Points you need for your function to take Action
Begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], x, y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['oblin'])) then // Enter The name of Your NPC or Monster
Begin
Result := True;
GetMousePos(X, Y);
mouse(x,y,3,3,false);
wait(100 + random(200));
ChooseOption('elep');
wait(5000 + random(1000));
Break;
End;
until (Retry = 15);
Break;
end;
end;
In this Case, My function was Click on A NPC that I had to Talk and Choose an option to Teleport. Here, We want to Attack a goblin, so We are going to change the End of this Function to attack instead of Trying to Find the Option Teleport on Goblin.
Function TalkingToMages: Boolean;
Var
TPAA: T2DPointArray; // The Variables of the Functions
TPA: TPointArray;
CTS, I, Retry: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5940048, MSX1, MSY1, MSX2, MSY2, 7); // Enter the Color and Tolerance Here at the Right place.
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 3, 1); //Put the Width and Heigh here
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 5 Then // Set How Much Points you need for your function to take Action
Begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], x, y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['oblin'])) then // Enter The name of Your NPC or Monster
Begin
Result := True;
GetMousePos(X, Y);
mouse(x,y,3,3,true);
wait(5000 + random(1000));
Writeln('We have found our Goblin, Yeh!');
Break;
End;
until (Retry = 2);
Break;
end;
end;
Now, We are Good. Also, I added what we Call a FailSafe, so If the Script Doesn't find the goblin after 2 attempts, it will end. That's where You can enter in Your script a procedure to Walk To a New place to Try to find Another NPC or change the Angle of the compass.This method Can also be used to find Object in Runescape like Door or stairs. So, I hope I helped you out to Make a better Script with the Ability to find NPC's Way easier without any more Trouble.