From 2a1492c2bdc85f2917775987d4f72660fcfed4b0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 26 Oct 2015 20:35:19 +0300 Subject: Add script command setskin. For set npc dialog skin on client. --- src/emap/init.c | 1 + src/emap/script.c | 12 ++++++++++++ src/emap/script.h | 1 + src/emap/send.c | 17 +++++++++++++++++ src/emap/send.h | 3 +++ 5 files changed, 34 insertions(+) diff --git a/src/emap/init.c b/src/emap/init.c index 703b7d6..5251cbc 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -133,6 +133,7 @@ HPExport void plugin_init (void) addScriptCommand("setcells", "siiiiis", setCells); addScriptCommand("delcells", "s", delCells); addScriptCommand("setmount", "i", setMount); + addScriptCommand("setskin", "s", setSkin); do_init_langs(); diff --git a/src/emap/script.c b/src/emap/script.c index d64f190..b8f54a0 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -1777,3 +1777,15 @@ BUILDIN(setMount) send_pc_info(&sd->bl, &sd->bl, AREA); return true; } + +BUILDIN(setSkin) +{ + if (!st->oid) + return false; + + getSD() + + const char *skin = script_getstr(st, 2); + send_pc_skin(sd->fd, st->oid, skin); + return true; +} diff --git a/src/emap/script.h b/src/emap/script.h index edbd010..5db3897 100644 --- a/src/emap/script.h +++ b/src/emap/script.h @@ -63,5 +63,6 @@ BUILDIN(chatJoin); BUILDIN(checkNpcCell); BUILDIN(setCells); BUILDIN(delCells); +BUILDIN(setSkin); #endif // EVOL_MAP_SCRIPT diff --git a/src/emap/send.c b/src/emap/send.c index 815464a..3984421 100644 --- a/src/emap/send.c +++ b/src/emap/send.c @@ -436,3 +436,20 @@ void send_setwall_single(int fd, int m, int layer, int x1, int y1, int x2, int y mapindex->getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name,(char*)WFIFOP(fd, 18)); WFIFOSET(fd, 34); } + +void send_pc_skin(int fd, int npcId, const char *const skin) +{ + if (!skin) + return; + struct SessionExt *data = session_get(fd); + if (!data || data->clientVersion < 15) + return; + + const int sz = strlen(skin) + 9; + WFIFOHEAD (fd, sz); + WFIFOW(fd, 0) = 0xb1c; + WFIFOW(fd, 2) = sz; + WFIFOL(fd, 4) = npcId; + strcpy((char*)WFIFOP (fd, 8), skin); + WFIFOSET(fd, sz); +} diff --git a/src/emap/send.h b/src/emap/send.h index 7634f1a..2d6ca56 100644 --- a/src/emap/send.h +++ b/src/emap/send.h @@ -45,5 +45,8 @@ void send_setwall_single(int fd, int x1, int y1, int x2, int y2, int mask); +void send_pc_skin(int fd, + int npcId, + const char *const skin); #endif // EVOL_MAP_SEND -- cgit v1.2.3-60-g2f50