summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmistry <Equinox1991@gmail.com>2015-08-31 14:29:41 +0800
committerEmistry <Equinox1991@gmail.com>2015-08-31 14:29:41 +0800
commit4b1fad173be8b519fc27676d26c96b0f106cee11 (patch)
treed6aedc964f74ee27ba7a1b57dd2f3ac906022b5b
parentd6498f81cc40784337ae93957245176318a32cfe (diff)
downloadhercules-4b1fad173be8b519fc27676d26c96b0f106cee11.tar.gz
hercules-4b1fad173be8b519fc27676d26c96b0f106cee11.tar.bz2
hercules-4b1fad173be8b519fc27676d26c96b0f106cee11.tar.xz
hercules-4b1fad173be8b519fc27676d26c96b0f106cee11.zip
npctalk support extra npc name parameter.
The command will display the message on the NPC that name specified in the parameter. Useful in quest script that required a lot of different NPC to talk at the same time. Especially instances script.
-rw-r--r--doc/script_commands.txt3
-rw-r--r--src/map/script.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index f2022e347..9d3673490 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -6304,7 +6304,7 @@ A debug message also shows on the console when no events are triggered.
---------------------------------------
-*npctalk "<message>";
+*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
@@ -6314,6 +6314,7 @@ 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";
---------------------------------------
diff --git a/src/map/script.c b/src/map/script.c
index efce0b986..23cf034b8 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -13806,12 +13806,20 @@ BUILDIN(message) {
/*==========================================
* npctalk (sends message to surrounding area)
+ * usage: npctalk "<message>"{,"<npc name>"};
*------------------------------------------*/
BUILDIN(npctalk)
{
- struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid);
+ 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 = (struct npc_data *)map->id2bl(st->oid);
+ }
+
if (nd) {
char name[NAME_LENGTH], message[256];
safestrncpy(name, nd->name, sizeof(name));
@@ -20128,7 +20136,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF2(atcommand,"charcommand","s"), // [MouseJstr]
BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr]
BUILDIN_DEF(message,"ss"), // [MouseJstr]
- BUILDIN_DEF(npctalk,"s"), // [Valaris]
+ BUILDIN_DEF(npctalk,"s?"), // [Valaris]
BUILDIN_DEF(mobcount,"ss"),
BUILDIN_DEF(getlook,"i"),
BUILDIN_DEF(getsavepoint,"i"),