From c3c009a7e2c3ad40048935de0d0538081cf613be Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 30 Nov 2014 18:50:08 +0300 Subject: Add script command for change npc dialog title. New script command: setnpcdialogtitle newtitle --- src/map/init.c | 1 + src/map/script.c | 13 +++++++++++++ src/map/script.h | 1 + src/map/send.c | 17 +++++++++++++++++ src/map/send.h | 1 + 5 files changed, 33 insertions(+) (limited to 'src') diff --git a/src/map/init.c b/src/map/init.c index 8b5d1fe..a67ddba 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -93,6 +93,7 @@ HPExport void plugin_init (void) addScriptCommand("setavataraction", "i", setAvatarAction); addScriptCommand("clear", "", clear); addScriptCommand("changemusic", "ss", changeMusic); + addScriptCommand("setnpcdialogtitle", "s", setNpcDialogTitle); do_init_langs(); diff --git a/src/map/script.c b/src/map/script.c index 6d9a5d0..da63a29 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -815,3 +815,16 @@ BUILDIN(changeMusic) send_changemusic_brodcast(m, music); return true; } + +BUILDIN(setNpcDialogTitle) +{ + const char *const name = script_getstr(st, 2); + if (!name) + return false; + struct map_session_data *sd = script->rid2sd (st); + if (!sd) + return false; + + send_changenpc_title(sd, st->oid, name); + return true; +} diff --git a/src/map/script.h b/src/map/script.h index 97b8f51..b238e92 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -38,5 +38,6 @@ BUILDIN(setAvatarDir); BUILDIN(setAvatarAction); BUILDIN(clear); BUILDIN(changeMusic); +BUILDIN(setNpcDialogTitle); #endif // EVOL_MAP_SCRIPT diff --git a/src/map/send.c b/src/map/send.c index be913e0..029df93 100644 --- a/src/map/send.c +++ b/src/map/send.c @@ -166,3 +166,20 @@ void send_changemusic_brodcast(const int map, const char *music) strcpy ((char *)WBUFP (buf, 4), music); clif->send (buf, sz, &bl, ALL_SAMEMAP); } + +void send_changenpc_title (struct map_session_data *sd, const int npcId, const char *name) +{ + if (!sd || !name) + return; + + const int fd = sd->fd; + const int len = strlen (name); + const int sz = len + 5 + 4 + 2; + WFIFOHEAD (fd, sz); + WFIFOW (fd, 0) = 0xb06; + WFIFOW (fd, 2) = sz; + WFIFOL (fd, 4) = npcId; + WFIFOW (fd, 8) = len; + strcpy (WFIFOP (fd, 10), name); + WFIFOSET (fd, sz); +} diff --git a/src/map/send.h b/src/map/send.h index 438347a..0993624 100644 --- a/src/map/send.h +++ b/src/map/send.h @@ -13,5 +13,6 @@ void send_mapmask_brodcast(const int map, const int mask); void send_mob_info(struct block_list* bl1, struct block_list* bl2, enum send_target target); void send_advmoving(struct unit_data* ud, struct block_list *tbl, enum send_target target); void send_changemusic_brodcast(const int map, const char *music); +void send_changenpc_title (struct map_session_data *sd, const int npcId, const char *name); #endif // EVOL_MAP_PC -- cgit v1.2.3-70-g09d2