iubantot

npctalk script command like in herc

Recommended Posts

/*==========================================
 * npctalk (sends message to surrounding area)
 * usage: npctalk "<message>"{,"<npc name>"};
 *------------------------------------------*/
BUILDIN(npctalk)
{
	struct npc_data* nd;
	const char *str = script_getstr(st,2);

	if (script_hasdata(st, 3)) {
		nd = npc->name2id(script_getstr(st, 3));
	} else {
		nd = map->id2nd(st->oid);
	}

	if (nd != NULL) {
		char name[NAME_LENGTH], message[256];
		safestrncpy(name, nd->name, sizeof(name));
		strtok(name, "#"); // discard extra name identifier if present
		safesnprintf(message, sizeof(message), "%s : %s", name, str);
		clif->disp_overhead(&nd->bl, message);
	}

	return true;
}

How about implementing this on rathena?

 

 

---------------------------------------

 
*npctalk "<message>"{,"<npc name>"};
 
This command will display a message to the surrounding area as if the NPC 
object running it was a player talking - that is, above their head and in 
the chat window. The display name of the NPC will get appended in front of 
the message to complete the effect.
 
// This will make everyone in the area see the NPC greet the character
// who just invoked it.
npctalk "Hello "+strcharinfo(0)+", how are you?";
npctalk "Hello "+strcharinfo(0)+", how are you?","Another_NPC_Name";
 
---------------------------------------

 

Share this post


Link to post
Share on other sites

We do have the command. However I don't think we support the additional "<npc name>" parameter.

Share this post


Link to post
Share on other sites

We do have the command. However I don't think we support the additional "<npc name>" parameter.

 

 

i guess it's easier to make a dialogue for instance when there is a <npc name> parameter. 

i hope they will add this sometime :))

Share this post


Link to post
Share on other sites

can we expand our npctalk like in herc?

//from herc
*npctalk "<message>"{,"<npc name>"};

This command will display a message to the surrounding area as if the NPC 
object running it was a player talking - that is, above their head and in 
the chat window. The display name of the NPC will get appended in front of 
the message to complete the effect.

	// This will make everyone in the area see the NPC greet the character
	// who just invoked it.
	npctalk "Hello "+strcharinfo(0)+", how are you?";
	npctalk "Hello "+strcharinfo(0)+", how are you?","Another_NPC_Name";

source : https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt

 

i think this is very useful in making instance scripts

Share this post


Link to post
Share on other sites
*npctalk "<message>";

This command will display a message to the surrounding area as if the NPC object

running it was a player talking - that is, above their head and in the chat

window. The display name of the NPC won't get appended in front of the message.

    // This will make everyone in the area see the NPC greet the character

    // who just invoked it.

    npctalk "Hello "+strcharinfo(0)+", how are you?";

 

 

So simply use it like:

npctalk "MyCoolNPCName: ...";

 

Edit:

Just realized that I didn't understand the request. Sorry for that.

Edited by Jey

Share this post


Link to post
Share on other sites

For further reference:

 

You can use this regular expression in Find and Replace (Regex mode) function of Notepad++ to easily convert Herc scripts.

 

Find : npctalk "(.+)",(.+);

Replace with : npctalk $2 + " :  $1";

 

There might be some calls which are not covered by this regex, such as calls with no string literals. Anyways, this should speed you up :)

  • Upvote 1

Share this post


Link to post
Share on other sites