SRL Archive - OSR Help

Better way to find a moving NPC?


Sawyer

2013-04-29 00:37:22

I wrote this function to find a Npc, but the NPC keeps moving, so I have repeats in it.I want it to be faster, yet I cannot see how yet. Does anyone have any ideas that could improve it?
Function FindNPC:Boolean;
var
Cts,a, y, Tries:Integer;
NPCTPA:Tpointarray;
NPCATPA:T2DPointarray;
begin
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.05);
marktime(y);
repeat
if FindColorsSpiralTolerance(MSCX, MSCY, NPCTPA, 4025793, msx1, msy1, msx2, msy2, 14) then
begin
if Debug then
Writeln('Found npc colors...');

NPCATPA := SplitTPAEx(NPCTPA, 5, 5);
SortATPAFromMidPoint(NPCATPA, Point(262, 224-50))
end;
for a :=0 to high(NPCATPA) do
begin
MouseSpeed:=(Randomrange(9, 15));
HumanMMouse(NPCTPA[a].x, NPCTPA[a].y, 3, 3);
wait(300+Random(100));
Inc(Tries);
if isUptext('to') then
begin
Result := True;
Exit;
end else
Result := False;
end;
Until(TimeFromMark(y) > 20000);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.02, 0.02);
end;

King

2013-04-29 01:06:03

You can always increase mousepad and use waituptext instead of wait, if urtext blah blah blah. Personally I would just use super users surface include.

t4q

2013-04-29 04:16:19

you can go little pit faster by decreasing this wait. Maybe use 150 + random 50?
HumanMMouse(NPCTPA[a].x, NPCTPA[a].y, 3, 3);
wait(300+Random(100));
Inc(Tries);

Sawyer

2013-04-29 14:15:03

That sounds good. I'll try decreasing the wait times.

randy marsh

2013-04-29 14:27:08

 MouseSpeed:=(Randomrange(9, 15));
MMouse(NPCTPA[a].x, NPCTPA[a].y, 3, 3);
wait(300+Random(100));
Inc(Tries);
if isUptext('to') then


is (to) part of the npcs name?

NKN

2013-04-29 20:52:43

MMDotsToMS?

Calculate where the dot direction is moving, then search for it accordingly on the mainscreen?

King

2013-04-29 20:54:30

From: NKN
MMDotsToMS?

Calculate where the dot direction is moving, then search for it accordingly on the mainscreen?


This works well, I use this to find monsters a lot :D