HELP: Talk to an NPC using its ID numbers

All resolved question will be found here. It is recommended that you browse / search through this section first and see if your question has been answered before

Moderators: Moderators, Documentation Writers

Uzah
Human
Human
Posts: 25
Joined: 04 Jun 2011, 18:29
Noob?: Yes
Location: pRO Payon

HELP: Talk to an NPC using its ID numbers

#1 Post by Uzah »

Hi guys,
One quick question. Is there a way you can talk to an NPC using its ID numbers rather than using its coordinates?

We have an event quest in pRO wherein you can only complete by talking twice to an NPC located on a single spot everyday for fourteen consecutive days. The weird thing is, my bot can detect 14 NPCs having the same names but different ID numbers on a single spot; and, only one of them is visible and able to respond. I tried talking to the visible NPC using its coordinates like "do talknpc 229 310 c c n" but the NPC that my bot was talking to did not respond. I am certain that my bot talked to the invisible NPC instead of the visible one. Perhaps the only proficient way to do this is to use the NPC's ID numbers as a variable to talk to a specific NPC.

I surmise that this has something to do with Perl so I would like to seek advice from those who are expert and familiar with the variable needed to commence this. Thanks.
What have you done so far?
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: HELP: Talk to an NPC using its ID numbers

#2 Post by EternalHarvest »

If you know server's NPC ID (displayed in "nl"):

Code: Select all

nl
-----------NPC List-----------
#    Name                         Coordinates   ID
0    Mailbox                      (146, 86)     55561
1    Kafra Employee               (146, 89)     55658
---------------------------------

eval Log::message(Actor::get(pack 'V', 55658)->{binID})
1

talk 1
Kafra Employee: [Kafra Employee]
Kafra Employee: Welcome to the
Kafra Employee: Kafra Corporartion.
Also you would need to use "talk" as "talknpc" only accepts coordinates currently.
Uzah
Human
Human
Posts: 25
Joined: 04 Jun 2011, 18:29
Noob?: Yes
Location: pRO Payon

Re: HELP: Talk to an NPC using its ID numbers

#3 Post by Uzah »

Here it is:

Code: Select all

automacro Listen to Daily Mass {
	timeout 6
	location prontera 218 320
	call {
		$id = 50635
		$x = @eval (Actor::get(pack 'V', $id)->{binID})
		do talk $x
		}
	}
I changed autoTalkCont from 0 to 1 since the NPC does not require you to respond.
I just can't understand this "pack 'V'" function as of this moment but I will learn it eventually.

Thanks a bunch Eternal. You helped me again =)
Last edited by Uzah on 19 Dec 2011, 23:45, edited 1 time in total.
What have you done so far?
User avatar
SkylorD
Moderators
Moderators
Posts: 1197
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil

Re: HELP: Talk to an NPC using its ID numbers

#4 Post by SkylorD »

automacro Listen to Daily Mass {
timeout 6
location prontera 218 320
call {
$id = 50635
$x = @eval (Actor::get(pack 'V', $id)->{binID})
do talk $x
}
}
In your macro,is necessary a 'return' on @eval no ?
So :

Code: Select all

$x = @eval (return Actor::get(pack 'V', $id)->{binID})
do talk $x
Learn rules
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: HELP: Talk to an NPC using its ID numbers

#5 Post by EternalHarvest »

SkylorD wrote:In your macro,is necessary a 'return' on @eval no ?
It's Perl's eval, so:
In both forms, the value returned is the value of the last expression evaluated inside the mini-program; a return statement may be also used, just as with subroutines.
User avatar
SkylorD
Moderators
Moderators
Posts: 1197
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil

Re: HELP: Talk to an NPC using its ID numbers

#6 Post by SkylorD »

I'am confused.I understand that you say,but...
Why in the macros,like this :
automacro ok {
weight > 50%
call {
$hp = @eval (return $::char->{hp})
I know create plugins,and macros.

Is because that a macro works with packet and others with bot information (hp of bot) ?

Thanks for answer 8-)
Learn rules
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: HELP: Talk to an NPC using its ID numbers

#7 Post by EternalHarvest »

SkylorD wrote:Is because that a macro works with packet
Eh?

Everything inside @eval is not macro plugin related (except that it does macro variable substitution first, which can screw it well too).
User avatar
SkylorD
Moderators
Moderators
Posts: 1197
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil

Re: HELP: Talk to an NPC using its ID numbers

#8 Post by SkylorD »

Is because that a macro works with packet

Eh?

Everything inside @eval is not macro plugin related (except that it does macro variable substitution first, which can screw it well too).
Oh,finally.This logic has entered in my brain.
Thanks,Thanks.
Learn rules