summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"),