Bladeren bron

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.

aleos89 8 jaren geleden
bovenliggende
commit
cd5dbe28e4
2 gewijzigde bestanden met toevoegingen van 9 en 3 verwijderingen
  1. 3 1
      doc/script_commands.txt
  2. 6 2
      src/map/script.c

+ 3 - 1
doc/script_commands.txt

@@ -5984,11 +5984,13 @@ It is an approximation of official server script language's 'cmdothernpc'.
 
 ---------------------------------------
 
-*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 the chat 
 window. The display name of the NPC won't get appended in front of the message.
+If the <NPC name> 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.

+ 6 - 2
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);