summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-01-25 13:24:04 -0300
committerJesusaves <cpntb1@ymail.com>2020-01-25 13:24:04 -0300
commit7991c7c91af27fdd65913695b285ee7c422d3665 (patch)
tree67cb04a0e3bc92c6b920c740302f753ee49b37ba
parentfaa48875eae1c360fd00a187787bb07ccbe400f4 (diff)
downloadevol-hercules-7991c7c91af27fdd65913695b285ee7c422d3665.tar.gz
evol-hercules-7991c7c91af27fdd65913695b285ee7c422d3665.tar.bz2
evol-hercules-7991c7c91af27fdd65913695b285ee7c422d3665.tar.xz
evol-hercules-7991c7c91af27fdd65913695b285ee7c422d3665.zip
ChangePlayerMusic()
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script_buildins.c27
-rw-r--r--src/emap/script_buildins.h1
-rw-r--r--src/emap/send.c22
-rw-r--r--src/emap/send.h1
5 files changed, 52 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index b469281..dcb046b 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -167,6 +167,7 @@ HPExport void plugin_init (void)
addScriptCommand("setavataraction", "i", setAvatarAction);
addScriptCommand("clear", "", clear);
addScriptCommand("changemusic", "ss", changeMusic);
+ addScriptCommand("changeplayermusic", "s", changePlayerMusic);
addScriptCommand("setnpcdialogtitle", "s", setNpcDialogTitle);
addScriptCommand("getmapname", "", getMapName);
addScriptCommand("unequipbyid", "i", unequipById);
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index 297fb4e..65ac653 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -954,6 +954,33 @@ BUILDIN(changeMusic)
return true;
}
+// changePlayerMusic(music)
+BUILDIN(changePlayerMusic)
+{
+ const char *const music = script_getstr(st, 2);
+ //ShowWarning("ChangePlayerMusic called\n");
+ if (!music)
+ {
+ ShowWarning("invalid music file\n");
+ script->reportsrc(st);
+ return false;
+ }
+ //ShowWarning("Music defined as %s\n", (char*)(music));
+
+ struct map_session_data *sd = NULL;
+ sd = script->rid2sd(st);
+ if (sd == NULL)
+ {
+ ShowWarning("player not attached\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ //ShowWarning("Sending data\n");
+ send_changemusic(sd->fd, music);
+ return true;
+}
+
BUILDIN(setNpcDialogTitle)
{
const char *const name = script_getstr(st, 2);
diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h
index e8fdcf7..53907bd 100644
--- a/src/emap/script_buildins.h
+++ b/src/emap/script_buildins.h
@@ -40,6 +40,7 @@ BUILDIN(setAvatarDir);
BUILDIN(setAvatarAction);
BUILDIN(clear);
BUILDIN(changeMusic);
+BUILDIN(changePlayerMusic);
BUILDIN(setNpcDialogTitle);
BUILDIN(getMapName);
BUILDIN(unequipById);
diff --git a/src/emap/send.c b/src/emap/send.c
index 08c57b0..df60611 100644
--- a/src/emap/send.c
+++ b/src/emap/send.c
@@ -298,6 +298,28 @@ void send_advmoving(struct unit_data* ud, bool moving, struct block_list *tbl, e
aFree(buf);
}
+
+void send_changemusic(int fd, const char *music)
+{
+ if (!music)
+ return;
+
+ const int sz = (int)strlen(music) + 5;
+ char *buf;
+
+ // Setup the packet
+ CREATE(buf, char, sz);
+ WBUFW (buf, 0) = 0xb05 + evolPacketOffset;
+ WBUFW (buf, 2) = sz;
+ strcpy (WBUFP (buf, 4), music);
+ // Send the packet
+ WFIFOHEAD(fd,sz);
+ memcpy(WFIFOP(fd,0), buf, sz);
+ WFIFOSET(fd,sz);
+ // Free the buffer
+ aFree(buf);
+}
+
void send_changemusic_brodcast(const int map, const char *music)
{
if (!music)
diff --git a/src/emap/send.h b/src/emap/send.h
index b89f1fc..880cdb7 100644
--- a/src/emap/send.h
+++ b/src/emap/send.h
@@ -22,6 +22,7 @@ void send_mapmask(int fd, int mask);
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, bool moving, struct block_list *tbl, enum send_target target);
+void send_changemusic(int fd, const char *music);
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);
void send_join_ack(int fd, const char *const name, int flag);