summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorMurilo_Bio <murilopereti@gmail.com>2017-08-25 19:33:49 +0100
committerAsheraf <acheraf1998@gmail.com>2018-06-30 00:32:10 +0100
commita2cfc93a840e51fb1cc1ab132273890c200a9cd3 (patch)
tree83311c678533389e311ff9e56e86405c88ccbbc4 /src/map/script.c
parentfe476d318579755b30bb0ed5f61d402e5fa5754b (diff)
downloadhercules-a2cfc93a840e51fb1cc1ab132273890c200a9cd3.tar.gz
hercules-a2cfc93a840e51fb1cc1ab132273890c200a9cd3.tar.bz2
hercules-a2cfc93a840e51fb1cc1ab132273890c200a9cd3.tar.xz
hercules-a2cfc93a840e51fb1cc1ab132273890c200a9cd3.zip
add option to hide names from unittalk() and npctalk()
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c30
1 files changed, 24 insertions, 6 deletions
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]