SRL Archive - OSR Help

Function for Finding Hidden NPC


iBlank

2012-05-08 04:43:15

Ok, so I have been using a script that needs to find a NPC who is stationary at all times. Normally I just search for his head color and that works fine, but lately some people have been placing a Clan Vexillum over the NPC to intentionally mess scripts up so I decided I needed to figure out a way to get past this. This what I have come up with and it seems to work well, but I was wondering if there is a better or more accurate way to do it. Thanks!


Function FindHidden(x, y: Integer): Boolean;
Var
I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
InvPoint: TPoint;

Begin
TPA := GetMMDotsOnMS('npc')
ATPA := TPAToATPAEx(TPA, 15, 15);
MiddleTPAEx(ATPA[i], x, y);
InvPoint := MMToMSEx(0, -20, Point(x,y));
Begin
MMouse(InvPoint.x, InvPoint.y, 0, 0);
If(WaitUpTextMulti(['Clan','Vex','illum'],700)) Then Result:= True;
End;
End;

Edit - Basically, I am saying this is my first time using GetMMDotsOnMs and MMToMSEx so I don't know if this is the best way to use them or if there are better options. Thanks!

Daniel

2012-05-08 05:48:42

You'd most likely rather use something like this which I made for you:

function FindAllNPCs(const UpText: AnsiString): Boolean;
var
I, J: Integer;
tempTPA: array of TPoint;
begin
Result := False;
tempTPA := GetMMDotsOnMS(#110);

J := High(tempTPA);
if(J < 0) then
Exit;

for I := 0 to J do
begin
MMouse(tempTPA[I].x, tempTPA[I].y, 5, 5);
if(WaitUpText(UpText, 500)) then
begin
Result := True;
Exit;
end;

Sleep(3500 + Random(4000));
end;
end;

It will return True if your specified NPC is found using the UpText provided. And all you have to do is click the mouse (i.e. ClickMouse2).

Abu

2012-05-09 01:28:16

Yes, Daniel's is slightly better because it searches for uptext.

It was your idea though, not bad!

Gucci

2012-05-09 22:24:33

From: abu_jwka
Yes, Daniel's is slightly better because it searches for uptext.

It was your idea though, not bad!


The one by alevere4 also searches for uptext ;) just had to point that out

Er1k

2012-05-10 01:38:11

Where is this place you're working where legits are spamming their vexillums?

If your position is static, another way is to blind search, and right click through vex to hope your option is there.

iBlank

2012-05-10 01:46:06

From: Er1k
Where is this place you're working where legits are spamming their vexillums?

If your position is static, another way is to blind search, and right click through vex to hope your option is there.


Oh you know, mobilising armies :redface:

But no, I have to move from the bank to the investor so my position is different occassionally.