From cd5dbe28e45c36e7a40f02db83644d4bbd16cad4 Mon Sep 17 00:00:00 2001 From: aleos89 Date: Mon, 29 Aug 2016 11:56:19 -0400 Subject: [PATCH] Adjusted the npctalk script command * Now has an optional parameter of NPC name. - If supplied, it will display over that NPC's head, else it will use the attached NPC. --- doc/script_commands.txt | 4 +++- src/map/script.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 6d3d68eb51..1634026ed7 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -5984,11 +5984,13 @@ It is an approximation of official server script language's 'cmdothernpc'. --------------------------------------- -*npctalk ""; +*npctalk ""{,""}; 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. +If the option is given, then that NPC will display the message, else +the attached NPC will display the message. // This will make everyone in the area see the NPC greet the character // who just invoked it. diff --git a/src/map/script.c b/src/map/script.c index 6f1e0d0e31..99056495e4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14280,10 +14280,14 @@ BUILDIN_FUNC(message) *------------------------------------------*/ BUILDIN_FUNC(npctalk) { - struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid); + struct npc_data* nd = NULL; const char* str = script_getstr(st,2); - if (nd) { + if (script_hasdata(st, 3)) + nd = npc_name2id(script_getstr(st, 3)); + else + nd = (struct npc_data *)map_id2bl(st->oid); + if (nd != NULL) { char message[256]; safesnprintf(message, sizeof(message), "%s", str); clif_disp_overhead(&nd->bl, message);