SRL Archive - Discussions and Debates

FindNPC project


phantombmx

2006-06-07 03:18:38

well as you can see in my sig, i am making a NPC finder.. i am planning on getting all of the NPCs but i may just do basic ones like ones in shops and what-not.. currently i just have gerrant but you could EASILY add NPCs to it..

now what i was thinking was just get a unique database that a scriptor would just have to use the name of the npc

function FindNPC(var NPCX, NPCY: Integer; NPCName: String):Boolean;

NPCX is the x value of the NPC
NPCY is the y value of the NPC
NPCName is the name of the NPC

it will be a quite large database so i was requiring some suggestions..

should i make the large database for scripter ease? or should i just make it to where you would have to input 3 colors..

personally i like the whole database, but go ahead and post away!

PS: i know it may need to be tweaked a lot.. but thats what suggestions->trial->error is for ;)

leader

2006-06-07 03:43:28

Large database.

c0de

2006-06-07 15:09:52

Both, so let scripter choose :D (U can never go wrong with this lol)

Renax

2006-06-07 15:20:47

this is why we have findobject :), i don't see how this will be any more effcient then using a findobject in a repeat.

phantombmx

2006-06-07 17:56:22

eh, true but i think it'd be easier for some scripters.. personally, i would love to just use FindNPC(cx, cy, 'Bob'); :p

Avaphi

2006-06-07 19:49:27

Yea find obj works great. Also, srl is getting big enough as it is dude.

Cheesehunk

2006-06-07 19:59:50

I say use the 3 colors option!

Would shorten some of my code nicely.

phantombmx

2006-06-07 21:15:46

eh, this is lookin pretty grim already :(
i might just keep this for personal use :p

phantombmx

2006-06-12 00:55:58

well it will just pick one of the NPCs (so choose unique colors…)

Avaphi

2006-06-12 03:03:49

Instead, why not just use text ? You could use a variable called npc name, and then use cases, like says 'Hans' and then it would search for the name hans, and the words 'Talk to'. I just think it would be easier then using a whole bunch of colors.

Wizzup?

2006-06-12 03:38:55

Nice Job, make sure you add this to SRL, might want to try to tweak some stuff, but surely worthy(SP) to be added to SRL

phantombmx

2006-06-12 16:33:04

@db - if i didnt use colors, i would be searching aimlessly on the screen and it would be fairly obvious i would be autoing… it does use text.. thats kinda what FindText is for…? also it will search for the color of the NPC.. move to it.. check for text.. thats why you would need a bunch of colors..

@wizzy - thanks :D and yes im tweaking stuff day-by-day.. ;)

Cheesehunk

2006-06-12 20:16:03

One problem, when it clicks the Option tarde, sometimes it tardes a player, if there is one under the NPC.

Maybe use something like if (FindColor(x,y,NPCNameCol,x1,y1,x2,y2)) then Option(

And the x1,y1, etc. would be the area beside the Trade text, and if it is white then the Procedure will recognize it is a player, just so it does not mess up. WOuld require some re-coding though.

Sorry if I didn't explain it well, I can't really type correctly right now.

phantombmx

2006-06-12 22:23:37

yeah i have that covered already… ill have another procedure (or function) that will be like TradeNPC(npcname: string)

WhiteShadow

2006-06-13 00:29:28

findobj works perfectly.

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

function FindNPC(Nx, Ny : Integer; NPCText : String; NPCColor, Tolx, SearchTime : Integer) : Boolean;
var
Count : Integer;
begin
repeat
Count:= Count + 1
if(FindObj(Nx, Ny, NPCText, NPCColor, Tolx))then
begin
Result:= True;
end;
until(Result = True) or (Count >= SearchTime)
end;

But you will probably add alot more to that. :D

phantombmx

2006-06-13 01:26:29

i dont like findobj.. it may work efficiently, but sometimes (rare) it doesnt find it.. plus i am adding TONS more to it ;)

WhiteShadow

2006-06-13 19:02:27

One good thing about SRL is how their is so many procedures/functions for one thing.

Depreciated.Scar and Object.Scar

FindObj3, is excellentent to use with mining, and tree chopping, whilst FindObj for something that may be off to the sides a bit. Plus like 15 + more FindObj types to try out. ;P so try those if you have a hate for FindObj, because FindColorSpiral sucks more than them [when finding things on MainScreen]. :p

phantombmx

2006-06-13 19:11:25

but ive never had a problem with these ;)

just shh and leave other usefull comments :p

WhiteShadow

2006-06-13 19:17:25

Those were useful comments! Well these might be better.

-Remember to implement Option2 and IsUpText, and when it doesn't find the text, use SendArrowSilentWait(a :Byte; WaitTime : Integer); Sometimes it doesn't FindText because the background was to bright or something, as was my case a while back.

- When it still doesn't find NPC on the 2nd try or so Track the dot on the MM? So it would be closer. Do some subtraction on the Coords, as being to close would just enclose it I think.

Now, I will "sshhh".. :p

phantombmx

2006-06-13 19:37:45

now thats a good boy ;) lol jk ill work on it :p