npctalk script command now accepts color parameter (#4910)

Co-authored-by: Jittapan Pluemsumran <secret@jittapan.app>
Co-authored-by: Lemongrass3110 <lemongrass3110@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
Sader Fawall 2020-05-10 08:34:00 +02:00 committed by GitHub
parent c4609b19d6
commit 49c4ddf8f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -6596,13 +6596,14 @@ Returns true if the command was executed on the other NPC successfully, false if
--------------------------------------- ---------------------------------------
*npctalk "<message>"{,"<NPC name>","<flag>"}; *npctalk "<message>"{,"<NPC name>",<flag>{,<color>}};
This command will display a message as if the NPC object running it was a player This command will display a message as if the NPC object running it was a player
talking - that is, above their head and in the chat window. 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. The display name of the NPC won't get appended in front of the message.
If the <NPC name> option is given and not empty, then that NPC will display the message, If the <NPC name> option is given and not empty, then that NPC will display the message,
else the attached NPC will display the message. else the attached NPC will display the message,
the color format is in RGB (0xRRGGBB). The color is White by default.
Target for <flag>: Target for <flag>:
- bc_all : Broadcast message is sent server-wide (only in the chat window). - bc_all : Broadcast message is sent server-wide (only in the chat window).

View File

@ -15048,12 +15048,16 @@ BUILDIN_FUNC(npctalk)
{ {
struct npc_data* nd = NULL; struct npc_data* nd = NULL;
const char* str = script_getstr(st,2); const char* str = script_getstr(st,2);
int color = 0xFFFFFF;
if (script_hasdata(st, 3) && strlen(script_getstr(st,3)) > 0) if (script_hasdata(st, 3) && strlen(script_getstr(st,3)) > 0)
nd = npc_name2id(script_getstr(st, 3)); nd = npc_name2id(script_getstr(st, 3));
else else
nd = (struct npc_data *)map_id2bl(st->oid); nd = (struct npc_data *)map_id2bl(st->oid);
if (script_hasdata(st, 5))
color = script_getnum(st, 5);
if (nd != NULL) { if (nd != NULL) {
send_target target = AREA; send_target target = AREA;
char message[CHAT_SIZE_MAX]; char message[CHAT_SIZE_MAX];
@ -15069,12 +15073,12 @@ BUILDIN_FUNC(npctalk)
} }
safesnprintf(message, sizeof(message), "%s", str); safesnprintf(message, sizeof(message), "%s", str);
if (target != SELF) if (target != SELF)
clif_messagecolor(&nd->bl, color_table[COLOR_WHITE], message, false, target); clif_messagecolor(&nd->bl, color, message, true, target);
else { else {
TBL_PC *sd = map_id2sd(st->rid); TBL_PC *sd = map_id2sd(st->rid);
if (sd == NULL) if (sd == NULL)
return SCRIPT_CMD_FAILURE; return SCRIPT_CMD_FAILURE;
clif_messagecolor_target(&nd->bl, color_table[COLOR_WHITE], message, false, target, sd); clif_messagecolor_target(&nd->bl, color, message, true, target, sd);
} }
} }
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_SUCCESS;
@ -24950,7 +24954,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF2(atcommand,"charcommand","s"), // [MouseJstr] BUILDIN_DEF2(atcommand,"charcommand","s"), // [MouseJstr]
BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr] BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr]
BUILDIN_DEF(message,"ss"), // [MouseJstr] BUILDIN_DEF(message,"ss"), // [MouseJstr]
BUILDIN_DEF(npctalk,"s??"), // [Valaris] BUILDIN_DEF(npctalk,"s???"), // [Valaris]
BUILDIN_DEF(chatmes,"s?"), // [Jey] BUILDIN_DEF(chatmes,"s?"), // [Jey]
BUILDIN_DEF(mobcount,"ss"), BUILDIN_DEF(mobcount,"ss"),
BUILDIN_DEF(getlook,"i?"), BUILDIN_DEF(getlook,"i?"),