Log in

View Full Version : How to shorter and make it better



fearlesskiller
01-20-2012, 01:37 AM
So this is a part of my pest control script where it should attack the npcs teleporting to void knight. The only problem is that i dont know how to make it shorter, better and how to make it that its when it sees 1 of those 4 color.


procedure AttackNpc;
var x, y:integer;
begin
FindColorTolerance(x, y, 1327672, MSX1, MSY1, MSX2, MMY2, 3)
if FindColorTolerance(x, y, 1327672, MSX1, MSY1, MSX2, MMY2, 3) then
Mouse(x, y, 2, 2, True);
wait(3000+random(75));
FindColorTolerance(x, y, 2902160, MSX1, MSY1, MSX2, MSY2, 3)
if FindColorTolerance(x, y, 2902160, MMX1, MSY1, MSX2, MSY2, 3) then
Mouse(x, y, 2, 2, True);
wait(3000+random(75));
FindColorTolerance(x, y, 792070, MSX1, MSY1, MSX2, MSY2, 3)
if FindColorTolerance(x, y, 792070, MSX1, MSY1, MSX2, MSY2, 3) then
Mouse(x, y, 2, 2, True);
wait(3000+random(75));
FindColorTolerance(x, y, 3935042, MSX1, MSY1, MSX2, MSY2, 3)
if FindColorTolerance(x, y, 3935042, MSX1, MSY1, MSX2, MSY2, 3) then
Mouse(x, y, 2, 2, True);
wait(3000+random(75));
end;

bg5
01-20-2012, 02:03 AM
var
Colors: TIntegerArray;
b ,x,y: integer;
Found : Boolean;

begin

colors := [3432432,432432423,4234242] ; // all colors you want

for b := 0 to (High(colors)) do
begin
if (FindColorTolerance(x, y, colors[b], xs, ys, xe, ye, Tol)) then
begin
Found := True;
Break;
end;
end;

if (found) then
begin
{ ... }
end;

end;

fearlesskiller
01-20-2012, 02:06 AM
Do i need to change anything in that cause its not working. Maybe you should specify please

[XoL]
01-20-2012, 02:09 AM
if (found) then
begin
{ ... }
end;

end;


Put the procedure you want to happen in there.

Dynamite
01-20-2012, 02:10 AM
Do i need to change anything in that cause its not working. Maybe you should specify please

On an even bigger plate for you:

procedure FindAndClickColors;
var
colors: TIntegerArray;
b ,x, y: integer;

begin

colors := [1327672, 2902160, 792070, 3935042] ; // all colors you want

for b := 0 to (High(colors)) do
begin
if (FindColorTolerance(x, y, colors[b], xs, ys, xe, ye, Tol)) then
begin
Mouse(x, y, 2, 2, True);
wait(3000+random(75));
Break;
end;
end;

end;


-Boom

fearlesskiller
01-20-2012, 02:11 AM
I did put
Mouse(x, y, 2, 2, true);
but i get that error
[Error] (73:45): Unknown identifier 'xs' at line 72
which is in
if (FindColorTolerance(x, y, colors[b], xs, ys, xe, ye, Tol)) then

kevin33
01-20-2012, 02:13 AM
I did put
but i get that error
[Error] (73:45): Unknown identifier 'xs' at line 72
which is in

xs needs to be defined in variables. I would figure it would be:

xs: integer;
THEN again you may need to fill in your own info there. Not familiar with the FindColorTolerance.

Dynamite
01-20-2012, 02:19 AM
Use MS co-ordinates like you did.

-Boom

bg5
01-20-2012, 02:30 AM
procedure FindAndClickColors;
var
colors: TIntegerArray;
b ,x, y: integer;

begin

colors := [1327672, 2902160, 792070, 3935042] ; // all colors you want

for b := 0 to (High(colors)) do
begin
if (FindColorTolerance(x, y, colors[b], MSX1, MSY1, MSX2, MMY2, 3)) then
begin
Mouse(x, y, 2, 2, True);
wait(3000+random(75));
Break;
end;
end;

end;

fearlesskiller
01-20-2012, 12:47 PM
Thanks guys i really appreciate it!