SRL Archive - Research & Development Lounge

NpcFindNClick;//i must say it works good


ShowerThoughts

2007-10-27 13:10:07

updated!

program NPCFinder;
{.include SRL/SRL.Scar}

{==============================]
Function:FindClickNpc
by:Hermpie
Info:you could use it like this,
NPCFindNClick(Color1,Color2,'uptext1','uptext2','rade',InFight,False,10);
[==============================}
Function NPCFindNClick( NPCColor1, NPCColor2:integer; UpText1,UpText2, COption:string;RepeatUntil, RightOrLeft:boolean;
HMTolerance:integer):boolean;
var
TMT :Integer;
Coord123X :Integer;
Coord123Y :Integer;
T:integer;
begin
TMT:=0;
repeat
FindTalk;
TMT:=TMT + 1
Wait(50+random(10));
if FindObjCustom(Coord123X, Coord123Y, [Uptext1, Uptext2], [NPCColor1, NPCColor2],HMTolerance) then//Thanks killerDou!:)
begin
T := GetSystemTime;
Wait(50+random(10));
Mouse(Coord123X, Coord123Y, 1, 1, RightOrLeft);
Wait(50+random(10));
if (RightOrLeft=False) then
begin
if ChooseOption(COption) then
begin
Result:=True;
WriteLn('Found Npc');
Break;
end;
end;
end;
until (RepeatUntil) or (TMT>10)
if RepeatUntil then Result:=true;
Writeln(IntToStr(GetSystemTime - T));
end;


Begin
SetupSrl;
NPCFindNClick(1,1,'uptext1','uptext2','rade',InFight,False,10);
end.

-Hermpie(pls change my first letter to a capital'H')

Bobzilla69

2007-10-27 13:45:33

i like this, think its a good idea, i might use it, not sure yet

ShowerThoughts

2007-10-27 13:52:01

just try ;)

Bobzilla69

2007-10-27 15:43:09

ok coz u ask nicely i will have a go, i might even add it into my script :P

ShowerThoughts

2007-10-27 16:00:57

kk ty ;)

Lacky

2007-10-27 21:19:32

Damn you're smexy… :p

Dumpin

2007-10-28 11:25:53

simple but efficient, Very usefully for beginners, especially when they are making their first script with walk / talk :)

ShowerThoughts

2007-10-28 12:25:39

thank you!

MasterKill

2007-10-28 14:08:29

nice but you got some much to fill in for those poor starting scripters :(

I made an sort of eddited version:
{*******************************************************************************
Function FindAndClickNPC(NpcColors: TIntegerArray; UpTexts: TStringArray;
RChooseOption :string; RightOrLeftNpcClick:boolean; HMTolerance: integer;):boolean;
Started by: Hermpie.
modified by: MasterKill.
Description: Finds and clicks an NPC
Use: FindAndClickNPC([123456, 345678], ['ancelot', 'Sir'], 'Talk', False, 5)
*******************************************************************************}
Function FindAndClickNPC(NpcColors: TIntegerArray; UpTexts: TStringArray; RChooseOption :string; RightOrLeftNpcClick:boolean; HMTolerance: integer):boolean;
var
Coord123X, Coord123Y :Integer;
begin
repeat
if FindObjCustom(Coord123X, Coord123Y, UpTexts, NpcColors, HMTolerance) then
begin
If RightOrLeftNpcClick then
begin
Mouse(Coord123X, Coord123Y, 0, 0, True);
Result := True;
WriteLn('Found NPC');
exit;
end else
begin
Mouse(Coord123X, Coord123Y, 0, 0, False);
Wait(50 + random(100));
if ChooseOption(RChooseOption) then
begin
Result:=True;
WriteLn('Found NPC');
Exit;
end else WriteLn('NPC missclick!');
end;
end else
begin
WriteLn('not found NPC!');
Result := False;
exit;
end;
until(False)
end;

didn't test it but should be working

ShowerThoughts

2007-10-28 14:13:12

kk lol but mine is better;) i mean got more options ;)

MasterKill

2007-10-28 14:15:08

i said THAT might be a problem, that's why i made A better one :) :D

I also used some T Arays

ShowerThoughts

2007-10-28 14:15:39

lol but more options is better less is EASIER not better ;)

MasterKill

2007-10-28 14:18:12

nope, it's harder to fill in, and you allways needed to pick 2 colors, you can easely use 1 color now.

most options you use are kinda unless ;)

you don't have to thank me…

ShowerThoughts

2007-10-28 14:19:44

my thing can loop and will wait after you can say until click to continue or this tries its a bit harder to fill in but if you know how to use its better ;)

msn?, you and me are spamming right now…

Santa_Clause

2007-10-29 07:00:08

For the colours, use a TIntegerArray so they can put as many colours as they like…

function FindNPC(Colours : TIntegerArray) : Boolean;
begin
for I := 0 to GetArrayLength(Colours) - 1 do

And so on…

MasterKill

2007-10-29 09:43:31

From: Santa_Clause
For the colours, use a TIntegerArray so they can put as many colours as they like…

function FindNPC(Colours : TIntegerArray) : Boolean;
begin
for I := 0 to GetArrayLength(Colours) - 1 do

And so on…


see post #9 m8 :)

ShowerThoughts

2007-10-29 10:37:08

you changed the credit! when you gave your ''easier but not better version'' to him you changed the credit!

the scar noob

2007-10-30 08:32:38

