PDA

View Full Version : FindNearestNPC(x,y:Integer;Click:Boolean);



Sin
03-07-2012, 10:18 PM
function FindNearestNPC(var x,y:Integer;Click,Wait:Boolean):Boolean;
var
NPC:TPoint;
begin
if FindColorSpiralTolerance(NPC.x,NPC.y,65536,558,6,6 90,153,4) then
begin
Result := True;
if (Click = True) and (Result = True) then
Mouse(NPC.x,NPC.y,1,1,True);
if Wait = True then
begin
FFlag(1);
Wait(750 + random(250));
end;
end;
end;

x,y = Stores info of NPC locations.
Click = Whether to click or not.
Wait = Whether to wait until not moving or not.

It's been really useful for me in fighting scripts and even my ZMI :)

Sin
03-07-2012, 10:38 PM
Added an FFlag boolean :p

shstiger2009
03-07-2012, 10:44 PM
Right when I read the thread title I thought woah, this is for fighting for sure! Looks pretty good, I'd bet it speeds up some fighting scripts a ton.

Sin
03-07-2012, 10:45 PM
Right when I read the thread title I thought woah, this is for fighting for sure! Looks pretty good, I'd bet it speeds up some fighting scripts a ton.

Hehe, it will work for anything actually :P
For example, thieving, cooking scripts, etc :p

Flight
03-08-2012, 02:28 AM
Actually, your X and Y variables are never stored, therefore when calling this function they'll always return '0'... Also, by default, this function should return false, not true. Also, 'Wait' as one of your parameters is already a valid procedure in Simba thus you cannot use that same name. Here's your function fixed up:

function FindNearestNPC(var x,y: Integer; Click,DoWait: Boolean):Boolean;
var
NPC:TPoint;
begin
Result := False; //This should always be false by default
if FindColorSpiralTolerance(NPC.x,NPC.y,65536,558,6,6 90,153,4) then
begin
Result := True;
X := NPC.x; //Now, X & Y actually return something...
Y := NPC.y;
if (Click and Result) then //No need for (Boolean = True)
begin
Mouse(NPC.x,NPC.y,1,1,True);
if DoWait then
begin
FFlag(1);
Wait(750+random(250));
end;
end;
end;
end;

Jokester
03-08-2012, 02:33 AM
Actually, your X and Y variables are never stored, therefore when calling this function they'll always return '0'... Also, by default, this function should return false, not true. Also, 'Wait' as one of your parameters is already a valid procedure in Simba thus you cannot use that same name. Here's your function fixed up:

function FindNearestNPC(var x,y: Integer; Click,DoWait: Boolean):Boolean;
var
NPC:TPoint;
begin
Result := False; //This should always be false by default
if FindColorSpiralTolerance(NPC.x,NPC.y,65536,558,6,6 90,153,4) then
begin
Result := True;
X := NPC.x; //Now, X & Y actually return something...
Y := NPC.y;
if (Click and Result) then //No need for (Boolean = True)
begin
Mouse(NPC.x,NPC.y,1,1,True);
if DoWait then
begin
FFlag(1);
Wait(750+random(250));
end;
end;
end;
end;


Looks good! I've got the perfect script for this!:stirthepot:

Sin
03-08-2012, 02:34 AM
It was working for me Flight :$

Flight
03-08-2012, 02:56 AM
It was working for me Flight :$

If you were to debug your function's return values for X & Y you'd always have 0. You understand that an integer was never assigned to either of them within your function. Try this and you'll see:

Procedure Test;
Var
X,Y: Integer;
begin
if FindNearestNPC(X, Y, True, True) then
Writeln('NPC dot found at Point('+InttoStr(X)+', '+InttoStr(Y)+')');
end;

Ashaman88
03-08-2012, 03:01 AM
This could be pretty handy!