PDA

View Full Version : Brand new, first script help needed



Petrichorr
11-21-2018, 09:57 PM
Hello everyone, I have absolutely no experience with script writing (also never posted on any forum before so the format might be terrible) but Simba intrigues me so I am trying to learn, i got a basic script set up and went through a bunch of tutorials, and am now trying to write an extremely basic script to left click and attack stationary monsters. My problem is the script is having a terrible time finding the correct color tolerance.


{$I SRL/OSR.simba}

Const
STOP_KEY = 113; //F2 to exit


Procedure AttackAgg;
var
x,y:Integer;
begin
if FindColorTolerance(x, y, 1451962, 80, 73, 342, 180, 5) then
begin
movemouse(x, y);
wait(250);
ClickMouse(x, y, Mouse_Left);
Wait(5000);
end;
end;

begin
AttackAgg;

end.

All the code is doing is looking at a box for the color and clicking on it, the monsters are bright red and everything else is brown, but instead of clicking the red it just clicks the mouse randomly inside the box I made.


28582

The moust just clicks randomly within that area.
I honestly don't know what I am doing wrong and I tend not to ask for help, but I have come to realize that mentality wont get me very far with this.
Any help or tips would be greatly appreciated.

Zombified
11-21-2018, 11:44 PM
Have you tried using a different color/tolerance, or perhaps a different function for finding the color?

Petrichorr
11-21-2018, 11:47 PM
Ive tried 6 or 7 different color tolerances, I wasent aware there were other functions to find color, do you mean like the spiral and such or another method entirely?

Zombified
11-22-2018, 12:11 AM
Ive tried 6 or 7 different color tolerances, I wasent aware there were other functions to find color, do you mean like the spiral and such or another method entirely?

Yessir! Since you are new, I would recommend taking a look at the color finding section in the villavu docs. It contains all your basic functions that you can use to search for colors. You might also like a handy little tool floating around here, known as ACA. It allows you to select multiple points of different colors and calculates the best single color/tolerance combination that will accept all of those points.

Personally, I'm a fan of what's known as a DTM (deformable template model) when it comes to finding objects. Mainly because you can specify shapes, distance, tolerance, rotations, etc. They are slightly more advanced and you should probably get a feel for pin-point color finding first so you can understand the concepts a little more in depth.

If you'd like, feel free to add me on Discord and I'll give you a personal tour of color finding.
Zombie#4597

Petrichorr
11-22-2018, 12:28 AM
Yessir! Since you are new, I would recommend taking a look at the color finding section in the villavu docs. It contains all your basic functions that you can use to search for colors. You might also like a handy little tool floating around here, known as ACA. It allows you to select multiple points of different colors and calculates the best single color/tolerance combination that will accept all of those points.

Personally, I'm a fan of what's known as a DTM (deformable template model) when it comes to finding objects. Mainly because you can specify shapes, distance, tolerance, rotations, etc. They are slightly more advanced and you should probably get a feel for pin-point color finding first so you can understand the concepts a little more in depth.

If you'd like, feel free to add me on Discord and I'll give you a personal tour of color finding.
Zombie#4597


Sure, I might just have to take you up on that offer, this is all extremely interesting to me, but most of the videos and such were quite a bit out of date, ill through you an add on discord thanks.

Clarity
11-22-2018, 02:39 AM
Instead of clicking the red it just clicks the mouse randomly inside the box I made.
The moust just clicks randomly within that area.
I honestly don't know what I am doing wrong and I tend not to ask for help, but I have come to realize that mentality wont get me very far with this.
Any help or tips would be greatly appreciated.

Hi there,
I tested a slightly modified version of your code on the picture you attached and it appeared to work fine. Are you selecting the game as a target properly? Are the dimensions of the search box correct? Does this private server have some kind of color related anticheat requiring higher tolerance?

https://i.gyazo.com/4e6a08d191897bace45b593c6c5230c1.gif

As you can see the mouse is choosing random points to click correctly here. Without the modification it worked too, only it just clicked one point (top-left) as that’s all you coded. This was my modification for testing:

procedure attackAgg;
var
foundPoints: tPointArray;
clickPoint: tPoint;
begin
if findColorsTolerance(foundPoints, 1451962, 210, 269, 512, 399, 5) then
begin
clickPoint := foundPoints[random(0, high(foundPoints))]; //Select random point of the found red demon points
moveMouse(clickPoint.x, clickPoint.y);
wait(250);
clickMouse(clickPoint.x, clickPoint.y, MOUSE_LEFT);
wait(500);
end;
end;

var
i: integer;

begin
for i := 0 to 9 do
attackAgg;
end.


That said, there are of course lots of things you can do to make a better, more accurate object finding function, but I wanted you to know that your original code (with the color and tolerance you used) appears to work (on the picture at least) so the problem may be something you overlooked like window target selection.

Petrichorr
11-23-2018, 08:42 PM
Thanks for all the help guys, turns out it was a hardware problem on my end, it runs perfeclty fine on a vm, so i suppose ill be continuing from a vm from now on