diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/init.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 43 | ||||
-rw-r--r-- | src/map/script.h | 1 | ||||
-rw-r--r-- | src/map/send.c | 22 | ||||
-rw-r--r-- | src/map/send.h | 1 |
5 files changed, 68 insertions, 1 deletions
diff --git a/src/map/init.c b/src/map/init.c index 09c0a10..b74a3b4 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -44,7 +44,7 @@ HPExport void plugin_init (void) addScriptCommand("setcamnpc", "*", setCamNpc); addScriptCommand("restorecam", "", restoreCam); - addScriptCommand("npctalk3", "s", dummy); + addScriptCommand("npctalk3", "s", npcTalk3); addScriptCommand("closedialog", "", dummy); addScriptCommand("shop", "s", dummy); addScriptCommand("getitemlink", "s", dummyStr); diff --git a/src/map/script.c b/src/map/script.c index fffaa70..54bf82c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -85,3 +85,46 @@ BUILDIN(restoreCam) send_npccommand(sd, st->oid, 3); return 0; } + +BUILDIN(npcTalk3) +{ + getSD(); + + char *str; + char *msg; + struct npc_data *nd = NULL; + + if (script_hasdata(st, 3)) + { + nd = npc->name2id (script_getstr(st, 2)); + str = script_getstr(st, 3); + } + else + { + nd = (struct npc_data *) map->id2bl (st->oid); + str = script_getstr(st, 2); + } + + if (!nd) + return 0; + + msg = nd->name; +// +++ after restore lang support need translate here +/* + if (sd) + msg = (char*)lang_pctrans (nd->name, sd); + else + msg = nd->name; +*/ + if (strlen(str) + strlen(msg) > 450) + return 0; + + if (nd) + { + char message[500]; + strcpy (message, msg); + strcat (message, " : "); + strcat (message, str); + send_local_message (sd, &(nd->bl), message); + } +} diff --git a/src/map/script.h b/src/map/script.h index 7bd1abe..9116aaa 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -10,5 +10,6 @@ BUILDIN(getLang); BUILDIN(setLang); BUILDIN(setCamNpc); BUILDIN(restoreCam); +BUILDIN(npcTalk3); #endif // EVOL_MAP_SCRIPT diff --git a/src/map/send.c b/src/map/send.c index 9218a21..ccfb052 100644 --- a/src/map/send.c +++ b/src/map/send.c @@ -46,3 +46,25 @@ void send_npccommand2 (struct map_session_data *sd, int npcId, int cmd, int id, WFIFOW (fd, 14) = y; WFIFOSET (fd, 16); } + +void send_local_message(int fd, struct block_list* bl, const char* msg) +{ + unsigned short msg_len = strlen(msg) + 1; + uint8 buf[256]; + if (!bl) + return; + + int len = sizeof(buf) - 8; + if (msg_len > len) + { + ShowWarning("clif_message: Truncating too long message '%s' (len=%u).\n", msg, msg_len); + msg_len = len; + } + + WFIFOHEAD (fd, msg_len + 8); + WBUFW (fd, 0) = 0x8d; + WBUFW (fd, 2) = msg_len + 8; + WBUFL (fd, 4) = bl->id; + safestrncpy((char*)WBUFP(fd, 8), msg, msg_len); + WFIFOSET (fd, msg_len + 8); +} diff --git a/src/map/send.h b/src/map/send.h index 6a324b9..d9c6daa 100644 --- a/src/map/send.h +++ b/src/map/send.h @@ -6,5 +6,6 @@ void send_npccommand (struct map_session_data *sd, int npcId, int cmd); void send_npccommand2 (struct map_session_data *sd, int npcId, int cmd, int id, int x, int y); +void send_local_message(int fd, struct block_list* bl, const char* msg); #endif // EVOL_MAP_PC |