summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/script_commands.txt16
-rw-r--r--src/map/script.c30
2 files changed, 36 insertions, 10 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index a00756056..efccf799b 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -6631,12 +6631,16 @@ Examples:
*unitwarp(<GID>, <Mapname>, <x>, <y>)
*unitattack(<GID>, <Target ID>)
*unitstop(<GID>)
-*unittalk(<GID>, <Text>)
+*unittalk(<GID>, <Text>{, show_name})
*unitemote(<GID>, <Emote>)
Okay, these commands should be fairly self explaining.
For the emotions, you can look in db/constants.conf for prefixes with e_
PS: unitwarp() supports a <GID> of zero, which causes the executor of the
+PS: unittalk() can receive a third parameter:
+ show_name:
+ true: Shows Unit name like "UnitName : Message" (default)
+ false: Hides Unit name
script to be affected. This can be used with OnTouchNPC to warp
monsters:
@@ -6750,12 +6754,16 @@ A debug message also shows on the console when no events are triggered.
---------------------------------------
-*npctalk("<message>"{, "<npc name>"})
+*npctalk("<message>"{, "<npc name>"{, <show_name>}})
+
+show_npcname values:
+ true: shows npc name (default)
+ false: hide 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.
+the chat window. If show_npcname is true the name of the NPC will get appended in front of
+the message, otherwise the npc name will not be shown.
// 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 5252c0ff0..94a991d06 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15567,12 +15567,13 @@ BUILDIN(message)
/*==========================================
* npctalk (sends message to surrounding area)
- * usage: npctalk "<message>"{,"<npc name>"};
+ * usage: npctalk("<message>"{, "<npc name>"{, <show_name>}});
*------------------------------------------*/
BUILDIN(npctalk)
{
struct npc_data* nd;
const char *str = script_getstr(st,2);
+ bool show_name = true;
if (script_hasdata(st, 3)) {
nd = npc->name2id(script_getstr(st, 3));
@@ -15580,11 +15581,19 @@ BUILDIN(npctalk)
nd = map->id2nd(st->oid);
}
+ if (script_hasdata(st, 4)) {
+ show_name = (script_getnum(st, 4) != 0) ? true : false;
+ }
+
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);
+ if (show_name) {
+ safesnprintf(message, sizeof(message), "%s : %s", name, str);
+ } else {
+ safesnprintf(message, sizeof(message), "%s", str);
+ }
clif->disp_overhead(&nd->bl, message);
}
@@ -20108,15 +20117,20 @@ BUILDIN(unitstop) {
/// Makes the unit say the message
///
-/// unittalk <unit_id>,"<message>";
+/// unittalk(<unit_id>,"<message>"{, show_name});
BUILDIN(unittalk) {
int unit_id;
const char* message;
struct block_list* bl;
+ bool show_name = true;
unit_id = script_getnum(st,2);
message = script_getstr(st, 3);
+ if (script_hasdata(st, 4)) {
+ show_name = (script_getnum(st, 4) != 0) ? true : false;
+ }
+
bl = map->id2bl(unit_id);
if( bl != NULL ) {
struct StringBuf sbuf;
@@ -20125,7 +20139,11 @@ BUILDIN(unittalk) {
safestrncpy(blname, clif->get_bl_name(bl), sizeof(blname));
if(bl->type == BL_NPC)
strtok(blname, "#");
- StrBuf->Printf(&sbuf, "%s : %s", blname, message);
+ if (show_name) {
+ StrBuf->Printf(&sbuf, "%s : %s", blname, message);
+ } else {
+ StrBuf->Printf(&sbuf, "%s", message);
+ }
clif->disp_overhead(bl, StrBuf->Value(&sbuf));
StrBuf->Destroy(&sbuf);
}
@@ -24642,7 +24660,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF2(atcommand,"charcommand","s"), // [MouseJstr]
BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr]
BUILDIN_DEF(message,"vs"), // [MouseJstr]
- BUILDIN_DEF(npctalk,"s?"), // [Valaris]
+ BUILDIN_DEF(npctalk,"s??"), // [Valaris][Murilo BiO]
BUILDIN_DEF(mobcount,"ss"),
BUILDIN_DEF(getlook,"i"),
BUILDIN_DEF(getsavepoint,"i"),
@@ -24771,7 +24789,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(unitwarp,"isii"),
BUILDIN_DEF(unitattack,"iv?"),
BUILDIN_DEF(unitstop,"i"),
- BUILDIN_DEF(unittalk,"is"),
+ BUILDIN_DEF(unittalk,"is?"),
BUILDIN_DEF(unitemote,"ii"),
BUILDIN_DEF(unitskilluseid,"ivi?"), // originally by Qamera [Celest]
BUILDIN_DEF(unitskillusepos,"iviii"), // [Celest]