From: MasterKill
nice but you got some much to fill in for those poor starting scripters :(

I made an sort of eddited version:
{*******************************************************************************
Function FindAndClickNPC(NpcColors: TIntegerArray; UpTexts: TStringArray;
RChooseOption :string; RightOrLeftNpcClick:boolean; HMTolerance: integer;):boolean;
Started by: Hermpie.
modified by: MasterKill.
Description: Finds and clicks an NPC
Use: FindAndClickNPC([123456, 345678], ['ancelot', 'Sir'], 'Talk', False, 5)
*******************************************************************************}
Function FindAndClickNPC(NpcColors: TIntegerArray; UpTexts: TStringArray; RChooseOption :string; RightOrLeftNpcClick:boolean; HMTolerance: integer):boolean;
var
Coord123X, Coord123Y :Integer;
begin
repeat
if FindObjCustom(Coord123X, Coord123Y, UpTexts, NpcColors, HMTolerance) then
begin
If RightOrLeftNpcClick then
begin
Mouse(Coord123X, Coord123Y, 0, 0, True);
Result := True;
WriteLn('Found NPC');
exit;
end else
begin
Mouse(Coord123X, Coord123Y, 0, 0, False);
Wait(50 + random(100));
if ChooseOption(RChooseOption) then
begin
Result:=True;
WriteLn('Found NPC');
Exit;
end else WriteLn('NPC missclick!');
end;
end else
begin
WriteLn('not found NPC!');
Result := False;
exit;
end;
until(False)
end;

didn't test it but should be working

Heheh, I saw his functino were you could input 2 colors, I thought, I'll tell hem to use TIntegerArray.
I scrolled down the page and I saw your edited version, which includes TIntegerArray:D

However, good try hermpie, we finally see something better from you:).

-Tsn.

Naum

2007-10-30 13:48:32

Very Good Altough if someone was a 'poor scripter' they would want to use the function but keep frogetting it. I liked MasterKill's Version better because it is easier to understand but who knows?

->{Nauamn}<-

ShowerThoughts

2007-10-30 15:36:09

updated!

removed the realy realy ussless stuff and keep the good stuff it got 1/2 more options then masterkills one but its better i swear ;)

MasterKill

2007-10-30 17:32:39

From: hermpie
updated!

removed the realy realy ussless stuff and keep the good stuff it got 1/2 more options then masterkills one but its better i swear ;)


i would not say that hermpie…. :fiery:

this version looks better then your first one.

mat_de_b

2007-10-30 17:40:01

Put in arrays! :mad:

man slaughter

2007-11-02 10:36:01

im not sure how different this scrip is and the one modified by master kill is but, in heavy world like in varorck shop world 1. it mistakes the shop seller for a player. it happens about once in every 8 times. i eddited the script to make it check if it opened the store trade dialog. its good now. i think this one is better though since it includes a loop. i made a loop personally for master kills one.

ShowerThoughts

2007-11-02 10:39:45

From: man slaughter
im not sure how different this scrip is and the one modified by master kill is but, in heavy world like in varorck shop world 1. it mistakes the shop seller for a player. it happens about once in every 8 times. i eddited the script to make it check if it opened the store trade dialog. its good now. i think this one is better though since it includes a loop. i made a loop personally for master kills one.


thats the point you can do and fill in in my thing like Until foundshopdialog check my version there is somthing called repeat until fill in there the name of your findshopdialog procedure and it works fine ;)

Raskolnikov

2007-11-16 22:14:47

From: hermpie
updated!

removed the realy realy ussless stuff and keep the good stuff it got 1/2 more options then masterkills one but its better i swear ;)


I am so using this in my next function for pickpocketing people. There are no SRL skill functions for Theiving.

Czepa

2007-11-17 01:05:01

Begin
SetupSrl;
NPCFindNClick(1,1,'uptext1','uptext2','rade',InFight,False,10);
end.

if you were to use this function in a script you would not SetupSrl; would you?

ShowerThoughts

2008-02-10 05:16:08

dude my funtion uses some funtions out of srl duh :S

mixster

2008-02-10 05:41:40

You really should turn to the MK side - arrays would be much better for it because you can use as many or as little as you want - afterall, how many uptexts can one shopkeeper have (unless he works shift with a friend). Otherwise, it's a nice little function and I wish I could use it in my next script (alas, not much room for a NPC clicker in a bank'n'chopper).

ShowerThoughts

2008-02-10 05:47:25

you can use it for a tree to like this:

Procedure FindOak;
var
TMT,b: Integer;
begin
TMT := 0;
Check;
if (TreeGone = False) then exit;
repeat
TMT := TMT + 1
B := GetSystemTime
if FindObjCustom(X, Y, ['Oak', 'ak'], [OakColor, OakColor2], 10) then
begin
Wait(50+random(20));
Mouse(X, Y, 1, 1, False);
Wait(50+random(20));
if ChooseOption('hop') then
begin
WriteLn('Found Oak');
Break;
end;
end;
until (TMT > 10)
end;

mixster

2008-02-10 06:13:33

The only thing is I don't like using FindObj/Custom - much prefer using my own way of doing it - unless it's for uniquely coloured things.

Negaal

2008-02-10 06:23:41

11-17-2007


Bit late to answer? :p

Oh anyways, it's basically findobj and clicking…good to learn from it…(I mean failsafes and obj finding):)
Good to see you back…

Edit:
Quess why you gravedigged? You are the *spammasta*
:p:D

ShowerThoughts

2008-02-10 12:43:21

spam F
spam U
spam C
spam K

spam Y
spam O
spam U

spam just kidding :P

thanks mate ;)

(you always gravedig like that :S?)

Hermpie